From 710e5f38f9656b380f2840187f182bfbd2dc69a0 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Mon, 7 Jan 2019 10:38:44 +0100
Subject: [PATCH] FEAT #8938 change service for editing list diff

---
 apps/maarch_entreprise/actions/process.php    |  5 +--
 .../indexing_searching/details.php            |  6 +---
 modules/entities/difflist_display.php         |  2 +-
 modules/entities/lang/en.php                  |  7 ----
 modules/entities/lang/fr.php                  | 10 ------
 modules/entities/lang/nl.php                  |  9 -----
 modules/entities/load_listinstance.php        |  4 +--
 modules/entities/load_listmodel.php           | 14 ++++----
 modules/entities/show_diffList_tab.php        | 35 ++++++++++++-------
 modules/entities/xml/services.xml             |  8 ++---
 sql/data_en.sql                               | 13 ++++---
 sql/data_fr.sql                               | 13 ++++---
 sql/develop.sql                               | 21 +++++++++++
 src/core/lang/lang-en.php                     |  4 +--
 src/core/lang/lang-fr.php                     |  6 ++--
 src/core/lang/lang-nl.php                     |  4 +--
 16 files changed, 83 insertions(+), 78 deletions(-)

diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php
index b8f27410938..902eaae25ee 100755
--- a/apps/maarch_entreprise/actions/process.php
+++ b/apps/maarch_entreprise/actions/process.php
@@ -603,14 +603,11 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module,
     //DIFFUSION LIST
     if ($core_tools->is_module_loaded('entities')) {
         $category = $data['category_id']['value'];
-        if ($core->test_service('add_copy_in_indexing_validation', 'entities', false)) {
-            $onlyCC = '&only_cc';
-        }
         json_encode($roles);
         $roles_str = json_encode($roles);
         $frm_str .= '<td>';
         $pathScriptTab = $_SESSION['config']['businessappurl']
-                    .'index.php?display=true&page=show_diffList_tab&module=entities&resId='.$res_id.'&collId='.$coll_id.'&category='.$category.'&roles='.urlencode($roles_str).$onlyCC;
+                    .'index.php?display=true&page=show_diffList_tab&module=entities&resId='.$res_id.'&collId='.$coll_id.'&category='.$category.'&roles='.urlencode($roles_str);
         $frm_str .= '<span onclick="loadTab(\''.$res_id.'\',\''.$coll_id.'\',\''._DIFF_LIST_COPY.'\',\''.$pathScriptTab.'\',\'difflist\');return false;" '
             .'onmouseover="this.style.cursor=\'pointer\';" class="categorie" style="width:90%;">';
         $frm_str .= '<span id="difflist_tab" class="tab_module" style="color:#1C99C5;"><i class="fa fa-plus-square"></i></span>'
diff --git a/apps/maarch_entreprise/indexing_searching/details.php b/apps/maarch_entreprise/indexing_searching/details.php
index 7370deb938b..7fd65a6ffbf 100755
--- a/apps/maarch_entreprise/indexing_searching/details.php
+++ b/apps/maarch_entreprise/indexing_searching/details.php
@@ -565,12 +565,8 @@ if ($stmt->rowCount() == 0) {
         $diffList_frame = '';
         $category = $data['category_id']['value'];
 
-        $onlyCC = '';
-        if ($core->test_service('add_copy_in_indexing_validation', 'entities', false) && $_SESSION['user']['UserId'] != 'superadmin') {
-            $onlyCC = '&only_cc';
-        }
         $pathScriptTab = $_SESSION['config']['businessappurl']
-                .'index.php?display=true&page=show_diffList_tab&module=entities&resId='.$s_id.'&collId='.$coll_id.'&fromDetail=true&category='.$category.'&roles='.urlencode($roles_str).$onlyCC;
+                .'index.php?display=true&page=show_diffList_tab&module=entities&resId='.$s_id.'&collId='.$coll_id.'&fromDetail=true&category='.$category.'&roles='.urlencode($roles_str);
 
         $diffList_frame .= '<div class="fa fa-share-alt DetailsTabFunc" id="DetailsGearTab" title="'._DIFF_LIST.'" onclick="loadSpecificTab(\'uniqueDetailsIframe\',\''.$pathScriptTab.'\');tabClicked(\'DetailsGearTab\',true);"></div>';
         echo $diffList_frame;
diff --git a/modules/entities/difflist_display.php b/modules/entities/difflist_display.php
index ddfc664250d..6f912dbdff5 100755
--- a/modules/entities/difflist_display.php
+++ b/modules/entities/difflist_display.php
@@ -62,7 +62,7 @@ foreach ($roles as $role_id => $role_label) {
                 $contentDiffList .= '<td style="width:43%;">'.$user['entity_label'].'</td>';
                 $contentDiffList .= '<td class="movedest" style="width:5%;">';
 
-                if (empty($specific_role) && !empty($difflist['dest']['users'][0]) && $role_id != 'dest' && $origin != null && !$core->test_service('add_copy_in_indexing_validation', 'entities', false)) {
+                if (empty($specific_role) && !empty($difflist['dest']['users'][0]) && $role_id != 'dest' && $origin != null && $core->test_service('edit_recipient_outside_process', 'entities', false)) {
                     $contentDiffList .= '<i class="fa fa-arrow-up" style="cursor:pointer;" title="'._DEST.'" onclick="moveToDest(\''.$user['user_id'].'\',\''.$role_id.'\',\''.$origin.'\');"></i>';
                 }
                 $contentDiffList .= '</td>';
diff --git a/modules/entities/lang/en.php b/modules/entities/lang/en.php
index ef2e05d874d..8c896d2aac8 100755
--- a/modules/entities/lang/en.php
+++ b/modules/entities/lang/en.php
@@ -252,9 +252,6 @@ if (!defined('_NO_DIFF_LIST_ASSOCIATED')) {
 if (!defined('_PRINCIPAL_RECIPIENT')) {
     define('_PRINCIPAL_RECIPIENT', 'Main recipient');
 }
-if (!defined('_ADD_COPY_IN_PROCESS')) {
-    define('_ADD_COPY_IN_PROCESS', 'Add persons on copy in the handling');
-}
 if (!defined('_UPDATE_LIST_DIFF_IN_DETAILS')) {
     define('_UPDATE_LIST_DIFF_IN_DETAILS', 'Update diffusion list from the detailed page');
 }
@@ -617,10 +614,6 @@ if (!defined('_ENTITIES_PRINT_SEP_MLB_GENERIC')) {
 if (!defined('_SELECT_BARCODE_TYPE')) {
     define('_SELECT_BARCODE_TYPE', 'Barecode type');
 }
-if (!defined('_ADD_COPY_IN_INDEXING_VALIDATION')) {
-    define('_ADD_COPY_IN_INDEXING_VALIDATION', 'Forbid recipient modification on the diffusion list');
-}
-
 if (!defined('_DEL_USER_LISTDIFF')) {
     define('_DEL_USER_LISTDIFF', 'Remove the user from the diffusion list');
 }
diff --git a/modules/entities/lang/fr.php b/modules/entities/lang/fr.php
index 87a7eb2d6d3..d87cde600ac 100755
--- a/modules/entities/lang/fr.php
+++ b/modules/entities/lang/fr.php
@@ -252,12 +252,6 @@ if (!defined('_NO_DIFF_LIST_ASSOCIATED')) {
 if (!defined('_PRINCIPAL_RECIPIENT')) {
     define('_PRINCIPAL_RECIPIENT', 'Destinataire principal');
 }
-if (!defined('_ADD_COPY_IN_PROCESS')) {
-    define('_ADD_COPY_IN_PROCESS', 'Ajouter des personnes en copie dans le traitement');
-}
-if (!defined('_UPDATE_LIST_DIFF_IN_DETAILS')) {
-    define('_UPDATE_LIST_DIFF_IN_DETAILS', 'Mettre à jour la liste de diffusion depuis la page de détails');
-}
 if (!defined('_UPDATE_LIST_DIFF')) {
     define('_UPDATE_LIST_DIFF', 'Modifier la liste de diffusion');
 }
@@ -627,10 +621,6 @@ if (!defined('_ENTITIES_PRINT_SEP_MLB_GENERIC')) {
 if (!defined('_SELECT_BARCODE_TYPE')) {
     define('_SELECT_BARCODE_TYPE', 'Type de code à barres');
 }
-if (!defined('_ADD_COPY_IN_INDEXING_VALIDATION')) {
-    define('_ADD_COPY_IN_INDEXING_VALIDATION', "Interdire la modification de l'attributaire dans la liste de diffusion");
-}
-
 if (!defined('_DEL_USER_LISTDIFF')) {
     define('_DEL_USER_LISTDIFF', "Retirer l'utilisateur de la liste de diffusion");
 }
diff --git a/modules/entities/lang/nl.php b/modules/entities/lang/nl.php
index 743aed0b092..64e812dbbf2 100755
--- a/modules/entities/lang/nl.php
+++ b/modules/entities/lang/nl.php
@@ -234,9 +234,6 @@ if (!defined('_NO_DIFF_LIST_ASSOCIATED')) {
 if (!defined('_PRINCIPAL_RECIPIENT')) {
     define('_PRINCIPAL_RECIPIENT', 'Hoofdbestemmeling');
 }
-if (!defined('_ADD_COPY_IN_PROCESS')) {
-    define('_ADD_COPY_IN_PROCESS', 'Personen in kopie toevoegen in de verwerking');
-}
 if (!defined('_UPDATE_LIST_DIFF_IN_DETAILS')) {
     define('_UPDATE_LIST_DIFF_IN_DETAILS', 'De verdelingslijst vanuit de detailpagina’s updaten');
 }
@@ -579,9 +576,6 @@ if (!defined('_ENTITIES_PRINT_SEP_MLB_GENERIC')) {
 if (!defined('_SELECT_BARCODE_TYPE')) {
     define('_SELECT_BARCODE_TYPE', 'Type barcode');
 }
-if (!defined('_ADD_COPY_IN_INDEXING_VALIDATION')) {
-    define('_ADD_COPY_IN_INDEXING_VALIDATION', 'De wijziging van bestemmeling in de verdelingslijst verbieden');
-}
 if (!defined('_DEL_USER_LISTDIFF')) {
     define('_DEL_USER_LISTDIFF', 'De gebruiker van de verdelingslijst halen');
 }
@@ -657,9 +651,6 @@ if (!defined('_CHOOSE_ENTITIES')) {
 if (!defined('_ENTITIES_PRINT_SEP_MLB')) {
     define('_ENTITIES_PRINT_SEP_MLB', 'De separatoren per eenheid afdrukken');
 }
-if (!defined('_ADD_COPY_IN_INDEXING_VALIDATION')) {
-    define('_ADD_COPY_IN_INDEXING_VALIDATION', 'De wijziging van de toegekende persoon in de verdelingslijst verbieden');
-}
 if (!defined('_ARCHIVAL_AGENCY')) {
     define('_ARCHIVAL_AGENCY', 'Archiefeenheid');
 }
diff --git a/modules/entities/load_listinstance.php b/modules/entities/load_listinstance.php
index c4e7302b467..fce5a006276 100755
--- a/modules/entities/load_listinstance.php
+++ b/modules/entities/load_listinstance.php
@@ -59,8 +59,8 @@ $specific_role = $_REQUEST['specific_role'];
 
 $onlyCC = false;
 
-if (($core->test_service('add_copy_in_process', 'entities', false) && $_REQUEST['origin'] == 'process')
-    || ($core->test_service('add_copy_in_indexing_validation', 'entities', false) && ($_REQUEST['origin'] == 'indexing' || $_REQUEST['origin'] == 'redirect'))) {
+if ((!$core->test_service('edit_recipient_in_process', 'entities', false) && $_REQUEST['origin'] == 'process')
+    || (!$core->test_service('edit_recipient_outside_process', 'entities', false) && ($_REQUEST['origin'] == 'indexing' || $_REQUEST['origin'] == 'redirect'))) {
     $onlyCC = true;
 }
 
diff --git a/modules/entities/load_listmodel.php b/modules/entities/load_listmodel.php
index 096ddbb5e31..abf0068cd54 100755
--- a/modules/entities/load_listmodel.php
+++ b/modules/entities/load_listmodel.php
@@ -30,7 +30,7 @@ if ($objectId <> '') {
     $_SESSION[$origin]['difflist_object']['object_id'] = $objectId;
     if ($objectType == 'entity_id') {
         $query = "SELECT entity_label FROM entities WHERE entity_id = ?";
-        $stmt = $db->query($query,array($objectId));
+        $stmt = $db->query($query, array($objectId));
         $res = $stmt->fetchObject();
         if ($res->entity_label <> '') {
             $_SESSION[$origin]['difflist_object']['object_label'] = $res->entity_label;
@@ -41,13 +41,13 @@ if ($objectId <> '') {
 // Fill session with listmodel
 $_SESSION[$origin]['diff_list'] = $diffList->get_listmodel($objectType, $objectId);
 //Permet de bloquer la liste diffusion avec celle de l'utilisateur qui enregistre le courrier.
-if($category == 'outgoing' && $origin == 'indexing' && $objectId == $_SESSION['user']['primaryentity']['id']){
+if ($category == 'outgoing' && $origin == 'indexing' && $objectId == $_SESSION['user']['primaryentity']['id']) {
     $_SESSION[$origin]['diff_list']['dest']['users'] = array();
 
     //Get the right primary entity
     $primaryEntityId = $_SESSION['user']['primaryentity']['id'];
-    foreach($_SESSION['user']['entities'] as $entity){
-        if($entity['ENTITY_ID']==$primaryEntityId){
+    foreach ($_SESSION['user']['entities'] as $entity) {
+        if ($entity['ENTITY_ID']==$primaryEntityId) {
             $primaryEntityLabel = $entity['ENTITY_LABEL'];
         }
     }
@@ -74,7 +74,7 @@ $content = '';
 if (! $onlyCC) {
     if (isset($_SESSION['validStep']) && $_SESSION['validStep'] == 'ok') {
         $content .= "";
-    } 
+    }
 }
 
 # Get content from buffer of difflist_display 
@@ -86,7 +86,7 @@ ob_end_clean();
 $labelButton = _UPDATE_LIST_DIFF;
 $arg = '&mode=up';
 
-if( $core->test_service('add_copy_in_indexing_validation', 'entities', false) && $origin == 'indexing' ){
+if (!$core->test_service('edit_recipient_outside_process', 'entities', false) && $origin == 'indexing') {
     $onlyCC = true;
 }
 
@@ -103,6 +103,6 @@ $content_standard .= '<small><input type="button" style="margin-top:0px;" class=
          . 'resizable=yes,width=1280,height=800,location=no\');"/></small>';
 $content_standard .= '</span></center>';
 
-echo "{status : 0, div_content : '" . addslashes($content_standard . $content . '<br>') 
+echo "{status : 0, div_content : '" . addslashes($content_standard . $content . '<br>')
     . "', div_content_action : '" . addslashes($content) . "'}";
 exit();
diff --git a/modules/entities/show_diffList_tab.php b/modules/entities/show_diffList_tab.php
index 6d701c689ba..073e8255b51 100755
--- a/modules/entities/show_diffList_tab.php
+++ b/modules/entities/show_diffList_tab.php
@@ -1,14 +1,21 @@
 <?php
+/**
+* Copyright Maarch since 2008 under licence GPLv3.
+* See LICENCE.txt file at the root folder for more details.
+* This file is part of Maarch software.
+
+*
+* @brief   show_diffList_tab
+*
+* @author  dev <dev@maarch.org>
+* @ingroup entities
+*/
 
 $s_id = $_REQUEST['resId'];
 $category = $_REQUEST['category'];
 $coll_id = $_REQUEST['collId'];
 
-if (isset($_REQUEST['only_cc'])) {
-    $onlyCC = '&only_cc';
-} else {
-    $onlyCC = '';
-}
+$onlyCC = '';
 $roles = json_decode(urldecode($_REQUEST['roles']));
 
 require_once 'core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_request.php';
@@ -34,7 +41,10 @@ if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == true) {
 }
 
 if ($from_detail == true) {
-    if ($core_tools->test_service('update_list_diff_in_details', 'entities', false) || $core_tools->test_service('add_copy_in_indexing_validation', 'entities', false)) {
+    if ($core_tools->test_service('update_list_diff_in_details', 'entities', false)) {
+        if (!$core->test_service('edit_recipient_outside_process', 'entities', false)) {
+            $onlyCC = '&only_cc';
+        }
         $frm_str .= '<br />';
         $frm_str .= '<div style="text-align:center;">';
 
@@ -49,13 +59,14 @@ if ($from_detail == true) {
     }
     $difflist = $_SESSION['details']['diff_list'];
 } else {
-    if ($core_tools->test_service('add_copy_in_process', 'entities', false)) {
-        $frm_str .= '<div style="text-align:center;"><input type="button" class="button" title="'._UPDATE_LIST_DIFF.'" value="'._UPDATE_LIST_DIFF.'" onclick="window.open(\''
-                .$_SESSION['config']['businessappurl']
-                .'index.php?display=true&module=entities&cat='.$category.'&page=manage_listinstance'
-                .'&origin=process'.$onlyCC.'\', \'\', \'scrollbars=yes,menubar=no,'
-                .'toolbar=no,status=no,resizable=yes,width=1024,height=650,location=no\');" /></div>';
+    if (!$core->test_service('edit_recipient_in_process', 'entities', false)) {
+        $onlyCC = '&only_cc';
     }
+    $frm_str .= '<div style="text-align:center;"><input type="button" class="button" title="'._UPDATE_LIST_DIFF.'" value="'._UPDATE_LIST_DIFF.'" onclick="window.open(\''
+            .$_SESSION['config']['businessappurl']
+            .'index.php?display=true&module=entities&cat='.$category.'&page=manage_listinstance'
+            .'&origin=process'.$onlyCC.'\', \'\', \'scrollbars=yes,menubar=no,'
+            .'toolbar=no,status=no,resizable=yes,width=1024,height=650,location=no\');" /></div>';
     // Get content from buffer of difflist_display
     $difflist = $_SESSION['process']['diff_list'];
 }
diff --git a/modules/entities/xml/services.xml b/modules/entities/xml/services.xml
index 76dca67ccf7..7073770447a 100755
--- a/modules/entities/xml/services.xml
+++ b/modules/entities/xml/services.xml
@@ -103,8 +103,8 @@
         </WHEREAMIUSED>
     </SERVICE>
     <SERVICE>
-        <id>add_copy_in_process</id>
-        <name>_ADD_COPY_IN_PROCESS</name>
+        <id>edit_recipient_in_process</id>
+        <name>_EDIT_RECIPIENT_IN_PROCESS</name>
         <servicepage>add_copy_in_process.php</servicepage>
         <servicetype>use</servicetype>
         <system_service>false</system_service>
@@ -115,8 +115,8 @@
         </WHEREAMIUSED>
     </SERVICE>
     <SERVICE>
-        <id>add_copy_in_indexing_validation</id>
-        <name>_ADD_COPY_IN_INDEXING_VALIDATION</name>
+        <id>edit_recipient_outside_process</id>
+        <name>_EDIT_RECIPIENT_OUTSIDE_PROCESS</name>
         <servicepage>load_listinstance.php</servicepage>
         <servicetype>use</servicetype>
         <system_service>false</system_service>
diff --git a/sql/data_en.sql b/sql/data_en.sql
index 853494be354..72690e46443 100644
--- a/sql/data_en.sql
+++ b/sql/data_en.sql
@@ -66,9 +66,9 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'clos
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'modify_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'folder_freeze');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'delete_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'add_copy_in_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'entities_print_sep_mlb');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'use_mail_services');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'reports');
@@ -107,11 +107,11 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_cas
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_copy_in_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'use_mail_services');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'edit_attachments_from_detail');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'modify_attachments');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'delete_attachments');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_new_version');
@@ -150,7 +150,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER',
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'use_mail_services');
@@ -184,7 +185,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'a
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'use_mail_services');
@@ -255,7 +257,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'manage_entities');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'admin_difflist_types');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'admin_listmodels');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'entities_print_sep_mlb');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'sendmail');
diff --git a/sql/data_fr.sql b/sql/data_fr.sql
index 5a8322ae446..3028c9fc709 100755
--- a/sql/data_fr.sql
+++ b/sql/data_fr.sql
@@ -66,9 +66,9 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'clos
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'modify_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'folder_freeze');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'delete_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'add_copy_in_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'entities_print_sep_mlb');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'use_mail_services');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'reports');
@@ -107,11 +107,11 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_cas
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_copy_in_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'use_mail_services');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'edit_attachments_from_detail');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'modify_attachments');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'delete_attachments');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('AGENT', 'add_new_version');
@@ -150,7 +150,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER',
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESP_COURRIER', 'use_mail_services');
@@ -184,7 +185,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'a
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'view_folder_tree');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'create_folder');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'associate_folder');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'sendmail');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('RESPONSABLE', 'use_mail_services');
@@ -255,7 +257,8 @@ INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'manage_entities');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'admin_difflist_types');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'admin_listmodels');
-INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'add_copy_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'edit_recipient_in_process');
+INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'edit_recipient_outside_process');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'update_list_diff_in_details');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'entities_print_sep_mlb');
 INSERT INTO usergroups_services (group_id, service_id) VALUES ('ADMINISTRATEUR_N1', 'sendmail');
diff --git a/sql/develop.sql b/sql/develop.sql
index 41f56bbe193..335405ebfa2 100755
--- a/sql/develop.sql
+++ b/sql/develop.sql
@@ -76,3 +76,24 @@ send_date timestamp without time zone,
 CONSTRAINT emails_pkey PRIMARY KEY (id)
 )
 WITH (OIDS=FALSE);
+
+
+DO $$ BEGIN
+  IF (SELECT count(group_id) FROM usergroups_services WHERE service_id IN ('edit_recipient_in_process', 'edit_recipient_outside_process')) = 0 THEN
+    INSERT INTO usergroups_services (group_id, service_id) 
+    SELECT group_id, 'edit_recipient_in_process' FROM usergroups WHERE group_id NOT IN (
+      SELECT group_id
+      FROM usergroups_services 
+      WHERE service_id = 'add_copy_in_process'
+    );
+
+    INSERT INTO usergroups_services (group_id, service_id) 
+    SELECT group_id, 'edit_recipient_outside_process' FROM usergroups WHERE group_id NOT IN (
+      SELECT group_id
+      FROM usergroups_services 
+      WHERE service_id = 'add_copy_in_indexing_validation'
+    );
+
+    DELETE FROM usergroups_services WHERE service_id in ('add_copy_in_process', 'add_copy_in_indexing_validation');
+  END IF;
+END$$;
diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php
index 85b9b8e069d..ac5dd47acf5 100755
--- a/src/core/lang/lang-en.php
+++ b/src/core/lang/lang-en.php
@@ -363,8 +363,8 @@ define("_JOIN_RES_CASE_IN_PROCESS", "Link mails to cases (handling basket)");
 define("_CLOSE_CASE", "Enclose cases");
 define("_ADD_CASES", "Create cases");
 define('_CHOOSE_ENTITY', 'Choose a department');
-define('_ADD_COPY_IN_PROCESS', 'Add persons on copy in the handling');
-define('_ADD_COPY_IN_INDEXING_VALIDATION', 'Forbid recipient modification on the diffusion list');
+define('_EDIT_RECIPIENT_IN_PROCESS', 'Edit recipient in the handling');
+define('_EDIT_RECIPIENT_OUTSIDE_PROCESS', 'Edit recipient on the diffusion list');
 define('_UPDATE_LIST_DIFF_IN_DETAILS', 'Update diffusion list from the detailed page');
 define('_ENTITIES_PRINT_SEP_MLB', 'Print limiters by department/services');
 define("_EXPORT_SEDA_VIEW", "See message export");
diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php
index 96f6b976cfe..7b0fd4bc173 100755
--- a/src/core/lang/lang-fr.php
+++ b/src/core/lang/lang-fr.php
@@ -365,9 +365,9 @@ define("_JOIN_RES_CASE_IN_PROCESS", "Attacher des courriers aux affaires (bannet
 define("_CLOSE_CASE", "Clôturer des affaires");
 define("_ADD_CASES", "Créer des affaires");
 define('_CHOOSE_ENTITY', 'Choisissez une entité');
-define('_ADD_COPY_IN_PROCESS', 'Ajouter des personnes en copie dans le traitement');
-define('_ADD_COPY_IN_INDEXING_VALIDATION', "Interdire la modification de l'attributaire dans la liste de diffusion");
-define('_UPDATE_LIST_DIFF_IN_DETAILS', 'Mettre à jour la liste de diffusion depuis la page de détails');
+define('_EDIT_RECIPIENT_IN_PROCESS', 'Modifier l\'attributaire dans le traitement');
+define('_EDIT_RECIPIENT_OUTSIDE_PROCESS', "Modifier l'attributaire dans la liste de diffusion (hors traitement)");
+define('_UPDATE_LIST_DIFF_IN_DETAILS', 'Mettre à jour la liste de diffusion depuis la fiche détaillée');
 define('_ENTITIES_PRINT_SEP_MLB', 'Imprimer des séparateurs par service');
 define('_EXPORT_SEDA_VIEW', 'Voir le bordereau');
 define('_PUT_DOC_IN_FILEPLAN', 'Classer des documents');
diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php
index 0498e698bf7..b779943fc91 100644
--- a/src/core/lang/lang-nl.php
+++ b/src/core/lang/lang-nl.php
@@ -352,8 +352,8 @@ define('_JOIN_RES_CASE_IN_PROCESS', 'Brieven aan de zaken koppelen (verwerkingsb
 define('_CLOSE_CASE', 'Zaken afsluiten');
 define('_ADD_CASES', 'Zaken aanmaken');
 define('_CHOOSE_ENTITY', 'Kies een eenheid');
-define('_ADD_COPY_IN_PROCESS', 'Personen in kopie toevoegen in de verwerking');
-define('_ADD_COPY_IN_INDEXING_VALIDATION', 'De wijziging van de toegekende persoon in de verdelingslijst verbieden');
+define('_EDIT_RECIPIENT_IN_PROCESS', '_TO_TRANSLATE in de verwerking');
+define('_EDIT_RECIPIENT_OUTSIDE_PROCESS', '_TO_TRANSLATE in de verdelingslijst verbieden');
 define('_UPDATE_LIST_DIFF_IN_DETAILS', 'De verdelingslijst vanuit de detailpagina’s updaten');
 define('_ENTITIES_PRINT_SEP_MLB', 'De separatoren per dienst afdrukken');
 define('_EXPORT_SEDA_VIEW', 'Zie het borderel');
-- 
GitLab