diff --git a/inc/config.class.php b/inc/config.class.php index d366eae..87c54c0 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -113,6 +113,7 @@ static function install(Migration $mig) { `is_tickettasktodo` tinyint NOT NULL default '0', `is_problemtasktodo` tinyint NOT NULL default '0', `is_changetasktodo` tinyint NOT NULL default '0', + `show_child_groups_items` tinyint NOT NULL default '0', `date_mod` timestamp NULL DEFAULT NULL, `comment` text, PRIMARY KEY (`id`) @@ -222,6 +223,10 @@ static function install(Migration $mig) { //version 2.7.0 $mig->changeField($table, 'date_mod', 'date_mod', "timestamp NULL DEFAULT NULL"); + + //version ? + $mig->addField($table, 'show_child_groups_items', 'bool', ['after' => 'is_changetasktodo']); + } } @@ -314,7 +319,7 @@ static function showConfigForm($item) { Dropdown::showYesNo("is_ticketrealtime_mandatory", $config->fields['is_ticketrealtime_mandatory']); echo "".__('Update of a problem'); - echo ""; + echo ""; echo ""; echo "".__('Category is mandatory before ticket is solved/closed', 'behaviors').""; @@ -381,7 +386,7 @@ static function showConfigForm($item) { echo "".__("Use the technician's group", "behaviors").""; Dropdown::showFromArray('use_assign_user_group_update', $yesnoall, ['value' => $config->fields['use_assign_user_group_update']]); - echo "".__('Comments'); + echo "".__('General'); echo "\n"; echo ""; @@ -389,23 +394,32 @@ static function showConfigForm($item) { echo ""; Dropdown::showYesNo("is_ticketlocation_mandatory", $config->fields['is_ticketlocation_mandatory']); - echo ""; - Html::textarea(['name' => 'comment', - 'value' => $config->fields['comment'], - 'cols' => '60', - 'rows' => '12', - 'enable_ricktext' => false]); - echo ""; + echo ""; + + echo "".__('Show Items of child Groups', 'behaviors'); + echo ""; + Dropdown::showYesNo("show_child_groups_items", + $config->fields['show_child_groups_items']); + echo ""; echo ""; echo "".__('Task category is mandatory in a task', 'behaviors').""; Dropdown::showYesNo("is_tickettaskcategory_mandatory", $config->fields['is_tickettaskcategory_mandatory']); - echo ""; + echo "".__('Comments'); + echo "\n"; echo ""; echo "".__("Deny change of ticket's creation date", "behaviors").""; - Dropdown::showYesNo("is_ticketdate_locked", $config->fields['is_ticketdate_locked']); + Dropdown::showYesNo("is_ticketdate_locked", $config->fields['is_ticketdate_locked']); + echo ""; + + echo ""; + Html::textarea(['name' => 'comment', + 'value' => $config->fields['comment'], + 'cols' => '60', + 'rows' => '12', + 'enable_ricktext' => false]); echo ""; echo ""; diff --git a/inc/session.class.php b/inc/session.class.php new file mode 100644 index 0000000..96f6da6 --- /dev/null +++ b/inc/session.class.php @@ -0,0 +1,87 @@ +. + + @package behaviors + @author Remi Collet, Nelly Mahu-Lasson, Riccardo Bicelli + @copyright Copyright (c) 2010-2022 Behaviors plugin team + @license AGPL License 3.0 or (at your option) any later version + http://www.gnu.org/licenses/agpl-3.0-standalone.html + @link https://forge.glpi-project.org/projects/behaviors + @link http://www.glpi-project.org/ + @since version 0.83.4 + + -------------------------------------------------------------------------- +*/ + +use Group; + +class PluginBehaviorsSession extends PluginBehaviorsCommon { + + + static function LoadChildGroups() { + + $config = PluginBehaviorsConfig::getInstance(); + + if (($config->getField('show_child_groups_items') > 0)) { + + foreach ( $_SESSION["glpigroups"] as $glpi_group ) { + + self::LoadGroupsRecursive($glpi_group); + + } + + } + } + + /** + * Iterate through direct assigned groups and adds child groups + * to session variable, in order to let the search and permissions + * work with parent groups + * @param mixed $group_id + * @return void + */ + static function LoadGroupsRecursive($group_id){ + + /** @var \DBmysql $DB */ + global $DB; + + $iterator = $DB->request([ + 'SELECT' => Group::getTable() . '.id', + 'FROM' => Group::getTable(), + 'WHERE' => [ + Group::getTable() . '.groups_id' => $group_id + ] + getEntitiesRestrictCriteria( + Group::getTable(), + 'entities_id', + $_SESSION['glpiactiveentities'], + true + ) + ]); + + foreach ($iterator as $data) { + + $_SESSION["glpigroups"][] = $data["id"]; + self::LoadGroupsRecursive($data["id"]); + + } + + } +} diff --git a/locales/it_IT.po b/locales/it_IT.po index 55e59bb..b8e5854 100644 --- a/locales/it_IT.po +++ b/locales/it_IT.po @@ -149,7 +149,7 @@ msgstr "La categoria dell'attività è obbligatoria" #: inc/config.class.php:373 msgid "Deny change of ticket's creation date" -msgstr "Nega la possibilitù di cambiare la data di creazione della chiamata" +msgstr "Nega la possibilità di cambiare la data di creazione della chiamata" #: inc/config.class.php:378 msgid "Protect from simultaneous update" @@ -235,3 +235,11 @@ msgstr "Impossibile salvare, l'elemento è stato aggiornato" #: inc/tickettask.class.php:96 msgid "You cannot change status of a task in a solved ticket" msgstr "Non è possibile modificare lo stato di un'attività in una chiamata risolta" + +#: config.class.php:389 +msgid "General" +msgstr "Generale" + +#: config.class.php:399 +msgid "Show Items of child Group" +msgstr "Mostra gli elementi dei Gruppi Figlio" diff --git a/setup.php b/setup.php index cc7bde2..71efe7c 100644 --- a/setup.php +++ b/setup.php @@ -97,6 +97,7 @@ function plugin_init_behaviors() { $PLUGIN_HOOKS['add_default_where']['behaviors'] = ['PluginBehaviorsConfig', 'add_default_where']; + $PLUGIN_HOOKS['change_entity']['behaviors'] = ['PluginBehaviorsSession', 'LoadChildGroups']; }