From 3b6e2416ef9f72b6c410ee22df027f5cd3571d97 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Thu, 19 Oct 2017 09:46:48 -0400 Subject: [PATCH 1/3] HOR-3841 --- .../engine/content/translations/english/processmaker.en.po | 6 ++++++ workflow/engine/data/mysql/insert.sql | 3 ++- .../src/ProcessMaker/BusinessModel/ProcessPermissions.php | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index bf7890e93..6f16a77e4 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -27869,6 +27869,12 @@ msgstr "NOT IMPORTED" msgid "CANNOT IMPORT" msgstr "CANNOT IMPORT" +# TRANSLATION +# LABEL/ID_SELECT_USER_OR_GROUP +#: LABEL/ID_SELECT_USER_OR_GROUP +msgid "Please select the name of a user or a group in the Group or User field" +msgstr "Please select the name of a user or a group in the Group or User field" + # additionalTables/additionalTablesData.xml?ADD_TAB_NAME # additionalTables/additionalTablesData.xml #: text - ADD_TAB_NAME diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 524d1777b..1ae33de85 100644 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -6185,7 +6185,8 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_CASE_ROUTED_TO','en','Case routed to','2017-06-02'), ( 'LABEL','ID_IMPORTED','en','IMPORTED','2017-10-03'), ( 'LABEL','ID_NOT_IMPORTED','en','NOT IMPORTED','2017-10-03'), -( 'LABEL','ID_CANNOT_IMPORT','en','CANNOT IMPORT','2017-10-03'); +( 'LABEL','ID_CANNOT_IMPORT','en','CANNOT IMPORT','2017-10-03'), +( 'LABEL','ID_SELECT_USER_OR_GROUP','en','Please select the name of a user or a group in the Group or User field','2017-10-19'); INSERT INTO ISO_LOCATION (IC_UID,IL_UID,IL_NAME,IL_NORMAL_NAME,IS_UID) VALUES ('AD','','',' ','') , diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php index d66b6e197..c16555636 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php @@ -381,7 +381,7 @@ class ProcessPermissions { $usr_uid = trim($usr_uid); if ($usr_uid == '') { - throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('usr_uid','')))); + throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); } $oUsers = new \Users(); if (!($oUsers->userExists($usr_uid))) { @@ -403,7 +403,7 @@ class ProcessPermissions { $grp_uid = trim($grp_uid); if ($grp_uid == '') { - throw (new \Exception(\G::LoadTranslation("ID_GROUP_NOT_EXIST", array('grp_uid','')))); + throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); } $oGroup = new \Groupwf(); if (!($oGroup->GroupwfExists($grp_uid))) { From 11f01b8453a19230149ed634eb927fdf4f81b317 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Thu, 19 Oct 2017 11:44:31 -0400 Subject: [PATCH 2/3] HOR-3841 --- .../translations/english/processmaker.en.po | 12 ++--- .../BusinessModel/ProcessPermissions.php | 7 ++- .../Api/Project/ProcessPermissions.php | 44 +++++-------------- 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 6f16a77e4..09b966a0e 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -1747,6 +1747,12 @@ msgstr "Databases Source List" msgid "Changes saved" msgstr "Changes saved" +# TRANSLATION +# LABEL/ID_SELECT_USER_OR_GROUP +#: LABEL/ID_SELECT_USER_OR_GROUP +msgid "Please select the name of a user or a group in the Group or User field" +msgstr "Please select the name of a user or a group in the Group or User field" + # TRANSLATION # LABEL/ID_EMAILS #: LABEL/ID_EMAILS @@ -27869,12 +27875,6 @@ msgstr "NOT IMPORTED" msgid "CANNOT IMPORT" msgstr "CANNOT IMPORT" -# TRANSLATION -# LABEL/ID_SELECT_USER_OR_GROUP -#: LABEL/ID_SELECT_USER_OR_GROUP -msgid "Please select the name of a user or a group in the Group or User field" -msgstr "Please select the name of a user or a group in the Group or User field" - # additionalTables/additionalTablesData.xml?ADD_TAB_NAME # additionalTables/additionalTablesData.xml #: text - ADD_TAB_NAME diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php index c16555636..ca5a754c1 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php @@ -224,6 +224,9 @@ class ProcessPermissions if ($opUid != '') { $opUid = $this->validateOpUid($opUid); } + if (empty($data['USR_UID']) || $data['USR_UID'] === "null") { + throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); + } if ($data['OP_USER_RELATION'] == "1") { $this->validateUsrUid($data['USR_UID']); } else { @@ -381,7 +384,7 @@ class ProcessPermissions { $usr_uid = trim($usr_uid); if ($usr_uid == '') { - throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); + throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('usr_uid','')))); } $oUsers = new \Users(); if (!($oUsers->userExists($usr_uid))) { @@ -403,7 +406,7 @@ class ProcessPermissions { $grp_uid = trim($grp_uid); if ($grp_uid == '') { - throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); + throw (new \Exception(\G::LoadTranslation("ID_GROUP_NOT_EXIST", array('grp_uid','')))); } $oGroup = new \Groupwf(); if (!($oGroup->GroupwfExists($grp_uid))) { diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/ProcessPermissions.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/ProcessPermissions.php index 974f18116..7b023a8da 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/ProcessPermissions.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/ProcessPermissions.php @@ -58,44 +58,22 @@ class ProcessPermissions extends Api } /** + * Creates a new Process Permission for a project. + * + * @url POST /:prj_uid/process-permission/ + * @status 201 + * * @param string $prj_uid {@min 1} {@max 32} * @param array $request_data * - * @param string $usr_uid {@from body} {@min 1} {@max 32} - * @param string $op_user_relation {@from body} {@choice 1,2} - * @param string $op_case_status {@from body} {@choice ALL,DRAFT,TO_DO,PAUSED,COMPLETED} - * @param string $op_participate {@from body} {@choice 0,1} - * @param string $op_obj_type {@from body} {@choice ANY,DYNAFORM,ATTACHMENT,INPUT,OUTPUT,CASES_NOTES,MSGS_HISTORY,SUMMARY_FORM} - * @param string $op_action {@from body} {@choice VIEW,BLOCK,DELETE,RESEND} - * @param string $tas_uid {@from body} - * @param string $op_task_source {@from body} - * @param string $dynaforms {@from body} - * @param string $inputs {@from body} - * @param string $outputs {@from body} - * - * @author Brayan Pereyra (Cochalo) - * @copyright Colosa - Bolivia - * * @return array - * - * @url POST /:prj_uid/process-permission/ - * @status 201 + * @throws RestException + * + * @access protected + * @class AccessControl {@permission PM_FACTORY} */ - public function doPostProcessPermission( - $prj_uid, - $request_data, - $usr_uid, - $op_user_relation, - $op_case_status, - $op_participate, - $op_obj_type, - $op_action, - $tas_uid = '', - $op_task_source = '', - $dynaforms = '', - $inputs = '', - $outputs = '' - ) { + public function doPostProcessPermission($prj_uid, $request_data) + { try { $hiddenFields = array('task_target', 'group_user', 'task_source', 'object_type', 'object', 'participated', 'action' From 4ec3e2a90a8a70732f2ba81a0892377b61944bf6 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Thu, 19 Oct 2017 15:54:42 -0400 Subject: [PATCH 3/3] HOR-3841 --- .../src/ProcessMaker/BusinessModel/ProcessPermissions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php index ca5a754c1..862907bd8 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessPermissions.php @@ -5,6 +5,7 @@ use Behat\Behat\Exception\Exception; use \G; use \Criteria; use \ObjectPermissionPeer; +use \Exception as StandardException; /** * @author Brayan Pereyra (Cochalo) @@ -224,8 +225,8 @@ class ProcessPermissions if ($opUid != '') { $opUid = $this->validateOpUid($opUid); } - if (empty($data['USR_UID']) || $data['USR_UID'] === "null") { - throw (new \Exception(\G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); + if (empty($data['USR_UID']) || (isset($data['USR_UID']) && $data['USR_UID'] === "null")) { + throw (new StandardException(G::LoadTranslation("ID_SELECT_USER_OR_GROUP"))); } if ($data['OP_USER_RELATION'] == "1") { $this->validateUsrUid($data['USR_UID']);