Merged 3.0.1.8 into MT-10
This commit is contained in:
@@ -2694,30 +2694,22 @@ class Cases
|
||||
}
|
||||
|
||||
//Number records total
|
||||
$criteriaCount = clone $criteria;
|
||||
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addSelectColumn('COUNT(' . \UsersPeer::USR_UID . ') AS NUM_REC');
|
||||
|
||||
$rsCriteriaCount = \UsersPeer::doSelectRS($criteriaCount);
|
||||
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$result = $rsCriteriaCount->next();
|
||||
$row = $rsCriteriaCount->getRow();
|
||||
|
||||
$numRecTotal = (int)($row['NUM_REC']);
|
||||
$numRecTotal = \UsersPeer::doCount($criteria);
|
||||
|
||||
//Query
|
||||
$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;
|
||||
} else {
|
||||
$sortField = \UsersPeer::USR_FIRSTNAME;
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
} else {
|
||||
$sortField = \UsersPeer::USR_FIRSTNAME;
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
|
||||
if (!is_null($sortDir) && trim($sortDir) != '' && strtoupper($sortDir) == 'DESC') {
|
||||
|
||||
@@ -146,95 +146,6 @@ class Department
|
||||
return $aDepts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list for Assigned User
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAssignedUser($dep_uid)
|
||||
{
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
$oDept = new \Department();
|
||||
$oDept->Load( $dep_uid );
|
||||
$manager = $oDept->getDepManager();
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_STATUS );
|
||||
$oCriteria->add( UsersPeer::DEP_UID, '' );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'CLOSED', \Criteria::NOT_EQUAL );
|
||||
$oCriteria->add( UsersPeer::DEP_UID, $dep_uid );
|
||||
$oDataset = UsersPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$aUsers = array ();
|
||||
while ($oDataset->next()) {
|
||||
$dataTemp = $oDataset->getRow();
|
||||
$aUsers[] = array_change_key_case($dataTemp, CASE_LOWER);
|
||||
$index = sizeof( $aUsers ) - 1;
|
||||
$aUsers[$index]['usr_supervisor'] = ($manager == $aUsers[$index]['usr_uid']) ? true : false;
|
||||
}
|
||||
return $aUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list for Available User
|
||||
*
|
||||
* @access public
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableUser($dep_uid, $start = 0, $limit = 0, $search = '')
|
||||
{
|
||||
$dep_uid = Validator::depUid($dep_uid);
|
||||
|
||||
$start = (int)$start;
|
||||
$start = abs($start);
|
||||
if ($start != 0) {
|
||||
$start+1;
|
||||
}
|
||||
|
||||
$limit = (int)$limit;
|
||||
$limit = abs($limit);
|
||||
if ($limit == 0) {
|
||||
$limit = 25;
|
||||
} else {
|
||||
$limit = (int)$limit;
|
||||
}
|
||||
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
|
||||
$oCriteria->addSelectColumn( UsersPeer::USR_STATUS );
|
||||
$oCriteria->add( UsersPeer::DEP_UID, '' );
|
||||
$oCriteria->add( UsersPeer::USR_STATUS, 'CLOSED', \Criteria::NOT_EQUAL );
|
||||
|
||||
$oCriteria->setLimit( $limit );
|
||||
$oCriteria->setOffset( $start );
|
||||
|
||||
if ($search != '') {
|
||||
$oCriteria->add( $oCriteria->getNewCriterion( UsersPeer::USR_USERNAME, '%' . $search . '%', \Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_FIRSTNAME, '%' . $search . '%', \Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_LASTNAME, '%' . $search . '%', \Criteria::LIKE ) ) ) );
|
||||
}
|
||||
|
||||
$oDataset = UsersPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
$aUsers = array ();
|
||||
while ($oDataset->next()) {
|
||||
$dataTemp = $oDataset->getRow();
|
||||
$aUsers[] = array_change_key_case($dataTemp, CASE_LOWER);
|
||||
}
|
||||
return $aUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign User to Department
|
||||
*
|
||||
@@ -323,6 +234,217 @@ class Department
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* @return array Return an array with custom record
|
||||
*/
|
||||
private function __getUserCustomRecordFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
$recordc = [
|
||||
'usr_uid' => $record['USR_UID'],
|
||||
'usr_username' => $record['USR_USERNAME'],
|
||||
'usr_firstname' => $record['USR_FIRSTNAME'],
|
||||
'usr_lastname' => $record['USR_LASTNAME'],
|
||||
'usr_status' => $record['USR_STATUS']
|
||||
];
|
||||
|
||||
if (isset($record['USR_SUPERVISOR'])) {
|
||||
$recordc['usr_supervisor'] = $record['USR_SUPERVISOR'];
|
||||
}
|
||||
|
||||
return $recordc;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Users of a Department (Assigned/Available)
|
||||
*
|
||||
* @param string $departmentUid Unique id of Department
|
||||
* @param string $option Option (ASSIGNED, AVAILABLE)
|
||||
* @param array $arrayFilterData Data of the filters
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
* @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(
|
||||
$departmentUid,
|
||||
$option,
|
||||
array $arrayFilterData = null,
|
||||
$sortField = null,
|
||||
$sortDir = null,
|
||||
$start = null,
|
||||
$limit = null,
|
||||
$flagRecord = true,
|
||||
$throwException = true
|
||||
) {
|
||||
try {
|
||||
$arrayUser = array();
|
||||
|
||||
$numRecTotal = 0;
|
||||
|
||||
//Verify data and Set variables
|
||||
$flagFilter = !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData['filter']);
|
||||
|
||||
$result = \ProcessMaker\BusinessModel\Validator::validatePagerDataByPagerDefinition(
|
||||
['$start' => $start, '$limit' => $limit],
|
||||
['$start' => '$start', '$limit' => '$limit']
|
||||
);
|
||||
|
||||
if ($result !== true) {
|
||||
if ($throwException) {
|
||||
throw new \Exception($result);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$arrayDepartmentData = $this->getDepartmentRecordByPk(
|
||||
$departmentUid, ['$departmentUid' => '$departmentUid'], $throwException
|
||||
);
|
||||
|
||||
if ($arrayDepartmentData === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Set variables
|
||||
$filterName = 'filter';
|
||||
|
||||
if ($flagFilter) {
|
||||
$arrayAux = [
|
||||
'' => 'filter',
|
||||
'LEFT' => 'lfilter',
|
||||
'RIGHT' => 'rfilter'
|
||||
];
|
||||
|
||||
$filterName = $arrayAux[
|
||||
(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''
|
||||
];
|
||||
}
|
||||
|
||||
//Get data
|
||||
if (!is_null($limit) && (string)($limit) == '0') {
|
||||
return [
|
||||
'total' => $numRecTotal,
|
||||
'start' => (int)((!is_null($start))? $start : 0),
|
||||
'limit' => (int)((!is_null($limit))? $limit : 0),
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
}
|
||||
|
||||
//Query
|
||||
$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->add(\UsersPeer::USR_STATUS, 'CLOSED', \Criteria::NOT_EQUAL);
|
||||
|
||||
switch ($option) {
|
||||
case 'ASSIGNED':
|
||||
$criteria->add(\UsersPeer::DEP_UID, $departmentUid, \Criteria::EQUAL);
|
||||
break;
|
||||
case 'AVAILABLE':
|
||||
$criteria->add(\UsersPeer::DEP_UID, '', \Criteria::EQUAL);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($flagFilter && trim($arrayFilterData['filter']) != '') {
|
||||
$arraySearch = [
|
||||
'' => '%' . $arrayFilterData['filter'] . '%',
|
||||
'LEFT' => $arrayFilterData['filter'] . '%',
|
||||
'RIGHT' => '%' . $arrayFilterData['filter']
|
||||
];
|
||||
|
||||
$search = $arraySearch[
|
||||
(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''
|
||||
];
|
||||
|
||||
$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)))
|
||||
);
|
||||
}
|
||||
|
||||
//Number records total
|
||||
$numRecTotal = \UsersPeer::doCount($criteria);
|
||||
|
||||
//Query
|
||||
$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;
|
||||
} else {
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
} else {
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
|
||||
if (!is_null($sortDir) && trim($sortDir) != '' && strtoupper($sortDir) == 'DESC') {
|
||||
$criteria->addDescendingOrderByColumn($sortField);
|
||||
} else {
|
||||
$criteria->addAscendingOrderByColumn($sortField);
|
||||
}
|
||||
|
||||
if (!is_null($start)) {
|
||||
$criteria->setOffset((int)($start));
|
||||
}
|
||||
|
||||
if (!is_null($limit)) {
|
||||
$criteria->setLimit((int)($limit));
|
||||
}
|
||||
|
||||
$rsCriteria = \UsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$record = $rsCriteria->getRow();
|
||||
|
||||
switch ($option) {
|
||||
case 'ASSIGNED':
|
||||
$record['USR_SUPERVISOR'] = $record['USR_UID'] == $arrayDepartmentData['DEP_MANAGER'];
|
||||
break;
|
||||
case 'AVAILABLE':
|
||||
break;
|
||||
}
|
||||
|
||||
$arrayUser[] = ($flagRecord)? $record : $this->__getUserCustomRecordFromRecord($record);
|
||||
}
|
||||
|
||||
//Return
|
||||
return [
|
||||
'total' => $numRecTotal,
|
||||
'start' => (int)((!is_null($start))? $start : 0),
|
||||
'limit' => (int)((!is_null($limit))? $limit : 0),
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put Set Manager User
|
||||
*
|
||||
|
||||
@@ -1257,11 +1257,18 @@ class Light
|
||||
*/
|
||||
public function getConfiguration()
|
||||
{
|
||||
$sysConf = \System::getSystemConfiguration('', '', SYS_SYS);
|
||||
$sysConf = \Bootstrap::getSystemConfiguration('','',SYS_SYS);
|
||||
$multiTimeZone = false;
|
||||
//Set Time Zone
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (\PMLicensedFeatures::getSingleton()->verifyfeature
|
||||
('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||
$multiTimeZone = (int)($sysConf['system_utc_time_zone']) == 1;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$offset = timezone_offset_get( new \DateTimeZone( $sysConf['time_zone'] ), new \DateTime() );
|
||||
$response['timeZone'] = sprintf( "GMT%s%02d:%02d", ( $offset >= 0 ) ? '+' : '-', abs( $offset / 3600 ), abs( ($offset % 3600) / 60 ) );
|
||||
$response['multiTimeZone'] = (isset($sysConf['system_utc_time_zone']) && $sysConf['system_utc_time_zone'])
|
||||
?true:false;
|
||||
$response['multiTimeZone'] = $multiTimeZone;
|
||||
$fields = \System::getSysInfo();
|
||||
$response['version'] = $fields['PM_VERSION'];
|
||||
|
||||
|
||||
@@ -14,34 +14,47 @@ namespace ProcessMaker\BusinessModel\Light;
|
||||
|
||||
class PushMessageIOS
|
||||
{
|
||||
var $url = 'ssl://gateway.sandbox.push.apple.com:2195';
|
||||
var $passphrase = "sample";
|
||||
var $pemFile;
|
||||
var $devices = array();
|
||||
var $response = array();
|
||||
private $url = 'ssl://gateway.sandbox.push.apple.com:2195';
|
||||
private $passphrase = "sample";
|
||||
private $pemFile = 'mobileios.pem';
|
||||
private $devices = array();
|
||||
private $response = array();
|
||||
|
||||
/**
|
||||
* Sete server notification Ios
|
||||
* @param $url string the url server
|
||||
*/
|
||||
function setUrl($url){
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param $passphrase update your private key's
|
||||
* Set key passphrase
|
||||
* @param string $passphrase update your private key's
|
||||
*/
|
||||
function setKey($passphrase){
|
||||
public function setKey($passphrase)
|
||||
{
|
||||
$this->passphrase = $passphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices token to send to
|
||||
* @param $deviceIds array of device tokens to send to
|
||||
* Set name file .pem
|
||||
* @param string $file name file .pem
|
||||
*/
|
||||
function setDevices($devicesToken)
|
||||
public function setPemFile($file)
|
||||
{
|
||||
if(is_array($devicesToken)){
|
||||
$file = file_exists(PATH_CONFIG . $file)?$file:'mobileios.pem';
|
||||
$this->pemFile = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices token to send to
|
||||
* @param array $devicesToken of device tokens to send to
|
||||
*/
|
||||
public function setDevices($devicesToken)
|
||||
{
|
||||
if (is_array($devicesToken)) {
|
||||
$this->devices = $devicesToken;
|
||||
} else {
|
||||
$this->devices = array($devicesToken);
|
||||
@@ -53,27 +66,30 @@ class PushMessageIOS
|
||||
*/
|
||||
public function setSettingNotification()
|
||||
{
|
||||
$conf = \System::getSystemConfiguration( PATH_CONFIG . 'mobile.ini' );
|
||||
$conf = \System::getSystemConfiguration(PATH_CONFIG . 'mobile.ini');
|
||||
$this->setUrl($conf['apple']['url']);
|
||||
$this->setKey($conf['apple']['passphrase']);
|
||||
$this->setPemFile($conf['apple']['pemFile']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message to the device
|
||||
* @param $message the message to send
|
||||
* @return mixed
|
||||
* @param $message string the message to send
|
||||
* @param $data object for payload body
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
function send($message, $data)
|
||||
public function send($message, $data)
|
||||
{
|
||||
if(!is_array($this->devices) || count($this->devices) == 0){
|
||||
if (!is_array($this->devices) || count($this->devices) == 0) {
|
||||
$this->error("No devices set");
|
||||
}
|
||||
if(strlen($this->passphrase) < 8){
|
||||
if (strlen($this->passphrase) < 8) {
|
||||
$this->error("Server API Key not set");
|
||||
}
|
||||
|
||||
$ctx = stream_context_create();
|
||||
stream_context_set_option($ctx, 'ssl', 'local_cert', PATH_CONFIG . 'mobileios.pem');
|
||||
stream_context_set_option($ctx, 'ssl', 'local_cert', PATH_CONFIG . $this->pemFile);
|
||||
stream_context_set_option($ctx, 'ssl', 'passphrase', $this->passphrase);
|
||||
|
||||
// Open a connection to the APNS server
|
||||
@@ -88,7 +104,7 @@ class PushMessageIOS
|
||||
$body['aps'] = array(
|
||||
'alert' => $message,
|
||||
'sound' => 'default',
|
||||
'data' => $data
|
||||
'data' => $data
|
||||
);
|
||||
} else {
|
||||
$body['aps'] = array(
|
||||
@@ -112,7 +128,7 @@ class PushMessageIOS
|
||||
$fp = stream_socket_client($this->url, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
|
||||
|
||||
if (!$fp) {
|
||||
throw (new \Exception( \G::LoadTranslation( 'ID_FAILED' ).': ' ."$err $errstr"));
|
||||
throw (new \Exception(\G::LoadTranslation('ID_FAILED') . ': ' . "$err $errstr"));
|
||||
} else {
|
||||
//echo 'Apple service is online. ' . '<br />';
|
||||
}
|
||||
@@ -138,7 +154,8 @@ class PushMessageIOS
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
function error($msg){
|
||||
public function error($msg)
|
||||
{
|
||||
echo "Android send notification failed with error:";
|
||||
echo "\t" . $msg;
|
||||
}
|
||||
|
||||
@@ -217,48 +217,6 @@ class User
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criteria for User
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param array $arrayUserUidExclude Unique id of Users to exclude
|
||||
*
|
||||
* return object
|
||||
*/
|
||||
public function getUserCriteria($roleUid, array $arrayUserUidExclude = null)
|
||||
{
|
||||
try {
|
||||
$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->addAlias("USR", \RbacUsersPeer::TABLE_NAME);
|
||||
|
||||
$arrayCondition = array();
|
||||
$arrayCondition[] = array(\RbacUsersPeer::USR_UID, "USR.USR_UID", \Criteria::EQUAL);
|
||||
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
||||
|
||||
if ($roleUid != "") {
|
||||
$criteria->addJoin(\UsersRolesPeer::USR_UID, \RbacUsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add("USR.USR_USERNAME", "", \Criteria::NOT_EQUAL);
|
||||
|
||||
if (!is_null($arrayUserUidExclude) && is_array($arrayUserUidExclude)) {
|
||||
$criteria->add(\RbacUsersPeer::USR_UID, $arrayUserUidExclude, \Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of a User from a record
|
||||
*
|
||||
@@ -299,7 +257,11 @@ class User
|
||||
try {
|
||||
$arrayUser = array();
|
||||
|
||||
//Verify data
|
||||
$numRecTotal = 0;
|
||||
|
||||
//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();
|
||||
|
||||
@@ -314,56 +276,89 @@ class User
|
||||
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||
|
||||
//Get data
|
||||
if (!is_null($limit) && $limit . "" == "0") {
|
||||
return $arrayUser;
|
||||
//Set variables
|
||||
$filterName = 'filter';
|
||||
|
||||
if ($flagFilter) {
|
||||
$arrayAux = [
|
||||
'' => 'filter',
|
||||
'LEFT' => 'lfilter',
|
||||
'RIGHT' => 'rfilter'
|
||||
];
|
||||
|
||||
$filterName = $arrayAux[
|
||||
(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''
|
||||
];
|
||||
}
|
||||
|
||||
//SQL
|
||||
//Get data
|
||||
if (!is_null($limit) && (string)($limit) == '0') {
|
||||
return [
|
||||
'total' => $numRecTotal,
|
||||
'start' => (int)((!is_null($start))? $start : 0),
|
||||
'limit' => (int)((!is_null($limit))? $limit : 0),
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
}
|
||||
|
||||
//Query
|
||||
$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->addJoin(\RbacUsersPeer::USR_UID, \UsersRolesPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||
|
||||
$criteria->add(\RbacUsersPeer::USR_USERNAME, '', \Criteria::NOT_EQUAL);
|
||||
|
||||
switch ($option) {
|
||||
case "USERS":
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria($roleUid);
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
|
||||
break;
|
||||
case "AVAILABLE-USERS":
|
||||
//Get Uids
|
||||
$arrayUid = array();
|
||||
|
||||
$criteria = $this->getUserCriteria($roleUid);
|
||||
|
||||
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayUid[] = $row["USR_UID"];
|
||||
}
|
||||
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria("", $arrayUid);
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::NOT_EQUAL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
if ($flagFilter && trim($arrayFilterData['filter']) != '') {
|
||||
$arraySearch = [
|
||||
'' => '%' . $arrayFilterData['filter'] . '%',
|
||||
'LEFT' => $arrayFilterData['filter'] . '%',
|
||||
'RIGHT' => '%' . $arrayFilterData['filter']
|
||||
];
|
||||
|
||||
$search = $arraySearch[
|
||||
(isset($arrayFilterData['filterOption']))? $arrayFilterData['filterOption'] : ''
|
||||
];
|
||||
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_USERNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_FIRSTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_LASTNAME, "%" . $arrayFilterData["filter"] . "%", \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)))
|
||||
);
|
||||
}
|
||||
|
||||
//SQL
|
||||
if (!is_null($sortField) && trim($sortField) != "") {
|
||||
//Number records total
|
||||
$numRecTotal = \RbacUsersPeer::doCount($criteria);
|
||||
|
||||
//Query
|
||||
$conf = new \Configurations();
|
||||
$sortFieldDefault = \RbacUsersPeer::TABLE_NAME . '.' . $conf->userNameFormatGetFirstFieldByUsersTable();
|
||||
|
||||
if (!is_null($sortField) && trim($sortField) != '') {
|
||||
$sortField = strtoupper($sortField);
|
||||
|
||||
if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_STATUS"))) {
|
||||
$sortField = \RbacUsersPeer::TABLE_NAME . "." . $sortField;
|
||||
if (in_array(\RbacUsersPeer::TABLE_NAME . '.' . $sortField, $criteria->getSelectColumns())) {
|
||||
$sortField = \RbacUsersPeer::TABLE_NAME . '.' . $sortField;
|
||||
} else {
|
||||
$sortField = \RbacUsersPeer::USR_USERNAME;
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
} else {
|
||||
$sortField = \RbacUsersPeer::USR_USERNAME;
|
||||
$sortField = $sortFieldDefault;
|
||||
}
|
||||
|
||||
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
|
||||
@@ -390,7 +385,13 @@ class User
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayUser;
|
||||
return [
|
||||
'total' => $numRecTotal,
|
||||
'start' => (int)((!is_null($start))? $start : 0),
|
||||
'limit' => (int)((!is_null($limit))? $limit : 0),
|
||||
$filterName => ($flagFilter)? $arrayFilterData['filter'] : '',
|
||||
'data' => $arrayUser
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -64,8 +64,12 @@ class Department extends Api
|
||||
{
|
||||
try {
|
||||
$oDepartment = new \ProcessMaker\BusinessModel\Department();
|
||||
$response = $oDepartment->getAssignedUser($dep_uid);
|
||||
return $response;
|
||||
|
||||
$response = $oDepartment->getUsers(
|
||||
$dep_uid, 'ASSIGNED', null, null, null, null, null, false
|
||||
);
|
||||
|
||||
return $response['data'];
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
@@ -82,12 +86,16 @@ class Department extends Api
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
public function doGetAvailableUser($dep_uid, $start = 0, $limit = 0, $search = '')
|
||||
public function doGetAvailableUser($dep_uid, $start = null, $limit = null, $search = null)
|
||||
{
|
||||
try {
|
||||
$oDepartment = new \ProcessMaker\BusinessModel\Department();
|
||||
$response = $oDepartment->getAvailableUser($dep_uid, $start, $limit, $search);
|
||||
return $response;
|
||||
|
||||
$response = $oDepartment->getUsers(
|
||||
$dep_uid, 'AVAILABLE', ['filter' => $search, 'filterOption' => ''], null, null, $start, $limit, false
|
||||
);
|
||||
|
||||
return $response['data'];
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ class Light extends Api
|
||||
//return lists
|
||||
'date',
|
||||
'delegateDate',
|
||||
'dueDate'
|
||||
'dueDate',
|
||||
'delRiskDate'
|
||||
];
|
||||
/**
|
||||
* Get list counters
|
||||
|
||||
@@ -38,9 +38,13 @@ class User extends Api
|
||||
public function doGetUsers($rol_uid, $filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$response = $this->roleUser->getUsers($rol_uid, (preg_match("/^.*\/users$/", $this->restler->url))? "USERS" : "AVAILABLE-USERS", array("filter" => $filter), null, null, $start, $limit);
|
||||
$option = (preg_match('/^.*\/users$/', $this->restler->url))? 'USERS' : 'AVAILABLE-USERS';
|
||||
|
||||
return $response;
|
||||
$response = $this->roleUser->getUsers(
|
||||
$rol_uid, $option, ['filter' => $filter, 'filterOption' => ''], null, null, $start, $limit
|
||||
);
|
||||
|
||||
return $response['data'];
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user