Merged in feature/PMCORE-2860 (pull request #7882)

PMCORE-2860

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2021-05-07 21:19:28 +00:00
committed by Julio Cesar Laura Avendaño
49 changed files with 1521 additions and 927 deletions

View File

@@ -137,15 +137,29 @@ function deleteDocuments($aDocuments, $opt)
}
return true;
}
/////////////////////////////////////////////
function getExtJSParams()
/**
* Get the default menu
*/
function getExtJSParams ()
{
$validParams = array('callback' => '', 'dir' => 'DESC', 'sort' => '', 'start' => 0, 'limit' => 25, 'filter' => '',
'search' => '', 'action' => '', 'xaction' => '', 'data' => '', 'status' => '', 'query' => '', 'fields' => "");
$result = array();
foreach ($validParams as $paramName => $paramDefault) {
$result[$paramName] = isset($_REQUEST[$paramName]) ?
$_REQUEST[$paramName] : isset($_REQUEST[$paramName]) ? $_REQUEST[$paramName] : $paramDefault;
$validParams = [
'callback' => '',
'dir' => 'DESC',
'sort' => '',
'start' => 0,
'limit' => 25,
'filter' => '',
'search' => '',
'action' => '',
'xaction' => '',
'data' => '',
'status' => '',
'query' => '',
'fields' => ''
];
$result = [];
foreach ($validParams as $param => $default) {
$result[$param] = ($request[$param] ?? isset($request[$param])) ? $request[$param] : $default;
}
return $result;
}

View File

@@ -22,12 +22,29 @@ $functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
$functionName( $functionParams );
/**
* Get the default menu
*/
function getExtJSParams ()
{
$validParams = array ('callback' => '','dir' => 'DESC','sort' => '','start' => 0,'limit' => 25,'filter' => '','search' => '','action' => '','xaction' => '','data' => '','status' => '','query' => '','fields' => "");
$result = array ();
foreach ($validParams as $paramName => $paramDefault) {
$result[$paramName] = isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : isset( $_REQUEST[$paramName] ) ? $_REQUEST[$paramName] : $paramDefault;
$validParams = [
'callback' => '',
'dir' => 'DESC',
'sort' => '',
'start' => 0,
'limit' => 25,
'filter' => '',
'search' => '',
'action' => '',
'xaction' => '',
'data' => '',
'status' => '',
'query' => '',
'fields' => ''
];
$result = [];
foreach ($validParams as $param => $default) {
$result[$param] = ($request[$param] ?? isset($request[$param])) ? $request[$param] : $default;
}
return $result;
}

View File

@@ -2,6 +2,7 @@
use ProcessMaker\Core\System;
use ProcessMaker\GmailOAuth\GmailOAuth;
use ProcessMaker\Office365OAuth\Office365OAuth;
$option = (isset($_POST["option"])) ? $_POST["option"] : "";
$response = [];
@@ -232,6 +233,8 @@ switch ($option) {
case "createAuthUrl":
try {
$gmailOAuth = new GmailOAuth();
$gmailOAuth->setServer($_POST['server']);
$gmailOAuth->setPort($_POST['port']);
$gmailOAuth->setClientID($_POST['clientID']);
$gmailOAuth->setClientSecret($_POST['clientSecret']);
$gmailOAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerGmailOAuth");
@@ -258,6 +261,38 @@ switch ($option) {
];
}
break;
case "createAuthUrlOffice365":
try {
$office365OAuth = new Office365OAuth();
$office365OAuth->setServer($_POST['server']);
$office365OAuth->setPort($_POST['port']);
$office365OAuth->setClientID($_POST['clientID']);
$office365OAuth->setClientSecret($_POST['clientSecret']);
$office365OAuth->setRedirectURI(System::getServerMainPath() . "/emailServer/emailServerOffice365OAuth");
$office365OAuth->setEmailEngine($_POST['emailEngine']);
$office365OAuth->setFromAccount($_POST['fromAccount']);
$office365OAuth->setSenderEmail($_POST['senderEmail']);
$office365OAuth->setSenderName($_POST['senderName']);
$office365OAuth->setSendTestMail((int) $_POST['sendTestMail']);
$office365OAuth->setMailTo($_POST['mailTo']);
$office365OAuth->setSetDefaultConfiguration((int) $_POST['setDefaultConfiguration']);
if (!empty($_POST['emailServerUid'])) {
$office365OAuth->setEmailServerUid($_POST['emailServerUid']);
}
$client = $office365OAuth->getOffice365Client();
$response = [
"status" => 200,
"data" => $client->getAuthorizationUrl($office365OAuth->getOptions())
];
$_SESSION['office365OAuth'] = $office365OAuth;
} catch (Exception $e) {
$response = [
"status" => 500,
"message" => $e->getMessage()
];
}
break;
}
echo G::json_encode($response);

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Cache;
use ProcessMaker\Core\System;
use ProcessMaker\Office365OAuth\Office365OAuth;
Cache::forget('errorMessageIfNotAuthenticate');
try {
$header = "location:" . System::getServerMainPath() . "/setup/main?s=EMAIL_SERVER";
$validInput = empty($_GET['code']) || empty($_SESSION['office365OAuth']) || !is_object($_SESSION['office365OAuth']);
if ($validInput) {
G::header($header);
return;
}
$RBAC->allows(basename(__FILE__), "code");
$office365OAuth = $_SESSION['office365OAuth'];
$office365Client = $office365OAuth->getOffice365Client();
$accessToken = $office365Client->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);
$token = $accessToken->getToken();
$office365OAuth->setRefreshToken($accessToken->getRefreshToken());
$office365OAuth->saveEmailServer();
$office365OAuth->sendTestMailWithPHPMailerOAuth('Stevenmaguire\OAuth2\Client\Provider\Microsoft');
} catch (Exception $e) {
/**
* The laravel cache is volatile in each session, you can specify the duration
* value in minutes for each session. We use 2 minutes, enough time to retrieve
* the error message if there is one.
*/
Cache::put('errorMessageIfNotAuthenticate', $e->getMessage(), 2);
}
G::header($header);
return;

View File

@@ -346,7 +346,9 @@ function to_camel_case ($str, $capitalise_first_char = true)
if ($capitalise_first_char) {
$str[0] = strtoupper( $str[0] );
}
$func = create_function( '$c', 'return strtoupper($c[1]);' );
$func = function ($c) {
return strtoupper($c[1]);
};
return preg_replace_callback( '/_([a-z])/', $func, $str );
}

View File

@@ -264,7 +264,7 @@ try {
$oCriteria = new Criteria('workflow');
$oCriteria->add(AppDelegationPeer::APP_UID, $_SESSION['APPLICATION']);
$oCriteria->add(AppDelegationPeer::TAS_UID, $aTasks, Criteria::IN);
$oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL)->addOr($oCriteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, '')));
$oCriteria->add($oCriteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL)->addOr($oCriteria->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, '0000-00-00 00:00:00')));
if (AppDelegationPeer::doCount($oCriteria) > 0) {
$oStage->color = '#FF0000';
} else {

View File

@@ -1,46 +1,26 @@
<?php
/**
* triggers_WizardSave.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.
*/
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
return $RBAC_Response;
}
require_once ('classes/model/Triggers.php');
$oTrigger = new Triggers();
if (!class_exists('Triggers')) {
require_once ('classes/model/Triggers.php');
}
$triggers = new Triggers();
$oProcessMap = new ProcessMap(new DBConnection());
$processMap = new ProcessMap(new DBConnection());
$aDataTriggers = $_POST;
$post = $_POST;
$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
$allFunction = explode(",", $post['ALLFUNCTION']);
$allFunctionType = explode(",", $post['ALLFUNCTION_TYPE']);
$sPMfunction = "
$template = "
/***************************************************
*
* Generated by ProcessMaker Trigger Wizard
* Library: " . $aDataTriggers['LIBRARY_NAME'] . "
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
* Library: " . $post['LIBRARY_NAME'] . "
* Method: " . $post['PMFUNTION_LABEL'] . "
* Date: " . date("Y-m-d H:i:s") . "
*
* ProcessMaker " . date("Y") . "
@@ -49,65 +29,69 @@ $sPMfunction = "
";
$methodParamsFinal = array();
$params = [];
//Generate params to send
$i = 0;
foreach ($aInfoFunction as $k => $v) {
foreach ($allFunction as $k => $v) {
if ($v != '') {
$sOptionTrigger = trim(str_replace("$", "", $v));
if (strstr($sOptionTrigger, "=")) {
$aOptionParameters = explode("=", $sOptionTrigger);
$sOptionTrigger = trim($aOptionParameters[0]);
$key = trim(str_replace("$", "", $v));
if (strstr($key, "=")) {
$parameter = explode("=", $key);
$key = trim($parameter[0]);
}
if ($aDataTriggers[$sOptionTrigger] != '') {
if ($post[$key] != '') {
if ((strstr($aDataTriggers[$sOptionTrigger], "@@")) || ($aDataTriggers['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($aDataTriggers[$sOptionTrigger], "@="))) {
$option = trim($aDataTriggers[$sOptionTrigger]);
if ((strstr($post[$key], "@@")) || ($post['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($post[$key], "@="))) {
$option = trim($post[$key]);
} else {
$aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
switch (trim($aInfoFunctionType[$i])) {
$post[$key] = strstr($post[$key], 'array') !== false ? str_replace("'", '"', $post[$key]) : str_replace("'", "\'", $post[$key]);
switch (trim($allFunctionType[$i])) {
case 'boolean':
$option = $aDataTriggers[$sOptionTrigger];
$option = $post[$key];
break;
case 'int':
$option = intval($aDataTriggers[$sOptionTrigger]);
$option = intval($post[$key]);
break;
case 'float':
case 'real':
case 'double':
$option = floatval($aDataTriggers[$sOptionTrigger]);
$option = floatval($post[$key]);
break;
default:
$option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "'.array.'")) ? trim($aDataTriggers[$sOptionTrigger]) : '"' . trim($aDataTriggers[$sOptionTrigger]) . '"';
if (is_numeric($post[$key]) || is_bool($post[$key]) || (strstr($post[$key], "'.array.'") !== false)) {
$option = trim($post[$key]);
} else {
$option = '"' . trim($post[$key]) . '"';
}
break;
}
}
} else {
$option = "''";
}
$methodParamsFinal[] = $option;
$params[] = $option;
}
$i++;
}
//G::pr($methodParamsFinal);die;
$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
$template .= (isset($post['TRI_ANSWER']) && $post['TRI_ANSWER'] != '') ? $post['TRI_ANSWER'] . " = " : "";
$template .= $post['PMFUNTION_NAME'] . " (" . implode(",", $params) . ");";
//Create Trigger
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
$aDataTriggersParams = array();
$aDataTriggersParams['hash'] = G::encryptOld($sPMfunction);
$aDataTriggersParams['params'] = $aDataTriggers;
$post['TRI_WEBBOT'] = $template;
$postParams = [];
$postParams['hash'] = G::encryptOld($template);
$postParams['params'] = $post;
$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
$oTrigger->create($aDataTriggers);
$post['TRI_PARAM'] = serialize($postParams);
$triggers->create($post);
//Update Info
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
$oTrigger->update($aDataTriggers);
$post['TRI_UID'] = $triggers->getTriUid();
$triggers->update($post);
//Update Trigger Array
$oProcessMap->triggersList($aDataTriggers['PRO_UID']);
$processMap->triggersList($post['PRO_UID']);

View File

@@ -1,48 +1,26 @@
<?php
/**
* triggers_WizardUpdate.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.
*/
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
return $RBAC_Response;
}
if (!class_exists('Triggers')) {
require_once ('classes/model/Triggers.php');
}
$oTrigger = new Triggers();
$triggers = new Triggers();
$oProcessMap = new ProcessMap(new DBConnection());
$processMap = new ProcessMap(new DBConnection());
$aDataTriggers = $_POST;
$triUid = $_POST['TRI_UID'];
$post = $_POST;
$aInfoFunction = explode(",", $aDataTriggers['ALLFUNCTION']);
$aInfoFunctionType = explode(",", $aDataTriggers['ALLFUNCTION_TYPE']);
$sPMfunction = "
$allFunction = explode(",", $post['ALLFUNCTION']);
$allFunctionType = explode(",", $post['ALLFUNCTION_TYPE']);
$template = "
/***************************************************
*
* Generated by ProcessMaker Trigger Wizard
* Library: " . $aDataTriggers['LIBRARY_NAME'] . "
* Method: " . $aDataTriggers['PMFUNTION_LABEL'] . "
* Library: " . $post['LIBRARY_NAME'] . "
* Method: " . $post['PMFUNTION_LABEL'] . "
* Date: " . date("Y-m-d H:i:s") . "
*
* ProcessMaker " . date("Y") . "
@@ -51,68 +29,69 @@ $sPMfunction = "
";
$methodParamsFinal = array();
$params = [];
//Generate params to send
$i = 0;
foreach ($aInfoFunction as $k => $v) {
foreach ($allFunction as $k => $v) {
if ($v != '') {
$sOptionTrigger = trim(str_replace("$", "", $v));
if (strstr($sOptionTrigger, "=")) {
$aOptionParameters = explode("=", $sOptionTrigger);
$sOptionTrigger = trim($aOptionParameters[0]);
$key = trim(str_replace("$", "", $v));
if (strstr($key, "=")) {
$parameter = explode("=", $key);
$key = trim($parameter[0]);
}
if ($aDataTriggers[$sOptionTrigger] != '') {
if ($post[$key] != '') {
if ((strstr($aDataTriggers[$sOptionTrigger], "@@")) || ($aDataTriggers['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($aDataTriggers[$sOptionTrigger], "@="))) {
$option = $aDataTriggers[$sOptionTrigger];
if ((strstr($post[$key], "@@")) || ($post['PMFUNTION_NAME'] == 'evaluateFunction' && $k == 0 && strstr($post[$key], "@="))) {
$option = trim($post[$key]);
} else {
$aDataTriggers[$sOptionTrigger] = (strstr($aDataTriggers[$sOptionTrigger], 'array')) ? str_replace("'", '"', $aDataTriggers[$sOptionTrigger]) : str_replace("'", "\'", $aDataTriggers[$sOptionTrigger]);
switch (trim($aInfoFunctionType[$i])) {
$post[$key] = strstr($post[$key], 'array') !== false ? str_replace("'", '"', $post[$key]) : str_replace("'", "\'", $post[$key]);
switch (trim($allFunctionType[$i])) {
case 'boolean':
$option = $aDataTriggers[$sOptionTrigger];
$option = $post[$key];
break;
case 'int':
$option = intval($aDataTriggers[$sOptionTrigger]);
$option = intval($post[$key]);
break;
case 'float':
case 'real':
case 'double':
$option = floatval($aDataTriggers[$sOptionTrigger]);
$option = floatval($post[$key]);
break;
default:
$option = (is_numeric($aDataTriggers[$sOptionTrigger]) || is_bool($aDataTriggers[$sOptionTrigger]) ) ? trim($aDataTriggers[$sOptionTrigger]) : (strstr($aDataTriggers[$sOptionTrigger], "array")) ? trim($aDataTriggers[$sOptionTrigger]) : '"' . trim($aDataTriggers[$sOptionTrigger]) . '"';
if (is_numeric($post[$key]) || is_bool($post[$key]) || (strstr($post[$key], "array") !== false)) {
$option = trim($post[$key]);
} else {
$option = '"' . trim($post[$key]) . '"';
}
break;
}
}
} else {
$option = "' '";
}
$methodParamsFinal[] = $option;
$params[] = $option;
}
$i++;
}
$sPMfunction .= (isset($aDataTriggers['TRI_ANSWER']) && $aDataTriggers['TRI_ANSWER'] != '') ? $aDataTriggers['TRI_ANSWER'] . " = " : "";
$sPMfunction .= $aDataTriggers['PMFUNTION_NAME'] . " (" . implode(",", $methodParamsFinal) . ");";
$template .= (isset($post['TRI_ANSWER']) && $post['TRI_ANSWER'] != '') ? $post['TRI_ANSWER'] . " = " : "";
$template .= $post['PMFUNTION_NAME'] . " (" . implode(",", $params) . ");";
//Create Trigger
$aDataTriggers['TRI_WEBBOT'] = $sPMfunction;
$aDataTriggersParams = array();
$aDataTriggersParams['hash'] = G::encryptOld($sPMfunction);
$aDataTriggersParams['params'] = $aDataTriggers;
$post['TRI_WEBBOT'] = $template;
$postParams = [];
$postParams['hash'] = G::encryptOld($template);
$postParams['params'] = $post;
$post['TRI_PARAM'] = serialize($postParams);
$triggers->load($_POST['TRI_UID']);
$aDataTriggers['TRI_PARAM'] = serialize($aDataTriggersParams);
//$oTrigger->create ( $aDataTriggers );
$aDataTriggerLoaded = $oTrigger->load($triUid);
//var_dump($aDataTriggerLoaded);
//die;
//Update Info
$aDataTriggers['TRI_UID'] = $oTrigger->getTriUid();
$oTrigger->update($aDataTriggers);
$post['TRI_UID'] = $triggers->getTriUid();
$triggers->update($post);
//Update Trigger Array
$oProcessMap->triggersList($aDataTriggers['PRO_UID']);
$processMap->triggersList($post['PRO_UID']);

View File

@@ -1,6 +1,12 @@
<?php
use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\BusinessModel\Cases\Inbox;
use ProcessMaker\BusinessModel\Cases\Participated;
use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
try {
global $RBAC;
@@ -336,43 +342,81 @@ try {
echo '{success: true}';
break;
case 'summaryUserData':
//Get all information for the summary
$oUser = new Users();
$data = $oUser->loadDetailed($_REQUEST['USR_UID']);
$data['USR_STATUS'] = G::LoadTranslation('ID_' . $data['USR_STATUS']);
$oAppCache = new AppCacheView();
$aTypes = Array();
$aTypes['to_do'] = 'CASES_INBOX';
$aTypes['draft'] = 'CASES_DRAFT';
$aTypes['cancelled'] = 'CASES_CANCELLED';
$aTypes['sent'] = 'CASES_SENT';
$aTypes['paused'] = 'CASES_PAUSED';
$aTypes['completed'] = 'CASES_COMPLETED';
$aTypes['selfservice'] = 'CASES_SELFSERVICE';
$aCount = $oAppCache->getAllCounters(array_keys($aTypes), $_REQUEST['USR_UID']);
$dep = new Department();
if ($dep->existsDepartment($data['DEP_UID'])) {
$dep->Load($data['DEP_UID']);
$dep_name = $dep->getDepTitle();
} else {
$dep_name = '';
// Get all information for the summary
$result = [];
$usrUid = $_REQUEST['USR_UID'];
$usrId = User::getId($usrUid);
$data = User::getAllInformation($usrId);
$data = head($data);
$result['userdata'] = $data;
// Add additional user information
$isoCountry = IsoCountry::findById($data['USR_COUNTRY']);
$isoSubdivision = IsoSubdivision::findById($data['USR_COUNTRY'], $data['USR_CITY']);
$isoLocation = IsoLocation::findById($data['USR_COUNTRY'], $data['USR_CITY'], $data['USR_LOCATION']);
$result['userdata']['USR_COUNTRY_NAME'] = !empty($isoCountry["IC_NAME"]) ? $isoCountry["IC_NAME"] : '';
$result['userdata']['USR_CITY_NAME'] = !empty($isoSubdivision["IC_NAME"]) ? $isoSubdivision["IC_NAME"] : '';
$result['userdata']['USR_LOCATION_NAME'] = !empty($isoLocation["IC_NAME"]) ? $isoLocation["IC_NAME"] : '';
// Get the role name
$roles = new Roles();
$role = $roles->loadByCode($data['USR_ROLE']);
$result['userdata']['USR_ROLE_NAME'] = $role['ROL_NAME'];
// Get the language name
$translations = new Language();
$translation = $translations->loadByCode($data['USR_DEFAULT_LANG']);
$result['userdata']['USR_DEFAULT_LANG_NAME'] = $translation['LANGUAGE_NAME'];
// Get the full name
$conf = new Configurations();
$confSetting = $conf->getFormats();
$result['userdata']['USR_FULLNAME'] = G::getFormatUserList($confSetting['format'], $data);
// Get the cases counters
$types = [];
// For inbox
$inbox = new Inbox();
$inbox->setUserUid($usrUid);
$inbox->setUserId($usrId);
$types['to_do'] = $inbox->getCounter();
// For draft
$draft = new Draft();
$draft->setUserUid($usrUid);
$draft->setUserId($usrId);
$types['draft'] = $draft->getCounter();
// For Paused
$paused = new Paused();
$paused->setUserUid($usrUid);
$paused->setUserId($usrId);
$types['paused'] = $paused->getCounter();
// For Unassigned
$unassigned = new Unassigned();
$unassigned->setUserUid($usrUid);
$unassigned->setUserId($usrId);
$types['selfservice'] = $unassigned->getCounter();
// For started by me
$participated = new Participated();
$participated->setParticipatedStatus('STARTED');
$participated->setUserUid($usrUid);
$participated->setUserId($usrId);
$types['sent'] = $participated->getCounter();
$types['cancelled'] = 0;
$result['cases'] = $types;
// Get department name
$result['misc'] = [];
$dept = new Department();
$department = '';
if ($dept->existsDepartment($data['DEP_UID'])) {
$dept->Load($data['DEP_UID']);
$department = $dept->getDepTitle();
}
if ($data['USR_REPLACED_BY'] != '') {
$user = new Users();
$u = $user->load($data['USR_REPLACED_BY']);
$c = new Configurations();
$arrayConfFormat = $c->getFormats();
$replaced_by = G::getFormatUserList($arrayConfFormat['format'], $u);
} else {
$replaced_by = '';
$result['misc']['DEP_TITLE'] = $department;
// Get the user full name who will replace the current user
$replacedBy = '';
if (!empty($data['USR_REPLACED_BY'])) {
$usrId = User::getId($data['USR_REPLACED_BY']);
$dataUser = User::getAllInformation($usrId);
$replacedBy = G::getFormatUserList($confSetting['format'], head($dataUser));
}
$misc = Array();
$misc['DEP_TITLE'] = $dep_name;
$misc['REPLACED_NAME'] = $replaced_by;
echo '{success: true, userdata: ' . G::json_encode($data) . ', cases: ' . G::json_encode($aCount) . ', misc: ' . G::json_encode($misc) . '}';
$result['misc']['REPLACED_NAME'] = $replacedBy;
echo G::json_encode($result);
break;
case "verifyIfUserAssignedAsSupervisor":
//Before delete we check if is supervisor
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();