@@ -19,43 +19,43 @@ |
||
19 | 19 | |
20 | 20 | # validate the action type |
21 | 21 | if($_POST['action'] != 'add' && $_POST['action'] != 'delete' && $_POST['action'] != 'edit'){ |
22 | - $Result->show("danger", _("Invalid action."), true); |
|
22 | + $Result->show("danger", _("Invalid action."), true); |
|
23 | 23 | } |
24 | 24 | # check the zone alias. valid values are alphanumeric characters and special characters like ".-_ " |
25 | 25 | if($_POST['alias'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['alias'])) { |
26 | - $Result->show("danger", _("Invalid zone alias value."), true); |
|
26 | + $Result->show("danger", _("Invalid zone alias value."), true); |
|
27 | 27 | } |
28 | 28 | # check the interface name. valid values are alphanumeric characters and special characters like ".-_/ " |
29 | 29 | if($_POST['interface'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['interface'])) { |
30 | - $Result->show("danger", _("Invalid interface."), true); |
|
30 | + $Result->show("danger", _("Invalid interface."), true); |
|
31 | 31 | } |
32 | 32 | if ($_POST['action'] != 'delete') { |
33 | - # check the zone ID. valid value: integer |
|
34 | - if(!preg_match('/^[0-9]+$/i',$_POST['zoneId'])) { |
|
35 | - $Result->show("danger", _("Invalid zone ID."), true); |
|
36 | - } elseif (preg_match('/^0$/i',$_POST['zoneId'])) { |
|
37 | - $Result->show("danger", _("Invalid zone ID."), true); |
|
38 | - } |
|
39 | - # check the device ID. valid value: integer |
|
40 | - if(!preg_match('/^[0-9]+$/i',$_POST['deviceId'])) { |
|
41 | - $Result->show("danger", _("Invalid device ID."), true); |
|
42 | - } elseif (preg_match('/^0$/i',$_POST['deviceId'])) { |
|
43 | - $Result->show("danger", _("Please select a device."), true); |
|
44 | - } |
|
45 | - # check the mapping ID. valid value: integer |
|
46 | - if($_POST['id'] && !preg_match('/^[0-9]+$/i',$_POST['id'])) { |
|
47 | - $Result->show("danger", _("Invalid mapping ID."), true); |
|
48 | - } |
|
33 | + # check the zone ID. valid value: integer |
|
34 | + if(!preg_match('/^[0-9]+$/i',$_POST['zoneId'])) { |
|
35 | + $Result->show("danger", _("Invalid zone ID."), true); |
|
36 | + } elseif (preg_match('/^0$/i',$_POST['zoneId'])) { |
|
37 | + $Result->show("danger", _("Invalid zone ID."), true); |
|
38 | + } |
|
39 | + # check the device ID. valid value: integer |
|
40 | + if(!preg_match('/^[0-9]+$/i',$_POST['deviceId'])) { |
|
41 | + $Result->show("danger", _("Invalid device ID."), true); |
|
42 | + } elseif (preg_match('/^0$/i',$_POST['deviceId'])) { |
|
43 | + $Result->show("danger", _("Please select a device."), true); |
|
44 | + } |
|
45 | + # check the mapping ID. valid value: integer |
|
46 | + if($_POST['id'] && !preg_match('/^[0-9]+$/i',$_POST['id'])) { |
|
47 | + $Result->show("danger", _("Invalid mapping ID."), true); |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | # build the query parameter arrary |
53 | 53 | $values = array('id' => $_POST['id'], |
54 | - 'zoneId' => $_POST['zoneId'], |
|
55 | - 'alias' => $_POST['alias'], |
|
56 | - 'deviceId' => $_POST['deviceId'], |
|
57 | - 'interface' => $_POST['interface'] |
|
58 | - ); |
|
54 | + 'zoneId' => $_POST['zoneId'], |
|
55 | + 'alias' => $_POST['alias'], |
|
56 | + 'deviceId' => $_POST['deviceId'], |
|
57 | + 'interface' => $_POST['interface'] |
|
58 | + ); |
|
59 | 59 | # modify |
60 | 60 | if(!$Zones->modify_mapping($_POST['action'],$values)) { $Result->show("danger", _("Cannot add mapping"), true); } |
61 | 61 | else { $Result->show("success", _("Mapping modified successfully"), true); } |
@@ -27,28 +27,28 @@ |
||
27 | 27 | |
28 | 28 | # check the zone alias. valid values are alphanumeric characters and special characters like ".-_ " |
29 | 29 | if($_POST['alias'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['alias'])) { |
30 | - $Result->show("danger", _("Invalid zone alias value."), true); |
|
30 | + $Result->show("danger", _("Invalid zone alias value."), true); |
|
31 | 31 | } |
32 | 32 | # check the interface name. valid values are alphanumeric characters and special characters like ".-_/ " |
33 | 33 | if($_POST['interface'] && !preg_match('/^[0-9a-zA-Z.\/\-_ ]+$/i',$_POST['interface'])) { |
34 | - $Result->show("danger", _("Invalid interface."), true); |
|
34 | + $Result->show("danger", _("Invalid interface."), true); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | # check if there is any device mapping necessary |
38 | 38 | if ($_POST['deviceId']) { |
39 | - # build the query parameter arrary |
|
40 | - $values = array('id' => '', |
|
41 | - 'zoneId' => $_POST['zoneId'], |
|
42 | - 'alias' => $_POST['alias'], |
|
43 | - 'deviceId' => $_POST['deviceId'], |
|
44 | - 'interface' => $_POST['interface'] |
|
45 | - ); |
|
46 | - # modify |
|
47 | - if(!$Zones->modify_mapping('add',$values)) { $Result->show("danger", _("Cannot add mapping"), true); } |
|
39 | + # build the query parameter arrary |
|
40 | + $values = array('id' => '', |
|
41 | + 'zoneId' => $_POST['zoneId'], |
|
42 | + 'alias' => $_POST['alias'], |
|
43 | + 'deviceId' => $_POST['deviceId'], |
|
44 | + 'interface' => $_POST['interface'] |
|
45 | + ); |
|
46 | + # modify |
|
47 | + if(!$Zones->modify_mapping('add',$values)) { $Result->show("danger", _("Cannot add mapping"), true); } |
|
48 | 48 | } |
49 | 49 | # check and then add the network to the zone if possible |
50 | 50 | if($Zones->check_zone_network($_POST['subnetId'])) { |
51 | - if (!$Zones->add_zone_network($_POST['zoneId'],$_POST['subnetId'])) { $Result->show("danger", _("Cannot add this network to a zone."), true); } |
|
52 | - else { $Result->show("success", _("Zone modified successfully"), true); } |
|
51 | + if (!$Zones->add_zone_network($_POST['zoneId'],$_POST['subnetId'])) { $Result->show("danger", _("Cannot add this network to a zone."), true); } |
|
52 | + else { $Result->show("success", _("Zone modified successfully"), true); } |
|
53 | 53 | } |
54 | 54 | ?> |
55 | 55 | \ No newline at end of file |
@@ -47,10 +47,10 @@ |
||
47 | 47 | <select name="zoneId" class="form-control input-sm input-w-auto input-max-200 checkMapping"> |
48 | 48 | <option value="0"><?php print _('Select a Zone'); ?></option> |
49 | 49 | <?php |
50 | - foreach ($firewallZones as $firewallZone) { |
|
51 | - print '<option value="'.$firewallZone->id.'">'.$firewallZone->zone.' '.(($firewallZone->description) ? ' ('.$firewallZone->description.')' : '' ).'</option>'; |
|
52 | - } |
|
53 | - ?> |
|
50 | + foreach ($firewallZones as $firewallZone) { |
|
51 | + print '<option value="'.$firewallZone->id.'">'.$firewallZone->zone.' '.(($firewallZone->description) ? ' ('.$firewallZone->description.')' : '' ).'</option>'; |
|
52 | + } |
|
53 | + ?> |
|
54 | 54 | </select> |
55 | 55 | </td> |
56 | 56 | </tr> |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | # get latest version */ |
12 | 12 | if(!$version = $Tools->check_latest_phpipam_version()) { $Result->show("danger", _("Version check failed").'!', false); } |
13 | 13 | else { |
14 | - //print result |
|
15 | - if($User->settings->version == $version) { $Result->show("success", _('Latest version').' ('. $User->settings->version .') '._('already installed').'!', false); } |
|
16 | - else if ($User->settings->version > $version) { $Result->show("success", _('Development version').' ('. $User->settings->version .') '._('installed! Latest production version is').' '. $version, false);} |
|
17 | - else { $Result->show("danger", _('New version of phpipam available').':</b><hr>'._('Installed version').': '.$User->settings->version."<br>"._('Available version').': '. $version."<br><br>"._('You can download new version').' <a href="https://sourceforge.net/projects/phpipam/files/current/phpipam-'. $version .'.tar/download">'._('here').'</a>.', false); } |
|
14 | + //print result |
|
15 | + if($User->settings->version == $version) { $Result->show("success", _('Latest version').' ('. $User->settings->version .') '._('already installed').'!', false); } |
|
16 | + else if ($User->settings->version > $version) { $Result->show("success", _('Development version').' ('. $User->settings->version .') '._('installed! Latest production version is').' '. $version, false);} |
|
17 | + else { $Result->show("danger", _('New version of phpipam available').':</b><hr>'._('Installed version').': '.$User->settings->version."<br>"._('Available version').': '. $version."<br><br>"._('You can download new version').' <a href="https://sourceforge.net/projects/phpipam/files/current/phpipam-'. $version .'.tar/download">'._('here').'</a>.', false); } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | # release and commit logs |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | print "<div class='log-print releaselog' style='display:none'>"; |
44 | 44 | print "<h4 style='margin-top:40px;'>Release log</h4><hr>"; |
45 | 45 | foreach ($Tools->phpipam_releases as $r) { |
46 | - // pre-release ? |
|
47 | - $prerelease = !is_numeric(str_replace("Version", "", $r->title)) ? "<span class='label label-danger'>Prerelease</span>" : ""; |
|
48 | - |
|
49 | - // title |
|
50 | - print "<h5><i class='fa fa-angle-double-right'></i> $r->title $prerelease</h5>"; |
|
51 | - // date |
|
52 | - print "<div style='padding-left:20px;margin-bottom:20px;'>"; |
|
53 | - print "<span class='text-muted'>Released on ".date("Y-M-d", strtotime($r->updated))."</span> "; |
|
54 | - print "<div style='padding-top:10px;'>$r->content</div>"; |
|
55 | - // tag |
|
56 | - print "<a class='btn btn-xs btn-default' href='http://github.com".$r->link->{'@attributes'}->href."'>Download (GitHub)</a>"; |
|
57 | - print "</div>"; |
|
46 | + // pre-release ? |
|
47 | + $prerelease = !is_numeric(str_replace("Version", "", $r->title)) ? "<span class='label label-danger'>Prerelease</span>" : ""; |
|
48 | + |
|
49 | + // title |
|
50 | + print "<h5><i class='fa fa-angle-double-right'></i> $r->title $prerelease</h5>"; |
|
51 | + // date |
|
52 | + print "<div style='padding-left:20px;margin-bottom:20px;'>"; |
|
53 | + print "<span class='text-muted'>Released on ".date("Y-M-d", strtotime($r->updated))."</span> "; |
|
54 | + print "<div style='padding-top:10px;'>$r->content</div>"; |
|
55 | + // tag |
|
56 | + print "<a class='btn btn-xs btn-default' href='http://github.com".$r->link->{'@attributes'}->href."'>Download (GitHub)</a>"; |
|
57 | + print "</div>"; |
|
58 | 58 | } |
59 | 59 | print "</div>"; |
60 | 60 | } |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | # commit log for devel |
63 | 63 | if ($User->settings->version > $version) { |
64 | 64 | |
65 | - print "<div class='log-print gitlog' style='display:none'>"; |
|
66 | - |
|
67 | - # check |
|
68 | - $commit_log = shell_exec("git log"); |
|
69 | - |
|
70 | - if ($commit_log=="NULL") { |
|
71 | - $Result->show("info", "Git not available", false); |
|
72 | - } |
|
73 | - else { |
|
74 | - // title |
|
75 | - print "<h4 style='margin-top:40px;'>Commit log (local)</h4><hr>"; |
|
76 | - // split commits |
|
77 | - $commit_log = array_filter(explode("commit ", $commit_log)); |
|
78 | - |
|
79 | - // loop |
|
80 | - foreach ($commit_log as $commit) { |
|
81 | - // lines to array |
|
82 | - $lines = explode("\n", $commit); |
|
83 | - // commit |
|
84 | - unset($out); |
|
85 | - $out['commit'] = $lines[0]; |
|
86 | - // remove unneeded |
|
87 | - foreach ($lines as $k=>$l) { |
|
88 | - if (strpos($l, "Author")!==false) { $out['author'] = substr($l, 7); unset($lines[$k]); } |
|
89 | - elseif (strpos($l, "Date")!==false) { $out['date'] = substr($l, 7); unset($lines[$k]); } |
|
90 | - elseif (strpos($l, "Merge:")!==false) { $out['pr'] = $l; unset($lines[$k]); } |
|
91 | - elseif (strlen(trim($l))==0) { unset($lines[$k]); } |
|
92 | - unset($lines[0]); |
|
93 | - } |
|
94 | - // merge |
|
95 | - $lines = implode("<br>", array_filter($lines)); |
|
96 | - |
|
97 | - // title |
|
98 | - print "<h5><i class='fa fa-angle-double-right'></i> $out[commit]</h5>"; |
|
99 | - // date |
|
100 | - print "<div style='padding-left:20px;margin-bottom:20px;'>"; |
|
101 | - print "$out[author] <span class='text-muted'>(pushed on $out[date])</span>"; |
|
102 | - print "<div style='padding:10px;background:white;max-width:400px;border-radius:6px;border:1px solid #ddd;'>$lines</div>"; |
|
103 | - // tag |
|
104 | - print "<a class='btn btn-xs btn-default' style='margin-top:3px;' href='https://github.com/phpipam/phpipam/commit/$out[commit]' target='_blank'>View</a>"; |
|
105 | - print "</div>"; |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - print "</div>"; |
|
65 | + print "<div class='log-print gitlog' style='display:none'>"; |
|
66 | + |
|
67 | + # check |
|
68 | + $commit_log = shell_exec("git log"); |
|
69 | + |
|
70 | + if ($commit_log=="NULL") { |
|
71 | + $Result->show("info", "Git not available", false); |
|
72 | + } |
|
73 | + else { |
|
74 | + // title |
|
75 | + print "<h4 style='margin-top:40px;'>Commit log (local)</h4><hr>"; |
|
76 | + // split commits |
|
77 | + $commit_log = array_filter(explode("commit ", $commit_log)); |
|
78 | + |
|
79 | + // loop |
|
80 | + foreach ($commit_log as $commit) { |
|
81 | + // lines to array |
|
82 | + $lines = explode("\n", $commit); |
|
83 | + // commit |
|
84 | + unset($out); |
|
85 | + $out['commit'] = $lines[0]; |
|
86 | + // remove unneeded |
|
87 | + foreach ($lines as $k=>$l) { |
|
88 | + if (strpos($l, "Author")!==false) { $out['author'] = substr($l, 7); unset($lines[$k]); } |
|
89 | + elseif (strpos($l, "Date")!==false) { $out['date'] = substr($l, 7); unset($lines[$k]); } |
|
90 | + elseif (strpos($l, "Merge:")!==false) { $out['pr'] = $l; unset($lines[$k]); } |
|
91 | + elseif (strlen(trim($l))==0) { unset($lines[$k]); } |
|
92 | + unset($lines[0]); |
|
93 | + } |
|
94 | + // merge |
|
95 | + $lines = implode("<br>", array_filter($lines)); |
|
96 | + |
|
97 | + // title |
|
98 | + print "<h5><i class='fa fa-angle-double-right'></i> $out[commit]</h5>"; |
|
99 | + // date |
|
100 | + print "<div style='padding-left:20px;margin-bottom:20px;'>"; |
|
101 | + print "$out[author] <span class='text-muted'>(pushed on $out[date])</span>"; |
|
102 | + print "<div style='padding:10px;background:white;max-width:400px;border-radius:6px;border:1px solid #ddd;'>$lines</div>"; |
|
103 | + // tag |
|
104 | + print "<a class='btn btn-xs btn-default' style='margin-top:3px;' href='https://github.com/phpipam/phpipam/commit/$out[commit]' target='_blank'>View</a>"; |
|
105 | + print "</div>"; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + print "</div>"; |
|
110 | 110 | } |
111 | 111 | ?> |
@@ -21,16 +21,16 @@ |
||
21 | 21 | |
22 | 22 | # set update query |
23 | 23 | $values = array("id"=>1, |
24 | - "mtype"=>$_POST['mtype'], |
|
25 | - "msecure"=>@$_POST['msecure'], |
|
26 | - "mauth"=>@$_POST['mauth'], |
|
27 | - "mserver"=>@$_POST['mserver'], |
|
28 | - "mport"=>@$_POST['mport'], |
|
29 | - "muser"=>@$_POST['muser'], |
|
30 | - "mpass"=>@$_POST['mpass'], |
|
31 | - "mAdminName"=>@$_POST['mAdminName'], |
|
32 | - "mAdminMail"=>@$_POST['mAdminMail'] |
|
33 | - ); |
|
24 | + "mtype"=>$_POST['mtype'], |
|
25 | + "msecure"=>@$_POST['msecure'], |
|
26 | + "mauth"=>@$_POST['mauth'], |
|
27 | + "mserver"=>@$_POST['mserver'], |
|
28 | + "mport"=>@$_POST['mport'], |
|
29 | + "muser"=>@$_POST['muser'], |
|
30 | + "mpass"=>@$_POST['mpass'], |
|
31 | + "mAdminName"=>@$_POST['mAdminName'], |
|
32 | + "mAdminMail"=>@$_POST['mAdminMail'] |
|
33 | + ); |
|
34 | 34 | |
35 | 35 | # update |
36 | 36 | if(!$Admin->object_modify("settingsMail", "edit", "id", $values)) { $Result->show("danger", _('Cannot update settings').'!', true); } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | # verify admin mail and name |
23 | 23 | if (strlen($mail_settings->mAdminMail)==0 || strlen($mail_settings->mAdminName)==0) { |
24 | - $Result->show("danger", _("Mail settings are missing. Please set admin mail and name!"), true); |
|
24 | + $Result->show("danger", _("Mail settings are missing. Please set admin mail and name!"), true); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | |
43 | 43 | # try to send |
44 | 44 | try { |
45 | - $phpipam_mail->Php_mailer->setFrom($_POST['mAdminMail'], $_POST['mAdminName']); |
|
46 | - $phpipam_mail->Php_mailer->addAddress($User->settings->siteAdminMail, $User->settings->siteAdminName); |
|
47 | - $phpipam_mail->Php_mailer->Subject = 'phpIPAM localhost mail test'; |
|
48 | - $phpipam_mail->Php_mailer->msgHTML($content); |
|
49 | - $phpipam_mail->Php_mailer->AltBody = $content_plain; |
|
50 | - //send |
|
51 | - $phpipam_mail->Php_mailer->send(); |
|
45 | + $phpipam_mail->Php_mailer->setFrom($_POST['mAdminMail'], $_POST['mAdminName']); |
|
46 | + $phpipam_mail->Php_mailer->addAddress($User->settings->siteAdminMail, $User->settings->siteAdminName); |
|
47 | + $phpipam_mail->Php_mailer->Subject = 'phpIPAM localhost mail test'; |
|
48 | + $phpipam_mail->Php_mailer->msgHTML($content); |
|
49 | + $phpipam_mail->Php_mailer->AltBody = $content_plain; |
|
50 | + //send |
|
51 | + $phpipam_mail->Php_mailer->send(); |
|
52 | 52 | } catch (phpmailerException $e) { |
53 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
53 | + $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
54 | 54 | } catch (Exception $e) { |
55 | - $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
55 | + $Result->show("danger", "Mailer Error: ".$e->errorMessage(), true); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | //if error not sent print ok |
@@ -59,19 +59,19 @@ |
||
59 | 59 | <input type="hidden" name="table" value="<?php print $_POST['table']; ?>"> |
60 | 60 | |
61 | 61 | <?php |
62 | - foreach($custom as $k=>$c) { |
|
63 | - print "<tr>"; |
|
64 | - # select |
|
65 | - print " <td style='width:20px;'>"; |
|
66 | - if(in_array($k, $filters[$_POST['table']])) { print "<input type='checkbox' class='input-switch' name='$k' checked>"; } |
|
67 | - else { print "<input type='checkbox' class='input-switch' name='$k'>"; } |
|
68 | - print " </td>"; |
|
69 | - # name and comment |
|
70 | - print " <td>".$k." (".$c['Comment'].")</td>"; |
|
71 | - print "</tr>"; |
|
72 | - } |
|
73 | - |
|
74 | - ?> |
|
62 | + foreach($custom as $k=>$c) { |
|
63 | + print "<tr>"; |
|
64 | + # select |
|
65 | + print " <td style='width:20px;'>"; |
|
66 | + if(in_array($k, $filters[$_POST['table']])) { print "<input type='checkbox' class='input-switch' name='$k' checked>"; } |
|
67 | + else { print "<input type='checkbox' class='input-switch' name='$k'>"; } |
|
68 | + print " </td>"; |
|
69 | + # name and comment |
|
70 | + print " <td>".$k." (".$c['Comment'].")</td>"; |
|
71 | + print "</tr>"; |
|
72 | + } |
|
73 | + |
|
74 | + ?> |
|
75 | 75 | </table> |
76 | 76 | </form> |
77 | 77 |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | |
11 | 11 | /* fetch all custom fields */ |
12 | 12 | $custom_tables = array( "ipaddresses"=>"IP address", |
13 | - "subnets"=>"subnet", |
|
14 | - "vlans"=>"VLAN", |
|
15 | - "vrf"=>"VRF", |
|
16 | - "users"=>"User", |
|
17 | - "devices"=>"Device", |
|
18 | - "racks"=>"Rack"); |
|
13 | + "subnets"=>"subnet", |
|
14 | + "vlans"=>"VLAN", |
|
15 | + "vrf"=>"VRF", |
|
16 | + "users"=>"User", |
|
17 | + "devices"=>"Device", |
|
18 | + "racks"=>"Rack"); |
|
19 | 19 | |
20 | 20 | # create array |
21 | 21 | foreach($custom_tables as $k=>$f) { |
22 | - $custom_fields[$k] = $Tools->fetch_custom_fields($k); |
|
23 | - $custom_fields_numeric[$k] = $Tools->fetch_custom_fields_numeric($k); |
|
24 | - $custom_fields[$k]['title'] = "Custom $f fields"; |
|
25 | - $custom_fields[$k]['tooltip'] = "Add new custom $f field"; |
|
22 | + $custom_fields[$k] = $Tools->fetch_custom_fields($k); |
|
23 | + $custom_fields_numeric[$k] = $Tools->fetch_custom_fields_numeric($k); |
|
24 | + $custom_fields[$k]['title'] = "Custom $f fields"; |
|
25 | + $custom_fields[$k]['tooltip'] = "Add new custom $f field"; |
|
26 | 26 | } |
27 | 27 | ?> |
28 | 28 | |
@@ -50,114 +50,114 @@ discard block |
||
50 | 50 | # printout each |
51 | 51 | foreach($custom_fields as $k=>$cf) { |
52 | 52 | |
53 | - # save vars and unset |
|
54 | - $title = $cf['title']; |
|
55 | - $tooltip = $cf['tooltip']; |
|
56 | - |
|
57 | - unset($cf['title']); |
|
58 | - unset($cf['tooltip']); |
|
59 | - |
|
60 | - # set key |
|
61 | - $table = $k; |
|
62 | - |
|
63 | - # get custom fields |
|
64 | - $ffields = json_decode($User->settings->hiddenCustomFields, true); |
|
65 | - $ffields = is_array(@$ffields[$table]) ? $ffields[$table] : array(); |
|
66 | - |
|
67 | - print "<tbody id='custom-$k'>"; |
|
68 | - |
|
69 | - //title |
|
70 | - print " <tr>"; |
|
71 | - print " <th colspan='8'>"; |
|
72 | - print " <h5>"._($title)."</h5>"; |
|
73 | - print " </th>"; |
|
74 | - print " </tr>"; |
|
75 | - |
|
76 | - //empty |
|
77 | - if(sizeof($cf) == 0) { |
|
78 | - print " <tr>"; |
|
79 | - print " <td colspan='8'>"; |
|
80 | - print " <div class='alert alert-info alert-nomargin'>"._('No custom fields created yet')."</div>"; |
|
81 | - print " </td>"; |
|
82 | - print " </tr>"; |
|
83 | - } |
|
84 | - //content |
|
85 | - else { |
|
86 | - $size = sizeof($cf); //we must remove title |
|
87 | - $m=0; |
|
88 | - |
|
89 | - foreach($cf as $f) |
|
90 | - { |
|
91 | - # space? |
|
92 | - $class = !preg_match('/^[a-zA-Z0-9 \_]+$/i', $f['name']) ? "alert-danger" : ""; |
|
93 | - |
|
94 | - print "<tr class='$class'>"; |
|
95 | - |
|
96 | - # ordering |
|
97 | - if (( ($m+1) != $size) ) { print "<td style='width:10px;'><button class='btn btn-xs btn-default down' data-direction='down' data-table='$table' rel='tooltip' title='Move down' data-fieldname='".$custom_fields_numeric[$table][$m]['name']."' data-nextfieldname='".$custom_fields_numeric[$table][$m+1]['name']."'><i class='fa fa-chevron-down'></i></button></td>"; } |
|
98 | - else { print "<td style='width:10px;'></td>";} |
|
99 | - |
|
100 | - print "<td class='name'>$f[name]</td>"; |
|
101 | - |
|
102 | - # description |
|
103 | - print "<td>$f[Comment]</td>"; |
|
104 | - |
|
105 | - # type |
|
106 | - print "<td>$f[type]</td>"; |
|
107 | - |
|
108 | - # default |
|
109 | - print "<td>$f[Default]</td>"; |
|
110 | - |
|
111 | - |
|
112 | - # NULL |
|
113 | - if(@$f['Null']=="NO") { print "<td>"._('Required')."</td>"; } |
|
114 | - else { print "<td></td>"; } |
|
115 | - |
|
116 | - # visible |
|
117 | - if(in_array($f['name'], $ffields)) { print "<td><span class='text-danger'>"._('No')."</span></td>"; } |
|
118 | - else { print "<td><span class='text-success'>"._('Yes')."</span></td>"; } |
|
119 | - |
|
120 | - #actions |
|
121 | - print "<td class='actions'>"; |
|
122 | - print " <div class='btn-group'>"; |
|
123 | - print " <button class='btn btn-xs btn-default edit-custom-field' data-action='edit' data-fieldname='$f[name]' data-table='$table'><i class='fa fa-pencil'></i></button>"; |
|
124 | - print " <button class='btn btn-xs btn-default edit-custom-field' data-action='delete' data-fieldname='$f[name]' data-table='$table'><i class='fa fa-times'></i></button>"; |
|
125 | - print " </div>"; |
|
126 | - |
|
127 | - # warning for older versions |
|
128 | - if((is_numeric(substr($f['name'], 0, 1))) || (!preg_match('!^[\w_ ]*$!', $f['name'])) ) { print '<span class="alert alert-warning"><strong>Warning</strong>: '._('Invalid field name').'!</span>'; } |
|
129 | - |
|
130 | - print "</td>"; |
|
131 | - print "</tr>"; |
|
132 | - |
|
133 | - $prevName = $f['name']; |
|
134 | - $m++; |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - //add |
|
139 | - print "<tr>"; |
|
140 | - print "<td colspan='8' style='padding-right:0px;'>"; |
|
141 | - print " <button class='btn btn-xs btn-default pull-right edit-custom-field' data-action='add' data-fieldname='' data-table='$table' rel='tooltip' data-placement='right' title='"._($tooltip)."'><i class='fa fa-plus'></i></button>"; |
|
142 | - print "</td>"; |
|
143 | - print "</tr>"; |
|
144 | - |
|
145 | - //filter |
|
146 | - print "<tr>"; |
|
147 | - print "<td colspan='8' style='padding-right:0px;'>"; |
|
148 | - print " <button class='btn btn-xs btn-info pull-right edit-custom-filter' data-table='$table' rel='tooltip' data-placement='right' title='"._("Set which field to display in table")."'><i class='fa fa-filter'></i> Filter</button>"; |
|
149 | - print "</td>"; |
|
150 | - print "</tr>"; |
|
151 | - |
|
152 | - //result |
|
153 | - print "<tr>"; |
|
154 | - print " <td colspan='8' class='result'>"; |
|
155 | - print " <div class='$table-order-result'></div>"; |
|
156 | - print "</td>"; |
|
157 | - print "</tr>"; |
|
158 | - |
|
159 | - |
|
160 | - print "</tbody>"; |
|
53 | + # save vars and unset |
|
54 | + $title = $cf['title']; |
|
55 | + $tooltip = $cf['tooltip']; |
|
56 | + |
|
57 | + unset($cf['title']); |
|
58 | + unset($cf['tooltip']); |
|
59 | + |
|
60 | + # set key |
|
61 | + $table = $k; |
|
62 | + |
|
63 | + # get custom fields |
|
64 | + $ffields = json_decode($User->settings->hiddenCustomFields, true); |
|
65 | + $ffields = is_array(@$ffields[$table]) ? $ffields[$table] : array(); |
|
66 | + |
|
67 | + print "<tbody id='custom-$k'>"; |
|
68 | + |
|
69 | + //title |
|
70 | + print " <tr>"; |
|
71 | + print " <th colspan='8'>"; |
|
72 | + print " <h5>"._($title)."</h5>"; |
|
73 | + print " </th>"; |
|
74 | + print " </tr>"; |
|
75 | + |
|
76 | + //empty |
|
77 | + if(sizeof($cf) == 0) { |
|
78 | + print " <tr>"; |
|
79 | + print " <td colspan='8'>"; |
|
80 | + print " <div class='alert alert-info alert-nomargin'>"._('No custom fields created yet')."</div>"; |
|
81 | + print " </td>"; |
|
82 | + print " </tr>"; |
|
83 | + } |
|
84 | + //content |
|
85 | + else { |
|
86 | + $size = sizeof($cf); //we must remove title |
|
87 | + $m=0; |
|
88 | + |
|
89 | + foreach($cf as $f) |
|
90 | + { |
|
91 | + # space? |
|
92 | + $class = !preg_match('/^[a-zA-Z0-9 \_]+$/i', $f['name']) ? "alert-danger" : ""; |
|
93 | + |
|
94 | + print "<tr class='$class'>"; |
|
95 | + |
|
96 | + # ordering |
|
97 | + if (( ($m+1) != $size) ) { print "<td style='width:10px;'><button class='btn btn-xs btn-default down' data-direction='down' data-table='$table' rel='tooltip' title='Move down' data-fieldname='".$custom_fields_numeric[$table][$m]['name']."' data-nextfieldname='".$custom_fields_numeric[$table][$m+1]['name']."'><i class='fa fa-chevron-down'></i></button></td>"; } |
|
98 | + else { print "<td style='width:10px;'></td>";} |
|
99 | + |
|
100 | + print "<td class='name'>$f[name]</td>"; |
|
101 | + |
|
102 | + # description |
|
103 | + print "<td>$f[Comment]</td>"; |
|
104 | + |
|
105 | + # type |
|
106 | + print "<td>$f[type]</td>"; |
|
107 | + |
|
108 | + # default |
|
109 | + print "<td>$f[Default]</td>"; |
|
110 | + |
|
111 | + |
|
112 | + # NULL |
|
113 | + if(@$f['Null']=="NO") { print "<td>"._('Required')."</td>"; } |
|
114 | + else { print "<td></td>"; } |
|
115 | + |
|
116 | + # visible |
|
117 | + if(in_array($f['name'], $ffields)) { print "<td><span class='text-danger'>"._('No')."</span></td>"; } |
|
118 | + else { print "<td><span class='text-success'>"._('Yes')."</span></td>"; } |
|
119 | + |
|
120 | + #actions |
|
121 | + print "<td class='actions'>"; |
|
122 | + print " <div class='btn-group'>"; |
|
123 | + print " <button class='btn btn-xs btn-default edit-custom-field' data-action='edit' data-fieldname='$f[name]' data-table='$table'><i class='fa fa-pencil'></i></button>"; |
|
124 | + print " <button class='btn btn-xs btn-default edit-custom-field' data-action='delete' data-fieldname='$f[name]' data-table='$table'><i class='fa fa-times'></i></button>"; |
|
125 | + print " </div>"; |
|
126 | + |
|
127 | + # warning for older versions |
|
128 | + if((is_numeric(substr($f['name'], 0, 1))) || (!preg_match('!^[\w_ ]*$!', $f['name'])) ) { print '<span class="alert alert-warning"><strong>Warning</strong>: '._('Invalid field name').'!</span>'; } |
|
129 | + |
|
130 | + print "</td>"; |
|
131 | + print "</tr>"; |
|
132 | + |
|
133 | + $prevName = $f['name']; |
|
134 | + $m++; |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + //add |
|
139 | + print "<tr>"; |
|
140 | + print "<td colspan='8' style='padding-right:0px;'>"; |
|
141 | + print " <button class='btn btn-xs btn-default pull-right edit-custom-field' data-action='add' data-fieldname='' data-table='$table' rel='tooltip' data-placement='right' title='"._($tooltip)."'><i class='fa fa-plus'></i></button>"; |
|
142 | + print "</td>"; |
|
143 | + print "</tr>"; |
|
144 | + |
|
145 | + //filter |
|
146 | + print "<tr>"; |
|
147 | + print "<td colspan='8' style='padding-right:0px;'>"; |
|
148 | + print " <button class='btn btn-xs btn-info pull-right edit-custom-filter' data-table='$table' rel='tooltip' data-placement='right' title='"._("Set which field to display in table")."'><i class='fa fa-filter'></i> Filter</button>"; |
|
149 | + print "</td>"; |
|
150 | + print "</tr>"; |
|
151 | + |
|
152 | + //result |
|
153 | + print "<tr>"; |
|
154 | + print " <td colspan='8' class='result'>"; |
|
155 | + print " <div class='$table-order-result'></div>"; |
|
156 | + print "</td>"; |
|
157 | + print "</tr>"; |
|
158 | + |
|
159 | + |
|
160 | + print "</tbody>"; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | ?> |
@@ -23,12 +23,12 @@ |
||
23 | 23 | |
24 | 24 | /* enthing to write? */ |
25 | 25 | if(sizeof($_POST)>0) { |
26 | - foreach($_POST as $k=>$v) { |
|
27 | - $filtered_fields[] = $k; |
|
28 | - } |
|
26 | + foreach($_POST as $k=>$v) { |
|
27 | + $filtered_fields[] = $k; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | else { |
31 | - $filtered_fields = null; |
|
31 | + $filtered_fields = null; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /* save */ |