Skip to content

Commit

Permalink
Merge branch 'release/1.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 4, 2018
2 parents 1572020 + b4c0273 commit 81f848e
Show file tree
Hide file tree
Showing 31 changed files with 394 additions and 345 deletions.
146 changes: 73 additions & 73 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static function install(Migration $migration, $version) {
`is_active` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `entities_id` (`entities_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die ($DB->error());
}

Expand Down Expand Up @@ -694,66 +694,47 @@ static function getItemtypes($is_domtab) {

$tabs = [];

$assets = ['Computer' => Computer::getTypeName(2)];
if (!$is_domtab) {
$assets += [
'Monitor' => Monitor::getTypeName(2),
'Software' => Software::getTypeName(2),
'NetworkEquipment' => NetworkEquipment::getTypeName(2),
'Peripheral' => Peripheral::getTypeName(2),
'Printer' => Printer::getTypeName(2),
'CartridgeItem' => CartridgeItem::getTypeName(2),
'ConsumableItem' => ConsumableItem::getTypeName(2),
'Phone' => Phone::getTypeName(2)
];
}
$tabs[__('Assets')] = $assets;
$tabs[__('Assets')] = [
'Computer' => Computer::getTypeName(2),
'Monitor' => Monitor::getTypeName(2),
'Software' => Software::getTypeName(2),
'NetworkEquipment' => NetworkEquipment::getTypeName(2),
'Peripheral' => Peripheral::getTypeName(2),
'Printer' => Printer::getTypeName(2),
'CartridgeItem' => CartridgeItem::getTypeName(2),
'ConsumableItem' => ConsumableItem::getTypeName(2),
'Phone' => Phone::getTypeName(2)
];

$assistance = [
'Ticket' => Ticket::getTypeName(2),
'Problem' => Problem::getTypeName(2),
'Change' => Change::getTypeName(2),
$tabs[__('Assistance')] = [
'Ticket' => Ticket::getTypeName(2),
'Problem' => Problem::getTypeName(2),
'Change' => Change::getTypeName(2),
'TicketRecurrent' => TicketRecurrent::getTypeName(2),
];
if (!$is_domtab) {
$assistance += [
'TicketRecurrent' => TicketRecurrent::getTypeName(2)
];
}
$tabs[__('Assistance')] = $assistance;

if (!$is_domtab) {
$tabs += [
__("Management") => [
'SoftwareLicense' => SoftwareLicense::getTypeName(2),
'Budget' => Budget::getTypeName(2),
'Supplier' => Supplier::getTypeName(2),
'Contact' => Contact::getTypeName(2),
'Contract' => Contract::getTypeName(2),
'Document' => Document::getTypeName(2)
],
__("Tools") => [
'Project' => Project::getTypeName(2),
'ProjectTask' => ProjectTask::getTypeName(2),
'Reminder' => Reminder::getTypeName(2),
'RSSFeed' => RSSFeed::getTypeName(2),
]
];
}

$administration = [];
if (!$is_domtab) {
$administration += [
'User' => User::getTypeName(2),
'Group' => Group::getTypeName(2)
];
}
$administration['Entity'] = Entity::getTypeName(2);
if (!$is_domtab) {
$administration += [
'Profile' => Profile::getTypeName(2)
];
}
$tabs[__('Administration')] = $administration;
$tabs[__('Management')] = [
'SoftwareLicense' => SoftwareLicense::getTypeName(2),
'Budget' => Budget::getTypeName(2),
'Supplier' => Supplier::getTypeName(2),
'Contact' => Contact::getTypeName(2),
'Contract' => Contract::getTypeName(2),
'Document' => Document::getTypeName(2)
];

$tabs[__('Tools')] = [
'Project' => Project::getTypeName(2),
'ProjectTask' => ProjectTask::getTypeName(2),
'Reminder' => Reminder::getTypeName(2),
'RSSFeed' => RSSFeed::getTypeName(2),
];

$tabs[__('Administration')] = [
'User' => User::getTypeName(2),
'Group' => Group::getTypeName(2),
'Entity' => Entity::getTypeName(2),
'Profile' => Profile::getTypeName(2)
];

foreach ($PLUGIN_HOOKS['plugin_fields'] as $itemtype) {
$isPlugin = isPluginItemType($itemtype);
Expand All @@ -764,20 +745,39 @@ static function getItemtypes($is_domtab) {
}
}

if (!$is_domtab) {
$dropdowns = [];
// flatten dropdows
$raw_dropdowns = Dropdown::getStandardDropdownItemTypes();
array_walk_recursive($raw_dropdowns, function($val, $key) use (&$dropdowns) {
$dropdowns[$key] = $val;
});
$tabs[__('Dropdowns')] = $dropdowns;

$tabs[__('Other')] = [
'NetworkPort' => NetworkPort::getTypeName(2),
'Notification' => Notification::getTypeName(2),
'NotificationTemplate' => NotificationTemplate::getTypeName(2),
];
$dropdowns = [];
// flatten dropdows
$raw_dropdowns = Dropdown::getStandardDropdownItemTypes();
array_walk_recursive($raw_dropdowns, function($val, $key) use (&$dropdowns) {
$dropdowns[$key] = $val;
});
$tabs[__('Dropdowns')] = $dropdowns;

$tabs[__('Other')] = [
'NetworkPort' => NetworkPort::getTypeName(2),
'Notification' => Notification::getTypeName(2),
'NotificationTemplate' => NotificationTemplate::getTypeName(2),
];

if ($is_domtab) {
// Filter items that do not have tab handled
foreach ($tabs as $group => $items) {
$tabs[$group] = array_filter(
$items,
function ($item) {
return count(self::getSubtypes($item)) > 0;
},
ARRAY_FILTER_USE_KEY
);
}

// Filter groupts that do not have items handled
$tabs = array_filter(
$tabs,
function ($items) {
return count($items) > 0;
}
);
}

return $tabs;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ private static function getSubtypes($item) {
];
break;
default:
Toolbox::logDebug('Item type ' . $item::getType() . ' does not have any preconfigured subtypes!');
//Toolbox::logDebug('Item type ' . $item::getType() . ' does not have any preconfigured subtypes!');
/* For debug purposes
$tabs = $item->defineTabs();
list($id, ) = each($tabs);
Expand Down
29 changes: 17 additions & 12 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static function install(Migration $migration, $version) {
KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`),
KEY `is_active` (`is_active`),
KEY `is_readonly` (`is_readonly`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die ($DB->error());
}

Expand Down Expand Up @@ -240,7 +240,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {

return self::createTabEntry(__("Fields", "fields"),
countElementsInTable(self::getTable(),
"`plugin_fields_containers_id` = '".$item->getID()."'"));
['plugin_fields_containers_id' => $item->getID()]));
}

static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
Expand Down Expand Up @@ -275,16 +275,21 @@ function showSummary($container) {
$rand = mt_rand();

echo "<div id='viewField$cID$rand'></div>";
Html::scriptStart();
echo "viewAddField$cID$rand = function() {";
Ajax::updateItemJsCode("viewField" . $cID . "$rand",
$CFG_GLPI["root_doc"]."/ajax/viewsubitem.php",
['type' => __CLASS__,
'parenttype' => 'PluginFieldsContainer',
'plugin_fields_containers_id' => $cID,
'id' => -1]);
echo "};";
echo Html::scriptEnd();

echo Html::scriptBlock('
viewAddField' . $cID . $rand . ' = function() {
$("#viewField' . $cID . $rand . '").load(
"' . $CFG_GLPI['root_doc'] . '/ajax/viewsubitem.php",
' . json_encode([
'type' => __CLASS__,
'parenttype' => PluginFieldsContainer::class,
'plugin_fields_containers_id' => $cID,
'id' => -1
]) . '
);
};
');

echo "<div class='center'>".
"<a href='javascript:viewAddField$cID$rand();'>";
echo __("Add a new field", "fields")."</a></div><br>";
Expand Down
61 changes: 36 additions & 25 deletions inc/labeltranslation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static function install(Migration $migration, $version) {
KEY `plugin_fields_items_id` (`plugin_fields_items_id`),
KEY `language` (`language`),
UNIQUE KEY `unicity` (`plugin_fields_itemtype`, `plugin_fields_items_id`, `language`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die ($DB->error());
}

Expand Down Expand Up @@ -64,9 +64,13 @@ static function createForItem(CommonDBTM $item) {
}

function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
$nb = countElementsInTable(self::getTable(),
"`plugin_fields_itemtype` = '{$item::getType()}' AND
`plugin_fields_items_id` = '{$item->getID()}'");
$nb = countElementsInTable(
self::getTable(),
[
'plugin_fields_itemtype' => $item::getType(),
'plugin_fields_items_id' => $item->getID(),
]
);
return self::createTabEntry(self::getTypeName($nb), $nb);

}
Expand All @@ -89,16 +93,20 @@ static function showTranslations(CommonDBTM $item) {
$rand = mt_rand();
if ($canedit) {
echo "<div id='viewtranslation".$item->getID()."$rand'></div>";
Html::scriptStart();
echo "addTranslation".$item->getID()."$rand = function() {";
Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "$rand",
$CFG_GLPI["root_doc"]."/plugins/fields/ajax/viewtranslations.php",
['type' => __CLASS__,
'itemtype' => $item::getType(),
'items_id' => $item->fields['id'],
'id' => -1]);
echo "};";
echo Html::scriptEnd();

echo Html::scriptBlock('
addTranslation' . $item->getID() . $rand . ' = function() {
$("#viewtranslation' . $item->getID() . $rand . '").load(
"' . $CFG_GLPI['root_doc'] . '/plugins/fields/ajax/viewtranslations.php",
' . json_encode([
'type' => __CLASS__,
'itemtype' => $item::getType(),
'items_id' => $item->fields['id'],
'id' => -1
]) . '
);
};
');

echo "<div class='center'>".
"<a class='vsubmit' href='javascript:addTranslation".$item->getID()."$rand();'>".
Expand All @@ -123,7 +131,7 @@ static function showTranslations(CommonDBTM $item) {
echo "<th colspan='4'>".__("List of translations")."</th></tr>";
if ($canedit) {
echo "<th width='10'>";
Html::checkAllAsCheckbox('mass'.__CLASS__.$rand);
echo Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand);
echo "</th>";
}
echo "<th>".__("Language", "fields")."</th>";
Expand All @@ -138,16 +146,19 @@ static function showTranslations(CommonDBTM $item) {
}
echo "<td>";
if ($canedit) {
Html::scriptStart();
echo "viewEditTranslation". $data["id"]."$rand = function() {";
Ajax::updateItemJsCode("viewtranslation" . $item->getID() . "$rand",
$CFG_GLPI["root_doc"]."/plugins/fields/ajax/viewtranslations.php",
['type' => __CLASS__,
'itemtype' => $item::getType(),
'items_id' => $item->getID(),
'id' => $data["id"]]);
echo "};";
echo Html::scriptEnd();
echo Html::scriptBlock('
viewEditTranslation' . $data['id'] . $rand . ' = function() {
$("#viewtranslation' . $item->getID() . $rand . '").load(
"' . $CFG_GLPI['root_doc'] . '/plugins/fields/ajax/viewtranslations.php",
' . json_encode([
'type' => __CLASS__,
'itemtype' => $item::getType(),
'items_id' => $item->getID(),
'id' => $data['id']
]) . '
);
};
');
}
echo Dropdown::getLanguageName($data['language']);
echo "</td><td>";
Expand Down
2 changes: 1 addition & 1 deletion inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static function install(Migration $migration) {
PRIMARY KEY (`id`),
KEY `profiles_id` (`profiles_id`),
KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die ($DB->error());
}

Expand Down
Binary file modified locales/cs_CZ.mo
Binary file not shown.
Loading

0 comments on commit 81f848e

Please sign in to comment.