Merge branch '106-allow-super-admin-to-do-rider-assignment-regardless-of-locking' into 'master'
Resolve "Allow super admin to do rider assignment regardless of locking" Closes #106 See merge request jankstudio/resq!88
This commit is contained in:
commit
d7f4f30cc0
1 changed files with 25 additions and 17 deletions
|
|
@ -1024,27 +1024,35 @@ class JobOrderController extends BaseController
|
|||
throw $this->createNotFoundException('The job order does not have an assigning status');
|
||||
}
|
||||
|
||||
// check if hub is assigned to current user
|
||||
$user_hubs = $this->getUser()->getHubs();
|
||||
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
||||
{
|
||||
$em->getConnection()->rollback();
|
||||
throw $this->createNotFoundException('The job order is not on a hub assigned to this user');
|
||||
}
|
||||
|
||||
// check if we are the assignor
|
||||
$assignor = $obj->getAssignedBy();
|
||||
// check if super user
|
||||
$user = $this->getUser();
|
||||
|
||||
if ($assignor != null && $assignor->getID() != $user->getID())
|
||||
if ($user->isSuperAdmin())
|
||||
{
|
||||
$em->getConnection()->rollback();
|
||||
throw $this->createAccessDeniedException('Not the assignor');
|
||||
// do nothing, just allow page to be accessed
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if hub is assigned to current user
|
||||
$user_hubs = $this->getUser()->getHubs();
|
||||
if (!in_array($obj->getHub()->getID(), $user_hubs))
|
||||
{
|
||||
$em->getConnection()->rollback();
|
||||
throw $this->createNotFoundException('The job order is not on a hub assigned to this user');
|
||||
}
|
||||
|
||||
// make this user be the assignor
|
||||
$obj->setAssignedBy($user);
|
||||
$em->flush();
|
||||
// check if we are the assignor
|
||||
$assignor = $obj->getAssignedBy();
|
||||
|
||||
if ($assignor != null && $assignor->getID() != $user->getID())
|
||||
{
|
||||
$em->getConnection()->rollback();
|
||||
throw $this->createAccessDeniedException('Not the assignor');
|
||||
}
|
||||
|
||||
// make this user be the assignor
|
||||
$obj->setAssignedBy($user);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
$em->getConnection()->commit();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue