From 76df8eb1540e2a4e51939f65e6bd196fbaa3e8ce Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 3 Oct 2019 15:34:15 +0200 Subject: [PATCH] FEAT #11274 TIME 1:30 User usefull privileges route + refactoring tags services --- apps/maarch_entreprise/xml/services.xml | 24 ++++ migration/19.12/1912.sql | 3 + modules/tags/xml/services.xml | 112 ------------------ rest/index.php | 9 +- .../resource/controllers/StoreController.php | 3 +- src/app/tag/controllers/TagController.php | 10 +- src/app/user/controllers/UserController.php | 17 +++ src/core/lang/lang-en.php | 4 - src/core/lang/lang-fr.php | 8 +- src/core/lang/lang-nl.php | 4 - 10 files changed, 55 insertions(+), 139 deletions(-) diff --git a/apps/maarch_entreprise/xml/services.xml b/apps/maarch_entreprise/xml/services.xml index 8995e0dd4e6..b733a2cf825 100755 --- a/apps/maarch_entreprise/xml/services.xml +++ b/apps/maarch_entreprise/xml/services.xml @@ -431,4 +431,28 @@ <enabled>true</enabled> <angular>true</angular> </SERVICE> + <SERVICE> + <id>admin_tag</id> + <name>_TAGS</name> + <comment>_ADMIN_TAGS_DESC</comment> + <servicepage>index.php?page=manage_tag_list_controller&module=tags</servicepage> + <servicetype>admin</servicetype> + <category>classement</category> + <system_service>false</system_service> + <style>fa fa-tags</style> + <enabled>true</enabled> + <WHEREAMIUSED> + <page>admin.php</page> + <nature>listelement</nature> + </WHEREAMIUSED> + </SERVICE> + <SERVICE> + <id>manage_tags_application</id> + <name>_MANAGE_TAGS_IN_APPLICATION</name> + <comment>_MANAGE_TAGS_IN_APPLICATION_DESC</comment> + <servicepage></servicepage> + <servicetype>use</servicetype> + <system_service>false</system_service> + <enabled>true</enabled> + </SERVICE> </root> diff --git a/migration/19.12/1912.sql b/migration/19.12/1912.sql index 5953fd36f4f..b52123fbfe9 100644 --- a/migration/19.12/1912.sql +++ b/migration/19.12/1912.sql @@ -294,6 +294,9 @@ DELETE FROM usergroups_services WHERE service_id = 'join_res_case_in_process'; DELETE FROM usergroups_services WHERE service_id = 'close_case'; DELETE FROM usergroups_services WHERE service_id = 'add_cases'; DELETE FROM usergroups_services WHERE service_id IN ('folder_search', 'view_folder_tree', 'select_folder', 'show_history_folder', 'modify_folder', 'associate_folder', 'delete_folder', 'admin_foldertypes', 'create_folder', 'folder_freeze', 'close_folder'); +DELETE FROM usergroups_services WHERE service_id = 'add_tag_to_res'; +DELETE FROM usergroups_services WHERE service_id = 'tag_view'; +UPDATE usergroups_services SET service_id = 'manage_tags_application' WHERE service_id = 'create_tag'; /* REFACTORING MODIFICATION */ diff --git a/modules/tags/xml/services.xml b/modules/tags/xml/services.xml index 518c898b905..c9b80329a45 100755 --- a/modules/tags/xml/services.xml +++ b/modules/tags/xml/services.xml @@ -1,98 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <root> <SERVICE> - <id>admin_tag</id> - <name>_TAGS</name> - <comment>_ADMIN_TAGS_DESC</comment> - <servicepage>index.php?page=manage_tag_list_controller&module=tags</servicepage> - <servicetype>admin</servicetype> - <category>classement</category> - <system_service>false</system_service> - <style>fa fa-tags</style> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>admin.php</page> - <nature>listelement</nature> - </WHEREAMIUSED> - </SERVICE> - - <SERVICE> - <id>tag_view</id> - <name>_TAG_VIEW</name> - <comment>_TAG_VIEW_DESC</comment> - <servicepage>tag_view.php</servicepage> - <servicetype>use</servicetype> - <system_service>false</system_service> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>process.php</page> - <nature>include</nature> - </WHEREAMIUSED> - <WHEREAMIUSED> - <page>index_mlb.php</page> - <nature>include</nature> - </WHEREAMIUSED> - </SERVICE> - - <SERVICE> - <id>create_tag</id> - <name>_CREATE_TAG</name> - <comment>_CREATE_TAG_DESC</comment> - <servicepage>tag_view.php</servicepage> - <servicetype>use</servicetype> - <system_service>false</system_service> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>validation.php</page> - <nature>include</nature> - </WHEREAMIUSED> - <WHEREAMIUSED> - <page>details.php</page> - <nature>include</nature> - </WHEREAMIUSED> - </SERVICE> - - <SERVICE> - <id>add_tag_to_res</id> - <name>_ADD_TAG_TO_RES</name> - <comment>_ADD_TAG_TO_RES_DESC</comment> - <servicepage>tag_controller.php</servicepage> - <servicetype>use</servicetype> - <system_service>false</system_service> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>process.php</page> - <nature>include</nature> - </WHEREAMIUSED> - <WHEREAMIUSED> - <page>validation.php</page> - <nature>include</nature> - </WHEREAMIUSED> <WHEREAMIUSED> - <page>details.php</page> - <nature>include</nature> - </WHEREAMIUSED> - </SERVICE> - <!--<SERVICE> - <id>delete_tag_to_res</id> - <name>_DELETE_TAG_TO_RES</name> - <comment>_DELETE_TAG_TO_RES_DESC</comment> - <servicepage>tag_controller.php</servicepage> - <servicetype>use</servicetype> - <system_service>false</system_service> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>process.php</page> - <nature>include</nature> - </WHEREAMIUSED> - <WHEREAMIUSED> - <page>validation.php</page> - <nature>include</nature> - </WHEREAMIUSED> <WHEREAMIUSED> - <page>details.php</page> - <nature>include</nature> - </WHEREAMIUSED> - </SERVICE>--> - <SERVICE> <id>private_tag</id> <name>_PRIVATE_TAGS</name> <comment>_PRIVATE_TAGS_DESC</comment> @@ -101,24 +9,4 @@ <system_service>false</system_service> <enabled>true</enabled> </SERVICE> - <!--<SERVICE> - <id>new_tags_in_library_rights</id> - <name>_NEW_TAG_IN_LIBRARY_RIGHTS</name> - <comment>_NEW_TAG_IN_LIBRARY_RIGHTS_DESC</comment> - <servicepage>tag_controller.php</servicepage> - <servicetype>use</servicetype> - <system_service>false</system_service> - <enabled>true</enabled> - <WHEREAMIUSED> - <page>process.php</page> - <nature>include</nature> - </WHEREAMIUSED> - <WHEREAMIUSED> - <page>validation.php</page> - <nature>include</nature> - </WHEREAMIUSED> <WHEREAMIUSED> - <page>details.php</page> - <nature>include</nature> - </WHEREAMIUSED> - </SERVICE>--> </root> diff --git a/rest/index.php b/rest/index.php index a45874f1184..43f35d532b9 100755 --- a/rest/index.php +++ b/rest/index.php @@ -291,10 +291,6 @@ $app->delete('/priorities/{id}', \Priority\controllers\PriorityController::class $app->get('/sortedPriorities', \Priority\controllers\PriorityController::class . ':getSorted'); $app->put('/sortedPriorities', \Priority\controllers\PriorityController::class . ':updateSort'); -//Reconciliation -$app->post('/reconciliation/add', \Attachment\controllers\ReconciliationController::class . ':create'); -$app->get('/reconciliation/check', \Attachment\controllers\ReconciliationController::class . ':checkAttachment'); - //Reports $app->get('/reports/groups', \Report\controllers\ReportController::class . ':getGroups'); $app->get('/reports/groups/{groupId}', \Report\controllers\ReportController::class . ':getByGroupId'); @@ -361,11 +357,11 @@ $app->delete('/statuses/{identifier}', \Status\controllers\StatusController::cla $app->get('/administration/statuses/new', \Status\controllers\StatusController::class . ':getNewInformations'); //Tags +$app->get('/tags', \Tag\controllers\TagController::class . ':get'); $app->post('/tags', \Tag\controllers\TagController::class . ':create'); -$app->delete('/tags/{id}', \Tag\controllers\TagController::class . ':delete'); $app->get('/tags/{id}', \Tag\controllers\TagController::class . ':getById'); -$app->get('/tags', \Tag\controllers\TagController::class . ':get'); $app->put('/tags/{id}', \Tag\controllers\TagController::class . ':update'); +$app->delete('/tags/{id}', \Tag\controllers\TagController::class . ':delete'); //Templates $app->get('/templates', \Template\controllers\TemplateController::class . ':get'); @@ -421,6 +417,7 @@ $app->post('/currentUser/emailSignature', \User\controllers\UserController::clas $app->put('/currentUser/emailSignature/{id}', \User\controllers\UserController::class . ':updateCurrentUserEmailSignature'); $app->delete('/currentUser/emailSignature/{id}', \User\controllers\UserController::class . ':deleteCurrentUserEmailSignature'); $app->put('/currentUser/groups/{groupId}/baskets/{basketId}', \User\controllers\UserController::class . ':updateCurrentUserBasketPreferences'); +$app->get('/currentUser/privileges', \User\controllers\UserController::class . ':getPrivileges'); //Notifications $app->get('/notifications', \Notification\controllers\NotificationController::class . ':get'); diff --git a/src/app/resource/controllers/StoreController.php b/src/app/resource/controllers/StoreController.php index 34bc70048b4..14a67c5f6ba 100755 --- a/src/app/resource/controllers/StoreController.php +++ b/src/app/resource/controllers/StoreController.php @@ -78,9 +78,8 @@ class StoreController public static function storeAttachment(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['encodedFile', 'data', 'collId', 'table', 'fileFormat', 'status']); + ValidatorModel::notEmpty($aArgs, ['encodedFile', 'data', 'table', 'fileFormat', 'status']); ValidatorModel::stringType($aArgs, ['collId', 'table', 'fileFormat', 'status']); - ValidatorModel::arrayType($aArgs, ['data']); try { $fileContent = base64_decode(str_replace(['-', '_'], ['+', '/'], $aArgs['encodedFile'])); diff --git a/src/app/tag/controllers/TagController.php b/src/app/tag/controllers/TagController.php index bbd0405a455..8044c209421 100644 --- a/src/app/tag/controllers/TagController.php +++ b/src/app/tag/controllers/TagController.php @@ -24,7 +24,7 @@ class TagController { public function get(Request $request, Response $response) { - if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'tags', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -35,7 +35,7 @@ class TagController public function getById(Request $request, Response $response, array $args) { - if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'tags', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -53,7 +53,7 @@ class TagController public function create(Request $request, Response $response) { - if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'tags', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -80,7 +80,7 @@ class TagController public function update(Request $request, Response $response, array $args) { - if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'tags', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } @@ -116,7 +116,7 @@ class TagController public function delete(Request $request, Response $response, array $args) { - if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'tags', 'type' => 'admin'])) { + if (!ServiceModel::hasService(['id' => 'admin_tag', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) { return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']); } diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index b2dc0e69e2d..cec7cff44d4 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -1321,6 +1321,23 @@ class UserController return $response->withJson(['success' => 'success']); } + public function getPrivileges(Request $request, Response $response) + { + $privileges = [ + 'canManageTags' => false, + 'canUpdateDiffusionRecipientWhileIndexing' => false, + 'canUpdateDiffusionRolesWhileIndexing' => false, + 'canUpdateDiffusionRecipientWhileProcessing' => false, + 'canUpdateDiffusionRolesWhileProcessing' => false + ]; + + if (ServiceModel::hasService(['id' => 'manage_tags_application', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'use'])) { + $privileges['canManageTags'] = true; + } + + return $response->withJson(['privileges' => $privileges]); + } + public function updateCurrentUserBasketPreferences(Request $request, Response $response, array $aArgs) { $data = $request->getParams(); diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index 68a2a95a891..7af52cba9d4 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -265,12 +265,8 @@ define('_GRAPHICS_REPORTS_DESC', 'Display graphical mode in reports'); define("_USE_MAIL_SERVICES", "Use emails services as sender"); define("_USE_MAIL_SERVICES_DESC", "Use emails services as sender"); define("_TAG_DEFAULT", "Tag"); -define("_TAG_VIEW", "View the Tag of the mails"); -define("_TAG_VIEW_DESC", "Allows to view Tag"); define("_CREATE_TAG", "Create Tag"); define("_CREATE_TAG_DESC", "Allows to create Tag not existing in database"); -define("_ADD_TAG_TO_RES", "Associate the available Tag to a mail"); -define("_ADD_TAG_TO_RES_DESC", "Allows to add Tag to a resource"); define("_PRIVATE_TAGS", "Associate Tag to the user's entity (Direction level)"); define("_PRIVATE_TAGS_DESC", "User will only see Tag restricted to user's direction (adding / updating will automatically associate the word to user's direction)."); define("_THESAURUS_VIEW", "Display the thesaurus in the process pages"); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index f5bb00f2333..e86a9a429b5 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -265,12 +265,8 @@ define('_GRAPHICS_REPORTS_DESC', 'Voir le graphique sur l\'écran de statistique define("_USE_MAIL_SERVICES", "Utiliser les courriels de ses services en tant qu'expéditeur"); define("_USE_MAIL_SERVICES_DESC", "Utiliser les courriels de ses services en tant qu'expéditeur"); define("_TAG_DEFAULT", "Mot-clé"); -define("_TAG_VIEW", "Voir les Mots-clé des courriers"); -define("_TAG_VIEW_DESC", "Permet d'afficher le champ Mot-clé depuis les pages d'actions et fiche détaillée."); -define("_CREATE_TAG", "Créer des Mots-clé depuis les pages d'actions"); -define("_CREATE_TAG_DESC", "Permet d'enregistrer à la volée des Mots-clé inexistants dans la base de données"); -define("_ADD_TAG_TO_RES", "Associer des Mots-clé disponibles pour un courrier"); -define("_ADD_TAG_TO_RES_DESC", "Permet d'associer des Mots-clé à un courrier grâce au champ Mot-clé depuis les pages d'actions et fiche détaillée"); +define("_MANAGE_TAGS_IN_APPLICATION", "Créer des mots-clés depuis les pages d'actions"); +define("_MANAGE_TAGS_IN_APPLICATION_DESC", "Créer des mots-clés depuis l'indexation, le traitement et la fiche détaillé"); define("_PRIVATE_TAGS", "Lier les Mots-clé à l'entité de l'utilisateur (Niveau direction)"); define("_PRIVATE_TAGS_DESC", "L'utilisateur ne verra que les Mots-clé qui ont été restreints à sa direction (l'ajout / modification associera le mot clé automatiquement à sa direction)."); define("_THESAURUS_VIEW", "Afficher le thésaurus dans les pages de traitement"); diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php index 5670bc3cd31..d30daf7ce55 100755 --- a/src/core/lang/lang-nl.php +++ b/src/core/lang/lang-nl.php @@ -264,12 +264,8 @@ define('_GRAPHICS_REPORTS_DESC', 'De grafiek op het statistiekscherm bekijken'); define('_USE_MAIL_SERVICES', 'De e-mails van zijn diensten gebruiken als verzender'); define('_USE_MAIL_SERVICES_DESC', 'De e-mails van zijn diensten gebruiken als verzender'); define('_TAG_DEFAULT', 'Sleutelwoord'); -define('_TAG_VIEW', 'De sleutelwoorden van de brieven bekijken'); -define('_TAG_VIEW_DESC', 'Om het veld Sleutelwoord weer te geven vanuit de actiepagina’s en de gedetailleerde fiche.'); define('_CREATE_TAG', 'Sleutelwoorden aanmaken vanuit de actiepagina’s'); define('_CREATE_TAG_DESC', 'Om snel sleutelwoorden op te slaan die niet in de database staan'); -define('_ADD_TAG_TO_RES', 'Beschikbare sleutelwoorden voor een brief koppelen'); -define('_ADD_TAG_TO_RES_DESC', 'Om sleutelwoorden te koppelen aan een brief via het veld Sleutelwoord vanuit de actiepagina’s en de gedetailleerde fiche'); define('_PRIVATE_TAGS', 'De sleutelwoorden verbinden met de eenheid van de gebruiker (Directieniveau)'); define('_PRIVATE_TAGS_DESC', 'De gebruiker zal enkel de sleutelwoorden zien die beperkt werden tot zijn directie (de toevoeging / wijziging zal het sleutelwoord automatisch aan zijn directie koppelen).'); define('_THESAURUS_VIEW', 'De thesaurus weergeven in de verwerkingspagina’s'); -- GitLab