PMCORE-670 Error with unassign permissions in PROCESSMAKER_ADMIN role

This commit is contained in:
Roly Gutierrez
2022-04-21 11:32:29 -04:00
parent 52e884f30a
commit a20c93bb0b
4 changed files with 78 additions and 62 deletions

View File

@@ -26561,6 +26561,12 @@ msgstr "The mime type does not correspond to the permitted extension, please ver
msgid "The change might cause data loss in the PM table. Do you want to continue?" msgid "The change might cause data loss in the PM table. Do you want to continue?"
msgstr "The change might cause data loss in the PM table. Do you want to continue?" msgstr "The change might cause data loss in the PM table. Do you want to continue?"
# TRANSLATION
# LABEL/ID_THE_PERMISSION_CAN_NOT_BE_UNASSIGNED_FROM_THIS_ROLE
#: LABEL/ID_THE_PERMISSION_CAN_NOT_BE_UNASSIGNED_FROM_THIS_ROLE
msgid "The permission can not be unassigned from this role."
msgstr "The permission can not be unassigned from this role."
# TRANSLATION # TRANSLATION
# LABEL/ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED # LABEL/ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED
#: LABEL/ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED #: LABEL/ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED

View File

@@ -61404,6 +61404,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_THE_MAXIMUM_VALUE_OF_THIS_FIELD_IS','en','The maximum value of this field is {0}.','2019-02-26') , ( 'LABEL','ID_THE_MAXIMUM_VALUE_OF_THIS_FIELD_IS','en','The maximum value of this field is {0}.','2019-02-26') ,
( 'LABEL','ID_THE_MIMETYPE_EXTENSION_ERROR','en','The mime type does not correspond to the permitted extension, please verify your file.','2018-10-02') , ( 'LABEL','ID_THE_MIMETYPE_EXTENSION_ERROR','en','The mime type does not correspond to the permitted extension, please verify your file.','2018-10-02') ,
( 'LABEL','ID_THE_NAME_CHANGE_MAY_CAUSE_DATA_LOSS','en','The change might cause data loss in the PM table. Do you want to continue?','2017-03-30') , ( 'LABEL','ID_THE_NAME_CHANGE_MAY_CAUSE_DATA_LOSS','en','The change might cause data loss in the PM table. Do you want to continue?','2017-03-30') ,
( 'LABEL','ID_THE_PERMISSION_CAN_NOT_BE_UNASSIGNED_FROM_THIS_ROLE','en','The permission can not be unassigned from this role.','2022-04-20') ,
( 'LABEL','ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED','en','The PHP files execution was disabled please contact the system administrator.','2018-04-20') , ( 'LABEL','ID_THE_PHP_FILES_EXECUTION_WAS_DISABLED','en','The PHP files execution was disabled please contact the system administrator.','2018-04-20') ,
( 'LABEL','ID_THE_REASON_REASSIGN_USER_EMPTY','en','Please complete the reassign reason.','2016-10-20') , ( 'LABEL','ID_THE_REASON_REASSIGN_USER_EMPTY','en','Please complete the reassign reason.','2016-10-20') ,
( 'LABEL','ID_THE_REPORT_TABLE_IS_REGENERATING_PLEASE_COME_BACK_IN_A_FEW_MINUTES','en','The report table is regenerating please come back in a few minutes.','2020-06-01') , ( 'LABEL','ID_THE_REPORT_TABLE_IS_REGENERATING_PLEASE_COME_BACK_IN_A_FEW_MINUTES','en','The report table is regenerating please come back in a few minutes.','2020-06-01') ,

View File

@@ -1,27 +1,4 @@
<?php <?php
/**
* data_rolesPermissions.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
$filter = new InputFilter(); $filter = new InputFilter();
$_GET = $filter->xssFilterHard($_GET); $_GET = $filter->xssFilterHard($_GET);
@@ -31,20 +8,22 @@ $TYPE_DATA = $_GET["type"];
global $RBAC; global $RBAC;
$filter = (isset( $_REQUEST['textFilter'] )) ? $_REQUEST['textFilter'] : ''; $filter = (isset($_REQUEST['textFilter'])) ? $_REQUEST['textFilter'] : '';
//BUG 7554: erik/ hook for existents environments that have not PM_CANCELCASE //BUG 7554: erik/ hook for existents environments that have not PM_CANCELCASE
if ($RBAC->permissionsObj->loadByCode( 'PM_CANCELCASE' ) === false) { if ($RBAC->permissionsObj->loadByCode('PM_CANCELCASE') === false) {
$RBAC->permissionsObj->create( array ('PER_CODE' => 'PM_CANCELCASE','PER_CREATE_DATE' => date( 'Y-m-d H:i:s' ) $RBAC->permissionsObj->create(array('PER_CODE' => 'PM_CANCELCASE', 'PER_CREATE_DATE' => date('Y-m-d H:i:s')
) ); ));
} }
if ($TYPE_DATA == 'list') if ($TYPE_DATA == 'list') {
$oDataset = $RBAC->getRolePermissions( $ROL_UID, $filter, 1 ); $oDataset = $RBAC->getRolePermissions($ROL_UID, $filter, 1);
if ($TYPE_DATA == 'show') }
$oDataset = $RBAC->getAllPermissions( $ROL_UID, $RBAC->sSystem, $filter, 1 ); if ($TYPE_DATA == 'show') {
$oDataset = $RBAC->getAllPermissions($ROL_UID, $RBAC->sSystem, $filter, 1);
}
$rows = Array (); $rows = [];
$per = new RolesPermissions(); $per = new RolesPermissions();
while ($oDataset->next()) { while ($oDataset->next()) {
$row = $oDataset->getRow(); $row = $oDataset->getRow();
@@ -53,5 +32,7 @@ while ($oDataset->next()) {
$rows[] = $row; $rows[] = $row;
} }
echo '{permissions: ' . G::json_encode( $rows ) . '}'; $result = [
'permissions' => $rows
];
echo G::json_encode($result);

View File

@@ -104,13 +104,24 @@ GridByDefaultX = function(){
assignedUGrid.store.load(); assignedUGrid.store.load();
}; };
//edit permissions action /**
EditPermissionsAction = function(){ * Edit permissions action
availableGrid.show(); * @returns {void}
buttonsPanel.show(); */
editPermissionsButton.disable(); EditPermissionsAction = function () {
//cancelEditPermissionsButton.show(); availableGrid.show();
PermissionsPanel.doLayout(); buttonsPanel.show();
editPermissionsButton.disable();
PermissionsPanel.doLayout();
//if the role is administrator these buttons must be disabled.
if (ROLES.ROL_UID === pm_admin) {
Ext.getCmp('removeButtonAll').disable();
Ext.getCmp('assignButtonAll').disable();
} else {
Ext.getCmp('removeButtonAll').enable();
Ext.getCmp('assignButtonAll').enable();
}
}; };
EditPermissionsContentsAction = function(){ EditPermissionsContentsAction = function(){
@@ -862,22 +873,31 @@ SavePermissionsRole = function(arr_per, function_success, function_failure){
}); });
}; };
//REMOVE PERMISSION FROM A ROLE /**
DeletePermissionsRole = function(arr_per, function_success, function_failure){ * Remove permission from a role.
var sw_response; * @param {array} permissions
viewport.getEl().mask(_('ID_PROCESSING')); * @param {function} success
Ext.Ajax.request({ * @param {function} failure
url: 'roles_Ajax', * @returns {void}
params: {request: 'deletePermissionToRoleMultiple', ROL_UID: ROLES.ROL_UID, PER_UID: arr_per.join(',')}, */
success: function(){ DeletePermissionsRole = function (permissions, success, failure) {
function_success(); if (permissions.length === 0) {
viewport.getEl().unmask(); return;
}, }
failure: function(){ var sw_response;
function_failure(); viewport.getEl().mask(_('ID_PROCESSING'));
viewport.getEl().unmask(); Ext.Ajax.request({
} url: 'roles_Ajax',
}); params: {request: 'deletePermissionToRoleMultiple', ROL_UID: ROLES.ROL_UID, PER_UID: permissions.join(',')},
success: function () {
success();
viewport.getEl().unmask();
},
failure: function () {
failure();
viewport.getEl().unmask();
}
});
}; };
//AssignButton Functionality //AssignButton Functionality
@@ -890,15 +910,23 @@ AssignPermissionAction = function(){
SavePermissionsRole(arrAux,RefreshPermissions,FailureProcess); SavePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
}; };
//RemoveButton Functionality /**
RemovePermissionAction = function(){ * RemoveButton Functionality
* @returns {void}
*/
RemovePermissionAction = function () {
if (ROLES.ROL_UID === pm_admin) {
var message = _('ID_THE_PERMISSION_CAN_NOT_BE_UNASSIGNED_FROM_THIS_ROLE');
Ext.Msg.alert(_('ID_INFORMATION'), message);
return;
}
rowsSelected = assignedGrid.getSelectionModel().getSelections(); rowsSelected = assignedGrid.getSelectionModel().getSelections();
var arrAux = new Array(); var arrAux = new Array();
var sw; var sw;
for(var a=0; a < rowsSelected.length; a++){ for (var a = 0; a < rowsSelected.length; a++) {
sw = true; sw = true;
if (ROLES.ROL_UID == pm_admin) { if (ROLES.ROL_UID == pm_admin) {
for (var i=0; i < permissionsAdmin.length; i++) for (var i = 0; i < permissionsAdmin.length; i++)
{ {
if (permissionsAdmin[i]['PER_UID'] == rowsSelected[a].get('PER_UID')) { if (permissionsAdmin[i]['PER_UID'] == rowsSelected[a].get('PER_UID')) {
sw = false; sw = false;
@@ -910,7 +938,7 @@ RemovePermissionAction = function(){
arrAux[a] = rowsSelected[a].get('PER_UID'); arrAux[a] = rowsSelected[a].get('PER_UID');
} }
} }
DeletePermissionsRole(arrAux,RefreshPermissions,FailureProcess); DeletePermissionsRole(arrAux, RefreshPermissions, FailureProcess);
}; };
//AssignALLButton Functionality //AssignALLButton Functionality