Merged in luisfernandosl/processmaker/HOR-229-A-3018 (pull request #3699)

HOR-229-A
This commit is contained in:
Julio Cesar Laura Avendaño
2016-02-12 16:29:21 -04:00
2 changed files with 27 additions and 5 deletions

View File

@@ -50,6 +50,27 @@ class Department
}
}
/**
* Verify if the User is not in a Department
*
* @param string $departmentUid
* @param string $userUid
*
* return void Throw exception user not exists
*/
private function throwExceptionUserNotExistsInDepartment($departmentUid, $userUid)
{
try {
$user = \UsersPeer::retrieveByPK($userUid);
if (is_null($user) || $user->getDepUid() != $departmentUid) {
throw new \Exception(\G::LoadTranslation('ID_USER_NOT_EXIST_DEPARTMENT', [$userUid]));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the title of a Department
*
@@ -253,6 +274,8 @@ class Department
$dep_uid = Validator::depUid($dep_uid);
$usr_uid = Validator::usrUid($usr_uid);
$this->throwExceptionUserNotExistsInDepartment($dep_uid, $usr_uid);
$dep = new \Department();
$dep->load( $dep_uid );
$manager = $dep->getDepManager();