diff --git a/inc/rgpdtools.class.php b/inc/rgpdtools.class.php index 8910414..211d81a 100644 --- a/inc/rgpdtools.class.php +++ b/inc/rgpdtools.class.php @@ -137,10 +137,11 @@ public static function generateExport($POST) { self::injectRowHeader($spreadsheet, $objectInfos, 'User'); self::injectRowValues($spreadsheet, $objectInfos, 2, 'User'); + $itemTypes = $POST['itemTypes']; // récupération des éléments associés au user - $allUsedItems = self::getAllUsedItemsForUser($userID); + $allUsedItems = self::getAllUsedItemsForUser($userID, $itemTypes); // pour chaque élément séléctionné ajout d'un onglet - $itemTypes = $POST['itemTypes']; + foreach ($itemTypes as $itemType) { $nbWorkSheet++; $new_ws = new Worksheet($spreadsheet, $itemType); @@ -188,10 +189,9 @@ public static function deleteUploadedDocuments($POST) { private static function displayTabContentForUser(User $item) { $users_id = $item->getField('id'); - $itemsTypes = self::getUserAssociableItemTypes(); $html = ''; - $html .= self::generateExportForm($users_id, $itemsTypes); - $html .= self::generateUnlinkItemsForm($users_id, $itemsTypes); + $html .= self::generateExportForm($users_id); + $html .= self::generateUnlinkItemsForm($users_id); $html .= self::generateAnonymiseForm($users_id); echo $html; @@ -257,7 +257,7 @@ private static function generateExportForm($users_id) { $html .= ''; $html .= ''; $html .= ''; - $html .= '' . __($itemType) . ''; + $html .= '' . __(str_replace(['ItilFollowup', 'TicketTask'],['Followup', 'Task'],$itemType)) . ''; $html .= ''; $html .= ''; } @@ -329,13 +329,12 @@ private static function generateUnlinkItemsForm($users_id) { foreach ($itemsTypes as $itemType) { $html .= ''; - $html .= ''; + $html .= ''; $html .= '
'; - $html .= ''; - $html .= ''; + $html .= ''; + $html .= ''; $html .= '
'; $html .= ''; - $html .= '' . __($itemType) . ''; $html_parts = Dropdown::showFromArray('retentionPeriods[' . $itemType . ']', $values, $config); $html .= '' . $html_parts . ''; $html .= ''; @@ -483,10 +482,9 @@ private static function generateDeleteDocumentsForm($users_id) { $html .= ''; $html .= '
'; $html .= ''; - $html .= ''; + $html .= ''; $html .= '
'; $html .= ''; - //$html .= '' . __($itemType) . ''; $html_parts = Dropdown::showFromArray('retentionPeriods[' . $itemType . ']', $values, $config); $html .= '' . $html_parts . ''; $html .= ''; @@ -510,12 +508,12 @@ private static function generateDeleteDocumentsForm($users_id) { * @param ID of user * @return array */ - private static function getAllUsedItemsForUser($ID) { + private static function getAllUsedItemsForUser($ID, $itemTypes) { global $DB; $items = []; - foreach (self::getUserAssociableItemTypes() as $itemtype) { + foreach ($itemTypes as $itemtype) { if (!($item = getItemForItemtype($itemtype))) { continue; } @@ -568,30 +566,32 @@ private static function getAllUsedItemsForUser($ID) { } // Tickets - $tickets = $DB->request( - [ - 'SELECT' => ['*'], - //'DISTINCT' => true, - 'FROM' => Ticket::getTable(), - 'LEFT JOIN' => [ - Ticket_User::getTable() => [ - 'FKEY' => [ - Ticket::getTable() => 'id', - Ticket_User::getTable() => 'tickets_id' - ] - ] - ], - 'WHERE' => [ - 'OR' => [ - 'users_id_recipient' => $ID, - 'users_id' => $ID - ], - ], - 'ORDER' => 'date' - ] - ); - foreach ($tickets as $data) { - $items['Ticket'][] = $data; + if($itemtype == 'Ticket') { + $tickets = $DB->request( + [ + 'SELECT' => ['t.*'], + 'DISTINCT' => true, + 'FROM' => Ticket::getTable().' AS t', + 'INNER JOIN' => [ + Ticket_User::getTable() => [ + 'FKEY' => [ + 't' => 'id', + Ticket_User::getTable() => 'tickets_id' + ] + ] + ], + 'WHERE' => [ + 'OR' => [ + 'users_id_recipient' => $ID, + 'users_id' => $ID + ], + ], + 'ORDER' => 'date' + ] + ); + foreach ($tickets as $data) { + $items['Ticket'][] = $data; + } } // getComputersIDs @@ -619,7 +619,7 @@ private static function getAllUsedItemsForUser($ID) { private static function getUserAssociableItemTypes($permissionAccess = READ) { global $CFG_GLPI; - $itemsTypes = ['Ticket', 'Followup', 'Task']; + $itemsTypes = ['Ticket', 'ItilFollowup', 'TicketTask']; $linkuser_types = array_merge($CFG_GLPI['linkuser_types'], $itemsTypes);; foreach($linkuser_types as $itemsType){ diff --git a/rgpdtools.xml b/rgpdtools.xml index ceb3c34..89dfebc 100644 --- a/rgpdtools.xml +++ b/rgpdtools.xml @@ -59,6 +59,11 @@ ~10.O https://github.com/Probesys/glpi-plugins-rgpdtools/releases/download/v1.1.1/rgpdtools-1.1.1.tbz + + 1.1.2 + ~10.O + https://github.com/Probesys/glpi-plugins-rgpdtools/releases/download/v1.1.2/rgpdtools-1.1.2.tbz + fr_FR diff --git a/setup.php b/setup.php index ad6550f..6e08ea3 100644 --- a/setup.php +++ b/setup.php @@ -27,7 +27,7 @@ * --------------------------------------------------------------------- */ -define('PLUGIN_RGPDTOOLS_VERSION', '1.1.1'); +define('PLUGIN_RGPDTOOLS_VERSION', '1.1.2'); define('PLUGIN_RGPDTOOLS_GLPI_MIN_VERSION', '9.5'); define('PLUGIN_RGPDTOOLS_GLPI_MAX_VERSION', '11'); if (!defined("PLUGIN_RGPDTOOLS_DIR")) {