|
28 | 28 | */ |
29 | 29 |
|
30 | 30 | 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"); |
32 | 32 | } |
33 | 33 |
|
34 | 34 | /** |
35 | 35 | * Class PluginAddressingConfig |
36 | 36 | */ |
37 | | -class PluginAddressingConfig extends CommonDBTM { |
| 37 | +class PluginAddressingConfig extends CommonDBTM |
| 38 | +{ |
38 | 39 |
|
39 | | - static $rightname = "plugin_addressing"; |
| 40 | + static $rightname = "plugin_addressing"; |
40 | 41 |
|
41 | | - function showForm($ID, $options = []) { |
| 42 | + function showForm($ID, $options = []) |
| 43 | + { |
42 | 44 |
|
43 | | - $this->getFromDB($ID); |
| 45 | + $this->getFromDB($ID); |
44 | 46 |
|
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()."'>"; |
46 | 51 |
|
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>"; |
49 | 54 |
|
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'), |
55 | 57 | 1 => __('Windows', 'addressing'), |
56 | 58 | 2 => __('Linux fping', 'addressing'), |
57 | 59 | 3 => __('BSD ping', 'addressing'), |
58 | 60 | 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 | + } |
102 | 117 | } |
103 | | - |
|
0 commit comments