Merged in develop (pull request #5762)
Develop Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
@@ -560,7 +560,14 @@ switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) {
|
||||
$oCase = new Cases();
|
||||
$aProcesses = Array();
|
||||
$G_PUBLISH = new Publisher();
|
||||
$criteria = $oCase->getAllUploadedDocumentsCriteria($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['CURRENT_TASK'], $_SESSION['USER_LOGGED'], $_SESSION['INDEX']);
|
||||
$tasUid = isset($_SESSION['CURRENT_TASK']) ? $_SESSION['CURRENT_TASK'] : $_SESSION['TASK'];
|
||||
$criteria = $oCase->getAllUploadedDocumentsCriteria(
|
||||
$_SESSION['PROCESS'],
|
||||
$_SESSION['APPLICATION'],
|
||||
$tasUid,
|
||||
$_SESSION['USER_LOGGED'],
|
||||
$_SESSION['INDEX']
|
||||
);
|
||||
if ($criteria->getDbName() == 'dbarray') {
|
||||
$rs = ArrayBasePeer::doSelectRs($criteria);
|
||||
} else {
|
||||
@@ -601,8 +608,14 @@ switch (($_POST['action']) ? $_POST['action'] : $_REQUEST['action']) {
|
||||
$oCase = new Cases();
|
||||
$aProcesses = Array ();
|
||||
$G_PUBLISH = new Publisher();
|
||||
$c = $oCase->getAllGeneratedDocumentsCriteria($_SESSION['PROCESS'], $_SESSION['APPLICATION'],
|
||||
$_SESSION['CURRENT_TASK'], $_SESSION['USER_LOGGED'], $_SESSION['INDEX']);
|
||||
$tasUid = isset($_SESSION['CURRENT_TASK']) ? $_SESSION['CURRENT_TASK'] : $_SESSION['TASK'];
|
||||
$c = $oCase->getAllGeneratedDocumentsCriteria(
|
||||
$_SESSION['PROCESS'],
|
||||
$_SESSION['APPLICATION'],
|
||||
$tasUid,
|
||||
$_SESSION['USER_LOGGED'],
|
||||
$_SESSION['INDEX']
|
||||
);
|
||||
|
||||
if ($c->getDbName() == 'dbarray') {
|
||||
$rs = ArrayBasePeer::doSelectRs( $c );
|
||||
|
||||
@@ -125,7 +125,7 @@ switch ($_POST['action']) {
|
||||
$result->success = true;
|
||||
$result->groups = $arrData;
|
||||
$result->total_groups = $data['totalCount'];
|
||||
|
||||
G::header('Content-Type: application/json');
|
||||
echo G::json_encode( $result );
|
||||
break;
|
||||
case 'exitsGroupName':
|
||||
@@ -253,6 +253,7 @@ switch ($_POST['action']) {
|
||||
while ($oDataset->next()) {
|
||||
$arrData[] = $oDataset->getRow();
|
||||
}
|
||||
G::header('Content-Type: application/json');
|
||||
echo '{success: true, members: ' . G::json_encode( $arrData ) . ', total_users: ' . $totalRows . '}';
|
||||
break;
|
||||
case 'availableMembers':
|
||||
@@ -311,6 +312,7 @@ switch ($_POST['action']) {
|
||||
while ($oDataset->next()) {
|
||||
$arrData[] = $oDataset->getRow();
|
||||
}
|
||||
G::header('Content-Type: application/json');
|
||||
echo '{success: true, members: ' . G::json_encode( $arrData ) . ', total_users: ' . $totalRows . '}';
|
||||
break;
|
||||
case 'assignUsersToGroupsMultiple':
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* processes_DownloadFile.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->allows(basename(__FILE__), 'downloadFileHash');
|
||||
|
||||
if (!isset($_GET["file_hash"])) {
|
||||
throw new Exception("Invalid Request, param 'file_hash' was not sent.");
|
||||
@@ -28,26 +7,16 @@ if (!isset($_GET["file_hash"])) {
|
||||
|
||||
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
||||
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
||||
$filename = urldecode(base64_decode($_GET["file_hash"]));
|
||||
$fileExtension = pathinfo($outputDir . $filename, PATHINFO_EXTENSION);
|
||||
$fileName = urldecode(base64_decode($_GET["file_hash"]));
|
||||
$processFile = $outputDir . $fileName;
|
||||
|
||||
if (!file_exists($outputDir . $filename)) {
|
||||
throw new Exception("Error, couldn't find request file: $filename");
|
||||
//Verify if the file related to process exist in the corresponding path
|
||||
$fileInformation = pathinfo($processFile);
|
||||
$processFile = $outputDir . $fileInformation['basename'];
|
||||
if (!file_exists($processFile)) {
|
||||
throw new Exception("Error, couldn't find request file: $fileName");
|
||||
}
|
||||
|
||||
$httpStream->loadFromFile($outputDir . $filename);
|
||||
$fileExtension = $fileInformation['extension'];
|
||||
$httpStream->loadFromFile($processFile);
|
||||
$httpStream->setHeader("Content-Type", "application/$fileExtension");
|
||||
$httpStream->send();
|
||||
|
||||
// ************* DEPRECATED (it will be removed soon) *********************************
|
||||
//add more security, and catch any error or exception
|
||||
//$sFileName = $_GET['p'] . '.pm';
|
||||
//$file = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName . 'tpm';
|
||||
//$filex = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
//
|
||||
//if (file_exists( $file )) {
|
||||
// rename( $file, $filex );
|
||||
//}
|
||||
//
|
||||
//$realPath = PATH_DOCUMENT . 'output' . PATH_SEP . $sFileName;
|
||||
//G::streamFile( $realPath, true );
|
||||
|
||||
@@ -39,7 +39,8 @@ try {
|
||||
if (sizeof($_GET['objects']) == 0) {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$exporter = new ProcessMaker\Exporter\XmlExporter($_GET["pro_uid"]);
|
||||
$getProjectName = $exporter->truncateName($exporter->getProjectName(), false);
|
||||
$projectName = $exporter->getProjectName();
|
||||
$getProjectName = $exporter->truncateName($projectName, false);
|
||||
|
||||
$version = ProcessMaker\Util\Common::getLastVersion($outputDir . $getProjectName . "-*.pmx") + 1;
|
||||
$outputFilename = sprintf("%s-%s.%s", str_replace(" ", "_", $getProjectName), $version, "pmx");
|
||||
@@ -48,8 +49,10 @@ try {
|
||||
}else{
|
||||
$granularExporter = new \ProcessMaker\BusinessModel\Migrator\GranularExporter($_GET['pro_uid']);
|
||||
$outputFilename = $granularExporter->export($_GET['objects']);
|
||||
$projectName = $granularExporter->getProjectName();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
G::auditLog('ExportProcess','Export process "' . $projectName . '"');
|
||||
} else {
|
||||
$oProcess = new Processes();
|
||||
$proFields = $oProcess->serializeProcess($_GET["pro_uid"]);
|
||||
@@ -57,6 +60,7 @@ try {
|
||||
$outputFilename = $result["FILENAME"];
|
||||
|
||||
rename($outputDir . $outputFilename . "tpm", $outputDir . $outputFilename);
|
||||
G::auditLog('ExportProcess','Export process "' . $result["PRO_TITLE"] . '"');
|
||||
}
|
||||
$response->file_hash = base64_encode($outputFilename);
|
||||
$response->success = true;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
<?php
|
||||
G::LoadSystem('inputfilter');
|
||||
$filter = new InputFilter();
|
||||
$_REQUEST = $filter->xssFilterHard($_REQUEST);
|
||||
|
||||
if (! isset( $_REQUEST['action'] )) {
|
||||
$res['success'] = false;
|
||||
$res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION');
|
||||
@@ -17,8 +13,7 @@ if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['ac
|
||||
print G::json_encode( $res );
|
||||
die();
|
||||
}
|
||||
$restrictedFunctions = array ('copy_skin_folder','addTarFolder'
|
||||
);
|
||||
$restrictedFunctions = array ('copy_skin_folder','addTarFolder');
|
||||
if (in_array( $_REQUEST['action'], $restrictedFunctions )) {
|
||||
$res['success'] = false;
|
||||
$res['error'] = $res['message'] = G::LoadTranslation('ID_REQUEST_ACTION_NOT_EXIST');
|
||||
@@ -28,7 +23,7 @@ if (in_array( $_REQUEST['action'], $restrictedFunctions )) {
|
||||
|
||||
$functionName = $_REQUEST['action'];
|
||||
$functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
|
||||
|
||||
$RBAC->allows(basename(__FILE__), $functionName);
|
||||
$functionName();
|
||||
|
||||
function updatePageSize ()
|
||||
@@ -166,7 +161,7 @@ function newSkin ($baseSkin = 'classic')
|
||||
$configFileFinal = PATH_CUSTOM_SKINS . $skinFolder . PATH_SEP . 'config.xml';
|
||||
|
||||
$xmlConfiguration = file_get_contents( $configFileOriginal );
|
||||
|
||||
|
||||
$workspace = ($_REQUEST['workspace'] == 'global') ? '' : SYS_SYS;
|
||||
|
||||
$xmlConfigurationObj = G::xmlParser($xmlConfiguration);
|
||||
@@ -356,9 +351,9 @@ function exportSkin ($skinToExport = "")
|
||||
$response['success'] = true;
|
||||
$response['message'] = $skinTar;
|
||||
G::auditLog("ExportSkin", "Skin Name: ".$skinName);
|
||||
|
||||
|
||||
$response = $filter->xssFilterHard($response);
|
||||
|
||||
|
||||
print_r( G::json_encode( $response ) );
|
||||
} catch (Exception $e) {
|
||||
$response['success'] = false;
|
||||
@@ -374,7 +369,7 @@ function deleteSkin ()
|
||||
$filter = new InputFilter();
|
||||
try {
|
||||
$_REQUEST['SKIN_FOLDER_ID'] = $filter->xssFilterHard($_REQUEST['SKIN_FOLDER_ID']);
|
||||
|
||||
|
||||
if (! (isset( $_REQUEST['SKIN_FOLDER_ID'] ))) {
|
||||
throw (new Exception( G::LoadTranslation( 'ID_SKIN_FOLDER_REQUIRED' ) ));
|
||||
}
|
||||
@@ -400,9 +395,9 @@ function deleteSkin ()
|
||||
|
||||
function streamSkin ()
|
||||
{
|
||||
$skinTar = $_REQUEST['file'];
|
||||
$skinTar = basename($_REQUEST['file']);
|
||||
$bDownload = true;
|
||||
G::streamFile( $skinTar, $bDownload, basename( $skinTar ) );
|
||||
G::streamFile(PATH_CUSTOM_SKINS . $skinTar, $bDownload, $skinTar);
|
||||
@unlink( $fileTar );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* users_Ajax.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.
|
||||
*/
|
||||
try {
|
||||
G::LoadSystem('inputfilter');
|
||||
$filter = new InputFilter();
|
||||
$_GET = $filter->xssFilterHard($_GET);
|
||||
$_POST = $filter->xssFilterHard($_POST);
|
||||
$_REQUEST = $filter->xssFilterHard($_REQUEST);
|
||||
|
||||
global $RBAC;
|
||||
switch ($RBAC->userCanAccess('PM_LOGIN')) {
|
||||
case - 2:
|
||||
@@ -47,38 +19,15 @@ try {
|
||||
$_POST = $_POST['form'];
|
||||
}
|
||||
if (isset($_REQUEST['function'])) {
|
||||
//$value= $_POST['function'];
|
||||
$value = get_ajax_value('function');
|
||||
} else {
|
||||
//$value= $_POST['functions'];
|
||||
$value = get_ajax_value('functions');
|
||||
}
|
||||
|
||||
$RBAC->allows(basename(__FILE__), $value);
|
||||
switch ($value) {
|
||||
case 'verifyUsername':
|
||||
//print_r($_POST); die;
|
||||
$_POST['sOriginalUsername'] = get_ajax_value('sOriginalUsername');
|
||||
$_POST['sUsername'] = get_ajax_value('sUsername');
|
||||
if ($_POST['sOriginalUsername'] == $_POST['sUsername']) {
|
||||
echo '0';
|
||||
} else {
|
||||
require_once 'classes/model/Users.php';
|
||||
G::LoadClass('Users');
|
||||
$oUser = new Users();
|
||||
$oCriteria = $oUser->loadByUsername($_POST['sUsername']);
|
||||
$oDataset = UsersPeer::doSelectRs($oCriteria, Propel::getDbConnection('workflow_ro'));
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$aRow = $oDataset->getRow();
|
||||
//print_r($aRow); die;
|
||||
//if (!$aRow)
|
||||
if (!is_array($aRow)) {
|
||||
echo '0';
|
||||
} else {
|
||||
echo '1';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'availableUsers':
|
||||
//Classic process: list of users to assign in the task
|
||||
G::LoadClass('processMap');
|
||||
$oProcessMap = new ProcessMap();
|
||||
global $G_PUBLISH;
|
||||
@@ -87,6 +36,7 @@ try {
|
||||
G::RenderPage('publish', 'raw');
|
||||
break;
|
||||
case 'assign':
|
||||
//Classic process: assign users and groups in the task
|
||||
G::LoadClass('tasks');
|
||||
$oTasks = new Tasks();
|
||||
switch ((int) $_POST['TU_RELATION']) {
|
||||
@@ -103,6 +53,7 @@ try {
|
||||
}
|
||||
break;
|
||||
case 'ofToAssign':
|
||||
//Classic process: remove users and groups related a task
|
||||
G::LoadClass('tasks');
|
||||
$oTasks = new Tasks();
|
||||
switch ((int) $_POST['TU_RELATION']) {
|
||||
@@ -117,36 +68,11 @@ try {
|
||||
}
|
||||
break;
|
||||
case 'changeView':
|
||||
//Classic process: set variable for users and groups Ad hoc
|
||||
$_SESSION['iType'] = $_POST['TU_TYPE'];
|
||||
break;
|
||||
case 'deleteGroup':
|
||||
G::LoadClass('groups');
|
||||
$oGroup = new Groups();
|
||||
$oGroup->removeUserOfGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
||||
$_GET['sUserUID'] = $_POST['USR_UID'];
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('view', 'users/users_Tree');
|
||||
G::RenderPage('publish', 'raw');
|
||||
break;
|
||||
case 'showUserGroupInterface':
|
||||
$_GET['sUserUID'] = $_POST['sUserUID'];
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('view', 'users/users_AssignGroup');
|
||||
G::RenderPage('publish', 'raw');
|
||||
break;
|
||||
case 'showUserGroups':
|
||||
$_GET['sUserUID'] = $_POST['sUserUID'];
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('view', 'users/users_Tree');
|
||||
G::RenderPage('publish', 'raw');
|
||||
break;
|
||||
case 'assignUserToGroup':
|
||||
G::LoadClass('groups');
|
||||
$oGroup = new Groups();
|
||||
$oGroup->addUserToGroup($_POST['GRP_UID'], $_POST['USR_UID']);
|
||||
echo '<div align="center"><h2><font color="blue">' . G::LoadTranslation('ID_MSG_ASSIGN_DONE') . '</font></h2></div>';
|
||||
break;
|
||||
case 'usersGroup':
|
||||
//Classic process: list of users in a group related a task
|
||||
G::LoadClass('groups');
|
||||
$oGroup = new Groups();
|
||||
$aGroup = $oGroup->getUsersOfGroup($_POST['GRP_UID']);
|
||||
@@ -154,29 +80,8 @@ try {
|
||||
echo $aValues['USR_FIRSTNAME'] . ' ' . $aValues['USR_LASTNAME'] . '<br>';
|
||||
}
|
||||
break;
|
||||
|
||||
//This case is used to check if any of the user group has as role 'PROCESSMAKER_ADMIN',
|
||||
case 'usersAdminGroupExtJS':
|
||||
G::LoadClass('groups');
|
||||
$oGroup = new Groups();
|
||||
$aGroup = $oGroup->getUsersOfGroup($_POST['GRP_UID']);
|
||||
$responseUser = 'false';
|
||||
$usersAdmin = '';
|
||||
foreach ($aGroup as $iIndex => $aValues) {
|
||||
if ($aValues['USR_ROLE'] == 'PROCESSMAKER_ADMIN') {
|
||||
$responseUser = 'true';
|
||||
$usersAdmin .= $aValues['USR_FIRSTNAME'] . ' ' . $aValues['USR_LASTNAME'] . ', ';
|
||||
}
|
||||
}
|
||||
$usersAdmin = substr($usersAdmin, 0, - 2);
|
||||
|
||||
$result = new stdClass();
|
||||
$result->reponse = $responseUser;
|
||||
$result->users = $usersAdmin;
|
||||
|
||||
echo G::json_encode($result);
|
||||
break;
|
||||
case 'canDeleteUser':
|
||||
//Check before delete a user
|
||||
G::LoadClass('case');
|
||||
$oProcessMap = new Cases();
|
||||
$userUid = $_POST['uUID'];
|
||||
@@ -204,44 +109,31 @@ try {
|
||||
echo $response;
|
||||
break;
|
||||
case 'deleteUser':
|
||||
$UID = $_POST['USR_UID'];
|
||||
|
||||
//process permissions
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(ObjectPermissionPeer::USR_UID);
|
||||
$criteria->addSelectColumn(ObjectPermissionPeer::PRO_UID);
|
||||
$criteria->add(ObjectPermissionPeer::OP_USER_RELATION, 1, Criteria::EQUAL);
|
||||
$criteria->add(ObjectPermissionPeer::USR_UID, $UID, Criteria::EQUAL);
|
||||
$doSelectRS = DynaformPeer::doSelectRS($criteria);
|
||||
$doSelectRS->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$doSelectRS->next();
|
||||
$objectPermision = $doSelectRS->getRow();
|
||||
if (isset($objectPermision["USR_UID"])) {
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(ProcessPeer::PRO_TITLE);
|
||||
$criteria->add(ProcessPeer::PRO_UID, $objectPermision["PRO_UID"], Criteria::EQUAL);
|
||||
$doSelectRS = ProcessPeer::doSelectRS($criteria);
|
||||
$doSelectRS->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$doSelectRS->next();
|
||||
$content = $doSelectRS->getRow();
|
||||
//Check if the user was defined in a process permissions
|
||||
$oObjectPermission = new ObjectPermission();
|
||||
$aProcess = $oObjectPermission->objectPermissionPerUser($_POST['USR_UID'], 1);
|
||||
if (count($aProcess) > 0) {
|
||||
echo G::json_encode(array(
|
||||
"status" => 'ERROR',
|
||||
"message" => G::LoadTranslation('ID_USER_CANT_BE_DELETED_FOR_THE_PROCESS', array('processTitle' => isset($content["PRO_TITLE"]) ? $content["PRO_TITLE"] : $objectPermision['PRO_UID']))
|
||||
"message" => G::LoadTranslation('ID_USER_CANT_BE_DELETED_FOR_THE_PROCESS', array('processTitle' => isset($aProcess["PRO_TITLE"]) ? $aProcess["PRO_TITLE"] : $aProcess['PRO_UID']))
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
//Remove from tasks
|
||||
G::LoadClass('tasks');
|
||||
$oTasks = new Tasks();
|
||||
$oTasks->ofToAssignUserOfAllTasks($UID);
|
||||
|
||||
//Remove from groups
|
||||
G::LoadClass('groups');
|
||||
$oGroups = new Groups();
|
||||
$oGroups->removeUserOfAllGroups($UID);
|
||||
$RBAC->changeUserStatus($UID, 'CLOSED');
|
||||
$_GET['USR_USERNAME'] = '';
|
||||
$RBAC->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']
|
||||
), '');
|
||||
|
||||
//Update the table Users
|
||||
require_once 'classes/model/Users.php';
|
||||
$RBAC->changeUserStatus($UID, 'CLOSED');
|
||||
$RBAC->updateUser(array('USR_UID' => $UID,'USR_USERNAME' => ''), '');
|
||||
$oUser = new Users();
|
||||
$aFields = $oUser->load($UID);
|
||||
$aFields['USR_STATUS'] = 'CLOSED';
|
||||
@@ -258,13 +150,13 @@ try {
|
||||
|
||||
//Delete users as supervisor
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->add(ProcessUserPeer::USR_UID, $UID, Criteria::EQUAL);
|
||||
$criteria->add(ProcessUserPeer::PU_TYPE, "SUPERVISOR", Criteria::EQUAL);
|
||||
ProcessUserPeer::doDelete($criteria);
|
||||
G::auditLog("DeleteUser", "User Name: ". $userName." User ID: (".$UID.") ");
|
||||
break;
|
||||
case 'changeUserStatus':
|
||||
//When the user change the status: ACTIVE, INACTIVE, VACATION
|
||||
$response = new stdclass();
|
||||
if (isset($_REQUEST['USR_UID']) && isset($_REQUEST['NEW_USR_STATUS'])) {
|
||||
$RBAC->changeUserStatus($_REQUEST['USR_UID'], ($_REQUEST['NEW_USR_STATUS'] == 'ACTIVE' ? 1 : 0));
|
||||
@@ -284,6 +176,7 @@ try {
|
||||
die(G::json_encode($response));
|
||||
break;
|
||||
case 'availableGroups':
|
||||
//Get the available groups for assign to user
|
||||
G::LoadClass('groups');
|
||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
||||
$groups = new Groups();
|
||||
@@ -297,6 +190,7 @@ try {
|
||||
echo '{groups: ' . G::json_encode($arr) . '}';
|
||||
break;
|
||||
case 'assignedGroups':
|
||||
//Get the groups related to user
|
||||
G::LoadClass('groups');
|
||||
$filter = (isset($_POST['textFilter'])) ? $_POST['textFilter'] : '';
|
||||
$groups = new Groups();
|
||||
@@ -310,6 +204,7 @@ try {
|
||||
echo '{groups: ' . G::json_encode($arr) . '}';
|
||||
break;
|
||||
case 'assignGroupsToUserMultiple':
|
||||
//Assign user in a group
|
||||
$USR_UID = $_POST['USR_UID'];
|
||||
$gUIDs = explode(',', $_POST['GRP_UID']);
|
||||
G::LoadClass('groups');
|
||||
@@ -319,6 +214,7 @@ try {
|
||||
}
|
||||
break;
|
||||
case 'deleteGroupsToUserMultiple':
|
||||
//Remove a user from a group
|
||||
$USR_UID = $_POST['USR_UID'];
|
||||
$gUIDs = explode(',', $_POST['GRP_UID']);
|
||||
G::LoadClass('groups');
|
||||
@@ -328,6 +224,7 @@ try {
|
||||
}
|
||||
break;
|
||||
case 'authSources':
|
||||
//Get the authentication information
|
||||
$criteria = $RBAC->getAllAuthSources();
|
||||
$objects = AuthenticationSourcePeer::doSelectRS($criteria);
|
||||
$objects->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
@@ -342,22 +239,19 @@ try {
|
||||
}
|
||||
$started = Array();
|
||||
$started['AUTH_SOURCE_UID'] = '00000000000000000000000000000000';
|
||||
//$started['AUTH_SOURCE_NAME'] = 'ProcessMaker';
|
||||
//$started['AUTH_SOURCE_TYPE'] = 'MYSQL';
|
||||
$started['AUTH_SOURCE_SHOW'] = 'ProcessMaker (MYSQL)';
|
||||
$arr[] = $started;
|
||||
while ($objects->next()) {
|
||||
$row = $objects->getRow();
|
||||
$aux = Array();
|
||||
$aux['AUTH_SOURCE_UID'] = $row['AUTH_SOURCE_UID'];
|
||||
//$aux['AUTH_SOURCE_NAME'] = $row['AUTH_SOURCE_NAME'];
|
||||
//$aux['AUTH_SOURCE_TYPE'] = $row['AUTH_SOURCE_TYPE'];
|
||||
$aux['AUTH_SOURCE_SHOW'] = $row['AUTH_SOURCE_NAME'] . ' (' . $row['AUTH_SOURCE_PROVIDER'] . ')';
|
||||
$arr[] = $aux;
|
||||
}
|
||||
echo '{sources: ' . G::json_encode($arr) . '}';
|
||||
break;
|
||||
case 'loadAuthSourceByUID':
|
||||
//Get the authentication source assignment
|
||||
require_once 'classes/model/Users.php';
|
||||
$oCriteria = $RBAC->load($_POST['uUID']);
|
||||
$UID_AUTH = $oCriteria['UID_AUTH_SOURCE'];
|
||||
@@ -379,6 +273,7 @@ try {
|
||||
echo G::json_encode($res);
|
||||
break;
|
||||
case 'updateAuthServices':
|
||||
//Update the information related to user's autentication
|
||||
$aData = $RBAC->load($_POST['usr_uid']);
|
||||
unset($aData['USR_ROLE']);
|
||||
$auth_uid = $_POST['auth_source'];
|
||||
@@ -399,127 +294,31 @@ try {
|
||||
$aData['USR_AUTH_USER_DN'] = $auth_dn;
|
||||
}
|
||||
$RBAC->updateUser($aData);
|
||||
G::auditLog("AssignAuthenticationSource", "User Name: ".$aData['USR_USERNAME'].' User ID: ('.$aData['USR_UID'].') assign to '.$aData['USR_AUTH_TYPE']);
|
||||
G::auditLog(
|
||||
"AssignAuthenticationSource",
|
||||
"User Name: ".$aData['USR_USERNAME'].' User ID: ('.$aData['USR_UID'].') assign to '.$aData['USR_AUTH_TYPE']
|
||||
);
|
||||
echo '{success: true}';
|
||||
break;
|
||||
case 'usersList':
|
||||
require_once 'classes/model/Users.php';
|
||||
require_once 'classes/model/LoginLog.php';
|
||||
require_once 'classes/model/Department.php';
|
||||
require_once 'classes/model/AppCacheView.php';
|
||||
require_once PATH_RBAC . 'model/Roles.php';
|
||||
global $RBAC;
|
||||
//Get the list of users
|
||||
//Read the configurations related to enviroments
|
||||
G::LoadClass('configuration');
|
||||
$co = new Configurations();
|
||||
$config = $co->getConfiguration('usersList', 'pageSize', '', $_SESSION['USER_LOGGED']);
|
||||
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
|
||||
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
|
||||
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
|
||||
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
|
||||
$auths = isset($_REQUEST['auths']) ? $_REQUEST['auths'] : '';
|
||||
$authSource = isset($_REQUEST['auths']) ? $_REQUEST['auths'] : '';
|
||||
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
|
||||
$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : 'ASC';
|
||||
$aUsers = Array();
|
||||
if ($auths != '') {
|
||||
$aUsers = $RBAC->getListUsersByAuthSource($auths);
|
||||
}
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn('COUNT(*) AS CNT');
|
||||
if ($filter != '') {
|
||||
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
|
||||
$oCriteria->add($cc);
|
||||
}
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
|
||||
if ($auths != '') {
|
||||
$totalRows = sizeof($aUsers);
|
||||
} else {
|
||||
$oDataset = UsersPeer::DoSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
$row = $oDataset->getRow();
|
||||
$totalRows = $row['CNT'];
|
||||
}
|
||||
$oCriteria->clearSelectColumns();
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_ROLE);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_DUE_DATE);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_STATUS);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_UX);
|
||||
$oCriteria->addSelectColumn(UsersPeer::DEP_UID);
|
||||
$oCriteria->addSelectColumn(UsersPeer::USR_LAST_LOGIN);
|
||||
$oCriteria->addAsColumn('LAST_LOGIN', 0);
|
||||
$oCriteria->addAsColumn('DEP_TITLE', 0);
|
||||
$oCriteria->addAsColumn('TOTAL_CASES', 0);
|
||||
$oCriteria->addAsColumn('DUE_DATE_OK', 1);
|
||||
$sep = "'";
|
||||
$oCriteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN);
|
||||
if ($filter != '') {
|
||||
$cc = $oCriteria->getNewCriterion(UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($oCriteria->getNewCriterion(UsersPeer::USR_EMAIL, '%' . $filter . '%', Criteria::LIKE))));
|
||||
$oCriteria->add($cc);
|
||||
}
|
||||
if (sizeof($aUsers) > 0) {
|
||||
$oCriteria->add(UsersPeer::USR_UID, $aUsers, Criteria::IN);
|
||||
} elseif ($totalRows == 0 && $auths != '') {
|
||||
$oCriteria->add(UsersPeer::USR_UID, '', Criteria::IN);
|
||||
}
|
||||
if ($sort != '') {
|
||||
if ($dir == 'ASC') {
|
||||
$oCriteria->addAscendingOrderByColumn($sort);
|
||||
} else {
|
||||
$oCriteria->addDescendingOrderByColumn($sort);
|
||||
}
|
||||
}
|
||||
$oCriteria->setOffset($start);
|
||||
$oCriteria->setLimit($limit);
|
||||
$oDataset = UsersPeer::DoSelectRs($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$Department = new Department();
|
||||
$aDepart = $Department->getAllDepartmentsByUser();
|
||||
$aAuthSources = $RBAC->getAllAuthSourcesByUser();
|
||||
|
||||
require_once PATH_CONTROLLERS . 'adminProxy.php';
|
||||
$uxList = adminProxy::getUxTypesList();
|
||||
|
||||
$oRoles = new Roles();
|
||||
$oParticipated = new ListParticipatedLast();
|
||||
$oAppCache = new AppCacheView();
|
||||
$rows = Array();
|
||||
$uRole = Array();
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
|
||||
try {
|
||||
$uRole = $oRoles->loadByCode($row['USR_ROLE']);
|
||||
} catch (exception $oError) {
|
||||
$uRole['ROL_NAME'] = G::loadTranslation('ID_DELETED');
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (true) {
|
||||
$total = $oParticipated->getCountList($row['USR_UID']);
|
||||
} else {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$total = $oAppCache->getListCounters('sent', $row['USR_UID'], false);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$row['USR_ROLE_ID'] = $row['USR_ROLE'];
|
||||
$row['USR_ROLE'] = isset($uRole['ROL_NAME']) ? ($uRole['ROL_NAME'] != '' ? $uRole['ROL_NAME'] : $uRole['ROL_CODE']) : $uRole['ROL_CODE'];
|
||||
|
||||
$row['DUE_DATE_OK'] = (date('Y-m-d') > date('Y-m-d', strtotime($row['USR_DUE_DATE']))) ? 0 : 1;
|
||||
$row['LAST_LOGIN'] = isset($row['USR_LAST_LOGIN']) ? \ProcessMaker\Util\DateTime::convertUtcToTimeZone($row['USR_LAST_LOGIN']) : '';
|
||||
$row['TOTAL_CASES'] = $total;
|
||||
$row['DEP_TITLE'] = isset($aDepart[$row['USR_UID']]) ? $aDepart[$row['USR_UID']] : '';
|
||||
$row['USR_UX'] = isset($uxList[$row['USR_UX']]) ? $uxList[$row['USR_UX']] : $uxList['NORMAL'];
|
||||
$row['USR_AUTH_SOURCE'] = isset($aAuthSources[$row['USR_UID']]) ? $aAuthSources[$row['USR_UID']] : 'ProcessMaker (MYSQL)';
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
echo '{users: ' . G::json_encode($rows) . ', total_users: ' . $totalRows . '}';
|
||||
//Get all list of users with the additional information related to department, role, authentication, cases
|
||||
$oUser = new \ProcessMaker\BusinessModel\User();
|
||||
$oDatasetUsers = $oUser->getAllUsersWithAuthSource($authSource, $filter, $sort, $start, $limit, $dir);
|
||||
$rows = $oUser->getAdditionalInfoFromUsers($oDatasetUsers);
|
||||
echo '{users: ' . G::json_encode($rows['data']) . ', total_users: ' . $rows['totalCount'] . '}';
|
||||
break;
|
||||
case 'updatePageSize':
|
||||
G::LoadClass('configuration');
|
||||
@@ -533,6 +332,7 @@ try {
|
||||
echo '{success: true}';
|
||||
break;
|
||||
case 'summaryUserData':
|
||||
//Get all information for the summary
|
||||
require_once 'classes/model/Users.php';
|
||||
require_once 'classes/model/Department.php';
|
||||
require_once 'classes/model/AppCacheView.php';
|
||||
@@ -574,25 +374,16 @@ try {
|
||||
break;
|
||||
|
||||
case "verifyIfUserAssignedAsSupervisor":
|
||||
//Before delete we check if is supervisor
|
||||
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
|
||||
$isSupervisor = $supervisor->isUserSupervisor($_POST["supervisorUserUid"]);
|
||||
$supervisorUserUid = $_POST["supervisorUserUid"];
|
||||
$message = "OK";
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(ProcessUserPeer::PU_UID);
|
||||
$criteria->add(ProcessUserPeer::USR_UID, $supervisorUserUid, Criteria::EQUAL);
|
||||
$criteria->add(ProcessUserPeer::PU_TYPE, "SUPERVISOR", Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = ProcessUserPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$message = "ERROR";
|
||||
$message = 'OK';
|
||||
if ($isSupervisor) {
|
||||
$message = 'ERROR';
|
||||
}
|
||||
|
||||
$response = array();
|
||||
$response["result"] = $message;
|
||||
|
||||
echo G::json_encode($response);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user