Merge remote-tracking branch 'upstream/3.0.1.8' into 3.0.1.7-Gmail
This commit is contained in:
@@ -250,6 +250,8 @@ class Cases
|
||||
$type = "extjs";
|
||||
$dateFrom = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : "";
|
||||
$dateTo = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";
|
||||
$newerThan = (!empty($dataList['newerThan']))? $dataList['newerThan'] : '';
|
||||
$oldestThan = (!empty($dataList['oldestthan']))? $dataList['oldestthan'] : '';
|
||||
$first = isset( $dataList["first"] ) ? true :false;
|
||||
|
||||
$u = new \ProcessMaker\BusinessModel\User();
|
||||
@@ -291,7 +293,7 @@ class Cases
|
||||
}
|
||||
$dir = G::toUpper($dir);
|
||||
if (!($dir == 'DESC' || $dir == 'ASC')) {
|
||||
$dir = 'DESC';
|
||||
$dir = 'ASC';
|
||||
}
|
||||
if ($process != '') {
|
||||
Validator::proUid($process, '$pro_uid');
|
||||
@@ -383,7 +385,9 @@ class Cases
|
||||
(strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort,
|
||||
$category,
|
||||
true,
|
||||
$paged
|
||||
$paged,
|
||||
$newerThan,
|
||||
$oldestThan
|
||||
);
|
||||
}
|
||||
if (!empty($result['data'])) {
|
||||
|
||||
@@ -91,6 +91,41 @@ class Department
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Department record
|
||||
*
|
||||
* @param string $departmentUid Unique id of 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(
|
||||
$departmentUid,
|
||||
array $arrayVariableNameForException,
|
||||
$throwException = true
|
||||
) {
|
||||
try {
|
||||
$obj = \DepartmentPeer::retrieveByPK($departmentUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_DEPARTMENT_NOT_EXIST', [$arrayVariableNameForException['$departmentUid'], $departmentUid]
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list for Departments
|
||||
*
|
||||
@@ -187,7 +222,7 @@ class Department
|
||||
$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 ) ) ) );
|
||||
$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 );
|
||||
|
||||
@@ -328,6 +328,38 @@ class User
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User record
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @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 User record, ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getUserRecordByPk($userUid, array $arrayVariableNameForException, $throwException = true)
|
||||
{
|
||||
try {
|
||||
$obj = \UsersPeer::retrieveByPK($userUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
if ($throwException) {
|
||||
throw new \Exception(\G::LoadTranslation(
|
||||
'ID_USER_DOES_NOT_EXIST', [$arrayVariableNameForException['$userUid'], $userUid]
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $obj->toArray(\BasePeer::TYPE_FIELDNAME);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of a from a record
|
||||
*
|
||||
@@ -1288,5 +1320,68 @@ class User
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the User's Manager
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @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 string Returns an string with Unique id of User (Manager), ThrowTheException/FALSE otherwise
|
||||
*/
|
||||
public function getUsersManager($userUid, $throwException = true)
|
||||
{
|
||||
try {
|
||||
//Verify data and Set variables
|
||||
$arrayUserData = $this->getUserRecordByPk($userUid, ['$userUid' => '$userUid'], $throwException);
|
||||
|
||||
if ($arrayUserData === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Set variables
|
||||
$department = new \ProcessMaker\BusinessModel\Department();
|
||||
|
||||
//Get Manager
|
||||
if ((string)($arrayUserData['USR_REPORTS_TO']) == '' ||
|
||||
(string)($arrayUserData['USR_REPORTS_TO']) == $userUid
|
||||
) {
|
||||
if ((string)($arrayUserData['DEP_UID']) != '') {
|
||||
$departmentUid = $arrayUserData['DEP_UID'];
|
||||
|
||||
do {
|
||||
$flagd = false;
|
||||
|
||||
$arrayDepartmentData = $department->getDepartmentRecordByPk(
|
||||
$departmentUid, ['$departmentUid' => '$departmentUid'], $throwException
|
||||
);
|
||||
|
||||
if ($arrayDepartmentData === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((string)($arrayDepartmentData['DEP_MANAGER']) == '' ||
|
||||
(string)($arrayDepartmentData['DEP_MANAGER']) == $userUid
|
||||
) {
|
||||
if ((string)($arrayDepartmentData['DEP_PARENT']) != '') {
|
||||
$departmentUid = $arrayDepartmentData['DEP_PARENT'];
|
||||
$flagd = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return $arrayDepartmentData['DEP_MANAGER'];
|
||||
}
|
||||
} while ($flagd);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return $arrayUserData['USR_REPORTS_TO'];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user