HOR-229-A-301 "Unassign User from a Department..." SOLVED
HOR-229-A-3018 "Unassign User from a Department..." SOLVED
This commit is contained in:
@@ -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
|
* Verify if exists the title of a Department
|
||||||
*
|
*
|
||||||
@@ -253,6 +274,8 @@ class Department
|
|||||||
$dep_uid = Validator::depUid($dep_uid);
|
$dep_uid = Validator::depUid($dep_uid);
|
||||||
$usr_uid = Validator::usrUid($usr_uid);
|
$usr_uid = Validator::usrUid($usr_uid);
|
||||||
|
|
||||||
|
$this->throwExceptionUserNotExistsInDepartment($dep_uid, $usr_uid);
|
||||||
|
|
||||||
$dep = new \Department();
|
$dep = new \Department();
|
||||||
$dep->load( $dep_uid );
|
$dep->load( $dep_uid );
|
||||||
$manager = $dep->getDepManager();
|
$manager = $dep->getDepManager();
|
||||||
|
|||||||
@@ -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 $dep_uid {@min 1}{@max 32}
|
||||||
* @param string $usr_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 {
|
try {
|
||||||
$oDepartment = new \ProcessMaker\BusinessModel\Department();
|
$oDepartment = new \ProcessMaker\BusinessModel\Department();
|
||||||
$response = $oDepartment->unassignUser($dep_uid, $usr_uid);
|
$oDepartment->unassignUser($dep_uid, $usr_uid);
|
||||||
return $response;
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user