Skip to content

Commit

Permalink
fix glpi 10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe GODOT committed Jan 12, 2023
1 parent a8839d7 commit bebc962
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 50 deletions.
12 changes: 7 additions & 5 deletions front/rgpdtools.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$nbUnlinkedElmts = $PluginRgpdtoolsRgpdtools::deleteUserLinkItems($_POST);

if ($nbUnlinkedElmts) {
$message = $nbUnlinkedElmts.' link(s) with the user where deleted successfully.';
$message = $nbUnlinkedElmts.__(' link(s) with the user where deleted successfully', 'rgpdtools');
} else {
$message = __('No links matching criteria were founded, no update query were executed.', 'rgpdtools');
}
Expand All @@ -32,7 +32,9 @@
}

// standard form
Html::header(__('RgpdTools', 'rgpdtools'), $_SERVER['PHP_SELF'], 'tools', 'rgpdtools');
$PluginRgpdtoolsRgpdtools = new PluginRgpdtoolsRgpdtools();
$PluginRgpdtoolsRgpdtools->getFormsForCompleteForm();
Html::footer();
if (!isset($_REQUEST['generate'])) {
Html::header(__('RgpdTools', 'rgpdtools'), $_SERVER['PHP_SELF'], 'tools', 'rgpdtools');
$PluginRgpdtoolsRgpdtools = new PluginRgpdtoolsRgpdtools();
$PluginRgpdtoolsRgpdtools->getFormsForCompleteForm();
Html::footer();
}
10 changes: 5 additions & 5 deletions inc/rgpdtools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ private static function generateExportForm($users_id, $itemsTypes)
$rand = mt_rand();
$idForm = "useritemsexport_form$rand";

$html .= "<div class='center'>";
$html .= "<form method='post' name='$idForm' id='$idForm'
$html .= "<div class='center card card-sm mb-3'>";
$html .= "<form method='post' name='$idForm' id='$idForm' target='_blank'
action=\"" . Plugin::getWebDir('rgpdtools') . "/front/rgpdtools.form.php\" onsubmit=\"return confirm('" . __('Are you sure you want to execute this operation', 'rgpdtools') . "?');\">";
$html .= '<div class="spaced">';

Expand Down Expand Up @@ -251,7 +251,7 @@ private static function generateUnlinkItemsForm($users_id, $itemsTypes)
}

$idForm = "useritemsdelete_form$rand";
$html .= "<div class='center'>";
$html .= "<div class='center card card-sm mb-3'>";
$html .= "<form method='post' name='$idForm' id='$idForm'
action=\"" . Plugin::getWebDir('rgpdtools') . "/front/rgpdtools.form.php\" onsubmit=\"return confirm('" . __('Are you sure you want to execute this operation', 'rgpdtools') . "?');\">";
$html .= '<div class="spaced">';
Expand Down Expand Up @@ -355,7 +355,7 @@ private static function generateAnonymiseForm($users_id)
$values[$i] = $i . ' ' . __('month');
}
$idForm = "userpurgelogs_form$rand";
$html .= "<div class='center'>";
$html .= "<div class='center card card-sm'>";
$html .= "<form method='post' name='$idForm' id='$idForm'
action=\"" . Plugin::getWebDir('rgpdtools') . "/front/rgpdtools.form.php\" onsubmit=\"return confirm('" . __('Are you sure you want to execute this operation', 'rgpdtools') . "?');\">";
$html .= '<div class="spaced">';
Expand Down Expand Up @@ -605,7 +605,7 @@ private static function unlinkUserAssociateElementsToDate($userID, $className, $
if ($nbUnlinkedElmts) {
// construction du tableau des ids
$objectsIds = [];
while ($row = $DB->fetch_assoc($results)) {
while ($row = $DB->fetchAssoc($results)) {
array_push($objectsIds, $row['id']);
}
$query = "UPDATE " . $object->getTable() . " SET users_id=NULL WHERE id IN (" . implode(',', $objectsIds) . ")";
Expand Down
Binary file modified locales/fr_FR.mo
Binary file not shown.
52 changes: 34 additions & 18 deletions locales/fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: RgpdTools 0.0.1\n"
"Report-Msgid-Bugs-To: contact@probesys.com\n"
"POT-Creation-Date: 2021-03-05 14:01+0100\n"
"PO-Revision-Date: 2021-03-30 08:39+0200\n"
"POT-Creation-Date: 2023-01-12 09:47+0100\n"
"PO-Revision-Date: 2023-01-12 10:01+0100\n"
"Last-Translator: probeSys <contact@probesys.com>\n"
"Language-Team: \n"
"Language: fr_FR\n"
Expand All @@ -18,7 +18,8 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 2.4.2\n"

#: setup.php:71 front/rgpdtools.form.php:35 inc/rgpdtools.class.php:47
#: setup.php:71 front/rgpdtools.form.php:35 inc/rgpdtools.class.php:29
#: inc/rgpdtools.class.php:48
msgctxt "rgpdtools"
msgid "RgpdTools"
msgstr "Utilitaires RGPD"
Expand All @@ -28,6 +29,11 @@ msgctxt "rgpdtools"
msgid "Export successfully generated."
msgstr "Export généré avec succès."

#: front/rgpdtools.form.php:18
msgctxt "rgpdtools"
msgid " link(s) with the user where deleted successfully"
msgstr " lien(s) avec le(s) utilisateur(s) sélectionné(s) supprimé(s)"

#: front/rgpdtools.form.php:20
msgctxt "rgpdtools"
msgid "No links matching criteria were founded, no update query were executed."
Expand All @@ -39,69 +45,79 @@ msgstr ""
msgctxt "rgpdtools"
msgid "Logs contains information about the user were anonymize successfully."
msgstr ""
"Les logs contenant des informations relatives à l'utilisateur ont été "
"anonymisés avec succès."
"Les logs contenant des informations relatives aux utilisateurs sélectionnés "
"ont été anonymisés avec succès."

#: inc/rgpdtools.class.php:10
#: inc/rgpdtools.class.php:11
msgctxt "rgpdtools"
msgid "Run \"composer install --no-dev\" in the plugin tree"
msgstr "Executer \"composer install --no-dev\" dans le dossier du plugin"

#: inc/rgpdtools.class.php:180 inc/rgpdtools.class.php:250
#: inc/rgpdtools.class.php:346
#: inc/rgpdtools.class.php:71 inc/rgpdtools.class.php:102
msgctxt "rgpdtools"
msgid "user is required"
msgstr "vous devez sélectionner un utilisateur"

#: inc/rgpdtools.class.php:85
msgctxt "rgpdtools"
msgid "user is required or all user checkbox"
msgstr "vous devez sélectionner un utilisateur ou tout les utilisateurs"

#: inc/rgpdtools.class.php:185 inc/rgpdtools.class.php:256
#: inc/rgpdtools.class.php:360
msgctxt "rgpdtools"
msgid "Are you sure you want to execute this operation"
msgstr "Etes vous certain de vouloir exécuter cette opération"

#: inc/rgpdtools.class.php:186
#: inc/rgpdtools.class.php:191
msgctxt "rgpdtools"
msgid "Export users data"
msgstr "Export des données de l'utilisateur"

#: inc/rgpdtools.class.php:204
#: inc/rgpdtools.class.php:209
msgctxt "rgpdtools"
msgid "Choosing what to export"
msgstr "Sélectionner les éléments à exporter"

#: inc/rgpdtools.class.php:255
#: inc/rgpdtools.class.php:261
msgctxt "rgpdtools"
msgid "Removal of links to the user"
msgstr "Suppression des liens vers l'utilisateur"

#: inc/rgpdtools.class.php:273
#: inc/rgpdtools.class.php:283
msgctxt "rgpdtools"
msgid "Choice of elements for which to remove links to the user"
msgstr ""
"Sélection des types d'éléments pour lesquels supprimer les liens avec "
"l'utilisateur"

#: inc/rgpdtools.class.php:274
#: inc/rgpdtools.class.php:284
msgctxt "rgpdtools"
msgid "For each item, retention period"
msgstr "Pour chaque type d'élément, durée de rétention"

#: inc/rgpdtools.class.php:310
#: inc/rgpdtools.class.php:320
msgid "User"
msgid_plural "User"
msgstr[0] "Utilisateur"
msgstr[1] "Utilisateurs"

#: inc/rgpdtools.class.php:320
#: inc/rgpdtools.class.php:334
msgctxt "rgpdtools"
msgid "Apply to all users"
msgstr "Appliquer à tout les utilisateurs"

#: inc/rgpdtools.class.php:351
#: inc/rgpdtools.class.php:365
msgctxt "rgpdtools"
msgid "Purge logs referring to the user"
msgstr "Suppression des logs faisant référence à l'utilisateur"

#: inc/rgpdtools.class.php:355
#: inc/rgpdtools.class.php:369
msgctxt "rgpdtools"
msgid "Retention Period"
msgstr "Durée de rétention"

#: inc/rgpdtools.class.php:523
#: inc/rgpdtools.class.php:582
#, php-format
msgctxt "rgpdtools"
msgid "The class %1$s can't be instanciate because not finded on GLPI."
Expand Down
48 changes: 32 additions & 16 deletions locales/rgpdtools.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#
#, fuzzy
msgid ""
msgstr "Project-Id-Version: RgpdTools 0.0.1\n"
msgstr "Project-Id-Version: RgpdTools 1.0.0\n"
"Report-Msgid-Bugs-To: contact@probesys.com\n"
"POT-Creation-Date: 2021-03-05 14:01+0100\n"
"POT-Creation-Date: 2023-01-12 09:47+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,7 +17,8 @@ msgstr "Project-Id-Version: RgpdTools 0.0.1\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: setup.php:71 front/rgpdtools.form.php:35 inc/rgpdtools.class.php:47
#: setup.php:71 front/rgpdtools.form.php:35 inc/rgpdtools.class.php:29
#: inc/rgpdtools.class.php:48
msgctxt "rgpdtools"
msgid "RgpdTools"
msgstr ""
Expand All @@ -27,6 +28,11 @@ msgctxt "rgpdtools"
msgid "Export successfully generated."
msgstr ""

#: front/rgpdtools.form.php:18
msgctxt "rgpdtools"
msgid " link(s) with the user where deleted successfully"
msgstr ""

#: front/rgpdtools.form.php:20
msgctxt "rgpdtools"
msgid "No links matching criteria were founded, no update query were "
Expand All @@ -38,64 +44,74 @@ msgctxt "rgpdtools"
msgid "Logs contains information about the user were anonymize successfully."
msgstr ""

#: inc/rgpdtools.class.php:10
#: inc/rgpdtools.class.php:11
msgctxt "rgpdtools"
msgid "Run \"composer install --no-dev\" in the plugin tree"
msgstr ""

#: inc/rgpdtools.class.php:180 inc/rgpdtools.class.php:250
#: inc/rgpdtools.class.php:346
#: inc/rgpdtools.class.php:71 inc/rgpdtools.class.php:102
msgctxt "rgpdtools"
msgid "user is required"
msgstr ""

#: inc/rgpdtools.class.php:85
msgctxt "rgpdtools"
msgid "user is required or all user checkbox"
msgstr ""

#: inc/rgpdtools.class.php:185 inc/rgpdtools.class.php:256
#: inc/rgpdtools.class.php:360
msgctxt "rgpdtools"
msgid "Are you sure you want to execute this operation"
msgstr ""

#: inc/rgpdtools.class.php:186
#: inc/rgpdtools.class.php:191
msgctxt "rgpdtools"
msgid "Export users data"
msgstr ""

#: inc/rgpdtools.class.php:204
#: inc/rgpdtools.class.php:209
msgctxt "rgpdtools"
msgid "Choosing what to export"
msgstr ""

#: inc/rgpdtools.class.php:255
#: inc/rgpdtools.class.php:261
msgctxt "rgpdtools"
msgid "Removal of links to the user"
msgstr ""

#: inc/rgpdtools.class.php:273
#: inc/rgpdtools.class.php:283
msgctxt "rgpdtools"
msgid "Choice of elements for which to remove links to the user"
msgstr ""

#: inc/rgpdtools.class.php:274
#: inc/rgpdtools.class.php:284
msgctxt "rgpdtools"
msgid "For each item, retention period"
msgstr ""

#: inc/rgpdtools.class.php:310
#: inc/rgpdtools.class.php:320
msgid "User"
msgid_plural "User"
msgstr[0] ""
msgstr[1] ""

#: inc/rgpdtools.class.php:320
#: inc/rgpdtools.class.php:334
msgctxt "rgpdtools"
msgid "Apply to all users"
msgstr ""

#: inc/rgpdtools.class.php:351
#: inc/rgpdtools.class.php:365
msgctxt "rgpdtools"
msgid "Purge logs referring to the user"
msgstr ""

#: inc/rgpdtools.class.php:355
#: inc/rgpdtools.class.php:369
msgctxt "rgpdtools"
msgid "Retention Period"
msgstr ""

#: inc/rgpdtools.class.php:523
#: inc/rgpdtools.class.php:582
#, php-format
msgctxt "rgpdtools"
msgid "The class %1$s can't be instanciate because not finded on GLPI."
Expand Down
15 changes: 9 additions & 6 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
*
* --------------------------------------------------------------------------
*/
define('PLUGIN_RGPDTOOLS_VERSION', '0.1.3');
define('PLUGIN_RGPDTOOLS_VERSION', '1.0.0');
define('PLUGIN_RGPDTOOLS_GLPI_MIN_VERSION', '9.5');
define('PLUGIN_RGPDTOOLS_GLPI_MAX_VERSION', '11');
if (!defined("PLUGIN_RGPDTOOLS_DIR")) {
define('PLUGIN_RGPDTOOLS_DIR', Plugin::getPhpDir('rgpdtools'));
}
Expand Down Expand Up @@ -81,14 +82,16 @@ function plugin_version_rgpdtools()
}

/**
* Check pre-requisites before install
* OPTIONNAL, but recommanded
*
* @return boolean
* Check plugin's prerequisites before installation
*/
function plugin_rgpdtools_check_prerequisites()
{
return true;
if (version_compare(GLPI_VERSION, PLUGIN_RGPDTOOLS_GLPI_MIN_VERSION, 'lt') || version_compare(GLPI_VERSION, PLUGIN_RGPDTOOLS_GLPI_MAX_VERSION, 'ge')) {
echo __('This plugin requires GLPI >= ' . PLUGIN_RGPDTOOLS_GLPI_MIN_VERSION . ' and GLPI < ' . PLUGIN_RGPDTOOLS_GLPI_MAX_VERSION . '<br>');
} else {
return true;
}
return false;
}

/**
Expand Down

0 comments on commit bebc962

Please sign in to comment.