Skip to content

Commit 8819cc1

Browse files
committed
Fix getMenuContent (for savesearches lists)
1 parent a375f00 commit 8819cc1

13 files changed

+75
-116
lines changed

front/addressing.form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@
8787
} else if (isset($_POST["search"])) {
8888

8989
$addressing->checkGlobal(READ);
90-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu");
90+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing");
9191
$addressing->display($_POST);
9292
Html::footer();
9393
} else {
9494
$addressing->checkGlobal(READ);
95-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu");
95+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing");
9696
$addressing->display($_GET);
9797
Html::footer();
9898
}

front/addressing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
}
4040
} else {
4141

42-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu");
42+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing");
4343

4444
$PluginAddressingAddressing = new PluginAddressingAddressing();
4545

front/config.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
Html::back();
4141

4242
} else {
43-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu", "addressing");
43+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing", "addressing");
4444
$PluginAddressingConfig->showForm(1);
4545
Html::footer();
4646
}

front/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
Html::back();
4141

4242
} else {
43-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu", "addressing");
43+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing", "addressing");
4444
$PluginAddressingConfig->showForm(1);
4545
Html::footer();
4646
}

front/report.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
include ('../../../inc/includes.php');
3535

36-
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingmenu");
36+
Html::header(PluginAddressingAddressing::getTypeName(2), '', "tools", "pluginaddressingaddressing");
3737

3838
if (!isset($_GET["start"])) {
3939
$_GET["start"] = 0;

front/reserveip.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
$reserveip->reserveip($_POST);
3737
Html::back();
3838
} else {
39-
Html::header(PluginAddressingReserveip::getTypeName(), '', "tools", "pluginaddressingmenu");
39+
Html::header(PluginAddressingReserveip::getTypeName(), '', "tools", "pluginaddressingaddressing");
4040
if(filter_var($_REQUEST["ip"], FILTER_VALIDATE_IP)) {
4141
$reserveip->showReservationForm($_REQUEST["ip"], $_REQUEST["id_addressing"], $_REQUEST['rand']);
4242
}

hook.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ function plugin_addressing_uninstall() {
144144
global $DB;
145145

146146
include_once(PLUGIN_ADDRESSING_DIR . "/inc/profile.class.php");
147-
include_once(PLUGIN_ADDRESSING_DIR . "/inc/menu.class.php");
148147

149148
$migration = new Migration("2.5.0");
150149
$tables = ["glpi_plugin_addressing_addressings",
@@ -172,7 +171,7 @@ function plugin_addressing_uninstall() {
172171
//Remove rigth from $_SESSION['glpiactiveprofile'] if exists
173172
PluginAddressingProfile::removeRightsFromSession();
174173

175-
PluginAddressingMenu::removeRightsFromSession();
174+
PluginAddressingAddressing::removeRightsFromSession();
176175
CronTask::unregister("addressing");
177176
return true;
178177
}

inc/addressing.class.php

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static function getTypeName($nb = 0) {
4646
return _n('IP Adressing', 'IP Adressing', $nb, 'addressing');
4747
}
4848

49+
static function getIcon() {
50+
return "ti ti-map-pin";
51+
}
4952

5053
/**
5154
* Actions done when item is deleted from the database
@@ -177,22 +180,22 @@ function getTitle() {
177180
/**
178181
* @param $entity
179182
*/
180-
// function dropdownSubnet($entity) {
181-
// global $DB;
182-
//
183-
// $dbu = new DbUtils();
184-
// $sql = "SELECT DISTINCT `completename`
185-
// FROM `glpi_ipnetworks`" .
186-
// $dbu->getEntitiesRestrictRequest(" WHERE ", "glpi_ipnetworks", "entities_id", $entity);
187-
// $networkList = [0 => Dropdown::EMPTY_VALUE];
188-
// foreach ($DB->request($sql) as $network) {
189-
// $networkList += [$network["completename"] => $network["completename"]];
190-
// }
191-
// $rand = mt_rand();
192-
// $name = "_subnet";
193-
// Dropdown::ShowFromArray($name, $networkList, ['rand' => $rand,
194-
// 'on_change' => 'plugaddr_ChangeList("dropdown_' . $name . $rand . '");']);
195-
// }
183+
// function dropdownSubnet($entity) {
184+
// global $DB;
185+
//
186+
// $dbu = new DbUtils();
187+
// $sql = "SELECT DISTINCT `completename`
188+
// FROM `glpi_ipnetworks`" .
189+
// $dbu->getEntitiesRestrictRequest(" WHERE ", "glpi_ipnetworks", "entities_id", $entity);
190+
// $networkList = [0 => Dropdown::EMPTY_VALUE];
191+
// foreach ($DB->request($sql) as $network) {
192+
// $networkList += [$network["completename"] => $network["completename"]];
193+
// }
194+
// $rand = mt_rand();
195+
// $name = "_subnet";
196+
// Dropdown::ShowFromArray($name, $networkList, ['rand' => $rand,
197+
// 'on_change' => 'plugaddr_ChangeList("dropdown_' . $name . $rand . '");']);
198+
// }
196199

197200

198201
function post_getEmpty() {
@@ -399,8 +402,8 @@ function test(id) {
399402
echo "<td class='center' colspan='3'>";
400403
Html::textarea(['name' => 'comment',
401404
'value' => $this->fields["comment"],
402-
'cols' => 125,
403-
'rows' => 3,
405+
'cols' => 125,
406+
'rows' => 3,
404407
'enable_richtext' => false]);
405408
echo "</td></tr>";
406409

@@ -547,7 +550,7 @@ function compute($start, $params = []) {
547550

548551
if ($type == 'PluginFusioninventoryUnknownDevice'
549552
|| $type == 'Enclosure'
550-
|| $type == 'PDU'
553+
|| $type == 'PDU'
551554
|| $type == 'Cluster'
552555
|| $type == 'Unmanaged') {
553556
$sql .= " ,0 AS `users_id` ";
@@ -777,7 +780,7 @@ function showReport($params) {
777780
echo "</td>";
778781

779782
echo "<td class='center' colspan='4'>";
780-
echo "<button form='' type='submit' id='updatePingInfo' class='btn btn-primary me-2 center' name='updatePingInfo' title='" . _sx('button', 'Manual launch of ping', 'addressing') . "'>";
783+
echo "<button form='' type='submit' id='updatePingInfo' class='submit btn btn-primary me-2 center' name='updatePingInfo' title='" . _sx('button', 'Manual launch of ping', 'addressing') . "'>";
781784
echo "<i class='fas fa-spinner' data-hasqtip='0' aria-hidden='true'></i>&nbsp;";
782785
echo _sx('button', 'Manual launch of ping', 'addressing');
783786
echo "</button>";
@@ -1018,5 +1021,45 @@ static function showSwitchField($name, $value) {
10181021
echo "<a class=\"button\"><i class=\"$name fa-fw fas fa-2x fa-toggle-off disabled\"></i></a>";
10191022
}
10201023
}
1024+
1025+
static function getMenuContent() {
1026+
1027+
$menu = [];
1028+
$menu['title'] = self::getMenuName();
1029+
$menu['title'] = self::getTypeName(2);
1030+
$menu['page'] = self::getSearchURL(false);
1031+
$menu['links']['search'] = self::getSearchURL(false);
1032+
$menu['links']['lists'] = "";
1033+
if (Session::haveRight('plugin_addressing', UPDATE)) {
1034+
$menu['links']['add'] = self::getFormURL(false);
1035+
}
1036+
1037+
if (Session::haveRight(static::$rightname, UPDATE)
1038+
|| Session::haveRight("config", UPDATE)) {
1039+
//Entry icon in breadcrumb
1040+
$menu['links']['config'] = PluginAddressingConfig::getSearchURL(false);
1041+
//Link to config page in admin plugins list
1042+
$menu['config_page'] = PluginAddressingConfig::getSearchURL(false);
1043+
1044+
//Add a fourth level in breadcrumb for configuration page
1045+
$menu['options']['config']['title'] = __('Setup');
1046+
$menu['options']['config']['page'] = PluginAddressingConfig::getSearchURL(false);
1047+
$menu['options']['config']['links']['search'] = self::getSearchURL(false);
1048+
$menu['options']['config']['links']['add'] = self::getFormURL(false);
1049+
}
1050+
1051+
$menu['icon'] = self::getIcon();
1052+
1053+
return $menu;
1054+
}
1055+
1056+
static function removeRightsFromSession() {
1057+
if (isset($_SESSION['glpimenu']['tools']['types']['PluginAddressingAddressing'])) {
1058+
unset($_SESSION['glpimenu']['tools']['types']['PluginAddressingAddressing']);
1059+
}
1060+
if (isset($_SESSION['glpimenu']['tools']['content']['pluginaddressingaddressing'])) {
1061+
unset($_SESSION['glpimenu']['tools']['content']['pluginaddressingaddressing']);
1062+
}
1063+
}
10211064
}
10221065

inc/filter.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static function showList($item, $options = []) {
275275
echo "};";
276276
echo "</script>\n";
277277
echo "<div class='center firstbloc'>" .
278-
"<a class='btn btn-primary me-2' href='javascript:viewAddFilter" . $item_id . "$rand();'>";
278+
"<a class='submit btn btn-primary me-2' href='javascript:viewAddFilter" . $item_id . "$rand();'>";
279279
echo __('Add a filter', 'addressing') . "</a></div>\n";
280280
}
281281

inc/menu.class.php

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)