Skip to content

Commit 304b809

Browse files
committed
Disable ping for cloud installation
1 parent ab6ea94 commit 304b809

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/Config.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@ class Config extends CommonDBTM
4949
public function showForm($ID, $options = [])
5050
{
5151
$this->initForm($ID, $options);
52+
$is_cloud = defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD';
5253
TemplateRenderer::getInstance()->display(
5354
'@addressing/config.html.twig',
5455
[
55-
'id' => 1,
56-
'config' => $this->fields,
56+
'id' => 1,
57+
'config' => $this->fields,
58+
'is_cloud' => $is_cloud,
5759
],
5860
);
5961
}
62+
63+
public function prepareInputForUpdate($input)
64+
{
65+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
66+
$input['use_ping'] = 0;
67+
}
68+
return $input;
69+
}
6070
}

src/Ping_Equipment.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public function showPingForm($itemtype, $items_id)
155155
*/
156156
public function ping($system, $ip, $return = "list")
157157
{
158+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
159+
return $return === "true" ? false : [__('Ping unavailable in cloud mode', 'addressing'), 1];
160+
}
161+
158162
$error = 1;
159163
$list = '';
160164
switch ($system) {
@@ -260,6 +264,10 @@ public function ping($system, $ip, $return = "list")
260264
*/
261265
public function getHostnameByPing($system, $ip)
262266
{
267+
if (defined('GLPI_INSTALL_MODE') && GLPI_INSTALL_MODE === 'CLOUD') {
268+
return '';
269+
}
270+
263271
$error = 1;
264272
$list = '';
265273
switch ($system) {

templates/config.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@
7272

7373
{{ fields.sliderField(
7474
'use_ping',
75-
config["use_ping"],
75+
is_cloud ? 0 : config["use_ping"],
7676
__('Use Ping on IP ranges', 'addressing'),
77-
field_options
77+
field_options|merge({'disabled': is_cloud})
7878
) }}
7979
</div>
8080

81+
{% if not is_cloud %}
8182
<div class="hr-text">
8283
<i class="fa-2x ti ti-terminal-2"></i>
8384
<span>{{ __('System for ping', 'addressing') }}</span>
@@ -99,6 +100,7 @@
99100
) }}
100101

101102
</div>
103+
{% endif %}
102104

103105
<div class="hr mt-3 mb-3"></div>
104106
<div class="hstack gap-1">

0 commit comments

Comments
 (0)