2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2012-10-18 09:27:23 -04:00
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
/**
|
|
|
|
|
* class.rbac.php
|
2012-10-18 09:27:23 -04:00
|
|
|
*
|
2011-08-24 19:30:03 -04:00
|
|
|
* @package gulliver.system
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
2011-01-24 21:07:14 +00:00
|
|
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2012-10-18 09:27:23 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-18 09:27:23 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* File: $Id$
|
|
|
|
|
*
|
|
|
|
|
* RBAC class definition
|
|
|
|
|
*
|
2011-01-14 11:51:34 +00:00
|
|
|
* @package gulliver.system
|
2010-12-02 23:34:41 +00:00
|
|
|
* @copyright (C) 2002 by Colosa Development Team.
|
|
|
|
|
* @link http://www.colosa.com
|
2012-10-18 09:27:23 -04:00
|
|
|
* @link http://manuals.colosa.com/gulliver/rbac.html
|
2010-12-02 23:34:41 +00:00
|
|
|
* @author Fernando Ontiveros
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clase Wrapper
|
|
|
|
|
*
|
2011-01-14 11:51:34 +00:00
|
|
|
* @package gulliver.system
|
2010-12-02 23:34:41 +00:00
|
|
|
* @author Fernando Ontiveros
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class RBAC
|
|
|
|
|
{
|
2016-03-03 12:09:38 -04:00
|
|
|
const SETUPERMISSIONUID= '00000000000000000000000000000002';
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @access private
|
|
|
|
|
* @var $userObj
|
|
|
|
|
*/
|
|
|
|
|
public $userObj;
|
|
|
|
|
public $usersPermissionsObj;
|
|
|
|
|
public $usersRolesObj;
|
|
|
|
|
public $systemObj;
|
|
|
|
|
public $rolesObj;
|
|
|
|
|
public $permissionsObj;
|
|
|
|
|
public $userloggedobj;
|
|
|
|
|
public $currentSystemobj;
|
|
|
|
|
public $rolesPermissionsObj;
|
|
|
|
|
public $authSourcesObj;
|
|
|
|
|
|
|
|
|
|
public $aUserInfo = array ();
|
|
|
|
|
public $aRbacPlugins = array ();
|
|
|
|
|
public $sSystem = '';
|
|
|
|
|
|
|
|
|
|
public $singleSignOn = false;
|
|
|
|
|
|
|
|
|
|
private static $instance = null;
|
2017-05-19 16:31:27 -04:00
|
|
|
public $authorizedActions = array();
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
public function __construct ()
|
|
|
|
|
{
|
2017-05-19 16:31:27 -04:00
|
|
|
$this->authorizedActions = array(
|
|
|
|
|
'users_Ajax.php' => array(
|
|
|
|
|
'availableUsers' => array('PM_FACTORY'),
|
|
|
|
|
'assign' => array('PM_FACTORY'),
|
2017-05-23 16:12:45 -04:00
|
|
|
'changeView' => array(),
|
2017-05-19 16:31:27 -04:00
|
|
|
'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'),
|
2017-05-23 16:12:45 -04:00
|
|
|
'updatePageSize' => array(),
|
2017-05-19 16:31:27 -04:00
|
|
|
'summaryUserData' => array('PM_USERS'),
|
2017-05-30 09:59:09 -04:00
|
|
|
'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'),
|
2017-06-30 10:13:18 -04:00
|
|
|
'streamSkin' => array('PM_SETUP_SKIN'),
|
2017-05-30 09:59:09 -04:00
|
|
|
'addTarFolder' => array('PM_SETUP_SKIN'),
|
2017-06-30 10:13:18 -04:00
|
|
|
'copy_skin_folder' => array('PM_SETUP_SKIN')
|
2017-05-30 09:59:09 -04:00
|
|
|
),
|
|
|
|
|
'processes_DownloadFile.php' => array(
|
|
|
|
|
'downloadFileHash' => array('PM_FACTORY')
|
2017-06-01 13:53:49 -04:00
|
|
|
),
|
|
|
|
|
'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()
|
2017-06-20 16:10:44 -04:00
|
|
|
),
|
|
|
|
|
'home.php' => array(
|
|
|
|
|
'login' => array('PM_LOGIN'),
|
|
|
|
|
'index' => array('PM_CASES'),
|
|
|
|
|
'indexSingle' => array('PM_CASES'),
|
|
|
|
|
'appList' => array('PM_CASES'),
|
|
|
|
|
'appAdvancedSearch' => array('PM_ALLCASES'),
|
|
|
|
|
'getApps' => array('PM_ALLCASES'),
|
|
|
|
|
'getAppsData' => array('PM_ALLCASES'),
|
|
|
|
|
'startCase' => array('PM_CASES'),
|
|
|
|
|
'error' => array(),
|
|
|
|
|
'getUserArray' => array('PM_ALLCASES'),
|
|
|
|
|
'getCategoryArray' => array('PM_ALLCASES'),
|
|
|
|
|
'getAllUsersArray' => array('PM_ALLCASES'),
|
|
|
|
|
'getStatusArray' => array('PM_ALLCASES'),
|
2017-07-04 10:10:09 -04:00
|
|
|
'getProcessArray' => array('PM_ALLCASES'),
|
|
|
|
|
'getProcesses' => array('PM_ALLCASES'),
|
|
|
|
|
'getUsers' => array('PM_ALLCASES')
|
2017-05-19 16:31:27 -04:00
|
|
|
)
|
2017-05-30 09:59:09 -04:00
|
|
|
|
2017-05-19 16:31:27 -04:00
|
|
|
);
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* to get singleton instance
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @return object
|
|
|
|
|
*/
|
|
|
|
|
public function &getSingleton ()
|
|
|
|
|
{
|
|
|
|
|
if (self::$instance == null) {
|
|
|
|
|
self::$instance = new RBAC();
|
|
|
|
|
}
|
|
|
|
|
return self::$instance;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-02 15:21:06 -04:00
|
|
|
/**
|
2012-10-18 09:27:23 -04:00
|
|
|
* to get start with some classess
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @return object
|
|
|
|
|
*/
|
|
|
|
|
public function initRBAC ()
|
|
|
|
|
{
|
|
|
|
|
if (is_null( $this->userObj )) {
|
|
|
|
|
require_once ("classes/model/RbacUsers.php");
|
|
|
|
|
$this->userObj = new RbacUsers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->systemObj )) {
|
|
|
|
|
require_once ("classes/model/Systems.php");
|
|
|
|
|
$this->systemObj = new Systems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->usersRolesObj )) {
|
|
|
|
|
require_once ("classes/model/UsersRoles.php");
|
|
|
|
|
$this->usersRolesObj = new UsersRoles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->rolesObj )) {
|
|
|
|
|
require_once ("classes/model/Roles.php");
|
|
|
|
|
$this->rolesObj = new Roles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->permissionsObj )) {
|
|
|
|
|
require_once ("classes/model/Permissions.php");
|
|
|
|
|
$this->permissionsObj = new Permissions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->rolesPermissionsObj )) {
|
|
|
|
|
require_once ("classes/model/RolesPermissions.php");
|
|
|
|
|
$this->rolesPermissionsObj = new RolesPermissions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_null( $this->authSourcesObj )) {
|
|
|
|
|
require_once 'classes/model/AuthenticationSource.php';
|
|
|
|
|
$this->authSourcesObj = new AuthenticationSource();
|
|
|
|
|
}
|
|
|
|
|
//hook for RBAC plugins
|
|
|
|
|
$pathPlugins = PATH_RBAC . 'plugins';
|
|
|
|
|
if (is_dir( $pathPlugins )) {
|
|
|
|
|
if ($handle = opendir( $pathPlugins )) {
|
|
|
|
|
while (false !== ($file = readdir( $handle ))) {
|
|
|
|
|
if (strpos( $file, '.php', 1 ) && is_file( $pathPlugins . PATH_SEP . $file ) && substr( $file, 0, 6 ) == 'class.' && substr( $file, - 4 ) == '.php') {
|
|
|
|
|
|
|
|
|
|
$sClassName = substr( $file, 6, strlen( $file ) - 10 );
|
|
|
|
|
require_once ($pathPlugins . PATH_SEP . $file);
|
|
|
|
|
$this->aRbacPlugins[] = $sClassName;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-10 20:01:58 -04:00
|
|
|
if (!in_array('ldapAdvanced', $this->aRbacPlugins)) {
|
|
|
|
|
G::LoadClass('ldapAdvanced');
|
|
|
|
|
if (class_exists('ldapAdvanced')) {
|
|
|
|
|
$this->aRbacPlugins[] = 'ldapAdvanced';
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gets the Role and their permissions for Administrator Processmaker
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @return $this->permissionsAdmin[ $permissionsAdmin ]
|
|
|
|
|
*/
|
2016-03-03 12:09:38 -04:00
|
|
|
public function loadPermissionAdmin()
|
2012-10-18 09:27:23 -04:00
|
|
|
{
|
2016-03-03 12:09:38 -04:00
|
|
|
$permissionsAdmin = array(array("PER_UID" => "00000000000000000000000000000001", "PER_CODE" => "PM_LOGIN",
|
|
|
|
|
"PER_NAME" => "Login"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000002", "PER_CODE" => "PM_SETUP", "PER_NAME" => "Setup"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000003", "PER_CODE" => "PM_USERS", "PER_NAME" => "Users"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000004", "PER_CODE" => "PM_FACTORY", "PER_NAME" => "Design
|
|
|
|
|
Process"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000005", "PER_CODE" => "PM_CASES", "PER_NAME" => "Create Users"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000006", "PER_CODE" => "PM_ALLCASES", "PER_NAME" => "All Cases"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000007", "PER_CODE" => "PM_REASSIGNCASE", "PER_NAME" =>
|
|
|
|
|
"Reassign case"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000008", "PER_CODE" => "PM_REPORTS", "PER_NAME" => "PM reports"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000009", "PER_CODE" => "PM_SUPERVISOR", "PER_NAME" =>
|
|
|
|
|
"Supervisor"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000010", "PER_CODE" => "PM_SETUP_ADVANCE", "PER_NAME" =>
|
|
|
|
|
"Setup Advanced"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000011", "PER_CODE" => "PM_DASHBOARD", "PER_NAME" => "Dashboard"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000012", "PER_CODE" => "PM_WEBDAV", "PER_NAME" => "WebDav"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000013", "PER_CODE" => "PM_DELETECASE", "PER_NAME" => "Cancel
|
|
|
|
|
cases"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000014", "PER_CODE" => "PM_EDITPERSONALINFO", "PER_NAME" =>
|
|
|
|
|
"Edit Personal Info"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000015", "PER_CODE" => "PM_FOLDERS_VIEW", "PER_NAME" => "View
|
|
|
|
|
Folders"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000016", "PER_CODE" => "PM_FOLDERS_ADD_FOLDER", "PER_NAME" =>
|
|
|
|
|
"Delete folders"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000017", "PER_CODE" => "PM_FOLDERS_ADD_FILE", "PER_NAME" =>
|
|
|
|
|
"Delete folders"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000018", "PER_CODE" => "PM_CANCELCASE", "PER_NAME" => "Cancel
|
|
|
|
|
cases"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000019", "PER_CODE" => "PM_FOLDER_DELETE", "PER_NAME" =>
|
|
|
|
|
"Cancel cases"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000020", "PER_CODE" => "PM_SETUP_LOGO", "PER_NAME" => "Setup
|
|
|
|
|
Logo"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000021", "PER_CODE" => "PM_SETUP_EMAIL", "PER_NAME" => "Setup
|
|
|
|
|
Email"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000022", "PER_CODE" => "PM_SETUP_CALENDAR", "PER_NAME" =>
|
|
|
|
|
"Setup Calendar"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000023", "PER_CODE" => "PM_SETUP_PROCESS_CATEGORIES",
|
|
|
|
|
"PER_NAME" => "Setup Process Categories"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000024", "PER_CODE" => "PM_SETUP_CLEAR_CACHE", "PER_NAME" =>
|
|
|
|
|
"Setup Clear Cache"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000025", "PER_CODE" => "PM_SETUP_HEART_BEAT", "PER_NAME" =>
|
|
|
|
|
"Setup Heart Beat"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000026", "PER_CODE" => "PM_SETUP_ENVIRONMENT", "PER_NAME" =>
|
|
|
|
|
"Setup Environment"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000027", "PER_CODE" => "PM_SETUP_PM_TABLES", "PER_NAME" =>
|
|
|
|
|
"Setup PM Tables"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000028", "PER_CODE" => "PM_SETUP_LOGIN", "PER_NAME" => "Setup
|
|
|
|
|
Login"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000029", "PER_CODE" => "PM_SETUP_DASHBOARDS", "PER_NAME" =>
|
|
|
|
|
"Setup Dashboards"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000030", "PER_CODE" => "PM_SETUP_LANGUAGE", "PER_NAME" =>
|
|
|
|
|
"Setup Language"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000031", "PER_CODE" => "PM_SETUP_SKIN", "PER_NAME" => "Setup
|
|
|
|
|
Skin"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000032", "PER_CODE" => "PM_SETUP_CASES_LIST_CACHE_BUILDER",
|
|
|
|
|
"PER_NAME" => "Setup Case List Cache Builder"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000033", "PER_CODE" => "PM_SETUP_PLUGINS", "PER_NAME" =>
|
|
|
|
|
"Setup Plugins"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000034", "PER_CODE" =>
|
|
|
|
|
"PM_SETUP_USERS_AUTHENTICATION_SOURCES", "PER_NAME" => "Setup User Authentication Sources"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000035", "PER_CODE" => "PM_SETUP_LOGS", "PER_NAME" => "Setup
|
|
|
|
|
Logs"
|
2016-03-29 16:29:05 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000036", "PER_CODE" => "PM_DELETE_PROCESS_CASES", "PER_NAME" =>
|
2016-03-03 12:09:38 -04:00
|
|
|
"Delete process cases"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000037", "PER_CODE" => "PM_EDITPERSONALINFO_CALENDAR",
|
|
|
|
|
"PER_NAME" => "Edit personal info Calendar"
|
2016-06-13 13:14:37 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000038", "PER_CODE" => "PM_UNCANCELCASE",
|
|
|
|
|
"PER_NAME" => "Undo cancel case"
|
2016-06-15 09:07:51 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000039", "PER_CODE" => "PM_REST_API_APPLICATIONS",
|
2016-06-14 13:07:06 -04:00
|
|
|
"PER_NAME" => "Create rest API Aplications"
|
2016-07-18 10:42:38 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000040", "PER_CODE" => "PM_EDIT_USER_PROFILE_FIRST_NAME",
|
|
|
|
|
"PER_NAME" => "Edit User profile First Name"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000041", "PER_CODE" => "PM_EDIT_USER_PROFILE_LAST_NAME",
|
|
|
|
|
"PER_NAME" => "Edit User profile Last Name"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000042", "PER_CODE" => "PM_EDIT_USER_PROFILE_USERNAME",
|
|
|
|
|
"PER_NAME" => "Edit User profile Username"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000043", "PER_CODE" => "PM_EDIT_USER_PROFILE_EMAIL",
|
|
|
|
|
"PER_NAME" => "Edit User profile Email"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000044", "PER_CODE" => "PM_EDIT_USER_PROFILE_ADDRESS",
|
|
|
|
|
"PER_NAME" => "Edit User profile Address"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000045", "PER_CODE" => "PM_EDIT_USER_PROFILE_ZIP_CODE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Zip Code"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000046", "PER_CODE" => "PM_EDIT_USER_PROFILE_COUNTRY",
|
|
|
|
|
"PER_NAME" => "Edit User profile Country"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000047", "PER_CODE" => "PM_EDIT_USER_PROFILE_STATE_OR_REGION",
|
|
|
|
|
"PER_NAME" => "Edit User profile State or Region"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000048", "PER_CODE" => "PM_EDIT_USER_PROFILE_LOCATION",
|
|
|
|
|
"PER_NAME" => "Edit User profile Location"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000049", "PER_CODE" => "PM_EDIT_USER_PROFILE_PHONE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Phone"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000050", "PER_CODE" => "PM_EDIT_USER_PROFILE_POSITION",
|
|
|
|
|
"PER_NAME" => "Edit User profile Position"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000051", "PER_CODE" => "PM_EDIT_USER_PROFILE_REPLACED_BY",
|
|
|
|
|
"PER_NAME" => "Edit User profile Replaced By"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000052", "PER_CODE" => "PM_EDIT_USER_PROFILE_EXPIRATION_DATE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Expiration Date"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000053", "PER_CODE" => "PM_EDIT_USER_PROFILE_CALENDAR",
|
|
|
|
|
"PER_NAME" => "Edit User profile Calendar"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000054", "PER_CODE" => "PM_EDIT_USER_PROFILE_STATUS",
|
|
|
|
|
"PER_NAME" => "Edit User profile Status"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000055", "PER_CODE" => "PM_EDIT_USER_PROFILE_ROLE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Role"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000056", "PER_CODE" => "PM_EDIT_USER_PROFILE_TIME_ZONE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Time Zone"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000057", "PER_CODE" => "PM_EDIT_USER_PROFILE_DEFAULT_LANGUAGE",
|
|
|
|
|
"PER_NAME" => "Edit User profile Default Language"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000058", "PER_CODE" => "PM_EDIT_USER_PROFILE_COSTS",
|
|
|
|
|
"PER_NAME" => "Edit User profile Costs"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000059", "PER_CODE" => "PM_EDIT_USER_PROFILE_PASSWORD",
|
|
|
|
|
"PER_NAME" => "Edit User profile Password"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000060", "PER_CODE" => "PM_EDIT_USER_PROFILE_USER_MUST_CHANGE_PASSWORD_AT_NEXT_LOGON",
|
|
|
|
|
"PER_NAME" => "Edit User profile Must Change Password at next Logon"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000061", "PER_CODE" => "PM_EDIT_USER_PROFILE_PHOTO",
|
|
|
|
|
"PER_NAME" => "Edit User profile Photo"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000062", "PER_CODE" => "PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS",
|
|
|
|
|
"PER_NAME" => "Edit User profile Default Main Menu Options"
|
|
|
|
|
), array("PER_UID" => "00000000000000000000000000000063", "PER_CODE" => "PM_EDIT_USER_PROFILE_DEFAULT_CASES_MENU_OPTIONS",
|
|
|
|
|
"PER_NAME" => "Edit User profile Default Cases Menu Options"
|
2016-08-29 10:12:08 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000064", "PER_CODE" => "PM_REASSIGNCASE_SUPERVISOR",
|
|
|
|
|
"PER_NAME" => "Reassign case supervisor"
|
2017-03-27 13:36:26 -04:00
|
|
|
), array("PER_UID" => "00000000000000000000000000000065", "PER_CODE" => "PM_SETUP_CUSTOM_CASES_LIST",
|
|
|
|
|
"PER_NAME" => "Setup Custom Cases List"
|
2012-10-18 09:27:23 -04:00
|
|
|
)
|
2012-10-02 15:21:06 -04:00
|
|
|
);
|
|
|
|
|
return $permissionsAdmin;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* Gets the roles and permission for one RBAC_user
|
|
|
|
|
*
|
|
|
|
|
* gets the Role and their permissions for one User
|
|
|
|
|
*
|
|
|
|
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sSystem the system
|
|
|
|
|
* @param string $sUser the user
|
|
|
|
|
* @return $this->aUserInfo[ $sSystem ]
|
|
|
|
|
*/
|
|
|
|
|
public function loadUserRolePermission ($sSystem, $sUser)
|
|
|
|
|
{
|
|
|
|
|
//in previous versions we provided a path data and session we will cache the session Info for this user
|
|
|
|
|
//now this is deprecated, and all the aUserInfo is in the memcache
|
|
|
|
|
$this->sSystem = $sSystem;
|
|
|
|
|
$fieldsSystem = $this->systemObj->loadByCode( $sSystem );
|
|
|
|
|
$fieldsRoles = $this->usersRolesObj->getRolesBySystem( $fieldsSystem['SYS_UID'], $sUser );
|
|
|
|
|
$fieldsPermissions = $this->usersRolesObj->getAllPermissions( $fieldsRoles['ROL_UID'], $sUser );
|
|
|
|
|
$this->aUserInfo['USER_INFO'] = $this->userObj->load( $sUser );
|
|
|
|
|
$this->aUserInfo[$sSystem]['SYS_UID'] = $fieldsSystem['SYS_UID'];
|
|
|
|
|
$this->aUserInfo[$sSystem]['ROLE'] = $fieldsRoles;
|
|
|
|
|
$this->aUserInfo[$sSystem]['PERMISSIONS'] = $fieldsPermissions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* verification the register automatic
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $strUser the system
|
|
|
|
|
* @param string $strPass the password
|
|
|
|
|
* @return $res
|
|
|
|
|
*/
|
|
|
|
|
public function checkAutomaticRegister ($strUser, $strPass)
|
|
|
|
|
{
|
|
|
|
|
$result = - 1; //default return value,
|
|
|
|
|
|
|
|
|
|
foreach ($this->aRbacPlugins as $sClassName) {
|
|
|
|
|
$plugin = new $sClassName();
|
|
|
|
|
if (method_exists( $plugin, 'automaticRegister' )) {
|
|
|
|
|
$oCriteria = new Criteria( 'rbac' );
|
|
|
|
|
$oCriteria->add( AuthenticationSourcePeer::AUTH_SOURCE_PROVIDER, $sClassName );
|
|
|
|
|
$oCriteria->addAscendingOrderByColumn( AuthenticationSourcePeer::AUTH_SOURCE_NAME );
|
2014-10-07 14:39:40 -04:00
|
|
|
$oDataset = AuthenticationSourcePeer::doSelectRS( $oCriteria, Propel::getDbConnection('rbac_ro') );
|
2012-10-18 09:27:23 -04:00
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
|
|
|
|
while (is_array( $aRow )) {
|
|
|
|
|
$aRow = array_merge( $aRow, unserialize( $aRow['AUTH_SOURCE_DATA'] ) );
|
|
|
|
|
//Check if this authsource is enabled for AutoRegister, if not skip this
|
|
|
|
|
if ($aRow['AUTH_SOURCE_AUTO_REGISTER'] == 1) {
|
|
|
|
|
$plugin->sAuthSource = $aRow['AUTH_SOURCE_UID'];
|
|
|
|
|
$plugin->sSystem = $this->sSystem;
|
|
|
|
|
//search the usersRolesObj
|
|
|
|
|
//create the users in ProcessMaker
|
|
|
|
|
$res = $plugin->automaticRegister( $aRow, $strUser, $strPass );
|
|
|
|
|
if ($res == 1) {
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$aRow = $oDataset->getRow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function is checking the register automatic without authentication
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $sAuthType
|
|
|
|
|
* @param string $sAuthSource
|
|
|
|
|
* @param string $aUserFields
|
|
|
|
|
* @param string $sAuthUserDn
|
|
|
|
|
* @param string $strPass
|
|
|
|
|
* @return number -2: wrong password
|
|
|
|
|
* -3: inactive user
|
|
|
|
|
* -4: due date
|
|
|
|
|
* -5: invalid authentication source
|
|
|
|
|
*/
|
|
|
|
|
public function VerifyWithOtherAuthenticationSource ($sAuthType, $aUserFields, $strPass)
|
|
|
|
|
{
|
2014-06-26 17:13:26 -04:00
|
|
|
if ($sAuthType == '' || $sAuthType == 'MYSQL') {
|
|
|
|
|
//check if the user is active
|
|
|
|
|
if ($aUserFields['USR_STATUS'] != 1) {
|
|
|
|
|
return - 3; //inactive user
|
|
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
2014-06-26 17:13:26 -04:00
|
|
|
//check if the user's due date is valid
|
|
|
|
|
if ($aUserFields['USR_DUE_DATE'] < date( 'Y-m-d' )) {
|
|
|
|
|
return - 4; //due date
|
|
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($this->aRbacPlugins as $sClassName) {
|
|
|
|
|
if (strtolower( $sClassName ) == strtolower( $sAuthType )) {
|
|
|
|
|
$plugin = new $sClassName();
|
|
|
|
|
$plugin->sAuthSource = $aUserFields["UID_AUTH_SOURCE"];
|
|
|
|
|
$plugin->sSystem = $this->sSystem;
|
|
|
|
|
|
2012-11-05 09:57:09 -04:00
|
|
|
$bValidUser = false;
|
|
|
|
|
$bValidUser = $plugin->VerifyLogin( $aUserFields["USR_AUTH_USER_DN"], $strPass );
|
2012-10-18 09:27:23 -04:00
|
|
|
if ($bValidUser === true) {
|
|
|
|
|
return ($aUserFields['USR_UID']);
|
|
|
|
|
} else {
|
|
|
|
|
return - 2; //wrong password
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
return - 5; //invalid authentication source
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* authentication of an user through of class RBAC_user
|
|
|
|
|
*
|
|
|
|
|
* checking that an user has right to start an applicaton
|
|
|
|
|
*
|
|
|
|
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $strUser UserId (login) an user
|
|
|
|
|
* @param string $strPass Password
|
|
|
|
|
* @return -1: no user
|
|
|
|
|
* -2: wrong password
|
|
|
|
|
* -3: inactive usuario
|
|
|
|
|
* -4: due date
|
|
|
|
|
* -5: invalid authentication source ( **new )
|
|
|
|
|
* n : uid of user
|
|
|
|
|
*/
|
|
|
|
|
public function VerifyLogin ($strUser, $strPass)
|
|
|
|
|
{
|
2014-12-03 13:42:09 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
if (!class_exists('pmLicenseManager')) {
|
|
|
|
|
G::LoadClass('pmLicenseManager');
|
|
|
|
|
}
|
|
|
|
|
$licenseManager =& pmLicenseManager::getSingleton();
|
2015-03-26 10:19:43 -04:00
|
|
|
if (in_array(G::encryptOld($licenseManager->result), array('38afd7ae34bd5e3e6fc170d8b09178a3', 'ba2b45bdc11e2a4a6e86aab2ac693cbb'))) {
|
2014-12-03 13:42:09 -04:00
|
|
|
return -7;
|
|
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2013-05-13 17:09:54 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
if (strlen( $strPass ) == 0) {
|
|
|
|
|
return - 2;
|
|
|
|
|
}
|
|
|
|
|
//check if the user exists in the table RB_WORKFLOW.USERS
|
|
|
|
|
$this->initRBAC();
|
|
|
|
|
//if the user exists, the VerifyUser function will return the user properties
|
|
|
|
|
if ($this->userObj->verifyUser( $strUser ) == 0) {
|
|
|
|
|
//here we are checking if the automatic user Register is enabled, ioc return -1
|
|
|
|
|
$res = $this->checkAutomaticRegister( $strUser, $strPass );
|
|
|
|
|
if ($res == 1) {
|
|
|
|
|
$this->userObj->verifyUser( $strUser );
|
|
|
|
|
} else {
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//default values
|
|
|
|
|
$sAuthType = 'mysql';
|
|
|
|
|
if (isset( $this->userObj->fields['USR_AUTH_TYPE'] )) {
|
|
|
|
|
$sAuthType = strtolower( $this->userObj->fields['USR_AUTH_TYPE'] );
|
|
|
|
|
}
|
2012-11-05 09:57:09 -04:00
|
|
|
//Hook for RBAC plugins
|
2012-10-18 09:27:23 -04:00
|
|
|
if ($sAuthType != "mysql" && $sAuthType != "") {
|
|
|
|
|
$res = $this->VerifyWithOtherAuthenticationSource( $sAuthType, $this->userObj->fields, $strPass );
|
|
|
|
|
return $res;
|
|
|
|
|
} else {
|
|
|
|
|
$this->userObj->reuseUserFields = true;
|
|
|
|
|
$res = $this->userObj->VerifyLogin( $strUser, $strPass );
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if the user exist or not exists, the argument is the UserName
|
|
|
|
|
*
|
|
|
|
|
* @author Everth S. Berrios
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $strUser
|
|
|
|
|
* @return $res
|
|
|
|
|
*/
|
|
|
|
|
public function verifyUser ($strUser)
|
|
|
|
|
{
|
|
|
|
|
$res = $this->userObj->verifyUser( $strUser );
|
2010-12-02 23:34:41 +00:00
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* Verify if the user exist or not exists, the argument is the UserUID
|
|
|
|
|
*
|
|
|
|
|
* @author Everth S. Berrios
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $strUserId
|
|
|
|
|
* @return $res
|
|
|
|
|
*/
|
|
|
|
|
public function verifyUserId ($strUserId)
|
|
|
|
|
{
|
|
|
|
|
$res = $this->userObj->verifyUserId( $strUserId );
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* Verify if the user has a right over the permission
|
|
|
|
|
*
|
|
|
|
|
* @author Fernando Ontiveros
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid id of user
|
|
|
|
|
* @param string $system Code of System
|
|
|
|
|
* @param string $perm id of Permissions
|
2016-03-03 12:09:38 -04:00
|
|
|
* @return int 1: If it is ok
|
2012-10-18 09:27:23 -04:00
|
|
|
* -1: System doesn't exists
|
|
|
|
|
* -2: The User has not a Role
|
|
|
|
|
* -3: The User has not this Permission.
|
|
|
|
|
*/
|
|
|
|
|
public function userCanAccess ($perm)
|
|
|
|
|
{
|
|
|
|
|
if (isset( $this->aUserInfo[$this->sSystem]['PERMISSIONS'] )) {
|
|
|
|
|
$res = - 3;
|
|
|
|
|
//if ( !isset ( $this->aUserInfo[ $this->sSystem ]['ROLE'. 'x'] ) ) $res = -2;
|
|
|
|
|
foreach ($this->aUserInfo[$this->sSystem]['PERMISSIONS'] as $key => $val) {
|
|
|
|
|
if ($perm == $val['PER_CODE']) {
|
|
|
|
|
$res = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$res = - 1;
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-10 12:29:10 -04:00
|
|
|
return $res;
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
2012-10-10 12:29:10 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* to create an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @param string $sRolCode
|
|
|
|
|
* @return $sUserUID
|
|
|
|
|
*/
|
|
|
|
|
public function createUser ($aData = array(), $sRolCode = '')
|
|
|
|
|
{
|
2014-06-13 12:54:28 -04:00
|
|
|
if ($aData["USR_STATUS"] . "" == "1") {
|
|
|
|
|
$aData["USR_STATUS"] = "ACTIVE";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($aData["USR_STATUS"] . "" == "0") {
|
|
|
|
|
$aData["USR_STATUS"] = "INACTIVE";
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
if ($aData['USR_STATUS'] == 'ACTIVE') {
|
|
|
|
|
$aData['USR_STATUS'] = 1;
|
|
|
|
|
}
|
|
|
|
|
if ($aData['USR_STATUS'] == 'INACTIVE') {
|
|
|
|
|
$aData['USR_STATUS'] = 0;
|
|
|
|
|
}
|
2014-06-13 12:54:28 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
$sUserUID = $this->userObj->create( $aData );
|
2014-06-13 12:54:28 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
if ($sRolCode != '') {
|
|
|
|
|
$this->assignRoleToUser( $sUserUID, $sRolCode );
|
|
|
|
|
}
|
|
|
|
|
return $sUserUID;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* updated an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @param string $sRolCode
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function updateUser ($aData = array(), $sRolCode = '')
|
|
|
|
|
{
|
|
|
|
|
if (isset( $aData['USR_STATUS'] )) {
|
|
|
|
|
if ($aData['USR_STATUS'] == 'ACTIVE') {
|
|
|
|
|
$aData['USR_STATUS'] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->userObj->update( $aData );
|
|
|
|
|
if ($sRolCode != '') {
|
|
|
|
|
$this->removeRolesFromUser( $aData['USR_UID'] );
|
|
|
|
|
$this->assignRoleToUser( $aData['USR_UID'], $sRolCode );
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* to put role an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $sUserUID
|
|
|
|
|
* @param string $sRolCode
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function assignRoleToUser ($sUserUID = '', $sRolCode = '')
|
|
|
|
|
{
|
|
|
|
|
$aRol = $this->rolesObj->loadByCode( $sRolCode );
|
|
|
|
|
$this->usersRolesObj->create( $sUserUID, $aRol['ROL_UID'] );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* remove a role from an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $sUserUID
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function removeRolesFromUser ($sUserUID = '')
|
|
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'rbac' );
|
|
|
|
|
$oCriteria->add( UsersRolesPeer::USR_UID, $sUserUID );
|
|
|
|
|
UsersRolesPeer::doDelete( $oCriteria );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* change status of an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $sUserUID
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function changeUserStatus ($sUserUID = '', $sStatus = 'ACTIVE')
|
2014-06-13 12:54:28 -04:00
|
|
|
{
|
2013-05-13 17:09:54 -04:00
|
|
|
if ($sStatus === 'ACTIVE') {
|
2012-10-18 09:27:23 -04:00
|
|
|
$sStatus = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$aFields = $this->userObj->load( $sUserUID );
|
|
|
|
|
$aFields['USR_STATUS'] = $sStatus;
|
|
|
|
|
$this->userObj->update( $aFields );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* remove an user
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param array $sUserUID
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function removeUser ($sUserUID = '')
|
|
|
|
|
{
|
|
|
|
|
$this->userObj->remove( $sUserUID );
|
|
|
|
|
$this->removeRolesFromUser( $sUserUID );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getting user's basic information (rbac)
|
|
|
|
|
*
|
|
|
|
|
* getting datas that is saved in rbac
|
|
|
|
|
*
|
|
|
|
|
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $uid id user
|
|
|
|
|
* @return array with info of an user
|
|
|
|
|
*/
|
|
|
|
|
public function load ($uid)
|
|
|
|
|
{
|
|
|
|
|
$this->initRBAC();
|
|
|
|
|
$this->userObj->Fields = $this->userObj->load( $uid );
|
|
|
|
|
|
|
|
|
|
$fieldsSystem = $this->systemObj->loadByCode( $this->sSystem );
|
|
|
|
|
$fieldsRoles = $this->usersRolesObj->getRolesBySystem( $fieldsSystem['SYS_UID'], $uid );
|
|
|
|
|
$this->userObj->Fields['USR_ROLE'] = $fieldsRoles['ROL_CODE'];
|
|
|
|
|
return $this->userObj->Fields;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* loading permission by code
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sCode
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
// function loadPermissionByCode($sCode) {
|
|
|
|
|
// return $this->permissionsObj->loadByCode($sCode);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* create permission
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sCode
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function createPermision ($sCode)
|
|
|
|
|
{
|
2013-03-15 14:12:40 -04:00
|
|
|
return $this->permissionsObj->create( array ('PER_CODE' => $sCode) );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* loading role by code
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sCode
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
// function loadRoleByCode($sCode) {
|
|
|
|
|
// return $this->rolesObj->loadByCode($sCode);
|
|
|
|
|
// }
|
2011-08-24 19:30:03 -04:00
|
|
|
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* list all roles
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $systemCode
|
|
|
|
|
* @return $this->rolesObj
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function listAllRoles ($systemCode = 'PROCESSMAKER')
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->listAllRoles( $systemCode );
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* getting all roles
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $systemCode
|
|
|
|
|
* @return $this->rolesObj->getAllRoles
|
|
|
|
|
*/
|
|
|
|
|
public function getAllRoles ($systemCode = 'PROCESSMAKER')
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getAllRoles( $systemCode );
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* getting all roles by filter
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string $filter
|
|
|
|
|
* @return $this->rolesObj->getAllRolesFilter
|
|
|
|
|
*/
|
|
|
|
|
public function getAllRolesFilter ($start, $limit, $filter)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getAllRolesFilter( $start, $limit, $filter );
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* list all permission
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $systemCode
|
|
|
|
|
* @return $this->rolesObj->listAllPermissions
|
|
|
|
|
*/
|
|
|
|
|
public function listAllPermissions ($systemCode = 'PROCESSMAKER')
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->listAllPermissions( $systemCode );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function creates a role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return $this->rolesObj->createRole
|
|
|
|
|
*/
|
|
|
|
|
public function createRole ($aData)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->createRole( $aData );
|
2011-12-23 11:40:04 -04:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function removes a role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* $@return $this->rolesObj->removeRole
|
|
|
|
|
*/
|
|
|
|
|
public function removeRole ($ROL_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->removeRole( $ROL_UID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function checks a new role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $code
|
|
|
|
|
* @return $this->rolesObj->verifyNewRole
|
|
|
|
|
*/
|
|
|
|
|
public function verifyNewRole ($code)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->verifyNewRole( $code );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function updates a role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $fields
|
|
|
|
|
* @return $this->rolesObj->updateRole
|
|
|
|
|
*/
|
|
|
|
|
public function updateRole ($fields)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->updateRole( $fields );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function loads by ID
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->loadById
|
|
|
|
|
*/
|
|
|
|
|
public function loadById ($ROL_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->loadById( $ROL_UID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets the user's roles
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->getRoleUsers
|
|
|
|
|
*/
|
|
|
|
|
public function getRoleUsers ($ROL_UID, $filter = '')
|
|
|
|
|
{
|
2016-03-18 16:49:33 -04:00
|
|
|
throw new Exception(__METHOD__ . ': The method is deprecated');
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets the number of users by roles
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @author : Enrique Ponce de Leon <enrique@colosa.com>
|
|
|
|
|
*
|
|
|
|
|
* @return $this->rolesObj->getAllUsersByRole
|
|
|
|
|
*/
|
|
|
|
|
public function getAllUsersByRole ()
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getAllUsersByRole();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets the number of users by department
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @author : Enrique Ponce de Leon <enrique@colosa.com>
|
|
|
|
|
*
|
|
|
|
|
* @return $this->rolesObj->getAllUsersByRole
|
|
|
|
|
*/
|
|
|
|
|
public function getAllUsersByDepartment ()
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getAllUsersByDepartment();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets roles code
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->getRoleCode
|
|
|
|
|
*/
|
|
|
|
|
public function getRoleCode ($ROL_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getRoleCode( $ROL_UID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function removes role from an user
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @param string $USR_UID
|
|
|
|
|
* @return $this->rolesObj->deleteUserRole
|
|
|
|
|
*/
|
|
|
|
|
public function deleteUserRole ($ROL_UID, $USR_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->deleteUserRole( $ROL_UID, $USR_UID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets all user
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->getAllUsers
|
|
|
|
|
*/
|
|
|
|
|
public function getAllUsers ($ROL_UID, $filter = '')
|
|
|
|
|
{
|
2016-03-18 16:49:33 -04:00
|
|
|
throw new Exception(__METHOD__ . ': The method is deprecated');
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function assigns role an user
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return $this->rolesObj->assignUserToRole
|
|
|
|
|
*/
|
|
|
|
|
public function assignUserToRole ($aData)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->assignUserToRole( $aData );
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 12:09:38 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets role permission
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
2016-03-03 16:16:59 -04:00
|
|
|
* @return $this->rolesObj->getRolePermissionsByPerUid
|
2016-03-03 12:09:38 -04:00
|
|
|
*/
|
2016-07-18 10:42:38 -04:00
|
|
|
public function getRolePermissionsByPerUid($ROL_UID)
|
2016-03-03 12:09:38 -04:00
|
|
|
{
|
2016-07-18 10:42:38 -04:00
|
|
|
return $this->rolesObj->getRolePermissionsByPerUid($ROL_UID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function is Assigne role permission
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->isAssigneRolePermission
|
|
|
|
|
*/
|
|
|
|
|
public function getPermissionAssignedRole($ROL_UID, $PER_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getPermissionAssignedRole($ROL_UID, $PER_UID);
|
2016-03-03 12:09:38 -04:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets role permission
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->getRolePermissions
|
|
|
|
|
*/
|
|
|
|
|
public function getRolePermissions ($ROL_UID, $filter = '', $status = null)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getRolePermissions( $ROL_UID, $filter, $status );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets all permissions
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @param string $PER_SYSTEM
|
|
|
|
|
* @return $this->rolesObj->getAllPermissions
|
|
|
|
|
*/
|
|
|
|
|
public function getAllPermissions ($ROL_UID, $PER_SYSTEM = "", $filter = '', $status = null)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->getAllPermissions( $ROL_UID, $PER_SYSTEM, $filter, $status );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function assigns permissions and role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return $this->rolesObj->assignPermissionRole
|
|
|
|
|
*/
|
|
|
|
|
public function assignPermissionRole ($sData)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->assignPermissionRole( $sData );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function assigns permissions to a role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sRoleUID
|
|
|
|
|
* @param string $sPermissionUID
|
|
|
|
|
* @return $this->rolesPermissionsObj->create
|
|
|
|
|
*/
|
|
|
|
|
public function assignPermissionToRole ($sRoleUID, $sPermissionUID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesPermissionsObj->create( array ('ROL_UID' => $sRoleUID,'PER_UID' => $sPermissionUID ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function removes permission to role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @param string $PER_UID
|
|
|
|
|
* @return $this->rolesObj->deletePermissionRole
|
|
|
|
|
*/
|
|
|
|
|
public function deletePermissionRole ($ROL_UID, $PER_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->deletePermissionRole( $ROL_UID, $PER_UID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function counts number of user without role
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $ROL_UID
|
|
|
|
|
* @return $this->rolesObj->numUsersWithRole
|
|
|
|
|
*/
|
|
|
|
|
public function numUsersWithRole ($ROL_UID)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->numUsersWithRole( $ROL_UID );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function creates system code
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sCode
|
|
|
|
|
* @return $this->systemObj->create
|
|
|
|
|
*/
|
|
|
|
|
public function createSystem ($sCode)
|
|
|
|
|
{
|
|
|
|
|
return $this->systemObj->create( array ('SYS_CODE' => $sCode
|
|
|
|
|
) );
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function checks by code
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sCode
|
|
|
|
|
* @return $this->rolesObj->verifyByCode
|
|
|
|
|
*/
|
|
|
|
|
public function verifyByCode ($sCode)
|
|
|
|
|
{
|
|
|
|
|
return $this->rolesObj->verifyByCode( $sCode );
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets all authentication source
|
|
|
|
|
* Authentication Sources
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param void
|
|
|
|
|
* @return $this->authSourcesObj->getAllAuthSources()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getAllAuthSources ()
|
|
|
|
|
{
|
|
|
|
|
return $this->authSourcesObj->getAllAuthSources();
|
|
|
|
|
}
|
2011-08-09 16:40:32 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets all authentication source
|
|
|
|
|
* Authentication Sources By User
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
|
|
|
|
* @param void
|
|
|
|
|
* @return $this->authSourcesObj->getAllAuthSources()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getAllAuthSourcesByUser ()
|
|
|
|
|
{
|
|
|
|
|
return $this->authSourcesObj->getAllAuthSourcesByUser();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets all authentication source
|
|
|
|
|
* Authentication Sources based at parameters
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @author Enrique Ponce de Leon <enrique@colosa.com>
|
|
|
|
|
* @param int $start offset value to paging grid
|
|
|
|
|
* @param int $limit limit value to paging grid
|
|
|
|
|
* @param string $filter value to search or filter select
|
|
|
|
|
* @return $this->authSourcesObj->getAuthenticationSources()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getAuthenticationSources ($start, $limit, $filter = '')
|
|
|
|
|
{
|
|
|
|
|
return $this->authSourcesObj->getAuthenticationSources( $start, $limit, $filter );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this function gets all authentication source
|
|
|
|
|
* Authentication Sources
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sUID
|
|
|
|
|
* @return $this->authSourcesObj->load
|
|
|
|
|
*/
|
|
|
|
|
public function getAuthSource ($sUID)
|
|
|
|
|
{
|
|
|
|
|
$data = $this->authSourcesObj->load( $sUID );
|
|
|
|
|
$pass = explode( "_", $data['AUTH_SOURCE_PASSWORD'] );
|
|
|
|
|
foreach ($pass as $index => $value) {
|
|
|
|
|
if ($value == '2NnV3ujj3w') {
|
|
|
|
|
$data['AUTH_SOURCE_PASSWORD'] = G::decrypt( $pass[0], $data['AUTH_SOURCE_SERVER_NAME'] );
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
$this->authSourcesObj->Fields = $data;
|
|
|
|
|
return $this->authSourcesObj->Fields;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function creates an authentication source
|
|
|
|
|
* Authentication Sources
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return $this->authSourcesObj->create
|
|
|
|
|
*/
|
|
|
|
|
public function createAuthSource ($aData)
|
|
|
|
|
{
|
|
|
|
|
$aData['AUTH_SOURCE_PASSWORD'] = G::encrypt( $aData['AUTH_SOURCE_PASSWORD'], $aData['AUTH_SOURCE_SERVER_NAME'] ) . "_2NnV3ujj3w";
|
|
|
|
|
$this->authSourcesObj->create( $aData );
|
|
|
|
|
}
|
2011-08-24 19:30:03 -04:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function updates an authentication source
|
|
|
|
|
* Authentication Sources
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param array $aData
|
|
|
|
|
* @return $this->authSourcesObj->create
|
|
|
|
|
*/
|
|
|
|
|
public function updateAuthSource ($aData)
|
|
|
|
|
{
|
|
|
|
|
$aData['AUTH_SOURCE_PASSWORD'] = G::encrypt( $aData['AUTH_SOURCE_PASSWORD'], $aData['AUTH_SOURCE_SERVER_NAME'] ) . "_2NnV3ujj3w";
|
|
|
|
|
$this->authSourcesObj->update( $aData );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2011-02-23 22:14:04 +00:00
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function removes an authentication source
|
|
|
|
|
* Authentication Sources
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sUID
|
|
|
|
|
* @return $this->authSourcesObj->remove
|
|
|
|
|
*/
|
|
|
|
|
public function removeAuthSource ($sUID)
|
2011-02-23 22:14:04 +00:00
|
|
|
{
|
2012-10-18 09:27:23 -04:00
|
|
|
$this->authSourcesObj->remove( $sUID );
|
2011-02-23 22:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets all users by authentication source
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param void
|
|
|
|
|
* @return $this->userObj->getAllUsersByAuthSource()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getAllUsersByAuthSource ()
|
|
|
|
|
{
|
|
|
|
|
return $this->userObj->getAllUsersByAuthSource();
|
2011-02-23 22:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function gets all users by authentication source
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param void
|
|
|
|
|
* @return $this->userObj->getAllUsersByAuthSource()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function getListUsersByAuthSource ($aSource)
|
|
|
|
|
{
|
|
|
|
|
return $this->userObj->getListUsersByAuthSource( $aSource );
|
2011-02-23 22:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-18 09:27:23 -04:00
|
|
|
/**
|
|
|
|
|
* this function searchs users
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @param string $sUID
|
|
|
|
|
* @param string $sKeyword
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function searchUsers ($sUID, $sKeyword)
|
|
|
|
|
{
|
|
|
|
|
$aAuthSource = $this->getAuthSource( $sUID );
|
|
|
|
|
$sAuthType = strtolower( $aAuthSource['AUTH_SOURCE_PROVIDER'] );
|
|
|
|
|
foreach ($this->aRbacPlugins as $sClassName) {
|
|
|
|
|
if (strtolower( $sClassName ) == $sAuthType) {
|
|
|
|
|
$plugin = new $sClassName();
|
|
|
|
|
$plugin->sAuthSource = $sUID;
|
|
|
|
|
$plugin->sSystem = $this->sSystem;
|
|
|
|
|
return $plugin->searchUsers( $sKeyword );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return array ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function requirePermissions ($permissions)
|
|
|
|
|
{
|
|
|
|
|
$numPerms = func_num_args();
|
|
|
|
|
$permissions = func_get_args();
|
|
|
|
|
|
|
|
|
|
$access = - 1;
|
|
|
|
|
|
|
|
|
|
if ($numPerms == 1) {
|
|
|
|
|
$access = $this->userCanAccess( $permissions[0] );
|
|
|
|
|
} elseif ($numPerms > 0) {
|
|
|
|
|
foreach ($permissions as $perm) {
|
|
|
|
|
$access = $this->userCanAccess( $perm );
|
|
|
|
|
if ($access == 1) {
|
|
|
|
|
$access = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception( 'function requirePermissions() ->ERROR: Parameters missing!' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($access == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
switch ($access) {
|
|
|
|
|
case - 2:
|
|
|
|
|
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
|
|
|
|
G::header( 'location: ../login/login' );
|
|
|
|
|
break;
|
|
|
|
|
case - 1:
|
|
|
|
|
default:
|
|
|
|
|
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
|
|
|
|
G::header( 'location: ../login/login' );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
exit( 0 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getAllFiles ($directory, $recursive = true)
|
|
|
|
|
{
|
|
|
|
|
$result = array ();
|
|
|
|
|
if (is_dir( $directory )) {
|
|
|
|
|
$handle = opendir( $directory );
|
|
|
|
|
while ($datei = readdir( $handle )) {
|
|
|
|
|
if (($datei != '.') && ($datei != '..')) {
|
|
|
|
|
$file = $directory . $datei;
|
|
|
|
|
if (is_dir( $file )) {
|
|
|
|
|
if ($recursive) {
|
|
|
|
|
$result = array_merge( $result, getAllFiles( $file . '/' ) );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$result[] = $file;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir( $handle );
|
|
|
|
|
}
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getFilesTimestamp ($directory, $recursive = true)
|
|
|
|
|
{
|
|
|
|
|
$allFiles = self::getAllFiles( $directory, $recursive );
|
|
|
|
|
$fileArray = array ();
|
|
|
|
|
foreach ($allFiles as $val) {
|
|
|
|
|
$timeResult['file'] = $val;
|
|
|
|
|
$timeResult['timestamp'] = filemtime( $val );
|
|
|
|
|
$fileArray[] = $timeResult;
|
|
|
|
|
}
|
|
|
|
|
return $fileArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cleanSessionFiles ($hours = 72)
|
|
|
|
|
{
|
|
|
|
|
$currentTime = strtotime( "now" );
|
|
|
|
|
$timeDifference = $hours * 60 * 60;
|
|
|
|
|
$limitTime = $currentTime - $timeDifference;
|
|
|
|
|
$sessionsPath = PATH_DATA . 'session' . PATH_SEP;
|
|
|
|
|
$filesResult = self::getFilesTimestamp( $sessionsPath );
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ($filesResult as $file) {
|
|
|
|
|
if ($file['timestamp'] < $limitTime) {
|
|
|
|
|
unlink( $file['file'] );
|
|
|
|
|
$count ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-19 10:38:48 -04:00
|
|
|
/**
|
|
|
|
|
* this function permissions
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
*/
|
2016-07-18 10:42:38 -04:00
|
|
|
public function verifyPermissions()
|
2013-06-19 10:38:48 -04:00
|
|
|
{
|
|
|
|
|
$message = array();
|
|
|
|
|
$listPermissions = $this->loadPermissionAdmin();
|
2016-07-18 10:42:38 -04:00
|
|
|
$criteria = new Criteria('rbac');
|
|
|
|
|
$dataset = PermissionsPeer::doSelectRS($criteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2013-06-19 10:38:48 -04:00
|
|
|
$dataset->next();
|
|
|
|
|
$aRow = $dataset->getRow();
|
2016-07-18 10:42:38 -04:00
|
|
|
while (is_array($aRow)) {
|
|
|
|
|
foreach ($listPermissions as $key => $item) {
|
|
|
|
|
if ($aRow['PER_UID'] == $item['PER_UID']) {
|
2013-06-19 10:38:48 -04:00
|
|
|
unset($listPermissions[$key]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$dataset->next();
|
|
|
|
|
$aRow = $dataset->getRow();
|
|
|
|
|
}
|
2016-07-18 10:42:38 -04:00
|
|
|
foreach ($listPermissions as $key => $item) {
|
2016-03-03 12:09:38 -04:00
|
|
|
//Adding new permissions
|
|
|
|
|
$data = array();
|
2016-07-18 10:42:38 -04:00
|
|
|
$data['PER_UID'] = $item['PER_UID'];
|
|
|
|
|
$data['PER_CODE'] = $item['PER_CODE'];
|
2013-06-19 10:38:48 -04:00
|
|
|
$data['PER_CREATE_DATE'] = date('Y-m-d H:i:s');
|
|
|
|
|
$data['PER_UPDATE_DATE'] = $data['PER_CREATE_DATE'];
|
2016-07-18 10:42:38 -04:00
|
|
|
$data['PER_STATUS'] = 1;
|
|
|
|
|
$permission = new Permissions();
|
2013-06-19 10:38:48 -04:00
|
|
|
$permission->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
2013-06-19 14:57:00 -04:00
|
|
|
$permission->save();
|
|
|
|
|
$message[] = 'Add permission missing ' . $item['PER_CODE'];
|
2016-03-03 12:09:38 -04:00
|
|
|
//Adding new labels for new permissions
|
|
|
|
|
$o = new RolesPermissions();
|
|
|
|
|
$o->setPerUid($item['PER_UID']);
|
|
|
|
|
$o->setPermissionName($item['PER_NAME']);
|
2016-07-18 10:42:38 -04:00
|
|
|
//assigning new permissions
|
|
|
|
|
$this->assigningNewPermissionsPmSetup($item);
|
|
|
|
|
$this->assigningNewPermissionsPmEditProfile($item);
|
|
|
|
|
}
|
|
|
|
|
return $message;
|
|
|
|
|
}
|
2016-03-03 12:09:38 -04:00
|
|
|
|
2016-07-18 10:42:38 -04:00
|
|
|
/**
|
|
|
|
|
* Permissions for tab ADMIN
|
|
|
|
|
* @param array $item
|
|
|
|
|
*/
|
|
|
|
|
public function assigningNewPermissionsPmSetup($item = array())
|
|
|
|
|
{
|
|
|
|
|
if (strpos($item['PER_CODE'], 'PM_SETUP_') !== false) {
|
2016-03-03 16:16:59 -04:00
|
|
|
$rolesWithPermissionSetup = $this->getRolePermissionsByPerUid(self::SETUPERMISSIONUID);
|
2016-03-03 12:09:38 -04:00
|
|
|
$rolesWithPermissionSetup->next();
|
|
|
|
|
while ($aRow = $rolesWithPermissionSetup->getRow()) {
|
2016-07-18 10:42:38 -04:00
|
|
|
$isAssignedNewpermissions = $this->getPermissionAssignedRole($aRow['ROL_UID'], $item['PER_UID']);
|
|
|
|
|
if (!$isAssignedNewpermissions) {
|
|
|
|
|
$dataPermissions = array();
|
2016-03-03 12:09:38 -04:00
|
|
|
$dataPermissions['ROL_UID'] = $aRow['ROL_UID'];
|
|
|
|
|
$dataPermissions['PER_UID'] = $item['PER_UID'];
|
|
|
|
|
$this->assignPermissionRole($dataPermissions);
|
|
|
|
|
}
|
|
|
|
|
$rolesWithPermissionSetup->next();
|
|
|
|
|
}
|
2013-06-19 10:38:48 -04:00
|
|
|
}
|
2016-07-18 10:42:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Permissions for Edit Profile User
|
|
|
|
|
* @param array $item
|
|
|
|
|
*/
|
|
|
|
|
public function assigningNewPermissionsPmEditProfile($item = array())
|
|
|
|
|
{
|
|
|
|
|
if (strpos($item['PER_CODE'], 'PM_EDIT_USER_PROFILE_') !== false) {
|
|
|
|
|
$allRolesRolUid = $this->getAllRoles('PROCESSMAKER');
|
|
|
|
|
$perCodePM = array('PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR', 'PROCESSMAKER_MANAGER');
|
|
|
|
|
$permissionsForOperator = array(
|
|
|
|
|
'PM_EDIT_USER_PROFILE_POSITION',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_REPLACED_BY',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_EXPIRATION_DATE',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_STATUS',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_ROLE',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_COSTS',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_USER_MUST_CHANGE_PASSWORD_AT_NEXT_LOGON',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS',
|
|
|
|
|
'PM_EDIT_USER_PROFILE_DEFAULT_CASES_MENU_OPTIONS'
|
|
|
|
|
);
|
|
|
|
|
foreach ($allRolesRolUid as $index => $aRow) {
|
|
|
|
|
$isAssignedNewpermissions = $this->getPermissionAssignedRole($aRow['ROL_UID'], $item['PER_UID']);
|
|
|
|
|
$assignPermissions = true;
|
|
|
|
|
if (!$isAssignedNewpermissions) {
|
|
|
|
|
if ($aRow['ROL_CODE'] == 'PROCESSMAKER_OPERATOR' && in_array($item['PER_CODE'], $permissionsForOperator)) {
|
|
|
|
|
$assignPermissions = false;
|
|
|
|
|
}
|
|
|
|
|
if (!in_array($aRow['ROL_CODE'], $perCodePM)) {
|
|
|
|
|
$assignPermissions = false;
|
|
|
|
|
$checkPermisionEdit = $this->getPermissionAssignedRole($aRow['ROL_UID'], '00000000000000000000000000000014');
|
|
|
|
|
if ($checkPermisionEdit && !in_array($item['PER_CODE'], $permissionsForOperator)) {
|
|
|
|
|
$assignPermissions = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($assignPermissions) {
|
|
|
|
|
$dataPermissions = array();
|
|
|
|
|
$dataPermissions['ROL_UID'] = $aRow['ROL_UID'];
|
|
|
|
|
$dataPermissions['PER_UID'] = $item['PER_UID'];
|
|
|
|
|
$this->assignPermissionRole($dataPermissions);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-19 10:38:48 -04:00
|
|
|
}
|
2017-05-19 16:31:27 -04:00
|
|
|
/**
|
|
|
|
|
* 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)
|
|
|
|
|
{
|
2017-05-23 16:12:45 -04:00
|
|
|
$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;
|
2017-05-19 16:31:27 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$access) {
|
|
|
|
|
G::header('Location: /errors/error403.php');
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-10-18 09:27:23 -04:00
|
|
|
}
|
2011-02-23 22:14:04 +00:00
|
|
|
|