2010-12-02 23:34:41 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
2017-08-01 12:16:06 -04:00
|
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
require_once 'classes/model/om/BaseUsersProperties.php';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Skeleton subclass for representing a row from the 'USERS_PROPERTIES' table.
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should add additional methods to this class to meet the
|
2012-10-19 10:24:29 -04:00
|
|
|
|
* application requirements. This class will only be generated as
|
2010-12-02 23:34:41 +00:00
|
|
|
|
* long as it does not already exist in the output directory.
|
2011-02-03 11:13:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-19 10:24:29 -04:00
|
|
|
|
*
|
|
|
|
|
|
* @package workflow.engine.classes.model
|
2010-12-02 23:34:41 +00:00
|
|
|
|
*/
|
2012-09-25 17:33:17 -04:00
|
|
|
|
class UsersProperties extends BaseUsersProperties
|
2012-01-31 18:45:30 -04:00
|
|
|
|
{
|
2012-10-19 10:24:29 -04:00
|
|
|
|
public $fields = null;
|
|
|
|
|
|
public $usrID = '';
|
|
|
|
|
|
public $lang = 'en';
|
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function __construct()
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$this->lang = defined('SYS_LANG') ? SYS_LANG : 'en';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function UserPropertyExists($sUserUID)
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oUserProperty = UsersPropertiesPeer::retrieveByPk($sUserUID);
|
|
|
|
|
|
if (! is_null($oUserProperty) && is_object($oUserProperty) && get_class($oUserProperty) == 'UsersProperties') {
|
|
|
|
|
|
$this->fields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
|
$this->fromArray($this->fields, BasePeer::TYPE_FIELDNAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function load($sUserUID)
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID);
|
|
|
|
|
|
if (! is_null($oUserProperty)) {
|
|
|
|
|
|
$aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
|
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return $aFields;
|
|
|
|
|
|
} else {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
throw new Exception("User with $sUserUID does not exist!");
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function create($aData)
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
try {
|
|
|
|
|
|
$oUserProperty = new UsersProperties();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if ($oUserProperty->validate()) {
|
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
|
$iResult = $oUserProperty->save();
|
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
|
$aValidationFailures = $oUserProperty->getValidationFailures();
|
|
|
|
|
|
foreach ($aValidationFailures as $oValidationFailure) {
|
|
|
|
|
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
|
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
|
throw (new Exception('The registry cannot be created!<br />' . $sMessage));
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
|
throw ($oError);
|
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function update($aData)
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oConnection = Propel::getConnection(UsersPropertiesPeer::DATABASE_NAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
try {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oUserProperty = UsersPropertiesPeer::retrieveByPK($aData['USR_UID']);
|
|
|
|
|
|
if (! is_null($oUserProperty)) {
|
|
|
|
|
|
$oUserProperty->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if ($oUserProperty->validate()) {
|
|
|
|
|
|
$oConnection->begin();
|
|
|
|
|
|
$iResult = $oUserProperty->save();
|
|
|
|
|
|
$oConnection->commit();
|
|
|
|
|
|
return $iResult;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
|
$aValidationFailures = $oUserProperty->getValidationFailures();
|
|
|
|
|
|
foreach ($aValidationFailures as $oValidationFailure) {
|
|
|
|
|
|
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
|
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
|
throw (new Exception('The registry cannot be updated!<br />' . $sMessage));
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
throw (new Exception('This row doesn\'t exist!'));
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
|
$oConnection->rollback();
|
|
|
|
|
|
throw ($oError);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function loadOrCreateIfNotExists($sUserUID, $aUserProperty = array())
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (! $this->UserPropertyExists($sUserUID)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$aUserProperty['USR_UID'] = $sUserUID;
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (! isset($aUserProperty['USR_LAST_UPDATE_DATE'])) {
|
|
|
|
|
|
$aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s');
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (! isset($aUserProperty['USR_LOGGED_NEXT_TIME'])) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$aUserProperty['USR_LOGGED_NEXT_TIME'] = 0;
|
|
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$this->create($aUserProperty);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
} else {
|
|
|
|
|
|
$aUserProperty = $this->fields;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $aUserProperty;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2018-10-26 16:14:37 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* This function will be validate the password policies
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param string $password
|
|
|
|
|
|
* @param string $lastUpdate
|
|
|
|
|
|
* @param integer $changePassword
|
|
|
|
|
|
* @param boolean $nowLogin
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return array
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function validatePassword($password, $lastUpdate, $changePassword, $nowLogin = false)
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_MINIMUM_LENGTH')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_MINIMUM_LENGTH', 5);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_MAXIMUM_LENGTH')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_MAXIMUM_LENGTH', 20);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_NUMERICAL_CHARACTER_REQUIRED')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_NUMERICAL_CHARACTER_REQUIRED', 0);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_UPPERCASE_CHARACTER_REQUIRED')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_UPPERCASE_CHARACTER_REQUIRED', 0);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_SPECIAL_CHARACTER_REQUIRED')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_SPECIAL_CHARACTER_REQUIRED', 0);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (!defined('PPP_EXPIRATION_IN')) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
define('PPP_EXPIRATION_IN', 0);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
$lengthPassword = function_exists('mb_strlen') ? mb_strlen($password): strlen($password);
|
|
|
|
|
|
|
|
|
|
|
|
$listErrors = [];
|
|
|
|
|
|
//The password has the minimum length
|
|
|
|
|
|
if ($lengthPassword < PPP_MINIMUM_LENGTH || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_MINIMUM_LENGTH';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
//The password has the maximum length
|
|
|
|
|
|
if ($lengthPassword > PPP_MAXIMUM_LENGTH || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
//The password requires a number
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (preg_match_all('/[0-9]/', $password, $aMatch,
|
|
|
|
|
|
PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0 || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
//The password requires a upper case
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (preg_match_all('/[A-Z]/', $password, $aMatch,
|
|
|
|
|
|
PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0 || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
//The password requires a special character
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if (preg_match_all('/[<5B><>\\!|"@<40>#$~%<25>&<26>\/()=\'?<3F><>*+\-_.:,;]/', $password, $aMatch,
|
|
|
|
|
|
PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) == 0 || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_SPECIAL_CHARACTER_REQUIRED';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
//The configuration PPP_EXPIRATION_IN is saved in hours
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if (PPP_EXPIRATION_IN > 0) {
|
2018-10-26 16:14:37 -04:00
|
|
|
|
$hoursBetweenDates = (strtotime(date('Y-m-d H:i:s')) - strtotime($lastUpdate)) / (60 * 60);
|
|
|
|
|
|
if ($hoursBetweenDates > PPP_EXPIRATION_IN || $nowLogin) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_EXPIRATION_IN';
|
|
|
|
|
|
$changePassword = 1;
|
2013-11-26 17:36:40 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
}
|
2022-02-09 16:29:22 -04:00
|
|
|
|
//Spaces not supported at the end of passwords
|
|
|
|
|
|
if (substr($password, -1) === " ") {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_SPACES_NOT_SUPPORTED_AT_THE_END_OF_PASSWORD';
|
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
|
|
|
|
|
|
if ($changePassword == 1) {
|
|
|
|
|
|
$listErrors[] = 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN';
|
|
|
|
|
|
}
|
2013-11-26 17:36:40 -04:00
|
|
|
|
|
2018-10-26 16:14:37 -04:00
|
|
|
|
return $listErrors;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* This function will be get the message for show what policies does not complied
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param array $errorsInPassword
|
|
|
|
|
|
* @param boolean $afterFillingPass
|
|
|
|
|
|
* @param boolean $onlyText
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return array
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function getMessageValidatePassword($errorsInPassword, $afterFillingPass = true, $onlyText = false){
|
|
|
|
|
|
$messPassword = [];
|
|
|
|
|
|
$policyErrors = false;
|
|
|
|
|
|
if ($afterFillingPass) {
|
|
|
|
|
|
$policyMessage = G::LoadTranslation('ID_POLICY_ALERT');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$policyMessage = G::LoadTranslation('ID_POLICY_ALERT_INFO');
|
|
|
|
|
|
}
|
|
|
|
|
|
$policyMessage .= ($onlyText) ? ' ' : '<br/><br/>';
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($errorsInPassword as $error) {
|
|
|
|
|
|
switch ($error) {
|
|
|
|
|
|
case 'ID_PPP_CHANGE_PASSWORD_AFTER_NEXT_LOGIN':
|
|
|
|
|
|
//Does not consider a policy for the final user, the administrator request to change password
|
|
|
|
|
|
$messPassword[substr($error, 3)] = PPP_MINIMUM_LENGTH;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'ID_PPP_MINIMUM_LENGTH':
|
|
|
|
|
|
$policyErrors = true;
|
|
|
|
|
|
$policyMessage .= '- ' . G::LoadTranslation($error) . ': ' . PPP_MINIMUM_LENGTH;
|
|
|
|
|
|
$policyMessage .= ($onlyText) ? '. ' : '<br/>';
|
|
|
|
|
|
$messPassword[substr($error, 3)] = PPP_MINIMUM_LENGTH;
|
|
|
|
|
|
$messPassword['PPP_MINIMUN_LENGTH'] = PPP_MINIMUM_LENGTH;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'ID_PPP_MAXIMUM_LENGTH':
|
|
|
|
|
|
$policyErrors = true;
|
|
|
|
|
|
$policyMessage .= '- ' . G::LoadTranslation($error) . ': ' . PPP_MAXIMUM_LENGTH;
|
|
|
|
|
|
$policyMessage .= ($onlyText) ? '. ' : '<br/>';
|
|
|
|
|
|
$messPassword[substr($error, 3)] = PPP_MAXIMUM_LENGTH;
|
|
|
|
|
|
$messPassword['PPP_MAXIMUN_LENGTH'] = PPP_MAXIMUM_LENGTH;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'ID_PPP_EXPIRATION_IN':
|
|
|
|
|
|
//Does not consider a policy for the final user, this is enhanced login configuration
|
|
|
|
|
|
$messPassword[substr($error, 3)] = PPP_EXPIRATION_IN;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
//PPP_NUMERICAL_CHARACTER_REQUIRED
|
|
|
|
|
|
//PPP_UPPERCASE_CHARACTER_REQUIRED
|
|
|
|
|
|
//PPP_SPECIAL_CHARACTER_REQUIRED
|
|
|
|
|
|
$policyErrors = true;
|
|
|
|
|
|
$policyMessage .= '- ' . G::LoadTranslation($error);
|
|
|
|
|
|
$policyMessage .= ($onlyText) ? '. ' : '<br/>';
|
|
|
|
|
|
$messPassword[substr($error, 3)] = 1;
|
|
|
|
|
|
break;
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
if ($afterFillingPass){
|
|
|
|
|
|
$policyMessage .= G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY');
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
2018-10-26 16:14:37 -04:00
|
|
|
|
$messPassword['DESCRIPTION'] = ($policyErrors) ? $policyMessage : '';
|
|
|
|
|
|
|
|
|
|
|
|
return $messPassword;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* get user location
|
|
|
|
|
|
* defined by precedence plugin->ux->default
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function redirectTo($usrID, $lang = '')
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
|
|
|
|
|
$this->usrID = $usrID;
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$this->lang = empty($lang) ? $this->lang : $lang;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = $this->_getPluginLocation();
|
2012-09-25 17:33:17 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (empty($url)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = $this->_getUXLocation();
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$urlUx = $this->_getUXSkinVariant();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (empty($url) && ! empty($urlUx)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$_SESSION['_defaultUserLocation'] = $url;
|
|
|
|
|
|
$url = $urlUx;
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (empty($url)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = $this->_getDefaultLocation();
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return $url;
|
2012-04-05 12:52:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* get user location
|
|
|
|
|
|
* defined by precedence plugin->default
|
|
|
|
|
|
* note that is getting location without User Inbox Simplified varification
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function getUserLocation($usrID, $lang = 'en')
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
|
|
|
|
|
$this->usrID = $usrID;
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$this->lang = empty($lang) ? $this->lang : $lang;
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = $this->_getPluginLocation();
|
2012-09-25 17:33:17 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (empty($url)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = $this->_getDefaultLocation();
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$urlUx = $this->_getUXSkinVariant();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (! empty($urlUx)) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$_SESSION['_defaultUserLocation'] = $url;
|
|
|
|
|
|
$url = $urlUx;
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return $url;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* to verify if the user is using some "ux..." skin variant
|
|
|
|
|
|
* if that is the case, the redirection will change to 'main' controller
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function _getUXSkinVariant()
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
|
|
|
|
|
$url = '';
|
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') {
|
2012-12-14 11:43:43 -04:00
|
|
|
|
if (isset($_COOKIE['workspaceSkin'])) {
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (substr($_COOKIE['workspaceSkin'], 0, 2) != 'ux') {
|
2012-12-14 11:43:43 -04:00
|
|
|
|
$url = $this->_getDefaultLocation();
|
|
|
|
|
|
return $url;
|
|
|
|
|
|
} else {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$url = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . $_COOKIE['workspaceSkin'] . '/main';
|
2012-12-14 11:43:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$url = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . SYS_SKIN . '/main';
|
2012-12-14 11:43:43 -04:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
global $RBAC;
|
|
|
|
|
|
$oConf = new Configurations();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '');
|
2019-07-26 08:36:37 -04:00
|
|
|
|
if (isset($oConf->aConfig['DEFAULT_MENU'])) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
|
|
|
|
|
|
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = null;
|
|
|
|
|
|
|
|
|
|
|
|
switch ($oConf->aConfig['DEFAULT_MENU']) {
|
|
|
|
|
|
case 'PM_SETUP':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = 'admin';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_FACTORY':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = 'designer';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_CASES':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_CASES') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = 'home';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_USERS':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_USERS') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = 'admin';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_DASHBOARD':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$getUrl = 'dashboard';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$url = $url . (($getUrl != null) ? "?st=" . $getUrl : null);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return $url;
|
2012-04-05 12:52:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* get the plugins, and check if there is redirectLogins
|
|
|
|
|
|
* if yes, then redirect goes according his Role
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function _getPluginLocation()
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
|
|
|
|
|
global $RBAC;
|
|
|
|
|
|
$url = '';
|
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (class_exists('redirectDetail')) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
//to do: complete the validation
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (isset($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'])) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$userRole = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-01 12:16:06 -04:00
|
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$aRedirectLogin = $oPluginRegistry->getRedirectLogins();
|
2017-08-04 09:32:25 -04:00
|
|
|
|
if (isset($aRedirectLogin) && is_array($aRedirectLogin)) {
|
|
|
|
|
|
/** @var \ProcessMaker\Plugins\Interfaces\RedirectDetail $detail */
|
|
|
|
|
|
foreach ($aRedirectLogin as $detail) {
|
|
|
|
|
|
$pathMethod = $detail->getPathMethod();
|
|
|
|
|
|
if (isset($pathMethod) && $detail->equalRoleCodeTo($userRole)) {
|
2012-12-14 11:43:43 -04:00
|
|
|
|
if (isset($_COOKIE['workspaceSkin'])) {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$url = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . $_COOKIE['workspaceSkin'] . '/' . $pathMethod;
|
2012-12-14 11:43:43 -04:00
|
|
|
|
} else {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$url = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . SYS_SKIN . '/' . $pathMethod;
|
2012-12-14 11:43:43 -04:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $url;
|
2012-04-05 12:52:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* New feature - User Experience Redirector
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Erik Amaru Ortiz <erik@colosa.com>
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function _getUXLocation()
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
|
|
|
|
|
require_once 'classes/model/Users.php';
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$u = UsersPeer::retrieveByPK($this->usrID);
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = '';
|
|
|
|
|
|
|
|
|
|
|
|
$uxType = $u->getUsrUx();
|
|
|
|
|
|
$_SESSION['user_experience'] = 'NORMAL';
|
|
|
|
|
|
|
|
|
|
|
|
// find a group setting
|
|
|
|
|
|
if ($uxType == '' || $uxType == 'NORMAL') {
|
|
|
|
|
|
require_once 'classes/model/GroupUser.php';
|
|
|
|
|
|
$gu = new GroupUser();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$ugList = $gu->getAllUserGroups($this->usrID);
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
foreach ($ugList as $row) {
|
|
|
|
|
|
if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') {
|
|
|
|
|
|
$uxType = $row['GRP_UX'];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch ($uxType) {
|
|
|
|
|
|
case 'SIMPLIFIED':
|
|
|
|
|
|
case 'SWITCHABLE':
|
|
|
|
|
|
case 'SINGLE':
|
|
|
|
|
|
$_SESSION['user_experience'] = $uxType;
|
|
|
|
|
|
$_SESSION['user_last_skin'] = SYS_SKIN;
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$url = '/sys' . config("system.workspace") . '/' . $this->lang . '/uxs/' . 'home';
|
2012-10-19 10:24:29 -04:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2012-04-05 12:52:33 -04:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return $url;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* get user preferences for default redirect
|
|
|
|
|
|
* verifying if it has any preferences on configurations table
|
|
|
|
|
|
*/
|
2017-12-04 13:25:35 +00:00
|
|
|
|
public function _getDefaultLocation()
|
2012-10-19 10:24:29 -04:00
|
|
|
|
{
|
2012-09-13 14:17:39 -04:00
|
|
|
|
global $RBAC;
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$oConf = new Configurations();
|
2017-12-04 13:25:35 +00:00
|
|
|
|
$oConf->loadConfig($x, 'USER_PREFERENCES', '', '', $_SESSION['USER_LOGGED'], '');
|
2012-10-19 10:24:29 -04:00
|
|
|
|
|
2012-12-14 11:43:43 -04:00
|
|
|
|
if (isset($_COOKIE['workspaceSkin'])) {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$baseUrl = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . $_COOKIE['workspaceSkin'] . '/';
|
2012-12-14 11:43:43 -04:00
|
|
|
|
} else {
|
2017-10-10 12:33:25 -04:00
|
|
|
|
$baseUrl = '/sys' . config("system.workspace") . '/' . $this->lang . '/' . SYS_SKIN . '/';
|
2012-12-14 11:43:43 -04:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = '';
|
|
|
|
|
|
|
2019-07-26 08:36:37 -04:00
|
|
|
|
if (isset($oConf->aConfig['DEFAULT_MENU'])) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
// this user has a configuration record
|
|
|
|
|
|
// backward compatibility, because now, we don't have user and dashboard menu.
|
2012-09-13 14:17:39 -04:00
|
|
|
|
if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') {
|
|
|
|
|
|
$oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP';
|
|
|
|
|
|
}
|
2012-09-25 17:33:17 -04:00
|
|
|
|
|
2012-09-13 14:17:39 -04:00
|
|
|
|
switch ($oConf->aConfig['DEFAULT_MENU']) {
|
|
|
|
|
|
case 'PM_SETUP':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_SETUP') == 1 || $RBAC->userCanAccess('PM_USERS') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'setup/main';
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_FACTORY':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'processes/main';
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_CASES':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_CASES') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'cases/main';
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_USERS':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_USERS') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'setup/main';
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'PM_DASHBOARD':
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'dashboard/main';
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
2015-04-06 11:35:09 -04:00
|
|
|
|
case 'PM_STRATEGIC_DASHBOARD':
|
2025-03-28 13:16:06 +00:00
|
|
|
|
if ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
2015-04-06 11:35:09 -04:00
|
|
|
|
$url = 'strategicDashboard/main';
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-09-25 17:33:17 -04:00
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
|
if (empty($url)) {
|
|
|
|
|
|
if ($RBAC->userCanAccess('PM_FACTORY') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'processes/main';
|
2017-12-04 13:25:35 +00:00
|
|
|
|
} elseif ($RBAC->userCanAccess('PM_SETUP') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'setup/main';
|
2017-12-04 13:25:35 +00:00
|
|
|
|
} elseif ($RBAC->userCanAccess('PM_CASES') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'cases/main';
|
2017-12-04 13:25:35 +00:00
|
|
|
|
} elseif ($RBAC->userCanAccess('PM_USERS') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'setup/main';
|
2017-12-04 13:25:35 +00:00
|
|
|
|
} elseif ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
|
2012-10-19 10:24:29 -04:00
|
|
|
|
$url = 'dashboard/dashboard';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$url = 'users/myInfo';
|
|
|
|
|
|
}
|
2012-09-13 14:17:39 -04:00
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
2012-10-19 10:24:29 -04:00
|
|
|
|
return $baseUrl . $url;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-10-19 10:24:29 -04:00
|
|
|
|
}
|