Roles Manager Ext JS Migration Complete
This commit is contained in:
@@ -554,6 +554,18 @@ class RBAC
|
|||||||
function getAllRoles ( $systemCode = 'PROCESSMAKER') {
|
function getAllRoles ( $systemCode = 'PROCESSMAKER') {
|
||||||
return $this->rolesObj->getAllRoles($systemCode);
|
return $this->rolesObj->getAllRoles($systemCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getting all roles by filter
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $filter
|
||||||
|
* @return $this->rolesObj->getAllRolesFilter
|
||||||
|
*/
|
||||||
|
function getAllRolesFilter ($filter) {
|
||||||
|
return $this->rolesObj->getAllRolesFilter($filter);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list all permission
|
* list all permission
|
||||||
|
|||||||
@@ -86,8 +86,9 @@ class Roles extends BaseRoles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function listAllRoles($systemCode = 'PROCESSMAKER') {
|
function listAllRoles($systemCode = 'PROCESSMAKER', $filter = '') {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$oCriteria = new Criteria('rbac');
|
$oCriteria = new Criteria('rbac');
|
||||||
$oCriteria->addSelectColumn(RolesPeer::ROL_UID);
|
$oCriteria->addSelectColumn(RolesPeer::ROL_UID);
|
||||||
$oCriteria->addSelectColumn(RolesPeer::ROL_PARENT);
|
$oCriteria->addSelectColumn(RolesPeer::ROL_PARENT);
|
||||||
@@ -101,8 +102,12 @@ class Roles extends BaseRoles {
|
|||||||
$oCriteria->add(SystemsPeer::SYS_CODE, $systemCode);
|
$oCriteria->add(SystemsPeer::SYS_CODE, $systemCode);
|
||||||
$oCriteria->add(RolesPeer::ROL_CREATE_DATE, '', Criteria::NOT_EQUAL);
|
$oCriteria->add(RolesPeer::ROL_CREATE_DATE, '', Criteria::NOT_EQUAL);
|
||||||
$oCriteria->add(RolesPeer::ROL_UPDATE_DATE, '', Criteria::NOT_EQUAL);
|
$oCriteria->add(RolesPeer::ROL_UPDATE_DATE, '', Criteria::NOT_EQUAL);
|
||||||
|
//Added by QENNIX Jan 21th, 2011
|
||||||
|
if ($filter != ''){
|
||||||
|
$oCriteria->add(RolesPeer::ROL_CODE, '%'.$filter.'%', Criteria::LIKE);
|
||||||
|
}
|
||||||
$oCriteria->addJoin(RolesPeer::ROL_SYSTEM, SystemsPeer::SYS_UID);
|
$oCriteria->addJoin(RolesPeer::ROL_SYSTEM, SystemsPeer::SYS_UID);
|
||||||
|
|
||||||
return $oCriteria;
|
return $oCriteria;
|
||||||
|
|
||||||
} catch( exception $oError ) {
|
} catch( exception $oError ) {
|
||||||
@@ -110,6 +115,26 @@ class Roles extends BaseRoles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Added by QENNIX
|
||||||
|
function getAllRolesFilter($filter='') {
|
||||||
|
$systemCode = 'PROCESSMAKER';
|
||||||
|
$c = $this->listAllRoles($systemCode,$filter);
|
||||||
|
$rs = RolesPeer::DoSelectRs($c);
|
||||||
|
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
$aRows = Array();
|
||||||
|
while($rs->next()){
|
||||||
|
$row = $rs->getRow();
|
||||||
|
$o = new Roles();
|
||||||
|
$o->load($row['ROL_UID']);
|
||||||
|
$row['ROL_NAME'] = $o->getRolName();
|
||||||
|
$aRows[] = $row;
|
||||||
|
}
|
||||||
|
return $aRows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getAllRoles($systemCode = 'PROCESSMAKER') {
|
function getAllRoles($systemCode = 'PROCESSMAKER') {
|
||||||
$c = $this->listAllRoles($systemCode);
|
$c = $this->listAllRoles($systemCode);
|
||||||
$rs = RolesPeer::DoSelectRs($c);
|
$rs = RolesPeer::DoSelectRs($c);
|
||||||
|
|||||||
46
workflow/engine/methods/roles/data_rolesList.php
Executable file
46
workflow/engine/methods/roles/data_rolesList.php
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* data_additionalTablesList.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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once (PATH_RBAC . "model/RolesPeer.php");
|
||||||
|
G::LoadClass('ArrayPeer');
|
||||||
|
|
||||||
|
isset($_POST['textFilter']) ? $filter = $_POST['textFilter'] : $filter = '';
|
||||||
|
|
||||||
|
if ($filter != ""){
|
||||||
|
$aRoles = $RBAC->getAllRolesFilter($filter);
|
||||||
|
}else{
|
||||||
|
$aRoles = $RBAC->getAllRoles();
|
||||||
|
}
|
||||||
|
|
||||||
|
//$ocaux = $oAdditionalTables->getDataCriteria($_GET['sUID']);
|
||||||
|
//
|
||||||
|
//$rs = AdditionalTablesPeer::DoSelectRs ($ocaux);
|
||||||
|
//$rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
|
||||||
|
//
|
||||||
|
//$rows = Array();
|
||||||
|
//while($rs->next()){
|
||||||
|
// $rows[] = $rs->getRow();
|
||||||
|
//}
|
||||||
|
echo '{roles: '.G::json_encode($aRoles).'}';
|
||||||
38
workflow/engine/methods/roles/data_rolesPermissions.php
Executable file
38
workflow/engine/methods/roles/data_rolesPermissions.php
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
<?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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$ROL_UID = $_GET['rUID'];
|
||||||
|
$TYPE_DATA = $_GET["type"];
|
||||||
|
|
||||||
|
global $RBAC;
|
||||||
|
|
||||||
|
if ($TYPE_DATA=='list') $oDataset = $RBAC->getRolePermissions($ROL_UID);
|
||||||
|
if ($TYPE_DATA=='show') $oDataset = $RBAC->getAllPermissions($ROL_UID,$RBAC->sSystem);
|
||||||
|
|
||||||
|
$rows = Array();
|
||||||
|
while($oDataset->next()){
|
||||||
|
$rows[] = $oDataset->getRow();
|
||||||
|
}
|
||||||
|
echo '{permissions: '.G::json_encode($rows).'}';
|
||||||
38
workflow/engine/methods/roles/data_rolesUsers.php
Executable file
38
workflow/engine/methods/roles/data_rolesUsers.php
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* data_rolesUsers.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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$ROL_UID = $_GET['rUID'];
|
||||||
|
$TYPE_DATA = $_GET["type"];
|
||||||
|
|
||||||
|
global $RBAC;
|
||||||
|
|
||||||
|
if ($TYPE_DATA=='list') $oDataset = $RBAC->getRoleUsers($ROL_UID);
|
||||||
|
if ($TYPE_DATA=='show') $oDataset = $RBAC->getAllUsers($ROL_UID);
|
||||||
|
|
||||||
|
$rows = Array();
|
||||||
|
while($oDataset->next()){
|
||||||
|
$rows[] = $oDataset->getRow();
|
||||||
|
}
|
||||||
|
echo '{users: '.G::json_encode($rows).'}';
|
||||||
75
workflow/engine/methods/roles/rolesUsersPermission.php
Executable file
75
workflow/engine/methods/roles/rolesUsersPermission.php
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* rolesUsersPermission.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.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
global $RBAC;
|
||||||
|
switch ($RBAC->userCanAccess('PM_USERS')) {
|
||||||
|
case - 2:
|
||||||
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||||
|
G::header('location: ../login/login');
|
||||||
|
die;
|
||||||
|
break;
|
||||||
|
case - 1:
|
||||||
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||||
|
G::header('location: ../login/login');
|
||||||
|
die;
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||||
|
G::header('location: ../login/login');
|
||||||
|
die;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$G_MAIN_MENU = 'processmaker';
|
||||||
|
$G_SUB_MENU = 'users';
|
||||||
|
$G_ID_MENU_SELECTED = 'USERS';
|
||||||
|
$G_ID_SUB_MENU_SELECTED = 'ROLES';
|
||||||
|
|
||||||
|
|
||||||
|
$G_PUBLISH = new Publisher;
|
||||||
|
|
||||||
|
$oHeadPublisher =& headPublisher::getSingleton();
|
||||||
|
|
||||||
|
$oHeadPublisher->addExtJsScript('roles/rolesUsersPermission', false); //adding a javascript file .js
|
||||||
|
$oHeadPublisher->addContent('roles/rolesUsersPermission'); //adding a html file .html.
|
||||||
|
|
||||||
|
$labels = G::getTranslations(Array('ID_PRO_CREATE_DATE','ID_CODE','ID_NAME','ID_LAN_UPDATE_DATE', 'ID_ROLES',
|
||||||
|
'ID_USERS','ID_PERMISSIONS','ID_EDIT','ID_DELETE','ID_NEW','ID_STATUS','ID_SAVE','ID_CLOSE',
|
||||||
|
'ID_ACTIVE','ID_INACTIVE','ID_ROLES_MSG','ID_ROLES_CAN_NOT_DELETE','ID_ROLES_SUCCESS_NEW','ID_ROLES_SUCCESS_UPDATE',
|
||||||
|
'ID_ROLES_SUCCESS_DELETE','ID_REMOVE_ROLE','ID_ASSIGN','ID_REMOVE','ID_BACK','ID_PROCESSING',
|
||||||
|
'ID_REMOVE_ALL_PERMISSIONS','ID_ASSIGN_ALL_PERMISSIONS','ID_ASSIGN_ALL_USERS','ID_REMOVE_ALL_USERS',
|
||||||
|
'ID_USER_NAME','ID_PERMISSION_CODE','ID_AVAILABLE_PERMISSIONS','ID_ASSIGNED_PERMISSIONS',
|
||||||
|
'ID_FIRST_NAME','ID_LAST_NAME','ID_AVAILABLE_USERS','ID_ASSIGNED_USERS','ID_MSG_CONFIRM_ASSIGN_ALL_USERS','ID_MSG_AJAX_FAILURE'));
|
||||||
|
|
||||||
|
$roles = Array();
|
||||||
|
$roles['ROL_UID'] = $_GET['rUID'];
|
||||||
|
$roles['ROL_CODE'] = $RBAC->getRoleCode($_GET['rUID']);
|
||||||
|
$roles['CURRENT_TAB'] = ($_GET['tab']=='permissions') ? 1 : 0;
|
||||||
|
|
||||||
|
$oHeadPublisher->assign('TRANSLATIONS', $labels);
|
||||||
|
$oHeadPublisher->assign('ROLES', $roles);
|
||||||
|
G::RenderPage('publish', 'extJs');
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -34,6 +34,7 @@ switch ($REQUEST) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'saveNewRole':
|
case 'saveNewRole':
|
||||||
|
|
||||||
|
|
||||||
$newid = md5($_POST['code'].date("d-M-Y_H:i:s"));
|
$newid = md5($_POST['code'].date("d-M-Y_H:i:s"));
|
||||||
g::pr($_POST);
|
g::pr($_POST);
|
||||||
@@ -187,18 +188,17 @@ switch ($REQUEST) {
|
|||||||
case 'assignUserToRole':
|
case 'assignUserToRole':
|
||||||
|
|
||||||
$ROL_UID = $_POST['ROL_UID'];
|
$ROL_UID = $_POST['ROL_UID'];
|
||||||
|
$aUserIuds = explode(",",$_POST['aUsers']);
|
||||||
$aUserIuds = explode(",",$_POST['aUsers']);
|
foreach($aUserIuds as $key=>$val){
|
||||||
foreach($aUserIuds as $key=>$val){
|
$sData['USR_UID'] = $val;
|
||||||
$sData['USR_UID'] = $val;
|
$sData['ROL_UID'] = $ROL_UID;
|
||||||
$sData['ROL_UID'] = $ROL_UID;
|
$RBAC->assignUserToRole($sData);
|
||||||
$RBAC->assignUserToRole($sData);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$_GET['ROL_UID'] = $ROL_UID;
|
// $_GET['ROL_UID'] = $ROL_UID;
|
||||||
$G_PUBLISH = new Publisher;
|
// $G_PUBLISH = new Publisher;
|
||||||
$G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
|
// $G_PUBLISH->AddContent('view', 'roles/roles_Tree' );
|
||||||
G::RenderPage('publish', 'raw');
|
// G::RenderPage('publish', 'raw');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'assignPermissionToRole':
|
case 'assignPermissionToRole':
|
||||||
@@ -208,10 +208,10 @@ switch ($REQUEST) {
|
|||||||
$sData['ROL_UID'] = $ROL_UID;
|
$sData['ROL_UID'] = $ROL_UID;
|
||||||
$RBAC->assignPermissionRole($sData);
|
$RBAC->assignPermissionRole($sData);
|
||||||
|
|
||||||
$_GET['ROL_UID'] = $ROL_UID;
|
// $_GET['ROL_UID'] = $ROL_UID;
|
||||||
$G_PUBLISH = new Publisher;
|
// $G_PUBLISH = new Publisher;
|
||||||
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
|
// $G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree' );
|
||||||
G::RenderPage('publish', 'raw');
|
// G::RenderPage('publish', 'raw');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'viewPermitions':
|
case 'viewPermitions':
|
||||||
@@ -232,6 +232,35 @@ switch ($REQUEST) {
|
|||||||
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree');
|
$G_PUBLISH->AddContent('view', 'roles/roles_permissionsTree');
|
||||||
G::RenderPage('publish', 'raw');
|
G::RenderPage('publish', 'raw');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'assignPermissionToRoleMultiple':
|
||||||
|
$USR_UID = $_POST['PER_UID'];
|
||||||
|
$ROL_UID = $_POST['ROL_UID'];
|
||||||
|
$arrPer = explode(',',$USR_UID);
|
||||||
|
foreach ($arrPer as $PER_UID){
|
||||||
|
unset($sData);
|
||||||
|
$sData['PER_UID'] = $PER_UID;
|
||||||
|
$sData['ROL_UID'] = $ROL_UID;
|
||||||
|
$RBAC->assignPermissionRole($sData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'deletePermissionToRoleMultiple':
|
||||||
|
$USR_UID = $_POST['PER_UID'];
|
||||||
|
$ROL_UID = $_POST['ROL_UID'];
|
||||||
|
$arrPer = explode(',',$USR_UID);
|
||||||
|
foreach ($arrPer as $PER_UID){
|
||||||
|
$RBAC->deletePermissionRole($ROL_UID, $PER_UID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'deleteUserRoleMultiple':
|
||||||
|
$USR_UID = $_POST['USR_UID'];
|
||||||
|
$ROL_UID = $_POST['ROL_UID'];
|
||||||
|
$arrUsers = explode(',',$USR_UID);
|
||||||
|
foreach ($arrUsers as $aUID){
|
||||||
|
$RBAC->deleteUserRole($ROL_UID, $aUID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default: echo 'default';
|
default: echo 'default';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* users_List.php
|
* roles_List.php
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
* Copyright (C) 2004 - 2008 Colosa Inc.23
|
||||||
@@ -46,31 +46,48 @@
|
|||||||
$G_ID_MENU_SELECTED = 'USERS';
|
$G_ID_MENU_SELECTED = 'USERS';
|
||||||
$G_ID_SUB_MENU_SELECTED = 'ROLES';
|
$G_ID_SUB_MENU_SELECTED = 'ROLES';
|
||||||
|
|
||||||
require_once (PATH_RBAC . "model/RolesPeer.php");
|
// require_once (PATH_RBAC . "model/RolesPeer.php");
|
||||||
G::LoadClass('ArrayPeer');
|
// G::LoadClass('ArrayPeer');
|
||||||
$aRoles = $RBAC->getAllRoles();
|
// $aRoles = $RBAC->getAllRoles();
|
||||||
|
//
|
||||||
$fields = Array(
|
// $fields = Array(
|
||||||
'ROL_UID'=>'char',
|
// 'ROL_UID'=>'char',
|
||||||
'ROL_PARENT'=>'char',
|
// 'ROL_PARENT'=>'char',
|
||||||
'ROL_SYSTEM'=>'char',
|
// 'ROL_SYSTEM'=>'char',
|
||||||
'ROL_CREATE_DATE'=>'char',
|
// 'ROL_CREATE_DATE'=>'char',
|
||||||
'ROL_UPDATE_DATE'=>'char',
|
// 'ROL_UPDATE_DATE'=>'char',
|
||||||
'ROL_STATUS'=>'char'
|
// 'ROL_STATUS'=>'char'
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
$rows = array_merge(Array($fields), $aRoles);
|
// $rows = array_merge(Array($fields), $aRoles);
|
||||||
|
//
|
||||||
global $_DBArray;
|
// global $_DBArray;
|
||||||
$_DBArray['roles'] = $rows;
|
// $_DBArray['roles'] = $rows;
|
||||||
$_SESSION['_DBArray'] = $_DBArray;
|
// $_SESSION['_DBArray'] = $_DBArray;
|
||||||
$oCriteria = new Criteria('dbarray');
|
// $oCriteria = new Criteria('dbarray');
|
||||||
$oCriteria->setDBArrayTable('roles');
|
// $oCriteria->setDBArrayTable('roles');
|
||||||
|
//
|
||||||
|
// $G_PUBLISH = new Publisher;
|
||||||
|
// $G_PUBLISH->AddContent('propeltable', 'paged-table', 'roles/roles_List', $oCriteria);
|
||||||
|
//
|
||||||
|
// G::RenderPage('publish','blank');
|
||||||
|
|
||||||
|
$G_PUBLISH = new Publisher;
|
||||||
|
|
||||||
|
$oHeadPublisher =& headPublisher::getSingleton();
|
||||||
|
|
||||||
|
//$oHeadPublisher->usingExtJs('ux/Ext.ux.fileUploadField');
|
||||||
|
$oHeadPublisher->addExtJsScript('roles/rolesList', false); //adding a javascript file .js
|
||||||
|
$oHeadPublisher->addContent('roles/rolesList'); //adding a html file .html.
|
||||||
|
|
||||||
|
$labels = G::getTranslations(Array('ID_PRO_CREATE_DATE','ID_CODE','ID_NAME','ID_LAN_UPDATE_DATE', 'ID_ROLES',
|
||||||
|
'ID_USERS','ID_PERMISSIONS','ID_EDIT','ID_DELETE','ID_NEW','ID_STATUS','ID_SAVE','ID_CLOSE',
|
||||||
|
'ID_ACTIVE','ID_INACTIVE','ID_ROLES_MSG','ID_ROLES_CAN_NOT_DELETE','ID_ROLES_SUCCESS_NEW','ID_ROLES_SUCCESS_UPDATE',
|
||||||
|
'ID_ROLES_SUCCESS_DELETE','ID_REMOVE_ROLE','ID_SEARCH','ID_ENTER_SEARCH_TERM','ID_SELECT_STATUS'));
|
||||||
|
|
||||||
|
$oHeadPublisher->assign('TRANSLATIONS', $labels);
|
||||||
|
G::RenderPage('publish', 'extJs');
|
||||||
|
|
||||||
$G_PUBLISH = new Publisher;
|
|
||||||
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'roles/roles_List', $oCriteria);
|
|
||||||
|
|
||||||
G::RenderPage('publish','blank');
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
workflow/engine/templates/roles/rolesList.html
Executable file
3
workflow/engine/templates/roles/rolesList.html
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
<div style="padding: 15px">
|
||||||
|
<div id="list-panel"></div>
|
||||||
|
</div>
|
||||||
465
workflow/engine/templates/roles/rolesList.js
Executable file
465
workflow/engine/templates/roles/rolesList.js
Executable file
@@ -0,0 +1,465 @@
|
|||||||
|
/*
|
||||||
|
* @author: Qennix
|
||||||
|
* Jan 18th, 2011
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Keyboard Events
|
||||||
|
new Ext.KeyMap(document, [
|
||||||
|
{
|
||||||
|
key: Ext.EventObject.F5,
|
||||||
|
fn: function(keycode, e) {
|
||||||
|
if (! e.ctrlKey) {
|
||||||
|
if (Ext.isIE) {
|
||||||
|
// IE6 doesn't allow cancellation of the F5 key, so trick it into
|
||||||
|
// thinking some other key was pressed (backspace in this case)
|
||||||
|
e.browserEvent.keyCode = 8;
|
||||||
|
}
|
||||||
|
e.stopEvent();
|
||||||
|
document.location = document.location;
|
||||||
|
}else{
|
||||||
|
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: Ext.EventObject.DELETE,
|
||||||
|
fn: function(k,e){
|
||||||
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
|
rowSelected = iGrid.getSelectionModel().getSelected();
|
||||||
|
if (rowSelected){
|
||||||
|
CanDeleteRole();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
var store;
|
||||||
|
var cmodel;
|
||||||
|
var infoGrid;
|
||||||
|
var viewport;
|
||||||
|
var smodel;
|
||||||
|
|
||||||
|
var newButton;
|
||||||
|
var editButton;
|
||||||
|
var deleteButton;
|
||||||
|
var usersButton;
|
||||||
|
var permissionsButton;
|
||||||
|
var searchButton;
|
||||||
|
|
||||||
|
var serachText;
|
||||||
|
|
||||||
|
var newForm;
|
||||||
|
var comboStatusStore;
|
||||||
|
var editForm;
|
||||||
|
|
||||||
|
var contextMenu;
|
||||||
|
|
||||||
|
var w;
|
||||||
|
|
||||||
|
|
||||||
|
Ext.onReady(function(){
|
||||||
|
Ext.QuickTips.init();
|
||||||
|
|
||||||
|
newButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_NEW,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||||
|
handler: NewRoleWindow
|
||||||
|
});
|
||||||
|
|
||||||
|
editButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_EDIT,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_pencil',
|
||||||
|
handler: EditRole,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_DELETE,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_delete',
|
||||||
|
handler: CanDeleteRole,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
usersButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_USERS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_user_add',
|
||||||
|
handler: RolesUserPage,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
permissionsButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_PERMISSIONS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_key_add',
|
||||||
|
handler: RolesPermissionPage,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
searchButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_SEARCH,
|
||||||
|
handler: DoSearch
|
||||||
|
});
|
||||||
|
|
||||||
|
contextMenu = new Ext.menu.Menu({
|
||||||
|
items: [editButton, deleteButton,'-',usersButton, permissionsButton],
|
||||||
|
});
|
||||||
|
|
||||||
|
searchText = new Ext.form.TextField ({
|
||||||
|
id: 'searchTxt',
|
||||||
|
ctCls:'pm_search_text_field',
|
||||||
|
allowBlank: true,
|
||||||
|
width: 150,
|
||||||
|
emptyText: TRANSLATIONS.ID_ENTER_SEARCH_TERM,//'enter search term',
|
||||||
|
listeners: {
|
||||||
|
specialkey: function(f,e){
|
||||||
|
if (e.getKey() == e.ENTER) {
|
||||||
|
DoSearch();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focus: function(f,e) {
|
||||||
|
var row = infoGrid.getSelectionModel().getSelected();
|
||||||
|
infoGrid.getSelectionModel().deselectRow(infoGrid.getStore().indexOf(row));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
clearTextButton = new Ext.Action({
|
||||||
|
text: 'X',
|
||||||
|
ctCls:'pm_search_x_button',
|
||||||
|
handler: GridByDefault
|
||||||
|
});
|
||||||
|
|
||||||
|
comboStatusStore = new Ext.data.SimpleStore({
|
||||||
|
fields: ['id','value'],
|
||||||
|
data: [['1',TRANSLATIONS.ID_ACTIVE],['0',TRANSLATIONS.ID_INACTIVE]]
|
||||||
|
});
|
||||||
|
|
||||||
|
newForm = new Ext.FormPanel({
|
||||||
|
url: 'roles_Ajax?request=saveNewRole',
|
||||||
|
frame: true,
|
||||||
|
title: 'Create a new role',
|
||||||
|
items:[
|
||||||
|
{xtype: 'textfield', fieldLabel: TRANSLATIONS.ID_CODE, name: 'code', width: 250, allowBlank: false},
|
||||||
|
{xtype: 'textfield', fieldLabel: TRANSLATIONS.ID_NAME, name: 'name', width: 200, allowBlank: false},
|
||||||
|
{
|
||||||
|
xtype: 'combo',
|
||||||
|
fieldLabel: TRANSLATIONS.ID_STATUS,
|
||||||
|
hiddenName: 'status',
|
||||||
|
typeAhead: true,
|
||||||
|
mode: 'local',
|
||||||
|
store: comboStatusStore,
|
||||||
|
displayField: 'value',
|
||||||
|
valueField:'id',
|
||||||
|
allowBlank: false,
|
||||||
|
triggerAction: 'all',
|
||||||
|
emptyText: TRANSLATIONS.ID_SELECT_STATUS,
|
||||||
|
selectOnFocus:true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
buttons: [
|
||||||
|
{text: TRANSLATIONS.ID_CLOSE, handler: CloseWindow},
|
||||||
|
{text: TRANSLATIONS.ID_SAVE, handler: SaveNewRole}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
editForm = new Ext.FormPanel({
|
||||||
|
url: 'roles_Ajax?request=updateRole',
|
||||||
|
frame: true,
|
||||||
|
title: 'Updating role',
|
||||||
|
items:[
|
||||||
|
{xtype: 'textfield', name: 'rol_uid', hidden: true },
|
||||||
|
{xtype: 'textfield', fieldLabel: TRANSLATIONS.ID_CODE, name: 'code', width: 250, allowBlank: false},
|
||||||
|
{xtype: 'textfield', fieldLabel: TRANSLATIONS.ID_NAME, name: 'name', width: 200, allowBlank: false},
|
||||||
|
{
|
||||||
|
xtype: 'combo',
|
||||||
|
fieldLabel: TRANSLATIONS.ID_STATUS,
|
||||||
|
hiddenName: 'status',
|
||||||
|
typeAhead: true,
|
||||||
|
mode: 'local',
|
||||||
|
store: comboStatusStore,
|
||||||
|
displayField: 'value',
|
||||||
|
valueField:'id',
|
||||||
|
allowBlank: false,
|
||||||
|
triggerAction: 'all',
|
||||||
|
emptyText: TRANSLATIONS.ID_SELECT_STATUS,
|
||||||
|
selectOnFocus:true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
buttons: [
|
||||||
|
{text: TRANSLATIONS.ID_CLOSE, handler: CloseWindow},
|
||||||
|
{text: TRANSLATIONS.ID_SAVE, handler: UpdateRole}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
smodel = new Ext.grid.RowSelectionModel({
|
||||||
|
singleSelect: true,
|
||||||
|
listeners:{
|
||||||
|
rowselect: function(sm){
|
||||||
|
editButton.enable();
|
||||||
|
deleteButton.enable();
|
||||||
|
usersButton.enable();
|
||||||
|
permissionsButton.enable();
|
||||||
|
},
|
||||||
|
rowdeselect: function(sm){
|
||||||
|
editButton.disable();
|
||||||
|
deleteButton.disable();
|
||||||
|
usersButton.disable();
|
||||||
|
permissionsButton.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
store = new Ext.data.GroupingStore( {
|
||||||
|
proxy : new Ext.data.HttpProxy({
|
||||||
|
url: 'data_rolesList'
|
||||||
|
}),
|
||||||
|
reader : new Ext.data.JsonReader( {
|
||||||
|
root: 'roles',
|
||||||
|
fields : [
|
||||||
|
{name : 'ROL_UID'},
|
||||||
|
{name : 'ROL_CODE'},
|
||||||
|
{name : 'ROL_NAME'},
|
||||||
|
{name : 'ROL_CREATE_DATE'},
|
||||||
|
{name : 'ROL_UPDATE_DATE'},
|
||||||
|
{name : 'ROL_STATUS'}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
cmodel = new Ext.grid.ColumnModel({
|
||||||
|
defaults: {
|
||||||
|
width: 50,
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{id:'ROL_UID', dataIndex: 'ROL_UID', hidden:true, hideable:false},
|
||||||
|
{header: TRANSLATIONS.ID_CODE, dataIndex: 'ROL_CODE', width: 60, align:'left'},
|
||||||
|
{header: TRANSLATIONS.ID_NAME, dataIndex: 'ROL_NAME', width: 60, hidden:false, align:'left'},
|
||||||
|
{header: TRANSLATIONS.ID_STATUS, dataIndex: 'ROL_STATUS', width: 20, hidden: false, align: 'center', renderer: status_role},
|
||||||
|
{header: TRANSLATIONS.ID_PRO_CREATE_DATE, dataIndex: 'ROL_CREATE_DATE', width: 40, hidden:false, align:'center'},
|
||||||
|
{header: TRANSLATIONS.ID_LAN_UPDATE_DATE, dataIndex: 'ROL_UPDATE_DATE', width: 40, hidden:false, align:'center'}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
infoGrid = new Ext.grid.GridPanel({
|
||||||
|
region: 'center',
|
||||||
|
layout: 'fit',
|
||||||
|
id: 'infoGrid',
|
||||||
|
height:100,
|
||||||
|
autoWidth : true,
|
||||||
|
stateful : true,
|
||||||
|
stateId : 'grid',
|
||||||
|
enableColumnResize: true,
|
||||||
|
enableHdMenu: true,
|
||||||
|
frame:false,
|
||||||
|
iconCls:'icon-grid',
|
||||||
|
columnLines: false,
|
||||||
|
viewConfig: {
|
||||||
|
forceFit:true
|
||||||
|
},
|
||||||
|
title : TRANSLATIONS.ID_ROLES,
|
||||||
|
store: store,
|
||||||
|
cm: cmodel,
|
||||||
|
sm: smodel,
|
||||||
|
tbar: [newButton, '-', editButton, deleteButton,'-',usersButton, permissionsButton, {xtype: 'tbfill'}, searchText,clearTextButton,searchButton],
|
||||||
|
listeners: {
|
||||||
|
rowdblclick: EditRole
|
||||||
|
},
|
||||||
|
view: new Ext.grid.GroupingView({
|
||||||
|
forceFit:true,
|
||||||
|
groupTextTpl: '{text}'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
infoGrid.on('rowcontextmenu',
|
||||||
|
function (grid, rowIndex, evt) {
|
||||||
|
var sm = grid.getSelectionModel();
|
||||||
|
sm.selectRow(rowIndex, sm.isSelected(rowIndex));
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
infoGrid.on('contextmenu',
|
||||||
|
function (evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this);
|
||||||
|
|
||||||
|
infoGrid.store.load();
|
||||||
|
|
||||||
|
viewport = new Ext.Viewport({
|
||||||
|
layout: 'fit',
|
||||||
|
autoScroll: false,
|
||||||
|
items: [
|
||||||
|
infoGrid
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Funtion Handles Context Menu Opening
|
||||||
|
onMessageContextMenu = function (grid, rowIndex, e) {
|
||||||
|
e.stopEvent();
|
||||||
|
var coords = e.getXY();
|
||||||
|
contextMenu.showAt([coords[0], coords[1]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Do Nothing Function
|
||||||
|
DoNothing = function(){}
|
||||||
|
|
||||||
|
//Open New Role Form
|
||||||
|
NewRoleWindow = function(){
|
||||||
|
w = new Ext.Window({
|
||||||
|
height: 190,
|
||||||
|
width: 420,
|
||||||
|
title: TRANSLATIONS.ID_ROLES,
|
||||||
|
items: [newForm]
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Close Popup Window
|
||||||
|
CloseWindow = function(){
|
||||||
|
w.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save New Role
|
||||||
|
SaveNewRole = function(){
|
||||||
|
newForm.getForm().submit({
|
||||||
|
success: function(f,a){
|
||||||
|
w.hide(); //Hide popup widow
|
||||||
|
newForm.getForm().reset(); //Set empty form to next use
|
||||||
|
textSearch.reset();
|
||||||
|
infoGrid.store.load(); //Reload store grid
|
||||||
|
Ext.Msg.alert(TRANSLATIONS.ID_ROLES,TRANSLATIONS.ID_ROLES_SUCCESS_NEW);
|
||||||
|
},
|
||||||
|
failure: function(f,a){
|
||||||
|
switch(a.failureType){
|
||||||
|
case Ext.form.Action.CLIENT_INVALID:
|
||||||
|
//Ext.Msg.alert('New Role Form','Invalid Data');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update Selected Role
|
||||||
|
UpdateRole = function(){
|
||||||
|
editForm.getForm().submit({
|
||||||
|
success: function(f,a){
|
||||||
|
w.hide(); //Hide popup widow
|
||||||
|
DoSearch(); //Reload store grid
|
||||||
|
editButton.disable(); //Disable Edit Button
|
||||||
|
deleteButton.disable(); //Disable Delete Button
|
||||||
|
Ext.Msg.alert(TRANSLATIONS.ID_ROLES,TRANSLATIONS.ID_ROLES_SUCCESS_UPDATE);
|
||||||
|
},
|
||||||
|
failure: function(f,a){
|
||||||
|
switch(a.failureType){
|
||||||
|
case Ext.form.Action.CLIENT_INVALID:
|
||||||
|
//Ext.Msg.alert('New Role Form','Invalid Data');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//Edit Selected Role
|
||||||
|
EditRole = function(){
|
||||||
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
|
rowSelected = iGrid.getSelectionModel().getSelected();
|
||||||
|
if (rowSelected){
|
||||||
|
if (rowSelected.data.ROL_UID == '00000000000000000000000000000002'){
|
||||||
|
Ext.Msg.alert(TRANSLATIONS.ID_ROLES,TRANSLATIONS.ID_ROLES_MSG);
|
||||||
|
}else{
|
||||||
|
editForm.getForm().findField('rol_uid').setValue(rowSelected.data.ROL_UID);
|
||||||
|
editForm.getForm().findField('code').setValue(rowSelected.data.ROL_CODE);
|
||||||
|
editForm.getForm().findField('name').setValue(rowSelected.data.ROL_NAME);
|
||||||
|
editForm.getForm().findField('status').setValue(rowSelected.data.ROL_STATUS);
|
||||||
|
w = new Ext.Window({
|
||||||
|
height: 190,
|
||||||
|
width: 420,
|
||||||
|
title: TRANSLATIONS.ID_ROLES,
|
||||||
|
items: [editForm]
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check Can Delete Role
|
||||||
|
CanDeleteRole = function(){
|
||||||
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
|
rowSelected = iGrid.getSelectionModel().getSelected();
|
||||||
|
if (rowSelected){
|
||||||
|
var swDelete = false;
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
success: function(response, opts){
|
||||||
|
swDelete = (response.responseText=='true') ? true : false;
|
||||||
|
if (swDelete){
|
||||||
|
Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, TRANSLATIONS.ID_REMOVE_ROLE,
|
||||||
|
function(btn, text){
|
||||||
|
if (btn=="yes"){
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
params: {request: 'deleteRole', ROL_UID: rowSelected.data.ROL_UID},
|
||||||
|
success: function(r,o){
|
||||||
|
infoGrid.store.load(); //Reload store grid
|
||||||
|
editButton.disable(); //Disable Edit Button
|
||||||
|
deleteButton.disable(); //Disable Delete Button
|
||||||
|
Ext.Msg.alert(TRANSLATIONS.ID_ROLES,TRANSLATIONS.ID_ROLES_SUCCESS_DELETE);
|
||||||
|
},
|
||||||
|
failure: DoNothing
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Ext.Msg.alert(TRANSLATIONS.ID_ROLES,TRANSLATIONS.ID_ROLES_CAN_NOT_DELETE);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
failure: DoNothing,
|
||||||
|
params: {request: 'canDeleteRole', ROL_UID: rowSelected.data.ROL_UID}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Open User-Roles Manager
|
||||||
|
RolesUserPage = function(value){
|
||||||
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
|
rowSelected = iGrid.getSelectionModel().getSelected();
|
||||||
|
if (rowSelected){
|
||||||
|
value = rowSelected.data.ROL_UID;
|
||||||
|
location.href = 'rolesUsersPermission?rUID=' + value + '&tab=users';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Open Permission-Roles Manager
|
||||||
|
RolesPermissionPage = function(value){
|
||||||
|
iGrid = Ext.getCmp('infoGrid');
|
||||||
|
rowSelected = iGrid.getSelectionModel().getSelected();
|
||||||
|
if (rowSelected){
|
||||||
|
value = rowSelected.data.ROL_UID;
|
||||||
|
location.href = 'rolesUsersPermission?rUID=' + value + '&tab=permissions';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Renderer Active/Inactive Role
|
||||||
|
status_role = function(value){
|
||||||
|
return (value==1) ? TRANSLATIONS.ID_ACTIVE : TRANSLATIONS.ID_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load Grid By Default
|
||||||
|
GridByDefault = function(){
|
||||||
|
searchText.reset();
|
||||||
|
infoGrid.store.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Do Search Function
|
||||||
|
DoSearch = function(){
|
||||||
|
infoGrid.store.load({params: {textFilter: searchText.getValue()}});
|
||||||
|
}
|
||||||
4
workflow/engine/templates/roles/rolesUsersPermission.html
Executable file
4
workflow/engine/templates/roles/rolesUsersPermission.html
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
<div style="padding: 15px">
|
||||||
|
<div id="list-panel"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
687
workflow/engine/templates/roles/rolesUsersPermission.js
Executable file
687
workflow/engine/templates/roles/rolesUsersPermission.js
Executable file
@@ -0,0 +1,687 @@
|
|||||||
|
/*
|
||||||
|
* @author: Qennix
|
||||||
|
* Jan 19th, 2011
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Keyboard Events
|
||||||
|
new Ext.KeyMap(document, {
|
||||||
|
key: Ext.EventObject.F5,
|
||||||
|
fn: function(keycode, e) {
|
||||||
|
if (! e.ctrlKey) {
|
||||||
|
if (Ext.isIE) {
|
||||||
|
// IE6 doesn't allow cancellation of the F5 key, so trick it into
|
||||||
|
// thinking some other key was pressed (backspace in this case)
|
||||||
|
e.browserEvent.keyCode = 8;
|
||||||
|
}
|
||||||
|
e.stopEvent();
|
||||||
|
document.location = document.location;
|
||||||
|
}else{
|
||||||
|
Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var storeP;
|
||||||
|
var storeA;
|
||||||
|
var cmodelP;
|
||||||
|
var smodelA;
|
||||||
|
var smodelP;
|
||||||
|
var storeU;
|
||||||
|
var storeX;
|
||||||
|
var cmodelU;
|
||||||
|
var smodelU;
|
||||||
|
var smodelX;
|
||||||
|
|
||||||
|
var availableGrid;
|
||||||
|
var assignedGrid;
|
||||||
|
var availableUGrid;
|
||||||
|
var assignedUGrid;
|
||||||
|
|
||||||
|
var PermissionsPanel;
|
||||||
|
var UsersPanel;
|
||||||
|
var northPanel;
|
||||||
|
var tabsPanel;
|
||||||
|
var viewport;
|
||||||
|
|
||||||
|
var assignButton;
|
||||||
|
var assignAllButton;
|
||||||
|
var removeButton;
|
||||||
|
var removeAllButton;
|
||||||
|
var assignUButton;
|
||||||
|
var assignUAllButton;
|
||||||
|
var removeUButton;
|
||||||
|
var removeUAllButton;
|
||||||
|
var backButton;
|
||||||
|
|
||||||
|
var sw_func_permissions;
|
||||||
|
var sw_func_users;
|
||||||
|
|
||||||
|
const pm_admin = '00000000000000000000000000000002';
|
||||||
|
|
||||||
|
Ext.onReady(function(){
|
||||||
|
|
||||||
|
sw_func_permissions = false;
|
||||||
|
sw_func_users = false;
|
||||||
|
|
||||||
|
assignButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_ASSIGN,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||||
|
handler: AssignPermissionAction,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
assignAllButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_ASSIGN_ALL_PERMISSIONS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||||
|
handler: AssignAllPermissionsAction
|
||||||
|
});
|
||||||
|
|
||||||
|
removeButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_REMOVE,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_delete',
|
||||||
|
handler: RemovePermissionAction,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
removeAllButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_REMOVE_ALL_PERMISSIONS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_delete',
|
||||||
|
handler: RemoveAllPermissionsAction,
|
||||||
|
disabled: (ROLES.ROL_UID==pm_admin) ? true : false
|
||||||
|
});
|
||||||
|
|
||||||
|
assignUButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_ASSIGN,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||||
|
handler: AssignUserAction,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
assignUAllButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_ASSIGN_ALL_USERS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_add',
|
||||||
|
handler: AssignAllUsersAction
|
||||||
|
});
|
||||||
|
|
||||||
|
removeUButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_REMOVE,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_delete',
|
||||||
|
handler: RemoveUserAction,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
|
removeUAllButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_REMOVE_ALL_USERS,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_delete',
|
||||||
|
handler: RemoveAllUsersAction
|
||||||
|
});
|
||||||
|
|
||||||
|
backButton = new Ext.Action({
|
||||||
|
text: TRANSLATIONS.ID_BACK,
|
||||||
|
iconCls: 'button_menu_ext ss_sprite ss_arrow_redo',
|
||||||
|
handler: BackToRoles
|
||||||
|
});
|
||||||
|
|
||||||
|
storeP = new Ext.data.GroupingStore( {
|
||||||
|
proxy : new Ext.data.HttpProxy({
|
||||||
|
url: 'data_rolesPermissions?rUID=' + ROLES.ROL_UID + '&type=list'
|
||||||
|
}),
|
||||||
|
reader : new Ext.data.JsonReader( {
|
||||||
|
root: 'permissions',
|
||||||
|
fields : [
|
||||||
|
{name : 'PER_UID'},
|
||||||
|
{name : 'PER_CODE'},
|
||||||
|
{name : 'PER_CREATE_DATE'},
|
||||||
|
{name : 'PER_STATUS'}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
storeA = new Ext.data.GroupingStore( {
|
||||||
|
proxy : new Ext.data.HttpProxy({
|
||||||
|
url: 'data_rolesPermissions?rUID=' + ROLES.ROL_UID + '&type=show'
|
||||||
|
}),
|
||||||
|
reader : new Ext.data.JsonReader( {
|
||||||
|
root: 'permissions',
|
||||||
|
fields : [
|
||||||
|
{name : 'PER_UID'},
|
||||||
|
{name : 'PER_CODE'},
|
||||||
|
{name : 'PER_CREATE_DATE'},
|
||||||
|
{name : 'PER_STATUS'}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
cmodelP = new Ext.grid.ColumnModel({
|
||||||
|
defaults: {
|
||||||
|
width: 50,
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{id:'PER_UID', dataIndex: 'PER_UID', hidden:true, hideable:false},
|
||||||
|
{header: TRANSLATIONS.ID_PERMISSION_CODE, dataIndex: 'PER_CODE', width: 60, align:'left'}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
smodelA = new Ext.grid.RowSelectionModel({
|
||||||
|
selectSingle: false,
|
||||||
|
listeners:{
|
||||||
|
selectionchange: function(sm){
|
||||||
|
switch(sm.getCount()){
|
||||||
|
case 0: assignButton.disable(); break;
|
||||||
|
default: assignButton.enable(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
smodelP = new Ext.grid.RowSelectionModel({
|
||||||
|
selectSingle: false,
|
||||||
|
listeners:{
|
||||||
|
selectionchange: function(sm){
|
||||||
|
switch(sm.getCount()){
|
||||||
|
case 0: removeButton.disable(); break;
|
||||||
|
default: (ROLES.ROL_UID==pm_admin) ? removeButton.disable() : removeButton.enable(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
availableGrid = new Ext.grid.GridPanel({
|
||||||
|
layout : 'fit',
|
||||||
|
region : 'center',
|
||||||
|
ddGroup : 'assignedGridDDGroup',
|
||||||
|
store : storeA,
|
||||||
|
cm : cmodelP,
|
||||||
|
sm : smodelA,
|
||||||
|
enableDragDrop : true,
|
||||||
|
stripeRows : true,
|
||||||
|
autoExpandColumn: 'PER_CODE',
|
||||||
|
iconCls : 'icon-grid',
|
||||||
|
id : 'availableGrid',
|
||||||
|
height : 100,
|
||||||
|
autoWidth : true,
|
||||||
|
stateful : true,
|
||||||
|
stateId : 'grid',
|
||||||
|
enableColumnResize : true,
|
||||||
|
enableHdMenu : true,
|
||||||
|
frame : false,
|
||||||
|
columnLines : false,
|
||||||
|
viewConfig : {forceFit:true},
|
||||||
|
tbar: [TRANSLATIONS.ID_AVAILABLE_PERMISSIONS,{xtype: 'tbfill'},'-',assignButton],
|
||||||
|
bbar: [{xtype: 'tbfill'}, assignAllButton],
|
||||||
|
listeners: {rowdblclick: AssignPermissionAction}
|
||||||
|
});
|
||||||
|
|
||||||
|
assignedGrid = new Ext.grid.GridPanel({
|
||||||
|
layout : 'fit',
|
||||||
|
ddGroup : 'availableGridDDGroup',
|
||||||
|
store : storeP,
|
||||||
|
cm : cmodelP,
|
||||||
|
sm : smodelP,
|
||||||
|
enableDragDrop : (ROLES.ROL_UID==pm_admin) ? false : true,
|
||||||
|
stripeRows : true,
|
||||||
|
autoExpandColumn: 'PER_CODE',
|
||||||
|
iconCls : 'icon-grid',
|
||||||
|
id : 'assignedGrid',
|
||||||
|
height : 100,
|
||||||
|
autoWidth : true,
|
||||||
|
stateful : true,
|
||||||
|
stateId : 'grid',
|
||||||
|
enableColumnResize : true,
|
||||||
|
enableHdMenu : true,
|
||||||
|
frame : false,
|
||||||
|
columnLines : false,
|
||||||
|
viewConfig : {forceFit:true},
|
||||||
|
tbar: [TRANSLATIONS.ID_ASSIGNED_PERMISSIONS,{xtype: 'tbfill'},'-',removeButton],
|
||||||
|
bbar: [{xtype: 'tbfill'},removeAllButton],
|
||||||
|
listeners: {rowdblclick: RemovePermissionAction}
|
||||||
|
});
|
||||||
|
|
||||||
|
RefreshPermissions();
|
||||||
|
|
||||||
|
//PERMISSIONS DRAG AND DROP PANEL
|
||||||
|
PermissionsPanel = new Ext.Panel({
|
||||||
|
title : TRANSLATIONS.ID_PERMISSIONS,
|
||||||
|
autoWidth : true,
|
||||||
|
layout : 'hbox',
|
||||||
|
defaults : { flex : 1 }, //auto stretch
|
||||||
|
layoutConfig : { align : 'stretch' },
|
||||||
|
items : [availableGrid,{xtype: '', width: 10},assignedGrid],
|
||||||
|
viewConfig : {forceFit:true}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
storeU = new Ext.data.GroupingStore({
|
||||||
|
proxy : new Ext.data.HttpProxy({
|
||||||
|
url: 'data_rolesUsers?rUID=' + ROLES.ROL_UID + '&type=list'
|
||||||
|
}),
|
||||||
|
reader : new Ext.data.JsonReader( {
|
||||||
|
root: 'users',
|
||||||
|
fields : [
|
||||||
|
{name : 'USR_UID'},
|
||||||
|
{name : 'USR_USERNAME'},
|
||||||
|
{name : 'USR_FIRSTNAME'},
|
||||||
|
{name : 'USR_LASTNAME'}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
storeX = new Ext.data.GroupingStore({
|
||||||
|
proxy : new Ext.data.HttpProxy({
|
||||||
|
url: 'data_rolesUsers?rUID=' + ROLES.ROL_UID + '&type=show'
|
||||||
|
}),
|
||||||
|
reader : new Ext.data.JsonReader( {
|
||||||
|
root: 'users',
|
||||||
|
fields : [
|
||||||
|
{name : 'USR_UID'},
|
||||||
|
{name : 'USR_USERNAME'},
|
||||||
|
{name : 'USR_FIRSTNAME'},
|
||||||
|
{name : 'USR_LASTNAME'}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
cmodelU = new Ext.grid.ColumnModel({
|
||||||
|
defaults: {
|
||||||
|
width: 50,
|
||||||
|
sortable: true
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{id:'USR_UID', dataIndex: 'USR_UID', hidden:true, hideable:false},
|
||||||
|
{header: TRANSLATIONS.ID_FIRST_NAME, dataIndex: 'USR_FIRSTNAME', width: 60, align:'left'},
|
||||||
|
{header: TRANSLATIONS.ID_LAST_NAME, dataIndex: 'USR_LASTNAME', width: 60, align:'left'},
|
||||||
|
{header: TRANSLATIONS.ID_USER_NAME, dataIndex: 'USR_USERNAME', width: 60, align:'left'}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
smodelX = new Ext.grid.RowSelectionModel({
|
||||||
|
selectSingle: false,
|
||||||
|
listeners:{
|
||||||
|
selectionchange: function(sm){
|
||||||
|
switch(sm.getCount()){
|
||||||
|
case 0: assignUButton.disable(); break;
|
||||||
|
default: assignUButton.enable(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
smodelU = new Ext.grid.RowSelectionModel({
|
||||||
|
selectSingle: false,
|
||||||
|
listeners:{
|
||||||
|
selectionchange: function(sm){
|
||||||
|
switch(sm.getCount()){
|
||||||
|
case 0: removeUButton.disable(); break;
|
||||||
|
default: removeUButton.enable(); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
availableUGrid = new Ext.grid.GridPanel({
|
||||||
|
layout : 'fit',
|
||||||
|
region : 'center',
|
||||||
|
ddGroup : 'assignedUGridDDGroup',
|
||||||
|
store : storeX,
|
||||||
|
cm : cmodelU,
|
||||||
|
sm : smodelX,
|
||||||
|
enableDragDrop : true,
|
||||||
|
stripeRows : true,
|
||||||
|
autoExpandColumn: 'USR_USERNAME',
|
||||||
|
iconCls : 'icon-grid',
|
||||||
|
id : 'availableUGrid',
|
||||||
|
height : 100,
|
||||||
|
autoWidth : true,
|
||||||
|
stateful : true,
|
||||||
|
stateId : 'grid',
|
||||||
|
enableColumnResize : true,
|
||||||
|
enableHdMenu : true,
|
||||||
|
frame : false,
|
||||||
|
columnLines : false,
|
||||||
|
viewConfig : {forceFit:true},
|
||||||
|
tbar: [TRANSLATIONS.ID_AVAILABLE_USERS,{xtype: 'tbfill'},'-',assignUButton],
|
||||||
|
bbar: [{xtype: 'tbfill'}, assignUAllButton],
|
||||||
|
listeners: {rowdblclick: AssignUserAction}
|
||||||
|
});
|
||||||
|
|
||||||
|
assignedUGrid = new Ext.grid.GridPanel({
|
||||||
|
layout : 'fit',
|
||||||
|
ddGroup : 'availableUGridDDGroup',
|
||||||
|
store : storeU,
|
||||||
|
cm : cmodelU,
|
||||||
|
sm : smodelU,
|
||||||
|
enableDragDrop : true,
|
||||||
|
stripeRows : true,
|
||||||
|
autoExpandColumn: 'USR_USERNAME',
|
||||||
|
iconCls : 'icon-grid',
|
||||||
|
id : 'assignedUGrid',
|
||||||
|
height : 100,
|
||||||
|
autoWidth : true,
|
||||||
|
stateful : true,
|
||||||
|
stateId : 'grid',
|
||||||
|
enableColumnResize : true,
|
||||||
|
enableHdMenu : true,
|
||||||
|
frame : false,
|
||||||
|
columnLines : false,
|
||||||
|
viewConfig : {forceFit:true},
|
||||||
|
tbar: [TRANSLATIONS.ID_ASSIGNED_USERS,{xtype: 'tbfill'},'-',removeUButton],
|
||||||
|
bbar: [{xtype: 'tbfill'},removeUAllButton],
|
||||||
|
listeners: {rowdblclick: RemoveUserAction}
|
||||||
|
});
|
||||||
|
|
||||||
|
RefreshUsers();
|
||||||
|
|
||||||
|
//PERMISSIONS DRAG AND DROP PANEL
|
||||||
|
UsersPanel = new Ext.Panel({
|
||||||
|
title : TRANSLATIONS.ID_USERS,
|
||||||
|
autoWidth : true,
|
||||||
|
layout : 'hbox',
|
||||||
|
defaults : { flex : 1 }, //auto stretch
|
||||||
|
layoutConfig : { align : 'stretch' },
|
||||||
|
items : [availableUGrid,{xtype: '', width: 10},assignedUGrid],
|
||||||
|
viewConfig : {forceFit:true}
|
||||||
|
});
|
||||||
|
|
||||||
|
//NORTH PANEL WITH TITLE AND ROLE DETAILS
|
||||||
|
northPanel = new Ext.Panel({
|
||||||
|
region: 'north',
|
||||||
|
xtype: 'panel',
|
||||||
|
tbar: [TRANSLATIONS.ID_ROLES + ' : ' + ROLES.ROL_CODE,{xtype: 'tbfill'},backButton]
|
||||||
|
});
|
||||||
|
|
||||||
|
//TABS PANEL
|
||||||
|
tabsPanel = new Ext.TabPanel({
|
||||||
|
region: 'center',
|
||||||
|
activeTab: ROLES.CURRENT_TAB,
|
||||||
|
items:[UsersPanel,PermissionsPanel],
|
||||||
|
listeners:{
|
||||||
|
tabchange: function(p,t){
|
||||||
|
switch(t.title){
|
||||||
|
case TRANSLATIONS.ID_PERMISSIONS:
|
||||||
|
sw_func_permissions ? DoNothing() : DDLoadPermissions();
|
||||||
|
break;
|
||||||
|
case TRANSLATIONS.ID_USERS:
|
||||||
|
sw_func_users ? DoNothing() : DDLoadUsers();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//LOAD ALL PANELS
|
||||||
|
viewport = new Ext.Viewport({
|
||||||
|
layout: 'border',
|
||||||
|
items: [northPanel, tabsPanel]
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//Do Nothing Function
|
||||||
|
DoNothing = function(){}
|
||||||
|
|
||||||
|
//Return to Roles Main Page
|
||||||
|
BackToRoles = function(){
|
||||||
|
location.href = 'roles_List';
|
||||||
|
}
|
||||||
|
|
||||||
|
//Loads Drag N Drop Functionality for Permissions
|
||||||
|
DDLoadPermissions = function(){
|
||||||
|
//PERMISSIONS DRAG N DROP AVAILABLE
|
||||||
|
if (ROLES.ROL_UID!=pm_admin){
|
||||||
|
var availableGridDropTargetEl = availableGrid.getView().scroller.dom;
|
||||||
|
var availableGridDropTarget = new Ext.dd.DropTarget(availableGridDropTargetEl, {
|
||||||
|
ddGroup : 'availableGridDDGroup',
|
||||||
|
notifyDrop : function(ddSource, e, data){
|
||||||
|
var records = ddSource.dragData.selections;
|
||||||
|
var arrAux = new Array();
|
||||||
|
for (var r=0; r < records.length; r++){
|
||||||
|
arrAux[r] = records[r].data['PER_UID'];
|
||||||
|
}
|
||||||
|
DeletePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//PERMISSIONS DRAG N DROP ASSIGNED
|
||||||
|
var assignedGridDropTargetEl = assignedGrid.getView().scroller.dom;
|
||||||
|
var assignedGridDropTarget = new Ext.dd.DropTarget(assignedGridDropTargetEl, {
|
||||||
|
ddGroup : 'assignedGridDDGroup',
|
||||||
|
notifyDrop : function(ddSource, e, data){
|
||||||
|
var records = ddSource.dragData.selections;
|
||||||
|
var arrAux = new Array();
|
||||||
|
for (var r=0; r < records.length; r++){
|
||||||
|
arrAux[r] = records[r].data['PER_UID'];
|
||||||
|
}
|
||||||
|
SavePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sw_func_permissions = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDLoadUsers = function(){
|
||||||
|
//USERS DRAG N DROP AVAILABLE
|
||||||
|
var availableUGridDropTargetEl = availableUGrid.getView().scroller.dom;
|
||||||
|
var availableUGridDropTarget = new Ext.dd.DropTarget(availableUGridDropTargetEl, {
|
||||||
|
ddGroup : 'availableUGridDDGroup',
|
||||||
|
notifyDrop : function(ddSource, e, data){
|
||||||
|
var records = ddSource.dragData.selections;
|
||||||
|
var arrAux = new Array();
|
||||||
|
for (var r=0; r < records.length; r++){
|
||||||
|
arrAux[r] = records[r].data['USR_UID'];
|
||||||
|
}
|
||||||
|
DeleteUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//USERS DRAG N DROP ASSIGNED
|
||||||
|
var assignedUGridDropTargetEl = assignedUGrid.getView().scroller.dom;
|
||||||
|
var assignedUGridDropTarget = new Ext.dd.DropTarget(assignedUGridDropTargetEl, {
|
||||||
|
ddGroup : 'assignedUGridDDGroup',
|
||||||
|
notifyDrop : function(ddSource, e, data){
|
||||||
|
var records = ddSource.dragData.selections;
|
||||||
|
var arrAux = new Array();
|
||||||
|
for (var r=0; r < records.length; r++){
|
||||||
|
arrAux[r] = records[r].data['USR_UID'];
|
||||||
|
}
|
||||||
|
SaveUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sw_func_users = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//REFRESH PERMISSION GRIDS
|
||||||
|
RefreshPermissions = function(){
|
||||||
|
availableGrid.store.load();
|
||||||
|
assignedGrid.store.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
//REFRESH USERS GRIDS
|
||||||
|
RefreshUsers = function(){
|
||||||
|
availableUGrid.store.load();
|
||||||
|
assignedUGrid.store.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
//FAILURE AJAX FUNCTION
|
||||||
|
FailureProcess = function(){
|
||||||
|
Ext.Msg.alert({title: TRANSLATIONS.ID_ROLES, msg: TRANSLATIONS.ID_MSG_AJAX_FAILURE});
|
||||||
|
}
|
||||||
|
|
||||||
|
//ASSIGN PERMISSION TO A ROLE
|
||||||
|
SavePermissionsRole = function(arr_per, function_success, function_failure){
|
||||||
|
var sw_response;
|
||||||
|
viewport.getEl().mask(TRANSLATIONS.ID_PROCESSING);
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
params: {request: 'assignPermissionToRoleMultiple', ROL_UID: ROLES.ROL_UID, PER_UID: arr_per.join(',')},
|
||||||
|
success: function(){
|
||||||
|
function_success();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
},
|
||||||
|
failure: function(){
|
||||||
|
function_failure();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//REMOVE PERMISSION FROM A ROLE
|
||||||
|
DeletePermissionsRole = function(arr_per, function_success, function_failure){
|
||||||
|
var sw_response;
|
||||||
|
viewport.getEl().mask(TRANSLATIONS.ID_PROCESSING);
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
params: {request: 'deletePermissionToRoleMultiple', ROL_UID: ROLES.ROL_UID, PER_UID: arr_per.join(',')},
|
||||||
|
success: function(){
|
||||||
|
function_success();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
},
|
||||||
|
failure: function(){
|
||||||
|
function_failure();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//AssignButton Functionality
|
||||||
|
AssignPermissionAction = function(){
|
||||||
|
rowsSelected = availableGrid.getSelectionModel().getSelections();
|
||||||
|
var arrAux = new Array();
|
||||||
|
for(var a=0; a < rowsSelected.length; a++){
|
||||||
|
arrAux[a] = rowsSelected[a].get('PER_UID');
|
||||||
|
}
|
||||||
|
SavePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
//RemoveButton Functionality
|
||||||
|
RemovePermissionAction = function(){
|
||||||
|
if (ROLES.ROL_UID != pm_admin){
|
||||||
|
rowsSelected = assignedGrid.getSelectionModel().getSelections();
|
||||||
|
var arrAux = new Array();
|
||||||
|
for(var a=0; a < rowsSelected.length; a++){
|
||||||
|
arrAux[a] = rowsSelected[a].get('PER_UID');
|
||||||
|
}
|
||||||
|
DeletePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//AssignALLButton Functionality
|
||||||
|
AssignAllPermissionsAction = function(){
|
||||||
|
var allRows = availableGrid.getStore();
|
||||||
|
var arrAux = new Array();
|
||||||
|
if (allRows.getCount()>0){
|
||||||
|
for (var r=0; r < allRows.getCount(); r++){
|
||||||
|
row = allRows.getAt(r);
|
||||||
|
arrAux[r] = row.data['PER_UID'];
|
||||||
|
}
|
||||||
|
SavePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//RevomeALLButton Functionality
|
||||||
|
RemoveAllPermissionsAction = function(){
|
||||||
|
var allRows = assignedGrid.getStore();
|
||||||
|
var arrAux = new Array();
|
||||||
|
if (allRows.getCount()>0){
|
||||||
|
for (var r=0; r < allRows.getCount(); r++){
|
||||||
|
row = allRows.getAt(r);
|
||||||
|
arrAux[r] = row.data['PER_UID'];
|
||||||
|
}
|
||||||
|
DeletePermissionsRole(arrAux,RefreshPermissions,FailureProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//ASSIGN USERS TO A ROLE
|
||||||
|
SaveUsersRole = function(arr_usr, function_success, function_failure){
|
||||||
|
var sw_response;
|
||||||
|
viewport.getEl().mask(TRANSLATIONS.ID_PROCESSING);
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
params: {request: 'assignUserToRole', ROL_UID: ROLES.ROL_UID, aUsers: arr_usr.join(',')},
|
||||||
|
success: function(){
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
function_success();
|
||||||
|
},
|
||||||
|
failure: function(){
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
function_failure();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//REMOVE USERS FROM A ROLE
|
||||||
|
DeleteUsersRole = function(arr_usr, function_success, function_failure){
|
||||||
|
var sw_response;
|
||||||
|
viewport.getEl().mask(TRANSLATIONS.ID_PROCESSING);
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: 'roles_Ajax',
|
||||||
|
params: {request: 'deleteUserRoleMultiple', ROL_UID: ROLES.ROL_UID, USR_UID: arr_usr.join(',')},
|
||||||
|
success: function(){
|
||||||
|
function_success();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
},
|
||||||
|
failure: function(){
|
||||||
|
function_failure();
|
||||||
|
viewport.getEl().unmask();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//AssignUButton Functionality
|
||||||
|
AssignUserAction = function(){
|
||||||
|
rowsSelected = availableUGrid.getSelectionModel().getSelections();
|
||||||
|
var arrAux = new Array();
|
||||||
|
for(var a=0; a < rowsSelected.length; a++){
|
||||||
|
arrAux[a] = rowsSelected[a].get('USR_UID');
|
||||||
|
}
|
||||||
|
SaveUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
//RemoveUButton Functionality
|
||||||
|
RemoveUserAction = function(){
|
||||||
|
rowsSelected = assignedUGrid.getSelectionModel().getSelections();
|
||||||
|
var arrAux = new Array();
|
||||||
|
for(var a=0; a < rowsSelected.length; a++){
|
||||||
|
arrAux[a] = rowsSelected[a].get('USR_UID');
|
||||||
|
}
|
||||||
|
DeleteUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
//AssignUALLButton Functionality
|
||||||
|
AssignAllUsersAction = function(){
|
||||||
|
var allRows = availableUGrid.getStore();
|
||||||
|
if (allRows.getCount()>0){
|
||||||
|
Ext.Msg.confirm(TRANSLATIONS.ID_CONFIRM, TRANSLATIONS.ID_MSG_CONFIRM_ASSIGN_ALL_USERS,
|
||||||
|
function(btn, text){
|
||||||
|
if (btn=="yes"){
|
||||||
|
var arrAux = new Array();
|
||||||
|
for (var r=0; r < allRows.getCount(); r++){
|
||||||
|
row = allRows.getAt(r);
|
||||||
|
arrAux[r] = row.data['USR_UID'];
|
||||||
|
}
|
||||||
|
SaveUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//RevomeALLButton Functionality
|
||||||
|
RemoveAllUsersAction = function(){
|
||||||
|
var allRows = assignedUGrid.getStore();
|
||||||
|
var arrAux = new Array();
|
||||||
|
if (allRows.getCount()>0){
|
||||||
|
for (var r=0; r < allRows.getCount(); r++){
|
||||||
|
row = allRows.getAt(r);
|
||||||
|
arrAux[r] = row.data['USR_UID'];
|
||||||
|
}
|
||||||
|
DeleteUsersRole(arrAux,RefreshUsers,FailureProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user