diff --git a/composer.json b/composer.json index dee2afac1ddc608f1fe1f5cf8146cb3b31dd9256..33826fbfddf735eaa01d244f12a02c4f6bb7d6d5 100755 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "Doctype\\" : "src/app/doctype/", "Entity\\" : "src/app/entity/", "Folder\\" : "src/app/folder/", + "Group\\" : "src/app/group/", "History\\" : "src/app/history/", "Link\\" : "src/app/link/", "Notification\\" : "src/app/notification/", diff --git a/core/Controllers/UserController.php b/core/Controllers/UserController.php index c0c381aa9dc676cc4bff25c8ba8c811df5cb374f..ef67171d1113ec54c1f1269258fad4657b84a10a 100755 --- a/core/Controllers/UserController.php +++ b/core/Controllers/UserController.php @@ -16,12 +16,12 @@ namespace Core\Controllers; use Basket\models\BasketModel; -use Core\Models\GroupModel; use Core\Models\SecurityModel; use Core\Models\ServiceModel; use Core\Models\UserModel; use Entities\Models\ListModelsModel; use Entity\models\EntityModel; +use Group\models\GroupModel; use History\controllers\HistoryController; use History\models\HistoryModel; use Psr\Http\Message\RequestInterface; diff --git a/rest/index.php b/rest/index.php index 3088f352f43b75fb57659755e8c8f2dcaef39000..042de9583f3ae7f037daf13de754c05362855e6b 100755 --- a/rest/index.php +++ b/rest/index.php @@ -138,14 +138,14 @@ $app->delete('/statuses/{identifier}', \Status\controllers\StatusController::cla $app->get('/administration/statuses/new', \Status\controllers\StatusController::class . ':getNewInformations'); //groups -$app->get('/groups', \Core\Controllers\GroupController::class . ':get'); -$app->post('/groups', \Core\Controllers\GroupController::class . ':create'); -$app->get('/groups/{id}', \Core\Controllers\GroupController::class . ':getById'); -$app->put('/groups/{id}', \Core\Controllers\GroupController::class . ':update'); -$app->delete('/groups/{id}', \Core\Controllers\GroupController::class . ':delete'); -$app->get('/groups/{id}/details', \Core\Controllers\GroupController::class . ':getDetailledById'); -$app->put('/groups/{id}/services/{serviceId}', \Core\Controllers\GroupController::class . ':updateService'); -$app->put('/groups/{id}/reassign/{newGroupId}', \Core\Controllers\GroupController::class . ':reassignUsers'); +$app->get('/groups', \Group\controllers\GroupController::class . ':get'); +$app->post('/groups', \Group\controllers\GroupController::class . ':create'); +$app->get('/groups/{id}', \Group\controllers\GroupController::class . ':getById'); +$app->put('/groups/{id}', \Group\controllers\GroupController::class . ':update'); +$app->delete('/groups/{id}', \Group\controllers\GroupController::class . ':delete'); +$app->get('/groups/{id}/details', \Group\controllers\GroupController::class . ':getDetailledById'); +$app->put('/groups/{id}/services/{serviceId}', \Group\controllers\GroupController::class . ':updateService'); +$app->put('/groups/{id}/reassign/{newGroupId}', \Group\controllers\GroupController::class . ':reassignUsers'); //Docservers $app->get('/docservers', \Docserver\controllers\DocserverController::class . ':get'); @@ -207,7 +207,9 @@ $app->put('/currentUser/groups/{groupId}/baskets/{basketId}', \Core\Controllers\ //Entities $app->get('/entities', \Entity\controllers\EntityController::class . ':get'); +$app->post('/entities', \Entity\controllers\EntityController::class . ':create'); $app->get('/entities/{id}', \Entity\controllers\EntityController::class . ':getById'); +$app->put('/entities/{id}', \Entity\controllers\EntityController::class . ':update'); $app->delete('/entities/{id}', \Entity\controllers\EntityController::class . ':delete'); $app->get('/entities/{id}/details', \Entity\controllers\EntityController::class . ':getDetailledById'); $app->put('/entities/{id}/reassign/{newEntityId}', \Entity\controllers\EntityController::class . ':reassignEntity'); diff --git a/src/app/basket/controllers/BasketController.php b/src/app/basket/controllers/BasketController.php index 598bcd571aa3fac0eda4e5af31d749ba42f6bcc1..ce9998d9886928f5944d176a90a71154117c399f 100644 --- a/src/app/basket/controllers/BasketController.php +++ b/src/app/basket/controllers/BasketController.php @@ -16,9 +16,9 @@ namespace Basket\controllers; use Basket\models\BasketModel; use Action\models\ActionModel; -use Core\Models\GroupModel; use Core\Models\ServiceModel; use Core\Models\ValidatorModel; +use Group\models\GroupModel; use History\controllers\HistoryController; use Respect\Validation\Validator; use Slim\Http\Request; diff --git a/core/Controllers/GroupController.php b/src/app/group/controllers/GroupController.php similarity index 87% rename from core/Controllers/GroupController.php rename to src/app/group/controllers/GroupController.php index cbbab074d50730ff5143da39bddd852550555763..29d4ecc18744c9f374e6764ac0fa1a9d61d56f5a 100644 --- a/core/Controllers/GroupController.php +++ b/src/app/group/controllers/GroupController.php @@ -1,11 +1,9 @@ <?php -namespace Core\Controllers; +namespace Group\controllers; -use Core\Models\GroupModel; use Core\Models\ServiceModel; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; +use Group\models\GroupModel; use Respect\Validation\Validator; use Slim\Http\Request; use Slim\Http\Response; @@ -52,7 +50,6 @@ class GroupController $check = Validator::stringType()->notEmpty()->validate($data['group_id']) && preg_match("/^[\w-]*$/", $data['group_id']) && (strlen($data['group_id']) < 32); $check = $check && Validator::stringType()->notEmpty()->validate($data['group_desc']); $check = $check && Validator::stringType()->notEmpty()->validate($data['security']['where_clause']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['security']['maarch_comment']); if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } @@ -76,9 +73,9 @@ class GroupController return $response->withJson(['group' => $group['id']]); } - public function update(RequestInterface $request, ResponseInterface $response, $aArgs) + public function update(Request $request, Response $response, array $aArgs) { - if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -90,7 +87,6 @@ class GroupController $data = $request->getParams(); $check = Validator::stringType()->notEmpty()->validate($data['description']); $check = $check && Validator::stringType()->notEmpty()->validate($data['security']['where_clause']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['security']['maarch_comment']); if (!$check) { return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); } @@ -104,9 +100,9 @@ class GroupController return $response->withJson(['success' => 'success']); } - public function delete(RequestInterface $request, ResponseInterface $response, $aArgs) + public function delete(Request $request, Response $response, array $aArgs) { - if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -143,9 +139,9 @@ class GroupController return $response->withJson(['group' => $group]); } - public function updateService(RequestInterface $request, ResponseInterface $response, $aArgs) + public function updateService(Request $request, Response $response, array $aArgs) { - if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -165,9 +161,9 @@ class GroupController return $response->withJson(['success' => 'success']); } - public function reassignUsers(RequestInterface $request, ResponseInterface $response, $aArgs) + public function reassignUsers(Request $request, Response $response, array $aArgs) { - if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $_SESSION['user']['UserId'], 'location' => 'apps', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } diff --git a/core/Models/GroupModel.php b/src/app/group/models/GroupModel.php old mode 100755 new mode 100644 similarity index 78% rename from core/Models/GroupModel.php rename to src/app/group/models/GroupModel.php index 6555941bf51eea9dc09231a02996a356c2fa1776..43d868d7a1ada1b0a235ff32245b630635838293 --- a/core/Models/GroupModel.php +++ b/src/app/group/models/GroupModel.php @@ -10,12 +10,10 @@ /** * @brief Group Model * @author dev@maarch.org -* @ingroup core */ -namespace Core\Models; +namespace Group\models; class GroupModel extends GroupModelAbstract { - // Do your stuff in this class } diff --git a/core/Models/GroupModelAbstract.php b/src/app/group/models/GroupModelAbstract.php old mode 100755 new mode 100644 similarity index 97% rename from core/Models/GroupModelAbstract.php rename to src/app/group/models/GroupModelAbstract.php index d712b4402e0d2a948105f67393274ca8a898820b..f3478ab4f4e498c546f29dccb39824302e9cbfc1 --- a/core/Models/GroupModelAbstract.php +++ b/src/app/group/models/GroupModelAbstract.php @@ -10,12 +10,14 @@ /** * @brief Group Model * @author dev@maarch.org -* @ingroup core */ -namespace Core\Models; +namespace Group\models; +use Core\Models\ServiceModel; +use Core\Models\UserModel; use SrcCore\models\DatabaseModel; +use SrcCore\models\ValidatorModel; class GroupModelAbstract { @@ -64,7 +66,7 @@ class GroupModelAbstract public static function create(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['groupId', 'description', 'clause', 'comment']); + ValidatorModel::notEmpty($aArgs, ['groupId', 'description', 'clause']); ValidatorModel::stringType($aArgs, ['groupId', 'description', 'clause', 'comment']); DatabaseModel::insert([ @@ -91,7 +93,7 @@ class GroupModelAbstract public static function update(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['id', 'description', 'clause', 'comment']); + ValidatorModel::notEmpty($aArgs, ['id', 'description', 'clause']); ValidatorModel::stringType($aArgs, ['id', 'description', 'clause', 'comment']); DatabaseModel::update([ @@ -225,7 +227,7 @@ class GroupModelAbstract return $aData[0]; } - public static function getServiceById(array $aArgs = []) + public static function getServiceById(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['groupId', 'serviceId']); ValidatorModel::stringType($aArgs, ['groupId', 'serviceId']); @@ -240,7 +242,7 @@ class GroupModelAbstract return $service; } - public static function getServicesById(array $aArgs = []) + public static function getServicesById(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['groupId']); ValidatorModel::stringType($aArgs, ['groupId']); @@ -255,12 +257,11 @@ class GroupModelAbstract return $aServices; } - public static function getAllServicesByGroupId(array $aArgs = []) + public static function getAllServicesByGroupId(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['groupId']); ValidatorModel::stringType($aArgs, ['groupId']); - $rawCheckedServices = GroupModel::getServicesById(['groupId' => $aArgs['groupId']]); $checkedServices = []; foreach ($rawCheckedServices as $value) { diff --git a/src/app/report/controllers/ReportController.php b/src/app/report/controllers/ReportController.php index 86fdd3b5659f70a25e40b6f406bf7a09c71ebc25..c2326b2c1e74fa562070fbb9daa1ee7eb39ef7a7 100644 --- a/src/app/report/controllers/ReportController.php +++ b/src/app/report/controllers/ReportController.php @@ -14,8 +14,8 @@ namespace Report\controllers; -use Core\Models\GroupModel; use Core\Models\ServiceModel; +use Group\models\GroupModel; use History\controllers\HistoryController; use Report\models\ReportModel; use Slim\Http\Request;