Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(task): enhance dropdown when applying policies
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed May 25, 2018
1 parent 5006bce commit 50bd241
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions inc/policy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,28 @@ public function getSearchOptionsNew() {
return $tab;
}

public static function dropdown($options = []) {
global $DB;

$request = [
'FROM' => PluginFlyvemdmPolicyCategory::getTable(),
];

$category = [];
foreach ($DB->request($request) as $row) {
$elements[$row['name']] = [];
$category[$row['id']] = $row['completename'];
}

$request = [
'FROM' => static::getTable(),
];
$currentCategory = '';
foreach ($DB->request($request) as $row) {
$categoryName = $category[$row['plugin_flyvemdm_policycategories_id']];
$elements[$categoryName][] = $row['name'];
}
return Dropdown::showFromArray(static::getForeignKeyField(), $elements, $options);
}

}
4 changes: 2 additions & 2 deletions inc/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
switch (get_class($item)) {
case PluginFlyvemdmFleet::class:
case PluginFlyvemdmAgent::class:
static::showForFleet($item, $withtemplate);
static::showForNotifiable($item, $withtemplate);
break;
}
}
Expand All @@ -597,7 +597,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
* @param CommonDBTM $item
* @param string $withtemplate
*/
static function showForFleet(CommonDBTM $item, $withtemplate = '') {
static function showForNotifiable(CommonDBTM $item, $withtemplate = '') {
global $CFG_GLPI;

if (!$item->canView()) {
Expand Down

0 comments on commit 50bd241

Please sign in to comment.