Skip to content

Commit

Permalink
see #7
Browse files Browse the repository at this point in the history
Addition of the location and the domain internet
  • Loading branch information
amma35 committed Dec 2, 2016
1 parent cc4685a commit fd23926
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 69 deletions.
2 changes: 1 addition & 1 deletion addressing.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function plugaddr_IsFilter(msg) {

function nameIsThere(params) {
var root_doc = params;
var nameElm = $('input[id*="textfield_name"]');
var nameElm = $('input[id*="name_reserveip"]');
var typeElm = $('select[name="type"]');
var divNameItemElm = $('div[id="nameItem"]');
$.ajax({
Expand Down
15 changes: 13 additions & 2 deletions ajax/addressing.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
Html::header_nocache();
if(isset($_POST['action']) && $_POST['action'] == 'isName'){
$item = new $_POST['type']();
$datas = $item->find("`name` = '".$_POST['name']."'");
$datas = $item->find("`name` LIKE '".$_POST['name']."'");
if(count($datas) > 0){
echo json_encode(true);
}else{
Expand All @@ -48,8 +48,19 @@
} else {
_e('Access denied');
}
}elseif(isset($_POST['action']) && $_POST['action'] == 'networkip'){

}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_networkip'){
IPNetwork::showIPNetworkProperties($_POST['entities_id']);

}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_location'){
Dropdown::show('Location', array('name' => "locations_id",
'value' => $_POST["value"],
'entity' => $_POST['entities_id']));

}elseif(isset($_POST['action']) && $_POST['action'] == 'entities_fqdn'){
Dropdown::show('FQDN', array('name' => "fqdns_id",
'value' => $_POST["value"],
'entity'=> $_POST['entities_id']));

}elseif(isset($_POST['action']) && $_POST['action'] == 'showForm') {
$PluginAddressingReserveip = new PluginAddressingReserveip();
Expand Down
11 changes: 8 additions & 3 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function plugin_addressing_install() {
&&!TableExists("glpi_plugin_addressing")
&& !TableExists("glpi_plugin_addressing_configs")) {

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

} else {

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

//Version 3.0.0
if (!FieldExists("glpi_plugin_addressing_addressings", "locations_id") && !FieldExists("glpi_plugin_addressing_addressings", "fqdns_id")) {
$DB->runFile(GLPI_ROOT ."/plugins/addressing/sql/update-3.0.0.sql");
}

}

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

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

$migration = new Migration("2.3.0");
$migration = new Migration("3.0.0");
$tables = array("glpi_plugin_addressing_addressings",
"glpi_plugin_addressing_configs");

Expand Down
98 changes: 64 additions & 34 deletions inc/addressing.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ function getSearchOptions() {
$tab[4]['name'] = __('Ping free Ip', 'addressing');
$tab[4]['datatype'] = 'bool';

$tab[5]['table'] = 'glpi_locations';
$tab[5]['field'] = 'name';
$tab[5]['name'] = __('Location');
$tab[5]['datatype'] = 'dropdown';

$tab[6]['table'] = 'glpi_fqdns';
$tab[6]['field'] = 'name';
$tab[6]['name'] = FQDN::getTypeName(1);
$tab[6]['datatype'] = 'dropdown';

$tab[30]['table'] = $this->getTable();
$tab[30]['field'] = 'id';
$tab[30]['name'] = __('ID');
Expand Down Expand Up @@ -159,28 +169,31 @@ function showForm ($ID, $options=array()) {
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>".__('Select the network', 'addressing')."</td>";
echo "<td>".__('Location')."</td>";
echo "<td>";
Dropdown::show('Network', array('name' => "networks_id",
'value' => $this->fields["networks_id"]));
Dropdown::show('Location', array('name' => "locations_id",
'value' => $this->fields["locations_id"],
'entity' => $this->fields['entities_id']));
echo "</td>";

if ($PluginAddressingConfig->fields["free_ip"]) {
echo "<td>".__('Free Ip', 'addressing')."</td><td>";
Dropdown::showYesNo('free_ip', $this->fields["free_ip"]);
echo "</td>";
} else {
echo "<td>";
echo "<td>";
echo Html::hidden('free_ip', array('value' => 0));
echo "</td><td></td>";
//echo "<td><input type='hidden' name='free_ip' value='0'></td><td></td>";
}
echo "</tr>";

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

if ($PluginAddressingConfig->fields["double_ip"]) {
Expand All @@ -189,62 +202,81 @@ function showForm ($ID, $options=array()) {
echo "</td>";
} else {
//echo "<td><input type='hidden' name='double_ip' value='0'></td><td></td>";
echo "<td>";
echo "<td>";
echo Html::hidden('double_ip', array('value' => 0));
echo "</td><td></td>";
}
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>".__('First IP', 'addressing')."</td>"; // Subnet
echo "<td>".__('Select the network', 'addressing')."</td>";
echo "<td>";
echo "<input type='text' id='plugaddr_ipdeb0' value='' name='_ipdeb0' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb1' value='' name='_ipdeb1' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb2' value='' name='_ipdeb2' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb3' value='' name='_ipdeb3' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
Dropdown::show('Network', array('name' => "networks_id",
'value' => $this->fields["networks_id"]));
echo "</td>";

if ($PluginAddressingConfig->fields["reserved_ip"]) {
echo "<td>".__('Reserved IP', 'addressing')."</td><td>";
Dropdown::showYesNo('reserved_ip',$this->fields["reserved_ip"]);
echo "</td>";
} else {
echo "<td>";
echo "<td>";
echo Html::hidden('reserved_ip', array('value' => 0));
echo "</td><td></td>";
//echo "<td><input type='hidden' name='reserved_ip' value='0'></td><td></td>";
}
echo "</tr>";

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

if ($PluginAddressingConfig->fields["use_ping"]) {
echo "<td>".__('Ping free Ip', 'addressing')."</td><td>";
Dropdown::showYesNo('use_ping', $this->fields["use_ping"]);
echo "</td>";
} else {
echo "<td>";
echo "<td>";
echo Html::hidden('use_ping', array('value' => 0));
echo "</td><td></td>";
//echo "<td><input type='hidden' name='use_ping' value='0'></td><td></td>";
}
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>".__('First IP', 'addressing')."</td>"; // Subnet
echo "<td>";
echo "<input type='text' id='plugaddr_ipdeb0' value='' name='_ipdeb0' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb1' value='' name='_ipdeb1' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb2' value='' name='_ipdeb2' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipdeb3' value='' name='_ipdeb3' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
echo "</td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>".__('Last IP', 'addressing')."</td>"; // Mask
echo "<td>";
echo "<input type='text' id='plugaddr_ipfin0' value='' name='_ipfin0' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipfin1' value='' name='_ipfin1' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipfin2' value='' name='_ipfin2' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>.";
echo "<input type='text' id='plugaddr_ipfin3' value='' name='_ipfin3' size='3' ".
"onChange='plugaddr_ChangeNumber(\"".__('Invalid data !!', 'addressing')."\");'>";
echo "</td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td>".__('Report for the IP Range', 'addressing')."</td>"; // Mask
echo "<td>";
Expand All @@ -261,13 +293,11 @@ function showForm ($ID, $options=array()) {
echo "</tr>";

echo "<tr class='tab_bg_1'>";
echo "<td colspan = '4'>";
echo "<table cellpadding='2' cellspacing='2'><tr><td>";
echo __('Comments')."</td></tr>";
echo "<tr><td class='center'>".
"<textarea cols='125' rows='3' name='comment'>".$this->fields["comment"]."</textarea>";
echo "</td></tr></table>";
echo "</td>";
echo "<td>";
echo __('Comments')."</td>";
echo "<td class='center' colspan='3'>".
"<textarea cols='125' rows='3' name='comment'>".$this->fields["comment"]."</textarea>";
echo "</td></tr>";

$this->showFormButtons($options);

Expand Down
Loading

0 comments on commit fd23926

Please sign in to comment.