diff --git a/gulliver/system/class.menu.php b/gulliver/system/class.menu.php index 82ce5fa03..e539f2417 100644 --- a/gulliver/system/class.menu.php +++ b/gulliver/system/class.menu.php @@ -283,7 +283,7 @@ class Menu */ public function DisableOptionId($id) { - if (array_search($id, $this->Id)) { + if (array_search($id, $this->Id) !== FALSE) { $this->Enabled[array_search($id, $this->Id)] = 0; } } diff --git a/gulliver/system/class.rbac.php b/gulliver/system/class.rbac.php index 9d5938f4b..b24f0104f 100644 --- a/gulliver/system/class.rbac.php +++ b/gulliver/system/class.rbac.php @@ -70,9 +70,66 @@ class RBAC public $singleSignOn = false; private static $instance = null; + public $authorizedActions = array(); public function __construct () { + $this->authorizedActions = array( + 'users_Ajax.php' => array( + 'availableUsers' => array('PM_FACTORY'), + 'assign' => array('PM_FACTORY'), + 'changeView' => array(), + 'ofToAssign' => array('PM_FACTORY'), + 'usersGroup' => array('PM_FACTORY'), + 'canDeleteUser' => array('PM_USERS'), + 'deleteUser' => array('PM_USERS'), + 'changeUserStatus' => array('PM_USERS'), + 'availableGroups' => array('PM_USERS'), + 'assignedGroups' => array('PM_USERS'), + 'assignGroupsToUserMultiple' => array('PM_USERS'), + 'deleteGroupsToUserMultiple' => array('PM_USERS'), + 'authSources' => array('PM_USERS'), + 'loadAuthSourceByUID' => array('PM_USERS'), + 'updateAuthServices' => array('PM_USERS'), + 'usersList' => array('PM_USERS'), + 'updatePageSize' => array(), + 'summaryUserData' => array('PM_USERS'), + 'verifyIfUserAssignedAsSupervisor' => array('PM_USERS') + ), + 'skin_Ajax.php' => array( + 'updatePageSize' => array(), + 'skinList' => array('PM_SETUP_SKIN'), + 'newSkin' => array('PM_SETUP_SKIN'), + 'importSkin' => array('PM_SETUP_SKIN'), + 'exportSkin' => array('PM_SETUP_SKIN'), + 'deleteSkin' => array('PM_SETUP_SKIN'), + 'addTarFolder' => array('PM_SETUP_SKIN'), + 'copy_skin_folder' => array('PM_SETUP_SKIN'), + 'deleteSkin' => array('PM_SETUP_SKIN') + ), + 'processes_DownloadFile.php' => array( + 'downloadFileHash' => array('PM_FACTORY') + ), + 'processProxy.php' => array( + 'categoriesList' => array(), + 'getCategoriesList' => array(), + 'saveProcess' => array('PM_FACTORY'), + 'changeStatus' => array(), + 'changeDebugMode' => array(), + 'getUsers' => array(), + 'getGroups' => array(), + 'assignActorsTask' => array(), + 'removeActorsTask' => array(), + 'getActorsTask' => array(), + 'getProcessDetail' => array(), + 'getProperties' => array(), + 'saveProperties' => array(), + 'getCaledarList' => array(), + 'getPMVariables' => array(), + 'generateBpmn' => array() + ) + + ); } /** @@ -1445,5 +1502,36 @@ class RBAC } } } + /** + * This function verify if the user allows to the file with a specific action + * If the action is not defined in the authorizedActions we give the allow + * @param string $file + * @param string $action + * + * @return void + */ + public function allows($file, $action) + { + $access = false; + if (isset($this->authorizedActions[$file][$action])) { + $permissions = $this->authorizedActions[$file][$action]; + $totalPermissions = count($permissions); + $countAccess = 0; + foreach ($permissions as $key => $value) { + if ($this->userCanAccess($value) == 1) { + $countAccess++; + } + } + //Check if the user has all permissions that needed + if ($countAccess == $totalPermissions) { + $access = true; + } + } + + if (!$access) { + G::header('Location: /errors/error403.php'); + die(); + } + } } diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 529f875a1..e1a5bc940 100644 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -3348,7 +3348,7 @@ class Cases * @return integer */ - public function getCurrentDelegation($sApplicationUID = '', $sUserUID = '') + public function getCurrentDelegation($sApplicationUID = '', $sUserUID = '', $onlyOpenThreads = false) { $oCriteria = new Criteria(); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); @@ -3363,7 +3363,9 @@ class Cases //if the user is not in the task, we need to return a valid del index, so we are returning the latest delindex $oCriteria = new Criteria(); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); - $oCriteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); + if ($onlyOpenThreads) { + $oCriteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); + } $oCriteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $oApplication = AppDelegationPeer::doSelectOne($oCriteria); if (!is_null($oApplication)) { diff --git a/workflow/engine/classes/class.pmTable.php b/workflow/engine/classes/class.pmTable.php index 89f836af5..d7319dd07 100644 --- a/workflow/engine/classes/class.pmTable.php +++ b/workflow/engine/classes/class.pmTable.php @@ -54,6 +54,7 @@ class PmTable private $db; private $alterTable = true; private $keepData = false; + public $tableClassName = ''; public function __construct ($tableName = null) { @@ -67,7 +68,7 @@ class PmTable /** * Set oldTableName to pmTable - * + * * @param string $oldTableName */ public function setOldTableName($oldTableName) @@ -672,7 +673,7 @@ class PmTable $table = $this->oldTableName; $tableBackup = str_replace($this->tableName, $this->oldTableName, $tableBackup); $sqlTableBackup = str_replace($this->tableName, $this->oldTableName, $sqlTableBackup); - + //Delete backup if exists $rs = $stmt->executeQuery(str_replace($table, $tableBackup, $queryStack["drop"])); @@ -955,6 +956,7 @@ class PmTable $additionalTable = AdditionalTablesPeer::retrieveByPK($additionalTableUid); $tableName = $additionalTable->getAddTabName(); + $this->tableClassName = $additionalTable->getAddTabClassName(); $additionalTable = new AdditionalTables(); $tableData = $additionalTable->load($additionalTableUid, true); @@ -990,8 +992,12 @@ class PmTable $listTablePeer = 'ListInboxPeer'; break; } - - $oCriteria->addJoin($listTablePeer::APP_UID, $tableName.'.APP_UID', Criteria::LEFT_JOIN); + //Some PM tables don’t have the APP NUMBER column; but if exists, we must use it + if (in_array($tableName.'.APP_NUMBER', $oCriteria->getSelectColumns())) { + $oCriteria->addJoin($listTablePeer::APP_NUMBER, $tableName.'.APP_NUMBER', Criteria::LEFT_JOIN); + } else { + $oCriteria->addJoin($listTablePeer::APP_UID, $tableName.'.APP_UID', Criteria::LEFT_JOIN); + } } return $oCriteria; } diff --git a/workflow/engine/classes/model/ListInbox.php b/workflow/engine/classes/model/ListInbox.php index 9230c2b92..43501ce33 100644 --- a/workflow/engine/classes/model/ListInbox.php +++ b/workflow/engine/classes/model/ListInbox.php @@ -16,7 +16,8 @@ require_once 'classes/model/om/BaseListInbox.php'; // @codingStandardsIgnoreStart class ListInbox extends BaseListInbox { - // @codingStandardsIgnoreEnd + private $additionalClassName = ''; + /** * Create List Inbox Table * @@ -384,19 +385,27 @@ class ListInbox extends BaseListInbox self::create($data, $isSelfService); } - public function loadFilters(&$criteria, $filters) + /** + * This function add restriction in the query related to the filters + * @param Criteria $criteria, must be contain only select of columns + * @param array $filters + * @param array $additionalColumns information about the new columns related to custom cases list + * @throws PropelException + */ + public function loadFilters(&$criteria, $filters, $additionalColumns = array()) { - $action = isset($filters['action']) ? $filters['action'] : ""; - $usrUid = isset($filters['usr_uid']) ? $filters['usr_uid'] : ""; - $filter = isset($filters['filter']) ? $filters['filter'] : ""; - $search = isset($filters['search']) ? $filters['search'] : ""; - $process = isset($filters['process']) ? $filters['process'] : ""; - $category = isset($filters['category']) ? $filters['category'] : ""; - $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ""; - $dateTo = isset($filters['dateTo']) ? $filters['dateTo'] : ""; - $filterStatus = isset($filters['filterStatus']) ? $filters['filterStatus'] : ""; - $newestthan = isset($filters['newestthan']) ? $filters['newestthan'] : ''; - $oldestthan = isset($filters['oldestthan']) ? $filters['oldestthan'] : ''; + $action = isset($filters['action']) ? $filters['action'] : ''; + $usrUid = isset($filters['usr_uid']) ? $filters['usr_uid'] : ''; + $filter = isset($filters['filter']) ? $filters['filter'] : ''; + $search = isset($filters['search']) ? $filters['search'] : ''; + $caseLink = isset($filters['caseLink']) ? $filters['caseLink'] : ''; + $process = isset($filters['process']) ? $filters['process'] : ''; + $category = isset($filters['category']) ? $filters['category'] : ''; + $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ''; + $dateTo = isset($filters['dateTo']) ? $filters['dateTo'] : ''; + $filterStatus = isset($filters['filterStatus']) ? $filters['filterStatus'] : ''; + $newestthan = isset($filters['newestthan']) ? $filters['newestthan'] : ''; + $oldestthan = isset($filters['oldestthan']) ? $filters['oldestthan'] : ''; //Check the inbox to call switch ($action) { @@ -463,21 +472,14 @@ class ListInbox extends BaseListInbox //Filter Search if ($search != '') { - $criteria->add( - $criteria->getNewCriterion(ListInboxPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListInboxPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListInboxPeer::APP_PRO_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListInboxPeer::APP_UID, $search, Criteria::EQUAL) - ->addOr( - $criteria->getNewCriterion(ListInboxPeer::APP_NUMBER, $search, Criteria::EQUAL) - ) - ) - ) - ) - ); + //Check if we need to search to the APP_UID + if (!empty($caseLink)) { + $criteria->add(ListInboxPeer::APP_UID, $search, Criteria::EQUAL); + } else { + //If we have additional tables configured in the custom cases list, prepare the variables for search + $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + } } //Filter Process Id @@ -504,17 +506,20 @@ class ListInbox extends BaseListInbox } /** - * @param $usr_uid - * @param array $filters + * This function get the information in the corresponding cases list + * @param string $usr_uid, must be show cases related to this user + * @param array $filters for apply in the result * @param null $callbackRecord - * @return array + * @return array $data * @throws PropelException */ public function loadList($usr_uid, $filters = array(), $callbackRecord = null) { $pmTable = new PmTable(); - $criteria = $pmTable->addPMFieldsToList('todo'); - + $list = isset($filters['action']) ? $filters['action'] : ""; + $criteria = $pmTable->addPMFieldsToList($list); + $this->additionalClassName = $pmTable->tableClassName; + $additionalColumns = $criteria->getSelectColumns(); $filters['usr_uid'] = $usr_uid; $criteria->addSelectColumn(ListInboxPeer::APP_UID); @@ -542,7 +547,7 @@ class ListInbox extends BaseListInbox $criteria->addSelectColumn(UsersPeer::USR_LASTNAME); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->addJoin(ListInboxPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); - self::loadFilters($criteria, $filters); + self::loadFilters($criteria, $filters, $additionalColumns); $sort = (!empty($filters['sort'])) ? ListInboxPeer::TABLE_NAME.'.'.$filters['sort'] : @@ -615,7 +620,7 @@ class ListInbox extends BaseListInbox return isset($aRow[$fieldName]) ? $aRow[$fieldName] : null; } - /** + /** * Returns the number of cases of a user * @param string $usrUid * @param array $filters diff --git a/workflow/engine/classes/model/ListParticipatedLast.php b/workflow/engine/classes/model/ListParticipatedLast.php index 6407718c5..c5ca29955 100644 --- a/workflow/engine/classes/model/ListParticipatedLast.php +++ b/workflow/engine/classes/model/ListParticipatedLast.php @@ -14,7 +14,8 @@ require_once 'classes/model/om/BaseListParticipatedLast.php'; */ class ListParticipatedLast extends BaseListParticipatedLast { - // @codingStandardsIgnoreEnd + private $additionalClassName = ''; + /** * Create List Participated History Table. * @@ -234,10 +235,18 @@ class ListParticipatedLast extends BaseListParticipatedLast } } - public function loadFilters(&$criteria, $filters) + /** + * This function add restriction in the query related to the filters + * @param Criteria $criteria, must be contain only select of columns + * @param array $filters + * @param array $additionalColumns information about the new columns related to custom cases list + * @throws PropelException + */ + public function loadFilters(&$criteria, $filters, $additionalColumns = array()) { $filter = isset($filters['filter']) ? $filters['filter'] : ''; $search = isset($filters['search']) ? $filters['search'] : ''; + $caseLink = isset($filters['caseLink']) ? $filters['caseLink'] : ''; $process = isset($filters['process']) ? $filters['process'] : ''; $category = isset($filters['category']) ? $filters['category'] : ''; $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ''; @@ -271,25 +280,24 @@ class ListParticipatedLast extends BaseListParticipatedLast break; } + //Filter Search if ($search != '') { - $criteria->add( - $criteria->getNewCriterion(ListParticipatedLastPeer::APP_TITLE, '%'.$search.'%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListParticipatedLastPeer::APP_TAS_TITLE, '%'.$search.'%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListParticipatedLastPeer::APP_UID, $search, Criteria::EQUAL) - ->addOr( - $criteria->getNewCriterion(ListParticipatedLastPeer::APP_NUMBER, $search, Criteria::EQUAL) - ) - ) - ) - ); + //Check if we need to search to the APP_UID + if (!empty($caseLink)) { + $criteria->add(ListParticipatedLastPeer::APP_UID, $search, Criteria::EQUAL); + } else { + //If we have additional tables configured in the custom cases list, prepare the variables for search + $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + } } + //Filter Process Id if ($process != '') { $criteria->add(ListParticipatedLastPeer::PRO_UID, $process, Criteria::EQUAL); } + //Filter Category if ($category != '') { $criteria->addSelectColumn(ProcessPeer::PRO_CATEGORY); $aConditions = array(); @@ -308,10 +316,21 @@ class ListParticipatedLast extends BaseListParticipatedLast } } + /** + * This function get the information in the corresponding cases list + * @param string $usr_uid, must be show cases related to this user + * @param array $filters for apply in the result + * @param null $callbackRecord + * @param string $appUid related to the specific case + * @return array $data + * @throws PropelException + */ public function loadList($usr_uid, $filters = array(), $callbackRecord = null, $appUid = '') { $pmTable = new PmTable(); $criteria = $pmTable->addPMFieldsToList('sent'); + $this->additionalClassName = $pmTable->tableClassName; + $additionalColumns = $criteria->getSelectColumns(); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_UID); $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_INDEX); @@ -343,7 +362,7 @@ class ListParticipatedLast extends BaseListParticipatedLast $criteria->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL); } - self::loadFilters($criteria, $filters); + self::loadFilters($criteria, $filters, $additionalColumns); $sort = (!empty($filters['sort'])) ? ListParticipatedLastPeer::TABLE_NAME.'.'.$filters['sort'] : diff --git a/workflow/engine/classes/model/ListPaused.php b/workflow/engine/classes/model/ListPaused.php index 939ae1c2e..8844a9363 100644 --- a/workflow/engine/classes/model/ListPaused.php +++ b/workflow/engine/classes/model/ListPaused.php @@ -17,7 +17,8 @@ require_once 'classes/model/om/BaseListPaused.php'; // @codingStandardsIgnoreStart class ListPaused extends BaseListPaused { - // @codingStandardsIgnoreEnd + private $additionalClassName = ''; + /** * Create List Paused Table * @@ -212,13 +213,21 @@ class ListPaused extends BaseListPaused } } - public function loadFilters(&$criteria, $filters) + /** + * This function add restriction in the query related to the filters + * @param Criteria $criteria, must be contain only select of columns + * @param array $filters + * @param array $additionalColumns information about the new columns related to custom cases list + * @throws PropelException + */ + public function loadFilters(&$criteria, $filters, $additionalColumns = array()) { - $filter = isset($filters['filter']) ? $filters['filter'] : ""; - $search = isset($filters['search']) ? $filters['search'] : ""; - $process = isset($filters['process']) ? $filters['process'] : ""; - $category = isset($filters['category']) ? $filters['category'] : ""; - $filterStatus = isset($filters['filterStatus']) ? $filters['filterStatus'] : ""; + $filter = isset($filters['filter']) ? $filters['filter'] : ''; + $search = isset($filters['search']) ? $filters['search'] : ''; + $caseLink = isset($filters['caseLink']) ? $filters['caseLink'] : ''; + $process = isset($filters['process']) ? $filters['process'] : ''; + $category = isset($filters['category']) ? $filters['category'] : ''; + $filterStatus = isset($filters['filterStatus']) ? $filters['filterStatus'] : ''; //Filter Read Unread All switch ($filter) { @@ -230,25 +239,24 @@ class ListPaused extends BaseListPaused break; } + //Filter Search if ($search != '') { - $criteria->add( - $criteria->getNewCriterion(ListPausedPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListPausedPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListPausedPeer::APP_UID, $search, Criteria::EQUAL) - ->addOr( - $criteria->getNewCriterion(ListPausedPeer::APP_NUMBER, $search, Criteria::EQUAL) - ) - ) - ) - ); + //Check if we need to search to the APP_UID + if (!empty($caseLink)) { + $criteria->add(ListPausedPeer::APP_UID, $search, Criteria::EQUAL); + } else { + //If we have additional tables configured in the custom cases list, prepare the variables for search + $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + } } + //Filter Process Id if ($process != '') { $criteria->add(ListPausedPeer::PRO_UID, $process, Criteria::EQUAL); } + //Filter Category if ($category != '') { $criteria->addSelectColumn(ProcessPeer::PRO_CATEGORY); $aConditions = array(); @@ -258,11 +266,21 @@ class ListPaused extends BaseListPaused } } + /** + * This function get the information in the corresponding cases list + * @param string $usr_uid, must be show cases related to this user + * @param array $filters for apply in the result + * @param null $callbackRecord + * @return array $data + * @throws PropelException + */ public function loadList($usr_uid, $filters = array(), $callbackRecord = null) { $resp = array(); $pmTable = new PmTable(); $criteria = $pmTable->addPMFieldsToList('paused'); + $this->additionalClassName = $pmTable->tableClassName; + $additionalColumns = $criteria->getSelectColumns(); $criteria->addSelectColumn(ListPausedPeer::APP_UID); $criteria->addSelectColumn(ListPausedPeer::USR_UID); @@ -287,7 +305,7 @@ class ListPaused extends BaseListPaused $criteria->addSelectColumn(ListPausedPeer::DEL_DUE_DATE); $criteria->addSelectColumn(ListPausedPeer::DEL_PRIORITY); $criteria->add(ListPausedPeer::USR_UID, $usr_uid, Criteria::EQUAL); - self::loadFilters($criteria, $filters); + self::loadFilters($criteria, $filters, $additionalColumns); $sort = (!empty($filters['sort'])) ? ListPausedPeer::TABLE_NAME.'.'.$filters['sort'] : "APP_PAUSED_DATE"; $dir = isset($filters['dir']) ? $filters['dir'] : "ASC"; diff --git a/workflow/engine/classes/model/ListUnassigned.php b/workflow/engine/classes/model/ListUnassigned.php index 5e20fd6e1..f5a7836ab 100644 --- a/workflow/engine/classes/model/ListUnassigned.php +++ b/workflow/engine/classes/model/ListUnassigned.php @@ -17,8 +17,9 @@ require_once 'classes/model/om/BaseListUnassigned.php'; // @codingStandardsIgnoreStart class ListUnassigned extends BaseListUnassigned { - // @codingStandardsIgnoreEnd + private $additionalClassName = ''; private $total = 0; + /** * Create List Unassigned Table * @@ -165,34 +166,41 @@ class ListUnassigned extends BaseListUnassigned return true; } - public function loadFilters(&$criteria, $filters) + /** + * This function add restriction in the query related to the filters + * @param Criteria $criteria, must be contain only select of columns + * @param array $filters + * @param array $additionalColumns information about the new columns related to custom cases list + * @throws PropelException + */ + public function loadFilters(&$criteria, $filters, $additionalColumns = array()) { - $filter = isset($filters['filter']) ? $filters['filter'] : ""; - $search = isset($filters['search']) ? $filters['search'] : ""; - $process = isset($filters['process']) ? $filters['process'] : ""; - $category = isset($filters['category']) ? $filters['category'] : ""; - $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ""; - $dateTo = isset($filters['dateTo']) ? $filters['dateTo'] : ""; + $filter = isset($filters['filter']) ? $filters['filter'] : ''; + $search = isset($filters['search']) ? $filters['search'] : ''; + $caseLink = isset($filters['caseLink']) ? $filters['caseLink'] : ''; + $process = isset($filters['process']) ? $filters['process'] : ''; + $category = isset($filters['category']) ? $filters['category'] : ''; + $dateFrom = isset($filters['dateFrom']) ? $filters['dateFrom'] : ''; + $dateTo = isset($filters['dateTo']) ? $filters['dateTo'] : ''; + //Filter Search if ($search != '') { - $criteria->add( - $criteria->getNewCriterion(ListUnassignedPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListUnassignedPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE) - ->addOr( - $criteria->getNewCriterion(ListUnassignedPeer::APP_UID, $search, Criteria::EQUAL) - ->addOr( - $criteria->getNewCriterion(ListUnassignedPeer::APP_NUMBER, $search, Criteria::EQUAL) - ) - ) - ) - ); + //Check if we need to search to the APP_UID + if (!empty($caseLink)) { + $criteria->add(ListUnassignedPeer::APP_UID, $search, Criteria::EQUAL); + } else { + //If we have additional tables configured in the custom cases list, prepare the variables for search + $casesList = new \ProcessMaker\BusinessModel\Cases(); + $casesList->getSearchCriteriaListCases($criteria, __CLASS__ . 'Peer', $search, $this->additionalClassName, $additionalColumns); + } } + //Filter Process Id if ($process != '') { $criteria->add(ListUnassignedPeer::PRO_UID, $process, Criteria::EQUAL); } + //Filter Category if ($category != '') { $criteria->addSelectColumn(ProcessPeer::PRO_CATEGORY); $aConditions = array(); @@ -202,12 +210,22 @@ class ListUnassigned extends BaseListUnassigned } } + /** + * This function get the information in the corresponding cases list + * @param string $usr_uid, must be show cases related to this user + * @param array $filters for apply in the result + * @param null $callbackRecord + * @return array $data + * @throws PropelException + */ public function loadList($usr_uid, $filters = array(), $callbackRecord = null) { $resp = array(); $pmTable = new PmTable(); $tasks = $this->getSelfServiceTasks($usr_uid); $criteria = $pmTable->addPMFieldsToList('unassigned'); + $this->additionalClassName = $pmTable->tableClassName; + $additionalColumns = $criteria->getSelectColumns(); $criteria->addSelectColumn(ListUnassignedPeer::APP_UID); $criteria->addSelectColumn(ListUnassignedPeer::DEL_INDEX); @@ -282,7 +300,7 @@ class ListUnassigned extends BaseListUnassigned } //Apply some filters - self::loadFilters($criteria, $filters); + self::loadFilters($criteria, $filters, $additionalColumns); $sort = (!empty($filters['sort'])) ? ListUnassignedPeer::TABLE_NAME.'.'.$filters['sort'] : "LIST_UNASSIGNED.DEL_DELEGATE_DATE"; diff --git a/workflow/engine/classes/model/ObjectPermission.php b/workflow/engine/classes/model/ObjectPermission.php index 1319e6456..b483918db 100644 --- a/workflow/engine/classes/model/ObjectPermission.php +++ b/workflow/engine/classes/model/ObjectPermission.php @@ -409,5 +409,39 @@ class ObjectPermission extends BaseObjectPermission } return $result; } + + /** + * Verify if the user has a objectPermission for some process + * + * @param string $usrUid the uid of the user + * @param int $typeRelation + * + * @return array + */ + public function objectPermissionPerUser($usrUid, $typeRelation = 1) + { + $criteria = new Criteria("workflow"); + $criteria->addSelectColumn(ObjectPermissionPeer::USR_UID); + $criteria->addSelectColumn(ObjectPermissionPeer::PRO_UID); + $criteria->add(ObjectPermissionPeer::OP_USER_RELATION, $typeRelation, Criteria::EQUAL); + $criteria->add(ObjectPermissionPeer::USR_UID, $usrUid, Criteria::EQUAL); + $doSelectRS = ObjectPermissionPeer::doSelectRS($criteria); + $doSelectRS->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $doSelectRS->next(); + $objectPermision = $doSelectRS->getRow(); + $data = array(); + if (isset($objectPermision["USR_UID"])) { + $criteria = new Criteria("workflow"); + $criteria->addSelectColumn(ProcessPeer::PRO_TITLE); + $criteria->add(ProcessPeer::PRO_UID, $objectPermision["PRO_UID"], Criteria::EQUAL); + $doSelectRS = ProcessPeer::doSelectRS($criteria); + $doSelectRS->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $doSelectRS->next(); + $content = $doSelectRS->getRow(); + $data['PRO_TITLE'] = $content["PRO_TITLE"]; + $data['PRO_UID'] = $objectPermision["PRO_UID"]; + } + return $data; + } } diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index e2dc8c93d..79c68c507 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -15187,6 +15187,12 @@ msgstr "SYSTEM INSTALLATION FAILED" msgid "A problem occurred during the installation of the system. Please, uninstall the partial installation and try again." msgstr "A problem occurred during the installation of the system. Please, uninstall the partial installation and try again." +# TRANSLATION +# LABEL/ID_PROCESSMAKER_ALREADY_INSTALLED +#: LABEL/ID_PROCESSMAKER_ALREADY_INSTALLED +msgid "ProcessMaker is already installed." +msgstr "ProcessMaker is already installed." + # TRANSLATION # LABEL/ID_LICENSE_EMPTY #: LABEL/ID_LICENSE_EMPTY diff --git a/workflow/engine/controllers/designer.php b/workflow/engine/controllers/designer.php index 24d370c97..f80d6c52f 100644 --- a/workflow/engine/controllers/designer.php +++ b/workflow/engine/controllers/designer.php @@ -29,6 +29,18 @@ class Designer extends Controller $client = $this->getClientCredentials(); if (isset($httpData->tracker_designer) && $httpData->tracker_designer == 1) { + try { + if (!isset($_SESSION['CASE']) && !isset($_SESSION['PIN'])) { + throw (new \Exception( + \G::LoadTranslation('ID_CASE_NOT_EXISTS') . "\n" . \G::LoadTranslation('ID_PIN_INVALID') + )); + } + \ProcessMaker\BusinessModel\Light\Tracker::authentication($_SESSION['CASE'], $_SESSION['PIN']); + } catch (\Exception $e) { + Bootstrap::registerMonolog('CaseTracker', 400, $e->getMessage(), [], SYS_SYS, 'processmaker.log'); + \G::header('Location: /errors/error403.php'); + die(); + } $client["tracker_designer"] = 1; } diff --git a/workflow/engine/controllers/installer.php b/workflow/engine/controllers/installer.php index dbe1b0572..36a2ebe3b 100644 --- a/workflow/engine/controllers/installer.php +++ b/workflow/engine/controllers/installer.php @@ -38,10 +38,18 @@ class Installer extends Controller public function index ($httpData) { + if (file_exists(FILE_PATHS_INSTALLED)) { + $this->setJSVar('messageError', G::LoadTranslation('ID_PROCESSMAKER_ALREADY_INSTALLED')); + $this->includeExtJS('installer/stopInstall'); + $this->setView('installer/mainStopInstall'); + G::RenderPage('publish', 'extJs'); + return; + } if ((strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') && (file_exists($this->path_shared . 'partner.info'))) { - $this->includeExtJS( 'installer/stopInstall'); - $this->setView( 'installer/mainStopInstall' ); - G::RenderPage( 'publish', 'extJs' ); + $this->setJSVar('messageError', G::LoadTranslation('ID_NO_INSTALL')); + $this->includeExtJS('installer/stopInstall'); + $this->setView('installer/mainStopInstall'); + G::RenderPage('publish', 'extJs'); return; } diff --git a/workflow/engine/controllers/processProxy.php b/workflow/engine/controllers/processProxy.php index 3e3607644..90cf66bd9 100644 --- a/workflow/engine/controllers/processProxy.php +++ b/workflow/engine/controllers/processProxy.php @@ -3,6 +3,12 @@ class ProcessProxy extends HttpProxyController { + public function call ($name) + { + global $RBAC; + $RBAC->allows(basename(__FILE__), $name); + parent::call($name); + } /** * get Process Categories List with defailt value (empty option) and -All- aoption */ @@ -50,53 +56,6 @@ class ProcessProxy extends HttpProxyController } $sProUid = $project->getUid(); - - -// require_once 'classes/model/Task.php'; -// G::LoadClass( 'processMap' ); -// $oProcessMap = new ProcessMap(); -// -// $httpData->PRO_TITLE = trim( $httpData->PRO_TITLE ); -// -// try { -// if (! isset( $httpData->PRO_UID )) { -// if (Process::existsByProTitle( $httpData->PRO_TITLE )) { -// $result = array ('success' => false,'msg' => G::LoadTranslation( 'ID_SAVE_PROCESS_ERROR' ),'errors' => array ('PRO_TITLE' => G::LoadTranslation( 'ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, Array ('PRO_TITLE' => $httpData->PRO_TITLE -// ) ) -// ) -// ); -// print G::json_encode( $result ); -// exit( 0 ); -// } -// -// $processData['USR_UID'] = $_SESSION['USER_LOGGED']; -// $processData['PRO_TITLE'] = $httpData->PRO_TITLE; -// $processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION; -// $processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY; -// -// $sProUid = $oProcessMap->createProcess( $processData ); -// -// //call pluginsx -// $oData['PRO_UID'] = $sProUid; -// $oData['PRO_TEMPLATE'] = isset( $httpData->PRO_TEMPLATE ) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : ''; -// $oData['PROCESSMAP'] = $oProcessMap; -// -// $oPluginRegistry = & PMPluginRegistry::getSingleton(); -// $oPluginRegistry->executeTriggers( PM_NEW_PROCESS_SAVE, $oData ); -// -// } else { -// //$oProcessMap->updateProcess($_POST['form']); -// $sProUid = $httpData->PRO_UID; -// } -// -// //Save Calendar ID for this process -// if (isset( $httpData->PRO_CALENDAR )) { -// G::LoadClass( "calendar" ); -// $calendarObj = new Calendar(); -// $calendarObj->assignCalendarTo( $sProUid, $httpData->PRO_CALENDAR, 'PROCESS' ); -// } -// - $this->success = true; $this->PRO_UID = $sProUid; $this->msg = G::LoadTranslation( 'ID_CREATE_PROCESS_SUCCESS' ); diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 6cede1d6e..be616d70f 100644 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -4027,6 +4027,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_ROLE_NAME_NOT_EMPTY','en','The ''Name'' field can not be empty.','2014-01-15') , ( 'LABEL','ID_TITLE_NO_INSTALL','en','SYSTEM INSTALLATION FAILED','2014-01-15') , ( 'LABEL','ID_NO_INSTALL','en','A problem occurred during the installation of the system. Please, uninstall the partial installation and try again.','2014-01-15') , +( 'LABEL','ID_PROCESSMAKER_ALREADY_INSTALLED','en','ProcessMaker is already installed.','2017-05-31') , ( 'LABEL','ID_LICENSE_EMPTY','en','Can not find any license','2014-01-15') , ( 'LABEL','ID_ADD_LICENSE','en','Please add a new license','2014-01-15') , ( 'LABEL','ID_DEFAULT_CALENDAR','en','Default Calendar','2014-01-15') , diff --git a/workflow/engine/methods/groups/groups_Ajax.php b/workflow/engine/methods/groups/groups_Ajax.php index 9e6bc8b6b..aeb565bc5 100644 --- a/workflow/engine/methods/groups/groups_Ajax.php +++ b/workflow/engine/methods/groups/groups_Ajax.php @@ -125,7 +125,7 @@ switch ($_POST['action']) { $result->success = true; $result->groups = $arrData; $result->total_groups = $data['totalCount']; - + G::header('Content-Type: application/json'); echo G::json_encode( $result ); break; case 'exitsGroupName': @@ -253,6 +253,7 @@ switch ($_POST['action']) { while ($oDataset->next()) { $arrData[] = $oDataset->getRow(); } + G::header('Content-Type: application/json'); echo '{success: true, members: ' . G::json_encode( $arrData ) . ', total_users: ' . $totalRows . '}'; break; case 'availableMembers': @@ -311,6 +312,7 @@ switch ($_POST['action']) { while ($oDataset->next()) { $arrData[] = $oDataset->getRow(); } + G::header('Content-Type: application/json'); echo '{success: true, members: ' . G::json_encode( $arrData ) . ', total_users: ' . $totalRows . '}'; break; case 'assignUsersToGroupsMultiple': diff --git a/workflow/engine/methods/processes/processes_DownloadFile.php b/workflow/engine/methods/processes/processes_DownloadFile.php index 7cd355876..fee9c9c9b 100644 --- a/workflow/engine/methods/processes/processes_DownloadFile.php +++ b/workflow/engine/methods/processes/processes_DownloadFile.php @@ -1,26 +1,5 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ +$RBAC->allows(basename(__FILE__), 'downloadFileHash'); if (!isset($_GET["file_hash"])) { throw new Exception("Invalid Request, param 'file_hash' was not sent."); @@ -28,26 +7,16 @@ if (!isset($_GET["file_hash"])) { $httpStream = new \ProcessMaker\Util\IO\HttpStream(); $outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP; -$filename = urldecode(base64_decode($_GET["file_hash"])); -$fileExtension = pathinfo($outputDir . $filename, PATHINFO_EXTENSION); +$fileName = urldecode(base64_decode($_GET["file_hash"])); +$processFile = $outputDir . $fileName; -if (!file_exists($outputDir . $filename)) { - throw new Exception("Error, couldn't find request file: $filename"); +//Verify if the file related to process exist in the corresponding path +$fileInformation = pathinfo($processFile); +$processFile = $outputDir . $fileInformation['basename']; +if (!file_exists($processFile)) { + throw new Exception("Error, couldn't find request file: $fileName"); } - -$httpStream->loadFromFile($outputDir . $filename); +$fileExtension = $fileInformation['extension']; +$httpStream->loadFromFile($processFile); $httpStream->setHeader("Content-Type", "application/$fileExtension"); $httpStream->send(); - -// ************* DEPRECATED (it will be removed soon) ********************************* -//add more security, and catch any error or exception -//$sFileName = $_GET['p'] . '.pm'; -//$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm'; -//$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName; -// -//if (file_exists( $file )) { -// rename( $file, $filex ); -//} -// -//$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName; -//G::streamFile( $realPath, true ); diff --git a/workflow/engine/methods/setup/skin_Ajax.php b/workflow/engine/methods/setup/skin_Ajax.php index 2f3fe89a8..065510958 100644 --- a/workflow/engine/methods/setup/skin_Ajax.php +++ b/workflow/engine/methods/setup/skin_Ajax.php @@ -1,8 +1,4 @@ xssFilterHard($_REQUEST); - if (! isset( $_REQUEST['action'] )) { $res['success'] = false; $res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION'); @@ -17,8 +13,7 @@ if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['ac print G::json_encode( $res ); die(); } -$restrictedFunctions = array ('copy_skin_folder','addTarFolder' -); +$restrictedFunctions = array ('copy_skin_folder','addTarFolder'); if (in_array( $_REQUEST['action'], $restrictedFunctions )) { $res['success'] = false; $res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION_NOT_EXIST'); @@ -28,7 +23,7 @@ if (in_array( $_REQUEST['action'], $restrictedFunctions )) { $functionName = $_REQUEST['action']; $functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array (); - +$RBAC->allows(basename(__FILE__), $functionName); $functionName(); function updatePageSize () @@ -166,7 +161,7 @@ function newSkin ($baseSkin = 'classic') $configFileFinal = PATH_CUSTOM_SKINS . $skinFolder . PATH_SEP . 'config.xml'; $xmlConfiguration = file_get_contents( $configFileOriginal ); - + $workspace = ($_REQUEST['workspace'] == 'global') ? '' : SYS_SYS; $xmlConfigurationObj = G::xmlParser($xmlConfiguration); @@ -356,9 +351,9 @@ function exportSkin ($skinToExport = "") $response['success'] = true; $response['message'] = $skinTar; G::auditLog("ExportSkin", "Skin Name: ".$skinName); - + $response = $filter->xssFilterHard($response); - + print_r( G::json_encode( $response ) ); } catch (Exception $e) { $response['success'] = false; @@ -374,7 +369,7 @@ function deleteSkin () $filter = new InputFilter(); try { $_REQUEST['SKIN_FOLDER_ID'] = $filter->xssFilterHard($_REQUEST['SKIN_FOLDER_ID']); - + if (! (isset( $_REQUEST['SKIN_FOLDER_ID'] ))) { throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) )); } @@ -400,9 +395,9 @@ function deleteSkin () function streamSkin () { - $skinTar = $_REQUEST['file']; + $skinTar = basename($_REQUEST['file']); $bDownload = true; - G::streamFile( $skinTar, $bDownload, basename( $skinTar ) ); + G::streamFile(PATH_CUSTOM_SKINS . $skinTar, $bDownload, $skinTar); @unlink( $fileTar ); } diff --git a/workflow/engine/methods/users/users_Ajax.php b/workflow/engine/methods/users/users_Ajax.php index 6e3961caf..e9ebbc1c2 100644 --- a/workflow/engine/methods/users/users_Ajax.php +++ b/workflow/engine/methods/users/users_Ajax.php @@ -1,34 +1,6 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ try { - G::LoadSystem('inputfilter'); - $filter = new InputFilter(); - $_GET = $filter->xssFilterHard($_GET); - $_POST = $filter->xssFilterHard($_POST); - $_REQUEST = $filter->xssFilterHard($_REQUEST); - global $RBAC; switch ($RBAC->userCanAccess('PM_LOGIN')) { case - 2: @@ -47,38 +19,15 @@ try { $_POST = $_POST['form']; } if (isset($_REQUEST['function'])) { - //$value= $_POST['function']; $value = get_ajax_value('function'); } else { - //$value= $_POST['functions']; $value = get_ajax_value('functions'); } + + $RBAC->allows(basename(__FILE__), $value); switch ($value) { - case 'verifyUsername': - //print_r($_POST); die; - $_POST['sOriginalUsername'] = get_ajax_value('sOriginalUsername'); - $_POST['sUsername'] = get_ajax_value('sUsername'); - if ($_POST['sOriginalUsername'] == $_POST['sUsername']) { - echo '0'; - } else { - require_once 'classes/model/Users.php'; - G::LoadClass('Users'); - $oUser = new Users(); - $oCriteria = $oUser->loadByUsername($_POST['sUsername']); - $oDataset = UsersPeer::doSelectRs($oCriteria, Propel::getDbConnection('workflow_ro')); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - //print_r($aRow); die; - //if (!$aRow) - if (!is_array($aRow)) { - echo '0'; - } else { - echo '1'; - } - } - break; case 'availableUsers': + //Classic process: list of users to assign in the task G::LoadClass('processMap'); $oProcessMap = new ProcessMap(); global $G_PUBLISH; @@ -87,6 +36,7 @@ try { G::RenderPage('publish', 'raw'); break; case 'assign': + //Classic process: assign users and groups in the task G::LoadClass('tasks'); $oTasks = new Tasks(); switch ((int) $_POST['TU_RELATION']) { @@ -103,6 +53,7 @@ try { } break; case 'ofToAssign': + //Classic process: remove users and groups related a task G::LoadClass('tasks'); $oTasks = new Tasks(); switch ((int) $_POST['TU_RELATION']) { @@ -117,36 +68,11 @@ try { } break; case 'changeView': + //Classic process: set variable for users and groups Ad hoc $_SESSION['iType'] = $_POST['TU_TYPE']; break; - case 'deleteGroup': - G::LoadClass('groups'); - $oGroup = new Groups(); - $oGroup->removeUserOfGroup($_POST['GRP_UID'], $_POST['USR_UID']); - $_GET['sUserUID'] = $_POST['USR_UID']; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('view', 'users/users_Tree'); - G::RenderPage('publish', 'raw'); - break; - case 'showUserGroupInterface': - $_GET['sUserUID'] = $_POST['sUserUID']; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('view', 'users/users_AssignGroup'); - G::RenderPage('publish', 'raw'); - break; - case 'showUserGroups': - $_GET['sUserUID'] = $_POST['sUserUID']; - $G_PUBLISH = new Publisher(); - $G_PUBLISH->AddContent('view', 'users/users_Tree'); - G::RenderPage('publish', 'raw'); - break; - case 'assignUserToGroup': - G::LoadClass('groups'); - $oGroup = new Groups(); - $oGroup->addUserToGroup($_POST['GRP_UID'], $_POST['USR_UID']); - echo '