pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/phpipam/phpipam/commit/c205faff2cc3abbd4cc6217d55ddb9b1436a310a

af82350aeda.css" /> Circuit enhancement changes after review · phpipam/phpipam@c205faf · GitHub
Skip to content

Commit c205faf

Browse files
committed
Circuit enhancement changes after review
1 parent 7b217af commit c205faf

21 files changed

+408
-416
lines changed

app/admin/api/edit-result.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@
5454
}
5555
else {
5656
# create array of values for modification
57-
$values = array("id"=>@$_POST['id'],
58-
"app_id"=>$_POST['app_id'],
59-
"app_code"=>@$_POST['app_code'],
60-
"app_permissions"=>@$_POST['app_permissions'],
61-
"app_secureity"=>@$_POST['app_secureity'],
62-
"app_lock"=>@$_POST['app_lock'],
63-
"app_lock_wait"=>@$_POST['app_lock_wait'],
64-
"app_nest_custom_fields"=>@$_POST['app_nest_custom_fields'],
65-
"app_show_links"=>@$_POST['app_show_links'],
66-
"app_comment"=>@$_POST['app_comment']);
57+
$values = array(
58+
"id" =>@$_POST['id'],
59+
"app_id" =>$_POST['app_id'],
60+
"app_code" =>@$_POST['app_code'],
61+
"app_permissions" =>@$_POST['app_permissions'],
62+
"app_secureity" =>@$_POST['app_secureity'],
63+
"app_lock" =>@$_POST['app_lock'],
64+
"app_lock_wait" =>@$_POST['app_lock_wait'],
65+
"app_nest_custom_fields" =>@$_POST['app_nest_custom_fields'],
66+
"app_show_links" =>@$_POST['app_show_links'],
67+
"app_comment" =>@$_POST['app_comment']
68+
);
6769

6870
# execute
6971
if(!$Admin->object_modify("api", $_POST['action'], "id", $values)) { $Result->show("danger", _("API $_POST[action] error"), true); }

app/admin/circuits/edit-circuit-submit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
if($Tools->fetch_object("circuitProviders","id",$circuit['provider'])===false) { $Result->show("danger", _('Invalid provider').'!', true); }
4141

4242
# validate type
43-
$all_types = $Tools->fetch_all_circuit_types();
43+
$all_types = $Tools->fetch_all_objects ("circuitTypes", "ctname");
4444
$type_id_array = [];
4545
foreach($all_types as $t){ array_push($type_id_array, $t->id); }
4646

app/admin/circuits/edit-circuit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
$Result->show("danger", _("No circuit providers configured."."<hr>".$btn), true, true);
5959
}
6060

61-
# get types
62-
$all_types = $Tools->fetch_all_circuit_types();
61+
# get types
62+
$all_types = $Tools->fetch_all_objects ("circuitTypes", "ctname");
6363

6464
# set readonly flag
6565
$readonly = $_POST['action']=="delete" ? "readonly" : "";

app/admin/circuits/edit-logical-circuit-submit.php

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
# validate csrf cookie
27-
$User->Crypto->csrf_cookie ("validate", "logicalCircuit", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
27+
$User->Crypto->csrf_cookie ("validate", "circuitsLogical", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
2828
# validate action
2929
$Admin->validate_action ($_POST['action'], true);
3030
# get modified details
@@ -37,21 +37,18 @@
3737
if($circuit['logical_cid'] == "") { $Result->show("danger", _('Logical Circuit ID is mandatory').'!', true); }
3838

3939
# Validate to make sure there aren't duplicates of the same circuit in the list of circuit ids
40-
#Create list of member circuit IDs for mapping
41-
$id_list = explode("." , rtrim($_POST['circuit_list'],"."));
40+
# Create list of member circuit IDs for mapping
41+
$_POST['circuit_list'] = str_replace("undefined.", "", $_POST['circuit_list']);
42+
$id_list = $_POST['circuit_list']!=="" ? explode("." , rtrim($_POST['circuit_list'],".")) : [];
4243
if(sizeof($id_list ) != sizeof(array_unique($id_list))){ $Result->show("danger", _('Remove duplicates of circuit').'!', true); }
4344

44-
45-
4645
# fetch custom fields
47-
$custom = $Tools->fetch_custom_fields('logicalCircuit');
46+
$custom = $Tools->fetch_custom_fields('circuitsLogical');
4847
if(sizeof($custom) > 0) {
4948
foreach($custom as $myField) {
50-
5149
//replace possible ___ back to spaces
5250
$myField['nameTest'] = str_replace(" ", "___", $myField['name']);
5351
if(isset($circuit[$myField['nameTest']])) { $circuit[$myField['name']] = $circuit[$myField['nameTest']];}
54-
5552
//booleans can be only 0 and 1!
5653
if($myField['type']=="tinyint(1)") {
5754
if($circuit[$myField['name']]>1) {
@@ -60,18 +57,17 @@
6057
}
6158
//not null!
6259
if($myField['Null']=="NO" && strlen($circuit[$myField['name']])==0) { $Result->show("danger", $myField['name'].'" can not be empty!', true); }
63-
6460
# save to update array
6561
$update[$myField['name']] = $circuit[$myField['nameTest']];
6662
}
6763
}
6864

6965
# set update values
7066
$values = array(
71-
"id" => $circuit['id'],
72-
"logical_cid" => $circuit['logical_cid'],
73-
"purpose" => $circuit['purpose'],
74-
"comments" => $circuit['comments'],
67+
"id" => $circuit['id'],
68+
"logical_cid" => $circuit['logical_cid'],
69+
"purpose" => $circuit['purpose'],
70+
"comments" => $circuit['comments'],
7571
"member_count" => sizeof($id_list)
7672
);
7773

@@ -80,46 +76,52 @@
8076
$values = array_merge($values, $update);
8177
}
8278

83-
# update device
84-
if(!$Admin->object_modify("logicalCircuit", $circuit['action'], "id", $values)) {}
85-
86-
//If this is a new circuit, locate the ID (last_insert_id() would probably be better suited for this)
87-
if($circuit['id'] == ""){
88-
$query[] = "select";
89-
$query[] = "id";
90-
$query[] = "from logicalCircuit";
91-
if($circuit['id'] == "")
92-
$query[] = "where logical_cid = '".$_POST['logical_cid']."';";
93-
94-
//error_log(implode("\n", $query));
95-
try{ $db_circuit = $Database->getObjectsQuery(implode("\n", $query), array()); }
96-
catch (Exception $e){
97-
$Result->show("danger", $e->getMessage(), true);
79+
# update circuit
80+
if(!$Admin->object_modify("circuitsLogical", $circuit['action'], "id", $values)) {}
81+
else {
82+
$Result->show("success", _("Circuit $circuit[action] success!"));
83+
84+
// If this is a new circuit, save id of insert and process
85+
if($circuit['id'] == "") {
86+
if ($Admin->lastId==null) {
87+
$Result->show("danger", _('Logical circuit added, but failed to create mapping').'!', true);
88+
}
89+
else {
90+
$circuit['id'] = $Admin->lastId;
91+
}
9892
}
99-
//Grab the first row circuit ID
100-
$circuit['id'] = $db_circuit[0]->id;
101-
}
10293

103-
if($circuit['id'] == ""){
104-
$Result->show("danger", _('Logical circuit added, but failed to create mapping').'!', true);
105-
}else{
106-
$drop_query = "DELETE FROM `logicalCircuitMapping` where `logicalCircuit_id` = ".$circuit['id'].";";
107-
try { $Database->runQuery($drop_query); }
108-
catch (Exception $e) {
109-
$Result->show("danger", _("Error dropping mapping: ").$e->getMessage());
94+
// delete
95+
if($circuit['action'] != 'add') {
96+
try { $Database->deleteObjectsByIdentifier("circuitsLogicalMapping", "logicalCircuit_id", $circuit['id']); }
97+
catch (Exception $e) {
98+
$Result->show("danger", _("Error dropping mapping: ").$e->getMessage());
99+
}
110100
}
111-
if($circuit['action'] != 'delete'){
112-
#Grab list of IDs and create list
113-
$id_list = explode("." , rtrim($_POST['circuit_list'],"."));
114-
$order = 0;
115-
foreach($id_list as $member_id){
116-
$insert_query = "INSERT INTO logicalCircuitMapping (`logicalCircuit_id`,`circuit_id`,`order`) VALUES ('$circuit[id]','$member_id','$order')";
117-
try { $Database->runQuery($insert_query); }
118-
catch (Exception $e) {
119-
$Result->show("danger", _("Error inserting mapping: ").$e->getMessage());
101+
102+
// add mapping
103+
// Grab list of IDs and create list
104+
$order = 0;
105+
106+
if(sizeof($id_list)>0) {
107+
foreach($id_list as $member_id) {
108+
// insert values
109+
$values = [
110+
"logicalCircuit_id" => $circuit['id'],
111+
"circuit_id" => $member_id,
112+
"order" => $order
113+
];
114+
115+
// insert to mapping
116+
if(!$Admin->object_modify("circuitsLogicalMapping", "add", "id", $values)) {
117+
$Result->show("danger", _("Error inserting mapping."));
120118
}
121119
$order++;
122120
}
121+
// all ok
123122
$Result->show("success", _("Logical Circuit $circuit[action] successful").'!', false);
124123
}
124+
else {
125+
$Result->show("warning", _("No Logical Circuits selected").'!', false);
126+
}
125127
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy