Skip to content

Commit fd23926

Browse files
author
amma35
committed
see #7
Addition of the location and the domain internet
1 parent cc4685a commit fd23926

File tree

8 files changed

+218
-69
lines changed

8 files changed

+218
-69
lines changed

addressing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function plugaddr_IsFilter(msg) {
179179

180180
function nameIsThere(params) {
181181
var root_doc = params;
182-
var nameElm = $('input[id*="textfield_name"]');
182+
var nameElm = $('input[id*="name_reserveip"]');
183183
var typeElm = $('select[name="type"]');
184184
var divNameItemElm = $('div[id="nameItem"]');
185185
$.ajax({

ajax/addressing.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
Html::header_nocache();
3535
if(isset($_POST['action']) && $_POST['action'] == 'isName'){
3636
$item = new $_POST['type']();
37-
$datas = $item->find("`name` = '".$_POST['name']."'");
37+
$datas = $item->find("`name` LIKE '".$_POST['name']."'");
3838
if(count($datas) > 0){
3939
echo json_encode(true);
4040
}else{
@@ -48,8 +48,19 @@
4848
} else {
4949
_e('Access denied');
5050
}
51-
}elseif(isset($_POST['action']) && $_POST['action'] == 'networkip'){
51+
52+
}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_networkip'){
5253
IPNetwork::showIPNetworkProperties($_POST['entities_id']);
54+
55+
}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_location'){
56+
Dropdown::show('Location', array('name' => "locations_id",
57+
'value' => $_POST["value"],
58+
'entity' => $_POST['entities_id']));
59+
60+
}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_fqdn'){
61+
Dropdown::show('FQDN', array('name' => "fqdns_id",
62+
'value' => $_POST["value"],
63+
'entity'=> $_POST['entities_id']));
5364

5465
}elseif(isset($_POST['action']) && $_POST['action'] == 'showForm') {
5566
$PluginAddressingReserveip = new PluginAddressingReserveip();

hook.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function plugin_addressing_install() {
3737
&&!TableExists("glpi_plugin_addressing")
3838
&& !TableExists("glpi_plugin_addressing_configs")) {
3939

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

4242
} else {
4343

@@ -85,6 +85,11 @@ function plugin_addressing_install() {
8585
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-2.4.0.sql");
8686
}
8787

88+
//Version 3.0.0
89+
if (!FieldExists("glpi_plugin_addressing_addressings", "locations_id") && !FieldExists("glpi_plugin_addressing_addressings", "fqdns_id")) {
90+
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-3.0.0.sql");
91+
}
92+
8893
}
8994

9095
if ($update) {
@@ -120,7 +125,7 @@ function plugin_addressing_install() {
120125
//Add all rights for current user profile
121126
PluginAddressingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
122127
//Drop old profile table : not used anymore
123-
$migration = new Migration("2.4.0");
128+
$migration = new Migration("3.0.0");
124129
$migration->dropTable('glpi_plugin_addressing_profiles');
125130

126131
return true;
@@ -133,7 +138,7 @@ function plugin_addressing_uninstall() {
133138
include_once (GLPI_ROOT."/plugins/addressing/inc/profile.class.php");
134139
include_once (GLPI_ROOT."/plugins/addressing/inc/menu.class.php");
135140

136-
$migration = new Migration("2.3.0");
141+
$migration = new Migration("3.0.0");
137142
$tables = array("glpi_plugin_addressing_addressings",
138143
"glpi_plugin_addressing_configs");
139144

inc/addressing.class.php

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ function getSearchOptions() {
6767
$tab[4]['name'] = __('Ping free Ip', 'addressing');
6868
$tab[4]['datatype'] = 'bool';
6969

70+
$tab[5]['table'] = 'glpi_locations';
71+
$tab[5]['field'] = 'name';
72+
$tab[5]['name'] = __('Location');
73+
$tab[5]['datatype'] = 'dropdown';
74+
75+
$tab[6]['table'] = 'glpi_fqdns';
76+
$tab[6]['field'] = 'name';
77+
$tab[6]['name'] = FQDN::getTypeName(1);
78+
$tab[6]['datatype'] = 'dropdown';
79+
7080
$tab[30]['table'] = $this->getTable();
7181
$tab[30]['field'] = 'id';
7282
$tab[30]['name'] = __('ID');
@@ -159,28 +169,31 @@ function showForm ($ID, $options=array()) {
159169
echo "</tr>";
160170

161171
echo "<tr class='tab_bg_1'>";
162-
echo "<td>".__('Select the network', 'addressing')."</td>";
172+
echo "<td>".__('Location')."</td>";
163173
echo "<td>";
164-
Dropdown::show('Network', array('name' => "networks_id",
165-
'value' => $this->fields["networks_id"]));
174+
Dropdown::show('Location', array('name' => "locations_id",
175+
'value' => $this->fields["locations_id"],
176+
'entity' => $this->fields['entities_id']));
166177
echo "</td>";
167178

168179
if ($PluginAddressingConfig->fields["free_ip"]) {
169180
echo "<td>".__('Free Ip', 'addressing')."</td><td>";
170181
Dropdown::showYesNo('free_ip', $this->fields["free_ip"]);
171182
echo "</td>";
172183
} else {
173-
echo "<td>";
184+
echo "<td>";
174185
echo Html::hidden('free_ip', array('value' => 0));
175186
echo "</td><td></td>";
176187
//echo "<td><input type='hidden' name='free_ip' value='0'></td><td></td>";
177188
}
178189
echo "</tr>";
179190

180191
echo "<tr class='tab_bg_1'>";
181-
echo "<td>".__('Detected subnet list', 'addressing')."</td>";
192+
echo "<td>".FQDN::getTypeName(1)."</td>";
182193
echo "<td>";
183-
$this->dropdownSubnet($ID>0 ? $this->fields["entities_id"] : $_SESSION["glpiactive_entity"]);
194+
Dropdown::show('FQDN', array('name' => "fqdns_id",
195+
'value' => $this->fields["fqdns_id"],
196+
'entity'=> $this->fields['entities_id']));
184197
echo "</td>";
185198

186199
if ($PluginAddressingConfig->fields["double_ip"]) {
@@ -189,62 +202,81 @@ function showForm ($ID, $options=array()) {
189202
echo "</td>";
190203
} else {
191204
//echo "<td><input type='hidden' name='double_ip' value='0'></td><td></td>";
192-
echo "<td>";
205+
echo "<td>";
193206
echo Html::hidden('double_ip', array('value' => 0));
194207
echo "</td><td></td>";
195208
}
196209
echo "</tr>";
197210

198211
echo "<tr class='tab_bg_1'>";
199-
echo "<td>".__('First IP', 'addressing')."</td>"; // Subnet
212+
echo "<td>".__('Select the network', 'addressing')."</td>";
200213
echo "<td>";
201-
echo "<input type='text' id='plugaddr_ipdeb0' value='' name='_ipdeb0' size='3' ".
202-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
203-
echo "<input type='text' id='plugaddr_ipdeb1' value='' name='_ipdeb1' size='3' ".
204-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
205-
echo "<input type='text' id='plugaddr_ipdeb2' value='' name='_ipdeb2' size='3' ".
206-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
207-
echo "<input type='text' id='plugaddr_ipdeb3' value='' name='_ipdeb3' size='3' ".
208-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
214+
Dropdown::show('Network', array('name' => "networks_id",
215+
'value' => $this->fields["networks_id"]));
209216
echo "</td>";
210217

211218
if ($PluginAddressingConfig->fields["reserved_ip"]) {
212219
echo "<td>".__('Reserved IP', 'addressing')."</td><td>";
213220
Dropdown::showYesNo('reserved_ip',$this->fields["reserved_ip"]);
214221
echo "</td>";
215222
} else {
216-
echo "<td>";
223+
echo "<td>";
217224
echo Html::hidden('reserved_ip', array('value' => 0));
218225
echo "</td><td></td>";
219226
//echo "<td><input type='hidden' name='reserved_ip' value='0'></td><td></td>";
220227
}
221228
echo "</tr>";
222229

223230
echo "<tr class='tab_bg_1'>";
224-
echo "<td>".__('Last IP', 'addressing')."</td>"; // Mask
231+
echo "<td>".__('Detected subnet list', 'addressing')."</td>";
225232
echo "<td>";
226-
echo "<input type='text' id='plugaddr_ipfin0' value='' name='_ipfin0' size='3' ".
227-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
228-
echo "<input type='text' id='plugaddr_ipfin1' value='' name='_ipfin1' size='3' ".
229-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
230-
echo "<input type='text' id='plugaddr_ipfin2' value='' name='_ipfin2' size='3' ".
231-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
232-
echo "<input type='text' id='plugaddr_ipfin3' value='' name='_ipfin3' size='3' ".
233-
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
233+
$this->dropdownSubnet($ID>0 ? $this->fields["entities_id"] : $_SESSION["glpiactive_entity"]);
234234
echo "</td>";
235235

236236
if ($PluginAddressingConfig->fields["use_ping"]) {
237237
echo "<td>".__('Ping free Ip', 'addressing')."</td><td>";
238238
Dropdown::showYesNo('use_ping', $this->fields["use_ping"]);
239239
echo "</td>";
240240
} else {
241-
echo "<td>";
241+
echo "<td>";
242242
echo Html::hidden('use_ping', array('value' => 0));
243243
echo "</td><td></td>";
244244
//echo "<td><input type='hidden' name='use_ping' value='0'></td><td></td>";
245245
}
246246
echo "</tr>";
247247

248+
echo "<tr class='tab_bg_1'>";
249+
echo "<td>".__('First IP', 'addressing')."</td>"; // Subnet
250+
echo "<td>";
251+
echo "<input type='text' id='plugaddr_ipdeb0' value='' name='_ipdeb0' size='3' ".
252+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
253+
echo "<input type='text' id='plugaddr_ipdeb1' value='' name='_ipdeb1' size='3' ".
254+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
255+
echo "<input type='text' id='plugaddr_ipdeb2' value='' name='_ipdeb2' size='3' ".
256+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
257+
echo "<input type='text' id='plugaddr_ipdeb3' value='' name='_ipdeb3' size='3' ".
258+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
259+
echo "</td>";
260+
echo "<td></td>";
261+
echo "<td></td>";
262+
echo "</tr>";
263+
264+
echo "<tr class='tab_bg_1'>";
265+
echo "<td>".__('Last IP', 'addressing')."</td>"; // Mask
266+
echo "<td>";
267+
echo "<input type='text' id='plugaddr_ipfin0' value='' name='_ipfin0' size='3' ".
268+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
269+
echo "<input type='text' id='plugaddr_ipfin1' value='' name='_ipfin1' size='3' ".
270+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
271+
echo "<input type='text' id='plugaddr_ipfin2' value='' name='_ipfin2' size='3' ".
272+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
273+
echo "<input type='text' id='plugaddr_ipfin3' value='' name='_ipfin3' size='3' ".
274+
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
275+
echo "</td>";
276+
echo "<td></td>";
277+
echo "<td></td>";
278+
echo "</tr>";
279+
248280
echo "<tr class='tab_bg_1'>";
249281
echo "<td>".__('Report for the IP Range', 'addressing')."</td>"; // Mask
250282
echo "<td>";
@@ -261,13 +293,11 @@ function showForm ($ID, $options=array()) {
261293
echo "</tr>";
262294

263295
echo "<tr class='tab_bg_1'>";
264-
echo "<td colspan = '4'>";
265-
echo "<table cellpadding='2' cellspacing='2'><tr><td>";
266-
echo __('Comments')."</td></tr>";
267-
echo "<tr><td class='center'>".
268-
"<textarea cols='125' rows='3' name='comment'>".$this->fields["comment"]."</textarea>";
269-
echo "</td></tr></table>";
270-
echo "</td>";
296+
echo "<td>";
297+
echo __('Comments')."</td>";
298+
echo "<td class='center' colspan='3'>".
299+
"<textarea cols='125' rows='3' name='comment'>".$this->fields["comment"]."</textarea>";
300+
echo "</td></tr>";
271301

272302
$this->showFormButtons($options);
273303

0 commit comments

Comments
 (0)