Merged in bugfix/PMCORE-2333 (pull request #7820)

PMCORE-2333 Web entry can still be used/create cases when process is inactive

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Roly Rudy Gutierrez Pinto
2021-03-02 18:47:14 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 42 additions and 12 deletions

View File

@@ -26051,6 +26051,12 @@ msgstr "The user roles for attribute {0} has been modified, if you proceed to sa
msgid "The username or email is incorrect" msgid "The username or email is incorrect"
msgstr "The username or email is incorrect" msgstr "The username or email is incorrect"
# TRANSLATION
# LABEL/ID_THE_WEBSITE_CAN_NOT_BE_REACHED
#: LABEL/ID_THE_WEBSITE_CAN_NOT_BE_REACHED
msgid "The website can not be reached"
msgstr "The website can not be reached"
# TRANSLATION # TRANSLATION
# LABEL/ID_THIS_MONTH # LABEL/ID_THIS_MONTH
#: LABEL/ID_THIS_MONTH #: LABEL/ID_THIS_MONTH

View File

@@ -61297,6 +61297,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED','en','The upload of PHP files was disabled please contact the system administrator.','2018-04-20') , ( 'LABEL','ID_THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED','en','The upload of PHP files was disabled please contact the system administrator.','2018-04-20') ,
( 'LABEL','ID_THE_USER_ROLES_FOR_ATTRIBUTE_HAS_BEEN_DELETED_PLEASE_CONFIRM','en','The user roles for attribute {0} has been modified, if you proceed to save this attribute, all information for users stored in the attribute will be deleted for the removed role, please confirm.','2020-12-15') , ( 'LABEL','ID_THE_USER_ROLES_FOR_ATTRIBUTE_HAS_BEEN_DELETED_PLEASE_CONFIRM','en','The user roles for attribute {0} has been modified, if you proceed to save this attribute, all information for users stored in the attribute will be deleted for the removed role, please confirm.','2020-12-15') ,
( 'LABEL','ID_THE_USERNAME_EMAIL_IS_INCORRECT','en','The username or email is incorrect','2018-01-18') , ( 'LABEL','ID_THE_USERNAME_EMAIL_IS_INCORRECT','en','The username or email is incorrect','2018-01-18') ,
( 'LABEL','ID_THE_WEBSITE_CAN_NOT_BE_REACHED','en','The website can not be reached','2020-03-02') ,
( 'LABEL','ID_THIS_MONTH','en','This Month','2014-01-15') , ( 'LABEL','ID_THIS_MONTH','en','This Month','2014-01-15') ,
( 'LABEL','ID_THIS_QUARTER','en','This quarter','2014-01-15') , ( 'LABEL','ID_THIS_QUARTER','en','This quarter','2014-01-15') ,
( 'LABEL','ID_THIS_WEEK','en','This Week','2014-01-15') , ( 'LABEL','ID_THIS_WEEK','en','This Week','2014-01-15') ,

View File

@@ -1,4 +1,7 @@
<?php <?php
use ProcessMaker\Model\Process;
/** /**
* This page is the WebEntry Access Point. * This page is the WebEntry Access Point.
*/ */
@@ -18,6 +21,14 @@ $configuration = $conf->getConfiguration(
$userInformationFormat = isset($outResult['format']) ? $outResult['format'] : $userInformationFormat = isset($outResult['format']) ? $outResult['format'] :
'@lastName, @firstName (@userName)'; '@lastName, @firstName (@userName)';
$webEntryModel = \WebEntryPeer::retrieveByPK($weUid); $webEntryModel = \WebEntryPeer::retrieveByPK($weUid);
if (!Process::isActive($webEntryModel->getProUid(), 'PRO_UID')) {
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', [
'MESSAGE' => G::LoadTranslation('ID_THE_WEBSITE_CAN_NOT_BE_REACHED')
]);
G::RenderPage('publish', 'blank');
exit();
}
?> ?>
<html> <html>
<head> <head>

View File

@@ -8,20 +8,16 @@ use G;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use RBAC; use RBAC;
/**
* Class Process
* @package ProcessMaker\Model
*
* Represents a business process object in the system.
*/
class Process extends Model class Process extends Model
{ {
// Set our table name // Set our table name
protected $table = 'PROCESS'; protected $table = 'PROCESS';
protected $primaryKey = 'PRO_ID'; protected $primaryKey = 'PRO_ID';
// Our custom timestamp columns // Our custom timestamp columns
const CREATED_AT = 'PRO_CREATE_DATE'; const CREATED_AT = 'PRO_CREATE_DATE';
const UPDATED_AT = 'PRO_UPDATE_DATE'; const UPDATED_AT = 'PRO_UPDATE_DATE';
// Columns to see in the process list // Columns to see in the process list
public $listColumns = [ public $listColumns = [
'PRO_UID', 'PRO_UID',
@@ -244,10 +240,10 @@ class Process extends Model
$processes = array_column($privateProcesses, 'PRO_ID'); $processes = array_column($privateProcesses, 'PRO_ID');
Process::whereIn('PRO_ID', $processes) Process::whereIn('PRO_ID', $processes)
->update(['PRO_TYPE_PROCESS' => 'PUBLIC']); ->update(['PRO_TYPE_PROCESS' => 'PUBLIC']);
Process::where('PRO_CREATE_USER', $userUid) Process::where('PRO_CREATE_USER', $userUid)
->update(['PRO_CREATE_USER' => $admin]); ->update(['PRO_CREATE_USER' => $admin]);
} }
/** /**
@@ -278,11 +274,12 @@ class Process extends Model
$sort = 'PRO_CREATE_DATE', $sort = 'PRO_CREATE_DATE',
$counterByProcess = true, $counterByProcess = true,
$subProcess = false $subProcess = false
) { )
{
$process = new Process(); $process = new Process();
$rows = $process->getListColumns(); $rows = $process->getListColumns();
if (!in_array($sort, $rows)) { if (!in_array($sort, $rows)) {
throw new Exception('The column ' . $sort . ' does not exist'); throw new Exception('The column ' . $sort . ' does not exist');
} }
// Select rows // Select rows
$query = Process::query()->select($rows)->noStatus(); $query = Process::query()->select($rows)->noStatus();
@@ -340,7 +337,7 @@ class Process extends Model
$mask = isset($systemConf->aConfig['dateFormat']) ? $systemConf->aConfig['dateFormat'] : ''; $mask = isset($systemConf->aConfig['dateFormat']) ? $systemConf->aConfig['dateFormat'] : '';
// Prepare the final result // Prepare the final result
$results->transform(function ($item, $key) use ($counterByProcess, $systemConf, $mask){ $results->transform(function ($item, $key) use ($counterByProcess, $systemConf, $mask) {
// Get the counter related to the status // Get the counter related to the status
// todo: those counters needs to remove when the PMCORE-2314 was implemented // todo: those counters needs to remove when the PMCORE-2314 was implemented
$item['CASES_COUNT_DRAFT'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 1) : 0; $item['CASES_COUNT_DRAFT'] = $counterByProcess ? Application::getCountByProUid($item['PRO_UID'], 1) : 0;
@@ -358,7 +355,7 @@ class Process extends Model
$item['PROJECT_TYPE'] = ($bpmnProcess) ? 'bpmn' : 'classic'; $item['PROJECT_TYPE'] = ($bpmnProcess) ? 'bpmn' : 'classic';
// Get the process type: PUBLIC or PRIVATE // Get the process type: PUBLIC or PRIVATE
$item['PRO_TYPE_PROCESS'] = ($item['PRO_TYPE_PROCESS'] == 'PUBLIC') ? G::LoadTranslation("ID_PUBLIC") : G::LoadTranslation("ID_PRIVATE");; $item['PRO_TYPE_PROCESS'] = ($item['PRO_TYPE_PROCESS'] == 'PUBLIC') ? G::LoadTranslation("ID_PUBLIC") : G::LoadTranslation("ID_PRIVATE");
// Get information about the owner, with the format defined // Get information about the owner, with the format defined
$creatorOwner = $systemConf->usersNameFormat($item['USR_USERNAME'], $item['USR_FIRSTNAME'], $item['USR_LASTNAME']); $creatorOwner = $systemConf->usersNameFormat($item['USR_USERNAME'], $item['USR_FIRSTNAME'], $item['USR_LASTNAME']);
@@ -445,6 +442,21 @@ class Process extends Model
// Return processes // Return processes
return $query->get()->toArray(); return $query->get()->toArray();
}
/**
* Return true if process is active, false otherwise.
* @param int|string $proId
* @param string $key
* @return bool
*/
public static function isActive($proId, string $key = 'PRO_ID'): bool
{
$process = Process::query()
->where($key, $proId)
->where('PRO_STATUS', 'ACTIVE')
->get()
->first();
return !empty($process);
} }
} }