Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ The present file will list all changes made to the project; according to the
- Handling of encoded/escaped value in `autoName()`.
- `closeDBConnections`
- `regenerateTreeCompleteName()`
- `AbstractITILChildTemplate::addVisibilityJoins()`
- `Appliance::getMassiveActionsForItemtype()`
- `AuthLDAP::ldapChooseDirectory()`
- `AuthLDAP::displayLdapFilter()`
Expand Down
50 changes: 27 additions & 23 deletions ajax/visibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

if (
isset($_POST['type']) && !empty($_POST['type'])
&& isset($_POST['right'])
) {
$display = false;
$rand = mt_rand();
Expand All @@ -62,9 +61,16 @@
switch ($_POST['type']) {
case 'User':
$params = [
'right' => isset($_POST['allusers']) ? 'all' : $_POST['right'],
'right' => 'all',
'name' => $prefix . 'users_id' . $suffix,
];
if (isset($_POST['right']) && !isset($_POST['allusers'])) {
$params['right'] = $_POST['right'];
}
if (isset($_POST['entity']) && $_POST['entity'] >= 0) {
$params['entity'] = $_POST['entity'];
$params['entity_sons'] = $_POST['is_recursive'] ?? false;
}
User::dropdown($params);
$display = true;
break;
Expand All @@ -82,7 +88,6 @@
'prefix' => $_POST['prefix'],
],
];

Group::dropdown($params);
echo "<span id='subvisibility$rand'></span>";
$display = true;
Expand All @@ -101,27 +106,26 @@
break;

case 'Profile':
$checkright = (READ | CREATE | UPDATE | PURGE);
$righttocheck = $_POST['right'];
if ($_POST['right'] == 'faq') {
$righttocheck = 'knowbase';
$checkright = KnowbaseItem::READFAQ;
$righttocheck = $_POST['right'] ?? null;
if ($righttocheck) {
$checkright = (READ | CREATE | UPDATE | PURGE);
if ($_POST['right'] == 'faq') {
$righttocheck = 'knowbase';
$checkright = KnowbaseItem::READFAQ;
}
$params['condition'] = [
'glpi_profilerights.name' => $righttocheck,
'glpi_profilerights.rights' => ['&', $checkright],
];
}
$params = [
'rand' => $rand,
'name' => $prefix . 'profiles_id' . $suffix,
'condition' => [
'glpi_profilerights.name' => $righttocheck,
'glpi_profilerights.rights' => ['&', $checkright],
],
];
$params['toupdate'] = ['value_fieldname'
=> 'value',
'to_update' => "subvisibility$rand",
'url' => $CFG_GLPI["root_doc"] . "/ajax/subvisibility.php",
'moreparams' => ['items_id' => '__VALUE__',
'type' => $_POST['type'],
'prefix' => $_POST['prefix'],
$params['toupdate'] = [
'value_fieldname' => 'value',
'to_update' => "subvisibility$rand",
'url' => $CFG_GLPI["root_doc"] . "/ajax/subvisibility.php",
'moreparams' => [
'items_id' => '__VALUE__',
'type' => $_POST['type'],
'prefix' => $_POST['prefix'],
],
];

Expand Down
39 changes: 39 additions & 0 deletions inc/relation.constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,26 @@
'glpi_enclosures' => 'entities_id',
'_glpi_entities' => 'entities_id',
'glpi_entities' => 'entities_id_software',
'_glpi_entities_itilfollowuptemplates' => 'entities_id',
'_glpi_entities_itilvalidationtemplates' => 'entities_id',
'_glpi_entities_knowbaseitems' => 'entities_id',
'_glpi_entities_reminders' => 'entities_id',
'_glpi_entities_rssfeeds' => 'entities_id',
'_glpi_entities_solutiontemplates' => 'entities_id',
'_glpi_entities_tasktemplates' => 'entities_id',
'glpi_fieldblacklists' => 'entities_id',
'glpi_fieldunicities' => 'entities_id',
'glpi_forms_forms' => 'entities_id',
'glpi_forms_answerssets' => 'entities_id',
'glpi_fqdns' => 'entities_id',
'glpi_groups' => 'entities_id',
'glpi_groups_itilfollowuptemplates' => 'entities_id',
'glpi_groups_itilvalidationtemplates' => 'entities_id',
'glpi_groups_knowbaseitems' => 'entities_id',
'glpi_groups_reminders' => 'entities_id',
'glpi_groups_rssfeeds' => 'entities_id',
'glpi_groups_solutiontemplates' => 'entities_id',
'glpi_groups_tasktemplates' => 'entities_id',
'glpi_holidays' => 'entities_id',
'glpi_imageformats' => 'entities_id',
'glpi_imageresolutions' => 'entities_id',
Expand Down Expand Up @@ -657,8 +665,12 @@
'_glpi_problemcosts' => 'entities_id',
'glpi_problems' => 'entities_id',
'glpi_problemtemplates' => 'entities_id',
'glpi_profiles_itilfollowuptemplates' => 'entities_id',
'glpi_profiles_itilvalidationtemplates' => 'entities_id',
'glpi_profiles_reminders' => 'entities_id',
'glpi_profiles_rssfeeds' => 'entities_id',
'glpi_profiles_solutiontemplates' => 'entities_id',
'glpi_profiles_tasktemplates' => 'entities_id',
'_glpi_profiles_users' => 'entities_id',
'_glpi_projectcosts' => 'entities_id',
'glpi_projects' => 'entities_id',
Expand Down Expand Up @@ -736,10 +748,14 @@
'glpi_changetasks' => 'groups_id_tech',
'glpi_groups' => 'groups_id',
'_glpi_groups_items' => 'groups_id',
'_glpi_groups_itilfollowuptemplates' => 'groups_id',
'_glpi_groups_itilvalidationtemplates' => 'groups_id',
'_glpi_groups_knowbaseitems' => 'groups_id',
'_glpi_groups_problems' => 'groups_id',
'_glpi_groups_reminders' => 'groups_id',
'_glpi_groups_rssfeeds' => 'groups_id',
'_glpi_groups_solutiontemplates' => 'groups_id',
'_glpi_groups_tasktemplates' => 'groups_id',
'_glpi_groups_tickets' => 'groups_id',
'_glpi_groups_users' => 'groups_id',
'glpi_itilcategories' => 'groups_id',
Expand Down Expand Up @@ -810,10 +826,18 @@

'glpi_itilfollowuptemplates' => [
'glpi_pendingreasons' => 'itilfollowuptemplates_id',
'_glpi_entities_itilfollowuptemplates' => 'itilfollowuptemplates_id',
'_glpi_groups_itilfollowuptemplates' => 'itilfollowuptemplates_id',
'_glpi_itilfollowuptemplates_users' => 'itilfollowuptemplates_id',
'_glpi_profiles_itilfollowuptemplates' => 'itilfollowuptemplates_id',
],

'glpi_itilvalidationtemplates' => [
'_glpi_itilvalidationtemplates_targets' => 'itilvalidationtemplates_id',
'_glpi_entities_itilvalidationtemplates' => 'itilvalidationtemplates_id',
'_glpi_groups_itilvalidationtemplates' => 'itilvalidationtemplates_id',
'_glpi_itilvalidationtemplates_users' => 'itilvalidationtemplates_id',
'_glpi_profiles_itilvalidationtemplates' => 'itilvalidationtemplates_id',
'glpi_changevalidations' => 'itilvalidationtemplates_id',
'glpi_ticketvalidations' => 'itilvalidationtemplates_id',
],
Expand Down Expand Up @@ -1182,8 +1206,12 @@
'glpi_profiles' => [
'_glpi_knowbaseitems_profiles' => 'profiles_id',
'_glpi_profilerights' => 'profiles_id',
'_glpi_profiles_itilfollowuptemplates' => 'profiles_id',
'_glpi_profiles_itilvalidationtemplates' => 'profiles_id',
'_glpi_profiles_reminders' => 'profiles_id',
'_glpi_profiles_rssfeeds' => 'profiles_id',
'_glpi_profiles_solutiontemplates' => 'profiles_id',
'_glpi_profiles_tasktemplates' => 'profiles_id',
'_glpi_profiles_users' => 'profiles_id',
'glpi_users' => 'profiles_id',
],
Expand Down Expand Up @@ -1352,6 +1380,10 @@

'glpi_solutiontemplates' => [
'glpi_pendingreasons' => 'solutiontemplates_id',
'_glpi_entities_solutiontemplates' => 'solutiontemplates_id',
'_glpi_groups_solutiontemplates' => 'solutiontemplates_id',
'_glpi_profiles_solutiontemplates' => 'solutiontemplates_id',
'_glpi_solutiontemplates_users' => 'solutiontemplates_id',
],

'glpi_solutiontypes' => [
Expand Down Expand Up @@ -1427,6 +1459,10 @@
'glpi_changetasks' => 'tasktemplates_id',
'glpi_problemtasks' => 'tasktemplates_id',
'glpi_tickettasks' => 'tasktemplates_id',
'_glpi_entities_tasktemplates' => 'tasktemplates_id',
'_glpi_groups_tasktemplates' => 'tasktemplates_id',
'_glpi_profiles_tasktemplates' => 'tasktemplates_id',
'_glpi_tasktemplates_users' => 'tasktemplates_id',
],

'glpi_ticketrecurrents' => [
Expand Down Expand Up @@ -1556,6 +1592,7 @@
'users_id_tech',
'users_id',
],
'_glpi_itilfollowuptemplates_users' => 'users_id',
'_glpi_items_kanbans' => 'users_id',
'glpi_itilcategories' => 'users_id',
'glpi_itilfollowups' => [
Expand Down Expand Up @@ -1646,11 +1683,13 @@
'users_id_tech',
'users_id',
],
'_glpi_solutiontemplates_users' => 'users_id',
'glpi_tasktemplates' => 'users_id_tech',
'glpi_tickets' => [
'users_id_recipient',
'users_id_lastupdater',
],
'_glpi_tasktemplates_users' => 'users_id',
'_glpi_tickets_users' => 'users_id',
'glpi_tickettasks' => [
'users_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,88 @@
* ---------------------------------------------------------------------
*/

use Glpi\DBAL\QuerySubQuery;
use Glpi\DBAL\QueryExpression;

/**
* @var \DBmysql $DB
* @var \Migration $migration
*/

// Add pendingreasons_id field
$migration->addField("glpi_itilfollowuptemplates", "pendingreasons_id", "fkey");
$migration->addKey("glpi_itilfollowuptemplates", "pendingreasons_id");

$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();

if (!$DB->tableExists('glpi_entities_itilfollowuptemplates')) {
$query = "CREATE TABLE `glpi_entities_itilfollowuptemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilfollowuptemplates_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NOT NULL DEFAULT '0',
`is_recursive` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilfollowuptemplates_id` (`itilfollowuptemplates_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

$DB->insert('glpi_entities_itilfollowuptemplates', new QuerySubQuery([
'SELECT' => [
new QueryExpression('null AS `id`'),
'id as itilfollowuptemplates_id',
'entities_id',
'is_recursive',
],
'FROM' => 'glpi_itilfollowuptemplates',
]));

if (!$DB->tableExists('glpi_itilfollowuptemplates_users')) {
$query = "CREATE TABLE `glpi_itilfollowuptemplates_users` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilfollowuptemplates_id` int unsigned NOT NULL DEFAULT '0',
`users_id` int unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilfollowuptemplates_id` (`itilfollowuptemplates_id`),
KEY `users_id` (`users_id`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

if (!$DB->tableExists('glpi_groups_itilfollowuptemplates')) {
$query = "CREATE TABLE `glpi_groups_itilfollowuptemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilfollowuptemplates_id` int unsigned NOT NULL DEFAULT '0',
`groups_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NULL,
`is_recursive` tinyint NOT NULL DEFAULT '0',
`no_entity_restriction` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilfollowuptemplates_id` (`itilfollowuptemplates_id`),
KEY `groups_id` (`groups_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

if (!$DB->tableExists('glpi_profiles_itilfollowuptemplates')) {
$query = "CREATE TABLE `glpi_profiles_itilfollowuptemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilfollowuptemplates_id` int unsigned NOT NULL DEFAULT '0',
`profiles_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NULL,
`is_recursive` tinyint NOT NULL DEFAULT '0',
`no_entity_restriction` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilfollowuptemplates_id` (`itilfollowuptemplates_id`),
KEY `profiles_id` (`profiles_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,63 @@
}

$migration->addRight('itilvalidationtemplate', ALLSTANDARDRIGHT, ['dropdown' => UPDATE]);

if (!$DB->tableExists('glpi_entities_itilvalidationtemplates')) {
$query = "CREATE TABLE `glpi_entities_itilvalidationtemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilvalidationtemplates_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NOT NULL DEFAULT '0',
`is_recursive` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilvalidationtemplates_id` (`itilvalidationtemplates_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

if (!$DB->tableExists('glpi_itilvalidationtemplates_users')) {
$query = "CREATE TABLE `glpi_itilvalidationtemplates_users` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilvalidationtemplates_id` int unsigned NOT NULL DEFAULT '0',
`users_id` int unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilvalidationtemplates_id` (`itilvalidationtemplates_id`),
KEY `users_id` (`users_id`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

if (!$DB->tableExists('glpi_groups_itilvalidationtemplates')) {
$query = "CREATE TABLE `glpi_groups_itilvalidationtemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilvalidationtemplates_id` int unsigned NOT NULL DEFAULT '0',
`groups_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NULL,
`is_recursive` tinyint NOT NULL DEFAULT '0',
`no_entity_restriction` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilvalidationtemplates_id` (`itilvalidationtemplates_id`),
KEY `groups_id` (`groups_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}

if (!$DB->tableExists('glpi_profiles_itilvalidationtemplates')) {
$query = "CREATE TABLE `glpi_profiles_itilvalidationtemplates` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itilvalidationtemplates_id` int unsigned NOT NULL DEFAULT '0',
`profiles_id` int unsigned NOT NULL DEFAULT '0',
`entities_id` int unsigned NULL,
`is_recursive` tinyint NOT NULL DEFAULT '0',
`no_entity_restriction` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `itilvalidationtemplates_id` (`itilvalidationtemplates_id`),
KEY `profiles_id` (`profiles_id`),
KEY `entities_id` (`entities_id`),
KEY `is_recursive` (`is_recursive`)
) ENGINE = InnoDB ROW_FORMAT = DYNAMIC DEFAULT CHARSET = {$default_charset} COLLATE = {$default_collation};";
$DB->doQuery($query);
}
Loading
Loading