From 7d83b67c2b3eb08eea00b1f868561604fc53446d Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 22 May 2024 15:18:28 +0200 Subject: [PATCH 01/54] base setup to add advanced options with the plugin fields --- front/model.form.php | 12 +++- hook.php | 61 ++++++++++++++++++ inc/model.class.php | 101 +++++++++++++++++++++++++++--- inc/modelcontainer.class.php | 70 +++++++++++++++++++++ inc/modelcontainerfield.class.php | 79 +++++++++++++++++++++++ setup.php | 13 +++- 6 files changed, 323 insertions(+), 13 deletions(-) create mode 100644 inc/modelcontainer.class.php create mode 100644 inc/modelcontainerfield.class.php diff --git a/front/model.form.php b/front/model.form.php index 1505f90..f25aaeb 100644 --- a/front/model.form.php +++ b/front/model.form.php @@ -48,11 +48,19 @@ if (isset($_POST["add"])) { $model->check(-1, UPDATE, $_POST); - $model->add($_POST); + if ($id = $model->add($_POST)) { + if ($_POST['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($id); + } + } Html::back(); } else if (isset($_POST["update"])) { $model->check($_POST['id'], UPDATE); - $model->update($_POST); + if ($model->update($_POST)) { + if ($_POST['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($_POST['id']); + } + } Html::back(); } else if (isset($_POST['purge'])) { $model->check($_POST['id'], DELETE); diff --git a/hook.php b/hook.php index 0d62f63..ad7d32e 100644 --- a/hook.php +++ b/hook.php @@ -81,6 +81,8 @@ function plugin_uninstall_install() PluginUninstallModel::install($migration); PluginUninstallPreference::install($migration); PluginUninstallConfig::install($migration); + PluginUninstallModelcontainer::install($migration); + PluginUninstallModelcontainerfield::install($migration); $migration->executeMigration(); @@ -103,5 +105,64 @@ function plugin_uninstall_uninstall() PluginUninstallModel::uninstall(); PluginUninstallPreference::uninstall(); PluginUninstallConfig::uninstall(); + PluginUninstallModelcontainer::uninstall(); + PluginUninstallModelcontainerfield::uninstall(); return true; } + +function plugin_uninstall_hook_add_container($item) { + if (!($item instanceof PluginFieldsContainer)) { + return; + } + $containerId = $item->getID(); + $uninstallContainer = new PluginUninstallModelcontainer(); + $model = new PluginUninstallModel(); + $models = $model->find(); + foreach ($models as $mod) { + $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $mod['id'], + 'plugin_fields_containers_id' => $containerId + ]); + } +} + +function plugin_uninstall_hook_add_field($item) { + if (!($item instanceof PluginFieldsField)) { + return; + } + $fieldId = $item->getID(); + $uninstallContainer = new PluginUninstallModelcontainer(); + $uninstallContainers = $uninstallContainer->find(); + $uninstallField = new PluginUninstallModelcontainerfield(); + foreach ($uninstallContainers as $container) { + $uninstallField->add([ + 'plugin_uninstall_modelcontainers_id' => $container['id'], + 'plugin_fields_fields_id' => $fieldId, + 'action' => $uninstallField::ACTION_RAZ + ]); + } +} + +function plugin_uninstall_hook_purge_container($item) { + if (!($item instanceof PluginFieldsContainer)) { + return; + } + global $DB; + $containerId = $item->getID(); + $DB->delete( + PluginUninstallModelcontainer::getTable(), + ['plugin_fields_containers_id' => $containerId] + ); +} + +function plugin_uninstall_hook_purge_field($item) { + if (!($item instanceof PluginFieldsField)) { + return; + } + global $DB; + $fieldId = $item->getID(); + $DB->delete( + PluginUninstallModelcontainerfield::getTable(), + ['plugin_fields_fields_id' => $fieldId] + ); +} diff --git a/inc/model.class.php b/inc/model.class.php index fd8b986..b78a49f 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -38,6 +38,11 @@ class PluginUninstallModel extends CommonDBTM const TYPE_MODEL_UNINSTALL = 1; const TYPE_MODEL_REPLACEMENT = 2; + const PLUGIN_FIELDS_ACTION_NONE = 0; + const PLUGIN_FIELDS_ACTION_RAZ = 1; + const PLUGIN_FIELDS_ACTION_ADVANCED = 2; + + public static function getTypeName($nb = 0) { return _n("Template", "Templates", $nb); @@ -169,6 +174,10 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab = []; $tab[1] = self::getTypeName(1); $tab[2] = __('Replacing data', 'uninstall'); + $plugin = new Plugin(); + if ($plugin->isActivated('fields')) { + $tab[3] = __('Plugin fields options', 'uninstall'); + } return $tab; } return ''; @@ -188,6 +197,9 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ case 2: $item->showFormAction($item); break; + case 3: + $item->showFormPluginFields($item); + break; } } return true; @@ -738,14 +750,20 @@ public function showFormAction($item) ""; echo ""; - echo "" . __('Delete Fields plugin informations', 'uninstall') . ""; + echo "" . __('Fields plugin informations', 'uninstall') . ""; echo ""; - Dropdown::showYesNo( - "raz_plugin_fields", - (isset($this->fields["raz_plugin_fields"]) - ? $this->fields["raz_plugin_fields"] : 1), - -1, - ['width' => '100%'] + Dropdown::showFromArray( + "action_plugin_fields", + [ + self::PLUGIN_FIELDS_ACTION_NONE => __("Don't alter", 'uninstall'), + self::PLUGIN_FIELDS_ACTION_RAZ => __('Blank'), + self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall'), + ], + [ + 'value' => (isset($this->fields["action_plugin_fields"]) + ? $this->fields["action_plugin_fields"] : self::PLUGIN_FIELDS_ACTION_RAZ), + 'width' => '100%' + ] ); echo ""; echo ""; @@ -768,6 +786,27 @@ public function showFormAction($item) return true; } + /** + * @param $item + **/ + public function showFormPluginFields($item) + { + $plugin = new Plugin(); + if ($plugin->isActivated('fields')) { + if ($item->fields['action_plugin_fields'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + + } else { + echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; + return false; + } + } else { + echo "" . __("Activate the plugin 'fields' to access this tab.") . ""; + return false; + } + + return true; + } + /** * @param $model_id @@ -1335,7 +1374,10 @@ public static function install($migration) $migration->addField($table, 'raz_glpiinventory', "integer"); } - $migration->migrationOneTable($table); + // from 2.9.1 to 2.10.0 + if ($DB->fieldExists($table, 'raz_plugin_fields')) { + $migration->changeField($table, 'raz_plugin_fields', 'action_plugin_fields', 'int', ['value' => self::PLUGIN_FIELDS_ACTION_RAZ]); + } } else { // plugin never installed $query = "CREATE TABLE IF NOT EXISTS `" . getTableForItemType(__CLASS__) . "` ( @@ -1345,6 +1387,7 @@ public static function install($migration) `name` varchar(255) NOT NULL DEFAULT '', `transfers_id` int {$default_key_sign} NOT NULL, `states_id` int {$default_key_sign} NOT NULL, + `states_id` int {$default_key_sign} NOT NULL, `raz_name` int NOT NULL DEFAULT '1', `raz_contact` int NOT NULL DEFAULT '1', `raz_contact_num` int NOT NULL DEFAULT '1', @@ -1380,7 +1423,7 @@ public static function install($migration) `replace_method` int NOT NULL DEFAULT '2', `raz_glpiinventory` int NOT NULL DEFAULT '1', `raz_fusioninventory` int NOT NULL DEFAULT '1', - `raz_plugin_fields` tinyint NOT NULL DEFAULT '1', + `action_plugin_fields` int NOT NULL DEFAULT '1', `replace_contact` tinyint NOT NULL DEFAULT '0', `replace_contact_num` tinyint NOT NULL DEFAULT '0', PRIMARY KEY (`id`) @@ -1444,7 +1487,7 @@ public static function createTransferModel($name = 'Uninstall') $tmp['raz_ocs_registrykeys'] = 1; $tmp['raz_glpiinventory'] = 1; $tmp['raz_fusioninventory'] = 1; - $tmp['raz_plugin_fields'] = 1; + $tmp['action_plugin_fields'] = 1; $tmp['comment'] = ''; $tmp['groups_action'] = 'set'; $tmp['groups_id'] = 0; @@ -1542,4 +1585,42 @@ public static function getIcon() { return "fas fa-recycle"; } + + /** + * Create all non-existing relations between plugin fields containers and a model + * @param $modelId int + */ + public function createPluginFieldsRelations($modelId) { + global $DB; + if ($DB->tableExists('glpi_plugin_fields_containers')) { + $uninstallContainer = new PluginUninstallModelcontainer(); + $uninstallContainers = $uninstallContainer->find(['plugin_uninstall_models_id' => $modelId]); + $existingContainersIds = array_map(fn($e) => $e['plugin_fields_containers_id'], $uninstallContainers); + + $fieldsContainer = new PluginFieldsContainer(); + $condition = count($existingContainersIds) ? ['NOT' => [ + 'id' => $existingContainersIds + ]] : []; + $fieldsContainers = $fieldsContainer->find($condition); + + $fieldsField = new PluginFieldsField(); + $uninstallField = new PluginUninstallModelcontainerfield(); + + foreach($fieldsContainers as $container) { + $newId = $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $modelId, + 'plugin_fields_containers_id' => $container['id'] + ]); + + $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); + foreach($fieldsFields as $field) { + $uninstallField->add([ + 'plugin_fields_fields_id' => $field['id'], + 'plugin_uninstall_modelcontainers_id' => $newId, + 'action' => $uninstallField::ACTION_RAZ + ]); + } + } + } + } } diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php new file mode 100644 index 0000000..5c979ce --- /dev/null +++ b/inc/modelcontainer.class.php @@ -0,0 +1,70 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- + */ + +class PluginUninstallModelcontainer extends CommonDBTM +{ + public $dohistory = true; + + public static function install($migration) + { + /** @var DBmysql $DB */ + global $DB; + + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + + // first version with this feature + if (!$DB->tableExists(getTableForItemType(__CLASS__))) { + $query = "CREATE TABLE IF NOT EXISTS `" . getTableForItemType(__CLASS__) . "` ( + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', + `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; + + $DB->queryOrDie($query, $DB->error()); + } + return true; + } + + public static function uninstall() + { + /** @var DBmysql $DB */ + global $DB; + + $DB->query("DROP TABLE IF EXISTS `" . getTableForItemType(__CLASS__) . "`"); + + //Delete history + $log = new Log(); + $log->dohistory = false; + $log->deleteByCriteria(['itemtype' => __CLASS__]); + } +} diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php new file mode 100644 index 0000000..b78e59c --- /dev/null +++ b/inc/modelcontainerfield.class.php @@ -0,0 +1,79 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- + */ + +class PluginUninstallModelcontainerfield extends CommonDBTM +{ + public $dohistory = true; + + // don't modify the field + const ACTION_NONE = 0; + // delete value + const ACTION_RAZ = 1; + // set value to new_value + const ACTION_NEW_VALUE = 2; + + public static function install($migration) + { + /** @var DBmysql $DB */ + global $DB; + + $default_charset = DBConnection::getDefaultCharset(); + $default_collation = DBConnection::getDefaultCollation(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + + // first version with this feature + if (!$DB->tableExists(getTableForItemType(__CLASS__))) { + $query = "CREATE TABLE IF NOT EXISTS `" . getTableForItemType(__CLASS__) . "` ( + `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, + `plugin_uninstall_modelcontainers_id` int {$default_key_sign} DEFAULT '0', + `plugin_fields_fields_id` tinyint NOT NULL DEFAULT '0', + `action` int NOT NULL DEFAULT ". self::ACTION_RAZ ." , + `new_value` varchar(255), + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; + + $DB->queryOrDie($query, $DB->error()); + } + return true; + } + + public static function uninstall() + { + /** @var DBmysql $DB */ + global $DB; + + $DB->query("DROP TABLE IF EXISTS `" . getTableForItemType(__CLASS__) . "`"); + + //Delete history + $log = new Log(); + $log->dohistory = false; + $log->deleteByCriteria(['itemtype' => __CLASS__]); + } +} diff --git a/setup.php b/setup.php index 5f0723b..cbfde22 100644 --- a/setup.php +++ b/setup.php @@ -30,7 +30,7 @@ use Glpi\Plugin\Hooks; -define('PLUGIN_UNINSTALL_VERSION', '2.9.1'); +define('PLUGIN_UNINSTALL_VERSION', '2.10.0'); // Minimal GLPI version, inclusive define("PLUGIN_UNINSTALL_MIN_GLPI", "10.0.7"); @@ -135,6 +135,17 @@ function plugin_init_uninstall() } } $PLUGIN_HOOKS['post_init']['uninstall'] = 'plugin_uninstall_postinit'; + + if ($plugin->isActivated('fields')) { + $PLUGIN_HOOKS[Hooks::ITEM_ADD]['uninstall'] = [ + PluginFieldsContainer::class => 'plugin_uninstall_hook_add_container', + PluginFieldsField::class => 'plugin_uninstall_hook_add_field', + ]; + $PLUGIN_HOOKS[Hooks::ITEM_PURGE]['uninstall'] = [ + PluginFieldsContainer::class => 'plugin_uninstall_hook_purge_container', + PluginFieldsField::class => 'plugin_uninstall_hook_purge_field', + ]; + } } } From ebf83c11f547b5cabe99c0cc3c7416ef3b9ce7c1 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 22 May 2024 15:45:15 +0200 Subject: [PATCH 02/54] fix hook ITEM_ADD for PluginFieldsField --- hook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hook.php b/hook.php index ad7d32e..c080c15 100644 --- a/hook.php +++ b/hook.php @@ -132,7 +132,7 @@ function plugin_uninstall_hook_add_field($item) { } $fieldId = $item->getID(); $uninstallContainer = new PluginUninstallModelcontainer(); - $uninstallContainers = $uninstallContainer->find(); + $uninstallContainers = $uninstallContainer->find(['plugin_fields_containers_id' => $item->fields['plugin_fields_containers_id']]); $uninstallField = new PluginUninstallModelcontainerfield(); foreach ($uninstallContainers as $container) { $uninstallField->add([ From ed83b19d507ce4b912fb3b69c1306c0822fc9547 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 22 May 2024 17:33:30 +0200 Subject: [PATCH 03/54] display modelcontainers for models, and fields for modelcontainers --- composer.json | 2 +- front/modelcontainer.form.php | 53 +++++++++++++++ front/modelcontainerfield.form.php | 60 +++++++++++++++++ hook.php | 26 ++++++-- inc/model.class.php | 6 +- inc/modelcontainer.class.php | 100 +++++++++++++++++++++++++++++ inc/modelcontainerfield.class.php | 74 +++++++++++++++++++++ 7 files changed, 314 insertions(+), 7 deletions(-) create mode 100644 front/modelcontainer.form.php create mode 100644 front/modelcontainerfield.form.php diff --git a/composer.json b/composer.json index 0d0845e..ff09289 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": ">=7.4" + "php": ">=8.0" }, "require-dev": { "glpi-project/tools": "^0.7.1", diff --git a/front/modelcontainer.form.php b/front/modelcontainer.form.php new file mode 100644 index 0000000..bf78cfd --- /dev/null +++ b/front/modelcontainer.form.php @@ -0,0 +1,53 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- + */ + +include('../../../inc/includes.php'); + +Session::checkRightsOr('uninstall:profile', [READ, PluginUninstallProfile::RIGHT_REPLACE]); + +$model = new PluginUninstallModelcontainer(); + +Html::header( + PluginUninstallModel::getTypeName(), + $_SERVER['PHP_SELF'], + "admin", + "PluginUninstallModel", + "model" +); + + +echo ""; +echo ""; +echo "
" . __('Fields', 'fields') . + "
"; +Search::show('PluginUninstallModelcontainerfield'); + +Html::footer(); diff --git a/front/modelcontainerfield.form.php b/front/modelcontainerfield.form.php new file mode 100644 index 0000000..5f8630e --- /dev/null +++ b/front/modelcontainerfield.form.php @@ -0,0 +1,60 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- + */ + +include('../../../inc/includes.php'); + +Session::checkRightsOr('uninstall:profile', [READ, PluginUninstallProfile::RIGHT_REPLACE]); + +$id = 1; +if (isset($_GET["id"])) { + $id = $_GET["id"]; +} else if (isset($_POST["id"])) { + $id = $_POST["id"]; +} + +$field = new PluginUninstallModelcontainerfield(); + +if (isset($_POST["update"])) { + $field->check($_POST['id'], UPDATE); + $field->update($_POST); + Html::back(); +} else { + Html::header( + PluginUninstallModel::getTypeName(), + $_SERVER['PHP_SELF'], + "admin", + "PluginUninstallModel", + "model" + ); + + $field->display(['id' => $id]); + + Html::footer(); +} diff --git a/hook.php b/hook.php index c080c15..de0b6cb 100644 --- a/hook.php +++ b/hook.php @@ -57,6 +57,16 @@ function plugin_uninstall_addDefaultWhere($itemtype) return "`glpi_plugin_uninstall_models`.`types_id` = '1'"; } break; + case 'PluginUninstallModelcontainer': + if (isset($_GET['id'])) { + return "`glpi_plugin_uninstall_modelcontainers`.`plugin_uninstall_models_id` = '" . $_GET['id'] . "'"; + } + break; + case 'PluginUninstallModelcontainerfield': + if (isset($_GET['id'])) { + return "`glpi_plugin_uninstall_modelcontainerfields`.`plugin_uninstall_modelcontainers_id` = '" . $_GET['id'] . "'"; + } + break; } } @@ -110,7 +120,8 @@ function plugin_uninstall_uninstall() return true; } -function plugin_uninstall_hook_add_container($item) { +function plugin_uninstall_hook_add_container($item) +{ if (!($item instanceof PluginFieldsContainer)) { return; } @@ -126,13 +137,16 @@ function plugin_uninstall_hook_add_container($item) { } } -function plugin_uninstall_hook_add_field($item) { +function plugin_uninstall_hook_add_field($item) +{ if (!($item instanceof PluginFieldsField)) { return; } $fieldId = $item->getID(); $uninstallContainer = new PluginUninstallModelcontainer(); - $uninstallContainers = $uninstallContainer->find(['plugin_fields_containers_id' => $item->fields['plugin_fields_containers_id']]); + $uninstallContainers = $uninstallContainer->find( + ['plugin_fields_containers_id' => $item->fields['plugin_fields_containers_id']] + ); $uninstallField = new PluginUninstallModelcontainerfield(); foreach ($uninstallContainers as $container) { $uninstallField->add([ @@ -143,7 +157,8 @@ function plugin_uninstall_hook_add_field($item) { } } -function plugin_uninstall_hook_purge_container($item) { +function plugin_uninstall_hook_purge_container($item) +{ if (!($item instanceof PluginFieldsContainer)) { return; } @@ -155,7 +170,8 @@ function plugin_uninstall_hook_purge_container($item) { ); } -function plugin_uninstall_hook_purge_field($item) { +function plugin_uninstall_hook_purge_field($item) +{ if (!($item instanceof PluginFieldsField)) { return; } diff --git a/inc/model.class.php b/inc/model.class.php index b78a49f..b9db27e 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -794,7 +794,11 @@ public function showFormPluginFields($item) $plugin = new Plugin(); if ($plugin->isActivated('fields')) { if ($item->fields['action_plugin_fields'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { - + echo ""; + echo ""; + echo "
" . __('Plugin fields blocks', 'uninstall') . + "
"; + Search::show('PluginUninstallModelcontainer'); } else { echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; return false; diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index 5c979ce..c69dd4f 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -32,6 +32,106 @@ class PluginUninstallModelcontainer extends CommonDBTM { public $dohistory = true; + public static function getTypeName($nb = 0) + { + return __("Plugin fields block", "uninstall"); + } + + public function rawSearchOptions() + { + $tab = []; + + $tab[] = [ + 'id' => 'common', + 'name' => self::getTypeName(), + ]; + + $tab[] = [ + 'id' => '1', + 'table' => self::getTable(), + 'field' => 'id', + 'name' => __('ID'), + 'massiveaction' => false, + 'datatype' => 'itemlink' + ]; + + $tab[] = [ + 'id' => '2', + 'table' => PluginFieldsContainer::getTable(), + 'field' => 'label', + 'name' => __('Block', 'fields'), + 'datatype' => 'dropdown', + 'linkfield' => 'plugin_fields_containers_id', + 'massiveaction' => false + ]; + + $tab[] = [ + 'id' => 3, + 'table' => PluginFieldsContainer::getTable(), + 'field' => 'itemtypes', + 'name' => __("Associated item type"), + 'datatype' => 'specific', + 'massiveaction' => false + ]; + + return $tab; + } + + /** + * Copy from PluginFieldsContainer + * @param $field + * @param $values + * @param array $options + * @return string + */ + public static function getSpecificValueToDisplay($field, $values, array $options = []) + { + if (!is_array($values)) { + $values = [$field => $values]; + } + switch ($field) { + case 'itemtypes': + $types = json_decode($values[$field]); + $obj = ''; + $count = count($types); + $i = 1; + foreach ($types as $type) { + // prevent usage of plugin class if not loaded + if (!class_exists($type)) { + continue; + } + $name_type = getItemForItemtype($type); + $obj .= $name_type->getTypeName(2); + if ($count > $i) { + $obj .= ", "; + } + $i++; + } + return $obj; + } + + return ''; + } + + /** + * Copy from PluginFieldsContainer + * @param $field_id_or_search_options + * @param $name + * @param $values + * @param $options + * @return mixed + */ + public function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = []) + { + switch ($field_id_or_search_options['table'] . '.' . $field_id_or_search_options['field']) { + case $this->getTable() . '.itemtypes': + $options['display'] = false; + return Dropdown::showFromArray($name, self::getItemtypes(false), $options); + } + + return parent::getValueToSelect($field_id_or_search_options, $name, $values, $options); + } + public static function install($migration) { /** @var DBmysql $DB */ diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index b78e59c..629214b 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -39,6 +39,80 @@ class PluginUninstallModelcontainerfield extends CommonDBTM // set value to new_value const ACTION_NEW_VALUE = 2; + public static function getTypeName($nb = 0) + { + return __("Plugin fields block", "uninstall"); + } + + public function rawSearchOptions() + { + $tab = []; + + $tab[] = [ + 'id' => '1', + 'table' => self::getTable(), + 'field' => 'id', + 'name' => __('ID'), + 'massiveaction' => false, + 'datatype' => 'itemlink' + ]; + + $tab[] = [ + 'id' => '2', + 'table' => PluginFieldsField::getTable(), + 'field' => 'label', + 'name' => __('Label'), + 'datatype' => 'dropdown', + 'linkfield' => 'plugin_fields_fields_id', + ]; + + $tab[] = [ + 'id' => 3, + 'table' => PluginFieldsField::getTable(), + 'field' => 'type', + 'name' => __("Type"), + 'datatype' => 'specific', + 'massiveaction' => false, + 'nosearch' => true, + ]; + + $tab[] = [ + 'id' => 4, + 'table' => self::getTable(), + 'field' => 'action', + 'name' => __("Action"), + 'datatype' => 'specific', + 'massiveaction' => true, + 'nosearch' => true, + ]; + + return $tab; + } + + public static function getSpecificValueToDisplay($field, $values, array $options = []) + { + if (!is_array($values)) { + $values = [$field => $values]; + } + switch ($field) { + case 'type': + // TODO why does type never go there ? + $types = PluginFieldsField::getType(false); + return $types[$values[$field]]; + case 'action': + switch ($values[$field]) { + case self::ACTION_NONE: + return __("Don't alter", 'uninstall'); + case self::ACTION_RAZ: + return __('Blank'); + case self::ACTION_NEW_VALUE: + return __('Set value', 'uninstall'); + } + } + + return ''; + } + public static function install($migration) { /** @var DBmysql $DB */ From b6981133591df87fd273e6e183a689bc1dcb8c1c Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 22 May 2024 17:41:45 +0200 Subject: [PATCH 04/54] fix model install query --- inc/model.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index b9db27e..d481725 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1391,7 +1391,6 @@ public static function install($migration) `name` varchar(255) NOT NULL DEFAULT '', `transfers_id` int {$default_key_sign} NOT NULL, `states_id` int {$default_key_sign} NOT NULL, - `states_id` int {$default_key_sign} NOT NULL, `raz_name` int NOT NULL DEFAULT '1', `raz_contact` int NOT NULL DEFAULT '1', `raz_contact_num` int NOT NULL DEFAULT '1', From 91cc12d3304f2fbe75fd96ff755e7cfb8239764e Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 11:40:01 +0200 Subject: [PATCH 05/54] basic interface to choose action per field --- ajax/fieldValueInput.php | 120 +++++++++++++++++++++++++++++ front/modelcontainerfield.form.php | 15 ++-- hook.php | 15 ++++ inc/modelcontainerfield.class.php | 94 +++++++++++++++++++++- 4 files changed, 235 insertions(+), 9 deletions(-) create mode 100644 ajax/fieldValueInput.php diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php new file mode 100644 index 0000000..5eef835 --- /dev/null +++ b/ajax/fieldValueInput.php @@ -0,0 +1,120 @@ +. + -------------------------------------------------------------------------- + */ + +include('../../../inc/includes.php'); +header("Content-Type: text/html; charset=UTF-8"); +Html::header_nocache(); + +Session::checkLoginUser(); + +switch ($_POST['action']) { + case PluginUninstallModelcontainerfield::ACTION_NONE: + case PluginUninstallModelcontainerfield::ACTION_RAZ: + echo ""; + break; + + case PluginUninstallModelcontainerfield::ACTION_NEW_VALUE: + if (isset($_POST['id']) && $_POST['id']) { + $pluginUninstallField = new PluginUninstallModelcontainerfield(); + $pluginUninstallField->getFromDB($_POST['id']); + + $pluginFieldsField = new PluginFieldsField(); + $pluginFieldsField->getFromDB($pluginUninstallField->fields['plugin_fields_fields_id']); + + $type = $pluginFieldsField->fields['type']; + + if ($type === 'glpi_item') { + // TODO handling this case + // Display "allowed values" field + echo __('Allowed values', 'fields') . ' :'; + + $allowed_itemtypes = !empty($pluginFieldsField->fields['allowed_values']) + ? json_decode($pluginFieldsField->fields['allowed_values']) + : []; + echo implode( + ', ', + array_map( + function ($itemtype) { + return is_a($itemtype, CommonDBTM::class, true) + ? $itemtype::getTypeName(Session::getPluralNumber()) + : $itemtype; + }, + $allowed_itemtypes + ) + ); + + } else { + $dropdown_matches = []; + $is_dropdown = $type == 'dropdown' || preg_match( + '/^dropdown-(?.+)$/', + $type, + $dropdown_matches + ) === 1; + + if (in_array($type, ['date', 'datetime'])) { + echo ''; + } + + if ($is_dropdown) { + $multiple = (bool)$pluginFieldsField->fields['multiple']; + Toolbox::logInfo($multiple); + + echo '
'; + + $itemtype = $type == 'dropdown' + ? PluginFieldsDropdown::getClassname($pluginFieldsField->fields['name']) + : $dropdown_matches['class']; + $default_value = $multiple ? json_decode( + $pluginUninstallField->fields['new_value'] ?? $pluginFieldsField->fields['default_value'] + ) : $pluginUninstallField->fields['new_value'] ?? $pluginFieldsField->fields['default_value']; + Dropdown::show( + $itemtype, + [ + 'name' => 'new_value' . ($multiple ? '[]' : ''), + 'value' => $default_value, + 'entity_restrict' => -1, + 'multiple' => $multiple, + ] + ); + + echo '
'; + } else { + echo Html::input( + 'new_value', + [ + 'value' => $pluginUninstallField->fields['new_value'] ?? $pluginFieldsField->fields['default_value'], + ] + ); + } + } + } + break; +} + + diff --git a/front/modelcontainerfield.form.php b/front/modelcontainerfield.form.php index 5f8630e..5b46d2c 100644 --- a/front/modelcontainerfield.form.php +++ b/front/modelcontainerfield.form.php @@ -32,16 +32,10 @@ Session::checkRightsOr('uninstall:profile', [READ, PluginUninstallProfile::RIGHT_REPLACE]); -$id = 1; -if (isset($_GET["id"])) { - $id = $_GET["id"]; -} else if (isset($_POST["id"])) { - $id = $_POST["id"]; -} - $field = new PluginUninstallModelcontainerfield(); if (isset($_POST["update"])) { + // TODO handling of mandatory when action = SET_VALUE $field->check($_POST['id'], UPDATE); $field->update($_POST); Html::back(); @@ -54,7 +48,12 @@ "model" ); - $field->display(['id' => $id]); + if (isset($_GET["id"])) { + PluginUninstallModelcontainerfield::displayFullPageForItem($_GET['id']); + } else { + + } + Html::footer(); } diff --git a/hook.php b/hook.php index de0b6cb..50dc0de 100644 --- a/hook.php +++ b/hook.php @@ -164,6 +164,21 @@ function plugin_uninstall_hook_purge_container($item) } global $DB; $containerId = $item->getID(); + $pluginUninstallContainers = $DB->request([ + 'FROM' => PluginUninstallModelcontainer::getTable(), + 'SELECT' => 'id', + 'WHERE' => ['plugin_fields_containers_id' => $containerId] + ]); + $ids = []; + foreach($pluginUninstallContainers as $cont) { + $ids[] = $cont['id']; + } + if (count($ids)) { + $DB->delete( + PluginUninstallModelcontainerfield::getTable(), + ['plugin_uninstall_modelcontainers_id' => $ids] + ); + } $DB->delete( PluginUninstallModelcontainer::getTable(), ['plugin_fields_containers_id' => $containerId] diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 629214b..48e0fee 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -32,6 +32,7 @@ class PluginUninstallModelcontainerfield extends CommonDBTM { public $dohistory = true; + public static $rightname = "uninstall:profile"; // don't modify the field const ACTION_NONE = 0; // delete value @@ -41,7 +42,7 @@ class PluginUninstallModelcontainerfield extends CommonDBTM public static function getTypeName($nb = 0) { - return __("Plugin fields block", "uninstall"); + return __("Plugin fields field", "uninstall"); } public function rawSearchOptions() @@ -89,6 +90,97 @@ public function rawSearchOptions() return $tab; } + public function showForm($ID, $options = []) + { + /** @var array $CFG_GLPI */ + global $CFG_GLPI; + + $this->initForm($ID, $options); + $this->showFormHeader($options); + + $pluginFieldsField = new PluginFieldsField(); + if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { + echo ""; + echo "" . __('Field informations', 'uninstall') . + ""; + echo ""; + echo "" . __("Label") . " : "; + echo ""; + echo $pluginFieldsField->fields['label']; + echo ""; + echo "" . __("Type") . " : "; + echo ""; + echo PluginFieldsField::getTypes(true)[$pluginFieldsField->fields['type']]; + echo ""; + echo ""; + // DEFAULT VALUE + echo ""; + echo "" . __('Active') . " :"; + echo ""; + echo $pluginFieldsField->fields["is_active"] ? __('Yes') : __('No'); + echo ""; + echo "" . __("Mandatory field") . " : "; + echo ""; + echo $pluginFieldsField->fields["mandatory"] ? __('Yes') : __('No'); + echo ""; + echo ""; + + echo ""; + echo "" . __('Uninstall action', 'uninstall') . + ""; + echo ""; + echo "" . __('Action', 'uninstall') . " :"; + echo ""; + $rand = mt_rand(); + Dropdown::showFromArray( + "action", + [ + self::ACTION_NONE => __("Don't alter", 'uninstall'), + self::ACTION_RAZ => __('Blank'), + self::ACTION_NEW_VALUE => __('Set value', 'uninstall'), + ], + [ + 'value' => (isset($this->fields["action"]) + ? $this->fields["action"] : self::ACTION_RAZ), + 'width' => '100%', + 'rand' => $rand + ] + ); + echo ""; + echo ""; + echo ""; + echo ""; + $url = Plugin::getWebDir('uninstall') . "/ajax/fieldValueInput.php"; + echo " + + "; + + $this->showFormButtons($options); + } else { + // TODO warning message + button to delete + } + + return true; + } + public static function getSpecificValueToDisplay($field, $values, array $options = []) { if (!is_array($values)) { From 42b15155156ae3a62dd9ebc5019fe2f30787f294 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 13:46:54 +0200 Subject: [PATCH 06/54] possibility to choose action to do for all fields in a block --- front/modelcontainer.form.php | 42 +++++++++++-------- inc/modelcontainer.class.php | 79 +++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 17 deletions(-) diff --git a/front/modelcontainer.form.php b/front/modelcontainer.form.php index bf78cfd..74e7c58 100644 --- a/front/modelcontainer.form.php +++ b/front/modelcontainer.form.php @@ -33,21 +33,29 @@ Session::checkRightsOr('uninstall:profile', [READ, PluginUninstallProfile::RIGHT_REPLACE]); -$model = new PluginUninstallModelcontainer(); +$container = new PluginUninstallModelcontainer(); +if (isset($_POST["update"])) { + $container->check($_POST['id'], UPDATE); + $container->update($_POST); + Html::back(); +} else { + Html::header( + PluginUninstallModel::getTypeName(), + $_SERVER['PHP_SELF'], + "admin", + "PluginUninstallModel", + "model" + ); + $container->getFromDB($_GET['id']); + $container->showForm($_GET['id']); + if ($container->fields['action'] == $container::ACTION_CUSTOM) { + echo ""; + echo ""; + echo "
" . __('Fields', 'fields') . + "
"; + Search::show('PluginUninstallModelcontainerfield'); + } + + Html::footer(); +} -Html::header( - PluginUninstallModel::getTypeName(), - $_SERVER['PHP_SELF'], - "admin", - "PluginUninstallModel", - "model" -); - - -echo ""; -echo ""; -echo "
" . __('Fields', 'fields') . - "
"; -Search::show('PluginUninstallModelcontainerfield'); - -Html::footer(); diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index c69dd4f..03a0af4 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -32,6 +32,14 @@ class PluginUninstallModelcontainer extends CommonDBTM { public $dohistory = true; + public static $rightname = "uninstall:profile"; + + const ACTION_NONE = 0; + // delete value + const ACTION_RAZ = 1; + // set value to new_value + const ACTION_CUSTOM = 2; + public static function getTypeName($nb = 0) { return __("Plugin fields block", "uninstall"); @@ -132,6 +140,76 @@ public function getValueToSelect($field_id_or_search_options, $name = '', $value return parent::getValueToSelect($field_id_or_search_options, $name, $values, $options); } + public function showForm($ID, $options = []) + { + /** @var array $CFG_GLPI */ + global $CFG_GLPI; + + $this->initForm($ID, $options); + $this->showFormHeader($options); + + $pluginFieldsContainer = new PluginFieldsContainer(); + if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { + echo ""; + echo "" . __('Block informations', 'uninstall') . + ""; + echo ""; + echo "" . __("Label") . " : "; + echo ""; + echo $pluginFieldsContainer->fields['label']; + echo ""; + echo "" . __("Associated item type") . " : "; + echo ""; + $types = json_decode($pluginFieldsContainer->fields['itemtypes']); + $obj = ''; + $count = count($types); + $i = 1; + foreach ($types as $type) { + // prevent usage of plugin class if not loaded + if (!class_exists($type)) { + continue; + } + + $name_type = getItemForItemtype($type); + $obj .= $name_type->getTypeName(2); + if ($count > $i) { + $obj .= ", "; + } + $i++; + } + echo $obj; + echo ""; + echo ""; + + echo ""; + echo "" . __('Uninstall action', 'uninstall') . + ""; + echo ""; + echo "" . __('Action', 'uninstall') . " :"; + echo ""; + $rand = mt_rand(); + Dropdown::showFromArray( + "action", + [ + self::ACTION_NONE => __("Don't alter", 'uninstall'), + self::ACTION_RAZ => __('Blank'), + self::ACTION_CUSTOM => __('Per field action', 'uninstall'), + ], + [ + 'value' => (isset($this->fields["action"]) + ? $this->fields["action"] : self::ACTION_RAZ), + 'width' => '100%', + 'rand' => $rand + ] + ); + echo ""; + echo ""; + $this->showFormButtons($options); + } + + return true; + } + public static function install($migration) { /** @var DBmysql $DB */ @@ -147,6 +225,7 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', + `action` int NOT NULL DEFAULT ". self::ACTION_RAZ ." , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; From db392fec482e9cf8447aad2fbb0be18b16fc20c8 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 13:55:02 +0200 Subject: [PATCH 07/54] don't show action 'set value' for 'glpi_item' type field --- inc/modelcontainerfield.class.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 48e0fee..f4a8c61 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -132,13 +132,16 @@ public function showForm($ID, $options = []) echo "" . __('Action', 'uninstall') . " :"; echo ""; $rand = mt_rand(); + $options = [ + self::ACTION_NONE => __("Don't alter", 'uninstall'), + self::ACTION_RAZ => __('Blank') + ]; + if ($pluginFieldsField->fields['type'] !== 'glpi_item') { + $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); + } Dropdown::showFromArray( "action", - [ - self::ACTION_NONE => __("Don't alter", 'uninstall'), - self::ACTION_RAZ => __('Blank'), - self::ACTION_NEW_VALUE => __('Set value', 'uninstall'), - ], + $options, [ 'value' => (isset($this->fields["action"]) ? $this->fields["action"] : self::ACTION_RAZ), @@ -148,7 +151,11 @@ public function showForm($ID, $options = []) ); echo ""; echo ""; - echo ""; + echo ""; + if ($pluginFieldsField->fields['type'] === 'glpi_item') { + echo __('Action set value is not available for this field type', 'uninstall'); + } + echo ""; echo ""; $url = Plugin::getWebDir('uninstall') . "/ajax/fieldValueInput.php"; echo " From d63cbe472589b900352238467fac3feb4461e92a Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 14:58:19 +0200 Subject: [PATCH 08/54] different behaviors during uninstall done --- inc/uninstall.class.php | 79 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index a8bbe20..53bc830 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -316,9 +316,12 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr } if ($plug->isActivated('fields')) { - if ($model->fields['raz_plugin_fields'] == 1) { + if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_RAZ) { self::deletePluginFieldsLink($type, $id); } + if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + self::handlePluginFieldsValues($type, $id, $model); + } } //Plugin hook after uninstall @@ -508,6 +511,80 @@ public static function deletePluginFieldsLink($itemtype, $items_id) PluginFieldsContainer::preItemPurge($item); } + /** + * Update information related to the Fields plugin + * + * @param $itemtype the asset type + * @param $items_id the asset's ID in GLPI + * @param $model PluginUninstallModel + * + */ + public static function handlePluginFieldsValues($itemtype, $items_id, $model) + { + global $DB; + $item = new $itemtype(); + $item->getFromDB($items_id); + + $pluginFieldsContainer = new PluginFieldsContainer(); + $pluginFieldsField = new PluginFieldsField(); + + $pluginUninstallContainer = new PluginUninstallModelcontainer(); + $pluginUninstallField = new PluginUninstallModelcontainerfield(); + + // first level foreach & condition of first level if are copied from PluginFieldsContainer::preItemPurge + $existingFieldsContainers = $pluginFieldsContainer->find(); + foreach($existingFieldsContainers as $fieldsContainer) { + $itemtypes = json_decode($fieldsContainer['itemtypes']); + if (in_array($itemtype, $itemtypes)) { + if ($pluginUninstallContainer->getFromDBByCrit([ + 'plugin_uninstall_models_id' => $model->getID(), + 'plugin_fields_containers_id' => $fieldsContainer['id'] + ])) { + if ($pluginUninstallContainer->fields['action'] != PluginUninstallModelcontainer::ACTION_NONE) { + $classname = 'PluginFields' . $itemtype . getSingular($fieldsContainer['name']); + $obj = new $classname(); + if ($pluginUninstallContainer->fields['action'] == PluginUninstallModelcontainer::ACTION_RAZ) { + // same as PluginFieldsContainer::preItemPurge + $obj->deleteByCriteria(['items_id' => $item->fields['id']], true); + } else if ($pluginUninstallContainer->fields['action'] == PluginUninstallModelcontainer::ACTION_CUSTOM) { + $uninstallFields = $pluginUninstallField->find([ + 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID() + ]); + $fieldsFields = $pluginFieldsField->find([ + 'plugin_fields_containers_id' => $fieldsContainer['id'] + ]); + foreach ($uninstallFields as $setting) { + $field = array_filter($fieldsFields, fn($e) => $e['id'] == $setting['plugin_fields_fields_id']); + $field = reset($field); + switch ($setting['action']) { + case PluginUninstallModelcontainerfield::ACTION_RAZ : + $razValue = null; + // field types which doesn't accept NULL values + if (str_starts_with($field['type'], 'dropdown') || $field['type'] == 'glpi_item') { + $razValue = 0; + } + $DB->update( + $obj->getTable(), + [$field['name'] => $razValue], + ['items_id' => $items_id] + ); + break; + case PluginUninstallModelcontainerfield::ACTION_NEW_VALUE : + $DB->update( + $obj->getTable(), + [$field['name'] => $setting['new_value']], + ['items_id' => $items_id] + ); + break; + } + } + } + } + } + } + } + } + /** * Function to remove FusionInventory information for an asset * From cd978a89b9edb2cb775ed9641438bd320e864c0a Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 15:25:18 +0200 Subject: [PATCH 09/54] show plugin fields options only for uninstall type models --- inc/model.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index d481725..33273ae 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -175,7 +175,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab[1] = self::getTypeName(1); $tab[2] = __('Replacing data', 'uninstall'); $plugin = new Plugin(); - if ($plugin->isActivated('fields')) { + if ($plugin->isActivated('fields') && $item->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { $tab[3] = __('Plugin fields options', 'uninstall'); } return $tab; @@ -744,7 +744,8 @@ public function showFormAction($item) echo ""; } - if ($plug->isActivated('fields')) { + // noticed that the field was never used in replace.class.php + if ($plug->isActivated('fields') && $this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { echo ""; echo "" . __("Additionnal fields", "fields") . ""; From 1ef58ed38b9428e159cb7c81709bbcf470637a20 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 23 May 2024 16:05:44 +0200 Subject: [PATCH 10/54] improved display --- front/modelcontainer.form.php | 10 +--- inc/model.class.php | 10 +++- inc/modelcontainer.class.php | 83 ++++++++++++++++++++++++++++--- inc/modelcontainerfield.class.php | 2 +- 4 files changed, 87 insertions(+), 18 deletions(-) diff --git a/front/modelcontainer.form.php b/front/modelcontainer.form.php index 74e7c58..dfcd617 100644 --- a/front/modelcontainer.form.php +++ b/front/modelcontainer.form.php @@ -46,15 +46,7 @@ "PluginUninstallModel", "model" ); - $container->getFromDB($_GET['id']); - $container->showForm($_GET['id']); - if ($container->fields['action'] == $container::ACTION_CUSTOM) { - echo ""; - echo ""; - echo "
" . __('Fields', 'fields') . - "
"; - Search::show('PluginUninstallModelcontainerfield'); - } + $container->display(['id' => $_GET['id']]); Html::footer(); } diff --git a/inc/model.class.php b/inc/model.class.php index 33273ae..9b1f6fc 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -799,7 +799,15 @@ public function showFormPluginFields($item) echo ""; echo "" . __('Plugin fields blocks', 'uninstall') . ""; - Search::show('PluginUninstallModelcontainer'); + $parameters = [ + 'start' => 0, + 'is_deleted' => 0, + 'sort' => 1, + 'order' => 'DESC', + 'reset' => 'reset', + 'criteria' => [], + ]; + Search::showList(PluginUninstallModelcontainer::class, $parameters); } else { echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; return false; diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index 03a0af4..b7e7e11 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -45,6 +45,52 @@ public static function getTypeName($nb = 0) return __("Plugin fields block", "uninstall"); } + public static function getActions() { + return [ + self::ACTION_NONE => __("Don't alter", 'uninstall'), + self::ACTION_RAZ => __('Blank'), + self::ACTION_CUSTOM => __('Per field action', 'uninstall'), + ]; + } + + public function defineTabs($options = []) + { + $ong = []; + $this->addStandardTab(__CLASS__, $ong, $options); + $this->addStandardTab('Log', $ong, $options); + return $ong; + } + + public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) + { + switch ($item->getType()) { + case __CLASS__: + switch ($tabnum) { + case 1: + $item->showForm($item->getID()); + break; + case 2: + $item->showFields($item); + break; + } + } + return true; + } + + public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) + { + switch ($item->getType()) { + case __CLASS__: + $tab = []; + $tab[1] = self::getTypeName(1); + if ($item->fields['action'] == self::ACTION_CUSTOM) { + $tab[2] = __('Fields'); + } + return $tab; + } + return ''; + } + public function rawSearchOptions() { $tab = []; @@ -82,11 +128,19 @@ public function rawSearchOptions() 'massiveaction' => false ]; + $tab[] = [ + 'id' => 4, + 'table' => self::getTable(), + 'field' => 'action', + 'name' => __('Action', 'uninstall'), + 'datatype' => 'specific', + 'massiveaction' => false + ]; + return $tab; } /** - * Copy from PluginFieldsContainer * @param $field * @param $values * @param array $options @@ -104,7 +158,6 @@ public static function getSpecificValueToDisplay($field, $values, array $options $count = count($types); $i = 1; foreach ($types as $type) { - // prevent usage of plugin class if not loaded if (!class_exists($type)) { continue; } @@ -116,6 +169,8 @@ public static function getSpecificValueToDisplay($field, $values, array $options $i++; } return $obj; + case 'action': + return self::getActions()[$values[$field]]; } return ''; @@ -190,11 +245,7 @@ public function showForm($ID, $options = []) $rand = mt_rand(); Dropdown::showFromArray( "action", - [ - self::ACTION_NONE => __("Don't alter", 'uninstall'), - self::ACTION_RAZ => __('Blank'), - self::ACTION_CUSTOM => __('Per field action', 'uninstall'), - ], + self::getActions(), [ 'value' => (isset($this->fields["action"]) ? $this->fields["action"] : self::ACTION_RAZ), @@ -210,6 +261,24 @@ public function showForm($ID, $options = []) return true; } + public function showFields($item) { + if ($item->fields['action'] == self::ACTION_CUSTOM) { + echo ""; + echo ""; + echo "
" . __('Fields', 'fields') . + "
"; + $parameters = [ + 'start' => 0, + 'is_deleted' => 0, + 'sort' => 1, + 'order' => 'DESC', + 'reset' => 'reset', + 'criteria' => [], + ]; + Search::showList(PluginUninstallModelcontainerfield::class, $parameters); + } + } + public static function install($migration) { /** @var DBmysql $DB */ diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index f4a8c61..dda8b5f 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -81,7 +81,7 @@ public function rawSearchOptions() 'id' => 4, 'table' => self::getTable(), 'field' => 'action', - 'name' => __("Action"), + 'name' => __('Action', 'uninstall'), 'datatype' => 'specific', 'massiveaction' => true, 'nosearch' => true, From 139b8163ff9aae171a5d94127d141ee58b3aca68 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Fri, 24 May 2024 14:01:10 +0200 Subject: [PATCH 11/54] temp fix to fields 'type' (from PluginFieldsField) display in containerfield list display --- inc/modelcontainerfield.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index dda8b5f..133cdd5 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -63,14 +63,15 @@ public function rawSearchOptions() 'table' => PluginFieldsField::getTable(), 'field' => 'label', 'name' => __('Label'), - 'datatype' => 'dropdown', + 'datatype' => 'text', 'linkfield' => 'plugin_fields_fields_id', ]; + // temp solution to the fact that the plugin Fields does not provide the specific value display for type $tab[] = [ 'id' => 3, - 'table' => PluginFieldsField::getTable(), - 'field' => 'type', + 'table' => self::getTable(), + 'field' => 'plugin_fields_fields_id', 'name' => __("Type"), 'datatype' => 'specific', 'massiveaction' => false, @@ -194,10 +195,11 @@ public static function getSpecificValueToDisplay($field, $values, array $options $values = [$field => $values]; } switch ($field) { - case 'type': - // TODO why does type never go there ? - $types = PluginFieldsField::getType(false); - return $types[$values[$field]]; + case 'plugin_fields_fields_id': + $pluginField = new PluginFieldsField(); + $pluginField->getFromDB($values[$field]); + $types = PluginFieldsField::getTypes(true); + return $types[$pluginField->fields['type']]; case 'action': switch ($values[$field]) { case self::ACTION_NONE: From e2f79be82e7ef47322ef9cae2153b886d1064cb1 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 30 May 2024 16:00:27 +0200 Subject: [PATCH 12/54] add options for replace type models --- hook.php | 2 +- inc/model.class.php | 66 +++++++++++++++++++++++++------ inc/modelcontainer.class.php | 45 ++++++++++++++++----- inc/modelcontainerfield.class.php | 33 ++++++++++------ 4 files changed, 112 insertions(+), 34 deletions(-) diff --git a/hook.php b/hook.php index 50dc0de..114959f 100644 --- a/hook.php +++ b/hook.php @@ -152,7 +152,7 @@ function plugin_uninstall_hook_add_field($item) $uninstallField->add([ 'plugin_uninstall_modelcontainers_id' => $container['id'], 'plugin_fields_fields_id' => $fieldId, - 'action' => $uninstallField::ACTION_RAZ + 'action' => $uninstallField::ACTION_NONE ]); } } diff --git a/inc/model.class.php b/inc/model.class.php index 9b1f6fc..407c692 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -38,9 +38,14 @@ class PluginUninstallModel extends CommonDBTM const TYPE_MODEL_UNINSTALL = 1; const TYPE_MODEL_REPLACEMENT = 2; + // do nothing const PLUGIN_FIELDS_ACTION_NONE = 0; + // delete values, uninstall only const PLUGIN_FIELDS_ACTION_RAZ = 1; - const PLUGIN_FIELDS_ACTION_ADVANCED = 2; + // copy values, replace only + const PLUGIN_FIELDS_ACTION_COPY = 2; + // choose action for each container individually + const PLUGIN_FIELDS_ACTION_ADVANCED = 3; public static function getTypeName($nb = 0) @@ -175,7 +180,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab[1] = self::getTypeName(1); $tab[2] = __('Replacing data', 'uninstall'); $plugin = new Plugin(); - if ($plugin->isActivated('fields') && $item->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { + if ($plugin->isActivated('fields') && $item->fields['action_plugin_fields'] == self::PLUGIN_FIELDS_ACTION_ADVANCED) { $tab[3] = __('Plugin fields options', 'uninstall'); } return $tab; @@ -745,7 +750,7 @@ public function showFormAction($item) } // noticed that the field was never used in replace.class.php - if ($plug->isActivated('fields') && $this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { + if ($plug->isActivated('fields')) { echo ""; echo "" . __("Additionnal fields", "fields") . ""; @@ -753,16 +758,23 @@ public function showFormAction($item) echo ""; echo "" . __('Fields plugin informations', 'uninstall') . ""; echo ""; + $choices = [ + self::PLUGIN_FIELDS_ACTION_NONE => __("Do nothing", 'uninstall') + ]; + if ($this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { + $choices[self::PLUGIN_FIELDS_ACTION_RAZ] = __('Blank'); + } else { + $choices[self::PLUGIN_FIELDS_ACTION_COPY] = __('Copy values', 'uninstall'); + } + $choices[self::PLUGIN_FIELDS_ACTION_ADVANCED] = __('Advanced options', 'uninstall'); + $defaultValue = $this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL ? + self::PLUGIN_FIELDS_ACTION_RAZ : self::PLUGIN_FIELDS_ACTION_NONE; Dropdown::showFromArray( "action_plugin_fields", + $choices, [ - self::PLUGIN_FIELDS_ACTION_NONE => __("Don't alter", 'uninstall'), - self::PLUGIN_FIELDS_ACTION_RAZ => __('Blank'), - self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall'), - ], - [ - 'value' => (isset($this->fields["action_plugin_fields"]) - ? $this->fields["action_plugin_fields"] : self::PLUGIN_FIELDS_ACTION_RAZ), + 'value' => isset($this->fields["action_plugin_fields"]) ? + $this->fields["action_plugin_fields"] : $defaultValue, 'width' => '100%' ] ); @@ -1388,8 +1400,38 @@ public static function install($migration) } // from 2.9.1 to 2.10.0 - if ($DB->fieldExists($table, 'raz_plugin_fields')) { - $migration->changeField($table, 'raz_plugin_fields', 'action_plugin_fields', 'int', ['value' => self::PLUGIN_FIELDS_ACTION_RAZ]); + if (!$DB->fieldExists($table, 'action_plugin_fields')) { + $migration->addField($table, 'action_plugin_fields', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); + $migration->addPostQuery( + // uninstall with no raz + $DB->buildUpdate( + $table, + ['action_plugin_fields' => '0'], + [ + 'raz_plugin_fields' => '0', + 'types_id' => '1' + ] + ) + ); + $migration->addPostQuery( + // uninstall with raz + $DB->buildUpdate( + $table, + ['action_plugin_fields' => '1'], + [ + 'raz_plugin_fields' => '1', + 'types_id' => '1' + ] + ) + ); + $migration->addPostQuery( + // replace default value + $DB->buildUpdate( + $table, + ['action_plugin_fields' => '0'], + ['types_id' => '2'] + ) + ); } } else { // plugin never installed diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index b7e7e11..cfd1e34 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -34,22 +34,46 @@ class PluginUninstallModelcontainer extends CommonDBTM public static $rightname = "uninstall:profile"; + // do nothing const ACTION_NONE = 0; - // delete value + // delete values, uninstall only const ACTION_RAZ = 1; - // set value to new_value - const ACTION_CUSTOM = 2; + // copy values, replace only + const ACTION_COPY = 2; + // choose action for each field individually + const ACTION_CUSTOM = 3; + public static function getTypeName($nb = 0) { return __("Plugin fields block", "uninstall"); } - public static function getActions() { + /** + * Get the list of actions available for an instance, or all available actions + * @param $self PluginUninstallModelcontainer|null + * @return array value => label + */ + public static function getActions($self = null) { + if ($self) { + $model = new PluginUninstallModel(); + $model->getFromDB($self->fields['plugin_uninstall_models_id']); + $values = [ + self::ACTION_NONE => __("Do nothing", 'uninstall'), + ]; + if ($model->fields['types_id'] == $model::TYPE_MODEL_UNINSTALL) { + $values[self::ACTION_RAZ] = __('Blank'); + } else { + $values[self::ACTION_COPY] = __('Copy values', 'uninstall'); + } + $values[self::ACTION_CUSTOM] = __('Per field action', 'uninstall'); + return $values; + } return [ - self::ACTION_NONE => __("Don't alter", 'uninstall'), + self::ACTION_NONE => __("Do nothing", 'uninstall'), self::ACTION_RAZ => __('Blank'), - self::ACTION_CUSTOM => __('Per field action', 'uninstall'), + self::ACTION_COPY => __('Copy values', 'uninstall'), + self::ACTION_CUSTOM => __('Per field action', 'uninstall') ]; } @@ -243,12 +267,15 @@ public function showForm($ID, $options = []) echo "" . __('Action', 'uninstall') . " :"; echo ""; $rand = mt_rand(); + $model = new PluginUninstallModel(); + $model->getFromDB($this->fields['plugin_uninstall_models_id']); + $defaultValue = $model->fields['types_id'] == $model::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; Dropdown::showFromArray( "action", - self::getActions(), + self::getActions($this), [ 'value' => (isset($this->fields["action"]) - ? $this->fields["action"] : self::ACTION_RAZ), + ? $this->fields["action"] : $defaultValue), 'width' => '100%', 'rand' => $rand ] @@ -294,7 +321,7 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT ". self::ACTION_RAZ ." , + `action` int NOT NULL DEFAULT ". self::ACTION_NONE ." , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 133cdd5..070bcc7 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -33,12 +33,14 @@ class PluginUninstallModelcontainerfield extends CommonDBTM public $dohistory = true; public static $rightname = "uninstall:profile"; - // don't modify the field + // do nothing const ACTION_NONE = 0; - // delete value + // delete value, uninstall only const ACTION_RAZ = 1; - // set value to new_value + // set value to new_value, uninstall only const ACTION_NEW_VALUE = 2; + // copy value, replace only + const ACTION_COPY = 3; public static function getTypeName($nb = 0) { @@ -100,6 +102,10 @@ public function showForm($ID, $options = []) $this->showFormHeader($options); $pluginFieldsField = new PluginFieldsField(); + $pluginUninstallContainer = new PluginUninstallModelcontainer(); + $pluginUninstallContainer->getFromDB($this->fields['plugin_uninstall_modelcontainers_id']); + $pluginUninstallModel = new PluginUninstallModel(); + $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { echo ""; echo "" . __('Field informations', 'uninstall') . @@ -134,18 +140,23 @@ public function showForm($ID, $options = []) echo ""; $rand = mt_rand(); $options = [ - self::ACTION_NONE => __("Don't alter", 'uninstall'), - self::ACTION_RAZ => __('Blank') + self::ACTION_NONE => __("Do nothing", 'uninstall'), ]; - if ($pluginFieldsField->fields['type'] !== 'glpi_item') { - $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); + if ($pluginUninstallModel->fields['types_id'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { + $options[self::ACTION_RAZ] = __('Blank'); + if ($pluginFieldsField->fields['type'] !== 'glpi_item') { + $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); + } + } else { + $options[self::ACTION_COPY] = __('Copy value'); } + Dropdown::showFromArray( "action", $options, [ 'value' => (isset($this->fields["action"]) - ? $this->fields["action"] : self::ACTION_RAZ), + ? $this->fields["action"] : self::ACTION_NONE), 'width' => '100%', 'rand' => $rand ] @@ -182,8 +193,6 @@ public function showForm($ID, $options = []) "; $this->showFormButtons($options); - } else { - // TODO warning message + button to delete } return true; @@ -203,7 +212,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options case 'action': switch ($values[$field]) { case self::ACTION_NONE: - return __("Don't alter", 'uninstall'); + return __("Do nothing", 'uninstall'); case self::ACTION_RAZ: return __('Blank'); case self::ACTION_NEW_VALUE: @@ -229,7 +238,7 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_modelcontainers_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_fields_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT ". self::ACTION_RAZ ." , + `action` int NOT NULL DEFAULT ". self::ACTION_NONE ." , `new_value` varchar(255), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; From 35f46fe895d477f9525536d370e69a64192d0833 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 30 May 2024 17:39:09 +0200 Subject: [PATCH 13/54] specific actions for plugin fields during replacement --- inc/replace.class.php | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/inc/replace.class.php b/inc/replace.class.php index 0b237f6..9e2989b 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -444,6 +444,31 @@ public static function replace($type, $model_id, $tab_ids, $location) } } + if ($plug->isActivated('fields')) { + $pluginFieldsContainer = new PluginFieldsContainer(); + if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_COPY) { + $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); + foreach ($containers as $container) { + self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); + } + } + if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $pluginUninstallContainer = new PluginUninstallModelcontainer(); + $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); + foreach ($containers as $container) { + $pluginUninstallContainer->getFromDBByCrit([ + 'plugin_fields_containers_id' => $container['id'], + 'plugin_uninstall_models_id' => $model->getID() + ]); + if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_COPY) { + self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); + } else if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { + self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type, $pluginUninstallContainer); + } + } + } + } + // METHOD REPLACEMENT 1 : Purge switch ($model->fields['replace_method']) { case self::METHOD_PURGE: @@ -1082,4 +1107,57 @@ public static function getPdfUserPreference($item) return $tabs; } } + + /** + * Create the query + * @param $container array data of PluginFieldsContainer + * @param $olditem CommonDBTM + * @param $newitem CommonDBTM + * @param $type string + * @param $pluginUninstallContainer PluginUninstallModelcontainer + * @return void + */ + public static function handlePluginFieldsContainerValues($container, $olditem, $newitem, $type, $pluginUninstallContainer = null) { + global $DB; + $pluginFieldsField = new PluginFieldsField(); + $pluginUninstallField = new PluginUninstallModelcontainerfield(); + $table = 'glpi_plugin_fields_'.strtolower($type).$container['name'].'s'; + $values = $DB->request([ + 'FROM' => $table, + 'WHERE' => [ + 'items_id' => $olditem->getID(), + 'itemtype' => $type, + 'plugin_fields_containers_id' => $container['id'] + ] + ]); + if ($values->count()) { + $fields = $pluginFieldsField->find(['plugin_fields_containers_id' => $container['id']]); + $parameters = []; + foreach($fields as $field) { + if ($pluginUninstallContainer && $pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { + if ($pluginUninstallField->getFromDBByCrit([ + 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID(), + 'plugin_fields_fields_id' => $field['id'] + ])) { + if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { + $parameters[$field['name']] = $values->current()[$field['name']]; + } + } + } else { + $parameters[$field['name']] = $values->current()[$field['name']]; + } + } + if (count($parameters)) { + $DB->updateOrInsert( + $table, + $parameters, + [ + 'items_id' => $newitem->getID(), + 'itemtype' => $type, + 'plugin_fields_containers_id' => $container['id'] + ] + ); + } + } + } } From 3de99d2cf31937f9dab7ca701f5548bfbf11beeb Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Fri, 31 May 2024 09:37:33 +0200 Subject: [PATCH 14/54] fr translations for new texts --- inc/model.class.php | 4 +- inc/modelcontainer.class.php | 14 +- inc/modelcontainerfield.class.php | 12 +- locales/fr_FR.mo | Bin 6085 -> 7087 bytes locales/fr_FR.po | 505 +++++++++++++++++------------- 5 files changed, 298 insertions(+), 237 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index 407c692..fc86167 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -759,12 +759,12 @@ public function showFormAction($item) echo "" . __('Fields plugin informations', 'uninstall') . ""; echo ""; $choices = [ - self::PLUGIN_FIELDS_ACTION_NONE => __("Do nothing", 'uninstall') + self::PLUGIN_FIELDS_ACTION_NONE => __('Do nothing') ]; if ($this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { $choices[self::PLUGIN_FIELDS_ACTION_RAZ] = __('Blank'); } else { - $choices[self::PLUGIN_FIELDS_ACTION_COPY] = __('Copy values', 'uninstall'); + $choices[self::PLUGIN_FIELDS_ACTION_COPY] = __('Copy'); } $choices[self::PLUGIN_FIELDS_ACTION_ADVANCED] = __('Advanced options', 'uninstall'); $defaultValue = $this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL ? diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index cfd1e34..bd0ec33 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -59,20 +59,20 @@ public static function getActions($self = null) { $model = new PluginUninstallModel(); $model->getFromDB($self->fields['plugin_uninstall_models_id']); $values = [ - self::ACTION_NONE => __("Do nothing", 'uninstall'), + self::ACTION_NONE => __('Do nothing'), ]; if ($model->fields['types_id'] == $model::TYPE_MODEL_UNINSTALL) { $values[self::ACTION_RAZ] = __('Blank'); } else { - $values[self::ACTION_COPY] = __('Copy values', 'uninstall'); + $values[self::ACTION_COPY] = __('Copy'); } $values[self::ACTION_CUSTOM] = __('Per field action', 'uninstall'); return $values; } return [ - self::ACTION_NONE => __("Do nothing", 'uninstall'), + self::ACTION_NONE => __('Do nothing'), self::ACTION_RAZ => __('Blank'), - self::ACTION_COPY => __('Copy values', 'uninstall'), + self::ACTION_COPY => __('Copy'), self::ACTION_CUSTOM => __('Per field action', 'uninstall') ]; } @@ -156,7 +156,7 @@ public function rawSearchOptions() 'id' => 4, 'table' => self::getTable(), 'field' => 'action', - 'name' => __('Action', 'uninstall'), + 'name' => __('Action'), 'datatype' => 'specific', 'massiveaction' => false ]; @@ -264,7 +264,7 @@ public function showForm($ID, $options = []) echo "" . __('Uninstall action', 'uninstall') . ""; echo ""; - echo "" . __('Action', 'uninstall') . " :"; + echo "" . __('Action') . " :"; echo ""; $rand = mt_rand(); $model = new PluginUninstallModel(); @@ -292,7 +292,7 @@ public function showFields($item) { if ($item->fields['action'] == self::ACTION_CUSTOM) { echo ""; echo ""; - echo "
" . __('Fields', 'fields') . + echo "" . __('Fields') . "
"; $parameters = [ 'start' => 0, diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 070bcc7..affabae 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -84,7 +84,7 @@ public function rawSearchOptions() 'id' => 4, 'table' => self::getTable(), 'field' => 'action', - 'name' => __('Action', 'uninstall'), + 'name' => __('Action'), 'datatype' => 'specific', 'massiveaction' => true, 'nosearch' => true, @@ -136,11 +136,11 @@ public function showForm($ID, $options = []) echo "" . __('Uninstall action', 'uninstall') . ""; echo ""; - echo "" . __('Action', 'uninstall') . " :"; + echo "" . __('Action') . " :"; echo ""; $rand = mt_rand(); $options = [ - self::ACTION_NONE => __("Do nothing", 'uninstall'), + self::ACTION_NONE => __('Do nothing'), ]; if ($pluginUninstallModel->fields['types_id'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { $options[self::ACTION_RAZ] = __('Blank'); @@ -148,7 +148,7 @@ public function showForm($ID, $options = []) $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); } } else { - $options[self::ACTION_COPY] = __('Copy value'); + $options[self::ACTION_COPY] = __('Copy'); } Dropdown::showFromArray( @@ -212,9 +212,11 @@ public static function getSpecificValueToDisplay($field, $values, array $options case 'action': switch ($values[$field]) { case self::ACTION_NONE: - return __("Do nothing", 'uninstall'); + return __('Do nothing'); case self::ACTION_RAZ: return __('Blank'); + case self::ACTION_COPY: + return __('Copy'); case self::ACTION_NEW_VALUE: return __('Set value', 'uninstall'); } diff --git a/locales/fr_FR.mo b/locales/fr_FR.mo index bb630e1bd052d8c5d0e524628b29bdbd8621301c..a1516c0a3e0261002adce757de9555703028af4b 100644 GIT binary patch delta 2846 zcma)+Yitx%6vuBXY)hft777JH9Ll38ZRvvwRNjRmP)m6RC4fVB+AeH&H#@rpw01S3 zQ4^za6pbH5Vj{svNG$SE5{Z>WqA`X<48cc?iN+5k5=Hsq?>{@Oh>3WzXMXqIxpVG$ z-Tip}sfF1q<43(}knQL+^g_NdS=c|C2Xe5$m@qs9o8WVB96Srh!waw!egh}MtFQ!y z3XK^HC&CIi1I~hrp-k_Fe4jND2E{BKfK%bq(1ORH41WYG;g@hS{0+9i@R;2C7C4i6 zAJqFdpd1^7a%2d~k&D6lckoW;*I>Cq4HxA;oCW3SQaBrKgWC8QoC}Y@Dex?mW0#;Z z_A^vu1)Op>tcG%+4a$K%P~XMjB={`kY;zQrE7d0$$l!;;i_alJnoHUMzlU<<_u&0_ z@-IWvp!PMwdbk8ClW{0}{csL^0p0^oLj`sPw!=|u&Q4&kg@F$0hMM<7)$%2%TD=2j z!1rJXeg@^xMM$~LRj325Lwq!qge?bap)#IihN(dbP4%i$ie^%4e$(9Eq{Va zSuvfbl2k!Ov>eJnM=*aFveoQ|+W#m#m1oQ=Pywwj<8b&8R7s9P1^7PXXNJniziRds zGaYap>ccVYz6(x=_rfJ`6zqn2AAaRg%ZYrl9giE1Ha0WKO z%gVnT2xFC@nGa>S1uBJ`piv3K9U0qp$^;)b-ND3 zD)<(xhuQNCRJ%We4YN2^4y}Od?nfXt&Et^1F)u@Y=4h~f2C4*~LZ$R;D93(*IxvKH zRKrw4UE>C*OmBlLbpN{;DB|N#20nn*@Do@EuR%pJo3MAmHmLc#P?3BAbv^%p3Z#jRNlrpJ za2YCdqY2xBv!Nnyg$i&xROFF>890~o%`*&WTC*ILp=MMYb+}S1X+=BG6{zalh^|L< zpp45QiJD5He@KZ+w++2d6J$va{x#Jw%h|rrsD2|U14`REf0Y{mYf$xqM7KcFgeq$i z-2mFh7o}RV6m3VhqKiGz(fR28{z|T&f?)v8*I($cSPZtKsUcV3W;T@=&N%h@`4of`) zT|>!+9Q;2x^~theF04g2qjTip1E^WqnT{sn7QgOPB9k1RyH48bvtt>@in>-jk+$qU zI~ue1#vH3Fk+RY~EO$knSj0*nN;+O$sInx|XU998h?PjnqPHdFSPA5{$R!72#MAKGd?Sk5dqLG?pQWp95>*ScWs@!o_XHO#P zMtNl`1rD3yRgRmslD2C_qHZz~kE(3R1aCSWzg||v;WN9Ja_>uI(&Q`S-6)w}y3sG4 zt76AH&z*3*ig0D=cHbzucT&Ak*Kxf?;XPASL9_0r0$P!bpH}Zk_=&+)rJ1}Y7IJ6Y zx-BT8|I)SGOfnfeccRycr|oEJ@Oat5{BV0B)91u+Iv0>Pz5H-lOAuz#CJg!R9V`DK zD?fDff7x_gzv0NnZTGdv@c-EuWUBJ^Hs3xxF>l2Aks1v?HK{PKG`M^tetFMV-2WE~ CjNDiN delta 1808 zcmY+^Uu+ar6vy$~ZvRmW)7_S>E!a+Ll_D+dZVQFVzfxOjXexz-M5HvEx~yAD3tcv- z(M%9|s!GVk_+Z7vXe1_z$;OcQzyk;xVj>u$hJXnnJ`hllNHmcIzrWq-12;YMnVs3$ zd+s@Rdb0D}GVixg(YuDxPb?&M6dDu9nIaAhx5O9+8?geT7{awUABXS}OkxeDu^Fdv zE`Es%@HD!387uKWY&6C*6{W^BabYPwibL3gWB&Co@Nqt0^6%e6B`~jyz(!O85v<15 znEM@6LSy&@zJYak0$cDb)-u1j#fdU1nUk+T4Qd4)*nrQYCVT}o;agaX?_(IhLjKJ6 z9F)M%sNcKkU%!t`VM@yL_Z?Is%@}5WvyKyeVH-wq1Xa4D_#}Rai}5^aC3kQT!z{ZP z6G$n|ZltQ_ZPWzEkYbsWsOL{1f94toCH@C`T2T>=RWGZMWX)pi#CD9~Zd417qgH+f zRoW}4mHv%-u9&R#dk*S*_4sjtF)LA(xynsd@-9|ku|xe;;#zi?zOV`(!$Eus$B}2v zd#ILt;(GzL!rQn6%gI8OT7jy>Fusf)s$&157E&L~w{!@Vz`h{$*93>TppsbB=J^b@ zg0rZVUPUEz5A~qSGBjZaYJwL~yZj(7!VfTt=TN2p$G_jm!&>kf)Y~@faiW#Kid4}Y zK_xQdU(cdS`W-U2`305O4b+4I9@g8_fGpB%!1cHlwXkE@iXUMFe?TR!eh-7Uh!bt1 z!>H0tqk8!{suHLC&lm9-K3_&9+CY}t6RoI(Hv5ht`_sIM`u-7Iia%is1}LX0(2B0! z{{c>DquGPX_;u7urcn>fAbTh`R&i7tVnjc|EfXNL!lwyMsL8bJml11-dO~9@k=rY{ zK^GW~8O?7bs$#l`6@<#I-jMJ^!+q#eKG}_2TTc`cv^Y0QE^P#rNTZWbznY0AqK8nU^^c&N&@QAuy}1`$ z^;A>UfZ4H*lhs6@e_=Ulhp@r;h0*<~$qARg6c?Wc3Uv6*>)+Wk(4v$?xx zQ}@PRcU$k4tKyI|K2FWG0?Wbh*2x zM*6nc3zZ}DXLCzurrhyFKEH%L9&E9{23vR-w#IG1SlZs<@!_Ur1G a3T>?Bko~six*e!}kR7foEwGsdUH=2rUBv|e diff --git a/locales/fr_FR.po b/locales/fr_FR.po index 389253b..8c959e5 100644 --- a/locales/fr_FR.po +++ b/locales/fr_FR.po @@ -2,320 +2,379 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. -# +# # Translators: # Walid Nouh, 2017 # Johan Cwiklinski, 2017 # alexandre delaunay , 2018 # Cédric Anne, 2023 -# +# #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-06-30 12:39+0000\n" -"PO-Revision-Date: 2017-01-03 22:10+0000\n" +"POT-Creation-Date: 2024-05-31 09:34+0200\n" +"PO-Revision-Date: 2024-05-31 09:35+0200\n" "Last-Translator: Cédric Anne, 2023\n" -"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/fr_FR/)\n" +"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/" +"fr_FR/)\n" +"Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fr_FR\n" -"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" +"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % " +"1000000 == 0 ? 1 : 2;\n" +"X-Generator: Poedit 3.4.2\n" -#: inc/model.class.php:244 inc/model.class.php:841 -msgid "Action on group" -msgstr "Action sur le groupe" +#: hook.php:44 inc/uninstall.class.php:344 +msgid "Uninstall" +msgstr "Désinstaller" -#: inc/model.class.php:281 -msgid "Add template" -msgstr "Ajouter un modèle" +#: setup.php:155 +msgid "Item's Lifecycle (uninstall)" +msgstr "Cycle de vie des matériels (uninstall)" -#: inc/model.class.php:625 -msgid "Additionnal fields" -msgstr "Champs additionnels" +#: ajax/fieldValueInput.php:53 +msgid "Allowed values" +msgstr "Valeurs permises" -#: inc/model.class.php:249 -msgid "Affect to a new group" -msgstr "Affecter à une nouvelle valeur" +#: ajax/locations.php:49 inc/preference.class.php:102 inc/replace.class.php:682 +msgid "Keep previous location" +msgstr "Garder l'ancien lieu" -#: inc/uninstall.class.php:841 -msgid "Apply model" -msgstr "Appliquer un modèle" +#: ajax/locations.php:50 inc/preference.class.php:103 inc/replace.class.php:686 +msgid "Empty location" +msgstr "Vider le lieu" -#: inc/replace.class.php:136 -msgid "Archive of old material" -msgstr "Archive de l'ancien matériel" +#: front/action.php:64 inc/replace.class.php:562 +msgid "Replacement successful" +msgstr "Remplacement effectué avec succès" -#: inc/replace.class.php:567 inc/model.class.php:421 inc/model.class.php:852 -msgid "Archiving method of the old material" -msgstr "Méthode d'archivage de l'ancien matériel" +#: front/action.php:114 inc/uninstall.class.php:370 +msgid "Uninstallation successful" +msgstr "Désinstallation effectuée avec succès" + +#: inc/config.class.php:41 inc/model.class.php:81 inc/uninstall.class.php:39 +msgid "Item's Lifecycle" +msgstr "Cycle de vie des matériels" + +#: inc/config.class.php:85 +msgid "Shortcuts" +msgstr "Raccourcis" + +#: inc/config.class.php:91 +msgid "Location preferences" +msgstr "Préférences de lieux" + +#: inc/config.class.php:99 +msgid "Replace status dropdown by plugin actions" +msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" + +#: inc/model.class.php:113 inc/model.class.php:1171 inc/model.class.php:1211 +msgid "Uninstallation" +msgstr "Désinstallation" -#: inc/model.class.php:112 +#: inc/model.class.php:115 inc/model.class.php:1173 inc/model.class.php:1213 +#: inc/replace.class.php:67 inc/replace.class.php:115 +msgid "Replacement" +msgstr "Remplacement" + +#: inc/model.class.php:126 +msgid "PDF Archiving" +msgstr "Archivage PDF" + +#: inc/model.class.php:128 msgid "CSV Archiving" msgstr "Archivage CSV" -#: inc/replace.class.php:672 -msgid "Choices for item to replace" -msgstr "Choix des matériels de remplacement" - -#: inc/replace.class.php:625 inc/model.class.php:441 -msgid "Connections with other materials" -msgstr "Connexion avec les autres matériels" +#: inc/model.class.php:131 +msgid "Purge" +msgstr "Purge" -#: inc/model.class.php:116 +#: inc/model.class.php:132 msgid "Delete + Comment" msgstr "Suppression + Commentaires" -#: inc/model.class.php:629 -msgid "Delete Fields plugin informations" -msgstr "Supprimer les informations du plugin Fields" +#: inc/model.class.php:133 +msgid "Keep + Comment" +msgstr "Ne pas supprimer + Commentaires" -#: inc/model.class.php:613 -msgid "Delete computer in FusionInventory" -msgstr "Supprimer le lien avec FusionInventory" +#: inc/model.class.php:181 +msgid "Replacing data" +msgstr "Remplacement des données" -#: inc/model.class.php:593 inc/model.class.php:814 -msgid "Delete computer in OCSNG" -msgstr "Supprimer l'ordinateur dans OCSNG" +#: inc/model.class.php:184 +msgid "Plugin fields options" +msgstr "Options du plugin champs supplémentaires" -#: inc/model.class.php:380 -msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" -msgstr "" -"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " -"verrous, informations relatives à l'agent, ...)" +#: inc/model.class.php:240 inc/model.class.php:1013 +msgid "Type of template" +msgstr "Type de modèle" -#: inc/model.class.php:599 inc/model.class.php:822 -msgid "Delete link with computer in OCSNG" -msgstr "Supprimer le lien avec la machine OCS" +#: inc/model.class.php:249 inc/model.class.php:977 +msgid "Transfer's model to use" +msgstr "Modèle de transfert à utiliser" -#: inc/model.class.php:298 inc/model.class.php:703 +#: inc/model.class.php:270 inc/replace.class.php:696 +msgid "New status of the computer" +msgstr "Nouveau statut du matériel" + +#: inc/model.class.php:279 inc/model.class.php:1023 +msgid "Action on group" +msgstr "Action sur le groupe" + +#: inc/model.class.php:283 inc/model.class.php:1178 +msgid "Keep in the current group" +msgstr "Conserver la valeur actuelle" + +#: inc/model.class.php:284 +msgid "Affect to a new group" +msgstr "Affecter à une nouvelle valeur" + +#: inc/model.class.php:299 +msgid "New group" +msgstr "Nouveau groupe" + +#: inc/model.class.php:319 +msgid "Add template" +msgstr "Ajouter un modèle" + +#: inc/model.class.php:322 +msgid "Manage templates" +msgstr "Gestion des modèles" + +#: inc/model.class.php:334 +msgid "Erase datas" +msgstr "Effacement de données" + +#: inc/model.class.php:337 inc/model.class.php:885 msgid "Delete software history (computers)" msgstr "Supprimer l'historique des logiciels (ordinateurs)" -#: inc/model.class.php:303 inc/model.class.php:862 +#: inc/model.class.php:344 inc/model.class.php:1044 msgid "Delete the whole history" msgstr "Effacement de tout l'historique" -#: inc/replace.class.php:660 inc/model.class.php:515 -msgid "Direct connections" -msgstr "connexions directes" - -#: inc/preference.class.php:99 inc/replace.class.php:593 ajax/locations.php:46 -msgid "Empty location" -msgstr "Vider le lieu" +#: inc/model.class.php:446 +msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" +msgstr "" +"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " +"verrous, informations relatives à l'agent, ...)" -#: inc/model.class.php:295 -msgid "Erase datas" -msgstr "Effacement de données" +#: inc/model.class.php:462 inc/model.class.php:525 +msgid "Informations replacement" +msgstr "Remplacement des données" -#: inc/replace.class.php:549 inc/model.class.php:392 +#: inc/model.class.php:463 inc/replace.class.php:641 msgid "General informations" msgstr "Informations générales" -#: inc/model.class.php:391 inc/model.class.php:440 -msgid "Informations replacement" -msgstr "Remplacement des données" +#: inc/model.class.php:494 inc/replace.class.php:657 +msgid "Overwrite informations (from old item to the new)" +msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" -#: inc/uninstall.class.php:718 -msgid "Item is now uninstalled" -msgstr "Matériel désinstallé" +#: inc/model.class.php:503 inc/model.class.php:1034 inc/replace.class.php:660 +msgid "Archiving method of the old material" +msgstr "Méthode d'archivage de l'ancien matériel" -#: inc/uninstall.class.php:720 -#, php-format -msgid "Item is now uninstalled with model %s" -msgstr "Matériel désinstallé avec le modèle %s" +#: inc/model.class.php:512 +msgid "Plugin PDF is installed and activated" +msgstr "Le plugin PDF est installé et activé" -#: inc/uninstall.class.php:726 -msgid "Item replaced by a new one" -msgstr "Matériel remplacé" +#: inc/model.class.php:516 +msgid "" +"Plugin PDF is not installed, you won't be able to use PDF format for " +"archiving" +msgstr "" +"Le plugin PDF n'est pas installé, vous ne pouvez pas utiliser le format PDF " +"pour l'archivage" -#: inc/uninstall.class.php:728 -#, php-format -msgid "Item replaced by a new one with model %s" -msgstr "Matériel remplacé avec le modèle %s" +#: inc/model.class.php:526 inc/replace.class.php:719 +msgid "Connections with other materials" +msgstr "Connexion avec les autres matériels" -#: inc/uninstall.class.php:734 -msgid "Item replacing an old one" -msgstr "Matériel provenant d'un remplacement" +#: inc/model.class.php:625 inc/replace.class.php:764 +msgid "Direct connections" +msgstr "connexions directes" -#: inc/uninstall.class.php:38 inc/model.class.php:66 inc/config.class.php:39 -msgid "Item's Lifecycle" -msgstr "Cycle de vie des matériels" +#: inc/model.class.php:704 +msgid "OCSNG link" +msgid_plural "OCSNG links" +msgstr[0] "Lien OCSNG" +msgstr[1] "Liens OCSNG" +msgstr[2] "Liens OCSNG" -#: setup.php:135 -msgid "Item's Lifecycle (uninstall)" -msgstr "Cycle de vie des matériels (uninstall)" +#: inc/model.class.php:707 +msgid "These options only apply to computers coming from OCSNG" +msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" -#: inc/uninstall.class.php:858 -msgid "Item's location after applying model" -msgstr "Lieu de l'élément après application du modèle" +#: inc/model.class.php:712 inc/model.class.php:996 +msgid "Delete computer in OCSNG" +msgstr "Supprimer l'ordinateur dans OCSNG" -#: inc/preference.class.php:73 -msgid "Item's location after uninstall" -msgstr "Lieu du matériel après désinstallation" +#: inc/model.class.php:722 inc/model.class.php:1004 +msgid "Delete link with computer in OCSNG" +msgstr "Supprimer le lien avec la machine OCS" -#: inc/replace.class.php:40 -msgid "Item's replacement" -msgstr "Remplacement d'un matériel" +#: inc/model.class.php:738 +msgid "Delete computer in FusionInventory" +msgstr "Supprimer le lien avec FusionInventory" -#: inc/model.class.php:117 -msgid "Keep + Comment" -msgstr "Ne pas supprimer + Commentaires" +#: inc/model.class.php:755 +msgid "Additionnal fields" +msgstr "Champs additionnels" -#: inc/model.class.php:248 inc/model.class.php:996 -msgid "Keep in the current group" -msgstr "Conserver la valeur actuelle" +#: inc/model.class.php:759 +msgid "Fields plugin informations" +msgstr "Informations du plugin champs supplémentaires" -#: inc/preference.class.php:98 inc/replace.class.php:589 ajax/locations.php:45 -msgid "Keep previous location" -msgstr "Garder l'ancien lieu" +#: inc/model.class.php:769 +msgid "Advanced options" +msgstr "Options avancées" -#: inc/uninstall.class.php:963 -msgid "Lifecycle" -msgstr "Cycle de vie" +#: inc/model.class.php:812 +msgid "Plugin fields blocks" +msgstr "Blocs du plugin champs supplémentaires" -#: inc/config.class.php:87 -msgid "Location preferences" -msgstr "Préférences de lieux" +#: inc/modelcontainer.class.php:49 +msgid "Plugin fields block" +msgstr "Bloc du plugin champs supplémentaires" -#: inc/model.class.php:284 -msgid "Manage templates" -msgstr "Gestion des modèles" +#: inc/modelcontainer.class.php:69 inc/modelcontainer.class.php:76 +msgid "Per field action" +msgstr "Choisir par champ" -#: inc/model.class.php:264 -msgid "New group" -msgstr "Nouveau groupe" +#: inc/modelcontainer.class.php:140 +msgid "Block" +msgstr "Bloc" -#: inc/replace.class.php:685 -msgid "New item" -msgstr "Nouveau matériel" +#: inc/modelcontainer.class.php:233 +msgid "Block informations" +msgstr "Informations du bloc" -#: inc/replace.class.php:586 -msgid "New location of item" -msgstr "Nouveau lieu du matériel" +#: inc/modelcontainer.class.php:264 inc/modelcontainerfield.class.php:136 +msgid "Uninstall action" +msgstr "Action du plugin" -#: inc/replace.class.php:603 inc/model.class.php:236 -msgid "New status of the computer" -msgstr "Nouveau statut du matériel" +#: inc/modelcontainerfield.class.php:47 +msgid "Plugin fields field" +msgstr "Champs du plugin champs supplémentaires" -#: inc/model.class.php:587 -msgid "OCSNG link" -msgid_plural "OCSNG links" -msgstr[0] "Lien OCSNG" -msgstr[1] "Liens OCSNG" -msgstr[2] "Liens OCSNG" +#: inc/modelcontainerfield.class.php:111 +msgid "Field informations" +msgstr "Informations du champ" -#: inc/replace.class.php:675 -msgid "Old item" -msgstr "Ancien matériel" +#: inc/modelcontainerfield.class.php:148 inc/modelcontainerfield.class.php:221 +msgid "Set value" +msgstr "Choisir la valeur" -#: inc/replace.class.php:564 inc/model.class.php:414 -msgid "Overwrite informations (from old item to the new)" -msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" +#: inc/modelcontainerfield.class.php:165 +msgid "New value" +msgstr "Nouvelle valeur" -#: inc/model.class.php:110 -msgid "PDF Archiving" -msgstr "Archivage PDF" +#: inc/modelcontainerfield.class.php:168 +msgid "Action set value is not available for this field type" +msgstr "L'action choisir la valeur n'est pas disponible pour ce type de champ" -#: inc/replace.class.php:65 +#: inc/preference.class.php:77 +msgid "Item's location after uninstall" +msgstr "Lieu du matériel après désinstallation" + +#: inc/replace.class.php:41 +msgid "Item's replacement" +msgstr "Remplacement d'un matériel" + +#: inc/replace.class.php:71 msgid "Please wait, replacement is running..." msgstr "Veuillez patienter, remplacement en cours..." -#: inc/uninstall.class.php:324 -msgid "Please wait, uninstallation is running..." -msgstr "Veuillez patienter, désinstallation en cours..." +#: inc/replace.class.php:138 +msgid "This document is the archive of this replaced item" +msgstr "Ce document est l'archive de l'objet remplacé" -#: inc/model.class.php:430 -msgid "Plugin PDF is installed and activated" -msgstr "Le plugin PDF est installé et activé" +#: inc/replace.class.php:143 +msgid "Archive of old material" +msgstr "Archive de l'ancien matériel" -#: inc/model.class.php:433 -msgid "" -"Plugin PDF is not installed, you won't be able to use PDF format for " -"archiving" -msgstr "" -"Le plugin PDF n'est pas installé, vous ne pouvez pas utiliser le format PDF " -"pour l'archivage" +#: inc/replace.class.php:483 +msgid "See attached document" +msgstr "Voir le document attaché" -#: inc/model.class.php:115 -msgid "Purge" -msgstr "Purge" +#: inc/replace.class.php:586 +msgid "This item is a replacement for item" +msgstr "Cet objet est le remplacement de l'objet" -#: inc/replace.class.php:548 inc/replace.class.php:624 +#: inc/replace.class.php:588 +msgid "This item was replaced by" +msgstr "Cet objet a été remplacé par" + +#: inc/replace.class.php:640 inc/replace.class.php:718 msgid "Reminder of the replacement model" msgstr "Rappel du modèle de remplacement" -#: inc/replace.class.php:688 -msgid "Remove" -msgstr "Supprimer" - -#: inc/uninstall.class.php:739 -msgid "Removed from OCSNG with ID" -msgstr "Supprimé d'OCSNG ID OCS" - -#: inc/replace.class.php:734 -msgid "Replace" -msgstr "Remplacer" +#: inc/replace.class.php:679 +msgid "New location of item" +msgstr "Nouveau lieu du matériel" -#: inc/config.class.php:95 -msgid "Replace status dropdown by plugin actions" -msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" +#: inc/replace.class.php:776 +msgid "Choices for item to replace" +msgstr "Choix des matériels de remplacement" -#: inc/replace.class.php:61 inc/replace.class.php:109 inc/model.class.php:100 -#: inc/model.class.php:991 inc/model.class.php:1033 -msgid "Replacement" -msgstr "Remplacement" +#: inc/replace.class.php:779 +msgid "Old item" +msgstr "Ancien matériel" -#: inc/replace.class.php:476 front/action.php:57 -msgid "Replacement successful" -msgstr "Remplacement effectué avec succès" +#: inc/replace.class.php:789 +msgid "New item" +msgstr "Nouveau matériel" -#: inc/model.class.php:158 -msgid "Replacing data" -msgstr "Remplacement des données" +#: inc/replace.class.php:792 +msgid "Remove" +msgstr "Supprimer" -#: inc/replace.class.php:408 -msgid "See attached document" -msgstr "Voir le document attaché" +#: inc/replace.class.php:838 +msgid "Replace" +msgstr "Remplacer" -#: inc/config.class.php:81 -msgid "Shortcuts" -msgstr "Raccourcis" +#: inc/uninstall.class.php:348 +msgid "Please wait, uninstallation is running..." +msgstr "Veuillez patienter, désinstallation en cours..." -#: inc/model.class.php:589 -msgid "These options only apply to computers coming from OCSNG" -msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" +#: inc/uninstall.class.php:837 +msgid "Item is now uninstalled" +msgstr "Matériel désinstallé" -#: inc/replace.class.php:131 -msgid "This document is the archive of this replaced item" -msgstr "Ce document est l'archive de l'objet remplacé" +#: inc/uninstall.class.php:840 +#, php-format +msgid "Item is now uninstalled with model %s" +msgstr "Matériel désinstallé avec le modèle %s" -#: inc/replace.class.php:498 -msgid "This item is a replacement for item" -msgstr "Cet objet est le remplacement de l'objet" +#: inc/uninstall.class.php:847 +msgid "Item replaced by a new one" +msgstr "Matériel remplacé" -#: inc/replace.class.php:500 -msgid "This item was replaced by" -msgstr "Cet objet a été remplacé par" +#: inc/uninstall.class.php:850 +#, php-format +msgid "Item replaced by a new one with model %s" +msgstr "Matériel remplacé avec le modèle %s" -#: inc/model.class.php:216 inc/model.class.php:795 -msgid "Transfer's model to use" -msgstr "Modèle de transfert à utiliser" +#: inc/uninstall.class.php:857 +msgid "Item replacing an old one" +msgstr "Matériel provenant d'un remplacement" -#: inc/model.class.php:207 inc/model.class.php:831 -msgid "Type of template" -msgstr "Type de modèle" +#: inc/uninstall.class.php:863 +msgid "Removed from OCSNG with ID" +msgstr "Supprimé d'OCSNG ID OCS" -#: hook.php:42 inc/uninstall.class.php:320 -msgid "Uninstall" -msgstr "Désinstaller" +#: inc/uninstall.class.php:972 +msgid "Apply model" +msgstr "Appliquer un modèle" -#: inc/model.class.php:98 inc/model.class.php:989 inc/model.class.php:1031 -msgid "Uninstallation" -msgstr "Désinstallation" +#: inc/uninstall.class.php:996 +msgid "Item's location after applying model" +msgstr "Lieu de l'élément après application du modèle" -#: inc/uninstall.class.php:347 front/action.php:98 -msgid "Uninstallation successful" -msgstr "Désinstallation effectuée avec succès" +#: inc/uninstall.class.php:1113 +msgid "Lifecycle" +msgstr "Cycle de vie" From 12a434e05712779ee9a1ecc7b1d2e17747120f1f Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Fri, 31 May 2024 10:19:05 +0200 Subject: [PATCH 15/54] display --- inc/model.class.php | 4 +-- inc/modelcontainer.class.php | 20 ++++++++++- inc/modelcontainerfield.class.php | 20 ++++++++++- locales/fr_FR.mo | Bin 7087 -> 7033 bytes locales/fr_FR.po | 53 +++++++++++++++++------------- 5 files changed, 71 insertions(+), 26 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index fc86167..033077a 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -181,7 +181,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab[2] = __('Replacing data', 'uninstall'); $plugin = new Plugin(); if ($plugin->isActivated('fields') && $item->fields['action_plugin_fields'] == self::PLUGIN_FIELDS_ACTION_ADVANCED) { - $tab[3] = __('Plugin fields options', 'uninstall'); + $tab[3] = __('Additional fields options', 'uninstall'); } return $tab; } @@ -809,7 +809,7 @@ public function showFormPluginFields($item) if ($item->fields['action_plugin_fields'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { echo ""; echo ""; - echo "
" . __('Plugin fields blocks', 'uninstall') . + echo "" . __('Plugin additionnal fields blocks', 'uninstall') . "
"; $parameters = [ 'start' => 0, diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index bd0ec33..cdd1099 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -43,10 +43,12 @@ class PluginUninstallModelcontainer extends CommonDBTM // choose action for each field individually const ACTION_CUSTOM = 3; + protected $displaylist = false; + public static function getTypeName($nb = 0) { - return __("Plugin fields block", "uninstall"); + return __("Block", "fields"); } /** @@ -115,6 +117,12 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) return ''; } + public function getName($options = []) { + $container = new PluginFieldsContainer(); + $container->getFromDB($this->fields['plugin_fields_containers_id']); + return $container->getFriendlyName(); + } + public function rawSearchOptions() { $tab = []; @@ -229,6 +237,16 @@ public function showForm($ID, $options = []) $pluginFieldsContainer = new PluginFieldsContainer(); if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { + echo ""; + $backUrl = '../front/model.form.php?forecetab=3&id='.$this->fields['plugin_uninstall_models_id']; + $backTitle = __('Blocs list', 'uninstall'); + echo " + + $backTitle + "; + echo ""; echo ""; echo "" . __('Block informations', 'uninstall') . ""; diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index affabae..318ebfb 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -32,6 +32,8 @@ class PluginUninstallModelcontainerfield extends CommonDBTM { public $dohistory = true; + protected $displaylist = false; + public static $rightname = "uninstall:profile"; // do nothing const ACTION_NONE = 0; @@ -44,7 +46,13 @@ class PluginUninstallModelcontainerfield extends CommonDBTM public static function getTypeName($nb = 0) { - return __("Plugin fields field", "uninstall"); + return __("Field"); + } + + public function getName($options = []) { + $field = new PluginFieldsField(); + $field->getFromDB($this->fields['plugin_fields_fields_id']); + return $field->fields['label']; } public function rawSearchOptions() @@ -107,6 +115,16 @@ public function showForm($ID, $options = []) $pluginUninstallModel = new PluginUninstallModel(); $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { + echo ""; + $backUrl = '../front/modelcontainer.form.php?forecetab=2&id='.$pluginUninstallContainer->getID(); + $backTitle = __('Fields list', 'uninstall'); + echo " + + $backTitle + "; + echo ""; echo ""; echo "" . __('Field informations', 'uninstall') . ""; diff --git a/locales/fr_FR.mo b/locales/fr_FR.mo index a1516c0a3e0261002adce757de9555703028af4b..2fa79bbe7bbe970f0d16eaa1578697e89f7d5380 100644 GIT binary patch delta 1995 zcmYM!O>9(E7{>8;N|}~v>$J4Mlmgyjp{NBq6=;D{`oV`Hwn)X`f|#LGV5GE7E~z!9 z4vWHq4JCJFN+co01!5{0Sg=3?3nft_3n9dnh>C=SYFubx!~ePWHk{0v-??AsyyrdV z-pR)4bz{xhN;CVRz-%u5iKRG=^DtIu_5wOsgsX7@Zp0ew#@RTGdj1oP;b|h9^+>U5sVTR?zs46UxNjs0d^9wg{_GGi|~baUUv>5mX>!sOQe&e7uUp zWVcWO{DSIlDm-t+W=!5cI|FM{l8SOk)y{pi+7k)!~=89KXhw@ekC@ z;@s4UYtg|`)DoS?YWxDD_#`}iq<@|DKShJFYyz3QT}G|>jnD_ER24It zQeKNnWhV~fAS(3_u>s?ZszBP2Q??(~?+_}Zqo_=dV=3d?B^s;n25PtdgUUpVyR>U- zP?0yIIy{I9DrX_7bT|a~hY!tP*Cos!ccAW#-@p`>&Z~II$1M zP&0Up+O_i;O{rdl+B7Z5C3`(QPT>}g52GgV6>4u>Lw1{`#?*kSu3O3z;94hmQa;$O-v;} zz?yKAW~HLEvplwksuazXP8#n}H&UbFNqv}97JK)iQ7Hu1CvD^yaisRbErSSuOZX(W1Uf)t5=7o4VR>1zTCKMILn)l_m2R zy9-q|Q`b;e>VWcQfNj8J*q&iKjcO{djpr7m%2IvKflO~-+I0p7k7fq?UGMvXi?Q~; zfgacC%eY5#Lxsm9`F`u)IR|GYQt5O?_w_%2a6dO6&P|l8&zqgB-;iv~{T9C!De4Nk zbJD%8_iMuOu9n@5@1(#jlG7{MJ@+pI_=ZlsYo#=0+-#`QGhBO>Spp GPu??TqR1cs delta 1983 zcmZA1eMnVz9LMqRHN8G;cenIb+QW9cUdzhLhn2JGv{{Wx%rb+5YNbmpr-HVPt-J&+ z_Rm;!#s(3%2#Sqb&^7;TtUs*inGiCfvOj_%BA9H}U%fx)oI&*Ce$VUoJ5Rrd@9*4~ zOU{%Zs!U{?+0}HjiTD5~;|qKbgBfP;;AEVNvoMYon1)+X&$nO*zsBkKJx1{u>b(~* zhPN>n|HWDiXIjF&(3okK&xx;4HylB|IEfm_5NaU9{`payMtck+7|!yZi=zfwg$3Az zy6-zI#9uHE|3VFHBr9PygUVA*XlCj3@&Oj122h6@z&6x_oj3)5K>D_R)Bt`*z3{w$ z{suBh8}Y9{LJj0U|9bYj-g{;wsOZKrEWt|DQg)(VxEE*Rk2n_xP&2!a^_a@dIoOCA zNUPu8i%R7oRH{zkEIfrlyp9@BVwei)wil=l#*slCXYL)1veQ7_8pDGi_; z)!|mu=XC(*;BQ!hmr$vDY+gRQr!y)?YKZ#R+|% zFHtjz(YtnS9ct;bZl+p0#R1?WKh7Q|DS)m6b#TQ9~%b zWyEUwcRSR}H6j&lDi!@jswhQG#1b_ql^*VAsw#cEg?;MoBdvf|ZIyeLF8~)1+6yYF z9<~^(v}`JIg8kzbEwxG&QBQ0jJ|dJ775!hR#GKJ!&a(N`R=90%TdEo)Du`u-wyugk zMwNBMhs37@8_ec9e+P3yi>Q4}s1)nHi43pd9-|yL5=x#*BcUCpLdx9arr-oZ8$>x< zOZ;C-sOZyDS>xgUYbp1i_-*kSv7TUeIz8#zo#*MtlSeZS1d>Hr+a|2u+5SaGOHXu1 zM_2Q1Yv|b1+TIy`^IXqcC*5mro$KoEZSU$#9uHNdq!m{zEnA!%4c`nn!;@|#2eSVR t1e%@ZNPY4`q&U^N9?5r}=N6{bwr&5i+qo8rr>yOEE=LNJQ}UWqUIWHt$9(_* diff --git a/locales/fr_FR.po b/locales/fr_FR.po index 8c959e5..18ccd8d 100644 --- a/locales/fr_FR.po +++ b/locales/fr_FR.po @@ -14,8 +14,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-31 09:34+0200\n" -"PO-Revision-Date: 2024-05-31 09:35+0200\n" +"POT-Creation-Date: 2024-05-31 10:16+0200\n" +"PO-Revision-Date: 2024-05-31 10:17+0200\n" "Last-Translator: Cédric Anne, 2023\n" "Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/" "fr_FR/)\n" @@ -105,8 +105,8 @@ msgid "Replacing data" msgstr "Remplacement des données" #: inc/model.class.php:184 -msgid "Plugin fields options" -msgstr "Options du plugin champs supplémentaires" +msgid "Additional fields options" +msgstr "Options des champs supplémentaires" #: inc/model.class.php:240 inc/model.class.php:1013 msgid "Type of template" @@ -196,7 +196,7 @@ msgstr "Connexion avec les autres matériels" #: inc/model.class.php:625 inc/replace.class.php:764 msgid "Direct connections" -msgstr "connexions directes" +msgstr "Connexions directes" #: inc/model.class.php:704 msgid "OCSNG link" @@ -234,46 +234,46 @@ msgid "Advanced options" msgstr "Options avancées" #: inc/model.class.php:812 -msgid "Plugin fields blocks" +msgid "Plugin additionnal fields blocks" msgstr "Blocs du plugin champs supplémentaires" -#: inc/modelcontainer.class.php:49 -msgid "Plugin fields block" -msgstr "Bloc du plugin champs supplémentaires" +#: inc/modelcontainer.class.php:51 inc/modelcontainer.class.php:148 +msgid "Block" +msgstr "Bloc" -#: inc/modelcontainer.class.php:69 inc/modelcontainer.class.php:76 +#: inc/modelcontainer.class.php:71 inc/modelcontainer.class.php:78 msgid "Per field action" msgstr "Choisir par champ" -#: inc/modelcontainer.class.php:140 -msgid "Block" -msgstr "Bloc" +#: inc/modelcontainer.class.php:242 +msgid "Blocs list" +msgstr "Liste des blocs" -#: inc/modelcontainer.class.php:233 +#: inc/modelcontainer.class.php:251 msgid "Block informations" msgstr "Informations du bloc" -#: inc/modelcontainer.class.php:264 inc/modelcontainerfield.class.php:136 +#: inc/modelcontainer.class.php:282 inc/modelcontainerfield.class.php:154 msgid "Uninstall action" msgstr "Action du plugin" -#: inc/modelcontainerfield.class.php:47 -msgid "Plugin fields field" -msgstr "Champs du plugin champs supplémentaires" +#: inc/modelcontainerfield.class.php:120 +msgid "Fields list" +msgstr "Liste des champs" -#: inc/modelcontainerfield.class.php:111 +#: inc/modelcontainerfield.class.php:129 msgid "Field informations" msgstr "Informations du champ" -#: inc/modelcontainerfield.class.php:148 inc/modelcontainerfield.class.php:221 +#: inc/modelcontainerfield.class.php:166 inc/modelcontainerfield.class.php:239 msgid "Set value" msgstr "Choisir la valeur" -#: inc/modelcontainerfield.class.php:165 +#: inc/modelcontainerfield.class.php:183 msgid "New value" msgstr "Nouvelle valeur" -#: inc/modelcontainerfield.class.php:168 +#: inc/modelcontainerfield.class.php:186 msgid "Action set value is not available for this field type" msgstr "L'action choisir la valeur n'est pas disponible pour ce type de champ" @@ -378,3 +378,12 @@ msgstr "Lieu de l'élément après application du modèle" #: inc/uninstall.class.php:1113 msgid "Lifecycle" msgstr "Cycle de vie" + +#~ msgid "Plugin fields options" +#~ msgstr "Options du plugin champs supplémentaires" + +#~ msgid "Plugin fields block" +#~ msgstr "Bloc du plugin champs supplémentaires" + +#~ msgid "Plugin fields field" +#~ msgstr "Champs du plugin champs supplémentaires" From f658a876145e6eeaefb12dc117769a9cb5269b28 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Fri, 31 May 2024 11:01:26 +0200 Subject: [PATCH 16/54] default display preferences for search of new items --- inc/model.class.php | 2 +- inc/modelcontainer.class.php | 11 +++++++++++ inc/modelcontainerfield.class.php | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 033077a..cd6997d 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1477,7 +1477,7 @@ public static function install($migration) `replace_method` int NOT NULL DEFAULT '2', `raz_glpiinventory` int NOT NULL DEFAULT '1', `raz_fusioninventory` int NOT NULL DEFAULT '1', - `action_plugin_fields` int NOT NULL DEFAULT '1', + `action_plugin_fields` int NOT NULL DEFAULT '0', `replace_contact` tinyint NOT NULL DEFAULT '0', `replace_contact_num` tinyint NOT NULL DEFAULT '0', PRIMARY KEY (`id`) diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index cdd1099..485bb25 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -344,6 +344,15 @@ public static function install($migration) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->queryOrDie($query, $DB->error()); + + $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) + VALUES + ('".self::class."', '2', '1', '0'), + ('".self::class."', '3', '2', '0'), + ('".self::class."', '4', '3', '0') + ;"; + + $DB->queryOrDie($queryPreferences, $DB->error()); } return true; } @@ -355,6 +364,8 @@ public static function uninstall() $DB->query("DROP TABLE IF EXISTS `" . getTableForItemType(__CLASS__) . "`"); + $DB->query("DELETE FROM `glpi_displaypreferences` WHERE `itemtype` = '" . self::class . "';"); + //Delete history $log = new Log(); $log->dohistory = false; diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 318ebfb..1b2828a 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -264,6 +264,15 @@ public static function install($migration) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->queryOrDie($query, $DB->error()); + + $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) + VALUES + ('".self::class."', '2', '1', '0'), + ('".self::class."', '3', '2', '0'), + ('".self::class."', '4', '3', '0') + ;"; + + $DB->queryOrDie($queryPreferences, $DB->error()); } return true; } @@ -275,6 +284,8 @@ public static function uninstall() $DB->query("DROP TABLE IF EXISTS `" . getTableForItemType(__CLASS__) . "`"); + $DB->query("DELETE FROM `glpi_displaypreferences` WHERE `itemtype` = '" . self::class . "';"); + //Delete history $log = new Log(); $log->dohistory = false; From e56ab468e294b4464e50c522eb1225152ad4464b Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 10 Jun 2024 13:56:24 +0200 Subject: [PATCH 17/54] Merged main --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index cbfde22..52f36f2 100644 --- a/setup.php +++ b/setup.php @@ -30,7 +30,7 @@ use Glpi\Plugin\Hooks; -define('PLUGIN_UNINSTALL_VERSION', '2.10.0'); +define('PLUGIN_UNINSTALL_VERSION', '2.9.2-infotel'); // Minimal GLPI version, inclusive define("PLUGIN_UNINSTALL_MIN_GLPI", "10.0.7"); From 51fd3e245155e865084e8aae858ed988ad2b102b Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 10 Jun 2024 14:14:07 +0200 Subject: [PATCH 18/54] Merged main --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index 52f36f2..cbfde22 100644 --- a/setup.php +++ b/setup.php @@ -30,7 +30,7 @@ use Glpi\Plugin\Hooks; -define('PLUGIN_UNINSTALL_VERSION', '2.9.2-infotel'); +define('PLUGIN_UNINSTALL_VERSION', '2.10.0'); // Minimal GLPI version, inclusive define("PLUGIN_UNINSTALL_MIN_GLPI", "10.0.7"); From b1cddbd892d25774641be767f7685ad9050f51c0 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 10 Jun 2024 16:21:18 +0200 Subject: [PATCH 19/54] removed fr locales update & replace incorrect header --- ajax/fieldValueInput.php | 49 ++-- locales/fr_FR.mo | Bin 7033 -> 6085 bytes locales/fr_FR.po | 508 +++++++++++++++++---------------------- 3 files changed, 246 insertions(+), 311 deletions(-) diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index 5eef835..4260a8e 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -1,28 +1,31 @@ . - -------------------------------------------------------------------------- +/** + * ------------------------------------------------------------------------- + * Uninstall plugin for GLPI + * ------------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of Uninstall. + * + * Uninstall is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Uninstall is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Uninstall. If not, see . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- */ include('../../../inc/includes.php'); diff --git a/locales/fr_FR.mo b/locales/fr_FR.mo index 2fa79bbe7bbe970f0d16eaa1578697e89f7d5380..bb630e1bd052d8c5d0e524628b29bdbd8621301c 100644 GIT binary patch delta 1876 zcmY+^Sxj729LMo9>{8mx=1{1@1wmR1bOsPwEQJA~RV$V@Y2t!pG7JZe(rw$=YP(f zYdz<8q`#{yc)`&25jPMI#<2x5yX=8?g+7Sc!Y^dK||MID<8q#AaN^jrcBZ z!E@;1MJ&g^vC){cDJwRni4z^T8OL!L=e+Z8<4qiY>0Q5qN?=n7fsLpH0$7c^G5a1= zLUY)HPh%aP!L7K8we)X(W=9znU6-ps4Qd44*nsz4sf+BaY!M7(<>lFQTU8 zHP25`Bm51wV<}mvQaz|jOyHxKMpf)D)IjPha#K2vO5mXi>aPxtaY7}rsKxUpY6PpO zkzPV2bOrUG%P`boH>!jCQLFqZY{gR;#Pg`qU-hmx@~{TnkNVms((GvDk0VtyCs2v3 zc;_>yl75WzZN5Pz_9Lppd>+=<(|`=p4B;RiLJjOBw&5!nz|T>MYrZES-O7#@(J@r% zmQi#07OE0wz2h(Nc8)Ki5^W$$t%){NLI*tOko9SvMcsb_JMb&qiusgN6=*|O-~WDg zm_{>?%J@mtNS09#tRQPB+jg1SFt9}R3Pt+4?dx-2>!6BWX zIVO@@NL0o25j}*;t+^rLbzZ)|JC_ zdusKl?yBip(|i;Vs_$CUXTkTHU0qrTDv??*q4{binuuXS6Rkgj5TRAb{ETEjaMe?j zstH(Y1MKW3M!gfaqE-kCj5kDV^c{Jnx2kEmfWR; z8+PN-N4%RlO765PC6T((>`m@MEHyJ5cW2|%iN*P_-j~c=EpdFA!P5LZdv{sbeo%J7 zzP|AzyR_+7n{>LJ1EJx&LVHKt!y^X|-Eq&DeZy(12==xIg6)AWx3jY^7}y>N*dLrH z>_Yi{&i-(GCKaBE_PNuGlcNXiC*_lNsKVb8noFdXqKj@S?#?HsR?ozuX81^Wej(|G zr>16=M?4y{*D9K9TjhiHy~=cba$S<{RBA2v>_{>#RsB9+#73$|GXGW|$+HjFJYzR( T{@(g)|I4)275nVKmcIW1gM;2h delta 2829 zcmaLXZEO@p9LMn~LR*fu*YZ%TAS{msq0p8BwP2ww&z6E91VfN)d)snwy}R7rl@ft7 zu`!W1Vm2BL2BM+{)F44$_(F*gkrxa#E2px5qzc4H-3M++k%ofxw+5W?C#8e z{xf@DEWEuW|I^r!FB{5s>SXGb5ys^4;3&Q*{YAz^@c=Hy7qA4+V-;S(vG^O7<87RP zkz!-Y(84je5GUd?oQYeJDe|VDh6Xr{5qt?t@pYVpr_sVos0ps&bo?71#7U!#X~PCo ze?QK^W2o!rQRDxB3g`wZpgVp)OD$wpbyVR)I19()O4I<`P?0Bb7Cw)pP*5RpCCb*Z%_gJh#K%_*sr{^XcIwQABPHL z4(ho!)HoYa_rKi5llGBvvzxSv=O zZ$=HUDg6Bua;w>ky8i&4DKN%EWvH#fnANxgmHOkT@z3Ho{H}uh(>B-n(jE<>CYr?E z8el#?j4k*G?#7XLB)tA2GM71tEZ%&C+Vcyc*HD=%VK$|_8kNZo?8kJThEjhW>oLl# z3Zxb3GM%V_`%ozzK&A2+D$ujI056~p>z}AhM7T+rn~4g1IcmHfR3Oiw=FPuJL$BFo ztj4QYhb7FWJ#9u^--8Nl0Cl=gB6FF~k>g{&M?U74u>THfYobJ<3{OD?R*M>M1CqJC z>87Fgwhy(U*Kj4CMy>n?YJl4~AIGrFT5LqEB#yiAC~5(Jpbl*%vnkb+QD>$Zxn$Ob zzinKlzq)-iw1N*&hvQS^V}1@DLVVFZ=fo3O0xn|SsdX1BdVz_ z*+P9(KPZm{_zPAuuLyMzw3k}7QmPZYo~km1s&s2*DkB3-BWhJDN;|t_wo#R#q0&L) zN$N6cVc4lZCKbI^6s`Ym(Y~z?f9lk#=nrN&wS}rQt60>P)F-G*sjXD)t|7Lj7v|UD7%JNT?Nt4XscfY#^jpEH*DExF`T&*f_0Pp7R9Qi7pw{RIrTHb zxYdO1bRyRiPu@G=xu)V#BSv>P`-927=16DM$%G5D{mgjBBbTQJ58C%F$Lds|t`{3~ zsdy-1-kg$KMOOH5S!uJkvvht%eM3#{;+jQuR$XmV-O_or_1>$c2czwFvL|QvI89b} zX7`#c-ng=z-r=&R^E+zRI!PyEXH%IbYjesWi`JqA4GZcc!`qX~SZsyAWsYgD4yLoZ z_N3x&oJ+PAuf}8~T@}`U*sAvnbn6}B1mgv1P{%Un_^qBkq g26f!G1|}2?k1)Is=bo!9E+`M*wc#, YEAR. -# +# # Translators: # Walid Nouh, 2017 # Johan Cwiklinski, 2017 # alexandre delaunay , 2018 # Cédric Anne, 2023 -# +# #, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-31 10:16+0200\n" -"PO-Revision-Date: 2024-05-31 10:17+0200\n" +"POT-Creation-Date: 2023-06-30 12:39+0000\n" +"PO-Revision-Date: 2017-01-03 22:10+0000\n" "Last-Translator: Cédric Anne, 2023\n" -"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/" -"fr_FR/)\n" -"Language: fr_FR\n" +"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/fr_FR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % " -"1000000 == 0 ? 1 : 2;\n" -"X-Generator: Poedit 3.4.2\n" - -#: hook.php:44 inc/uninstall.class.php:344 -msgid "Uninstall" -msgstr "Désinstaller" - -#: setup.php:155 -msgid "Item's Lifecycle (uninstall)" -msgstr "Cycle de vie des matériels (uninstall)" - -#: ajax/fieldValueInput.php:53 -msgid "Allowed values" -msgstr "Valeurs permises" - -#: ajax/locations.php:49 inc/preference.class.php:102 inc/replace.class.php:682 -msgid "Keep previous location" -msgstr "Garder l'ancien lieu" - -#: ajax/locations.php:50 inc/preference.class.php:103 inc/replace.class.php:686 -msgid "Empty location" -msgstr "Vider le lieu" - -#: front/action.php:64 inc/replace.class.php:562 -msgid "Replacement successful" -msgstr "Remplacement effectué avec succès" - -#: front/action.php:114 inc/uninstall.class.php:370 -msgid "Uninstallation successful" -msgstr "Désinstallation effectuée avec succès" +"Language: fr_FR\n" +"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" -#: inc/config.class.php:41 inc/model.class.php:81 inc/uninstall.class.php:39 -msgid "Item's Lifecycle" -msgstr "Cycle de vie des matériels" +#: inc/model.class.php:244 inc/model.class.php:841 +msgid "Action on group" +msgstr "Action sur le groupe" -#: inc/config.class.php:85 -msgid "Shortcuts" -msgstr "Raccourcis" +#: inc/model.class.php:281 +msgid "Add template" +msgstr "Ajouter un modèle" -#: inc/config.class.php:91 -msgid "Location preferences" -msgstr "Préférences de lieux" +#: inc/model.class.php:625 +msgid "Additionnal fields" +msgstr "Champs additionnels" -#: inc/config.class.php:99 -msgid "Replace status dropdown by plugin actions" -msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" +#: inc/model.class.php:249 +msgid "Affect to a new group" +msgstr "Affecter à une nouvelle valeur" -#: inc/model.class.php:113 inc/model.class.php:1171 inc/model.class.php:1211 -msgid "Uninstallation" -msgstr "Désinstallation" +#: inc/uninstall.class.php:841 +msgid "Apply model" +msgstr "Appliquer un modèle" -#: inc/model.class.php:115 inc/model.class.php:1173 inc/model.class.php:1213 -#: inc/replace.class.php:67 inc/replace.class.php:115 -msgid "Replacement" -msgstr "Remplacement" +#: inc/replace.class.php:136 +msgid "Archive of old material" +msgstr "Archive de l'ancien matériel" -#: inc/model.class.php:126 -msgid "PDF Archiving" -msgstr "Archivage PDF" +#: inc/replace.class.php:567 inc/model.class.php:421 inc/model.class.php:852 +msgid "Archiving method of the old material" +msgstr "Méthode d'archivage de l'ancien matériel" -#: inc/model.class.php:128 +#: inc/model.class.php:112 msgid "CSV Archiving" msgstr "Archivage CSV" -#: inc/model.class.php:131 -msgid "Purge" -msgstr "Purge" +#: inc/replace.class.php:672 +msgid "Choices for item to replace" +msgstr "Choix des matériels de remplacement" -#: inc/model.class.php:132 +#: inc/replace.class.php:625 inc/model.class.php:441 +msgid "Connections with other materials" +msgstr "Connexion avec les autres matériels" + +#: inc/model.class.php:116 msgid "Delete + Comment" msgstr "Suppression + Commentaires" -#: inc/model.class.php:133 -msgid "Keep + Comment" -msgstr "Ne pas supprimer + Commentaires" - -#: inc/model.class.php:181 -msgid "Replacing data" -msgstr "Remplacement des données" - -#: inc/model.class.php:184 -msgid "Additional fields options" -msgstr "Options des champs supplémentaires" - -#: inc/model.class.php:240 inc/model.class.php:1013 -msgid "Type of template" -msgstr "Type de modèle" - -#: inc/model.class.php:249 inc/model.class.php:977 -msgid "Transfer's model to use" -msgstr "Modèle de transfert à utiliser" - -#: inc/model.class.php:270 inc/replace.class.php:696 -msgid "New status of the computer" -msgstr "Nouveau statut du matériel" +#: inc/model.class.php:629 +msgid "Delete Fields plugin informations" +msgstr "Supprimer les informations du plugin Fields" -#: inc/model.class.php:279 inc/model.class.php:1023 -msgid "Action on group" -msgstr "Action sur le groupe" - -#: inc/model.class.php:283 inc/model.class.php:1178 -msgid "Keep in the current group" -msgstr "Conserver la valeur actuelle" - -#: inc/model.class.php:284 -msgid "Affect to a new group" -msgstr "Affecter à une nouvelle valeur" - -#: inc/model.class.php:299 -msgid "New group" -msgstr "Nouveau groupe" +#: inc/model.class.php:613 +msgid "Delete computer in FusionInventory" +msgstr "Supprimer le lien avec FusionInventory" -#: inc/model.class.php:319 -msgid "Add template" -msgstr "Ajouter un modèle" +#: inc/model.class.php:593 inc/model.class.php:814 +msgid "Delete computer in OCSNG" +msgstr "Supprimer l'ordinateur dans OCSNG" -#: inc/model.class.php:322 -msgid "Manage templates" -msgstr "Gestion des modèles" +#: inc/model.class.php:380 +msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" +msgstr "" +"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " +"verrous, informations relatives à l'agent, ...)" -#: inc/model.class.php:334 -msgid "Erase datas" -msgstr "Effacement de données" +#: inc/model.class.php:599 inc/model.class.php:822 +msgid "Delete link with computer in OCSNG" +msgstr "Supprimer le lien avec la machine OCS" -#: inc/model.class.php:337 inc/model.class.php:885 +#: inc/model.class.php:298 inc/model.class.php:703 msgid "Delete software history (computers)" msgstr "Supprimer l'historique des logiciels (ordinateurs)" -#: inc/model.class.php:344 inc/model.class.php:1044 +#: inc/model.class.php:303 inc/model.class.php:862 msgid "Delete the whole history" msgstr "Effacement de tout l'historique" -#: inc/model.class.php:446 -msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" -msgstr "" -"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " -"verrous, informations relatives à l'agent, ...)" +#: inc/replace.class.php:660 inc/model.class.php:515 +msgid "Direct connections" +msgstr "connexions directes" -#: inc/model.class.php:462 inc/model.class.php:525 -msgid "Informations replacement" -msgstr "Remplacement des données" +#: inc/preference.class.php:99 inc/replace.class.php:593 ajax/locations.php:46 +msgid "Empty location" +msgstr "Vider le lieu" -#: inc/model.class.php:463 inc/replace.class.php:641 +#: inc/model.class.php:295 +msgid "Erase datas" +msgstr "Effacement de données" + +#: inc/replace.class.php:549 inc/model.class.php:392 msgid "General informations" msgstr "Informations générales" -#: inc/model.class.php:494 inc/replace.class.php:657 -msgid "Overwrite informations (from old item to the new)" -msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" - -#: inc/model.class.php:503 inc/model.class.php:1034 inc/replace.class.php:660 -msgid "Archiving method of the old material" -msgstr "Méthode d'archivage de l'ancien matériel" - -#: inc/model.class.php:512 -msgid "Plugin PDF is installed and activated" -msgstr "Le plugin PDF est installé et activé" +#: inc/model.class.php:391 inc/model.class.php:440 +msgid "Informations replacement" +msgstr "Remplacement des données" -#: inc/model.class.php:516 -msgid "" -"Plugin PDF is not installed, you won't be able to use PDF format for " -"archiving" -msgstr "" -"Le plugin PDF n'est pas installé, vous ne pouvez pas utiliser le format PDF " -"pour l'archivage" +#: inc/uninstall.class.php:718 +msgid "Item is now uninstalled" +msgstr "Matériel désinstallé" -#: inc/model.class.php:526 inc/replace.class.php:719 -msgid "Connections with other materials" -msgstr "Connexion avec les autres matériels" +#: inc/uninstall.class.php:720 +#, php-format +msgid "Item is now uninstalled with model %s" +msgstr "Matériel désinstallé avec le modèle %s" -#: inc/model.class.php:625 inc/replace.class.php:764 -msgid "Direct connections" -msgstr "Connexions directes" +#: inc/uninstall.class.php:726 +msgid "Item replaced by a new one" +msgstr "Matériel remplacé" -#: inc/model.class.php:704 -msgid "OCSNG link" -msgid_plural "OCSNG links" -msgstr[0] "Lien OCSNG" -msgstr[1] "Liens OCSNG" -msgstr[2] "Liens OCSNG" +#: inc/uninstall.class.php:728 +#, php-format +msgid "Item replaced by a new one with model %s" +msgstr "Matériel remplacé avec le modèle %s" -#: inc/model.class.php:707 -msgid "These options only apply to computers coming from OCSNG" -msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" +#: inc/uninstall.class.php:734 +msgid "Item replacing an old one" +msgstr "Matériel provenant d'un remplacement" -#: inc/model.class.php:712 inc/model.class.php:996 -msgid "Delete computer in OCSNG" -msgstr "Supprimer l'ordinateur dans OCSNG" +#: inc/uninstall.class.php:38 inc/model.class.php:66 inc/config.class.php:39 +msgid "Item's Lifecycle" +msgstr "Cycle de vie des matériels" -#: inc/model.class.php:722 inc/model.class.php:1004 -msgid "Delete link with computer in OCSNG" -msgstr "Supprimer le lien avec la machine OCS" +#: setup.php:135 +msgid "Item's Lifecycle (uninstall)" +msgstr "Cycle de vie des matériels (uninstall)" -#: inc/model.class.php:738 -msgid "Delete computer in FusionInventory" -msgstr "Supprimer le lien avec FusionInventory" +#: inc/uninstall.class.php:858 +msgid "Item's location after applying model" +msgstr "Lieu de l'élément après application du modèle" -#: inc/model.class.php:755 -msgid "Additionnal fields" -msgstr "Champs additionnels" +#: inc/preference.class.php:73 +msgid "Item's location after uninstall" +msgstr "Lieu du matériel après désinstallation" -#: inc/model.class.php:759 -msgid "Fields plugin informations" -msgstr "Informations du plugin champs supplémentaires" +#: inc/replace.class.php:40 +msgid "Item's replacement" +msgstr "Remplacement d'un matériel" -#: inc/model.class.php:769 -msgid "Advanced options" -msgstr "Options avancées" +#: inc/model.class.php:117 +msgid "Keep + Comment" +msgstr "Ne pas supprimer + Commentaires" -#: inc/model.class.php:812 -msgid "Plugin additionnal fields blocks" -msgstr "Blocs du plugin champs supplémentaires" +#: inc/model.class.php:248 inc/model.class.php:996 +msgid "Keep in the current group" +msgstr "Conserver la valeur actuelle" -#: inc/modelcontainer.class.php:51 inc/modelcontainer.class.php:148 -msgid "Block" -msgstr "Bloc" +#: inc/preference.class.php:98 inc/replace.class.php:589 ajax/locations.php:45 +msgid "Keep previous location" +msgstr "Garder l'ancien lieu" -#: inc/modelcontainer.class.php:71 inc/modelcontainer.class.php:78 -msgid "Per field action" -msgstr "Choisir par champ" +#: inc/uninstall.class.php:963 +msgid "Lifecycle" +msgstr "Cycle de vie" -#: inc/modelcontainer.class.php:242 -msgid "Blocs list" -msgstr "Liste des blocs" +#: inc/config.class.php:87 +msgid "Location preferences" +msgstr "Préférences de lieux" -#: inc/modelcontainer.class.php:251 -msgid "Block informations" -msgstr "Informations du bloc" +#: inc/model.class.php:284 +msgid "Manage templates" +msgstr "Gestion des modèles" -#: inc/modelcontainer.class.php:282 inc/modelcontainerfield.class.php:154 -msgid "Uninstall action" -msgstr "Action du plugin" +#: inc/model.class.php:264 +msgid "New group" +msgstr "Nouveau groupe" -#: inc/modelcontainerfield.class.php:120 -msgid "Fields list" -msgstr "Liste des champs" +#: inc/replace.class.php:685 +msgid "New item" +msgstr "Nouveau matériel" -#: inc/modelcontainerfield.class.php:129 -msgid "Field informations" -msgstr "Informations du champ" +#: inc/replace.class.php:586 +msgid "New location of item" +msgstr "Nouveau lieu du matériel" -#: inc/modelcontainerfield.class.php:166 inc/modelcontainerfield.class.php:239 -msgid "Set value" -msgstr "Choisir la valeur" +#: inc/replace.class.php:603 inc/model.class.php:236 +msgid "New status of the computer" +msgstr "Nouveau statut du matériel" -#: inc/modelcontainerfield.class.php:183 -msgid "New value" -msgstr "Nouvelle valeur" +#: inc/model.class.php:587 +msgid "OCSNG link" +msgid_plural "OCSNG links" +msgstr[0] "Lien OCSNG" +msgstr[1] "Liens OCSNG" +msgstr[2] "Liens OCSNG" -#: inc/modelcontainerfield.class.php:186 -msgid "Action set value is not available for this field type" -msgstr "L'action choisir la valeur n'est pas disponible pour ce type de champ" +#: inc/replace.class.php:675 +msgid "Old item" +msgstr "Ancien matériel" -#: inc/preference.class.php:77 -msgid "Item's location after uninstall" -msgstr "Lieu du matériel après désinstallation" +#: inc/replace.class.php:564 inc/model.class.php:414 +msgid "Overwrite informations (from old item to the new)" +msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" -#: inc/replace.class.php:41 -msgid "Item's replacement" -msgstr "Remplacement d'un matériel" +#: inc/model.class.php:110 +msgid "PDF Archiving" +msgstr "Archivage PDF" -#: inc/replace.class.php:71 +#: inc/replace.class.php:65 msgid "Please wait, replacement is running..." msgstr "Veuillez patienter, remplacement en cours..." -#: inc/replace.class.php:138 -msgid "This document is the archive of this replaced item" -msgstr "Ce document est l'archive de l'objet remplacé" - -#: inc/replace.class.php:143 -msgid "Archive of old material" -msgstr "Archive de l'ancien matériel" +#: inc/uninstall.class.php:324 +msgid "Please wait, uninstallation is running..." +msgstr "Veuillez patienter, désinstallation en cours..." -#: inc/replace.class.php:483 -msgid "See attached document" -msgstr "Voir le document attaché" +#: inc/model.class.php:430 +msgid "Plugin PDF is installed and activated" +msgstr "Le plugin PDF est installé et activé" -#: inc/replace.class.php:586 -msgid "This item is a replacement for item" -msgstr "Cet objet est le remplacement de l'objet" +#: inc/model.class.php:433 +msgid "" +"Plugin PDF is not installed, you won't be able to use PDF format for " +"archiving" +msgstr "" +"Le plugin PDF n'est pas installé, vous ne pouvez pas utiliser le format PDF " +"pour l'archivage" -#: inc/replace.class.php:588 -msgid "This item was replaced by" -msgstr "Cet objet a été remplacé par" +#: inc/model.class.php:115 +msgid "Purge" +msgstr "Purge" -#: inc/replace.class.php:640 inc/replace.class.php:718 +#: inc/replace.class.php:548 inc/replace.class.php:624 msgid "Reminder of the replacement model" msgstr "Rappel du modèle de remplacement" -#: inc/replace.class.php:679 -msgid "New location of item" -msgstr "Nouveau lieu du matériel" - -#: inc/replace.class.php:776 -msgid "Choices for item to replace" -msgstr "Choix des matériels de remplacement" - -#: inc/replace.class.php:779 -msgid "Old item" -msgstr "Ancien matériel" - -#: inc/replace.class.php:789 -msgid "New item" -msgstr "Nouveau matériel" - -#: inc/replace.class.php:792 +#: inc/replace.class.php:688 msgid "Remove" msgstr "Supprimer" -#: inc/replace.class.php:838 +#: inc/uninstall.class.php:739 +msgid "Removed from OCSNG with ID" +msgstr "Supprimé d'OCSNG ID OCS" + +#: inc/replace.class.php:734 msgid "Replace" msgstr "Remplacer" -#: inc/uninstall.class.php:348 -msgid "Please wait, uninstallation is running..." -msgstr "Veuillez patienter, désinstallation en cours..." +#: inc/config.class.php:95 +msgid "Replace status dropdown by plugin actions" +msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" -#: inc/uninstall.class.php:837 -msgid "Item is now uninstalled" -msgstr "Matériel désinstallé" +#: inc/replace.class.php:61 inc/replace.class.php:109 inc/model.class.php:100 +#: inc/model.class.php:991 inc/model.class.php:1033 +msgid "Replacement" +msgstr "Remplacement" -#: inc/uninstall.class.php:840 -#, php-format -msgid "Item is now uninstalled with model %s" -msgstr "Matériel désinstallé avec le modèle %s" +#: inc/replace.class.php:476 front/action.php:57 +msgid "Replacement successful" +msgstr "Remplacement effectué avec succès" -#: inc/uninstall.class.php:847 -msgid "Item replaced by a new one" -msgstr "Matériel remplacé" +#: inc/model.class.php:158 +msgid "Replacing data" +msgstr "Remplacement des données" -#: inc/uninstall.class.php:850 -#, php-format -msgid "Item replaced by a new one with model %s" -msgstr "Matériel remplacé avec le modèle %s" +#: inc/replace.class.php:408 +msgid "See attached document" +msgstr "Voir le document attaché" -#: inc/uninstall.class.php:857 -msgid "Item replacing an old one" -msgstr "Matériel provenant d'un remplacement" +#: inc/config.class.php:81 +msgid "Shortcuts" +msgstr "Raccourcis" -#: inc/uninstall.class.php:863 -msgid "Removed from OCSNG with ID" -msgstr "Supprimé d'OCSNG ID OCS" +#: inc/model.class.php:589 +msgid "These options only apply to computers coming from OCSNG" +msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" -#: inc/uninstall.class.php:972 -msgid "Apply model" -msgstr "Appliquer un modèle" +#: inc/replace.class.php:131 +msgid "This document is the archive of this replaced item" +msgstr "Ce document est l'archive de l'objet remplacé" -#: inc/uninstall.class.php:996 -msgid "Item's location after applying model" -msgstr "Lieu de l'élément après application du modèle" +#: inc/replace.class.php:498 +msgid "This item is a replacement for item" +msgstr "Cet objet est le remplacement de l'objet" -#: inc/uninstall.class.php:1113 -msgid "Lifecycle" -msgstr "Cycle de vie" +#: inc/replace.class.php:500 +msgid "This item was replaced by" +msgstr "Cet objet a été remplacé par" + +#: inc/model.class.php:216 inc/model.class.php:795 +msgid "Transfer's model to use" +msgstr "Modèle de transfert à utiliser" -#~ msgid "Plugin fields options" -#~ msgstr "Options du plugin champs supplémentaires" +#: inc/model.class.php:207 inc/model.class.php:831 +msgid "Type of template" +msgstr "Type de modèle" -#~ msgid "Plugin fields block" -#~ msgstr "Bloc du plugin champs supplémentaires" +#: hook.php:42 inc/uninstall.class.php:320 +msgid "Uninstall" +msgstr "Désinstaller" -#~ msgid "Plugin fields field" -#~ msgstr "Champs du plugin champs supplémentaires" +#: inc/model.class.php:98 inc/model.class.php:989 inc/model.class.php:1031 +msgid "Uninstallation" +msgstr "Désinstallation" + +#: inc/uninstall.class.php:347 front/action.php:98 +msgid "Uninstallation successful" +msgstr "Désinstallation effectuée avec succès" From 9d9b0a71288e88766aa76e83bc913f51bb68e6e2 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 18 Jul 2024 10:52:02 +0200 Subject: [PATCH 20/54] merged main --- composer.lock | 1154 ------------------------------------------------- setup.php | 2 +- 2 files changed, 1 insertion(+), 1155 deletions(-) delete mode 100644 composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 61c8fdb..0000000 --- a/composer.lock +++ /dev/null @@ -1,1154 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "507d32e93c2d3c9f054296d893d98c63", - "packages": [], - "packages-dev": [ - { - "name": "glpi-project/tools", - "version": "0.7.3", - "source": { - "type": "git", - "url": "https://github.com/glpi-project/tools.git", - "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/a076482b057a727a9dcf155af40dac6c26a7b7c6", - "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6", - "shasum": "" - }, - "require": { - "symfony/console": "^5.4 || ^6.0", - "twig/twig": "^3.3" - }, - "require-dev": { - "nikic/php-parser": "^4.13", - "phpstan/phpstan-src": "^1.10" - }, - "bin": [ - "bin/extract-locales", - "bin/licence-headers-check", - "tools/plugin-release" - ], - "type": "library", - "autoload": { - "psr-4": { - "GlpiProject\\Tools\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-3.0-or-later" - ], - "authors": [ - { - "name": "Teclib'", - "email": "glpi@teclib.com", - "homepage": "http://teclib-group.com" - } - ], - "description": "Various tools for GLPI and its plugins", - "keywords": [ - "glpi", - "plugins", - "tools" - ], - "support": { - "issues": "https://github.com/glpi-project/tools/issues", - "source": "https://github.com/glpi-project/tools" - }, - "time": "2024-06-20T08:36:22+00:00" - }, - { - "name": "phpstan/phpstan", - "version": "1.11.6", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "6ac78f1165346c83b4a753f7e4186d969c6ad0ee" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6ac78f1165346c83b4a753f7e4186d969c6ad0ee", - "reference": "6ac78f1165346c83b4a753f7e4186d969c6ad0ee", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - } - ], - "time": "2024-07-01T15:33:06+00:00" - }, - { - "name": "psr/container", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", - "shasum": "" - }, - "require": { - "php": ">=7.4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" - }, - "time": "2021-11-05T16:50:12+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.10.1", - "source": { - "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", - "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" - }, - "bin": [ - "bin/phpcbf", - "bin/phpcs" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "Former lead" - }, - { - "name": "Juliette Reinders Folmer", - "role": "Current lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", - "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", - "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", - "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" - }, - "funding": [ - { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - } - ], - "time": "2024-05-22T21:24:41+00:00" - }, - { - "name": "symfony/console", - "version": "v5.4.41", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/6473d441a913cb997123b59ff2dbe3d1cf9e11ba", - "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command-line", - "console", - "terminal" - ], - "support": { - "source": "https://github.com/symfony/console/tree/v5.4.41" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-06-28T07:48:55+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-24T14:02:46+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-06-19T12:30:46+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.5.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.1", - "symfony/deprecation-contracts": "^2.1|^3" - }, - "conflict": { - "ext-psr": "<1.1|>=2" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-04-21T15:04:16+00:00" - }, - { - "name": "symfony/string", - "version": "v5.4.41", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "065a9611e0b1fd2197a867e1fb7f2238191b7096" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/065a9611e0b1fd2197a867e1fb7f2238191b7096", - "reference": "065a9611e0b1fd2197a867e1fb7f2238191b7096", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" - }, - "conflict": { - "symfony/translation-contracts": ">=3.0" - }, - "require-dev": { - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/http-client": "^4.4|^5.0|^6.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0|^6.0" - }, - "type": "library", - "autoload": { - "files": [ - "Resources/functions.php" - ], - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "support": { - "source": "https://github.com/symfony/string/tree/v5.4.41" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-06-28T09:20:55+00:00" - }, - { - "name": "twig/twig", - "version": "v3.10.3", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "67f29781ffafa520b0bbfbd8384674b42db04572" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/67f29781ffafa520b0bbfbd8384674b42db04572", - "reference": "67f29781ffafa520b0bbfbd8384674b42db04572", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php80": "^1.22" - }, - "require-dev": { - "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" - }, - "type": "library", - "autoload": { - "files": [ - "src/Resources/core.php", - "src/Resources/debug.php", - "src/Resources/escaper.php", - "src/Resources/string_loader.php" - ], - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Twig Team", - "role": "Contributors" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "support": { - "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.10.3" - }, - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/twig/twig", - "type": "tidelift" - } - ], - "time": "2024-05-16T10:04:27+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.4" - }, - "platform-dev": [], - "platform-overrides": { - "php": "7.4.0" - }, - "plugin-api-version": "2.6.0" -} diff --git a/setup.php b/setup.php index cbfde22..52f36f2 100644 --- a/setup.php +++ b/setup.php @@ -30,7 +30,7 @@ use Glpi\Plugin\Hooks; -define('PLUGIN_UNINSTALL_VERSION', '2.10.0'); +define('PLUGIN_UNINSTALL_VERSION', '2.9.2-infotel'); // Minimal GLPI version, inclusive define("PLUGIN_UNINSTALL_MIN_GLPI", "10.0.7"); From bb012023988ec83512f62c38c413779437a013d1 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 22 Jul 2024 13:57:59 +0200 Subject: [PATCH 21/54] Add new model type 'replacement then uninstallation' --- inc/model.class.php | 67 +++++++++++++++++++++++++++-------------- inc/replace.class.php | 13 ++++++++ inc/uninstall.class.php | 4 +-- 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index fd8b986..7021f22 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -37,6 +37,7 @@ class PluginUninstallModel extends CommonDBTM const TYPE_MODEL_UNINSTALL = 1; const TYPE_MODEL_REPLACEMENT = 2; + const TYPE_MODEL_REPLACEMENT_UNINSTALL = 3; public static function getTypeName($nb = 0) { @@ -85,6 +86,18 @@ public static function getMenuContent() return $menu; } + public function prepareInputForAdd($input) { + $input = parent::prepareInputForadd($input); + if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { + Session::addMessageAfterRedirect( + __("The purge archiving method is not available for this type of model"), + true, + ERROR + ); + $input = []; + } + return $input; + } public function prepareInputForUpdate($input) { @@ -96,15 +109,21 @@ public function prepareInputForUpdate($input) * * @param $name select name (default 'types_id') * @param $value default value (default '') + * @param bool $display echo or return string + * @return string|void **/ - public static function dropdownType($name = 'types_id', $value = '') + public static function dropdownType($name = 'types_id', $value = '', $display = true) { $values[1] = __('Uninstallation', 'uninstall'); if (self::canReplace()) { $values[2] = __('Replacement', 'uninstall'); + $values[3] = __('Replacement then uninstallation', 'uninstall'); } - Dropdown::showFromArray($name, $values, ['value' => $value]); + return Dropdown::showFromArray($name, $values, [ + 'value' => $value, + 'display' => $display + ]); } @@ -129,14 +148,19 @@ public static function getReplacementMethods() * Dropdown of method remplacement * * @param $name select name + * @param $type int types_id * @param $value default value (default '') **/ - public static function dropdownMethodReplacement($name, $value = '') + public static function dropdownMethodReplacement($name, $value = '', $type = self::TYPE_MODEL_REPLACEMENT) { - + $methods = self::getReplacementMethods(); + if ($type == PluginUninstallModel::TYPE_MODEL_REPLACEMENT_UNINSTALL) { + // can't purge to be able to apply uninstall after replacement + unset($methods[PluginUninstallReplace::METHOD_PURGE]); + } Dropdown::showFromArray( $name, - self::getReplacementMethods(), + $methods, ['value' => $value] ); } @@ -314,7 +338,7 @@ public function showForm($ID, $options = []) public function showPartFormUninstall() { echo ""; - echo "" . __('Erase datas', 'uninstall') . ""; + echo "" . __('Uninstallation', 'uninstall') . ' - ' . __('Erase datas', 'uninstall') . ""; echo ""; echo "" . __('Delete software history (computers)', 'uninstall') . ""; @@ -486,7 +510,7 @@ public function showPartFormRemplacement() echo "" . __('Archiving method of the old material', 'uninstall') . ""; echo ""; $value = (isset($this->fields["replace_method"]) ? $this->fields["replace_method"] : 0); - self::dropdownMethodReplacement('replace_method', $value); + self::dropdownMethodReplacement('replace_method', $value, $this->fields['types_id']); echo ""; echo ""; $plug = new Plugin(); @@ -673,13 +697,14 @@ public function showFormAction($item) echo "
"; echo ""; - if ($this->fields["types_id"] == self::TYPE_MODEL_UNINSTALL) { - // if Uninstall is selected - self::showPartFormUninstall(); - } else { - // if Replacement is selected + if ($this->fields["types_id"] != self::TYPE_MODEL_UNINSTALL) { + // if Replacement or Replacement then uninstall is selected self::showPartFormRemplacement(); } + if ($this->fields["types_id"] != self::TYPE_MODEL_REPLACEMENT) { + // if Uninstall or Replacement then uninstall is selected + self::showPartFormUninstall(); + } $plug = new Plugin(); if ($plug->isActivated('ocsinventoryng')) { @@ -1103,10 +1128,14 @@ public static function getSpecificValueToDisplay($field, $values, array $options break; case 'types_id': - if ($values['types_id'] == self::TYPE_MODEL_UNINSTALL) { - return __('Uninstallation', 'uninstall'); + switch($values['types_id']){ + case self::TYPE_MODEL_UNINSTALL: + return __('Uninstallation', 'uninstall'); + case self::TYPE_MODEL_REPLACEMENT: + return __('Replacement', 'uninstall'); + case self::TYPE_MODEL_REPLACEMENT_UNINSTALL: + return __('Replacement then uninstallation', 'uninstall'); } - return __('Replacement', 'uninstall'); break; case 'groups_id': @@ -1144,13 +1173,7 @@ public static function getSpecificValueToSelect($field, $name = '', $values = '' return Dropdown::showFromArray($name, self::getReplacementMethods(), $options); case 'types_id': - $types[self::TYPE_MODEL_UNINSTALL] = __('Uninstallation', 'uninstall'); - if (self::canReplace()) { - $types[self::TYPE_MODEL_REPLACEMENT] = __('Replacement', 'uninstall'); - } - $options['value'] = $values[$field]; - return Dropdown::showFromArray($name, $types, $options); - + return self::dropdownType($name, $values[$field], false); case 'groups_id': $options['name'] = $name; $options['value'] = $values[$field]; diff --git a/inc/replace.class.php b/inc/replace.class.php index c060282..8a2f928 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -543,6 +543,19 @@ public static function replace($type, $model_id, $tab_ids, $location) echo ""; echo "
"; + + if ($model->fields['types_id'] == PluginUninstallModel::TYPE_MODEL_REPLACEMENT_UNINSTALL) { + foreach ($tab_ids as $olditem_id => $newitem_id) { + PluginUninstallUninstall::uninstall( + $type, + $model->getID(), + [ + $type => [$olditem_id => $olditem_id] + ], + $location + ); + } + } } diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 40cefab..789d560 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -888,9 +888,9 @@ public static function getInfocomPresentForDevice($type, $ID) public static function showFormUninstallation($ID, $item, $user_id) { $type = $item->getType(); - // TODO review this to pass arg in form, not in URL. - echo ""; + echo Html::hidden('device_type', ['value' => $type]); echo ""; echo ""; From 9f3839c399f84176ae198766c8ea6aa82d8c3417 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 22 Jul 2024 14:30:43 +0200 Subject: [PATCH 22/54] lint --- inc/model.class.php | 8 ++++++-- inc/replace.class.php | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index 7021f22..7b718a8 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -86,7 +86,8 @@ public static function getMenuContent() return $menu; } - public function prepareInputForAdd($input) { + public function prepareInputForAdd($input) + { $input = parent::prepareInputForadd($input); if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( @@ -1128,13 +1129,16 @@ public static function getSpecificValueToDisplay($field, $values, array $options break; case 'types_id': - switch($values['types_id']){ + switch ($values['types_id']) { case self::TYPE_MODEL_UNINSTALL: return __('Uninstallation', 'uninstall'); + break; case self::TYPE_MODEL_REPLACEMENT: return __('Replacement', 'uninstall'); + break; case self::TYPE_MODEL_REPLACEMENT_UNINSTALL: return __('Replacement then uninstallation', 'uninstall'); + break; } break; diff --git a/inc/replace.class.php b/inc/replace.class.php index 8a2f928..cd59568 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -549,9 +549,7 @@ public static function replace($type, $model_id, $tab_ids, $location) PluginUninstallUninstall::uninstall( $type, $model->getID(), - [ - $type => [$olditem_id => $olditem_id] - ], + [$type => [$olditem_id => $olditem_id]], $location ); } From 535686c933345f3556ab1a367246dd7720e7fb22 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 22 Jul 2024 15:17:23 +0200 Subject: [PATCH 23/54] remove useless break --- inc/model.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index 7b718a8..6350522 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1132,13 +1132,10 @@ public static function getSpecificValueToDisplay($field, $values, array $options switch ($values['types_id']) { case self::TYPE_MODEL_UNINSTALL: return __('Uninstallation', 'uninstall'); - break; case self::TYPE_MODEL_REPLACEMENT: return __('Replacement', 'uninstall'); - break; case self::TYPE_MODEL_REPLACEMENT_UNINSTALL: return __('Replacement then uninstallation', 'uninstall'); - break; } break; From 8bee174f6c229d45bb877e16865f2be5b7c04c55 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Mon, 22 Jul 2024 15:23:22 +0200 Subject: [PATCH 24/54] indentation --- inc/model.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 6350522..87cc8fe 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1137,7 +1137,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options case self::TYPE_MODEL_REPLACEMENT_UNINSTALL: return __('Replacement then uninstallation', 'uninstall'); } - break; + break; case 'groups_id': if ($values['groups_action'] === 'old') { From ac156278c039f9594163a476b7315d9dc435a05b Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 09:13:24 +0200 Subject: [PATCH 25/54] start taking into account model type replacement then uninstallation --- hook.php | 8 ++- inc/model.class.php | 107 +++++++++++++++++++++-------------- inc/modelcontainer.class.php | 39 ++++++++++++- inc/replace.class.php | 7 ++- inc/uninstall.class.php | 7 ++- 5 files changed, 117 insertions(+), 51 deletions(-) diff --git a/hook.php b/hook.php index 114959f..f87e2ac 100644 --- a/hook.php +++ b/hook.php @@ -132,7 +132,13 @@ function plugin_uninstall_hook_add_container($item) foreach ($models as $mod) { $uninstallContainer->add([ 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId + 'plugin_fields_containers_id' => $containerId, + 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT + ]); + $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $mod['id'], + 'plugin_fields_containers_id' => $containerId, + 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL ]); } } diff --git a/inc/model.class.php b/inc/model.class.php index 2bf348c..6bd3798 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -477,6 +477,33 @@ public function showPartFormUninstall() -1 ); echo ""; + + if ((new Plugin())->isActivated('fields')) { + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } } public function showPartFormRemplacement() @@ -684,6 +711,33 @@ public function showPartFormRemplacement() ); echo ""; echo ""; + + if ((new Plugin())->isActivated('fields')) { + echo ""; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } } /** @@ -775,40 +829,6 @@ public function showFormAction($item) echo ""; } - // noticed that the field was never used in replace.class.php - if ($plug->isActivated('fields')) { - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - } - if ($canedit) { echo ""; echo ""; - echo ""; echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + // field infos + echo ""; + echo ""; echo ""; echo ""; echo ""; - echo ""; - $actionTitle = ''; - if ($pluginUninstallContainer->fields['model_type'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { - $actionTitle .= 'Uninstallation'; - } else { - $actionTitle .= 'Replacement'; - } - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + // model and container let the action be decided at this level, display dropdown + if ($model->fields[$modelProperty] == $model::PLUGIN_FIELDS_ACTION_ADVANCED + && $uninstallContainer->fields[$field] == $uninstallContainer::ACTION_CUSTOM) { + + echo ""; + $colspan = $field == 'action_uninstall' ? 1 : 3; + echo ""; - echo ""; - echo ""; - echo ""; - $url = Plugin::getWebDir('uninstall') . "/ajax/fieldValueInput.php"; - echo " - + "; + } + } else { + if ($model->fields[$modelProperty] == $model::PLUGIN_FIELDS_ACTION_ADVANCED) { + echo ""; } else { - label[0].style.display = 'none' + switch ($model->fields[$modelProperty]) { + case $model::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case $model::PLUGIN_FIELDS_ACTION_RAZ : + $action = __('Blank'); + break; + case $model::PLUGIN_FIELDS_ACTION_COPY : + $action = __('Copy'); + break; + } + + echo ""; } - inputContainer.load('$url', { - 'id' : $ID, - 'action' : e.target.selectedIndex - }); - }) - select.trigger('change'); - }); - - "; + + } + echo ""; + } + } $this->showFormButtons($options); } @@ -216,33 +230,6 @@ public function showForm($ID, $options = []) return true; } - public static function getSpecificValueToDisplay($field, $values, array $options = []) - { - if (!is_array($values)) { - $values = [$field => $values]; - } - switch ($field) { - case 'plugin_fields_fields_id': - $pluginField = new PluginFieldsField(); - $pluginField->getFromDB($values[$field]); - $types = PluginFieldsField::getTypes(true); - return $types[$pluginField->fields['type']]; - case 'action': - switch ($values[$field]) { - case self::ACTION_NONE: - return __('Do nothing'); - case self::ACTION_RAZ: - return __('Blank'); - case self::ACTION_COPY: - return __('Copy'); - case self::ACTION_NEW_VALUE: - return __('Set value', 'uninstall'); - } - } - - return ''; - } - public static function install($migration) { /** @var DBmysql $DB */ @@ -258,21 +245,13 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_modelcontainers_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_fields_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT " . self::ACTION_NONE . " , + `action_uninstall` int NOT NULL DEFAULT '0', + `action_replace` int NOT NULL DEFAULT '0', `new_value` varchar(255), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->queryOrDie($query, $DB->error()); - - $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) - VALUES - ('" . self::class . "', '2', '1', '0'), - ('" . self::class . "', '3', '2', '0'), - ('" . self::class . "', '4', '3', '0') - ;"; - - $DB->queryOrDie($queryPreferences, $DB->error()); } return true; } diff --git a/inc/replace.class.php b/inc/replace.class.php index a5723ee..c1617e5 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -450,24 +450,25 @@ public static function replace($type, $model_id, $tab_ids, $location) if ($plug->isActivated('fields')) { $pluginFieldsContainer = new PluginFieldsContainer(); + // copy all if ($model->fields['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_COPY) { $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); foreach ($containers as $container) { self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type); } } + // case by case for containers if ($model->fields['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { $pluginUninstallContainer = new PluginUninstallModelcontainer(); $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); foreach ($containers as $container) { $pluginUninstallContainer->getFromDBByCrit([ 'plugin_fields_containers_id' => $container['id'], - 'plugin_uninstall_models_id' => $model->getID(), - 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT + 'plugin_uninstall_models_id' => $model->getID() ]); - if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_COPY) { + if ($pluginUninstallContainer->fields['action_replace'] == $pluginUninstallContainer::ACTION_COPY) { self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type); - } else if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { + } else if ($pluginUninstallContainer->fields['action_replace'] == $pluginUninstallContainer::ACTION_CUSTOM) { self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer); } } @@ -1131,7 +1132,7 @@ public static function getPdfUserPreference($item) * @param $olditem CommonDBTM * @param $newitem CommonDBTM * @param $type string - * @param $pluginUninstallContainer PluginUninstallModelcontainer + * @param $pluginUninstallContainer PluginUninstallModelcontainer if not null, will see if it must do a case by case when handling the fields copies * @return void */ public static function handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer = null) @@ -1160,14 +1161,14 @@ public static function handlePluginFieldsContainerValues($overwrite, $container, $fields = $pluginFieldsField->find(['plugin_fields_containers_id' => $container['id']]); $parameters = []; foreach ($fields as $field) { - if ($pluginUninstallContainer && $pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { + if ($pluginUninstallContainer && $pluginUninstallContainer->fields['action_replace'] == $pluginUninstallContainer::ACTION_CUSTOM) { if ( $pluginUninstallField->getFromDBByCrit([ 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID(), 'plugin_fields_fields_id' => $field['id'] ]) ) { - if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { + if ($pluginUninstallField->fields['action_replace'] == $pluginUninstallField::ACTION_COPY) { if ($overwrite || !$newItemValues->current()) { // overwrite or no record $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index e6b65c7..5a46d31 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -538,16 +538,15 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) if (in_array($itemtype, $itemtypes)) { if ($pluginUninstallContainer->getFromDBByCrit([ 'plugin_uninstall_models_id' => $model->getID(), - 'plugin_fields_containers_id' => $fieldsContainer['id'], - 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL + 'plugin_fields_containers_id' => $fieldsContainer['id'] ])) { - if ($pluginUninstallContainer->fields['action'] != PluginUninstallModelcontainer::ACTION_NONE) { + if ($pluginUninstallContainer->fields['action_uninstall'] != PluginUninstallModelcontainer::ACTION_NONE) { $classname = 'PluginFields' . $itemtype . getSingular($fieldsContainer['name']); $obj = new $classname(); - if ($pluginUninstallContainer->fields['action'] == PluginUninstallModelcontainer::ACTION_RAZ) { + if ($pluginUninstallContainer->fields['action_uninstall'] == PluginUninstallModelcontainer::ACTION_RAZ) { // same as PluginFieldsContainer::preItemPurge $obj->deleteByCriteria(['items_id' => $item->fields['id']], true); - } else if ($pluginUninstallContainer->fields['action'] == PluginUninstallModelcontainer::ACTION_CUSTOM) { + } else if ($pluginUninstallContainer->fields['action_uninstall'] == PluginUninstallModelcontainer::ACTION_CUSTOM) { $uninstallFields = $pluginUninstallField->find([ 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID() ]); @@ -557,7 +556,7 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) foreach ($uninstallFields as $setting) { $field = array_filter($fieldsFields, fn($e) => $e['id'] == $setting['plugin_fields_fields_id']); $field = reset($field); - switch ($setting['action']) { + switch ($setting['action_uninstall']) { case PluginUninstallModelcontainerfield::ACTION_RAZ : $razValue = null; // field types which doesn't accept NULL values From 8dde679caabdc5e506143ae5103f97efa9e12278 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 11 Sep 2024 19:13:08 +0200 Subject: [PATCH 48/54] debug logs --- inc/modelcontainer.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index f841bf7..aa4c112 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -438,11 +438,8 @@ public function showFields($item) $fieldsField = new PluginFieldsField(); $types = $fieldsField->getTypes(true); - Toolbox::logInfo($fields); foreach ($fields as $fieldData) { - Toolbox::logInfo($fieldData); if ($fieldsField->getFromDB($fieldData['plugin_fields_fields_id'])) { - Toolbox::logInfo($fieldsField->getID()); echo ""; $link = PluginUninstallModelcontainerfield::getFormURLWithID($fieldData['id']); echo "
" . __("Apply model", 'uninstall') . "
" . __('Uninstallation', 'uninstall') . ' - ' . __("Additionnal fields", "fields") . + "
" . __('Fields plugin informations', 'uninstall') . ""; + $choices = [ + self::PLUGIN_FIELDS_ACTION_NONE => __('Do nothing'), + self::PLUGIN_FIELDS_ACTION_RAZ => __('Blank'), + self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall') + ]; + Dropdown::showFromArray( + "action_plugin_fields", + $choices, + [ + 'value' => isset($this->fields["action_plugin_fields_uninstall"]) ? + $this->fields["action_plugin_fields_uninstall"] : self::PLUGIN_FIELDS_ACTION_RAZ, + 'width' => '100%' + ] + ); + echo "
" . __('Replacement', 'uninstall') . ' - ' . __("Additionnal fields", "fields") . + "
" . __('Fields plugin informations', 'uninstall') . ""; + $choices = [ + self::PLUGIN_FIELDS_ACTION_NONE => __('Do nothing'), + self::PLUGIN_FIELDS_ACTION_COPY => __('Copy'), + self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall') + ]; + Dropdown::showFromArray( + "action_plugin_fields", + $choices, + [ + 'value' => isset($this->fields["action_plugin_fields_replace"]) ? + $this->fields["action_plugin_fields_replace"] : self::PLUGIN_FIELDS_ACTION_NONE, + 'width' => '100%' + ] + ); + echo "
" . __("Additionnal fields", "fields") . - "
" . __('Fields plugin informations', 'uninstall') . ""; - $choices = [ - self::PLUGIN_FIELDS_ACTION_NONE => __('Do nothing') - ]; - if ($this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL) { - $choices[self::PLUGIN_FIELDS_ACTION_RAZ] = __('Blank'); - } else { - $choices[self::PLUGIN_FIELDS_ACTION_COPY] = __('Copy'); - } - $choices[self::PLUGIN_FIELDS_ACTION_ADVANCED] = __('Advanced options', 'uninstall'); - $defaultValue = $this->fields['types_id'] == self::TYPE_MODEL_UNINSTALL ? - self::PLUGIN_FIELDS_ACTION_RAZ : self::PLUGIN_FIELDS_ACTION_NONE; - Dropdown::showFromArray( - "action_plugin_fields", - $choices, - [ - 'value' => isset($this->fields["action_plugin_fields"]) ? - $this->fields["action_plugin_fields"] : $defaultValue, - 'width' => '100%' - ] - ); - echo "
"; @@ -832,7 +852,8 @@ public function showFormPluginFields($item) { $plugin = new Plugin(); if ($plugin->isActivated('fields')) { - if ($item->fields['action_plugin_fields'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + if (($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) + || ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED)) { echo ""; echo ""; echo "
" . __('Plugin additionnal fields blocks', 'uninstall') . @@ -1423,14 +1444,15 @@ public static function install($migration) $migration->addField($table, 'raz_glpiinventory', "integer"); } - // from 2.9.1 to 2.10.0 + // from 2.9.2 to 2.10.0 if (!$DB->fieldExists($table, 'action_plugin_fields')) { - $migration->addField($table, 'action_plugin_fields', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); + $migration->addField($table, 'action_plugin_fields_replace', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); + $migration->addField($table, 'action_plugin_fields_uninstall', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); $migration->addPostQuery( // uninstall with no raz $DB->buildUpdate( $table, - ['action_plugin_fields' => '0'], + ['action_plugin_fields_uninstall' => '0'], [ 'raz_plugin_fields' => '0', 'types_id' => '1' @@ -1441,7 +1463,7 @@ public static function install($migration) // uninstall with raz $DB->buildUpdate( $table, - ['action_plugin_fields' => '1'], + ['action_plugin_fields_uninstall' => '1'], [ 'raz_plugin_fields' => '1', 'types_id' => '1' @@ -1452,7 +1474,7 @@ public static function install($migration) // replace default value $DB->buildUpdate( $table, - ['action_plugin_fields' => '0'], + ['action_plugin_fields_replace' => '0'], ['types_id' => '2'] ) ); @@ -1501,7 +1523,8 @@ public static function install($migration) `replace_method` int NOT NULL DEFAULT '2', `raz_glpiinventory` int NOT NULL DEFAULT '1', `raz_fusioninventory` int NOT NULL DEFAULT '1', - `action_plugin_fields` int NOT NULL DEFAULT '0', + `action_plugin_fields_uninstall` int NOT NULL DEFAULT '0', + `action_plugin_fields_replace` int NOT NULL DEFAULT '0', `replace_contact` tinyint NOT NULL DEFAULT '0', `replace_contact_num` tinyint NOT NULL DEFAULT '0', PRIMARY KEY (`id`) @@ -1565,7 +1588,7 @@ public static function createTransferModel($name = 'Uninstall') $tmp['raz_ocs_registrykeys'] = 1; $tmp['raz_glpiinventory'] = 1; $tmp['raz_fusioninventory'] = 1; - $tmp['action_plugin_fields'] = 1; + $tmp['action_plugin_fields_uninstall'] = 0; $tmp['comment'] = ''; $tmp['groups_action'] = 'set'; $tmp['groups_id'] = 0; diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index 485bb25..d812561 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -169,6 +169,17 @@ public function rawSearchOptions() 'massiveaction' => false ]; + $tab[] = [ + 'id' => 5, + 'table' => self::getTable(), + 'field' => 'types_id', + 'name' => __('Type of template', 'uninstall'), + 'linkfield' => '', + 'datatype' => 'specific', + 'searchtype' => 'equals', + 'massiveaction' => false + ]; + return $tab; } @@ -203,11 +214,36 @@ public static function getSpecificValueToDisplay($field, $values, array $options return $obj; case 'action': return self::getActions()[$values[$field]]; + case 'model_type': + switch ($values['types_id']) { + case PluginUninstallModel::TYPE_MODEL_UNINSTALL: + return __('Uninstallation', 'uninstall'); + case PluginUninstallModel::TYPE_MODEL_REPLACEMENT: + return __('Replacement', 'uninstall'); + } + break; } return ''; } + public static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = []) + { + if (!is_array($values)) { + $values = [$field => $values]; + } + switch ($field) { + case 'model_type': + $choices[1] = __('Uninstallation', 'uninstall'); + $choices[2] = __('Replacement', 'uninstall'); + return Dropdown::showFromArray($name, $choices, [ + 'value' => $values[$field], + 'display' => false + ]); + } + return parent::getSpecificValueToSelect($field, $name, $values, $options); + } + /** * Copy from PluginFieldsContainer * @param $field_id_or_search_options @@ -286,8 +322,7 @@ class='btn btn-sm btn-icon btn-ghost-secondary' echo ""; $rand = mt_rand(); $model = new PluginUninstallModel(); - $model->getFromDB($this->fields['plugin_uninstall_models_id']); - $defaultValue = $model->fields['types_id'] == $model::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; + $defaultValue = $this->fields['model_type'] == $model::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; Dropdown::showFromArray( "action", self::getActions($this), diff --git a/inc/replace.class.php b/inc/replace.class.php index 7c09b95..7c050c0 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -450,19 +450,20 @@ public static function replace($type, $model_id, $tab_ids, $location) if ($plug->isActivated('fields')) { $pluginFieldsContainer = new PluginFieldsContainer(); - if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_COPY) { + if ($model->fields['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_COPY) { $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); foreach ($containers as $container) { self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); } } - if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + if ($model->fields['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { $pluginUninstallContainer = new PluginUninstallModelcontainer(); $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); foreach ($containers as $container) { $pluginUninstallContainer->getFromDBByCrit([ 'plugin_fields_containers_id' => $container['id'], - 'plugin_uninstall_models_id' => $model->getID() + 'plugin_uninstall_models_id' => $model->getID(), + 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT ]); if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_COPY) { self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 66e9c64..2f7949a 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -316,10 +316,10 @@ private static function doOneUninstall(PluginUninstallModel $model, Transfer $tr } if ($plug->isActivated('fields')) { - if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_RAZ) { + if ($model->fields['action_plugin_fields_uninstall'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_RAZ) { self::deletePluginFieldsLink($type, $id); } - if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + if ($model->fields['action_plugin_fields_uninstall'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { self::handlePluginFieldsValues($type, $id, $model); } } @@ -538,7 +538,8 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) if (in_array($itemtype, $itemtypes)) { if ($pluginUninstallContainer->getFromDBByCrit([ 'plugin_uninstall_models_id' => $model->getID(), - 'plugin_fields_containers_id' => $fieldsContainer['id'] + 'plugin_fields_containers_id' => $fieldsContainer['id'], + 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL ])) { if ($pluginUninstallContainer->fields['action'] != PluginUninstallModelcontainer::ACTION_NONE) { $classname = 'PluginFields' . $itemtype . getSingular($fieldsContainer['name']); From dfff24ab967b521e06b1eee541aff9b8ac69cb82 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 09:22:07 +0200 Subject: [PATCH 26/54] fix for replacement then uninstall massive action --- inc/replace.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/inc/replace.class.php b/inc/replace.class.php index cd59568..ded1479 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -545,14 +545,16 @@ public static function replace($type, $model_id, $tab_ids, $location) echo "
"; if ($model->fields['types_id'] == PluginUninstallModel::TYPE_MODEL_REPLACEMENT_UNINSTALL) { + $uninstallArray = []; foreach ($tab_ids as $olditem_id => $newitem_id) { - PluginUninstallUninstall::uninstall( - $type, - $model->getID(), - [$type => [$olditem_id => $olditem_id]], - $location - ); + $uninstallArray[$olditem_id] = $olditem_id; } + PluginUninstallUninstall::uninstall( + $type, + $model->getID(), + [$type => $uninstallArray], + $location + ); } } From 0b63db66c8325fc66cf1459ee52cba9054950c88 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 09:27:02 +0200 Subject: [PATCH 27/54] fix translation without domain --- inc/model.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 6bd3798..76ae7bd 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -101,7 +101,7 @@ public function prepareInputForAdd($input) $input = parent::prepareInputForadd($input); if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( - __("The purge archiving method is not available for this type of model"), + __('The purge archiving method is not available for this type of model', 'uninstall'), true, ERROR ); From f47b90c2f5bd2c2e39db3469ea85e2db7c5371a6 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 09:28:37 +0200 Subject: [PATCH 28/54] fix translation without domain --- inc/model.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 87cc8fe..32ce68e 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -91,7 +91,7 @@ public function prepareInputForAdd($input) $input = parent::prepareInputForadd($input); if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( - __("The purge archiving method is not available for this type of model"), + __("The purge archiving method is not available for this type of model", 'uninstall'), true, ERROR ); From e7ff32540b44e1b563988ed12d14fd23b3de8ea8 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:28:59 +0200 Subject: [PATCH 29/54] take overwrite into account when copying values from plugin fields --- inc/replace.class.php | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/inc/replace.class.php b/inc/replace.class.php index 09b97d8..acb4450 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -453,7 +453,7 @@ public static function replace($type, $model_id, $tab_ids, $location) if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_COPY) { $containers = $pluginFieldsContainer->find(['itemtypes' => ['LIKE', "%\"$type\"%"]]); foreach ($containers as $container) { - self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); + self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type); } } if ($model->fields['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { @@ -465,9 +465,9 @@ public static function replace($type, $model_id, $tab_ids, $location) 'plugin_uninstall_models_id' => $model->getID() ]); if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_COPY) { - self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type); + self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type); } else if ($pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { - self::handlePluginFieldsContainerValues($container, $olditem, $newitem, $type, $pluginUninstallContainer); + self::handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer); } } } @@ -1111,7 +1111,8 @@ public static function getPdfUserPreference($item) } /** - * Create the query + * Handle copy of values from the plugin fields + * @param $overwrite bool if true copy will replace values from newitem by those of olditem * @param $container array data of PluginFieldsContainer * @param $olditem CommonDBTM * @param $newitem CommonDBTM @@ -1119,12 +1120,12 @@ public static function getPdfUserPreference($item) * @param $pluginUninstallContainer PluginUninstallModelcontainer * @return void */ - public static function handlePluginFieldsContainerValues($container, $olditem, $newitem, $type, $pluginUninstallContainer = null) { + public static function handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer = null) { global $DB; $pluginFieldsField = new PluginFieldsField(); $pluginUninstallField = new PluginUninstallModelcontainerfield(); $table = 'glpi_plugin_fields_'.strtolower($type).$container['name'].'s'; - $values = $DB->request([ + $oldItemValues = $DB->request([ 'FROM' => $table, 'WHERE' => [ 'items_id' => $olditem->getID(), @@ -1132,21 +1133,40 @@ public static function handlePluginFieldsContainerValues($container, $olditem, $ 'plugin_fields_containers_id' => $container['id'] ] ]); - if ($values->count()) { + $newItemValues = $DB->request([ + 'FROM' => $table, + 'WHERE' => [ + 'items_id' => $newitem->getID(), + 'itemtype' => $type, + 'plugin_fields_containers_id' => $container['id'] + ] + ]); + if ($oldItemValues->count()) { $fields = $pluginFieldsField->find(['plugin_fields_containers_id' => $container['id']]); $parameters = []; foreach($fields as $field) { + if ($pluginUninstallContainer && $pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { if ($pluginUninstallField->getFromDBByCrit([ 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID(), 'plugin_fields_fields_id' => $field['id'] ])) { if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { - $parameters[$field['name']] = $values->current()[$field['name']]; + if ($overwrite || !$newItemValues->current()) { + // overwrite or no record + $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { + // null or empty string + $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + } } } } else { - $parameters[$field['name']] = $values->current()[$field['name']]; + if ($overwrite || !$newItemValues->current()) { + $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { + $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + } } } if (count($parameters)) { From 3afc80e7ab1238c1edd69695dd53e7954ed2c0da Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:32:31 +0200 Subject: [PATCH 30/54] phpcs --- inc/replace.class.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/inc/replace.class.php b/inc/replace.class.php index acb4450..e58ac05 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -1120,11 +1120,12 @@ public static function getPdfUserPreference($item) * @param $pluginUninstallContainer PluginUninstallModelcontainer * @return void */ - public static function handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer = null) { + public static function handlePluginFieldsContainerValues($overwrite, $container, $olditem, $newitem, $type, $pluginUninstallContainer = null) + { global $DB; $pluginFieldsField = new PluginFieldsField(); $pluginUninstallField = new PluginUninstallModelcontainerfield(); - $table = 'glpi_plugin_fields_'.strtolower($type).$container['name'].'s'; + $table = 'glpi_plugin_fields_' . strtolower($type) . $container['name'] . 's'; $oldItemValues = $DB->request([ 'FROM' => $table, 'WHERE' => [ @@ -1144,13 +1145,14 @@ public static function handlePluginFieldsContainerValues($overwrite, $container, if ($oldItemValues->count()) { $fields = $pluginFieldsField->find(['plugin_fields_containers_id' => $container['id']]); $parameters = []; - foreach($fields as $field) { - + foreach ($fields as $field) { if ($pluginUninstallContainer && $pluginUninstallContainer->fields['action'] == $pluginUninstallContainer::ACTION_CUSTOM) { - if ($pluginUninstallField->getFromDBByCrit([ - 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID(), - 'plugin_fields_fields_id' => $field['id'] - ])) { + if ( + $pluginUninstallField->getFromDBByCrit([ + 'plugin_uninstall_modelcontainers_id' => $pluginUninstallContainer->getID(), + 'plugin_fields_fields_id' => $field['id'] + ]) + ) { if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { if ($overwrite || !$newItemValues->current()) { // overwrite or no record From 550d4e63ba55ebefe11033066748c586598ac81a Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:33:40 +0200 Subject: [PATCH 31/54] update composer.json config php version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2647eb6..7d7f96f 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "config": { "optimize-autoloader": true, "platform": { - "php": "7.4.0" + "php": "8.0.3" }, "sort-packages": true } From c334bdd3a68cdcfba78f4e7fa1fa50b9ee8113f7 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:40:07 +0200 Subject: [PATCH 32/54] composer.json set to php 7.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2647eb6..1272c71 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": ">=8.0" + "php": ">=7.4" }, "require-dev": { "glpi-project/tools": "^0.7.3", From dc1ecabf5b43338ea56a79b2bb270964af495458 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:41:15 +0200 Subject: [PATCH 33/54] composer.json set to php 7.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fe64ff1..1272c71 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "config": { "optimize-autoloader": true, "platform": { - "php": "8.0.3" + "php": "7.4.0" }, "sort-packages": true } From 6c5f3600efada0498c48200dfd39a1c901eaa61d Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 23 Jul 2024 10:50:07 +0200 Subject: [PATCH 34/54] phpcs --- ajax/fieldValueInput.php | 15 ++++++--------- front/modelcontainer.form.php | 2 -- front/modelcontainerfield.form.php | 1 - hook.php | 2 +- inc/model.class.php | 12 +++++++----- inc/modelcontainer.class.php | 19 +++++++++++-------- inc/modelcontainerfield.class.php | 17 +++++++++-------- inc/uninstall.class.php | 16 +++++++++------- 8 files changed, 43 insertions(+), 41 deletions(-) diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index 4260a8e..6e5f8e7 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -69,19 +69,18 @@ function ($itemtype) { $allowed_itemtypes ) ); - } else { $dropdown_matches = []; $is_dropdown = $type == 'dropdown' || preg_match( - '/^dropdown-(?.+)$/', - $type, - $dropdown_matches - ) === 1; + '/^dropdown-(?.+)$/', + $type, + $dropdown_matches + ) === 1; if (in_array($type, ['date', 'datetime'])) { echo ''; + "You can use 'now' for date and datetime field" + ) . '">'; } if ($is_dropdown) { @@ -119,5 +118,3 @@ function ($itemtype) { } break; } - - diff --git a/front/modelcontainer.form.php b/front/modelcontainer.form.php index dfcd617..f302bcc 100644 --- a/front/modelcontainer.form.php +++ b/front/modelcontainer.form.php @@ -1,6 +1,5 @@ ['plugin_fields_containers_id' => $containerId] ]); $ids = []; - foreach($pluginUninstallContainers as $cont) { + foreach ($pluginUninstallContainers as $cont) { $ids[] = $cont['id']; } if (count($ids)) { diff --git a/inc/model.class.php b/inc/model.class.php index cd6997d..a8d5aa4 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1401,7 +1401,7 @@ public static function install($migration) // from 2.9.1 to 2.10.0 if (!$DB->fieldExists($table, 'action_plugin_fields')) { - $migration->addField($table, 'action_plugin_fields', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); + $migration->addField($table, 'action_plugin_fields', "int NOT NULL DEFAULT '" . self::PLUGIN_FIELDS_ACTION_NONE . "'"); $migration->addPostQuery( // uninstall with no raz $DB->buildUpdate( @@ -1644,7 +1644,8 @@ public static function getIcon() * Create all non-existing relations between plugin fields containers and a model * @param $modelId int */ - public function createPluginFieldsRelations($modelId) { + public function createPluginFieldsRelations($modelId) + { global $DB; if ($DB->tableExists('glpi_plugin_fields_containers')) { $uninstallContainer = new PluginUninstallModelcontainer(); @@ -1654,20 +1655,21 @@ public function createPluginFieldsRelations($modelId) { $fieldsContainer = new PluginFieldsContainer(); $condition = count($existingContainersIds) ? ['NOT' => [ 'id' => $existingContainersIds - ]] : []; + ] + ] : []; $fieldsContainers = $fieldsContainer->find($condition); $fieldsField = new PluginFieldsField(); $uninstallField = new PluginUninstallModelcontainerfield(); - foreach($fieldsContainers as $container) { + foreach ($fieldsContainers as $container) { $newId = $uninstallContainer->add([ 'plugin_uninstall_models_id' => $modelId, 'plugin_fields_containers_id' => $container['id'] ]); $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); - foreach($fieldsFields as $field) { + foreach ($fieldsFields as $field) { $uninstallField->add([ 'plugin_fields_fields_id' => $field['id'], 'plugin_uninstall_modelcontainers_id' => $newId, diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index 485bb25..89af690 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -56,7 +56,8 @@ public static function getTypeName($nb = 0) * @param $self PluginUninstallModelcontainer|null * @return array value => label */ - public static function getActions($self = null) { + public static function getActions($self = null) + { if ($self) { $model = new PluginUninstallModel(); $model->getFromDB($self->fields['plugin_uninstall_models_id']); @@ -117,7 +118,8 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) return ''; } - public function getName($options = []) { + public function getName($options = []) + { $container = new PluginFieldsContainer(); $container->getFromDB($this->fields['plugin_fields_containers_id']); return $container->getFriendlyName(); @@ -238,7 +240,7 @@ public function showForm($ID, $options = []) $pluginFieldsContainer = new PluginFieldsContainer(); if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { echo "
"; - $backUrl = '../front/model.form.php?forecetab=3&id='.$this->fields['plugin_uninstall_models_id']; + $backUrl = '../front/model.form.php?forecetab=3&id=' . $this->fields['plugin_uninstall_models_id']; $backTitle = __('Blocs list', 'uninstall'); echo "fields['action'] == self::ACTION_CUSTOM) { echo ""; echo ""; @@ -339,7 +342,7 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT ". self::ACTION_NONE ." , + `action` int NOT NULL DEFAULT " . self::ACTION_NONE . " , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; @@ -347,9 +350,9 @@ public static function install($migration) $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) VALUES - ('".self::class."', '2', '1', '0'), - ('".self::class."', '3', '2', '0'), - ('".self::class."', '4', '3', '0') + ('" . self::class . "', '2', '1', '0'), + ('" . self::class . "', '3', '2', '0'), + ('" . self::class . "', '4', '3', '0') ;"; $DB->queryOrDie($queryPreferences, $DB->error()); diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 1b2828a..e9d6e9c 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -49,7 +49,8 @@ public static function getTypeName($nb = 0) return __("Field"); } - public function getName($options = []) { + public function getName($options = []) + { $field = new PluginFieldsField(); $field->getFromDB($this->fields['plugin_fields_fields_id']); return $field->fields['label']; @@ -116,7 +117,7 @@ public function showForm($ID, $options = []) $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { echo ""; + echo ""; echo ""; + } else { + $actionTitle .= self::getActions()[$item->fields[$field]]; + if ($item->fields[$field] != self::ACTION_CUSTOM) { + $actionTitle .= " (" . __('set by bloc', 'uninstall') . ')'; + } + } + echo "

" . $actionTitle . "

"; + if ($item->fields[$field] == self::ACTION_CUSTOM) { + $uninstallField = new PluginUninstallModelcontainerfield(); + $fields = $uninstallField->find([ + 'plugin_uninstall_modelcontainers_id' => $item->getID() + ]); + if (count($fields)) { + echo "
"; - $backUrl = '../front/modelcontainer.form.php?forecetab=2&id='.$pluginUninstallContainer->getID(); + $backUrl = '../front/modelcontainer.form.php?forecetab=2&id=' . $pluginUninstallContainer->getID(); $backTitle = __('Fields list', 'uninstall'); echo ""; - echo ""; if ($pluginFieldsField->fields['type'] === 'glpi_item') { echo __('Action set value is not available for this field type', 'uninstall'); @@ -195,7 +196,7 @@ class='btn btn-sm btn-icon btn-ghost-secondary' const label = $('#label-set-value'); const inputContainer = $('#container-set-value'); select.change(e => { - if (e.target.selectedIndex === ".self::ACTION_NEW_VALUE.") { + if (e.target.selectedIndex === " . self::ACTION_NEW_VALUE . ") { label[0].style.display = ''; } else { label[0].style.display = 'none' @@ -258,7 +259,7 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_modelcontainers_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_fields_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT ". self::ACTION_NONE ." , + `action` int NOT NULL DEFAULT " . self::ACTION_NONE . " , `new_value` varchar(255), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; @@ -267,9 +268,9 @@ public static function install($migration) $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) VALUES - ('".self::class."', '2', '1', '0'), - ('".self::class."', '3', '2', '0'), - ('".self::class."', '4', '3', '0') + ('" . self::class . "', '2', '1', '0'), + ('" . self::class . "', '3', '2', '0'), + ('" . self::class . "', '4', '3', '0') ;"; $DB->queryOrDie($queryPreferences, $DB->error()); diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 759f197..23b0e60 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -533,13 +533,15 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) // first level foreach & condition of first level if are copied from PluginFieldsContainer::preItemPurge $existingFieldsContainers = $pluginFieldsContainer->find(); - foreach($existingFieldsContainers as $fieldsContainer) { + foreach ($existingFieldsContainers as $fieldsContainer) { $itemtypes = json_decode($fieldsContainer['itemtypes']); if (in_array($itemtype, $itemtypes)) { - if ($pluginUninstallContainer->getFromDBByCrit([ - 'plugin_uninstall_models_id' => $model->getID(), - 'plugin_fields_containers_id' => $fieldsContainer['id'] - ])) { + if ( + $pluginUninstallContainer->getFromDBByCrit([ + 'plugin_uninstall_models_id' => $model->getID(), + 'plugin_fields_containers_id' => $fieldsContainer['id'] + ]) + ) { if ($pluginUninstallContainer->fields['action'] != PluginUninstallModelcontainer::ACTION_NONE) { $classname = 'PluginFields' . $itemtype . getSingular($fieldsContainer['name']); $obj = new $classname(); @@ -557,7 +559,7 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) $field = array_filter($fieldsFields, fn($e) => $e['id'] == $setting['plugin_fields_fields_id']); $field = reset($field); switch ($setting['action']) { - case PluginUninstallModelcontainerfield::ACTION_RAZ : + case PluginUninstallModelcontainerfield::ACTION_RAZ: $razValue = null; // field types which doesn't accept NULL values if (str_starts_with($field['type'], 'dropdown') || $field['type'] == 'glpi_item') { @@ -569,7 +571,7 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) ['items_id' => $items_id] ); break; - case PluginUninstallModelcontainerfield::ACTION_NEW_VALUE : + case PluginUninstallModelcontainerfield::ACTION_NEW_VALUE: $DB->update( $obj->getTable(), [$field['name'] => $setting['new_value']], From 6549706245e909b7426864c0228017e73809da9c Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 30 Jul 2024 17:23:36 +0200 Subject: [PATCH 35/54] start adaptation for model type 'uninstall then replace' --- inc/model.class.php | 45 ++++++++++++++++++++---------------- inc/modelcontainer.class.php | 26 +++++++++++++++++++++ 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index 76ae7bd..5b16982 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -852,22 +852,16 @@ public function showFormPluginFields($item) { $plugin = new Plugin(); if ($plugin->isActivated('fields')) { - if (($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) - || ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED)) { - echo ""; - echo ""; - echo "
" . __('Plugin additionnal fields blocks', 'uninstall') . - "
"; - $parameters = [ - 'start' => 0, - 'is_deleted' => 0, - 'sort' => 1, - 'order' => 'DESC', - 'reset' => 'reset', - 'criteria' => [], - ]; - Search::showList(PluginUninstallModelcontainer::class, $parameters); - } else { + $advancedOptions = false; + if ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + $advancedOptions = true; + PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_REPLACEMENT); + } + if ($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + $advancedOptions = true; + PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_UNINSTALL); + } + if (!$advancedOptions) { echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; return false; } @@ -875,7 +869,6 @@ public function showFormPluginFields($item) echo "" . __("Activate the plugin 'fields' to access this tab.") . ""; return false; } - return true; } @@ -1697,6 +1690,7 @@ public function createPluginFieldsRelations($modelId) { $uninstallContainer = new PluginUninstallModelcontainer(); $uninstallContainers = $uninstallContainer->find(['plugin_uninstall_models_id' => $modelId]); $existingContainersIds = array_map(fn($e) => $e['plugin_fields_containers_id'], $uninstallContainers); + $existingContainersIds = array_unique($existingContainersIds); $fieldsContainer = new PluginFieldsContainer(); $condition = count($existingContainersIds) ? ['NOT' => [ @@ -1708,16 +1702,27 @@ public function createPluginFieldsRelations($modelId) { $uninstallField = new PluginUninstallModelcontainerfield(); foreach($fieldsContainers as $container) { - $newId = $uninstallContainer->add([ + $newIdReplace = $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $modelId, + 'plugin_fields_containers_id' => $container['id'], + 'model_type' => self::TYPE_MODEL_REPLACEMENT + ]); + $newIdUninstall = $uninstallContainer->add([ 'plugin_uninstall_models_id' => $modelId, - 'plugin_fields_containers_id' => $container['id'] + 'plugin_fields_containers_id' => $container['id'], + 'model_type' => self::TYPE_MODEL_UNINSTALL ]); $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); foreach($fieldsFields as $field) { $uninstallField->add([ 'plugin_fields_fields_id' => $field['id'], - 'plugin_uninstall_modelcontainers_id' => $newId, + 'plugin_uninstall_modelcontainers_id' => $newIdReplace, + 'action' => $uninstallField::ACTION_RAZ + ]); + $uninstallField->add([ + 'plugin_fields_fields_id' => $field['id'], + 'plugin_uninstall_modelcontainers_id' => $newIdUninstall, 'action' => $uninstallField::ACTION_RAZ ]); } diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index d812561..fa88d95 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -341,6 +341,32 @@ class='btn btn-sm btn-icon btn-ghost-secondary' return true; } + /** + * @param $modelId int PluginUninstallModel id + * @param $type int const TYPE_MODEL from PluginUninstallModel + * @return void + */ + public static function showListsForType($modelId, $type) { + echo ""; + echo ""; + $typeTitle = $type === PluginUninstallModel::TYPE_MODEL_UNINSTALL ? __('Uninstallation', 'uninstall') : __('Replacement', 'uninstall'); + echo "
" . $typeTitle . ' - ' . __('Plugin additionnal fields blocks', 'uninstall') . + "
"; + $self = new self(); + Search::showList( + __CLASS__, + [ + 'display_type' => Search::HTML_OUTPUT, + 'criteria' => [ + $self->rawSearchOptions() + ] + ], + [ + array_map(fn($e) => $e['field'], $self->rawSearchOptions()) + ] + ); + } + public function showFields($item) { if ($item->fields['action'] == self::ACTION_CUSTOM) { echo ""; From aa260928fbce572f5cb1b34ba4f8cce0bfebc83c Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Tue, 30 Jul 2024 17:24:52 +0200 Subject: [PATCH 36/54] fix can't update data replacement tab values --- inc/model.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index 32ce68e..1a91d60 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -89,13 +89,15 @@ public static function getMenuContent() public function prepareInputForAdd($input) { $input = parent::prepareInputForadd($input); - if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { - Session::addMessageAfterRedirect( - __("The purge archiving method is not available for this type of model", 'uninstall'), - true, - ERROR - ); - $input = []; + if (array_key_exists('types_id', $input)) { + if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { + Session::addMessageAfterRedirect( + __("The purge archiving method is not available for this type of model", 'uninstall'), + true, + ERROR + ); + $input = []; + } } return $input; } From c430b9098bcd9a0169107adacb979d1fb4f5ee54 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel <155963006+ArthurMinfotel@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:42:06 +0200 Subject: [PATCH 37/54] Update model.class.php --- inc/model.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 1a91d60..38ea6e8 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -89,7 +89,7 @@ public static function getMenuContent() public function prepareInputForAdd($input) { $input = parent::prepareInputForadd($input); - if (array_key_exists('types_id', $input)) { + if (array_key_exists('types_id', $input) && array_key_exists('replace_method', $input)) { if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( __("The purge archiving method is not available for this type of model", 'uninstall'), From 0f8cd50d105313e34fd2f51d4bdb37b691eb1489 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 31 Jul 2024 14:09:15 +0200 Subject: [PATCH 38/54] end compatibility with replace then uninstall model type --- front/model.form.php | 33 +++- front/modelcontainer.form.php | 2 +- front/modelcontainerfield.form.php | 2 +- inc/model.class.php | 20 +- inc/modelcontainer.class.php | 295 ++++++++++++----------------- inc/modelcontainerfield.class.php | 27 ++- 6 files changed, 171 insertions(+), 208 deletions(-) diff --git a/front/model.form.php b/front/model.form.php index f25aaeb..08c2a56 100644 --- a/front/model.form.php +++ b/front/model.form.php @@ -49,16 +49,35 @@ if (isset($_POST["add"])) { $model->check(-1, UPDATE, $_POST); if ($id = $model->add($_POST)) { - if ($_POST['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { - $model->createPluginFieldsRelations($id); + $relationsCreated = false; + if (isset($_POST['action_plugin_fields_uninstall'])) { + if ($_POST['action_plugin_fields_uninstall'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($id); + $relationsCreated = true; + } + } + // possible that the relations were created in previous if for replace then uninstall model types + if (isset($_POST['action_plugin_fields_replace']) && !$relationsCreated) { + if ($_POST['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($id); + } } } Html::back(); } else if (isset($_POST["update"])) { $model->check($_POST['id'], UPDATE); if ($model->update($_POST)) { - if ($_POST['action_plugin_fields'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { - $model->createPluginFieldsRelations($_POST['id']); + $relationsCreated = false; + if (isset($_POST['action_plugin_fields_uninstall'])) { + if ($_POST['action_plugin_fields_uninstall'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($id); + $relationsCreated = true; + } + } + if (isset($_POST['action_plugin_fields_replace']) && !$relationsCreated) { + if ($_POST['action_plugin_fields_replace'] == PluginUninstallModel::PLUGIN_FIELDS_ACTION_ADVANCED) { + $model->createPluginFieldsRelations($id); + } } } Html::back(); @@ -66,7 +85,11 @@ $model->check($_POST['id'], DELETE); $model->delete($_POST); $model->redirectToList(); -} else { +} else if (isset($_GET["load_fields"])) { + $model->check($id, UPDATE); + $model->createPluginFieldsRelations($id); + Html::back(); +}else { Html::header( PluginUninstallModel::getTypeName(), $_SERVER['PHP_SELF'], diff --git a/front/modelcontainer.form.php b/front/modelcontainer.form.php index dfcd617..b4c3a56 100644 --- a/front/modelcontainer.form.php +++ b/front/modelcontainer.form.php @@ -40,7 +40,7 @@ Html::back(); } else { Html::header( - PluginUninstallModel::getTypeName(), + PluginUninstallModelContainer::getTypeName(), $_SERVER['PHP_SELF'], "admin", "PluginUninstallModel", diff --git a/front/modelcontainerfield.form.php b/front/modelcontainerfield.form.php index 5b46d2c..f8c8219 100644 --- a/front/modelcontainerfield.form.php +++ b/front/modelcontainerfield.form.php @@ -41,7 +41,7 @@ Html::back(); } else { Html::header( - PluginUninstallModel::getTypeName(), + PluginUninstallModelcontainerfield::getTypeName(), $_SERVER['PHP_SELF'], "admin", "PluginUninstallModel", diff --git a/inc/model.class.php b/inc/model.class.php index 2941137..945cf88 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -99,7 +99,7 @@ public static function getMenuContent() public function prepareInputForAdd($input) { $input = parent::prepareInputForadd($input); - if (array_key_exists('types_id', $input)) { + if (array_key_exists('types_id', $input) && array_key_exists('replace_method', $input)) { if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( __("The purge archiving method is not available for this type of model", 'uninstall'), @@ -207,7 +207,8 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab[1] = self::getTypeName(1); $tab[2] = __('Replacing data', 'uninstall'); $plugin = new Plugin(); - if ($plugin->isActivated('fields') && $item->fields['action_plugin_fields'] == self::PLUGIN_FIELDS_ACTION_ADVANCED) { + if ($plugin->isActivated('fields') && + ($item->fields['action_plugin_fields_uninstall'] == self::PLUGIN_FIELDS_ACTION_ADVANCED || $item->fields['action_plugin_fields_replace'] == self::PLUGIN_FIELDS_ACTION_ADVANCED)) { $tab[3] = __('Additional fields options', 'uninstall'); } return $tab; @@ -494,7 +495,7 @@ public function showPartFormUninstall() self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall') ]; Dropdown::showFromArray( - "action_plugin_fields", + "action_plugin_fields_uninstall", $choices, [ 'value' => isset($this->fields["action_plugin_fields_uninstall"]) ? @@ -728,7 +729,7 @@ public function showPartFormRemplacement() self::PLUGIN_FIELDS_ACTION_ADVANCED => __('Advanced options', 'uninstall') ]; Dropdown::showFromArray( - "action_plugin_fields", + "action_plugin_fields_replace", $choices, [ 'value' => isset($this->fields["action_plugin_fields_replace"]) ? @@ -860,6 +861,9 @@ public function showFormPluginFields($item) PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_REPLACEMENT); } if ($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + if ($advancedOptions) { + echo "
"; + } $advancedOptions = true; PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_UNINSTALL); } @@ -1440,7 +1444,7 @@ public static function install($migration) } // from 2.9.2 to 2.10.0 - if (!$DB->fieldExists($table, 'action_plugin_fields')) { + if (!$DB->fieldExists($table, 'action_plugin_fields_replace')) { $migration->addField($table, 'action_plugin_fields_replace', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); $migration->addField($table, 'action_plugin_fields_uninstall', "int NOT NULL DEFAULT '".self::PLUGIN_FIELDS_ACTION_NONE."'"); $migration->addPostQuery( @@ -1695,11 +1699,7 @@ public function createPluginFieldsRelations($modelId) { $existingContainersIds = array_map(fn($e) => $e['plugin_fields_containers_id'], $uninstallContainers); $existingContainersIds = array_unique($existingContainersIds); - $fieldsContainer = new PluginFieldsContainer(); - $condition = count($existingContainersIds) ? ['NOT' => [ - 'id' => $existingContainersIds - ]] : []; - $fieldsContainers = $fieldsContainer->find($condition); + $fieldsContainers = PluginUninstallModelcontainer::getContainerForItemtypes($existingContainersIds); $fieldsField = new PluginFieldsField(); $uninstallField = new PluginUninstallModelcontainerfield(); diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index fa88d95..24376b7 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -class PluginUninstallModelcontainer extends CommonDBTM +class PluginUninstallModelcontainer extends CommonDBChild { public $dohistory = true; @@ -43,7 +43,9 @@ class PluginUninstallModelcontainer extends CommonDBTM // choose action for each field individually const ACTION_CUSTOM = 3; - protected $displaylist = false; + public static $itemtype = 'PluginUninstallModel'; + public static $items_id = 'plugin_uninstall_models_id'; + protected $displaylist = true; public static function getTypeName($nb = 0) @@ -56,14 +58,13 @@ public static function getTypeName($nb = 0) * @param $self PluginUninstallModelcontainer|null * @return array value => label */ - public static function getActions($self = null) { + public static function getActions($self = null) + { if ($self) { - $model = new PluginUninstallModel(); - $model->getFromDB($self->fields['plugin_uninstall_models_id']); $values = [ self::ACTION_NONE => __('Do nothing'), ]; - if ($model->fields['types_id'] == $model::TYPE_MODEL_UNINSTALL) { + if ($self->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) { $values[self::ACTION_RAZ] = __('Blank'); } else { $values[self::ACTION_COPY] = __('Copy'); @@ -117,133 +118,13 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) return ''; } - public function getName($options = []) { + public function getName($options = []) + { $container = new PluginFieldsContainer(); $container->getFromDB($this->fields['plugin_fields_containers_id']); return $container->getFriendlyName(); } - public function rawSearchOptions() - { - $tab = []; - - $tab[] = [ - 'id' => 'common', - 'name' => self::getTypeName(), - ]; - - $tab[] = [ - 'id' => '1', - 'table' => self::getTable(), - 'field' => 'id', - 'name' => __('ID'), - 'massiveaction' => false, - 'datatype' => 'itemlink' - ]; - - $tab[] = [ - 'id' => '2', - 'table' => PluginFieldsContainer::getTable(), - 'field' => 'label', - 'name' => __('Block', 'fields'), - 'datatype' => 'dropdown', - 'linkfield' => 'plugin_fields_containers_id', - 'massiveaction' => false - ]; - - $tab[] = [ - 'id' => 3, - 'table' => PluginFieldsContainer::getTable(), - 'field' => 'itemtypes', - 'name' => __("Associated item type"), - 'datatype' => 'specific', - 'massiveaction' => false - ]; - - $tab[] = [ - 'id' => 4, - 'table' => self::getTable(), - 'field' => 'action', - 'name' => __('Action'), - 'datatype' => 'specific', - 'massiveaction' => false - ]; - - $tab[] = [ - 'id' => 5, - 'table' => self::getTable(), - 'field' => 'types_id', - 'name' => __('Type of template', 'uninstall'), - 'linkfield' => '', - 'datatype' => 'specific', - 'searchtype' => 'equals', - 'massiveaction' => false - ]; - - return $tab; - } - - /** - * @param $field - * @param $values - * @param array $options - * @return string - */ - public static function getSpecificValueToDisplay($field, $values, array $options = []) - { - if (!is_array($values)) { - $values = [$field => $values]; - } - switch ($field) { - case 'itemtypes': - $types = json_decode($values[$field]); - $obj = ''; - $count = count($types); - $i = 1; - foreach ($types as $type) { - if (!class_exists($type)) { - continue; - } - $name_type = getItemForItemtype($type); - $obj .= $name_type->getTypeName(2); - if ($count > $i) { - $obj .= ", "; - } - $i++; - } - return $obj; - case 'action': - return self::getActions()[$values[$field]]; - case 'model_type': - switch ($values['types_id']) { - case PluginUninstallModel::TYPE_MODEL_UNINSTALL: - return __('Uninstallation', 'uninstall'); - case PluginUninstallModel::TYPE_MODEL_REPLACEMENT: - return __('Replacement', 'uninstall'); - } - break; - } - - return ''; - } - - public static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = []) - { - if (!is_array($values)) { - $values = [$field => $values]; - } - switch ($field) { - case 'model_type': - $choices[1] = __('Uninstallation', 'uninstall'); - $choices[2] = __('Replacement', 'uninstall'); - return Dropdown::showFromArray($name, $choices, [ - 'value' => $values[$field], - 'display' => false - ]); - } - return parent::getSpecificValueToSelect($field, $name, $values, $options); - } - /** * Copy from PluginFieldsContainer * @param $field_id_or_search_options @@ -273,23 +154,15 @@ public function showForm($ID, $options = []) $pluginFieldsContainer = new PluginFieldsContainer(); if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { - echo "
"; + $model = new PluginUninstallModel(); + $model->getFromDB($this->fields['plugin_uninstall_models_id']); echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; echo ""; - echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; @@ -151,7 +144,13 @@ class='btn btn-sm btn-icon btn-ghost-secondary' echo ""; echo ""; - echo ""; echo ""; echo ""; @@ -160,7 +159,7 @@ class='btn btn-sm btn-icon btn-ghost-secondary' $options = [ self::ACTION_NONE => __('Do nothing'), ]; - if ($pluginUninstallModel->fields['types_id'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { + if ($pluginUninstallContainer->fields['model_type'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { $options[self::ACTION_RAZ] = __('Blank'); if ($pluginFieldsField->fields['type'] !== 'glpi_item') { $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); From feef70303de88b8634f05692f31473829530d874 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 31 Jul 2024 14:10:04 +0200 Subject: [PATCH 39/54] bugfix yesno field type + comments --- ajax/fieldValueInput.php | 11 +++++++++++ hook.php | 3 +++ inc/uninstall.class.php | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index 4260a8e..dd20be1 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -107,6 +107,17 @@ function ($itemtype) { ); echo ''; + } else if ($type === 'yesno') { + $value = 0; + if ($pluginUninstallField->fields['new_value'] === 1 || $pluginUninstallField->fields['new_value'] === '1') { + $value = 1; + } else if ($pluginFieldsField->fields['default_value']) { + $value = $pluginFieldsField->fields['default_value']; + } + Dropdown::showYesNo( + 'new_value', + $value + ); } else { echo Html::input( 'new_value', diff --git a/hook.php b/hook.php index f87e2ac..fd29d1b 100644 --- a/hook.php +++ b/hook.php @@ -170,6 +170,7 @@ function plugin_uninstall_hook_purge_container($item) } global $DB; $containerId = $item->getID(); + // all uninstall containers associated with the purged item $pluginUninstallContainers = $DB->request([ 'FROM' => PluginUninstallModelcontainer::getTable(), 'SELECT' => 'id', @@ -179,12 +180,14 @@ function plugin_uninstall_hook_purge_container($item) foreach($pluginUninstallContainers as $cont) { $ids[] = $cont['id']; } + // delete all uninstall fields associated with one of the previously fetched uninstall container if (count($ids)) { $DB->delete( PluginUninstallModelcontainerfield::getTable(), ['plugin_uninstall_modelcontainers_id' => $ids] ); } + // delete all uninstall containers associated with the purged item $DB->delete( PluginUninstallModelcontainer::getTable(), ['plugin_fields_containers_id' => $containerId] diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 2f7949a..e6b65c7 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -561,7 +561,9 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) case PluginUninstallModelcontainerfield::ACTION_RAZ : $razValue = null; // field types which doesn't accept NULL values - if (str_starts_with($field['type'], 'dropdown') || $field['type'] == 'glpi_item') { + if (str_starts_with($field['type'], 'dropdown') + || $field['type'] == 'glpi_item' + || $field['type'] == 'yesno') { $razValue = 0; } $DB->update( From dffdd06f11d45d65991fe7b3020126f425ba2b9d Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 31 Jul 2024 14:21:17 +0200 Subject: [PATCH 40/54] translations --- locales/fr_FR.mo | Bin 6085 -> 7242 bytes locales/fr_FR.po | 510 ++++++++++++++++++++++++++--------------------- 2 files changed, 288 insertions(+), 222 deletions(-) diff --git a/locales/fr_FR.mo b/locales/fr_FR.mo index bb630e1bd052d8c5d0e524628b29bdbd8621301c..5f86a778dea43a2b1f92f88d0f53962e316f4d15 100644 GIT binary patch delta 3002 zcma)+d2AF_9LHZNEoTpCDVN6sp_S9N6pB?*PUR2~{1%RegN7PY z568eUuo>3EOQHO%gk#}GI7L_aEOgf+P!9IM8h8*+gomMpA456*4Niu`h8Z&s&V-BM zQYiZ_cmX^RpT7^~_dBRS{(uT(#BkY3bu5bs7^cHUxD?9q7N|%AI2GOt_1p{aLii3; z<|m;7tHY}*Xd#)I%i#I28!CW1p#s@`vlZ;x574f7gR+LLHR!lo8fU-oW|mJ7RqocPpyV4p@n;(T5}jq zg0I7B_%+nU-$UANsz^(IY9KM2PN+Z@Lsei4s7Kh4B0sD$>`QhzP>V^{oO3O-*!VvyX-bE8TXdl@ce|1MNZ8b(up zMcB-)0WO1_nJrNEbZoy5s^m|?bKxO49exA{!$0HmN}Ny>GY)D7nq#hns#q4P^!Gwl z^u;2J?JSN%wcu)QX@>z+0Q(?E=1nNapF)-PTc}e01!u!CY&5h>pek?!RHe2-1^NJ# zpI4v)cn|8n;z<_z%qHTs1$M$VxD~3W55ed&gbL_ms44#ya<^&Z7L|A!)aN%3a%46` zooAt1vlFVak3a>u58}6IUSmO<%;!)Jet^;EL^@Znw@{foP<9{Agm=JJcn~V1FW?QZ z3h&w{poaGzs8T-&H7hSd9yPB<`y!tmizOJogvw+JjndGyK?SrPa%8s0d>AT|1CUSO z9Dys~TTp%)NlPu+4D~y4H&o?bfEIoLmGIB7hWpJR>Z#1?pmDBp%Rr?G9Oi+B`QB%j6}Z&Wl`HCm!SIHSg!u7ClY-wr%N@4rLj@NDA6z5rRYLb z11nK^uRyOwJ5dd=dOQOy%hfE_p!&KN#Kt-L{XbpQ)3T`l8&S=LWId|hO6XGbNmatZ zDD98t;upR?sP+f>dkWXt=& z&D(w_U2v@z*o>dIPQT-&o$j<7y_WCA+~c|Fq|M)wb;H)`rVb}vvIN%8%70)MCX=34 znSYKj^*fn_n~a|c*Hn+MNvHj7SfcBKu%~*(xJ79{akGj3TQ5VLeNN;te7-svZW=N& zTsY+SnaiT<;a%x-RD#+vnzc{p4Bdtx8+J$M*S2H$BikazaITea*~K z?H#jPJ7>*lvuzz+?X5Ff+r!6dZmV16WKsnu<#ySg+}365!iL)G!`o|bEN+^0rJHec zPTtRT*|ok)hwPl$9kbhqms_9p3;)hVz?z;%v*DUmEv3TPM6d4!9!HL<=kidd#SQW{ z>jXCG1zA7iX;dOt2{)P%n{;`t(&@{FKh-uaSyP%3tN~`Mf&Hh(ZaOfF|HD>(hgr-d zj_!BEv2~LhHbnRHc7c?<0CNz|uiH9a(_@yOGCVd}hdIxT8M)$g)nZ zbV>MB<2TI;N^zX+0^;8>=99{7!3%2}CWSXPHK!JzUT(9_NhIh~!VAnQ$MzlFui0^J bvZXXnG(MiM|J9e2)9vKE{J{N9ofUrrSKJY1 delta 1884 zcmY+^Sxj729LMo9Whqc#fMG|=1<`KM&HxrlHz-1DC0JsXM z&;NfeSNkvTNdHh%_?lrHBJLm_S!YZTmkT*CoML0V*oNg8z#80#bvS_=a26XdfgQMn z75E{x;3w$db*#dFvCWvYDPM0)I~TTNBTnEjM)KF+$GiCaRsQ}eDuK!p0^3jt_^}rE zVD@)V2}SU3d=8uO0&d0?Y+` z9F)MfsNefFfBipX3R7H`yYEFM(t-8NZ}xMdFC4=FPNPcq3f_Zn;}*PvTFDSwSLcw`rbx7?=hwyRhb*yR3&er4~x9iUnOp0hv^Hu@J<}Ztr$g~ zHLs&u@^0R%s1^Q>+pvr*RH>b)N=)Gsm_}9XAJjrNR_9teflA=9YU-~EPIEyev8c`S z9%=C>UEN;R#F@Tp*rT;sBzm12r;Jv7~Z7R))R{j)H zMRNv~$a4OA2369}kh#rwsKkCjO<2IgdV5-tMVbRRh(}QiJByuo4*mEADslCD3euZ6 z(Iz^LD%}#Qmlsi$xRn3=CEmy9>!?Iq$x?fw6P3`Byb)x7nio*tKZD!xYutyR%%d`X2DOqU)C0@N9?Fhg9My(y;t;_tQ$T2iy9rIG$+YWt5POM@gvLH1 zyI1glE-<_%l-o#D#S9QT36)#DA>rGGbK9p}vIn^~NUS4hadwPwRBQA~_Y+LA*QVM2}8KY}4byO91& zW?yjCQ%zL^*2aEL_7J1_3-_XS2pf!F2qouY3l4v?@mOln428o^(w$$729vJ!l+@ME z%($VXlZ-h*XTg0u_bq$4=WFoU#+3fKi85(|I=-`NRY-IB2{SS^?Z&hb?ps&jx=<@eC-Q5EL|2Dth zj#WKvuT?$d9SbhZrh>EXfHM=H9-Xv->gnBU2`5roT<4^X*rfW7*S7BdmZZ4Y)hC;DaJT#Zc_*(ir{{x5*-bnxe diff --git a/locales/fr_FR.po b/locales/fr_FR.po index 389253b..934aaef 100644 --- a/locales/fr_FR.po +++ b/locales/fr_FR.po @@ -2,236 +2,210 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. -# +# # Translators: # Walid Nouh, 2017 # Johan Cwiklinski, 2017 # alexandre delaunay , 2018 # Cédric Anne, 2023 -# +# #, fuzzy msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-06-30 12:39+0000\n" -"PO-Revision-Date: 2017-01-03 22:10+0000\n" +"POT-Creation-Date: 2024-07-31 14:12+0200\n" +"PO-Revision-Date: 2024-07-31 14:20+0200\n" "Last-Translator: Cédric Anne, 2023\n" -"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/fr_FR/)\n" +"Language-Team: French (France) (https://app.transifex.com/teclib/teams/28042/" +"fr_FR/)\n" +"Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fr_FR\n" -"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" - -#: inc/model.class.php:244 inc/model.class.php:841 -msgid "Action on group" -msgstr "Action sur le groupe" +"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % " +"1000000 == 0 ? 1 : 2;\n" +"X-Generator: Poedit 3.4.2\n" -#: inc/model.class.php:281 -msgid "Add template" -msgstr "Ajouter un modèle" - -#: inc/model.class.php:625 -msgid "Additionnal fields" -msgstr "Champs additionnels" - -#: inc/model.class.php:249 -msgid "Affect to a new group" -msgstr "Affecter à une nouvelle valeur" +#: hook.php:44 inc/uninstall.class.php:344 +msgid "Uninstall" +msgstr "Désinstaller" -#: inc/uninstall.class.php:841 -msgid "Apply model" -msgstr "Appliquer un modèle" +#: setup.php:155 +msgid "Item's Lifecycle (uninstall)" +msgstr "Cycle de vie des matériels (uninstall)" -#: inc/replace.class.php:136 -msgid "Archive of old material" -msgstr "Archive de l'ancien matériel" +#: ajax/fieldValueInput.php:56 +msgid "Allowed values" +msgstr "Valeurs autorisées" -#: inc/replace.class.php:567 inc/model.class.php:421 inc/model.class.php:852 -msgid "Archiving method of the old material" -msgstr "Méthode d'archivage de l'ancien matériel" +#: ajax/locations.php:49 inc/preference.class.php:102 inc/replace.class.php:700 +msgid "Keep previous location" +msgstr "Garder l'ancien lieu" -#: inc/model.class.php:112 -msgid "CSV Archiving" -msgstr "Archivage CSV" +#: ajax/locations.php:50 inc/preference.class.php:103 inc/replace.class.php:704 +msgid "Empty location" +msgstr "Vider le lieu" -#: inc/replace.class.php:672 -msgid "Choices for item to replace" -msgstr "Choix des matériels de remplacement" +#: front/action.php:64 inc/replace.class.php:567 +msgid "Replacement successful" +msgstr "Remplacement effectué avec succès" -#: inc/replace.class.php:625 inc/model.class.php:441 -msgid "Connections with other materials" -msgstr "Connexion avec les autres matériels" +#: front/action.php:114 inc/uninstall.class.php:370 +msgid "Uninstallation successful" +msgstr "Désinstallation effectuée avec succès" -#: inc/model.class.php:116 -msgid "Delete + Comment" -msgstr "Suppression + Commentaires" +#: inc/config.class.php:41 inc/model.class.php:82 inc/uninstall.class.php:39 +msgid "Item's Lifecycle" +msgstr "Cycle de vie des matériels" -#: inc/model.class.php:629 -msgid "Delete Fields plugin informations" -msgstr "Supprimer les informations du plugin Fields" +#: inc/config.class.php:85 +msgid "Shortcuts" +msgstr "Raccourcis" -#: inc/model.class.php:613 -msgid "Delete computer in FusionInventory" -msgstr "Supprimer le lien avec FusionInventory" +#: inc/config.class.php:91 +msgid "Location preferences" +msgstr "Préférences de lieux" -#: inc/model.class.php:593 inc/model.class.php:814 -msgid "Delete computer in OCSNG" -msgstr "Supprimer l'ordinateur dans OCSNG" +#: inc/config.class.php:99 +msgid "Replace status dropdown by plugin actions" +msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" -#: inc/model.class.php:380 -msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" +#: inc/model.class.php:105 +msgid "The purge archiving method is not available for this type of model" msgstr "" -"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " -"verrous, informations relatives à l'agent, ...)" - -#: inc/model.class.php:599 inc/model.class.php:822 -msgid "Delete link with computer in OCSNG" -msgstr "Supprimer le lien avec la machine OCS" +"La méthode d'archivage purge n'est pas disponible pour ce type de gabarit" -#: inc/model.class.php:298 inc/model.class.php:703 -msgid "Delete software history (computers)" -msgstr "Supprimer l'historique des logiciels (ordinateurs)" - -#: inc/model.class.php:303 inc/model.class.php:862 -msgid "Delete the whole history" -msgstr "Effacement de tout l'historique" - -#: inc/replace.class.php:660 inc/model.class.php:515 -msgid "Direct connections" -msgstr "connexions directes" - -#: inc/preference.class.php:99 inc/replace.class.php:593 ajax/locations.php:46 -msgid "Empty location" -msgstr "Vider le lieu" - -#: inc/model.class.php:295 -msgid "Erase datas" -msgstr "Effacement de données" +#: inc/model.class.php:131 inc/model.class.php:362 inc/model.class.php:486 +#: inc/model.class.php:1218 inc/modelcontainer.class.php:229 +msgid "Uninstallation" +msgstr "Désinstallation" -#: inc/replace.class.php:549 inc/model.class.php:392 -msgid "General informations" -msgstr "Informations générales" +#: inc/model.class.php:133 inc/model.class.php:720 inc/model.class.php:1220 +#: inc/modelcontainer.class.php:230 inc/replace.class.php:67 +#: inc/replace.class.php:115 +msgid "Replacement" +msgstr "Remplacement" -#: inc/model.class.php:391 inc/model.class.php:440 -msgid "Informations replacement" -msgstr "Remplacement des données" +#: inc/model.class.php:134 inc/model.class.php:1222 +msgid "Replacement then uninstallation" +msgstr "Remplacement puis désinstallation" -#: inc/uninstall.class.php:718 -msgid "Item is now uninstalled" -msgstr "Matériel désinstallé" +#: inc/model.class.php:148 +msgid "PDF Archiving" +msgstr "Archivage PDF" -#: inc/uninstall.class.php:720 -#, php-format -msgid "Item is now uninstalled with model %s" -msgstr "Matériel désinstallé avec le modèle %s" +#: inc/model.class.php:150 +msgid "CSV Archiving" +msgstr "Archivage CSV" -#: inc/uninstall.class.php:726 -msgid "Item replaced by a new one" -msgstr "Matériel remplacé" +#: inc/model.class.php:153 +msgid "Purge" +msgstr "Purge" -#: inc/uninstall.class.php:728 -#, php-format -msgid "Item replaced by a new one with model %s" -msgstr "Matériel remplacé avec le modèle %s" +#: inc/model.class.php:154 +msgid "Delete + Comment" +msgstr "Suppression + Commentaires" -#: inc/uninstall.class.php:734 -msgid "Item replacing an old one" -msgstr "Matériel provenant d'un remplacement" +#: inc/model.class.php:155 +msgid "Keep + Comment" +msgstr "Ne pas supprimer + Commentaires" -#: inc/uninstall.class.php:38 inc/model.class.php:66 inc/config.class.php:39 -msgid "Item's Lifecycle" -msgstr "Cycle de vie des matériels" +#: inc/model.class.php:208 +msgid "Replacing data" +msgstr "Remplacement des données" -#: setup.php:135 -msgid "Item's Lifecycle (uninstall)" -msgstr "Cycle de vie des matériels (uninstall)" +#: inc/model.class.php:212 +msgid "Additional fields options" +msgstr "Options des champs additionnels" -#: inc/uninstall.class.php:858 -msgid "Item's location after applying model" -msgstr "Lieu de l'élément après application du modèle" +#: inc/model.class.php:268 inc/model.class.php:1059 +msgid "Type of template" +msgstr "Type de modèle" -#: inc/preference.class.php:73 -msgid "Item's location after uninstall" -msgstr "Lieu du matériel après désinstallation" +#: inc/model.class.php:277 inc/model.class.php:1023 +msgid "Transfer's model to use" +msgstr "Modèle de transfert à utiliser" -#: inc/replace.class.php:40 -msgid "Item's replacement" -msgstr "Remplacement d'un matériel" +#: inc/model.class.php:298 inc/replace.class.php:714 +msgid "New status of the computer" +msgstr "Nouveau statut du matériel" -#: inc/model.class.php:117 -msgid "Keep + Comment" -msgstr "Ne pas supprimer + Commentaires" +#: inc/model.class.php:307 inc/model.class.php:1069 +msgid "Action on group" +msgstr "Action sur le groupe" -#: inc/model.class.php:248 inc/model.class.php:996 +#: inc/model.class.php:311 inc/model.class.php:1228 msgid "Keep in the current group" msgstr "Conserver la valeur actuelle" -#: inc/preference.class.php:98 inc/replace.class.php:589 ajax/locations.php:45 -msgid "Keep previous location" -msgstr "Garder l'ancien lieu" +#: inc/model.class.php:312 +msgid "Affect to a new group" +msgstr "Affecter à une nouvelle valeur" -#: inc/uninstall.class.php:963 -msgid "Lifecycle" -msgstr "Cycle de vie" +#: inc/model.class.php:327 +msgid "New group" +msgstr "Nouveau groupe" -#: inc/config.class.php:87 -msgid "Location preferences" -msgstr "Préférences de lieux" +#: inc/model.class.php:347 +msgid "Add template" +msgstr "Ajouter un modèle" -#: inc/model.class.php:284 +#: inc/model.class.php:350 msgid "Manage templates" msgstr "Gestion des modèles" -#: inc/model.class.php:264 -msgid "New group" -msgstr "Nouveau groupe" +#: inc/model.class.php:362 +msgid "Erase datas" +msgstr "Effacement de données" -#: inc/replace.class.php:685 -msgid "New item" -msgstr "Nouveau matériel" +#: inc/model.class.php:365 inc/model.class.php:931 +msgid "Delete software history (computers)" +msgstr "Supprimer l'historique des logiciels (ordinateurs)" -#: inc/replace.class.php:586 -msgid "New location of item" -msgstr "Nouveau lieu du matériel" +#: inc/model.class.php:372 inc/model.class.php:1090 +msgid "Delete the whole history" +msgstr "Effacement de tout l'historique" -#: inc/replace.class.php:603 inc/model.class.php:236 -msgid "New status of the computer" -msgstr "Nouveau statut du matériel" +#: inc/model.class.php:474 +msgid "Delete inventory data (dynamic flag, locks, agent information, ...)" +msgstr "" +"Supprimer les données relatives à l'inventaire (marqueur \"dynamique\", " +"verrous, informations relatives à l'agent, ...)" -#: inc/model.class.php:587 -msgid "OCSNG link" -msgid_plural "OCSNG links" -msgstr[0] "Lien OCSNG" -msgstr[1] "Liens OCSNG" -msgstr[2] "Liens OCSNG" +#: inc/model.class.php:486 inc/model.class.php:720 +msgid "Additionnal fields" +msgstr "Champs additionnels" -#: inc/replace.class.php:675 -msgid "Old item" -msgstr "Ancien matériel" +#: inc/model.class.php:490 inc/model.class.php:724 +msgid "Fields plugin informations" +msgstr "Informations du plugin champs supplémentaires" -#: inc/replace.class.php:564 inc/model.class.php:414 -msgid "Overwrite informations (from old item to the new)" -msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" +#: inc/model.class.php:495 inc/model.class.php:729 +msgid "Advanced options" +msgstr "Options avancées" -#: inc/model.class.php:110 -msgid "PDF Archiving" -msgstr "Archivage PDF" +#: inc/model.class.php:517 inc/model.class.php:580 +msgid "Informations replacement" +msgstr "Remplacement des données" -#: inc/replace.class.php:65 -msgid "Please wait, replacement is running..." -msgstr "Veuillez patienter, remplacement en cours..." +#: inc/model.class.php:518 inc/replace.class.php:659 +msgid "General informations" +msgstr "Informations générales" -#: inc/uninstall.class.php:324 -msgid "Please wait, uninstallation is running..." -msgstr "Veuillez patienter, désinstallation en cours..." +#: inc/model.class.php:549 inc/replace.class.php:675 +msgid "Overwrite informations (from old item to the new)" +msgstr "Ecraser les informations (de l'ancien matériel vers le nouveau)" -#: inc/model.class.php:430 +#: inc/model.class.php:558 inc/model.class.php:1080 inc/replace.class.php:678 +msgid "Archiving method of the old material" +msgstr "Méthode d'archivage de l'ancien matériel" + +#: inc/model.class.php:567 msgid "Plugin PDF is installed and activated" msgstr "Le plugin PDF est installé et activé" -#: inc/model.class.php:433 +#: inc/model.class.php:571 msgid "" "Plugin PDF is not installed, you won't be able to use PDF format for " "archiving" @@ -239,83 +213,175 @@ msgstr "" "Le plugin PDF n'est pas installé, vous ne pouvez pas utiliser le format PDF " "pour l'archivage" -#: inc/model.class.php:115 -msgid "Purge" -msgstr "Purge" +#: inc/model.class.php:581 inc/replace.class.php:737 +msgid "Connections with other materials" +msgstr "Connexion avec les autres matériels" -#: inc/replace.class.php:548 inc/replace.class.php:624 -msgid "Reminder of the replacement model" -msgstr "Rappel du modèle de remplacement" +#: inc/model.class.php:680 inc/replace.class.php:782 +msgid "Direct connections" +msgstr "connexions directes" -#: inc/replace.class.php:688 -msgid "Remove" -msgstr "Supprimer" +#: inc/model.class.php:787 +msgid "OCSNG link" +msgid_plural "OCSNG links" +msgstr[0] "Lien OCSNG" +msgstr[1] "Liens OCSNG" +msgstr[2] "Liens OCSNG" -#: inc/uninstall.class.php:739 -msgid "Removed from OCSNG with ID" -msgstr "Supprimé d'OCSNG ID OCS" +#: inc/model.class.php:790 +msgid "These options only apply to computers coming from OCSNG" +msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" -#: inc/replace.class.php:734 -msgid "Replace" -msgstr "Remplacer" +#: inc/model.class.php:795 inc/model.class.php:1042 +msgid "Delete computer in OCSNG" +msgstr "Supprimer l'ordinateur dans OCSNG" -#: inc/config.class.php:95 -msgid "Replace status dropdown by plugin actions" -msgstr "Remplacer la liste déroulante des statuts par les actions du plugin" +#: inc/model.class.php:805 inc/model.class.php:1050 +msgid "Delete link with computer in OCSNG" +msgstr "Supprimer le lien avec la machine OCS" -#: inc/replace.class.php:61 inc/replace.class.php:109 inc/model.class.php:100 -#: inc/model.class.php:991 inc/model.class.php:1033 -msgid "Replacement" -msgstr "Remplacement" +#: inc/model.class.php:821 +msgid "Delete computer in FusionInventory" +msgstr "Supprimer le lien avec FusionInventory" -#: inc/replace.class.php:476 front/action.php:57 -msgid "Replacement successful" -msgstr "Remplacement effectué avec succès" +#: inc/modelcontainer.class.php:53 inc/modelcontainer.class.php:244 +msgid "Block" +msgstr "Bloc" -#: inc/model.class.php:158 -msgid "Replacing data" -msgstr "Remplacement des données" +#: inc/modelcontainer.class.php:72 inc/modelcontainer.class.php:79 +msgid "Per field action" +msgstr "Action par champ" -#: inc/replace.class.php:408 -msgid "See attached document" -msgstr "Voir le document attaché" +#: inc/modelcontainer.class.php:160 +msgid "Block informations" +msgstr "Informations du bloc" -#: inc/config.class.php:81 -msgid "Shortcuts" -msgstr "Raccourcis" +#: inc/modelcontainer.class.php:197 inc/modelcontainerfield.class.php:153 +msgid "Action for " +msgstr "Action pour " -#: inc/model.class.php:589 -msgid "These options only apply to computers coming from OCSNG" -msgstr "Ces options s'appliquent seulement aux ordinateurs provenant d'OCSNG" +#: inc/modelcontainer.class.php:233 +msgid "Plugin additionnal fields blocks" +msgstr "Bloc du plugin champs supplémentaires" + +#: inc/modelcontainer.class.php:282 +msgid "Load plugin data" +msgstr "Charger les informations du plugin" + +#: inc/modelcontainerfield.class.php:122 +msgid "Field informations" +msgstr "Informations du champ" + +#: inc/modelcontainerfield.class.php:165 inc/modelcontainerfield.class.php:238 +msgid "Set value" +msgstr "Choisir la valeur" + +#: inc/modelcontainerfield.class.php:182 +msgid "New value" +msgstr "Nouvelle valeur" -#: inc/replace.class.php:131 +#: inc/modelcontainerfield.class.php:185 +msgid "Action set value is not available for this field type" +msgstr "L'action choisir la valeur n'est pas disponible pour ce type de champ" + +#: inc/preference.class.php:77 +msgid "Item's location after uninstall" +msgstr "Lieu du matériel après désinstallation" + +#: inc/replace.class.php:41 +msgid "Item's replacement" +msgstr "Remplacement d'un matériel" + +#: inc/replace.class.php:71 +msgid "Please wait, replacement is running..." +msgstr "Veuillez patienter, remplacement en cours..." + +#: inc/replace.class.php:138 msgid "This document is the archive of this replaced item" msgstr "Ce document est l'archive de l'objet remplacé" -#: inc/replace.class.php:498 +#: inc/replace.class.php:143 +msgid "Archive of old material" +msgstr "Archive de l'ancien matériel" + +#: inc/replace.class.php:488 +msgid "See attached document" +msgstr "Voir le document attaché" + +#: inc/replace.class.php:604 msgid "This item is a replacement for item" msgstr "Cet objet est le remplacement de l'objet" -#: inc/replace.class.php:500 +#: inc/replace.class.php:606 msgid "This item was replaced by" msgstr "Cet objet a été remplacé par" -#: inc/model.class.php:216 inc/model.class.php:795 -msgid "Transfer's model to use" -msgstr "Modèle de transfert à utiliser" +#: inc/replace.class.php:658 inc/replace.class.php:736 +msgid "Reminder of the replacement model" +msgstr "Rappel du modèle de remplacement" -#: inc/model.class.php:207 inc/model.class.php:831 -msgid "Type of template" -msgstr "Type de modèle" +#: inc/replace.class.php:697 +msgid "New location of item" +msgstr "Nouveau lieu du matériel" -#: hook.php:42 inc/uninstall.class.php:320 -msgid "Uninstall" -msgstr "Désinstaller" +#: inc/replace.class.php:794 +msgid "Choices for item to replace" +msgstr "Choix des matériels de remplacement" -#: inc/model.class.php:98 inc/model.class.php:989 inc/model.class.php:1031 -msgid "Uninstallation" -msgstr "Désinstallation" +#: inc/replace.class.php:797 +msgid "Old item" +msgstr "Ancien matériel" -#: inc/uninstall.class.php:347 front/action.php:98 -msgid "Uninstallation successful" -msgstr "Désinstallation effectuée avec succès" +#: inc/replace.class.php:807 +msgid "New item" +msgstr "Nouveau matériel" + +#: inc/replace.class.php:810 +msgid "Remove" +msgstr "Supprimer" + +#: inc/replace.class.php:856 +msgid "Replace" +msgstr "Remplacer" + +#: inc/uninstall.class.php:348 +msgid "Please wait, uninstallation is running..." +msgstr "Veuillez patienter, désinstallation en cours..." + +#: inc/uninstall.class.php:840 +msgid "Item is now uninstalled" +msgstr "Matériel désinstallé" + +#: inc/uninstall.class.php:843 +#, php-format +msgid "Item is now uninstalled with model %s" +msgstr "Matériel désinstallé avec le modèle %s" + +#: inc/uninstall.class.php:850 +msgid "Item replaced by a new one" +msgstr "Matériel remplacé" + +#: inc/uninstall.class.php:853 +#, php-format +msgid "Item replaced by a new one with model %s" +msgstr "Matériel remplacé avec le modèle %s" + +#: inc/uninstall.class.php:860 +msgid "Item replacing an old one" +msgstr "Matériel provenant d'un remplacement" + +#: inc/uninstall.class.php:866 +msgid "Removed from OCSNG with ID" +msgstr "Supprimé d'OCSNG ID OCS" + +#: inc/uninstall.class.php:975 +msgid "Apply model" +msgstr "Appliquer un modèle" + +#: inc/uninstall.class.php:999 +msgid "Item's location after applying model" +msgstr "Lieu de l'élément après application du modèle" + +#: inc/uninstall.class.php:1116 +msgid "Lifecycle" +msgstr "Cycle de vie" From be89a0ec8b9ec278b0d82dd9b5247adba0f37b52 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 1 Aug 2024 10:14:55 +0200 Subject: [PATCH 41/54] bugfix copy plugin fields values on replace && better restrictions on hook and display linked to plugin fields --- ajax/fieldValueInput.php | 1 - hook.php | 37 ++++++++++++++++++++++--------------- inc/model.class.php | 23 +++++++++++++++-------- inc/replace.class.php | 8 ++++---- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index dd20be1..fd6b82e 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -86,7 +86,6 @@ function ($itemtype) { if ($is_dropdown) { $multiple = (bool)$pluginFieldsField->fields['multiple']; - Toolbox::logInfo($multiple); echo '
'; diff --git a/hook.php b/hook.php index fd29d1b..50466a8 100644 --- a/hook.php +++ b/hook.php @@ -86,6 +86,8 @@ function plugin_uninstall_install() require_once($dir . "/inc/model.class.php"); require_once($dir . "/inc/replace.class.php"); require_once($dir . "/inc/config.class.php"); + require_once($dir . "/inc/modelcontainer.class.php"); + require_once($dir . "/inc/modelcontainerfield.class.php"); PluginUninstallProfile::install($migration); PluginUninstallModel::install($migration); @@ -122,24 +124,29 @@ function plugin_uninstall_uninstall() function plugin_uninstall_hook_add_container($item) { + global $UNINSTALL_TYPES; if (!($item instanceof PluginFieldsContainer)) { return; } - $containerId = $item->getID(); - $uninstallContainer = new PluginUninstallModelcontainer(); - $model = new PluginUninstallModel(); - $models = $model->find(); - foreach ($models as $mod) { - $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId, - 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT - ]); - $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId, - 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL - ]); + $types = json_decode($item->fields['itemtypes']); + // only create matching elements for containers concerning item types used by the plugin + if (!empty(array_intersect($types, $UNINSTALL_TYPES))) { + $containerId = $item->getID(); + $uninstallContainer = new PluginUninstallModelcontainer(); + $model = new PluginUninstallModel(); + $models = $model->find(); + foreach ($models as $mod) { + $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $mod['id'], + 'plugin_fields_containers_id' => $containerId, + 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT + ]); + $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $mod['id'], + 'plugin_fields_containers_id' => $containerId, + 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL + ]); + } } } diff --git a/inc/model.class.php b/inc/model.class.php index 945cf88..7a3a2f3 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -856,17 +856,24 @@ public function showFormPluginFields($item) $plugin = new Plugin(); if ($plugin->isActivated('fields')) { $advancedOptions = false; - if ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { - $advancedOptions = true; - PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_REPLACEMENT); + + if ($item->fields["types_id"] != self::TYPE_MODEL_UNINSTALL) { + if ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + $advancedOptions = true; + PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_REPLACEMENT); + } } - if ($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { - if ($advancedOptions) { - echo "
"; + + if ($item->fields["types_id"] != self::TYPE_MODEL_REPLACEMENT) { + if ($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { + if ($advancedOptions) { + echo "
"; + } + $advancedOptions = true; + PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_UNINSTALL); } - $advancedOptions = true; - PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_UNINSTALL); } + if (!$advancedOptions) { echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; return false; diff --git a/inc/replace.class.php b/inc/replace.class.php index 4f4f856..91eff2c 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -1168,18 +1168,18 @@ public static function handlePluginFieldsContainerValues($overwrite, $container, if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { if ($overwrite || !$newItemValues->current()) { // overwrite or no record - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { // null or empty string - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } } } } else { if ($overwrite || !$newItemValues->current()) { - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } } } From 9474739284e769582bde40e65d58d0a3c76afcdf Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 21 Aug 2024 10:23:21 +0200 Subject: [PATCH 42/54] bugfix yesno fields raz & bugfix copy value & restrict container creation for link with fields --- ajax/fieldValueInput.php | 12 +++++++++++- hook.php | 23 ++++++++++++++--------- inc/replace.class.php | 8 ++++---- inc/uninstall.class.php | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index 6e5f8e7..38400c6 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -85,7 +85,6 @@ function ($itemtype) { if ($is_dropdown) { $multiple = (bool)$pluginFieldsField->fields['multiple']; - Toolbox::logInfo($multiple); echo '
'; @@ -106,6 +105,17 @@ function ($itemtype) { ); echo '
'; + } else if ($type === 'yesno') { + $value = 0; + if ($pluginUninstallField->fields['new_value'] === 1 || $pluginUninstallField->fields['new_value'] === '1') { + $value = 1; + } else if ($pluginFieldsField->fields['default_value']) { + $value = $pluginFieldsField->fields['default_value']; + } + Dropdown::showYesNo( + 'new_value', + $value + ); } else { echo Html::input( 'new_value', diff --git a/hook.php b/hook.php index 6641e2d..e626847 100644 --- a/hook.php +++ b/hook.php @@ -122,18 +122,23 @@ function plugin_uninstall_uninstall() function plugin_uninstall_hook_add_container($item) { + global $UNINSTALL_TYPES; if (!($item instanceof PluginFieldsContainer)) { return; } - $containerId = $item->getID(); - $uninstallContainer = new PluginUninstallModelcontainer(); - $model = new PluginUninstallModel(); - $models = $model->find(); - foreach ($models as $mod) { - $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId - ]); + $types = json_decode($item->fields['itemtypes']); + // only create matching elements for containers concerning item types used by the plugin + if (!empty(array_intersect($types, $UNINSTALL_TYPES))) { + $containerId = $item->getID(); + $uninstallContainer = new PluginUninstallModelcontainer(); + $model = new PluginUninstallModel(); + $models = $model->find(); + foreach ($models as $mod) { + $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $mod['id'], + 'plugin_fields_containers_id' => $containerId + ]); + } } } diff --git a/inc/replace.class.php b/inc/replace.class.php index e58ac05..32f9606 100644 --- a/inc/replace.class.php +++ b/inc/replace.class.php @@ -1156,18 +1156,18 @@ public static function handlePluginFieldsContainerValues($overwrite, $container, if ($pluginUninstallField->fields['action'] == $pluginUninstallField::ACTION_COPY) { if ($overwrite || !$newItemValues->current()) { // overwrite or no record - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { // null or empty string - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } } } } else { if ($overwrite || !$newItemValues->current()) { - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } else if (!$newItemValues->current()[$field['name']] && !$newItemValues->current()[$field['name']] !== 0 && !$newItemValues->current()[$field['name']] !== '0') { - $parameters[$field['name']] = $newItemValues->current()[$field['name']]; + $parameters[$field['name']] = $oldItemValues->current()[$field['name']]; } } } diff --git a/inc/uninstall.class.php b/inc/uninstall.class.php index 23b0e60..e04b998 100644 --- a/inc/uninstall.class.php +++ b/inc/uninstall.class.php @@ -562,7 +562,7 @@ public static function handlePluginFieldsValues($itemtype, $items_id, $model) case PluginUninstallModelcontainerfield::ACTION_RAZ: $razValue = null; // field types which doesn't accept NULL values - if (str_starts_with($field['type'], 'dropdown') || $field['type'] == 'glpi_item') { + if (str_starts_with($field['type'], 'dropdown') || $field['type'] == 'glpi_item' || $field['type'] == 'yesno') { $razValue = 0; } $DB->update( From 0544cc94786d03f8b672241d9a30e1bc0f3caacc Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 21 Aug 2024 10:35:59 +0200 Subject: [PATCH 43/54] change class extended by fields related classes to CommonDBChild --- inc/modelcontainer.class.php | 19 +++++-------------- inc/modelcontainerfield.class.php | 17 +++++------------ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index 89af690..5654706 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -class PluginUninstallModelcontainer extends CommonDBTM +class PluginUninstallModelcontainer extends CommonDBChild { public $dohistory = true; @@ -43,8 +43,9 @@ class PluginUninstallModelcontainer extends CommonDBTM // choose action for each field individually const ACTION_CUSTOM = 3; - protected $displaylist = false; - + public static $itemtype = 'PluginUninstallModel'; + public static $items_id = 'plugin_uninstall_models_id'; + protected $displaylist = true; public static function getTypeName($nb = 0) { @@ -239,23 +240,13 @@ public function showForm($ID, $options = []) $pluginFieldsContainer = new PluginFieldsContainer(); if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { - echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; From ff5d103ba2fbe1ebe5f30f84683f8496517cdca9 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 21 Aug 2024 11:10:57 +0200 Subject: [PATCH 44/54] apply restriction on links created with plugin fields in createPluginFieldsRelations --- inc/model.class.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index a8d5aa4..537ed16 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1646,7 +1646,7 @@ public static function getIcon() */ public function createPluginFieldsRelations($modelId) { - global $DB; + global $DB, $UNINSTALL_TYPES; if ($DB->tableExists('glpi_plugin_fields_containers')) { $uninstallContainer = new PluginUninstallModelcontainer(); $uninstallContainers = $uninstallContainer->find(['plugin_uninstall_models_id' => $modelId]); @@ -1663,18 +1663,22 @@ public function createPluginFieldsRelations($modelId) $uninstallField = new PluginUninstallModelcontainerfield(); foreach ($fieldsContainers as $container) { - $newId = $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $modelId, - 'plugin_fields_containers_id' => $container['id'] - ]); - - $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); - foreach ($fieldsFields as $field) { - $uninstallField->add([ - 'plugin_fields_fields_id' => $field['id'], - 'plugin_uninstall_modelcontainers_id' => $newId, - 'action' => $uninstallField::ACTION_RAZ + $types = json_decode($container['itemtypes']); + // only create matching elements for containers concerning item types used by the plugin + if (!empty(array_intersect($types, $UNINSTALL_TYPES))) { + $newId = $uninstallContainer->add([ + 'plugin_uninstall_models_id' => $modelId, + 'plugin_fields_containers_id' => $container['id'] ]); + + $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); + foreach ($fieldsFields as $field) { + $uninstallField->add([ + 'plugin_fields_fields_id' => $field['id'], + 'plugin_uninstall_modelcontainers_id' => $newId, + 'action' => $uninstallField::ACTION_RAZ + ]); + } } } } From 3d7806aee876e6f74693f4894fccf4c6c36584e5 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 21 Aug 2024 13:49:02 +0200 Subject: [PATCH 45/54] replacement then uninstall model created during install/update if none present --- inc/model.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/model.class.php b/inc/model.class.php index 38ea6e8..eecbbd0 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -1362,6 +1362,11 @@ public static function install($migration) } $migration->migrationOneTable($table); + + $self = new self(); + if (!$self->find(['types_id' => self::TYPE_MODEL_REPLACEMENT_UNINSTALL])) { + self::createTransferModel('Replace then uninstall'); + } } else { // plugin never installed $query = "CREATE TABLE IF NOT EXISTS `" . getTableForItemType(__CLASS__) . "` ( @@ -1416,6 +1421,7 @@ public static function install($migration) self::createTransferModel('Uninstall'); self::createTransferModel('Replace'); + self::createTransferModel('Replace then uninstall'); } return true; } @@ -1478,8 +1484,10 @@ public static function createTransferModel($name = 'Uninstall') $tmp['delete_ocs_link'] = 0; if ($name == 'Uninstall') { $tmp['types_id'] = self::TYPE_MODEL_UNINSTALL; - } else { + } else if ($name == 'Replace') { $tmp['types_id'] = self::TYPE_MODEL_REPLACEMENT; + } else { + $tmp['types_id'] = self::TYPE_MODEL_REPLACEMENT_UNINSTALL; } $tmp['replace_name'] = 1; $tmp['replace_serial'] = 1; From c9b759594e3a123862fadd1594c07761600347bb Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 21 Aug 2024 16:12:44 +0200 Subject: [PATCH 46/54] fix text & phpdoc & replace multiple if by switch --- inc/model.class.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/inc/model.class.php b/inc/model.class.php index eecbbd0..09a6c7e 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -92,7 +92,7 @@ public function prepareInputForAdd($input) if (array_key_exists('types_id', $input) && array_key_exists('replace_method', $input)) { if ($input['types_id'] == self::TYPE_MODEL_REPLACEMENT_UNINSTALL && $input['replace_method'] == PluginUninstallReplace::METHOD_PURGE) { Session::addMessageAfterRedirect( - __("The purge archiving method is not available for this type of model", 'uninstall'), + __("The purge archiving method is not available for this model type", 'uninstall'), true, ERROR ); @@ -150,9 +150,9 @@ public static function getReplacementMethods() /** * Dropdown of method remplacement * - * @param $name select name + * @param $name string name + * @param $value string|int default value (default '') * @param $type int types_id - * @param $value default value (default '') **/ public static function dropdownMethodReplacement($name, $value = '', $type = self::TYPE_MODEL_REPLACEMENT) { @@ -700,13 +700,17 @@ public function showFormAction($item) echo ""; echo "
"; - $backUrl = '../front/model.form.php?forecetab=3&id='.$this->fields['plugin_uninstall_models_id']; - $backTitle = __('Blocs list', 'uninstall'); - echo " - - $backTitle - "; - echo "
" . __('Block informations', 'uninstall') . "
" . __("Label") . " : " . $pluginFieldsContainer->getTypeName() . " : "; - echo $pluginFieldsContainer->fields['label']; + echo "" . $pluginFieldsContainer->fields['label'] . ""; echo "" . __("Associated item type") . " : "; @@ -315,14 +188,19 @@ class='btn btn-sm btn-icon btn-ghost-secondary' echo "
" . __('Uninstall action', 'uninstall') . + $actionTitle = ''; + if ($this->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) { + $actionTitle .= 'Uninstallation'; + } else { + $actionTitle .= 'Replacement'; + } + echo "" . __('Action for ', 'uninstall') . __($actionTitle, 'uninstall') . "
" . __('Action') . " :"; $rand = mt_rand(); - $model = new PluginUninstallModel(); - $defaultValue = $this->fields['model_type'] == $model::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; + $defaultValue = $this->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; Dropdown::showFromArray( "action", self::getActions($this), @@ -346,40 +224,111 @@ class='btn btn-sm btn-icon btn-ghost-secondary' * @param $type int const TYPE_MODEL from PluginUninstallModel * @return void */ - public static function showListsForType($modelId, $type) { - echo ""; - echo ""; - $typeTitle = $type === PluginUninstallModel::TYPE_MODEL_UNINSTALL ? __('Uninstallation', 'uninstall') : __('Replacement', 'uninstall'); - echo "
" . $typeTitle . ' - ' . __('Plugin additionnal fields blocks', 'uninstall') . - "
"; - $self = new self(); - Search::showList( - __CLASS__, - [ - 'display_type' => Search::HTML_OUTPUT, - 'criteria' => [ - $self->rawSearchOptions() - ] - ], - [ - array_map(fn($e) => $e['field'], $self->rawSearchOptions()) - ] + public static function showListsForType($modelId, $type) + { + $typeTitle = $type === PluginUninstallModel::TYPE_MODEL_UNINSTALL ? __('Uninstallation', 'uninstall') : __( + 'Replacement', + 'uninstall' ); + echo "

" . $typeTitle . ' - ' . __('Plugin additionnal fields blocks', 'uninstall') . + "

"; + $self = new self(); + $uninstallContainers = $self->find([ + 'plugin_uninstall_models_id' => $modelId, + 'model_type' => $type + ]); + $fieldContainer = new PluginFieldsContainer(); + if (count($uninstallContainers)) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + foreach($uninstallContainers as $uninstallContainer) { + if ($fieldContainer->getFromDB($uninstallContainer['plugin_fields_containers_id'])) { + echo ""; + $link = PluginUninstallModelContainer::getFormURLWithID($uninstallContainer['id']); + echo ""; + $types = json_decode($fieldContainer->fields['itemtypes']); + $obj = ''; + $count = count($types); + $i = 1; + foreach ($types as $type) { + if (!class_exists($type)) { + continue; + } + $name_type = getItemForItemtype($type); + $obj .= $name_type->getTypeName(2); + if ($count > $i) { + $obj .= ", "; + } + $i++; + } + echo ""; + echo ""; + echo ""; + } + } + echo ""; + echo "
" . __('Block', 'fields') . "" . __("Associated item type") . "" . __("Action") . "
"; + echo "" . $fieldContainer->fields['label'] . ""; + echo "" . $obj . "" . self::getActions()[$uninstallContainer['action']] . "
"; + } else { + if (count(self::getContainerForItemtypes())) { + $link = PluginUninstallModel::getFormURLWithID($modelId) . "&load_fields=1"; + echo "" . __('Load plugin data', 'uninstall') . ""; + } + } + } + + /** + * Get all containers from the plugin fields which are associated with an itemtype used by uninstall + * @param $ids array list of plugin fields container ids to exclude from the request + * @return array + */ + public static function getContainerForItemtypes($ids = []) { + global $DB, $UNINSTALL_TYPES; + $query = "SELECT * FROM " . PluginFieldsContainer::getTable() . " WHERE "; + if (count($ids)) { + $query .= 'id NOT IN ('.implode(',', $ids).') AND ('; + } + foreach($UNINSTALL_TYPES as $index => $type) { + $query .= 'itemtypes LIKE \'%"'.$type.'"%\' '; + if ($index != count($UNINSTALL_TYPES) - 1) { + $query .= 'OR '; + } + } + if (count($ids)) { + $query .= ')'; + } + $return = []; + if ($result = $DB->doQuery($query)) { + if ($DB->numrows($result) > 0) { + while ($data = $DB->fetchAssoc($result)) { + $return[] = $data; + } + } + } + return $return; } - public function showFields($item) { + public function showFields($item) + { if ($item->fields['action'] == self::ACTION_CUSTOM) { echo ""; echo ""; echo "
" . __('Fields') . "
"; $parameters = [ - 'start' => 0, + 'start' => 0, 'is_deleted' => 0, - 'sort' => 1, - 'order' => 'DESC', - 'reset' => 'reset', - 'criteria' => [], + 'sort' => 1, + 'order' => 'DESC', + 'reset' => 'reset', + 'criteria' => [], ]; Search::showList(PluginUninstallModelcontainerfield::class, $parameters); } @@ -400,20 +349,12 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', - `action` int NOT NULL DEFAULT ". self::ACTION_NONE ." , + `model_type` int DEFAULT '0', + `action` int NOT NULL DEFAULT " . self::ACTION_NONE . " , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; $DB->queryOrDie($query, $DB->error()); - - $queryPreferences = "INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) - VALUES - ('".self::class."', '2', '1', '0'), - ('".self::class."', '3', '2', '0'), - ('".self::class."', '4', '3', '0') - ;"; - - $DB->queryOrDie($queryPreferences, $DB->error()); } return true; } diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 1b2828a..e291d09 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -28,11 +28,11 @@ * ------------------------------------------------------------------------- */ -class PluginUninstallModelcontainerfield extends CommonDBTM +class PluginUninstallModelcontainerfield extends CommonDBChild { public $dohistory = true; - protected $displaylist = false; + protected $displaylist = true; public static $rightname = "uninstall:profile"; // do nothing @@ -44,6 +44,9 @@ class PluginUninstallModelcontainerfield extends CommonDBTM // copy value, replace only const ACTION_COPY = 3; + public static $itemtype = 'PluginUninstallModelcontainer'; + public static $items_id = 'plugin_uninstall_modelcontainers_id'; + public static function getTypeName($nb = 0) { return __("Field"); @@ -115,16 +118,6 @@ public function showForm($ID, $options = []) $pluginUninstallModel = new PluginUninstallModel(); $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { - echo "
"; - $backUrl = '../front/modelcontainer.form.php?forecetab=2&id='.$pluginUninstallContainer->getID(); - $backTitle = __('Fields list', 'uninstall'); - echo " - - $backTitle - "; - echo "
" . __('Field informations', 'uninstall') . "
" . __('Uninstall action', 'uninstall') . + $actionTitle = ''; + if ($pluginUninstallContainer->fields['model_type'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { + $actionTitle .= 'Uninstallation'; + } else { + $actionTitle .= 'Replacement'; + } + echo "" . __('Action for ', 'uninstall') . __($actionTitle, 'uninstall') . "
" . __('Action') . " :
"; - $backUrl = '../front/model.form.php?forecetab=3&id=' . $this->fields['plugin_uninstall_models_id']; - $backTitle = __('Blocs list', 'uninstall'); - echo " - - $backTitle - "; - echo "
" . __('Block informations', 'uninstall') . "
" . __("Label") . " : "; - echo $pluginFieldsContainer->fields['label']; + echo "" . $pluginFieldsContainer->fields['label'] . ""; echo "" . __("Associated item type") . " : "; diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index e9d6e9c..b964fec 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -28,11 +28,11 @@ * ------------------------------------------------------------------------- */ -class PluginUninstallModelcontainerfield extends CommonDBTM +class PluginUninstallModelcontainerfield extends CommonDBChild { public $dohistory = true; - protected $displaylist = false; + protected $displaylist = true; public static $rightname = "uninstall:profile"; // do nothing @@ -44,6 +44,9 @@ class PluginUninstallModelcontainerfield extends CommonDBTM // copy value, replace only const ACTION_COPY = 3; + public static $itemtype = 'PluginUninstallModelcontainer'; + public static $items_id = 'plugin_uninstall_modelcontainers_id'; + public static function getTypeName($nb = 0) { return __("Field"); @@ -116,16 +119,6 @@ public function showForm($ID, $options = []) $pluginUninstallModel = new PluginUninstallModel(); $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { - echo "
"; - $backUrl = '../front/modelcontainer.form.php?forecetab=2&id=' . $pluginUninstallContainer->getID(); - $backTitle = __('Fields list', 'uninstall'); - echo " - - $backTitle - "; - echo "
" . __('Field informations', 'uninstall') . "
"; - if ($this->fields["types_id"] != self::TYPE_MODEL_UNINSTALL) { - // if Replacement or Replacement then uninstall is selected - self::showPartFormRemplacement(); - } - if ($this->fields["types_id"] != self::TYPE_MODEL_REPLACEMENT) { - // if Uninstall or Replacement then uninstall is selected - self::showPartFormUninstall(); + switch ($this->fields["types_id"]) { + case self::TYPE_MODEL_UNINSTALL: + self::showPartFormUninstall(); + break; + case self::TYPE_MODEL_REPLACEMENT: + self::showPartFormRemplacement(); + break; + case self::TYPE_MODEL_REPLACEMENT_UNINSTALL: + self::showPartFormRemplacement(); + self::showPartFormUninstall(); + break; } $plug = new Plugin(); From 18232af2250a25b19e85ea963615ebe86e294022 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Wed, 11 Sep 2024 19:11:58 +0200 Subject: [PATCH 47/54] regroup action for plugin fields replace and uninstall for modelcontainer & modelcontainerfield --- hook.php | 11 +- inc/model.class.php | 60 ++++--- inc/modelcontainer.class.php | 247 ++++++++++++++++++++------ inc/modelcontainerfield.class.php | 279 ++++++++++++++---------------- inc/replace.class.php | 15 +- inc/uninstall.class.php | 11 +- 6 files changed, 371 insertions(+), 252 deletions(-) diff --git a/hook.php b/hook.php index feafeae..2fac3c8 100644 --- a/hook.php +++ b/hook.php @@ -138,13 +138,7 @@ function plugin_uninstall_hook_add_container($item) foreach ($models as $mod) { $uninstallContainer->add([ 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId, - 'model_type' => PluginUninstallModel::TYPE_MODEL_REPLACEMENT - ]); - $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $mod['id'], - 'plugin_fields_containers_id' => $containerId, - 'model_type' => PluginUninstallModel::TYPE_MODEL_UNINSTALL + 'plugin_fields_containers_id' => $containerId ]); } } @@ -164,8 +158,7 @@ function plugin_uninstall_hook_add_field($item) foreach ($uninstallContainers as $container) { $uninstallField->add([ 'plugin_uninstall_modelcontainers_id' => $container['id'], - 'plugin_fields_fields_id' => $fieldId, - 'action' => $uninstallField::ACTION_NONE + 'plugin_fields_fields_id' => $fieldId ]); } } diff --git a/inc/model.class.php b/inc/model.class.php index a501448..11df9e3 100644 --- a/inc/model.class.php +++ b/inc/model.class.php @@ -207,8 +207,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) $tab[1] = self::getTypeName(1); $tab[2] = __('Replacing data', 'uninstall'); $plugin = new Plugin(); - if ($plugin->isActivated('fields') && - ($item->fields['action_plugin_fields_uninstall'] == self::PLUGIN_FIELDS_ACTION_ADVANCED || $item->fields['action_plugin_fields_replace'] == self::PLUGIN_FIELDS_ACTION_ADVANCED)) { + if ($plugin->isActivated('fields')) { $tab[3] = __('Additional fields options', 'uninstall'); } return $tab; @@ -859,28 +858,45 @@ public function showFormPluginFields($item) { $plugin = new Plugin(); if ($plugin->isActivated('fields')) { - $advancedOptions = false; + $separator = false; + + echo '

' . __('Plugin additionnal fields blocks', 'uninstall') . '

'; if ($item->fields["types_id"] != self::TYPE_MODEL_UNINSTALL) { if ($item->fields['action_plugin_fields_replace'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { - $advancedOptions = true; + $separator = true; PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_REPLACEMENT); + } else { + switch ($item->fields['action_plugin_fields_replace']) { + case self::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case self::PLUGIN_FIELDS_ACTION_COPY : + $action = __('Copy'); + break; + } + + echo "

". __('Action for ', 'uninstall') . __('Replacement', 'uninstall') . ' : ' . $action . "

"; } } + echo "
"; + if ($item->fields["types_id"] != self::TYPE_MODEL_REPLACEMENT) { if ($item->fields['action_plugin_fields_uninstall'] === self::PLUGIN_FIELDS_ACTION_ADVANCED) { - if ($advancedOptions) { - echo "
"; - } - $advancedOptions = true; PluginUninstallModelcontainer::showListsForType($item->getID(),self::TYPE_MODEL_UNINSTALL); - } - } + } else { + switch ($item->fields['action_plugin_fields_uninstall']) { + case self::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case self::PLUGIN_FIELDS_ACTION_RAZ : + $action = __('Blank'); + break; + } - if (!$advancedOptions) { - echo "" . __("Select 'Advanced options' for the field 'Fields plugin informations' to access this tab.") . ""; - return false; + echo "

". __('Action for ', 'uninstall') . __('Uninstallation', 'uninstall') . ' : ' . $action . "

"; + } } } else { echo "" . __("Activate the plugin 'fields' to access this tab.") . ""; @@ -1729,28 +1745,16 @@ public function createPluginFieldsRelations($modelId) $types = json_decode($container['itemtypes']); // only create matching elements for containers concerning item types used by the plugin if (!empty(array_intersect($types, $UNINSTALL_TYPES))) { - $newIdReplace = $uninstallContainer->add([ - 'plugin_uninstall_models_id' => $modelId, - 'plugin_fields_containers_id' => $container['id'], - 'model_type' => self::TYPE_MODEL_REPLACEMENT - ]); - $newIdUninstall = $uninstallContainer->add([ + $newId = $uninstallContainer->add([ 'plugin_uninstall_models_id' => $modelId, - 'plugin_fields_containers_id' => $container['id'], - 'model_type' => self::TYPE_MODEL_UNINSTALL + 'plugin_fields_containers_id' => $container['id'] ]); $fieldsFields = $fieldsField->find(['plugin_fields_containers_id' => $container['id']]); foreach($fieldsFields as $field) { $uninstallField->add([ 'plugin_fields_fields_id' => $field['id'], - 'plugin_uninstall_modelcontainers_id' => $newIdReplace, - 'action' => $uninstallField::ACTION_RAZ - ]); - $uninstallField->add([ - 'plugin_fields_fields_id' => $field['id'], - 'plugin_uninstall_modelcontainers_id' => $newIdUninstall, - 'action' => $uninstallField::ACTION_RAZ + 'plugin_uninstall_modelcontainers_id' => $newId ]); } } diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index f17e67b..f841bf7 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -55,16 +55,16 @@ public static function getTypeName($nb = 0) /** * Get the list of actions available for an instance, or all available actions - * @param $self PluginUninstallModelcontainer|null + * @param $type int|null * @return array value => label */ - public static function getActions($self = null) + public static function getActions($type = null) { - if ($self) { + if ($type) { $values = [ self::ACTION_NONE => __('Do nothing'), ]; - if ($self->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) { + if ($type == PluginUninstallModel::TYPE_MODEL_UNINSTALL) { $values[self::ACTION_RAZ] = __('Blank'); } else { $values[self::ACTION_COPY] = __('Copy'); @@ -110,7 +110,10 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) case __CLASS__: $tab = []; $tab[1] = self::getTypeName(1); - if ($item->fields['action'] == self::ACTION_CUSTOM) { + $model = new PluginUninstallModel(); + $model->getFromDB($item->fields['plugin_uninstall_models_id']); + if (($model->fields['types_id'] != $model::TYPE_MODEL_UNINSTALL && $item->fields['action_replace'] == self::ACTION_CUSTOM) || + ($model->fields['types_id'] != $model::TYPE_MODEL_REPLACEMENT && $item->fields['action_uninstall'] == self::ACTION_CUSTOM)) { $tab[2] = __('Fields'); } return $tab; @@ -152,11 +155,15 @@ public function showForm($ID, $options = []) $this->initForm($ID, $options); $this->showFormHeader($options); + $model = new PluginUninstallModel(); + $model->getFromDB($this->fields['plugin_uninstall_models_id']); + $pluginFieldsContainer = new PluginFieldsContainer(); if ($pluginFieldsContainer->getFromDB($this->fields['plugin_fields_containers_id'])) { - $model = new PluginUninstallModel(); - $model->getFromDB($this->fields['plugin_uninstall_models_id']); + // associated model name + echo "

" . __('Model') . ' : ' . $model->fields['name'] . "

"; echo "
"; + // associated plugin fields block informations echo ""; echo ""; @@ -187,32 +194,82 @@ public function showForm($ID, $options = []) echo ""; echo ""; + // actual form data + $titleColspan = 4; + $actionColspan = 3; + if ($model->fields['types_id'] == $model::TYPE_MODEL_REPLACEMENT_UNINSTALL) { + $titleColspan = 2; + $actionColspan = 1; + } + echo ""; - $actionTitle = ''; - if ($this->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) { - $actionTitle .= 'Uninstallation'; - } else { - $actionTitle .= 'Replacement'; + if ($model->fields['types_id'] != $model::TYPE_MODEL_UNINSTALL) { + echo ""; } - echo ""; + if ($model->fields['types_id'] != $model::TYPE_MODEL_REPLACEMENT) { + echo ""; + } + echo ""; echo ""; - echo ""; - echo ""; + if ($model->fields['types_id'] != $model::TYPE_MODEL_UNINSTALL) { + echo ""; + echo ""; + } + + if ($model->fields['types_id'] != $model::TYPE_MODEL_REPLACEMENT) { + echo ""; + echo ""; + } echo ""; + $this->showFormButtons($options); } @@ -230,23 +287,21 @@ public static function showListsForType($modelId, $type) 'Replacement', 'uninstall' ); - echo "

" . $typeTitle . ' - ' . __('Plugin additionnal fields blocks', 'uninstall') . - "

"; + echo "

" . $typeTitle . '

'; $self = new self(); $uninstallContainers = $self->find([ - 'plugin_uninstall_models_id' => $modelId, - 'model_type' => $type + 'plugin_uninstall_models_id' => $modelId ]); $fieldContainer = new PluginFieldsContainer(); if (count($uninstallContainers)) { echo "
" . __('Block informations', 'uninstall') . "
" . __('Action for ', 'uninstall') . __('Replacement', 'uninstall') . "" . __('Action for ', 'uninstall') . __($actionTitle, 'uninstall') . - "
" . __('Action for ', 'uninstall') . __('Uninstallation', 'uninstall') . "
" . __('Action') . " :"; - $rand = mt_rand(); - $defaultValue = $this->fields['model_type'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL ? $this::ACTION_RAZ : $this::ACTION_NONE; - Dropdown::showFromArray( - "action", - self::getActions($this), - [ - 'value' => (isset($this->fields["action"]) - ? $this->fields["action"] : $defaultValue), - 'width' => '100%', - 'rand' => $rand - ] - ); - echo "" . __('Action') . ""; + if ($model->fields['action_plugin_fields_replace'] == $model::PLUGIN_FIELDS_ACTION_ADVANCED) { + $rand = mt_rand(); + Dropdown::showFromArray( + "action_replace", + self::getActions($model::TYPE_MODEL_REPLACEMENT), + [ + 'value' => (isset($this->fields["action_replace"]) + ? $this->fields["action_replace"] : $this::ACTION_NONE), + 'width' => '100%', + 'rand' => $rand + ] + ); + } else { + switch ($model->fields['action_plugin_fields_replace']) { + case $model::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case $model::PLUGIN_FIELDS_ACTION_COPY : + $action = __('Copy'); + } + + echo "" . $action . " " . "(" . __('inherit from model', 'uninstall') . ")"; + } + echo "" . __('Action') . ""; + if ($model->fields['action_plugin_fields_uninstall'] == $model::PLUGIN_FIELDS_ACTION_ADVANCED) { + $rand = mt_rand(); + Dropdown::showFromArray( + "action_uninstall", + self::getActions($model::TYPE_MODEL_UNINSTALL), + [ + 'value' => (isset($this->fields["action_uninstall"]) + ? $this->fields["action_uninstall"] : $this::ACTION_NONE), + 'width' => '100%', + 'rand' => $rand + ] + ); + } else { + switch ($model->fields['action_plugin_fields_uninstall']) { + case $model::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case $model::PLUGIN_FIELDS_ACTION_RAZ : + $action = __('Blank'); + } + + echo "" . $action . " " . "(" . __('inherit from model', 'uninstall') . ")"; + } + echo "
"; echo ""; echo ""; - echo ""; echo ""; + echo ""; echo ""; echo ""; - + $actionProperty = $type === PluginUninstallModel::TYPE_MODEL_UNINSTALL ? 'action_uninstall' : 'action_replace'; foreach($uninstallContainers as $uninstallContainer) { if ($fieldContainer->getFromDB($uninstallContainer['plugin_fields_containers_id'])) { echo ""; @@ -254,6 +309,7 @@ public static function showListsForType($modelId, $type) echo ""; + echo ""; $types = json_decode($fieldContainer->fields['itemtypes']); $obj = ''; $count = count($types); @@ -270,7 +326,6 @@ public static function showListsForType($modelId, $type) $i++; } echo ""; - echo ""; echo ""; } } @@ -315,22 +370,110 @@ public static function getContainerForItemtypes($ids = []) { return $return; } + /** + * Display list + * @param $item + * @return void + */ public function showFields($item) { - if ($item->fields['action'] == self::ACTION_CUSTOM) { - echo "
" . __('Block', 'fields') . "" . __("Associated item type") . "" . __("Action") . "" . __("Associated item type") . "
"; echo "" . $fieldContainer->fields['label'] . ""; echo "" . self::getActions()[$uninstallContainer[$actionProperty]] . "" . $obj . "" . self::getActions()[$uninstallContainer['action']] . "
"; - echo ""; - echo "
" . __('Fields') . - "
"; - $parameters = [ - 'start' => 0, - 'is_deleted' => 0, - 'sort' => 1, - 'order' => 'DESC', - 'reset' => 'reset', - 'criteria' => [], - ]; - Search::showList(PluginUninstallModelcontainerfield::class, $parameters); + $model = new PluginUninstallModel(); + $model->getFromDB($item->fields['plugin_uninstall_models_id']); + + echo "

" . __('Plugin additionnal fields field', 'uninstall') . "

"; + + echo "

" . __('Model') . " : " . "" . $model->fields['name'] . "" . "

"; + + $actionFields = ['action_replace', 'action_uninstall']; + foreach ($actionFields as $field) { + if (($field === 'action_uninstall' && $model->fields['types_id'] != $model::TYPE_MODEL_REPLACEMENT) + || ($field === 'action_replace' && $model->fields['types_id'] != $model::TYPE_MODEL_UNINSTALL)) { + switch ($field) { + case 'action_uninstall': + $typeTitle = __('Uninstallation', 'uninstall'); + $modelProperty = 'action_plugin_fields_uninstall'; + break; + case 'action_replace' : + $typeTitle = __('Replacement', 'uninstall'); + $modelProperty = 'action_plugin_fields_replace'; + break; + } + $actionTitle = __('Action for ', 'uninstall') . $typeTitle . ' : '; + if ($model->fields[$modelProperty] != $model::PLUGIN_FIELDS_ACTION_ADVANCED) { + switch ($model->fields[$modelProperty]) { + case $model::PLUGIN_FIELDS_ACTION_NONE : + $action = __('Do nothing'); + break; + case $model::PLUGIN_FIELDS_ACTION_RAZ : + $action = __('Blank'); + break; + case $model::PLUGIN_FIELDS_ACTION_COPY : + $action = __('Copy'); + break; + } + + $actionTitle .= $action . " (" . __('set by model', 'uninstall') . ")
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $fieldsField = new PluginFieldsField(); + $types = $fieldsField->getTypes(true); + Toolbox::logInfo($fields); + foreach ($fields as $fieldData) { + Toolbox::logInfo($fieldData); + if ($fieldsField->getFromDB($fieldData['plugin_fields_fields_id'])) { + Toolbox::logInfo($fieldsField->getID()); + echo ""; + $link = PluginUninstallModelcontainerfield::getFormURLWithID($fieldData['id']); + echo ""; + echo ""; + echo ""; + echo ""; + } + } + echo ""; + echo "
" . __('Field') . "" . __("Action") . "" . __("Type") . "
"; + echo "" . $fieldsField->fields['label'] . ""; + echo ""; + switch ($fieldData[$field]) { + case $uninstallField::ACTION_NONE: + echo __('Do nothing'); + break; + case $uninstallField::ACTION_RAZ: + echo __('Blank'); + break; + case $uninstallField::ACTION_COPY: + echo __('Copy'); + break; + case $uninstallField::ACTION_NEW_VALUE: + echo __('Set value', 'uninstall'); + echo ' : "' . $fieldData['new_value'] . '"'; + break; + } + echo "" . $types[$fieldsField->fields['type']] . "
"; + } + } + } } } @@ -349,8 +492,8 @@ public static function install($migration) `id` int {$default_key_sign} NOT NULL AUTO_INCREMENT, `plugin_uninstall_models_id` int {$default_key_sign} DEFAULT '0', `plugin_fields_containers_id` tinyint NOT NULL DEFAULT '0', - `model_type` int DEFAULT '0', - `action` int NOT NULL DEFAULT " . self::ACTION_NONE . " , + `action_uninstall` int NOT NULL DEFAULT '0', + `action_replace` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;"; diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 5eefedb..79f9f9b 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -59,52 +59,6 @@ public function getName($options = []) return $field->fields['label']; } - public function rawSearchOptions() - { - $tab = []; - - $tab[] = [ - 'id' => '1', - 'table' => self::getTable(), - 'field' => 'id', - 'name' => __('ID'), - 'massiveaction' => false, - 'datatype' => 'itemlink' - ]; - - $tab[] = [ - 'id' => '2', - 'table' => PluginFieldsField::getTable(), - 'field' => 'label', - 'name' => __('Label'), - 'datatype' => 'text', - 'linkfield' => 'plugin_fields_fields_id', - ]; - - // temp solution to the fact that the plugin Fields does not provide the specific value display for type - $tab[] = [ - 'id' => 3, - 'table' => self::getTable(), - 'field' => 'plugin_fields_fields_id', - 'name' => __("Type"), - 'datatype' => 'specific', - 'massiveaction' => false, - 'nosearch' => true, - ]; - - $tab[] = [ - 'id' => 4, - 'table' => self::getTable(), - 'field' => 'action', - 'name' => __('Action'), - 'datatype' => 'specific', - 'massiveaction' => true, - 'nosearch' => true, - ]; - - return $tab; - } - public function showForm($ID, $options = []) { /** @var array $CFG_GLPI */ @@ -113,16 +67,36 @@ public function showForm($ID, $options = []) $this->initForm($ID, $options); $this->showFormHeader($options); + $uninstallContainer = new PluginUninstallModelcontainer(); + $uninstallContainer->getFromDB($this->fields['plugin_uninstall_modelcontainers_id']); + + $fieldsContainer = new PluginFieldsContainer(); + $fieldsContainer->getFromDB($uninstallContainer->fields['plugin_fields_containers_id']); + + $model = new PluginUninstallModel(); + $model->getFromDB($uninstallContainer->fields['plugin_uninstall_models_id']); + $pluginFieldsField = new PluginFieldsField(); - $pluginUninstallContainer = new PluginUninstallModelcontainer(); - $pluginUninstallContainer->getFromDB($this->fields['plugin_uninstall_modelcontainers_id']); - $pluginUninstallModel = new PluginUninstallModel(); - $pluginUninstallModel->getFromDB($pluginUninstallContainer->fields['plugin_uninstall_models_id']); if ($pluginFieldsField->getFromDB($this->fields['plugin_fields_fields_id'])) { + // context echo "
" . __('Field informations', 'uninstall') . + echo "" . __('Parents', 'uninstall') . "
" . __('Model') . " : "; + echo "" . $model->fields['name'] . ""; + echo "" . __('Bloc') . " : "; + echo "" . $fieldsContainer->fields['name'] . ""; + echo "
" . __('Field informations', 'uninstall') . + "
" . __("Label") . " : "; echo $pluginFieldsField->fields['label']; @@ -144,71 +118,111 @@ public function showForm($ID, $options = []) echo "
" . __('Action for ', 'uninstall') . __($actionTitle, 'uninstall') . - "
" . __('Action') . " :"; - $rand = mt_rand(); - $options = [ - self::ACTION_NONE => __('Do nothing'), - ]; - if ($pluginUninstallContainer->fields['model_type'] == $pluginUninstallModel::TYPE_MODEL_UNINSTALL) { - $options[self::ACTION_RAZ] = __('Blank'); - if ($pluginFieldsField->fields['type'] !== 'glpi_item') { - $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); - } - } else { - $options[self::ACTION_COPY] = __('Copy'); - } + $actionFields = ['action_replace', 'action_uninstall']; + foreach($actionFields as $field) { + // model can use the property + if (($field === 'action_uninstall' && $model->fields['types_id'] != $model::TYPE_MODEL_REPLACEMENT) + || ($field === 'action_replace' && $model->fields['types_id'] != $model::TYPE_MODEL_UNINSTALL)) { + switch($field) { + case 'action_uninstall': + $typeTitle = __('Uninstallation', 'uninstall'); + $modelProperty = 'action_plugin_fields_uninstall'; + break; + case 'action_replace' : + $typeTitle = __('Replacement', 'uninstall'); + $modelProperty = 'action_plugin_fields_replace'; + break; + } + + echo "" . __('Action for ', 'uninstall') . $typeTitle . + "
" . __('Action') . " :"; + $rand = mt_rand(); + $options = [ + self::ACTION_NONE => __('Do nothing'), + ]; + if ($field == 'action_uninstall') { + $options[self::ACTION_RAZ] = __('Blank'); + if ($pluginFieldsField->fields['type'] !== 'glpi_item') { + $options[self::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); + } + } else { + $options[self::ACTION_COPY] = __('Copy'); + } - Dropdown::showFromArray( - "action", - $options, - [ - 'value' => (isset($this->fields["action"]) - ? $this->fields["action"] : self::ACTION_NONE), - 'width' => '100%', - 'rand' => $rand - ] - ); - echo ""; - if ($pluginFieldsField->fields['type'] === 'glpi_item') { - echo __('Action set value is not available for this field type', 'uninstall'); - } - echo "
" . $uninstallContainer::getActions()[$uninstallContainer->fields[$field]] . " (". __('set by bloc', 'uninstall') .")" . $action . " (" . __('set by model', 'uninstall') . ")
"; From a071d5efd1f981634a3897ce08672fc3cd046516 Mon Sep 17 00:00:00 2001 From: ArthurMinfotel Date: Thu, 12 Sep 2024 11:40:36 +0200 Subject: [PATCH 49/54] allow for modelcontainerfields update to be done through ajax from modelcontainer --- ajax/fieldValueInput.php | 13 +++- ajax/saveField.php | 46 +++++++++++ inc/modelcontainer.class.php | 122 +++++++++++++++++++++++++----- inc/modelcontainerfield.class.php | 8 +- 4 files changed, 164 insertions(+), 25 deletions(-) create mode 100644 ajax/saveField.php diff --git a/ajax/fieldValueInput.php b/ajax/fieldValueInput.php index 38400c6..6a2a6e2 100644 --- a/ajax/fieldValueInput.php +++ b/ajax/fieldValueInput.php @@ -33,7 +33,6 @@ Html::header_nocache(); Session::checkLoginUser(); - switch ($_POST['action']) { case PluginUninstallModelcontainerfield::ACTION_NONE: case PluginUninstallModelcontainerfield::ACTION_RAZ: @@ -42,6 +41,11 @@ case PluginUninstallModelcontainerfield::ACTION_NEW_VALUE: if (isset($_POST['id']) && $_POST['id']) { + $rand = mt_rand(); + if (isset($_POST['rand']) && $_POST['rand']) { + $rand = $_POST['rand']; + } + $pluginUninstallField = new PluginUninstallModelcontainerfield(); $pluginUninstallField->getFromDB($_POST['id']); @@ -101,6 +105,7 @@ function ($itemtype) { 'value' => $default_value, 'entity_restrict' => -1, 'multiple' => $multiple, + 'rand' => $rand ] ); @@ -114,13 +119,17 @@ function ($itemtype) { } Dropdown::showYesNo( 'new_value', - $value + $value, + -1, + ['rand' => $rand] ); } else { + $id = 'new_value' . $rand; echo Html::input( 'new_value', [ 'value' => $pluginUninstallField->fields['new_value'] ?? $pluginFieldsField->fields['default_value'], + 'id' => $id ] ); } diff --git a/ajax/saveField.php b/ajax/saveField.php new file mode 100644 index 0000000..6ad4678 --- /dev/null +++ b/ajax/saveField.php @@ -0,0 +1,46 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Teclib'. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/uninstall + * ------------------------------------------------------------------------- + */ + +include('../../../inc/includes.php'); +header("Content-Type: text/html; charset=UTF-8"); +Html::header_nocache(); + +Session::checkLoginUser(); + +if (isset($_POST['id']) && $_POST['id']) { + $field = new PluginUninstallModelcontainerfield(); + $field->check($_POST['id'], UPDATE); + if (!$field->update($_POST)) { + Session::addMessageAfterRedirect(__('Field updated', 'uninstall')); + } else { + Session::addMessageAfterRedirect(__('An error has occured'), ERROR); + } + echo ""; +} diff --git a/inc/modelcontainer.class.php b/inc/modelcontainer.class.php index aa4c112..df8728c 100644 --- a/inc/modelcontainer.class.php +++ b/inc/modelcontainer.class.php @@ -431,38 +431,122 @@ public function showFields($item) echo ""; echo ""; echo ""; - echo ""; echo ""; + echo ""; + echo ""; echo ""; echo ""; $fieldsField = new PluginFieldsField(); $types = $fieldsField->getTypes(true); foreach ($fields as $fieldData) { - if ($fieldsField->getFromDB($fieldData['plugin_fields_fields_id'])) { + if ($fieldsField->getFromDB($fieldData['plugin_fields_fields_id']) + && $uninstallField->getFromDB($fieldData['id'])) { echo ""; $link = PluginUninstallModelcontainerfield::getFormURLWithID($fieldData['id']); echo ""; - echo ""; echo ""; + echo ""; + echo ""; echo ""; } } diff --git a/inc/modelcontainerfield.class.php b/inc/modelcontainerfield.class.php index 79f9f9b..4bb1cda 100644 --- a/inc/modelcontainerfield.class.php +++ b/inc/modelcontainerfield.class.php @@ -170,8 +170,8 @@ public function showForm($ID, $options = []) echo ""; // for uninstall, show the part that allow for a new value to be set if ($field == 'action_uninstall') { - echo ""; - echo ""; + echo "
" . __('Field') . "" . __("Action") . "" . __("Type") . "" . __("Action") . "
"; echo "" . $fieldsField->fields['label'] . ""; echo ""; - switch ($fieldData[$field]) { - case $uninstallField::ACTION_NONE: - echo __('Do nothing'); - break; - case $uninstallField::ACTION_RAZ: - echo __('Blank'); - break; - case $uninstallField::ACTION_COPY: - echo __('Copy'); - break; - case $uninstallField::ACTION_NEW_VALUE: - echo __('Set value', 'uninstall'); - echo ' : "' . $fieldData['new_value'] . '"'; - break; - } - echo "" . $types[$fieldsField->fields['type']] . "
"; + $options = [ + $uninstallField::ACTION_NONE => __('Do nothing'), + ]; + if ($field == 'action_uninstall') { + $options[$uninstallField::ACTION_RAZ] = __('Blank'); + if ($fieldsField->fields['type'] !== 'glpi_item') { + $options[$uninstallField::ACTION_NEW_VALUE] = __('Set value', 'uninstall'); + } + } else { + $options[$uninstallField::ACTION_COPY] = __('Copy'); + } + $rand = mt_rand(); + echo "
"; + Dropdown::showFromArray( + $field, + $options, + [ + 'value' => (isset($uninstallField->fields[$field]) + ? $uninstallField->fields[$field] : $uninstallField::ACTION_NONE), + 'width' => '100%', + 'rand' => $rand + ] + ); + echo "
"; + $id = $uninstallField->getID(); + if ($field == 'action_uninstall') { + echo "
"; + echo "
"; + if ($fieldsField->fields['type'] === 'glpi_item') { + echo __('Action set value is not available for this field type', 'uninstall'); + } + echo "
"; + echo "
"; + $url = Plugin::getWebDir('uninstall') . "/ajax/fieldValueInput.php"; + echo " + + "; + } + echo "
"; + echo "
"; + echo "
"; + $saveUrl = Plugin::getWebDir('uninstall') . "/ajax/saveField.php"; + echo " + + "; + echo "
"; + echo ""; if ($pluginFieldsField->fields['type'] === 'glpi_item') { echo __('Action set value is not available for this field type', 'uninstall'); } @@ -182,8 +182,8 @@ public function showForm($ID, $options = [])