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();

View File

@@ -114,20 +114,19 @@ class Department extends Api
}
/**
* @url PUT /:dep_uid/unassign-user/:usr_uid
* @url DELETE /:dep_uid/unassign-user/:usr_uid
*
* @param string $dep_uid {@min 1}{@max 32}
* @param string $usr_uid {@min 1}{@max 32}
*
* @return array
* @status 200
*
*/
public function doPutUnassignUser($dep_uid, $usr_uid)
public function doDeleteUnassignUser($dep_uid, $usr_uid)
{
try {
$oDepartment = new \ProcessMaker\BusinessModel\Department();
$response = $oDepartment->unassignUser($dep_uid, $usr_uid);
return $response;
$oDepartment->unassignUser($dep_uid, $usr_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}