Skip to content

Commit 46426f4

Browse files
committed
Bump version
Disable ping for cloud installation
1 parent 9929c80 commit 46426f4

4 files changed

Lines changed: 87 additions & 59 deletions

File tree

addressing.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<author>Nelly Mahu-Lasson</author>
2828
</authors>
2929
<versions>
30+
<version>
31+
<num>3.0.5</num>
32+
<compatibility>~10.0</compatibility>
33+
<download_url>https://github.com/pluginsGLPI/addressing/releases/download/3.0.5/glpi-addressing-3.0.5.tar.bz2</download_url>
34+
</version>
3035
<version>
3136
<num>3.0.4</num>
3237
<compatibility>~10.0</compatibility>

inc/config.class.php

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,90 @@
2828
*/
2929

3030
if (!defined('GLPI_ROOT')) {
31-
die("Sorry. You can't access directly to this file");
31+
die("Sorry. You can't access directly to this file");
3232
}
3333

3434
/**
3535
* Class PluginAddressingConfig
3636
*/
37-
class PluginAddressingConfig extends CommonDBTM {
37+
class PluginAddressingConfig extends CommonDBTM
38+
{
3839

39-
static $rightname = "plugin_addressing";
40+
static $rightname = "plugin_addressing";
4041

41-
function showForm($ID, $options = []) {
42+
function showForm($ID, $options = [])
43+
{
4244

43-
$this->getFromDB($ID);
45+
$this->getFromDB($ID);
4446

45-
$system = $this->fields["used_system"];
47+
$system = $this->fields["used_system"];
48+
$is_cloud = defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD';
49+
echo "<div class='center'>";
50+
echo "<form method='post' action='".$this->getFormURL()."'>";
4651

47-
echo "<div class='center'>";
48-
echo "<form method='post' action='".$this->getFormURL()."'>";
52+
echo "<table class='tab_cadre_fixe'>";
53+
echo "<tr><th colspan='4'>".__('System for ping', 'addressing')."</th></tr>";
4954

50-
echo "<table class='tab_cadre_fixe'>";
51-
echo "<tr><th colspan='4'>".__('System for ping', 'addressing')."</th></tr>";
52-
53-
echo "<tr class='tab_bg_1'><td colspan='4'><div class='center'>";
54-
$array = [0 => __('Linux ping', 'addressing'),
55+
echo "<tr class='tab_bg_1'><td colspan='4'><div class='center'>";
56+
$array = [0 => __('Linux ping', 'addressing'),
5557
1 => __('Windows', 'addressing'),
5658
2 => __('Linux fping', 'addressing'),
5759
3 => __('BSD ping', 'addressing'),
5860
4 => __('MacOSX ping', 'addressing')];
59-
Dropdown::ShowFromArray("used_system", $array, ['value' => $system]);
60-
echo "</div></td></tr>";
61-
62-
echo "<tr><th colspan='4'>".__('Display', 'addressing')."</th></tr>";
63-
64-
echo "<tr class='tab_bg_1'><td>".__('Assigned IP', 'addressing')."</td>";
65-
echo "<td>";
66-
Dropdown::showYesNo("alloted_ip", $this->fields["alloted_ip"]);
67-
echo "</td>";
68-
69-
echo "<td>".__('Free IP', 'addressing')."</td>";
70-
echo "<td>";
71-
Dropdown::showYesNo("free_ip", $this->fields["free_ip"]);
72-
echo "</td>";
73-
echo "</tr>";
74-
75-
echo "<tr class='tab_bg_1'><td>".__('Same IP', 'addressing')."</td>";
76-
echo "<td>";
77-
Dropdown::showYesNo("double_ip", $this->fields["double_ip"]);
78-
echo "</td>";
79-
80-
echo "<td>".__('Reserved IP', 'addressing')."</td>";
81-
echo "<td>";
82-
Dropdown::showYesNo("reserved_ip", $this->fields["reserved_ip"]);
83-
echo "</td>";
84-
85-
echo "</tr>";
86-
87-
echo "<tr class='tab_bg_1'><td colspan='2'>".__('Use Ping', 'addressing')."</td>";
88-
echo "<td colspan='2'>";
89-
Dropdown::showYesNo("use_ping", $this->fields["use_ping"]);
90-
echo "</td>";
91-
echo "</tr>";
92-
93-
echo "<tr><th colspan='4'>";
94-
echo Html::hidden('id', ['value' => 1]);
95-
echo "<div class='center'>";
96-
echo Html::submit(_sx('button', 'Post'), ['name' => 'update', 'class' => 'btn btn-primary me-2']);
97-
echo "</div></th></tr>";
98-
echo "</table>";
99-
Html::closeForm();
100-
echo "</div>";
101-
}
61+
Dropdown::ShowFromArray("used_system", $array, ['value' => $system]);
62+
echo "</div></td></tr>";
63+
64+
echo "<tr><th colspan='4'>".__('Display', 'addressing')."</th></tr>";
65+
66+
echo "<tr class='tab_bg_1'><td>".__('Assigned IP', 'addressing')."</td>";
67+
echo "<td>";
68+
Dropdown::showYesNo("alloted_ip", $this->fields["alloted_ip"]);
69+
echo "</td>";
70+
71+
echo "<td>".__('Free IP', 'addressing')."</td>";
72+
echo "<td>";
73+
Dropdown::showYesNo("free_ip", $this->fields["free_ip"]);
74+
echo "</td>";
75+
echo "</tr>";
76+
77+
echo "<tr class='tab_bg_1'><td>".__('Same IP', 'addressing')."</td>";
78+
echo "<td>";
79+
Dropdown::showYesNo("double_ip", $this->fields["double_ip"]);
80+
echo "</td>";
81+
82+
echo "<td>".__('Reserved IP', 'addressing')."</td>";
83+
echo "<td>";
84+
Dropdown::showYesNo("reserved_ip", $this->fields["reserved_ip"]);
85+
echo "</td>";
86+
87+
echo "</tr>";
88+
89+
if ($is_cloud) {
90+
echo Html::hidden('use_ping', ['value' => 0]);
91+
} else {
92+
echo "<tr class='tab_bg_1'><td colspan='2'>".__('Use Ping', 'addressing')."</td>";
93+
echo "<td colspan='2'>";
94+
Dropdown::showYesNo("use_ping", $this->fields["use_ping"]);
95+
echo "</td>";
96+
echo "</tr>";
97+
}
98+
99+
100+
echo "<tr><th colspan='4'>";
101+
echo Html::hidden('id', ['value' => 1]);
102+
echo "<div class='center'>";
103+
echo Html::submit(_sx('button', 'Post'), ['name' => 'update', 'class' => 'btn btn-primary me-2']);
104+
echo "</div></th></tr>";
105+
echo "</table>";
106+
Html::closeForm();
107+
echo "</div>";
108+
}
109+
110+
public function prepareInputForUpdate($input)
111+
{
112+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
113+
$input['use_ping'] = 0;
114+
}
115+
return $input;
116+
}
102117
}
103-

inc/ping_equipment.class.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function showPingForm($itemtype, $items_id) {
5050
$list_ip = [];
5151

5252
$query = "SELECT `glpi_networknames`.`name`, `glpi_ipaddresses`.`name` as ip, `glpi_networkports`.`items_id`
53-
FROM `glpi_networkports`
53+
FROM `glpi_networkports`
5454
LEFT JOIN `" . $obj->getTable() . "` ON (`glpi_networkports`.`items_id` = `" . $obj->getTable() . "`.`id`
5555
AND `glpi_networkports`.`itemtype` = '" . $itemtype . "')
5656
LEFT JOIN `glpi_networknames` ON (`glpi_networkports`.`id` = `glpi_networknames`.`items_id`)
@@ -117,6 +117,11 @@ function showPingForm($itemtype, $items_id) {
117117
* @return array
118118
*/
119119
function ping($system, $ip, $return = "list") {
120+
121+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
122+
return $return === "true" ? false : [__('Ping unavailable in cloud mode', 'addressing'), 1];
123+
}
124+
120125
$error = 1;
121126
$list = '';
122127
switch ($system) {
@@ -221,6 +226,10 @@ function ping($system, $ip, $return = "list") {
221226
* @return array
222227
*/
223228
function getHostnameByPing($system, $ip) {
229+
230+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
231+
return '';
232+
}
224233
$error = 1;
225234
$list = '';
226235
switch ($system) {

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
--------------------------------------------------------------------------
2828
*/
2929

30-
define('PLUGIN_ADDRESSING_VERSION', '3.0.4');
30+
define('PLUGIN_ADDRESSING_VERSION', '3.0.5');
3131

3232
if (!defined("PLUGIN_ADDRESSING_DIR")) {
3333
define("PLUGIN_ADDRESSING_DIR", Plugin::getPhpDir("addressing"));

0 commit comments

Comments
 (0)