Merged in feature/HOR-3906 (pull request #6100)
feature/HOR-3906 Approved-by: David Callizaya <david.callizaya@processmaker.com> Approved-by: Paula Quispe <paula.quispe@processmaker.com> Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
17
Rakefile
17
Rakefile
@@ -1,5 +1,5 @@
|
||||
require 'rubygems'
|
||||
|
||||
require 'json'
|
||||
desc "Default Task - Build Library"
|
||||
task :default => [:required] do
|
||||
Rake::Task['build'].execute
|
||||
@@ -53,6 +53,7 @@ task :build => [:required] do
|
||||
mafeDir = targetDir + "/mafe"
|
||||
pmdynaformDir = targetDir + "/pmdynaform"
|
||||
|
||||
generateEnviromentVariables
|
||||
prepareDirs([targetDir, pmUIDir, mafeDir, pmdynaformDir, jsTargetDir, cssTargetDir, cssImagesTargetDir, imgTargetDir, pmUIFontsDir])
|
||||
|
||||
buildPmUi(Dir.pwd + "/vendor/colosa/pmUI", targetDir, mode)
|
||||
@@ -134,6 +135,20 @@ task :build => [:required] do
|
||||
#task argv1.to_sym do ; end
|
||||
end
|
||||
|
||||
def generateEnviromentVariables()
|
||||
puts "Creating System Constants..."
|
||||
content = "var __env = __env || {};"
|
||||
file = File.read('./config/enviromentvariables.json')
|
||||
dataUser = JSON.parse(file)
|
||||
content = content + "__env.USER_GUEST = " + JSON.generate(dataUser['constants']['userguest'])
|
||||
dir = "vendor/colosa/MichelangeloFE/src/enviroment/"
|
||||
# create a directory enviroment
|
||||
FileUtils.mkdir_p(dir)
|
||||
File.open(dir +'constants.js', 'w') { |fileWrite|
|
||||
fileWrite.write content + ';'
|
||||
}
|
||||
end
|
||||
|
||||
def buildPmUi(homeDir, targetDir, mode)
|
||||
puts "\nBuilding PMUI library".green.bold
|
||||
|
||||
|
||||
12
config/enviromentvariables.json
Normal file
12
config/enviromentvariables.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Environment variables",
|
||||
"description": "Definition of system constants",
|
||||
"constants": {
|
||||
"userguest": {
|
||||
"uid": "00000000000000000000000000000002",
|
||||
"firstname": "Guest",
|
||||
"lastname": "Guest",
|
||||
"username": "guest"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
21
gulpfile.js
21
gulpfile.js
@@ -471,7 +471,26 @@ gulp.task('clean', function () {
|
||||
cleanDirectory('workflow/public_html/lib');
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean'], function (cb) {
|
||||
/**
|
||||
* This scheduled task is to be able to create the guest user constants
|
||||
*/
|
||||
gulp.task('__env', function (cb) {
|
||||
var data = require('./config/enviromentvariables.json'),
|
||||
pathEnviroment = 'vendor/colosa/MichelangeloFE/src/enviroment/',
|
||||
content = 'var __env = __env || {};';
|
||||
|
||||
gutil.log(gutil.colors.green('Creating System Constants...'));
|
||||
if (!fs.existsSync(pathEnviroment)){
|
||||
fs.mkdirSync(pathEnviroment);
|
||||
}
|
||||
fs.writeFile(
|
||||
pathEnviroment + 'constants.js',
|
||||
content + '__env.USER_GUEST = ' + JSON.stringify(data.constants.userguest) + ';',
|
||||
cb
|
||||
);
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean', '__env'], function (cb) {
|
||||
var i, tasks = [];
|
||||
|
||||
gutil.log(gutil.colors.green('Initializing ProcessMaker building...'));
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*/
|
||||
@@ -44,57 +45,60 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
class RbacUsers extends BaseRbacUsers
|
||||
{
|
||||
|
||||
private $userUidReserved = [RBAC::GUEST_USER_UID];
|
||||
|
||||
/**
|
||||
* Autentificacion de un usuario a traves de la clase RBAC_user
|
||||
* Authentication of a user through the class RBAC_user
|
||||
*
|
||||
* verifica que un usuario tiene derechos de iniciar una aplicacion
|
||||
* verifies that a user has permission to start an application
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* access public
|
||||
* @access public
|
||||
* Function verifyLogin
|
||||
*
|
||||
* @param string $strUser UserId (login) de usuario
|
||||
* @param string $strPass Password
|
||||
* @return
|
||||
* -1: no existe usuario
|
||||
* -2: password errado
|
||||
* -3: usuario inactivo
|
||||
* -4: usuario vencido
|
||||
* -6: role inactivo
|
||||
* n : uid de usuario
|
||||
* @param string $userName UserId (login) de usuario
|
||||
* @param string $password Password
|
||||
* @return type
|
||||
* -1: no user exists
|
||||
* -2: wrong password
|
||||
* -3: inactive user
|
||||
* -4: expired user
|
||||
* -6: role inactive
|
||||
* n : string user uid
|
||||
* @throws Exception
|
||||
*/
|
||||
public function verifyLogin($sUsername, $sPassword)
|
||||
public function verifyLogin($userName, $password)
|
||||
{
|
||||
//invalid user
|
||||
if ($sUsername == '') {
|
||||
if ($userName == '') {
|
||||
return -1;
|
||||
}
|
||||
//invalid password
|
||||
if ($sPassword == '') {
|
||||
if ($password == '') {
|
||||
return -2;
|
||||
}
|
||||
$con = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria('rbac');
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $sUsername);
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $userName);
|
||||
/* @var $rs RbacUsers[] */
|
||||
$rs = RbacUsersPeer::doSelect($c, Propel::getDbConnection('rbac_ro'));
|
||||
if (is_array($rs) && isset($rs[0]) && is_object($rs[0]) && get_class($rs[0]) == 'RbacUsers') {
|
||||
$aFields = $rs[0]->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$dataFields = $rs[0]->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
//verify password with md5, and md5 format
|
||||
if (mb_strtoupper($sUsername, 'utf-8') === mb_strtoupper($aFields['USR_USERNAME'], 'utf-8')) {
|
||||
if( Bootstrap::verifyHashPassword($sPassword, $rs[0]->getUsrPassword()) ) {
|
||||
if ($aFields['USR_DUE_DATE'] < date('Y-m-d')) {
|
||||
if (mb_strtoupper($userName, 'utf-8') === mb_strtoupper($dataFields['USR_USERNAME'], 'utf-8')) {
|
||||
if (Bootstrap::verifyHashPassword($password, $rs[0]->getUsrPassword())) {
|
||||
if ($dataFields['USR_DUE_DATE'] < date('Y-m-d')) {
|
||||
return -4;
|
||||
}
|
||||
if ($aFields['USR_STATUS'] != 1) {
|
||||
if ($dataFields['USR_STATUS'] != 1 && $dataFields['USR_UID'] !== RBAC::GUEST_USER_UID) {
|
||||
return -3;
|
||||
}
|
||||
$role = $this->getUserRole($aFields['USR_UID']);
|
||||
$role = $this->getUserRole($dataFields['USR_UID']);
|
||||
if ($role['ROL_STATUS'] == 0) {
|
||||
return -6;
|
||||
}
|
||||
return $aFields['USR_UID'];
|
||||
|
||||
return $dataFields['USR_UID'];
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
@@ -104,100 +108,134 @@ class RbacUsers extends BaseRbacUsers
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function verifyUser($sUsername)
|
||||
/**
|
||||
* Verify if the userName exists
|
||||
* @param string $userName
|
||||
* @return integer
|
||||
* @throws Exception
|
||||
*/
|
||||
public function verifyUser($userName)
|
||||
{
|
||||
//invalid user
|
||||
if ($sUsername == '') {
|
||||
if ($userName == '') {
|
||||
return 0;
|
||||
}
|
||||
$con = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria('rbac');
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $sUsername);
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $userName);
|
||||
$rs = RbacUsersPeer::doSelect($c, Propel::getDbConnection('rbac_ro'));
|
||||
if (is_array($rs) && isset($rs[0]) && is_object($rs[0]) && get_class($rs[0]) == 'RbacUsers') {
|
||||
//return the row for futher check of which Autentificacion method belongs this user
|
||||
$this->fields = $rs[0]->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
;
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
public function getByUsername($sUsername)
|
||||
/**
|
||||
* Get user info by userName
|
||||
* @param string $userName
|
||||
* @return array $dataFields if exist
|
||||
* false if does not exist
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getByUsername($userName)
|
||||
{
|
||||
//invalid user
|
||||
if ($sUsername == '') {
|
||||
if ($userName == '') {
|
||||
return 0;
|
||||
}
|
||||
$con = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria('rbac');
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $sUsername);
|
||||
$c->add(RbacUsersPeer::USR_USERNAME, $userName);
|
||||
$rs = RbacUsersPeer::doSelect($c, Propel::getDbConnection('rbac_ro'));
|
||||
|
||||
if (is_array($rs) && isset($rs[0]) && is_object($rs[0]) && get_class($rs[0]) == 'RbacUsers') {
|
||||
$aFields = $rs[0]->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
$dataFields = $rs[0]->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
return $dataFields;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyUserId($sUserId)
|
||||
/**
|
||||
* Verify user by Uid
|
||||
* @param string $userUid
|
||||
* @return integer
|
||||
* @throws Exception
|
||||
*/
|
||||
public function verifyUserId($userUid)
|
||||
{
|
||||
//invalid user
|
||||
if ($sUserId == '') {
|
||||
if ($userUid == '') {
|
||||
return 0;
|
||||
}
|
||||
$con = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria('rbac');
|
||||
$c->add(RbacUsersPeer::USR_UID, $sUserId);
|
||||
$c->add(RbacUsersPeer::USR_UID, $userUid);
|
||||
$rs = RbacUsersPeer::doSelect($c, Propel::getDbConnection('rbac_ro'));
|
||||
if (is_array($rs) && isset($rs[0]) && is_object($rs[0]) && get_class($rs[0]) == 'RbacUsers') {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
public function load($sUsrUid)
|
||||
/**
|
||||
* Load user information by Uid
|
||||
* @param string $userUid
|
||||
* @return array $dataFields
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($userUid)
|
||||
{
|
||||
$con = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria('rbac');
|
||||
$c->add(RbacUsersPeer::USR_UID, $sUsrUid);
|
||||
$c->add(RbacUsersPeer::USR_UID, $userUid);
|
||||
$resultSet = RbacUsersPeer::doSelectRS($c, Propel::getDbConnection('rbac_ro'));
|
||||
if ($resultSet->next()) {
|
||||
$this->hydrate($resultSet);
|
||||
$aFields = $this->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
return $aFields;
|
||||
$dataFields = $this->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
return $dataFields;
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function create($aData)
|
||||
/**
|
||||
* Create an user
|
||||
* @param string $infoData
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create($infoData)
|
||||
{
|
||||
if (class_exists('ProcessMaker\Plugins\PluginRegistry')) {
|
||||
$pluginRegistry = PluginRegistry::loadSingleton();
|
||||
@@ -209,116 +247,134 @@ class RbacUsers extends BaseRbacUsers
|
||||
}
|
||||
}
|
||||
}
|
||||
$oConnection = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
$connection = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$oRBACUsers = new RbacUsers();
|
||||
$rbacUsers = new RbacUsers();
|
||||
do {
|
||||
$aData['USR_UID'] = G::generateUniqueID();
|
||||
} while ($oRBACUsers->load($aData['USR_UID']));
|
||||
$oRBACUsers->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
//if ($oRBACUsers->validate()) {
|
||||
//$oConnection->begin();
|
||||
$iResult = $oRBACUsers->save();
|
||||
//$oConnection->commit();
|
||||
return $aData['USR_UID'];
|
||||
/* }
|
||||
else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oRBACUsers->getValidationFailures();
|
||||
foreach($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw(new Exception('The registry cannot be created!<br />' . $sMessage));
|
||||
} */
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
$infoData['USR_UID'] = G::generateUniqueID();
|
||||
} while ($rbacUsers->load($infoData['USR_UID']));
|
||||
$rbacUsers->fromArray($infoData, BasePeer::TYPE_FIELDNAME);
|
||||
$result = $rbacUsers->save();
|
||||
|
||||
return $infoData['USR_UID'];
|
||||
} catch (Exception $error) {
|
||||
$connection->rollback();
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
public function update($aData)
|
||||
/**
|
||||
* Update an user
|
||||
* @param string $infoData
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($infoData)
|
||||
{
|
||||
if (in_array($infoData['USR_UID'], $this->userUidReserved)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($infoData['USR_UID'])));
|
||||
return false;
|
||||
}
|
||||
$oConnection = Propel::getConnection(RbacUsersPeer::DATABASE_NAME);
|
||||
try {
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($infoData, BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
$iResult = $this->save();
|
||||
} catch (Exception $oError) {
|
||||
$result = $this->save();
|
||||
} catch (Exception $error) {
|
||||
$oConnection->rollback();
|
||||
throw($oError);
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($sUserUID = '')
|
||||
/**
|
||||
* Remove an user
|
||||
* @param string $userUid
|
||||
* @return void
|
||||
*/
|
||||
public function remove($userUid = '')
|
||||
{
|
||||
$this->setUsrUid($sUserUID);
|
||||
$this->setUsrUid($userUid);
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
//Added by Qennix at Feb 14th, 2011
|
||||
//Gets an associative array with total users by authentication sources
|
||||
/**
|
||||
* Gets an associative array with total users by authentication sources
|
||||
* @return array $listAuth
|
||||
*/
|
||||
public function getAllUsersByAuthSource()
|
||||
{
|
||||
$oCriteria = new Criteria('rbac');
|
||||
$oCriteria->addSelectColumn(RbacUsersPeer::UID_AUTH_SOURCE);
|
||||
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
|
||||
$oCriteria->add(RbacUsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
$oCriteria->addGroupByColumn(RbacUsersPeer::UID_AUTH_SOURCE);
|
||||
$oDataset = RbacUsersPeer::doSelectRS($oCriteria, Propel::getDbConnection('rbac_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$criteria = new Criteria('rbac');
|
||||
$criteria->addSelectColumn(RbacUsersPeer::UID_AUTH_SOURCE);
|
||||
$criteria->addSelectColumn('COUNT(*) AS CNT');
|
||||
$criteria->add(RbacUsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
$criteria->addGroupByColumn(RbacUsersPeer::UID_AUTH_SOURCE);
|
||||
$dataset = RbacUsersPeer::doSelectRS($criteria, Propel::getDbConnection('rbac_ro'));
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aAuth = Array();
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$aAuth[$row['UID_AUTH_SOURCE']] = $row['CNT'];
|
||||
$listAuth = [];
|
||||
while ($dataset->next()) {
|
||||
$row = $dataset->getRow();
|
||||
$listAuth[$row['UID_AUTH_SOURCE']] = $row['CNT'];
|
||||
}
|
||||
return $aAuth;
|
||||
|
||||
return $listAuth;
|
||||
}
|
||||
|
||||
//Returns all users with auth_source
|
||||
public function getListUsersByAuthSource($auth_source)
|
||||
/**
|
||||
* Get users list related to an authentication source
|
||||
* @param string $authSource
|
||||
* @return array $listUsers, all users with auth_source
|
||||
*/
|
||||
public function getListUsersByAuthSource($authSource)
|
||||
{
|
||||
$oCriteria = new Criteria('rbac');
|
||||
$oCriteria->addSelectColumn(RbacUsersPeer::USR_UID);
|
||||
$criteria = new Criteria('rbac');
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_UID);
|
||||
|
||||
if ($auth_source == '00000000000000000000000000000000') {
|
||||
$oCriteria->add(
|
||||
$oCriteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, $auth_source, Criteria::EQUAL)->addOr(
|
||||
$oCriteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, '', Criteria::EQUAL)
|
||||
));
|
||||
if ($authSource == '00000000000000000000000000000000') {
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, $authSource, Criteria::EQUAL)->addOr(
|
||||
$criteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, '', Criteria::EQUAL)
|
||||
));
|
||||
} else {
|
||||
$oCriteria->add(RbacUsersPeer::UID_AUTH_SOURCE, $auth_source, Criteria::EQUAL);
|
||||
$criteria->add(RbacUsersPeer::UID_AUTH_SOURCE, $authSource, Criteria::EQUAL);
|
||||
}
|
||||
$oCriteria->add(RbacUsersPeer::USR_STATUS, 0, Criteria::NOT_EQUAL);
|
||||
$oDataset = RbacUsersPeer::doSelectRS($oCriteria, Propel::getDbConnection('rbac_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$aUsers = array();
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$aUsers[] = $row['USR_UID'];
|
||||
$criteria->add(RbacUsersPeer::USR_STATUS, 0, Criteria::NOT_EQUAL);
|
||||
$dataset = RbacUsersPeer::doSelectRS($criteria, Propel::getDbConnection('rbac_ro'));
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$listUsers = [];
|
||||
while ($dataset->next()) {
|
||||
$row = $dataset->getRow();
|
||||
$listUsers[] = $row['USR_UID'];
|
||||
}
|
||||
return $aUsers;
|
||||
|
||||
return $listUsers;
|
||||
}
|
||||
|
||||
public function getUserRole($UsrUid)
|
||||
/**
|
||||
* Get the user's role
|
||||
* @param string $userUid
|
||||
* @return array $row
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getUserRole($userUid)
|
||||
{
|
||||
$con = Propel::getConnection(UsersRolesPeer::DATABASE_NAME);
|
||||
try {
|
||||
$c = new Criteria( 'rbac' );
|
||||
$c = new Criteria('rbac');
|
||||
$c->clearSelectColumns();
|
||||
$c->addSelectColumn ( RolesPeer::ROL_UID );
|
||||
$c->addSelectColumn ( RolesPeer::ROL_CODE );
|
||||
$c->addSelectColumn ( RolesPeer::ROL_STATUS );
|
||||
$c->addJoin ( UsersRolesPeer::ROL_UID, RolesPeer::ROL_UID );
|
||||
$c->add ( UsersRolesPeer::USR_UID, $UsrUid );
|
||||
$rs = UsersRolesPeer::doSelectRs( $c , Propel::getDbConnection('rbac_ro'));
|
||||
$rs->setFetchmode (ResultSet::FETCHMODE_ASSOC);
|
||||
$c->addSelectColumn(RolesPeer::ROL_UID);
|
||||
$c->addSelectColumn(RolesPeer::ROL_CODE);
|
||||
$c->addSelectColumn(RolesPeer::ROL_STATUS);
|
||||
$c->addJoin(UsersRolesPeer::ROL_UID, RolesPeer::ROL_UID);
|
||||
$c->add(UsersRolesPeer::USR_UID, $userUid);
|
||||
$rs = UsersRolesPeer::doSelectRs($c, Propel::getDbConnection('rbac_ro'));
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
throw($oError);
|
||||
} catch (Exception $error) {
|
||||
throw($error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +398,7 @@ class RbacUsers extends BaseRbacUsers
|
||||
);
|
||||
$array = parent::toArray($keyType);
|
||||
unset($array[$key]);
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ class Roles extends BaseRoles {
|
||||
$oCriteria->addSelectColumn(RolesPeer::ROL_UPDATE_DATE);
|
||||
$oCriteria->addSelectColumn(RolesPeer::ROL_STATUS);
|
||||
$oCriteria->add(RolesPeer::ROL_UID, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(RolesPeer::ROL_CODE, RBAC::PROCESSMAKER_GUEST, Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(SystemsPeer::SYS_CODE, $systemCode);
|
||||
$oCriteria->add(RolesPeer::ROL_CREATE_DATE, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(RolesPeer::ROL_UPDATE_DATE, '', Criteria::NOT_EQUAL);
|
||||
@@ -158,7 +159,7 @@ class Roles extends BaseRoles {
|
||||
$oCriteria->addSelectColumn(RolesPeer::ROL_CREATE_DATE);
|
||||
$oCriteria->addSelectColumn(RolesPeer::ROL_UPDATE_DATE);
|
||||
$oCriteria->addSelectColumn(RolesPeer::ROL_STATUS);
|
||||
$oCriteria->add(RolesPeer::ROL_UID, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(RolesPeer::ROL_UID, ['', RBAC::PROCESSMAKER_GUEST_UID], Criteria::NOT_IN);
|
||||
$oCriteria->add(SystemsPeer::SYS_CODE, $systemCode);
|
||||
$oCriteria->add(RolesPeer::ROL_CREATE_DATE, '', Criteria::NOT_EQUAL);
|
||||
$oCriteria->add(RolesPeer::ROL_UPDATE_DATE, '', Criteria::NOT_EQUAL);
|
||||
@@ -572,7 +573,7 @@ class Roles extends BaseRoles {
|
||||
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$result->next();
|
||||
|
||||
$a = Array();
|
||||
$a = [RBAC::PM_GUEST_CASE_UID];
|
||||
while( $row = $result->getRow() ) {
|
||||
$a[] = $row['PER_UID'];
|
||||
$result->next();
|
||||
|
||||
@@ -63,13 +63,15 @@ INSERT INTO `RBAC_PERMISSIONS` VALUES
|
||||
('00000000000000000000000000000062','PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS','2016-07-18 00:00:00','2016-07-18 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000063','PM_EDIT_USER_PROFILE_DEFAULT_CASES_MENU_OPTIONS','2016-07-18 00:00:00','2016-07-18 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000064','PM_REASSIGNCASE_SUPERVISOR','2016-09-01 00:00:00','2016-09-01 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000065','PM_SETUP_CUSTOM_CASES_LIST','2017-03-27 00:00:00','2017-03-27 00:00:00',1,'00000000000000000000000000000002');
|
||||
('00000000000000000000000000000065','PM_SETUP_CUSTOM_CASES_LIST','2017-03-27 00:00:00','2017-03-27 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000066','PM_GUEST_CASE','2017-03-27 00:00:00','2017-03-27 00:00:00',1,'00000000000000000000000000000002');
|
||||
|
||||
INSERT INTO `RBAC_ROLES` VALUES
|
||||
('00000000000000000000000000000001','','00000000000000000000000000000001','RBAC_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
|
||||
('00000000000000000000000000000002','','00000000000000000000000000000002','PROCESSMAKER_ADMIN','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
|
||||
('00000000000000000000000000000003','','00000000000000000000000000000002','PROCESSMAKER_OPERATOR','2007-07-31 19:10:22','2007-08-03 12:24:36',1),
|
||||
('00000000000000000000000000000004', '', '00000000000000000000000000000002', 'PROCESSMAKER_MANAGER', '2010-03-29 09:14:15', '2010-03-29 09:19:53', 1);
|
||||
('00000000000000000000000000000004', '', '00000000000000000000000000000002', 'PROCESSMAKER_MANAGER', '2010-03-29 09:14:15', '2010-03-29 09:19:53', 1),
|
||||
('00000000000000000000000000000005', '', '00000000000000000000000000000002', 'PROCESSMAKER_GUEST', '2009-02-01 12:24:36', '2009-02-01 12:24:36', 1);
|
||||
|
||||
|
||||
INSERT INTO `RBAC_ROLES_PERMISSIONS` VALUES
|
||||
@@ -213,8 +215,11 @@ INSERT INTO `RBAC_ROLES_PERMISSIONS` VALUES
|
||||
('00000000000000000000000000000004','00000000000000000000000000000060'),
|
||||
('00000000000000000000000000000004','00000000000000000000000000000061'),
|
||||
('00000000000000000000000000000004','00000000000000000000000000000062'),
|
||||
('00000000000000000000000000000004','00000000000000000000000000000063');
|
||||
('00000000000000000000000000000004','00000000000000000000000000000063'),
|
||||
('00000000000000000000000000000005','00000000000000000000000000000066');
|
||||
|
||||
INSERT INTO `RBAC_SYSTEMS` VALUES ('00000000000000000000000000000001','RBAC','2007-07-31 19:10:22','2007-08-03 12:24:36',1),('00000000000000000000000000000002','PROCESSMAKER','2007-07-31 19:10:22','2007-08-03 12:24:36',1);
|
||||
INSERT INTO `RBAC_USERS` VALUES ('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator','','admin@processmaker.com','2020-01-01','2007-08-03 12:24:36','2008-02-13 07:24:07',1,'MYSQL','00000000000000000000000000000000','','');
|
||||
INSERT INTO `RBAC_USERS_ROLES` VALUES ('00000000000000000000000000000001','00000000000000000000000000000002');
|
||||
INSERT INTO `RBAC_USERS` VALUES ('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator','','admin@processmaker.com','2020-01-01','2007-08-03 12:24:36','2008-02-13 07:24:07',1,'MYSQL','00000000000000000000000000000000','',''),
|
||||
('00000000000000000000000000000002','guest','674ba9750749d735ec9787d606170d78','Guest','','guest@processmaker.com','2200-01-01','2009-02-01 12:24:36','2009-02-01 12:24:36',0,'MYSQL','00000000000000000000000000000000','','');
|
||||
INSERT INTO `RBAC_USERS_ROLES` VALUES ('00000000000000000000000000000001','00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000002','00000000000000000000000000000005');
|
||||
|
||||
@@ -77,28 +77,38 @@ class Groups
|
||||
/**
|
||||
* Set a user to group
|
||||
*
|
||||
* @param string $GrpUid, $UsrUid
|
||||
* @return array
|
||||
* @param string $grpUid
|
||||
* @param string $usrUid
|
||||
* @return boolean
|
||||
* @throws exception
|
||||
*/
|
||||
public function addUserToGroup($GrpUid, $UsrUid)
|
||||
public function addUserToGroup($grpUid, $usrUid)
|
||||
{
|
||||
try {
|
||||
$oGrp = GroupUserPeer::retrieveByPk($GrpUid, $UsrUid);
|
||||
if (is_object($oGrp) && get_class($oGrp) == 'GroupUser') {
|
||||
//Check the usrUid value
|
||||
if (RBAC::isGuestUserUid($usrUid)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($usrUid)));
|
||||
return false;
|
||||
}
|
||||
|
||||
$groupUser = GroupUserPeer::retrieveByPk($grpUid, $usrUid);
|
||||
if (is_object($groupUser) && get_class($groupUser) == 'GroupUser') {
|
||||
return true;
|
||||
} else {
|
||||
$oGrp = new GroupUser();
|
||||
$oGrp->setGrpUid($GrpUid);
|
||||
$oGrp->setUsrUid($UsrUid);
|
||||
$oGrp->Save();
|
||||
$groupUser = new GroupUser();
|
||||
$groupUser->setGrpUid($grpUid);
|
||||
$groupUser->setUsrUid($usrUid);
|
||||
$groupUser->Save();
|
||||
|
||||
$oGrpwf = new Groupwf();
|
||||
$grpName = $oGrpwf->loadByGroupUid($GrpUid);
|
||||
$groupWf = new Groupwf();
|
||||
$grpName = $groupWf->loadByGroupUid($grpUid);
|
||||
|
||||
$oUsr = new Users();
|
||||
$usrName = $oUsr->load($UsrUid);
|
||||
$users = new Users();
|
||||
$usrName = $users->load($usrUid);
|
||||
|
||||
G::auditLog("AssignUserToGroup", "Assign user ". $usrName['USR_USERNAME'] ." (".$UsrUid.") to group ".$grpName['CON_VALUE']." (".$GrpUid.") ");
|
||||
G::auditLog("AssignUserToGroup", "Assign user ". $usrName['USR_USERNAME'] ." (".$usrUid.") to group ".$grpName['CON_VALUE']." (".$grpUid.") ");
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
@@ -107,13 +117,14 @@ class Groups
|
||||
|
||||
/**
|
||||
* Remove a user from group
|
||||
* @param string $GrpUid, $UsrUid
|
||||
* @param string $grpUid
|
||||
* @param string $usrUid
|
||||
* @return array
|
||||
*/
|
||||
public function removeUserOfGroup($GrpUid, $UsrUid)
|
||||
public function removeUserOfGroup($grpUid, $usrUid)
|
||||
{
|
||||
$gu = new GroupUser();
|
||||
$gu->remove($GrpUid, $UsrUid);
|
||||
$gu->remove($grpUid, $usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,7 +72,7 @@ class WsBase
|
||||
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
|
||||
$res = $RBAC->userCanAccess("PM_LOGIN");
|
||||
|
||||
if ($res != 1) {
|
||||
if ($res != 1 && $uid !== RBAC::GUEST_USER_UID) {
|
||||
$wsResponse = new WsResponse(2, G::loadTranslation('ID_USER_HAVENT_RIGHTS_SYSTEM'));
|
||||
throw (new Exception(serialize($wsResponse)));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class WsBase
|
||||
public function processList()
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$result = [];
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
|
||||
$oDataset = ProcessPeer::doSelectRS($oCriteria);
|
||||
@@ -142,7 +142,7 @@ class WsBase
|
||||
public function roleList()
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
$RBAC = & RBAC::getSingleton();
|
||||
$RBAC->initRBAC();
|
||||
@@ -195,7 +195,7 @@ class WsBase
|
||||
}
|
||||
$rs = GroupwfPeer::doSelectRS($criteria);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$result = array();
|
||||
$result = [];
|
||||
while ($rs->next()) {
|
||||
$rows = $rs->getRow();
|
||||
$result[] = array('guid' => $rows['GRP_UID'], 'name' => $rows['GRP_TITLE']);
|
||||
@@ -216,7 +216,7 @@ class WsBase
|
||||
public function departmentList()
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$result = [];
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(DepartmentPeer::DEP_STATUS, 'ACTIVE');
|
||||
$oDataset = DepartmentPeer::doSelectRS($oCriteria);
|
||||
@@ -283,9 +283,9 @@ class WsBase
|
||||
|
||||
if ($solrEnabled == 1) {
|
||||
try {
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$delegationIndexes = array();
|
||||
$delegationIndexes = [];
|
||||
$columsToInclude = array("APP_UID");
|
||||
$solrSearchText = null;
|
||||
|
||||
@@ -323,7 +323,7 @@ class WsBase
|
||||
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
|
||||
|
||||
//Get the missing data from database
|
||||
$arrayApplicationUid = array();
|
||||
$arrayApplicationUid = [];
|
||||
|
||||
foreach ($solrQueryResult->aaData as $i => $data) {
|
||||
$arrayApplicationUid[] = $data["APP_UID"];
|
||||
@@ -333,7 +333,7 @@ class WsBase
|
||||
|
||||
foreach ($solrQueryResult->aaData as $i => $data) {
|
||||
//Initialize array
|
||||
$delIndexes = array(); //Store all the delegation indexes
|
||||
$delIndexes = []; //Store all the delegation indexes
|
||||
//Complete empty values
|
||||
$applicationUid = $data["APP_UID"]; //APP_UID
|
||||
//Get all the indexes returned by Solr as columns
|
||||
@@ -357,7 +357,7 @@ class WsBase
|
||||
|
||||
//Get records
|
||||
foreach ($delIndexes as $delIndex) {
|
||||
$aRow = array();
|
||||
$aRow = [];
|
||||
|
||||
//Copy result values to new row from Solr server
|
||||
$aRow["APP_UID"] = $data["APP_UID"];
|
||||
@@ -394,7 +394,7 @@ class WsBase
|
||||
|
||||
return $arrayData;
|
||||
} catch (InvalidIndexSearchTextException $e) {
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$arrayData[] = array(
|
||||
"guid" => $e->getMessage(),
|
||||
@@ -407,7 +407,7 @@ class WsBase
|
||||
return $arrayData;
|
||||
}
|
||||
} else {
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
@@ -452,7 +452,7 @@ class WsBase
|
||||
return $arrayData;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$arrayData[] = array(
|
||||
"guid" => $e->getMessage(),
|
||||
@@ -475,7 +475,7 @@ class WsBase
|
||||
public function unassignedCaseList($userId)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$result = [];
|
||||
$oAppCache = new AppCacheView();
|
||||
$Criteria = $oAppCache->getUnassignedListCriteria($userId);
|
||||
$oDataset = AppCacheViewPeer::doSelectRS($Criteria);
|
||||
@@ -504,30 +504,34 @@ class WsBase
|
||||
}
|
||||
|
||||
/**
|
||||
* get all groups
|
||||
* Get all users
|
||||
*
|
||||
* @param none
|
||||
* @return $result will return an object
|
||||
* @return array $result, will return an array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userList()
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$result = [];
|
||||
$criteria = new Criteria('workflow');
|
||||
$criteria->add(UsersPeer::USR_STATUS, 'ACTIVE');
|
||||
$criteria->add(UsersPeer::USR_UID, [RBAC::GUEST_USER_UID], Criteria::NOT_IN);
|
||||
$dataset = UsersPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$result[] = array('guid' => $aRow['USR_UID'], 'name' => $aRow['USR_USERNAME']);
|
||||
$oDataset->next();
|
||||
while ($row = $dataset->getRow()) {
|
||||
$result[] = ['guid' => $row['USR_UID'], 'name' => $row['USR_USERNAME']];
|
||||
$dataset->next();
|
||||
}
|
||||
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$result[] = array('guid' => $e->getMessage(), 'name' => $e->getMessage()
|
||||
);
|
||||
$result[] = [
|
||||
'guid' => $e->getMessage(),
|
||||
'name' => $e->getMessage()
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -542,7 +546,7 @@ class WsBase
|
||||
public function triggerList()
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$result = [];
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
|
||||
$oCriteria->addSelectColumn(TriggersPeer::PRO_UID);
|
||||
@@ -583,12 +587,12 @@ class WsBase
|
||||
$sTaskUID = '';
|
||||
$oCriteria = $oCase->getAllUploadedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID);
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
global $_DBArray;
|
||||
|
||||
foreach ($_DBArray['inputDocuments'] as $key => $row) {
|
||||
if (isset($row['DOC_VERSION'])) {
|
||||
$docrow = array();
|
||||
$docrow = [];
|
||||
$docrow['guid'] = $row['APP_DOC_UID'];
|
||||
$docrow['filename'] = $row['APP_DOC_FILENAME'];
|
||||
$docrow['docId'] = $row['DOC_UID'];
|
||||
@@ -630,7 +634,7 @@ class WsBase
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if ($aRow['INP_DOC_TITLE'] == null) {
|
||||
@@ -641,7 +645,7 @@ class WsBase
|
||||
$aRow['INP_DOC_DESCRIPTION'] = $inputDocumentObj['INP_DOC_DESCRIPTION'];
|
||||
}
|
||||
|
||||
$docrow = array();
|
||||
$docrow = [];
|
||||
$docrow['guid'] = $aRow['INP_DOC_UID'];
|
||||
$docrow['name'] = $aRow['INP_DOC_TITLE'];
|
||||
$docrow['description'] = $aRow['INP_DOC_DESCRIPTION'];
|
||||
@@ -674,12 +678,12 @@ class WsBase
|
||||
$sTaskUID = '';
|
||||
$oCriteria = $oCase->getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID);
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
global $_DBArray;
|
||||
|
||||
foreach ($_DBArray['outputDocuments'] as $key => $row) {
|
||||
if (isset($row['DOC_VERSION'])) {
|
||||
$docrow = array();
|
||||
$docrow = [];
|
||||
$docrow['guid'] = $row['APP_DOC_UID'];
|
||||
$docrow['filename'] = $row['DOWNLOAD_FILE'];
|
||||
|
||||
@@ -736,7 +740,7 @@ class WsBase
|
||||
$oGroup = new Groups();
|
||||
$aGroups = $oGroup->getActiveGroupsForAnUser($userId);
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$del = DBAdapter::getStringDelimiter();
|
||||
$oCriteria->addSelectColumn(TaskPeer::PRO_UID);
|
||||
@@ -787,13 +791,13 @@ class WsBase
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function sendMessage(
|
||||
$caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true, $delIndex = 0, $config = array(), $gmail = 0
|
||||
$caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $appFields = null, $aAttachment = null, $showMessage = true, $delIndex = 0, $config = [], $gmail = 0
|
||||
) {
|
||||
try {
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (!empty($config)) {
|
||||
$arrayConfigAux = array();
|
||||
$arrayConfigAux = [];
|
||||
|
||||
if (is_array($config)) {
|
||||
if (PMLicensedFeatures::getSingleton()->verifyfeature("nKaNTNuT1MzK0RsMEtXTnYzR09ucHF2WGNuS0hRdDBBak42WXJhNVVOOG1INEVoaU1EaTllbjBBeEJNeG9wRVJ6NmxQelhyVTBvdThzPQ==")) {
|
||||
@@ -962,7 +966,7 @@ class WsBase
|
||||
|
||||
$oDataset = AppDelayPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$aIndexsPaused = array();
|
||||
$aIndexsPaused = [];
|
||||
while ($oDataset->next()) {
|
||||
$data = $oDataset->getRow();
|
||||
$aIndexsPaused[] = $data['APP_DEL_INDEX'];
|
||||
@@ -993,7 +997,7 @@ class WsBase
|
||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aCurrentUsers = array();
|
||||
$aCurrentUsers = [];
|
||||
|
||||
while ($oDataset->next()) {
|
||||
$aAppDel = $oDataset->getRow();
|
||||
@@ -1114,7 +1118,7 @@ class WsBase
|
||||
$strRole = $role;
|
||||
|
||||
if ($RBAC->verifyByCode($role) == 0) {
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["ROLE"] = $role;
|
||||
|
||||
$result = new WsCreateUserResponse(6, G::loadTranslation("ID_INVALID_ROLE", SYS_LANG, $data), null);
|
||||
@@ -1130,7 +1134,7 @@ class WsBase
|
||||
}
|
||||
|
||||
if ($RBAC->verifyUser($userName) == 1) {
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["USER_ID"] = $userName;
|
||||
|
||||
$result = new WsCreateUserResponse(7, G::loadTranslation("ID_USERNAME_ALREADY_EXISTS", SYS_LANG, $data), null);
|
||||
@@ -1139,7 +1143,7 @@ class WsBase
|
||||
}
|
||||
|
||||
//Set fields
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$arrayData["USR_USERNAME"] = $userName;
|
||||
$arrayData["USR_PASSWORD"] = Bootstrap::hashPassword($password);
|
||||
@@ -1175,7 +1179,7 @@ class WsBase
|
||||
$user->create($arrayData);
|
||||
|
||||
//Response
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["FIRSTNAME"] = $firstName;
|
||||
$data["LASTNAME"] = $lastName;
|
||||
$data["USER_ID"] = $userName;
|
||||
@@ -1265,7 +1269,7 @@ class WsBase
|
||||
$strRole = $role;
|
||||
|
||||
if ($RBAC->verifyByCode($role) == 0) {
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["ROLE"] = $role;
|
||||
|
||||
$result = new WsResponse(6, G::LoadTranslation("ID_INVALID_ROLE", SYS_LANG, $data));
|
||||
@@ -1288,7 +1292,7 @@ class WsBase
|
||||
$rs = UsersPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rs->next()) {
|
||||
$data = array();
|
||||
$data = [];
|
||||
$data["USER_ID"] = $userName;
|
||||
|
||||
$result = new WsResponse(7, G::LoadTranslation("ID_USERNAME_ALREADY_EXISTS", SYS_LANG, $data));
|
||||
@@ -1297,7 +1301,7 @@ class WsBase
|
||||
}
|
||||
|
||||
//Set fields
|
||||
$arrayData = array();
|
||||
$arrayData = [];
|
||||
|
||||
$arrayData["USR_UID"] = $userUid;
|
||||
$arrayData["USR_USERNAME"] = $userName;
|
||||
@@ -1695,7 +1699,7 @@ class WsBase
|
||||
|
||||
$caseFields = $oCase->loadCase($caseId);
|
||||
$oldFields = $caseFields['APP_DATA'];
|
||||
$resFields = array();
|
||||
$resFields = [];
|
||||
|
||||
foreach ($variables as $key => $val) {
|
||||
$a .= $val->name . ', ';
|
||||
@@ -1763,7 +1767,7 @@ class WsBase
|
||||
$caseFields = $oCase->loadCase($caseId);
|
||||
|
||||
$oldFields = $caseFields['APP_DATA'];
|
||||
$resFields = array();
|
||||
$resFields = [];
|
||||
|
||||
foreach ($oldFields as $key => $val) {
|
||||
$node = new stdClass();
|
||||
@@ -1805,7 +1809,7 @@ class WsBase
|
||||
$_SESSION["TASK"] = $taskId;
|
||||
$_SESSION["USER_LOGGED"] = $userId;
|
||||
|
||||
$Fields = array();
|
||||
$Fields = [];
|
||||
|
||||
if (is_array($variables) && count($variables) > 0) {
|
||||
$Fields = $variables;
|
||||
@@ -2105,7 +2109,7 @@ class WsBase
|
||||
* @param bool $bExecuteTriggersBeforeAssignment
|
||||
* @return $result will return an object
|
||||
*/
|
||||
public function derivateCase($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = array())
|
||||
public function derivateCase($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = [])
|
||||
{
|
||||
$g = new G();
|
||||
|
||||
@@ -2119,7 +2123,7 @@ class WsBase
|
||||
//Define variables
|
||||
$sStatus = 'TO_DO';
|
||||
$varResponse = '';
|
||||
$previousAppData = array();
|
||||
$previousAppData = [];
|
||||
|
||||
if ($delIndex == '') {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
@@ -2165,7 +2169,7 @@ class WsBase
|
||||
}
|
||||
}
|
||||
|
||||
$aData = array();
|
||||
$aData = [];
|
||||
$aData['APP_UID'] = $caseId;
|
||||
$aData['DEL_INDEX'] = $delIndex;
|
||||
$aData['USER_UID'] = $userId;
|
||||
@@ -2221,7 +2225,7 @@ class WsBase
|
||||
|
||||
foreach ($derive as $key => $val) {
|
||||
//Routed to the next task, if end process then not exist user
|
||||
$nodeNext = array();
|
||||
$nodeNext = [];
|
||||
$usrasgdUid = null;
|
||||
$usrasgdUserName = null;
|
||||
|
||||
@@ -2332,7 +2336,7 @@ class WsBase
|
||||
$oDataset = AppDelegationPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$aCurrentUsers = array();
|
||||
$aCurrentUsers = [];
|
||||
|
||||
while ($oDataset->next()) {
|
||||
$aAppDel = $oDataset->getRow();
|
||||
@@ -2469,7 +2473,7 @@ class WsBase
|
||||
}
|
||||
|
||||
//executeTrigger
|
||||
$aTriggers = array();
|
||||
$aTriggers = [];
|
||||
$c = new Criteria();
|
||||
$c->add(TriggersPeer::TRI_UID, $triggerIndex);
|
||||
$rs = TriggersPeer::doSelectRS($c);
|
||||
@@ -2531,7 +2535,7 @@ class WsBase
|
||||
*/
|
||||
public function taskCase($caseId)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
try {
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
@@ -2574,7 +2578,7 @@ class WsBase
|
||||
try {
|
||||
$oCase = new Cases();
|
||||
$rows = $oCase->getStartCases($userId);
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
foreach ($rows as $key => $val) {
|
||||
if ($key != 0) {
|
||||
@@ -2659,7 +2663,7 @@ class WsBase
|
||||
* ****************( 3 )*****************
|
||||
*/
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$aConditions = array();
|
||||
$aConditions = [];
|
||||
$oCriteria->add(AppDelegationPeer::APP_UID, $caseId);
|
||||
$oCriteria->add(AppDelegationPeer::USR_UID, $userIdSource);
|
||||
$oCriteria->add(AppDelegationPeer::DEL_INDEX, $delIndex);
|
||||
@@ -2790,10 +2794,10 @@ class WsBase
|
||||
try {
|
||||
$result = new wsGetCaseNotesResponse(0, G::loadTranslation('ID_SUCCESS'), Cases::getCaseNotes($applicationID, 'array', $userUid));
|
||||
|
||||
$var = array();
|
||||
$var = [];
|
||||
|
||||
foreach ($result->notes as $key => $value) {
|
||||
$var2 = array();
|
||||
$var2 = [];
|
||||
|
||||
foreach ($value as $keys => $values) {
|
||||
$field = strtolower($keys);
|
||||
|
||||
@@ -1,33 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* TaskUser.php
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* 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 'classes/model/om/BaseTaskUser.php';
|
||||
//require_once 'classes/model/Content.php';
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'GROUP_USER' table.
|
||||
*
|
||||
@@ -39,42 +10,59 @@
|
||||
*
|
||||
* @package workflow.engine.classes.model
|
||||
*/
|
||||
|
||||
use ProcessMaker\BusinessModel\WebEntry;
|
||||
class TaskUser extends BaseTaskUser
|
||||
{
|
||||
|
||||
/**
|
||||
* Create the application document registry
|
||||
* Create the new record in the table TaskUser
|
||||
*
|
||||
* @param array $aData
|
||||
* @param array $requestData
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*
|
||||
*/
|
||||
public function create ($aData)
|
||||
public function create ($requestData)
|
||||
{
|
||||
$oConnection = Propel::getConnection( TaskUserPeer::DATABASE_NAME );
|
||||
$connection = Propel::getConnection(TaskUserPeer::DATABASE_NAME);
|
||||
try {
|
||||
$taskUser = TaskUserPeer::retrieveByPK( $aData['TAS_UID'], $aData['USR_UID'], $aData['TU_TYPE'], $aData['TU_RELATION'] );
|
||||
|
||||
if (is_object( $taskUser )) {
|
||||
return - 1;
|
||||
$bmWebEntry = new WebEntry;
|
||||
//Check the usrUid value
|
||||
if (RBAC::isGuestUserUid($requestData['USR_UID']) && !$bmWebEntry->isTaskAWebEntry($requestData['TAS_UID'])) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($requestData['USR_UID'])));
|
||||
return false;
|
||||
}
|
||||
$oTaskUser = new TaskUser();
|
||||
$oTaskUser->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($oTaskUser->validate()) {
|
||||
$oConnection->begin();
|
||||
$iResult = $oTaskUser->save();
|
||||
$oConnection->commit();
|
||||
return $iResult;
|
||||
|
||||
$taskUser = TaskUserPeer::retrieveByPK(
|
||||
$requestData['TAS_UID'],
|
||||
$requestData['USR_UID'],
|
||||
$requestData['TU_TYPE'],
|
||||
$requestData['TU_RELATION']
|
||||
);
|
||||
|
||||
if (is_object($taskUser)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$taskUser = new TaskUser();
|
||||
$taskUser->fromArray($requestData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($taskUser->validate()) {
|
||||
$connection->begin();
|
||||
$result = $taskUser->save();
|
||||
$connection->commit();
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$sMessage = '';
|
||||
$aValidationFailures = $oTaskUser->getValidationFailures();
|
||||
$message = '';
|
||||
$aValidationFailures = $taskUser->getValidationFailures();
|
||||
foreach ($aValidationFailures as $oValidationFailure) {
|
||||
$sMessage .= $oValidationFailure->getMessage() . '<br />';
|
||||
$message .= $oValidationFailure->getMessage() . '<br />';
|
||||
}
|
||||
throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
|
||||
throw (new Exception('The registry cannot be created!<br />' . $message));
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
$connection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,10 +281,20 @@ class Users extends BaseUsers
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all information about the user
|
||||
* @param string $userUid
|
||||
* @return array $arrayData
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAllInformation ($userUid)
|
||||
{
|
||||
if (! isset( $userUid ) || $userUid == "") {
|
||||
throw (new Exception( "$userUid is empty." ));
|
||||
if (!isset($userUid) || empty($userUid)) {
|
||||
throw (new Exception('$userUid is empty.'));
|
||||
}
|
||||
if (RBAC::isGuestUserUid($userUid)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($userUid)));
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
INSERT INTO USERS (USR_UID,USR_USERNAME,USR_PASSWORD,USR_FIRSTNAME,USR_LASTNAME,USR_EMAIL,USR_DUE_DATE,USR_CREATE_DATE,USR_UPDATE_DATE,USR_STATUS,USR_COUNTRY,USR_CITY,USR_LOCATION,USR_ADDRESS,USR_PHONE,USR_FAX,USR_CELLULAR,USR_ZIP_CODE,DEP_UID,USR_POSITION,USR_RESUME,USR_BIRTHDAY,USR_ROLE,USR_REPORTS_TO,USR_REPLACED_BY ) VALUES
|
||||
('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator',' ', 'admin@processmaker.com','2020-01-01','1999-11-30 00:00:00','2008-05-23 18:36:19','ACTIVE', 'US','FL','MMK','','', '1-305-402-0282','1-305-675-1400','','','Administrator', '','1999-02-25','PROCESSMAKER_ADMIN','','');
|
||||
('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator',' ', 'admin@processmaker.com','2020-01-01','1999-11-30 00:00:00','2008-05-23 18:36:19','ACTIVE', 'US','FL','MMK','','', '1-305-402-0282','1-305-675-1400','','','Administrator', '','1999-02-25','PROCESSMAKER_ADMIN','',''),
|
||||
('00000000000000000000000000000002','guest','674ba9750749d735ec9787d606170d78','Guest',' ', 'guest@processmaker.com','2200-01-01','2009-02-01 12:24:36','2009-02-01 12:24:36','INACTIVE', 'US','FL','MMK','','', '1-305-402-0282','1-305-675-1400','','','Guest', '','2009-02-01','PROCESSMAKER_GUEST','','');
|
||||
|
||||
INSERT INTO CONTENT (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG,CON_VALUE) VALUES
|
||||
('ROL_NAME','','00000000000000000000000000000002','en','System Administrator'),
|
||||
|
||||
@@ -64,6 +64,7 @@ if ($actionAjax == "userValues") {
|
||||
$cUsers->addSelectColumn(UsersPeer::USR_ID);
|
||||
break;
|
||||
}
|
||||
$cUsers->add(UsersPeer::USR_UID, [RBAC::GUEST_USER_UID], Criteria::NOT_IN);
|
||||
$cUsers->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
if (!is_null($query)) {
|
||||
$filters = $cUsers->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $query . '%', Criteria::LIKE)->addOr(
|
||||
|
||||
@@ -1,38 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* main.php Cases List main processor
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$RBAC->requirePermissions( 'PM_CASES' );
|
||||
$RBAC->requirePermissions('PM_CASES/strict');
|
||||
|
||||
$G_MAIN_MENU = 'processmaker';
|
||||
$G_ID_MENU_SELECTED = 'CASES';
|
||||
|
||||
$_POST['qs'] = isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' ? '?' . $_SERVER['QUERY_STRING'] : '';
|
||||
$_POST['qs'] = isset($_SERVER['QUERY_STRING'])
|
||||
&& $_SERVER['QUERY_STRING'] != '' ? '?' . $_SERVER['QUERY_STRING'] : '';
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'view', 'cases/cases_Load' );
|
||||
$G_PUBLISH->AddContent('view', 'cases/cases_Load');
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile('/jscore/src/PM.js');
|
||||
$oHeadPublisher->addScriptFile('/jscore/src/Sessions.js');
|
||||
G::RenderPage( 'publish' );
|
||||
G::RenderPage('publish');
|
||||
|
||||
|
||||
@@ -252,7 +252,8 @@ switch ($_POST['action']) {
|
||||
$subQuery = "SELECT " . GroupUserPeer::USR_UID .
|
||||
" FROM " . GroupUserPeer::TABLE_NAME .
|
||||
" WHERE " . GroupUserPeer::GRP_UID . " = '" .
|
||||
$inputFilter->quoteSmart($_REQUEST['gUID'], Propel::getConnection("workflow")) . "'";
|
||||
$inputFilter->quoteSmart($_REQUEST['gUID'], Propel::getConnection("workflow")) . "'\n" .
|
||||
"UNION SELECT '" . RBAC::GUEST_USER_UID . "'";
|
||||
|
||||
$aUsers = Array ();
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
|
||||
@@ -293,7 +293,7 @@ try {
|
||||
|
||||
// Assign the uid of user to userloggedobj
|
||||
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
|
||||
$res = $RBAC->userCanAccess('PM_LOGIN');
|
||||
$res = $RBAC->userCanAccess('PM_LOGIN/strict');
|
||||
if ($res != 1 ) {
|
||||
if ($res == -2) {
|
||||
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
|
||||
|
||||
@@ -981,14 +981,7 @@ function ifPermission($sessionId, $permission)
|
||||
|
||||
$oRBAC = RBAC::getSingleton();
|
||||
$oRBAC->loadUserRolePermission($oRBAC->sSystem, $user['USR_UID']);
|
||||
$aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
|
||||
$sw = 0;
|
||||
|
||||
foreach ($aPermissions as $aPermission) {
|
||||
if ($aPermission['PER_CODE'] == $permission) {
|
||||
$sw = 1;
|
||||
}
|
||||
}
|
||||
$sw = $oRBAC->userCanAccess($permission) === 1 ? 1 : 0;
|
||||
|
||||
return $sw;
|
||||
}
|
||||
|
||||
@@ -8,33 +8,33 @@ global $RBAC;
|
||||
G::LoadClass('pmFunctions');
|
||||
try {
|
||||
if (empty($_REQUEST['we_uid'])) {
|
||||
throw new \Exception('Missing required field "we_uid"');
|
||||
throw new Exception('Missing required field "we_uid"');
|
||||
}
|
||||
|
||||
$weUid = $_REQUEST['we_uid'];
|
||||
|
||||
$webEntry = \WebEntryPeer::retrieveByPK($weUid);
|
||||
$webEntry = WebEntryPeer::retrieveByPK($weUid);
|
||||
if (empty($webEntry)) {
|
||||
throw new \Exception('Undefined WebEntry');
|
||||
throw new Exception('Undefined WebEntry');
|
||||
}
|
||||
|
||||
$userUid = $webEntry->getUsrUid();
|
||||
$userInfo = PMFInformationUser($userUid);
|
||||
$userInfo = UsersPeer::retrieveByPK($userUid);
|
||||
if (empty($userInfo)) {
|
||||
throw new \Exception('WebEntry User not found');
|
||||
throw new Exception('WebEntry User not found');
|
||||
}
|
||||
|
||||
initUserSession($userUid, $userInfo['username']);
|
||||
initUserSession($userUid, $userInfo->getUsrUsername());
|
||||
|
||||
$result = [
|
||||
'user_logged' => $userUid,
|
||||
'userName' => $userInfo['username'],
|
||||
'firstName' => $userInfo['firstname'],
|
||||
'lastName' => $userInfo['lastname'],
|
||||
'mail' => $userInfo['mail'],
|
||||
'user_logged' => $userUid,
|
||||
'userName' => $userInfo->getUsrUsername(),
|
||||
'firstName' => $userInfo->getUsrFirstName(),
|
||||
'lastName' => $userInfo->getUsrLastName(),
|
||||
'mail' => $userInfo->getUsrEmail(),
|
||||
'image' => '../users/users_ViewPhoto?t='.microtime(true),
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$result = [
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
|
||||
@@ -1,31 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* dashboard.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.
|
||||
*/
|
||||
|
||||
$RBAC->requirePermissions('PM_DASHBOARD');
|
||||
$licensedFeatures = & PMLicensedFeatures::getSingleton();
|
||||
if (!$licensedFeatures->verifyfeature('r19Vm5DK1UrT09MenlLYjZxejlhNUZ1b1NhV0JHWjBsZEJ6dnpJa3dTeWVLVT0=')) {
|
||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
||||
G::header( 'location: ../login/login' );
|
||||
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||
G::header('location: ../login/login');
|
||||
die;
|
||||
}
|
||||
|
||||
@@ -33,10 +11,10 @@ $G_MAIN_MENU = 'processmaker';
|
||||
$G_ID_MENU_SELECTED = 'DASHBOARD+';
|
||||
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent( 'view', 'strategicDashboard/load' );
|
||||
$G_PUBLISH->AddContent('view', 'strategicDashboard/load');
|
||||
$oHeadPublisher = & headPublisher::getSingleton();
|
||||
$oHeadPublisher->addScriptFile('/jscore/src/PM.js');
|
||||
$oHeadPublisher->addScriptFile('/jscore/src/Sessions.js');
|
||||
G::RenderPage( 'publish' );
|
||||
G::RenderPage('publish');
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
//Check guest user
|
||||
if (isset($_GET['USR_UID']) && RBAC::isGuestUserUid($_GET['USR_UID'])) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($_GET['USR_UID'])));
|
||||
return;
|
||||
}
|
||||
|
||||
//calculating the max upload file size;
|
||||
use ProcessMaker\Core\System;
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ try {
|
||||
$total = $webEntry->getWebEntryRelatedToUser($userUid);
|
||||
}
|
||||
|
||||
//check user guest
|
||||
if (RBAC::isGuestUserUid($userUid)) {
|
||||
$total++;
|
||||
}
|
||||
|
||||
$response = '{success: true, candelete: ';
|
||||
$response .= ($total > 0) ? 'false' : 'true';
|
||||
$response .= ', hashistory: ';
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use \G;
|
||||
use \UsersPeer;
|
||||
use \DepartmentPeer;
|
||||
use BasePeer;
|
||||
use Configurations;
|
||||
use Criteria;
|
||||
use Department as DepartmentModel;
|
||||
use DepartmentPeer;
|
||||
use Exception;
|
||||
use ProcessMaker\BusinessModel\Validator;
|
||||
use Propel;
|
||||
use RBAC;
|
||||
use ResultSet;
|
||||
use Users;
|
||||
use UsersPeer;
|
||||
use G;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Department
|
||||
{
|
||||
/**
|
||||
@@ -16,27 +22,26 @@ class Department
|
||||
*
|
||||
* @param string $departmentTitle Title
|
||||
* @param string $departmentUidExclude Unique id of Department to exclude
|
||||
*
|
||||
* return bool Return true if exists the title of a Department, false otherwise
|
||||
* @return bool Return true if exists the title of a Department, false otherwise
|
||||
*/
|
||||
public function existsTitle($departmentTitle, $departmentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\DepartmentPeer::DEP_UID);
|
||||
$criteria->addSelectColumn(\DepartmentPeer::DEP_TITLE);
|
||||
$criteria->addSelectColumn(DepartmentPeer::DEP_UID);
|
||||
$criteria->addSelectColumn(DepartmentPeer::DEP_TITLE);
|
||||
|
||||
if ($departmentUidExclude != "") {
|
||||
$criteria->add(\DepartmentPeer::DEP_UID, $departmentUidExclude, \Criteria::NOT_EQUAL);
|
||||
$criteria->add(DepartmentPeer::DEP_UID, $departmentUidExclude, Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\DepartmentPeer::DEP_TITLE, $departmentTitle, \Criteria::EQUAL);
|
||||
$criteria->add(DepartmentPeer::DEP_TITLE, $departmentTitle, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \DepartmentPeer::doSelectRS($criteria);
|
||||
$rsCriteria = DepartmentPeer::doSelectRS($criteria);
|
||||
|
||||
return ($rsCriteria->next())? true : false;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -46,18 +51,17 @@ class Department
|
||||
*
|
||||
* @param string $departmentUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return void Throw exception user not exists
|
||||
* @return void Throw exception user not exists
|
||||
*/
|
||||
private function throwExceptionUserNotExistsInDepartment($departmentUid, $userUid)
|
||||
{
|
||||
try {
|
||||
$user = \UsersPeer::retrieveByPK($userUid);
|
||||
$user = UsersPeer::retrieveByPK($userUid);
|
||||
|
||||
if (is_null($user) || $user->getDepUid() != $departmentUid) {
|
||||
throw new \Exception(\G::LoadTranslation('ID_USER_NOT_EXIST_DEPARTMENT', [$userUid]));
|
||||
throw new Exception(G::LoadTranslation('ID_USER_NOT_EXIST_DEPARTMENT', [$userUid]));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -68,16 +72,15 @@ class Department
|
||||
* @param string $departmentTitle Title
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $departmentUidExclude Unique id of Department to exclude
|
||||
*
|
||||
* return void Throw exception if exists the title of a Department
|
||||
* @return void Throw exception if exists the title of a Department
|
||||
*/
|
||||
public function throwExceptionIfExistsTitle($departmentTitle, $fieldNameForException, $departmentUidExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->existsTitle($departmentTitle, $departmentUidExclude)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_DEPARTMENT_TITLE_ALREADY_EXISTS", array($fieldNameForException, $departmentTitle)));
|
||||
throw new Exception(G::LoadTranslation("ID_DEPARTMENT_TITLE_ALREADY_EXISTS", array($fieldNameForException, $departmentTitle)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +92,6 @@ class Department
|
||||
* @param array $arrayVariableNameForException Variable name for exception
|
||||
* @param bool $throwException Flag to throw the exception if the main parameters are invalid or do not exist
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array Returns an array with Department record, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getDepartmentRecordByPk(
|
||||
@@ -98,11 +100,11 @@ class Department
|
||||
$throwException = true
|
||||
) {
|
||||
try {
|
||||
$obj = \DepartmentPeer::retrieveByPK($departmentUid);
|
||||
$obj = DepartmentPeer::retrieveByPK($departmentUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
throw new Exception(G::LoadTranslation(
|
||||
'ID_DEPARTMENT_NOT_EXIST', [$arrayVariableNameForException['$departmentUid'], $departmentUid]
|
||||
));
|
||||
} else {
|
||||
@@ -111,8 +113,8 @@ class Department
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
return $obj->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -121,14 +123,11 @@ class Department
|
||||
* Get list for Departments
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDepartments()
|
||||
{
|
||||
$oDepartment = new \Department();
|
||||
$oDepartment = new DepartmentModel();
|
||||
$aDepts = $oDepartment->getDepartments('');
|
||||
foreach ($aDepts as &$depData) {
|
||||
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
||||
@@ -142,15 +141,14 @@ class Department
|
||||
*
|
||||
* @param string $departmentUid Unique id of Department
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the User assigned to Department
|
||||
*/
|
||||
public function assignUser($departmentUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
$process = new Process();
|
||||
$validator = new Validator();
|
||||
|
||||
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
@@ -172,14 +170,14 @@ class Department
|
||||
);
|
||||
|
||||
//Verify data
|
||||
$departmentUid = \ProcessMaker\BusinessModel\Validator::depUid($departmentUid);
|
||||
$departmentUid = Validator::depUid($departmentUid);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $arrayUserFieldDefinition, $arrayUserFieldNameForException, true);
|
||||
|
||||
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $arrayUserFieldNameForException["userUid"]);
|
||||
|
||||
//Assign User
|
||||
$department = new \Department();
|
||||
$department = new DepartmentModel();
|
||||
|
||||
$department->load($departmentUid);
|
||||
|
||||
@@ -192,7 +190,7 @@ class Department
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -201,9 +199,6 @@ class Department
|
||||
* Post Unassign User
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unassignUser($dep_uid, $usr_uid)
|
||||
@@ -213,7 +208,7 @@ class Department
|
||||
|
||||
$this->throwExceptionUserNotExistsInDepartment($dep_uid, $usr_uid);
|
||||
|
||||
$dep = new \Department();
|
||||
$dep = new DepartmentModel();
|
||||
$dep->load( $dep_uid );
|
||||
$manager = $dep->getDepManager();
|
||||
$dep->removeUserFromDepartment( $dep_uid, $usr_uid );
|
||||
@@ -229,7 +224,6 @@ class Department
|
||||
* Get custom record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* @return array Return an array with custom record
|
||||
*/
|
||||
private function __getUserCustomRecordFromRecord(array $record)
|
||||
@@ -248,7 +242,7 @@ class Department
|
||||
}
|
||||
|
||||
return $recordc;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +260,6 @@ class Department
|
||||
* @param bool $flagRecord Flag that set the "getting" of record
|
||||
* @param bool $throwException Flag to throw the exception (This only if the parameters are invalid)
|
||||
* (TRUE: throw the exception; FALSE: returns FALSE)
|
||||
*
|
||||
* @return array Return an array with all Users of a Department, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getUsers(
|
||||
@@ -288,14 +281,14 @@ class Department
|
||||
//Verify data and Set variables
|
||||
$flagFilter = !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']);
|
||||
|
||||
$result = \ProcessMaker\BusinessModel\Validator::validatePagerDataByPagerDefinition(
|
||||
$result = Validator::validatePagerDataByPagerDefinition(
|
||||
['$start' => $start, '$limit' => $limit],
|
||||
['$start' => '$start', '$limit' => '$limit']
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
if ($throwException) {
|
||||
throw new \Exception($result);
|
||||
throw new Exception($result);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -336,22 +329,23 @@ class Department
|
||||
}
|
||||
|
||||
//Query
|
||||
$criteria = new \Criteria('workflow');
|
||||
$criteria = new Criteria('workflow');
|
||||
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_LASTNAME);
|
||||
$criteria->addSelectColumn(\UsersPeer::USR_STATUS);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_STATUS);
|
||||
|
||||
$criteria->add(\UsersPeer::USR_STATUS, 'CLOSED', \Criteria::NOT_EQUAL);
|
||||
$criteria->add(UsersPeer::USR_STATUS, 'CLOSED', Criteria::NOT_EQUAL);
|
||||
|
||||
switch ($option) {
|
||||
case 'ASSIGNED':
|
||||
$criteria->add(\UsersPeer::DEP_UID, $departmentUid, \Criteria::EQUAL);
|
||||
$criteria->add(UsersPeer::DEP_UID, $departmentUid, Criteria::EQUAL);
|
||||
break;
|
||||
case 'AVAILABLE':
|
||||
$criteria->add(\UsersPeer::DEP_UID, '', \Criteria::EQUAL);
|
||||
$criteria->add(UsersPeer::DEP_UID, '', Criteria::EQUAL);
|
||||
$criteria->add(UsersPeer::USR_UID, RBAC::GUEST_USER_UID, Criteria::NOT_EQUAL);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -367,24 +361,24 @@ class Department
|
||||
];
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_USERNAME, $search, \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_FIRSTNAME, $search, \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\UsersPeer::USR_LASTNAME, $search, \Criteria::LIKE)))
|
||||
$criteria->getNewCriterion(UsersPeer::USR_USERNAME, $search, Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, $search, Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(UsersPeer::USR_LASTNAME, $search, Criteria::LIKE)))
|
||||
);
|
||||
}
|
||||
|
||||
//Number records total
|
||||
$numRecTotal = \UsersPeer::doCount($criteria);
|
||||
$numRecTotal = UsersPeer::doCount($criteria);
|
||||
|
||||
//Query
|
||||
$conf = new \Configurations();
|
||||
$sortFieldDefault = \UsersPeer::TABLE_NAME . '.' . $conf->userNameFormatGetFirstFieldByUsersTable();
|
||||
$conf = new Configurations();
|
||||
$sortFieldDefault = UsersPeer::TABLE_NAME . '.' . $conf->userNameFormatGetFirstFieldByUsersTable();
|
||||
|
||||
if (!is_null($sortField) && trim($sortField) != '') {
|
||||
$sortField = strtoupper($sortField);
|
||||
|
||||
if (in_array(\UsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
|
||||
$sortField = \UsersPeer::TABLE_NAME . '.' . $sortField;
|
||||
if (in_array(UsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
|
||||
$sortField = UsersPeer::TABLE_NAME . '.' . $sortField;
|
||||
} else {
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
@@ -406,8 +400,8 @@ class Department
|
||||
$criteria->setLimit((int)($limit));
|
||||
}
|
||||
|
||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria = UsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
@@ -431,7 +425,7 @@ class Department
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -440,9 +434,6 @@ class Department
|
||||
* Put Set Manager User
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setManagerUser($dep_uid, $usr_uid)
|
||||
@@ -450,23 +441,23 @@ class Department
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
$usr_uid = Validator::usrUid($usr_uid);
|
||||
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( DepartmentPeer::DEP_UID );
|
||||
$oCriteria->add( DepartmentPeer::DEP_MANAGER, $usr_uid, \Criteria::EQUAL );
|
||||
$oCriteria->add( DepartmentPeer::DEP_MANAGER, $usr_uid, Criteria::EQUAL );
|
||||
|
||||
$oDataset = DepartmentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
if ($oDataset->next()) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_MANAGER_EXIST", array('usr_uid',$usr_uid))));
|
||||
throw (new Exception(G::LoadTranslation("ID_DEPARTMENT_MANAGER_EXIST", array('usr_uid',$usr_uid))));
|
||||
}
|
||||
|
||||
$editDepartment['DEP_UID'] = $dep_uid;
|
||||
$editDepartment['DEP_MANAGER'] = $usr_uid;
|
||||
$oDept = new \Department();
|
||||
$oDept = new DepartmentModel();
|
||||
$oDept->update( $editDepartment );
|
||||
$oDept->updateDepartmentManager( $dep_uid );
|
||||
|
||||
$oDept = new \Department();
|
||||
$oDept = new DepartmentModel();
|
||||
$oDept->Load($dep_uid);
|
||||
$oDept->addUserToDepartment($dep_uid, $usr_uid, ($oDept->getDepManager() == "")? true : false, false);
|
||||
$oDept->updateDepartmentManager($dep_uid);
|
||||
@@ -474,22 +465,19 @@ class Department
|
||||
|
||||
/**
|
||||
* Get list for Departments
|
||||
*
|
||||
* @var string $dep_uid. Uid for Department
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDepartment($dep_uid)
|
||||
{
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
$criteria = new \Criteria( 'workflow' );
|
||||
$criteria->add( DepartmentPeer::DEP_UID, $dep_uid, \Criteria::EQUAL );
|
||||
$con = \Propel::getConnection( DepartmentPeer::DATABASE_NAME );
|
||||
$criteria = new Criteria( 'workflow' );
|
||||
$criteria->add( DepartmentPeer::DEP_UID, $dep_uid, Criteria::EQUAL );
|
||||
$con = Propel::getConnection( DepartmentPeer::DATABASE_NAME );
|
||||
$objects = DepartmentPeer::doSelect( $criteria, $con );
|
||||
$oUsers = new \Users();
|
||||
$oUsers = new Users();
|
||||
|
||||
$node = array ();
|
||||
foreach ($objects as $oDepartment) {
|
||||
@@ -513,14 +501,14 @@ class Department
|
||||
$node['DEP_MANAGER_LASTNAME'] = '';
|
||||
}
|
||||
|
||||
$criteria = new \Criteria();
|
||||
$criteria->add(UsersPeer::DEP_UID, $dep_uid, \Criteria::EQUAL );
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(UsersPeer::DEP_UID, $dep_uid, Criteria::EQUAL );
|
||||
$node['DEP_MEMBERS'] = UsersPeer::doCount($criteria);
|
||||
|
||||
$criteriaCount = new \Criteria( 'workflow' );
|
||||
$criteriaCount = new Criteria( 'workflow' );
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addSelectColumn( 'COUNT(*)' );
|
||||
$criteriaCount->add( DepartmentPeer::DEP_PARENT, $oDepartment->getDepUid(), \Criteria::EQUAL );
|
||||
$criteriaCount->add( DepartmentPeer::DEP_PARENT, $oDepartment->getDepUid(), Criteria::EQUAL );
|
||||
$rs = DepartmentPeer::doSelectRS( $criteriaCount );
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
@@ -532,13 +520,10 @@ class Department
|
||||
|
||||
/**
|
||||
* Save Department
|
||||
*
|
||||
* @var string $dep_data. Data for Process
|
||||
* @var string $create. Flag for create or update
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function saveDepartment($dep_data, $create = true)
|
||||
@@ -553,7 +538,7 @@ class Department
|
||||
unset($dep_data["DEP_UID"]);
|
||||
}
|
||||
|
||||
$oDepartment = new \Department();
|
||||
$oDepartment = new DepartmentModel();
|
||||
if (isset($dep_data['DEP_UID']) && $dep_data['DEP_UID'] != '') {
|
||||
Validator::depUid($dep_data['DEP_UID']);
|
||||
}
|
||||
@@ -580,7 +565,7 @@ class Department
|
||||
if (isset($dep_data['DEP_TITLE'])) {
|
||||
$this->throwExceptionIfExistsTitle($dep_data["DEP_TITLE"], strtolower("DEP_TITLE"));
|
||||
} else {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))));
|
||||
throw (new Exception(G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))));
|
||||
}
|
||||
|
||||
$dep_uid = $oDepartment->create($dep_data);
|
||||
@@ -594,41 +579,35 @@ class Department
|
||||
* @var string $dep_uid. Uid for department
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function deleteDepartment($dep_uid)
|
||||
{
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
$oDepartment = new \Department();
|
||||
$oDepartment = new DepartmentModel();
|
||||
$countUsers = $oDepartment->cantUsersInDepartment($dep_uid);
|
||||
if ($countUsers != 0) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_USERS")));
|
||||
throw (new Exception(G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_USERS")));
|
||||
}
|
||||
$dep_data = $this->getDepartment($dep_uid);
|
||||
if ($dep_data['has_children'] != 0) {
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_CHILDREN")));
|
||||
throw (new Exception(G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_CHILDREN")));
|
||||
}
|
||||
$oDepartment->remove($dep_uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for Children for department
|
||||
*
|
||||
* @var array $dataDep. Data for child department
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getChildren ($dataDep)
|
||||
{
|
||||
$children = array();
|
||||
if ((int)$dataDep['HAS_CHILDREN'] > 0) {
|
||||
$oDepartment = new \Department();
|
||||
$oDepartment = new DepartmentModel();
|
||||
$aDepts = $oDepartment->getDepartments($dataDep['DEP_UID']);
|
||||
foreach ($aDepts as &$depData) {
|
||||
$depData['DEP_CHILDREN'] = $this->getChildren($depData);
|
||||
@@ -639,4 +618,3 @@ class Department
|
||||
return $children;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Role;
|
||||
|
||||
use Configurations;
|
||||
use Criteria;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\Process;
|
||||
use ProcessMaker\BusinessModel\Role;
|
||||
use ProcessMaker\BusinessModel\Validator;
|
||||
use RBAC;
|
||||
use RbacUsersPeer;
|
||||
use ResultSet;
|
||||
use Roles;
|
||||
use UsersRolesPeer;
|
||||
|
||||
class User
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
@@ -19,7 +32,7 @@ class User
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -27,7 +40,7 @@ class User
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +49,7 @@ class User
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
@@ -45,7 +57,7 @@ class User
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +66,7 @@ class User
|
||||
* Set exception messages for fields
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
@@ -63,7 +74,7 @@ class User
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -72,14 +83,13 @@ class User
|
||||
* Get the name of the field according to the format
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
* @return string Return the field name according the format
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -90,18 +100,17 @@ class User
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if it's assigned the User to Role
|
||||
* @return void Throw exception if it's assigned the User to Role
|
||||
*/
|
||||
public function throwExceptionIfItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
$obj = UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
|
||||
if (!is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_ALREADY_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
throw new Exception(G::LoadTranslation("ID_ROLE_USER_IS_ALREADY_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -112,18 +121,17 @@ class User
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if not it's assigned the User to Role
|
||||
* @return void Throw exception if not it's assigned the User to Role
|
||||
*/
|
||||
public function throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
$obj = UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_NOT_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
throw new Exception(G::LoadTranslation("ID_ROLE_USER_IS_NOT_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -133,15 +141,14 @@ class User
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the User assigned to Role
|
||||
* @return array Return data of the User assigned to Role
|
||||
*/
|
||||
public function create($roleUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
$process = new Process();
|
||||
$validator = new Validator();
|
||||
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
|
||||
@@ -151,7 +158,7 @@ class User
|
||||
unset($arrayData["ROL_UID"]);
|
||||
|
||||
//Verify data
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
$role = new Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
@@ -162,11 +169,11 @@ class User
|
||||
$this->throwExceptionIfItsAssignedUserToRole($roleUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
if ($arrayData["USR_UID"] == "00000000000000000000000000000001") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
throw new Exception(G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
}
|
||||
|
||||
//Create
|
||||
$role = new \Roles();
|
||||
$role = new Roles();
|
||||
|
||||
$arrayData = array_merge(array("ROL_UID" => $roleUid), $arrayData);
|
||||
|
||||
@@ -178,7 +185,7 @@ class User
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -188,15 +195,14 @@ class User
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete($roleUid, $userUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
$process = new Process();
|
||||
$role = new Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
@@ -205,14 +211,14 @@ class User
|
||||
$this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
if ($userUid == "00000000000000000000000000000001") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
throw new Exception(G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
}
|
||||
|
||||
//Delete
|
||||
$role = new \Roles();
|
||||
$role = new Roles();
|
||||
|
||||
$role->deleteUserRole($roleUid, $userUid);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -221,8 +227,7 @@ class User
|
||||
* Get data of a User from a record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data User
|
||||
* @return array Return an array with data User
|
||||
*/
|
||||
public function getUserDataFromRecord(array $record)
|
||||
{
|
||||
@@ -234,7 +239,7 @@ class User
|
||||
$this->getFieldNameByFormatFieldName("USR_LASTNAME") => $record["USR_LASTNAME"] . "",
|
||||
$this->getFieldNameByFormatFieldName("USR_STATUS") => ($record["USR_STATUS"] . "" == "1")? "ACTIVE" : "INACTIVE"
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -249,8 +254,7 @@ class User
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* return array Return an array with all Users of a Role
|
||||
* @return array Return an array with all Users of a Role
|
||||
*/
|
||||
public function getUsers($roleUid, $option, array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
{
|
||||
@@ -262,8 +266,8 @@ class User
|
||||
//Verify data and Set variables
|
||||
$flagFilter = !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']);
|
||||
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
$process = new Process();
|
||||
$role = new Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
@@ -303,24 +307,25 @@ class User
|
||||
}
|
||||
|
||||
//Query
|
||||
$criteria = new \Criteria('rbac');
|
||||
$criteria = new Criteria('rbac');
|
||||
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_LASTNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_STATUS);
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_LASTNAME);
|
||||
$criteria->addSelectColumn(RbacUsersPeer::USR_STATUS);
|
||||
|
||||
$criteria->addJoin(\RbacUsersPeer::USR_UID, \UsersRolesPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||
$criteria->addJoin(RbacUsersPeer::USR_UID, UsersRolesPeer::USR_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
$criteria->add(\RbacUsersPeer::USR_USERNAME, '', \Criteria::NOT_EQUAL);
|
||||
$criteria->add(RbacUsersPeer::USR_USERNAME, '', Criteria::NOT_EQUAL);
|
||||
|
||||
switch ($option) {
|
||||
case "USERS":
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
|
||||
$criteria->add(UsersRolesPeer::ROL_UID, $roleUid, Criteria::EQUAL);
|
||||
break;
|
||||
case "AVAILABLE-USERS":
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::NOT_EQUAL);
|
||||
$criteria->add(UsersRolesPeer::ROL_UID, $roleUid, Criteria::NOT_EQUAL);
|
||||
$criteria->add(RbacUsersPeer::USR_UID, [RBAC::GUEST_USER_UID], Criteria::NOT_IN);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -336,24 +341,24 @@ class User
|
||||
];
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_USERNAME, $search, \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_FIRSTNAME, $search, \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_LASTNAME, $search, \Criteria::LIKE)))
|
||||
$criteria->getNewCriterion(RbacUsersPeer::USR_USERNAME, $search, Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(RbacUsersPeer::USR_FIRSTNAME, $search, Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(RbacUsersPeer::USR_LASTNAME, $search, Criteria::LIKE)))
|
||||
);
|
||||
}
|
||||
|
||||
//Number records total
|
||||
$numRecTotal = \RbacUsersPeer::doCount($criteria);
|
||||
$numRecTotal = RbacUsersPeer::doCount($criteria);
|
||||
|
||||
//Query
|
||||
$conf = new \Configurations();
|
||||
$sortFieldDefault = \RbacUsersPeer::TABLE_NAME . '.' . $conf->userNameFormatGetFirstFieldByUsersTable();
|
||||
$conf = new Configurations();
|
||||
$sortFieldDefault = RbacUsersPeer::TABLE_NAME . '.' . $conf->userNameFormatGetFirstFieldByUsersTable();
|
||||
|
||||
if (!is_null($sortField) && trim($sortField) != '') {
|
||||
$sortField = strtoupper($sortField);
|
||||
|
||||
if (in_array(\RbacUsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
|
||||
$sortField = \RbacUsersPeer::TABLE_NAME . '.' . $sortField;
|
||||
if (in_array(RbacUsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
|
||||
$sortField = RbacUsersPeer::TABLE_NAME . '.' . $sortField;
|
||||
} else {
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
@@ -375,8 +380,8 @@ class User
|
||||
$criteria->setLimit((int)($limit));
|
||||
}
|
||||
|
||||
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria = RbacUsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
@@ -392,7 +397,7 @@ class User
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@ class User
|
||||
'PREF_DEFAULT_CASES_MENUSELECTED' => 'PM_EDIT_USER_PROFILE_DEFAULT_CASES_MENU_OPTIONS'
|
||||
);
|
||||
|
||||
private $guestUser = RBAC::GUEST_USER_UID;
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*/
|
||||
@@ -124,6 +126,16 @@ class User
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the guest user defined
|
||||
*
|
||||
* @return string guestUser, uid related to this user
|
||||
*/
|
||||
public function getGuestUser()
|
||||
{
|
||||
return $this->guestUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -640,6 +652,10 @@ class User
|
||||
{
|
||||
try {
|
||||
|
||||
//check user guest
|
||||
if (RBAC::isGuestUserUid($userUid)) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($userUid)));
|
||||
}
|
||||
|
||||
//Verify data
|
||||
$validator = new Validator();
|
||||
@@ -1078,6 +1094,12 @@ class User
|
||||
$history += ApplicationPeer::doCount($c);
|
||||
$c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);
|
||||
$history += ApplicationPeer::doCount($c);
|
||||
|
||||
//check user guest
|
||||
if (RBAC::isGuestUserUid($usrUid)) {
|
||||
throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", array($USR_UID)));
|
||||
}
|
||||
|
||||
if ($total > 0) {
|
||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID)));
|
||||
} else {
|
||||
@@ -1182,6 +1204,9 @@ class User
|
||||
//Query
|
||||
$criteria = $this->getUserCriteria();
|
||||
|
||||
//Remove the guest user
|
||||
$criteria->add(UsersPeer::USR_UID, RBAC::GUEST_USER_UID, Criteria::NOT_EQUAL);
|
||||
|
||||
if ($flagCondition && !empty($arrayWhere['condition'])) {
|
||||
foreach ($arrayWhere['condition'] as $value) {
|
||||
$criteria->add($value[0], $value[1], $value[2]);
|
||||
@@ -1556,6 +1581,9 @@ class User
|
||||
}
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
|
||||
|
||||
//Remove the guest user
|
||||
$oCriteria->add(UsersPeer::USR_UID, RBAC::GUEST_USER_UID, Criteria::NOT_EQUAL);
|
||||
|
||||
if ($authSource != '') {
|
||||
$totalRows = sizeof($aUsers);
|
||||
} else {
|
||||
@@ -1583,6 +1611,10 @@ class User
|
||||
$oCriteria->addAsColumn('DUE_DATE_OK', 1);
|
||||
$sep = "'";
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
|
||||
|
||||
//Remove the guest user
|
||||
$oCriteria->add(UsersPeer::USR_UID, RBAC::GUEST_USER_UID, Criteria::NOT_EQUAL);
|
||||
|
||||
if ($filter != '') {
|
||||
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)
|
||||
|
||||
@@ -9,6 +9,23 @@ use WebEntryPeer;
|
||||
use Exception;
|
||||
use G;
|
||||
use BpmnFlowPeer;
|
||||
use ProcessMaker\BusinessModel\Process as BusinessModelProcess;
|
||||
use ProcessMaker\BusinessModel\Validator as BusinessModelValidator;
|
||||
use ProcessMaker\Project\Workflow;
|
||||
use WebEntryEvent as ModelWebEntryEvent;
|
||||
use ProcessMaker\Util\Common;
|
||||
use Task as ModelTask;
|
||||
use Propel;
|
||||
use BasePeer;
|
||||
use Content;
|
||||
use Tasks;
|
||||
use Step;
|
||||
use TaskPeer;
|
||||
use StepPeer;
|
||||
use ResultSet;
|
||||
use TaskUser;
|
||||
use TaskUserPeer;
|
||||
|
||||
|
||||
class WebEntryEvent
|
||||
{
|
||||
@@ -358,13 +375,7 @@ class WebEntryEvent
|
||||
|
||||
$arrayFinalData = array_merge($arrayWebEntryEventData, $arrayData);
|
||||
|
||||
//Verify data - Field definition
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
//Dependent fields:
|
||||
if (!isset($arrayData['WE_AUTHENTICATION']) || $arrayData['WE_AUTHENTICATION']
|
||||
== 'ANONYMOUS') {
|
||||
$this->arrayFieldDefinition['USR_UID']['required'] = true;
|
||||
}
|
||||
//Define the required dependent fields:
|
||||
if (!isset($arrayData['WE_TYPE']) || $arrayData['WE_TYPE']
|
||||
== 'SINGLE') {
|
||||
$this->arrayFieldDefinition['DYN_UID']['required'] = true;
|
||||
@@ -391,6 +402,7 @@ class WebEntryEvent
|
||||
$this->arrayFieldDefinition['WE_LINK_LANGUAGE']['defaultValues'] = $languages;
|
||||
}
|
||||
|
||||
$process = new BusinessModelProcess();
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition,
|
||||
$this->arrayFieldNameForException, $flagInsert);
|
||||
|
||||
@@ -513,11 +525,11 @@ class WebEntryEvent
|
||||
$arrayEventData = $bpmn->getEvent($eventUid);
|
||||
|
||||
//Task
|
||||
$task = new \Task();
|
||||
$task = new ModelTask();
|
||||
|
||||
$tasUid = static::getTaskUidFromEvnUid($eventUid);
|
||||
|
||||
if (\TaskPeer::retrieveByPK($tasUid)) {
|
||||
if (TaskPeer::retrieveByPK($tasUid)) {
|
||||
$this->webEntryEventWebEntryTaskUid = $tasUid;
|
||||
} else {
|
||||
$this->webEntryEventWebEntryTaskUid = $task->create(
|
||||
@@ -535,7 +547,7 @@ class WebEntryEvent
|
||||
|
||||
if (!isset($arrayData['WE_TYPE']) || $arrayData['WE_TYPE'] === 'SINGLE') {
|
||||
//Task - Step
|
||||
$step = new \Step();
|
||||
$step = new Step();
|
||||
|
||||
$stepUid = $step->create(array(
|
||||
"PRO_UID" => $projectUid,
|
||||
@@ -553,13 +565,13 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
//Task - User
|
||||
$task = new \Tasks();
|
||||
$task = new Tasks();
|
||||
if (!(isset($arrayData['WE_AUTHENTICATION']) && $arrayData['WE_AUTHENTICATION'] === 'LOGIN_REQUIRED')) {
|
||||
$task->assignUser($this->webEntryEventWebEntryTaskUid, $userUid, 1);
|
||||
}
|
||||
|
||||
//Route
|
||||
$workflow = \ProcessMaker\Project\Workflow::load($projectUid);
|
||||
$workflow = Workflow::load($projectUid);
|
||||
|
||||
$result = $workflow->addRoute($this->webEntryEventWebEntryTaskUid, $activityUid, "SEQUENTIAL");
|
||||
|
||||
@@ -622,10 +634,10 @@ class WebEntryEvent
|
||||
{
|
||||
try {
|
||||
if ($webEntryTaskUid != "") {
|
||||
$obj = \TaskPeer::retrieveByPK($webEntryTaskUid);
|
||||
$obj = TaskPeer::retrieveByPK($webEntryTaskUid);
|
||||
|
||||
if (!is_null($obj)) {
|
||||
$task = new \Tasks();
|
||||
$task = new Tasks();
|
||||
|
||||
$task->deleteTask($webEntryTaskUid);
|
||||
}
|
||||
@@ -657,8 +669,8 @@ class WebEntryEvent
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
$process = new BusinessModelProcess();
|
||||
$validator = new BusinessModelValidator();
|
||||
|
||||
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
@@ -693,17 +705,19 @@ class WebEntryEvent
|
||||
$arrayData["WEE_TITLE"] = null;
|
||||
}
|
||||
|
||||
//Verify data
|
||||
//Verify data related to the process
|
||||
$process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]);
|
||||
|
||||
//Define if the webEntry need to use the guest user
|
||||
$weUserUid = isset($arrayData["USR_UID"]) ? $arrayData["USR_UID"] : '';
|
||||
$weAuthentication = isset($arrayData["WE_AUTHENTICATION"]) ? $arrayData["WE_AUTHENTICATION"] : '';
|
||||
$arrayData["USR_UID"] = $this->getWebEntryUser($weAuthentication, $weUserUid);
|
||||
//Verify data with the required fields
|
||||
$this->throwExceptionIfDataIsInvalid("", $projectUid, $arrayData);
|
||||
|
||||
//Create
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
|
||||
$this->webEntryEventWebEntryUid = "";
|
||||
$this->webEntryEventWebEntryTaskUid = "";
|
||||
|
||||
//Create the connection
|
||||
$cnn = Propel::getConnection("workflow");
|
||||
try {
|
||||
//WebEntry
|
||||
$this->createWebEntry(
|
||||
@@ -719,11 +733,11 @@ class WebEntryEvent
|
||||
);
|
||||
|
||||
//WebEntry-Event
|
||||
$webEntryEvent = new \WebEntryEvent();
|
||||
$webEntryEvent = new ModelWebEntryEvent();
|
||||
|
||||
$webEntryEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
||||
$webEntryEvent->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
$webEntryEventUid = \ProcessMaker\Util\Common::generateUID();
|
||||
$webEntryEventUid = Common::generateUID();
|
||||
|
||||
$webEntryEvent->setWeeUid($webEntryEventUid);
|
||||
$webEntryEvent->setPrjUid($projectUid);
|
||||
@@ -739,13 +753,13 @@ class WebEntryEvent
|
||||
|
||||
//Set WEE_TITLE
|
||||
if (isset($arrayData["WEE_TITLE"])) {
|
||||
$result = \Content::addContent("WEE_TITLE", "", $webEntryEventUid, SYS_LANG,
|
||||
$result = Content::addContent("WEE_TITLE", "", $webEntryEventUid, SYS_LANG,
|
||||
$arrayData["WEE_TITLE"]);
|
||||
}
|
||||
|
||||
//Set WEE_DESCRIPTION
|
||||
if (isset($arrayData["WEE_DESCRIPTION"])) {
|
||||
$result = \Content::addContent("WEE_DESCRIPTION", "", $webEntryEventUid, SYS_LANG,
|
||||
$result = Content::addContent("WEE_DESCRIPTION", "", $webEntryEventUid, SYS_LANG,
|
||||
$arrayData["WEE_DESCRIPTION"]);
|
||||
}
|
||||
|
||||
@@ -782,12 +796,12 @@ class WebEntryEvent
|
||||
* @return array Return data of the WebEntry-Event updated
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update($webEntryEventUid, $userUidUpdater, array $arrayData)
|
||||
public function update($webEntryEventUid, $userUidUpdater, array $arrayData, $updateUser = true)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
$process = new BusinessModelProcess();
|
||||
$validator = new BusinessModelValidator();
|
||||
|
||||
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
@@ -806,14 +820,20 @@ class WebEntryEvent
|
||||
|
||||
$arrayFinalData = array_merge($arrayWebEntryEventData, $arrayData);
|
||||
|
||||
//Verify data
|
||||
//Verify data related to the process
|
||||
$this->throwExceptionIfNotExistsWebEntryEvent($webEntryEventUid,
|
||||
$this->arrayFieldNameForException["webEntryEventUid"]);
|
||||
|
||||
//Define if the webEntry need to use the guest user
|
||||
$weUserUid = isset($arrayData["USR_UID"]) ? $arrayData["USR_UID"] : '';
|
||||
$weAuthentication = isset($arrayData["WE_AUTHENTICATION"]) ? $arrayData["WE_AUTHENTICATION"] : '';
|
||||
if ($updateUser) {
|
||||
$arrayData["USR_UID"] = $this->getWebEntryUser($weAuthentication, $weUserUid);
|
||||
}
|
||||
//Verify data with the required fields
|
||||
$this->throwExceptionIfDataIsInvalid($webEntryEventUid, $arrayWebEntryEventData["PRJ_UID"], $arrayData);
|
||||
|
||||
//Update
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
$cnn = Propel::getConnection("workflow");
|
||||
|
||||
$this->webEntryEventWebEntryUid = "";
|
||||
$this->webEntryEventWebEntryTaskUid = "";
|
||||
@@ -821,20 +841,20 @@ class WebEntryEvent
|
||||
try {
|
||||
//WebEntry
|
||||
if ($arrayWebEntryEventData["WEE_WE_UID"] != "") {
|
||||
$task = new \Tasks();
|
||||
$task = new Tasks();
|
||||
|
||||
//Task - Step for WE_TYPE=SINGLE
|
||||
$weType = !empty($arrayData["WE_TYPE"]) ? $arrayData["WE_TYPE"] : $arrayWebEntryEventData["WE_TYPE"];
|
||||
if (isset($arrayData["DYN_UID"]) && $arrayData["DYN_UID"] !== $arrayWebEntryEventData["DYN_UID"] && $weType === 'SINGLE') {
|
||||
//Delete
|
||||
$step = new \Step();
|
||||
$step = new Step();
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->add(\StepPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
$criteria->add(StepPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
|
||||
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria = StepPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
@@ -843,7 +863,7 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
//Add
|
||||
$step = new \Step();
|
||||
$step = new Step();
|
||||
|
||||
$stepUid = $step->create(array(
|
||||
"PRO_UID" => $arrayWebEntryEventData["PRJ_UID"],
|
||||
@@ -859,16 +879,21 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
//Task - User
|
||||
if (!empty($arrayData["USR_UID"]) && $arrayData["USR_UID"] != $arrayWebEntryEventData["USR_UID"]) {
|
||||
$proUser = new ProjectUser();
|
||||
$newUser = !empty($arrayData["USR_UID"]) ? $arrayData["USR_UID"] : "";
|
||||
$oldUser = $arrayWebEntryEventData["USR_UID"];
|
||||
$isAssigned = $proUser->userIsAssignedToTask($newUser, $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
$shouldUpdate = !empty($newUser) && ($newUser !== $oldUser || !$isAssigned);
|
||||
if ($shouldUpdate) {
|
||||
//Unassign
|
||||
$taskUser = new \TaskUser();
|
||||
$taskUser = new TaskUser();
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->add(\TaskUserPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
$criteria->add(TaskUserPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]);
|
||||
|
||||
$rsCriteria = \TaskUserPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria = TaskUserPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
@@ -878,8 +903,11 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
//Assign
|
||||
$result = $task->assignUser($arrayWebEntryEventData["WEE_WE_TAS_UID"], $arrayData["USR_UID"],
|
||||
1);
|
||||
$result = $task->assignUser(
|
||||
$arrayWebEntryEventData["WEE_WE_TAS_UID"],
|
||||
$arrayData["USR_UID"],
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
//Route
|
||||
@@ -892,7 +920,7 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
//Add
|
||||
$workflow = \ProcessMaker\Project\Workflow::load($arrayWebEntryEventData["PRJ_UID"]);
|
||||
$workflow = Workflow::load($arrayWebEntryEventData["PRJ_UID"]);
|
||||
|
||||
$result = $workflow->addRoute($arrayWebEntryEventData["WEE_WE_TAS_UID"], $arrayData["ACT_UID"],
|
||||
"SEQUENTIAL");
|
||||
@@ -925,15 +953,18 @@ class WebEntryEvent
|
||||
}
|
||||
|
||||
if (count($arrayDataAux) > 0) {
|
||||
$arrayDataAux = $this->webEntry->update($arrayWebEntryEventData["WEE_WE_UID"], $userUidUpdater,
|
||||
$arrayDataAux);
|
||||
$arrayDataAux = $this->webEntry->update(
|
||||
$arrayWebEntryEventData["WEE_WE_UID"],
|
||||
$userUidUpdater,
|
||||
$arrayDataAux
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//WebEntry-Event
|
||||
$webEntryEvent = WebEntryEventPeer::retrieveByPK($webEntryEventUid);
|
||||
|
||||
$webEntryEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
||||
$webEntryEvent->fromArray($arrayData, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($webEntryEvent->validate()) {
|
||||
$cnn->begin();
|
||||
@@ -944,13 +975,13 @@ class WebEntryEvent
|
||||
|
||||
//Set WEE_TITLE
|
||||
if (isset($arrayData["WEE_TITLE"])) {
|
||||
$result = \Content::addContent("WEE_TITLE", "", $webEntryEventUid, SYS_LANG,
|
||||
$result = Content::addContent("WEE_TITLE", "", $webEntryEventUid, SYS_LANG,
|
||||
$arrayData["WEE_TITLE"]);
|
||||
}
|
||||
|
||||
//Set WEE_DESCRIPTION
|
||||
if (isset($arrayData["WEE_DESCRIPTION"])) {
|
||||
$result = \Content::addContent("WEE_DESCRIPTION", "", $webEntryEventUid, SYS_LANG,
|
||||
$result = Content::addContent("WEE_DESCRIPTION", "", $webEntryEventUid, SYS_LANG,
|
||||
$arrayData["WEE_DESCRIPTION"]);
|
||||
}
|
||||
|
||||
@@ -1123,7 +1154,7 @@ class WebEntryEvent
|
||||
$arrayWebEntryEvent = array();
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new BusinessModelProcess();
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]);
|
||||
|
||||
@@ -1133,7 +1164,7 @@ class WebEntryEvent
|
||||
$criteria->add(WebEntryEventPeer::PRJ_UID, $projectUid, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = WebEntryEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
@@ -1174,7 +1205,7 @@ class WebEntryEvent
|
||||
}
|
||||
$criteria->add(ProcessPeer::PRO_STATUS, 'ACTIVE', Criteria::EQUAL);
|
||||
$rsCriteria = WebEntryEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
$result[] = $this->getWebEntryEventDataFromRecord($row);
|
||||
@@ -1208,7 +1239,7 @@ class WebEntryEvent
|
||||
$criteria->add(WebEntryEventPeer::WEE_UID, $webEntryEventUid, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = WebEntryEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rsCriteria->next();
|
||||
|
||||
@@ -1235,7 +1266,7 @@ class WebEntryEvent
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process = new BusinessModelProcess();
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]);
|
||||
|
||||
@@ -1251,7 +1282,7 @@ class WebEntryEvent
|
||||
$criteria->add(WebEntryEventPeer::EVN_UID, $eventUid, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = WebEntryEventPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rsCriteria->next();
|
||||
|
||||
@@ -1361,4 +1392,22 @@ class WebEntryEvent
|
||||
return $url . "/" . $weData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function return the uid of user related to the webEntry
|
||||
* @param string $authentication, can be ANONYMOUS, LOGIN_REQUIRED
|
||||
* @param string $usrUid
|
||||
* @return string
|
||||
*/
|
||||
public function getWebEntryUser($authentication = 'ANONYMOUS', $usrUid = '')
|
||||
{
|
||||
//The webEntry old does not have type of authentication defined
|
||||
//The webEntry2.0 can be has values ANONYMOUS or LOGIN_REQUIRED
|
||||
if ($authentication === 'ANONYMOUS' || empty($authentication)) {
|
||||
$user = new User();
|
||||
return $user->getGuestUser();
|
||||
} else {
|
||||
return $usrUid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2086,7 +2086,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$arrayResult = $webEntryEvent->update(
|
||||
$arrayWebEntryEventData['WEE_UID'],
|
||||
$bpmnProject->getPrjAuthor(),
|
||||
(!is_null($arrayData))? $arrayData : $arrayWebEntryEventData
|
||||
(!is_null($arrayData))? $arrayData : $arrayWebEntryEventData,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user