$custom = $Tools->fetch_custom_fields('devices'); if (sizeof($custom) > 0) { foreach ($custom as $myField) { //booleans can be only 0 and 1! if ($myField['type'] == "tinyint(1)") { if ($device[$myField['name']] > 1) { $device[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($device[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $update[$myField['name']] = $device[$myField['name']]; } } # set update values $values = array("id" => @$device['switchId'], "hostname" => @$device['hostname'], "ip_addr" => @$device['ip_addr'], "type" => @$device['type'], "vendor" => @$device['vendor'], "model" => @$device['model'], "description" => @$device['description'], "sections" => @$device['sections']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # update device if (!$Admin->object_modify("devices", $_POST['action'], "id", $values)) { } else { $Result->show("success", _("Device {$device['action']} successfull") . '!', false); } # remove all references from subnets and ip addresses $Admin->remove_object_references("subnets", "device", $values["id"]); $Admin->remove_object_references("ipaddresses", "switch", $values["id"]);
} } if (strlen($_POST['name']) == 0) { $Result->show("danger", _('Name is required') . '!', true); } # formulate update query $values = array("vlanId" => @$_POST['vlanId'], "number" => $_POST['number'], "name" => $_POST['name'], "description" => @$_POST['description'], "domainId" => $_POST['domainId']); # append custom if (sizeof($custom) > 0) { foreach ($custom as $myField) { # replace possible ___ back to spaces! $myField['nameTest'] = str_replace(" ", "___", $myField['name']); if (isset($_POST[$myField['nameTest']])) { $values[$myField['name']] = @$_POST[$myField['nameTest']]; } } } # update if (!$Admin->object_modify("vlans", $_POST['action'], "vlanId", $values)) { $Result->show("danger", _("Failed to {$_POST['action']} VLAN") . '!', true); } else { $Result->show("success", _("VLAN {$_POST['action']} successfull") . '!', false); } # remove all references if delete if ($_POST['action'] == "delete") { $Admin->remove_object_references("subnets", "vlanId", $_POST['vlanId']); } # print value for on the fly if ($_POST['action'] == "add") { print '<p id="vlanidforonthefly" style="display:none">' . $Admin->lastId . '</p>'; }
$Result->show("danger", _("Name is mandatory"), true); } if ($_POST['namesrv1'] == "") { $Result->show("danger", _("Primary nameserver is mandatory"), true); } // set sections if (@$_POST['nameserverId'] != 1) { foreach ($_POST as $key => $line) { if (strlen(strstr($key, "section-")) > 0) { $key2 = str_replace("section-", "", $key); $temp[] = $key2; unset($_POST[$key]); } } # glue sections together $_POST['permissions'] = sizeof($temp) > 0 ? implode(";", $temp) : null; } else { $_POST['permissions'] = ""; } # set update array $values = array("id" => @$_POST['nameserverId'], "name" => $_POST['name'], "namesrv1" => $_POST['namesrv1'], "namesrv2" => $_POST['namesrv2'], "namesrv3" => $_POST['namesrv3'], "description" => $_POST['description'], "permissions" => $_POST['permissions']); # update if (!$Admin->object_modify("nameservers", $_POST['action'], "nameserverid", $values)) { $Result->show("danger", _("Failed to {$_POST['action']} nameserver set") . '!', true); } else { $Result->show("success", _("Nameserver set {$_POST['action']} successfull") . '!', false); } # remove all references if delete if ($_POST['action'] == "delete") { $Admin->remove_object_references("nameservers", "id", $_POST['nameserverId']); }
if (sizeof($custom) > 0) { foreach ($custom as $myField) { //booleans can be only 0 and 1! if ($myField['type'] == "tinyint(1)") { if ($rack[$myField['name']] > 1) { $rack[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($rack[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $update[$myField['name']] = $rack[$myField['name']]; } } # set update values $values = array("id" => @$rack['rackid'], "name" => @$rack['name'], "size" => @$rack['size'], "location" => @$rack['location'], "description" => @$rack['description']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # update rack if (!$Admin->object_modify("racks", $_POST['action'], "id", $values)) { } else { $Result->show("success", _("Rack {$rack['action']} successfull") . '!', false); } if ($_POST['action'] == "delete") { # remove all references from subnets and ip addresses $Admin->remove_object_references("devices", "rack", $values["id"]); }
if ($myField['Null'] == "NO" && strlen($device[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $update[$myField['name']] = $device[$myField['nameTest']]; } } # set update values $values = array("id" => @$device['switchId'], "hostname" => @$device['hostname'], "ip_addr" => @$device['ip_addr'], "type" => @$device['type'], "description" => @$device['description'], "sections" => @$device['sections'], "location" => @$device['location_item']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # rack if (strlen(@$device['rack'] > 0)) { $values['rack'] = $device['rack']; $values['rack_start'] = $device['rack_start']; $values['rack_size'] = $device['rack_size']; } # update device if (!$Admin->object_modify("devices", $_POST['action'], "id", $values)) { } else { $Result->show("success", _("Device {$device['action']} successfull") . '!', false); } if ($_POST['action'] == "delete") { # remove all references from subnets and ip addresses $Admin->remove_object_references("subnets", "device", $values["id"]); $Admin->remove_object_references("ipaddresses", "switch", $values["id"]); $Admin->remove_object_references("pstnPrefixes", "deviceId", $values["id"]); $Admin->remove_object_references("pstnNumbers", "deviceId", $values["id"]); }
if ($_POST[$myField['name']] > 1) { $_POST[$myField['name']] = 0; } } //not null! if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) { $Result->show("danger", $myField['name'] . '" can not be empty!', true); } # save to update array $update[$myField['name']] = $_POST[$myField['name']]; } } // set values $values = array("id" => @$_POST['id'], "name" => $_POST['name'], "prefix" => $_POST['prefix'], "start" => $_POST['start'], "stop" => $_POST['stop'], "deviceId" => $_POST['deviceId'], "description" => $_POST['description']); # custom fields if (isset($update)) { $values = array_merge($values, $update); } # execute update if (!$Admin->object_modify("pstnPrefixes", $_POST['action'], "id", $values)) { $Result->show("danger", _("Prefix {$_POST['action']} failed"), false); } else { $Result->show("success", _("Prefix {$_POST['action']} successful"), false); } # if delete remove all slaves if ($_POST['action'] == "delete") { $values['master'] = $values['id']; # remove all references from prefixes and remove all numbers $Admin->remove_object_references("pstnPrefixes", "master", $values["id"], 0); $Admin->object_modify("pstnNumbers", "delete", "prefix", $values); }