Skip to content

Commit fdf21f3

Browse files
committed
Prepare 9.5 Version
Fix #45 Fix #44 Fix #42 Fix #38
1 parent 8541309 commit fdf21f3

File tree

6 files changed

+53
-45
lines changed

6 files changed

+53
-45
lines changed

hook.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,64 +30,64 @@
3030
function plugin_addressing_install() {
3131
global $DB;
3232

33-
include_once (GLPI_ROOT."/plugins/addressing/inc/profile.class.php");
33+
include_once(GLPI_ROOT . "/plugins/addressing/inc/profile.class.php");
3434

3535
$update = false;
3636
if (!$DB->tableExists("glpi_plugin_addressing_display")
37-
&&!$DB->tableExists("glpi_plugin_addressing")
37+
&& !$DB->tableExists("glpi_plugin_addressing")
3838
&& !$DB->tableExists("glpi_plugin_addressing_configs")) {
3939

40-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/empty-2.7.0.sql");
40+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-2.7.0.sql");
4141

4242
} else {
4343

4444
if (!$DB->tableExists("glpi_plugin_addressing_profiles")
4545
&& $DB->tableExists("glpi_plugin_addressing_display")
4646
&& !$DB->fieldExists("glpi_plugin_addressing_display", "ipconf1")) {//1.4
4747
$update = true;
48-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.4.sql");
48+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql");
4949
}
5050

5151
if (!$DB->tableExists("glpi_plugin_addressing")
5252
&& $DB->tableExists("glpi_plugin_addressing_display")
5353
&& $DB->fieldExists("glpi_plugin_addressing_display", "ipconf1")) {
5454
$update = true;
55-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.5.sql");
55+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql");
5656

5757
}
5858

5959
if ($DB->tableExists("glpi_plugin_addressing_display")
6060
&& !$DB->fieldExists("glpi_plugin_addressing", "ipdeb")) {
6161
$update = true;
62-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.6.sql");
62+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql");
6363

6464
}
6565

6666
if ($DB->tableExists("glpi_plugin_addressing_profiles")
6767
&& $DB->fieldExists("glpi_plugin_addressing_profiles", "interface")) {
6868
$update = true;
69-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.7.0.sql");
69+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql");
7070

7171
}
7272

7373
if (!$DB->tableExists("glpi_plugin_addressing_configs")) {
74-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.8.0.sql");
74+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql");
7575
$update = true;
7676
}
7777

7878
if ($DB->tableExists("glpi_plugin_addressing_profiles")
7979
&& !$DB->fieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) {
80-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-1.9.0.sql");
80+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql");
8181
$update = true;
8282
}
8383
//Version 2.4.0
8484
if (!$DB->tableExists("glpi_plugin_addressing_filters")) {
85-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-2.4.0.sql");
85+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-2.4.0.sql");
8686
}
8787

8888
//Version 2.5.0
8989
if (!$DB->fieldExists("glpi_plugin_addressing_addressings", "locations_id") && !$DB->fieldExists("glpi_plugin_addressing_addressings", "fqdns_id")) {
90-
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-2.5.0.sql");
90+
$DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-2.5.0.sql");
9191
}
9292

9393
}
@@ -97,12 +97,12 @@ function plugin_addressing_install() {
9797
FROM `glpi_plugin_addressing_profiles` ";
9898
$result_ = $DB->query($query_);
9999

100-
if ($DB->numrows($result_)>0) {
101-
while ($data=$DB->fetch_array($result_)) {
102-
$query = "UPDATE `glpi_plugin_addressing_profiles`
103-
SET `profiles_id` = '".$data["id"]."'
104-
WHERE `id` = '".$data["id"]."'";
105-
$result=$DB->query($query);
100+
if ($DB->numrows($result_) > 0) {
101+
while ($data = $DB->fetchArray($result_)) {
102+
$query = "UPDATE `glpi_plugin_addressing_profiles`
103+
SET `profiles_id` = '" . $data["id"] . "'
104+
WHERE `id` = '" . $data["id"] . "'";
105+
$result = $DB->query($query);
106106
}
107107
}
108108

@@ -113,10 +113,10 @@ function plugin_addressing_install() {
113113
}
114114

115115
Plugin::migrateItemType([5000 => 'PluginAddressingAddressing',
116-
5001 => 'PluginAddressingReport'],
116+
5001 => 'PluginAddressingReport'],
117117
["glpi_savedsearches", "glpi_savedsearches_users",
118-
"glpi_displaypreferences", "glpi_documents_items",
119-
"glpi_infocoms", "glpi_logs", "glpi_items_tickets"]);
118+
"glpi_displaypreferences", "glpi_documents_items",
119+
"glpi_infocoms", "glpi_logs", "glpi_items_tickets"]);
120120

121121
}
122122

@@ -138,13 +138,13 @@ function plugin_addressing_install() {
138138
function plugin_addressing_uninstall() {
139139
global $DB;
140140

141-
include_once (GLPI_ROOT."/plugins/addressing/inc/profile.class.php");
142-
include_once (GLPI_ROOT."/plugins/addressing/inc/menu.class.php");
141+
include_once(GLPI_ROOT . "/plugins/addressing/inc/profile.class.php");
142+
include_once(GLPI_ROOT . "/plugins/addressing/inc/menu.class.php");
143143

144144
$migration = new Migration("2.5.0");
145-
$tables = ["glpi_plugin_addressing_addressings",
146-
"glpi_plugin_addressing_configs",
147-
"glpi_plugin_addressing_filters"];
145+
$tables = ["glpi_plugin_addressing_addressings",
146+
"glpi_plugin_addressing_configs",
147+
"glpi_plugin_addressing_filters"];
148148

149149
foreach ($tables as $table) {
150150
$migration->dropTable($table);
@@ -183,7 +183,7 @@ function plugin_addressing_getDatabaseRelations() {
183183

184184
if ($plugin->isActivated("addressing")) {
185185
return ["glpi_networks" => ["glpi_plugin_addressing_addressings" => "networks_id"],
186-
"glpi_entities" => ["glpi_plugin_addressing_addressings" => "entities_id"]];
186+
"glpi_entities" => ["glpi_plugin_addressing_addressings" => "entities_id"]];
187187
}
188188
return [];
189189
}
@@ -274,9 +274,9 @@ function plugin_addressing_dynamicReport($params) {
274274
$PluginAddressingAddressing = new PluginAddressingAddressing();
275275

276276
if ($params["item_type"] == 'PluginAddressingReport'
277-
&& isset($params["id"])
278-
&& isset($params["display_type"])
279-
&& $PluginAddressingAddressing->getFromDB($params["id"])) {
277+
&& isset($params["id"])
278+
&& isset($params["display_type"])
279+
&& $PluginAddressingAddressing->getFromDB($params["id"])) {
280280

281281
$PluginAddressingReport = new PluginAddressingReport();
282282
$PluginAddressingAddressing->getFromDB($params['id']);
@@ -286,16 +286,16 @@ function plugin_addressing_dynamicReport($params) {
286286
if ($addressingFilter->getFromDB($params['filter'])) {
287287
$ipdeb = sprintf("%u", ip2long($addressingFilter->fields['begin_ip']));
288288
$ipfin = sprintf("%u", ip2long($addressingFilter->fields['end_ip']));
289-
$result = $PluginAddressingAddressing->compute($params["start"], [ 'ipdeb' => $ipdeb,
290-
'ipfin' => $ipfin,
291-
'entities_id' => $addressingFilter->fields['entities_id'],
292-
'type_filter' => $addressingFilter->fields['type']]);
289+
$result = $PluginAddressingAddressing->compute($params["start"], ['ipdeb' => $ipdeb,
290+
'ipfin' => $ipfin,
291+
'entities_id' => $addressingFilter->fields['entities_id'],
292+
'type_filter' => $addressingFilter->fields['type']]);
293293
}
294294
} else {
295295
$ipdeb = sprintf("%u", ip2long($PluginAddressingAddressing->fields["begin_ip"]));
296296
$ipfin = sprintf("%u", ip2long($PluginAddressingAddressing->fields["end_ip"]));
297-
$result = $PluginAddressingAddressing->compute($params["start"], [ 'ipdeb' => $ipdeb,
298-
'ipfin' => $ipfin]);
297+
$result = $PluginAddressingAddressing->compute($params["start"], ['ipdeb' => $ipdeb,
298+
'ipfin' => $ipfin]);
299299
}
300300
$PluginAddressingReport->displayReport($result, $PluginAddressingAddressing);
301301

@@ -316,7 +316,7 @@ function plugin_addressing_dynamicReport($params) {
316316
*/
317317
function plugin_addressing_addOrderBy($itemtype, $ID, $order, $key) {
318318
if ($itemtype == "PluginAddressingAddressing"
319-
&& ($ID == 1000 || $ID == 1001)) {
319+
&& ($ID == 1000 || $ID == 1001)) {
320320
return "ORDER BY INET_ATON(ITEM_$key) $order";
321321

322322
}

inc/addressing.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ function linkToExport($ID) {
363363
function compute($start, $params = []) {
364364
global $DB;
365365

366+
$ipdeb = 0;
367+
$ipfin = 0;
366368
foreach ($params as $key => $val) {
367369
if (isset($params[$key])) {
368370
$$key = $params[$key];
@@ -481,7 +483,7 @@ function compute($start, $params = []) {
481483
}
482484
$res = $DB->query($sql);
483485
if ($res) {
484-
while ($row=$DB->fetch_assoc($res)) {
486+
while ($row=$DB->fetchAssoc($res)) {
485487
$result["IP".$row["ipnum"]][]=$row;
486488
}
487489
}

inc/menu.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ static function getMenuContent() {
5050
if (Session::haveRight('plugin_addressing', UPDATE)) {
5151
$menu['links']['add'] = PluginAddressingAddressing::getFormURL(false);
5252
}
53+
$menu['icon'] = self::getIcon();
54+
5355
return $menu;
5456
}
5557

58+
static function getIcon() {
59+
return "fas fa-map-pin";
60+
}
61+
5662
static function removeRightsFromSession() {
5763
if (isset($_SESSION['glpimenu']['tools']['types']['PluginAddressingMenu'])) {
5864
unset($_SESSION['glpimenu']['tools']['types']['PluginAddressingMenu']);

inc/ping_equipment.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function showForm($ID, $options = []) {
5252
WHERE `id` = '".$obj->fields['id']."'";
5353
5454
$res = $DB->query($query);
55-
while ($row = $DB->fetch_array($res)) {
55+
while ($row = $DB->fetchArray($res)) {
5656
if ($row['ip'] != '') {
5757
$list_ip[$row['ip']] = $row['ip'];
5858
}
@@ -72,7 +72,7 @@ function showForm($ID, $options = []) {
7272
WHERE `" . $obj->getTable() . "`.`id` = '".$obj->fields['id']."'";
7373

7474
$res = $DB->query($query);
75-
while ($row = $DB->fetch_array($res)) {
75+
while ($row = $DB->fetchArray($res)) {
7676
if ($row['ip'] != '') {
7777
$port = $row['ip'];
7878
if ($row['name'] != '') {

inc/reserveip.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function reserveip($input = []) {
122122
$np = new NetworkPort();
123123
$newID = $np->add($newinput);
124124

125-
Event::log($newID, "networkport", 5, "inventory",
125+
\Glpi\Event::log($newID, "networkport", 5, "inventory",
126126
//TRANS: %s is the user login
127127
sprintf(__('%s adds an item'), $_SESSION["glpiname"]));
128128
}

setup.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30-
define('PLUGIN_ADDRESSING_VERSION', '2.8.0');
30+
define('PLUGIN_ADDRESSING_VERSION', '2.9.0');
3131

3232
// Init the hooks of the plugins -Needed
3333
function plugin_init_addressing() {
@@ -75,7 +75,7 @@ function plugin_version_addressing() {
7575
'homepage' => 'https://github.com/pluginsGLPI/addressing',
7676
'requirements' => [
7777
'glpi' => [
78-
'min' => '9.4',
78+
'min' => '9.5',
7979
'dev' => false
8080
]
8181
]];
@@ -84,10 +84,10 @@ function plugin_version_addressing() {
8484

8585
// Optional : check prerequisites before install : may print errors or add to message after redirect
8686
function plugin_addressing_check_prerequisites() {
87-
if (version_compare(GLPI_VERSION, '9.4', 'lt')
88-
|| version_compare(GLPI_VERSION, '9.5', 'ge')) {
87+
if (version_compare(GLPI_VERSION, '9.5', 'lt')
88+
|| version_compare(GLPI_VERSION, '9.6', 'ge')) {
8989
if (method_exists('Plugin', 'messageIncompatible')) {
90-
echo Plugin::messageIncompatible('core', '9.4');
90+
echo Plugin::messageIncompatible('core', '9.5');
9191
}
9292
return false;
9393
}

0 commit comments

Comments
 (0)