diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php index d18941fa69c92a3d9d43bd36fd19d70a8baa8450..457e0b16f5761850cf18a9dfb493c004df9098d1 100755 --- a/src/app/group/controllers/GroupController.php +++ b/src/app/group/controllers/GroupController.php @@ -56,6 +56,8 @@ class GroupController 'select' => ['users.id', 'users.firstname', 'users.lastname'] ]); + $group['privileges'] = PrivilegeController::PRIVILEGES; + return $response->withJson(['group' => $group]); } @@ -139,6 +141,11 @@ class GroupController return $response->withStatus(400)->withJson(['errors' => 'Group not found']); } + $groupCount = GroupModel::get(['select' => ['count(*) as nb']]); + if ($groupCount[0]['nb'] == 0) { + return $response->withStatus(400)->withJson(['errors' => 'This is the last group']); + } + UserGroupModel::delete(['where' => ['group_id = ?'], 'data' => [$aArgs['id']]]); GroupPrivilegeModel::delete(['where' => ['group_id = ?'], 'data' => [$aArgs['id']]]); GroupModel::delete(['where' => ['id = ?'], 'data' => [$aArgs['id']]]); diff --git a/src/app/workflow/controllers/WorkflowController.php b/src/app/workflow/controllers/WorkflowController.php index b712e661d12b1e0948211313624c7c8fd8edb628..36febebdf58bba8eba9506e59a985b12eba85b9e 100755 --- a/src/app/workflow/controllers/WorkflowController.php +++ b/src/app/workflow/controllers/WorkflowController.php @@ -18,7 +18,6 @@ use Document\controllers\DocumentController; use Group\controllers\PrivilegeController; use Slim\Http\Request; use Slim\Http\Response; -use User\controllers\UserController; use User\models\UserModel; use Workflow\models\WorkflowModel;