From efe391b3d0a8783f1dc796c3a022fd336cfce118 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 26 Jun 2019 11:10:11 +0100 Subject: [PATCH] FIX #10733 TIME 0:10 WIP admin groups --- src/app/group/controllers/GroupController.php | 7 +++++++ src/app/workflow/controllers/WorkflowController.php | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/group/controllers/GroupController.php b/src/app/group/controllers/GroupController.php index d18941fa69..457e0b16f5 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 b712e661d1..36febebdf5 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; -- GitLab