Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for markdown in custom fields #3998

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/admin/custom-fields/edit.php
Expand Up @@ -106,7 +106,7 @@ function check_name_whitespace () {
$oldMSize = str_replace(array("(",")"), "",strstr(@$fieldval['Type'] ?: '', "(", false));

//exceptions
if(@$fieldval['Type']=="text" || @$fieldval['Type']=="date" || @$fieldval['Type']=="datetime" || @$fieldval['Type']=="set" || @$fieldval['Type']=="enum") { $oldMType = @$fieldval['Type']; }
if(@$fieldval['Type']=="longtext" || @$fieldval['Type']=="text" || @$fieldval['Type']=="date" || @$fieldval['Type']=="datetime" || @$fieldval['Type']=="set" || @$fieldval['Type']=="enum") { $oldMType = @$fieldval['Type']; }
?>
<td>
<select name="fieldType" class="input-sm input-w-auto form-control">
Expand Down Expand Up @@ -158,4 +158,4 @@ function check_name_whitespace () {
</div>
<!-- result -->
<div class="customEditResult"></div>
</div>
</div>
16 changes: 6 additions & 10 deletions app/admin/users/print-all.php
Expand Up @@ -162,19 +162,15 @@
foreach($custom as $field) {
if(!in_array($field['name'], $ffields)) {
print "<td>";
//booleans
if($field['type']=="tinyint(1)") {
if($user[$field['name']] == "0") { print _("No"); }
elseif($user[$field['name']] == "1") { print _("Yes"); }
}
//text
elseif($field['type']=="text") {
if(!is_blank($user[$field['name']])) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $user[$field['name']])."'>"; }

$ff = $Tools->process_field($user[$field['name']], $field['type']);

if($field['type']=="longtext" || $field['type']=="text") {
if(!is_blank($user[$field['name']])) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $ff)."'>"; }
else { print ""; }
}
else {
print $user[$field['name']];

print $ff;
}
print "</td>";
}
Expand Down
9 changes: 1 addition & 8 deletions app/subnets/addresses/address-details/address-details.php
Expand Up @@ -255,14 +255,7 @@
print "<tr>";
print " <th>$key</th>";
print " <td>";
#booleans
if($field['type']=="tinyint(1)") {
if($address[$key] == 0) { print _("No"); }
elseif($address[$key] == 1) { print _("Yes"); }
}
else {
print $Tools->create_links($address[$key]);
}
print $Tools->process_field($address[$key], $field['type']);
print " </td>";
print "</tr>";
}
Expand Down
10 changes: 2 additions & 8 deletions app/subnets/addresses/print-address-table.php
Expand Up @@ -492,15 +492,9 @@ function unset_array_value(&$array, $value) {
print "<td class='customField hidden-xs hidden-sm hidden-md'>";

// create html links
$addresses[$n]->{$myField['name']} = $Tools->create_links($addresses[$n]->{$myField['name']}, $myField['type']);

//booleans
if($myField['type']=="tinyint(1)") {
if($addresses[$n]->{$myField['name']} == "0") { print _("No"); }
elseif($addresses[$n]->{$myField['name']} == "1") { print _("Yes"); }
}
$addresses[$n]->{$myField['name']} = $Tools->process_field($addresses[$n]->{$myField['name']}, $myField['type']);
//text
elseif($myField['type']=="text") {
if($myField['type']=="text" || $myField['type']=="longtext") {
if(!is_blank($addresses[$n]->{$myField['name']})) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $addresses[$n]->{$myField['name']})."'>"; }
else { print ""; }
}
Expand Down
9 changes: 1 addition & 8 deletions app/subnets/subnet-details/subnet-details.php
Expand Up @@ -505,14 +505,7 @@
$html_custom[] = "<tr>";
$html_custom[] = " <th>".$Tools->print_custom_field_name ($key)."</th>";
$html_custom[] = " <td>";
#booleans
if($field['type']=="tinyint(1)") {
if($subnet[$key] == "0") { $html_custom[] = _("No"); }
elseif($subnet[$key] == "1") { $html_custom[] = _("Yes"); }
}
else {
$html_custom[] = $Tools->create_links($subnet[$key]);
}
$html_custom[] = $Tools->process_field($subnet[$key], $field['type']);
$html_custom[] = " </td>";
$html_custom[] = "</tr>";
}
Expand Down
9 changes: 1 addition & 8 deletions app/subnets/subnet-slaves-subnets.php
Expand Up @@ -125,14 +125,7 @@
# custom
if(isset($visible_fields)) {
foreach ($visible_fields as $key=>$field) {
#booleans
if($field['type']=="tinyint(1)") {
if($slave_subnet[$key] == "0") { $html_custom = _("No"); }
elseif($slave_subnet[$key] == "1") { $html_custom = _("Yes"); }
}
else {
$html_custom = $Tools->create_links($slave_subnet[$key]);
}
$html_custom = $Tools->process_field($slave_subnet[$key], $field['type']);

print "<td>".$html_custom."</td>";
}
Expand Down
9 changes: 1 addition & 8 deletions app/subnets/subnet-slaves.php
Expand Up @@ -125,14 +125,7 @@
# custom
if(isset($visible_fields)) {
foreach ($visible_fields as $key=>$field) {
#booleans
if($field['type']=="tinyint(1)") {
if($slave_subnet[$key] == "0") { $html_custom = _("No"); }
elseif($slave_subnet[$key] == "1") { $html_custom = _("Yes"); }
}
else {
$html_custom = $Tools->create_links($slave_subnet[$key]);
}
$html_custom = $Tools->process_field($slave_subnet[$key], $field['type']);

print "<td>".$html_custom."</td>";
}
Expand Down
Expand Up @@ -38,14 +38,7 @@
print "</tr>";

foreach($custom_fields as $field) {
# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($logical_circuit->{$field['name']}=="0") { $logical_circuit->{$field['name']} = "false"; }
elseif($logical_circuit->{$field['name']}=="1") { $logical_circuit->{$field['name']} = "true"; }
else { $logical_circuit->{$field['name']} = ""; }
}
# create links
$logical_circuit->{$field['name']} = $Tools->create_links ($logical_circuit->{$field['name']});
$logical_circuit->{$field['name']} = $Tools->process_field ($logical_circuit->{$field['name']}, $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand Down
2 changes: 1 addition & 1 deletion app/tools/circuits/logical-circuits/logical-circuits.php
Expand Up @@ -101,7 +101,7 @@
foreach($custom_fields as $field) {
if(!in_array($field['name'], $hidden_circuit_fields)) {
// create html links
$circuit->{$field['name']} = $User->create_links($circuit->{$field['name']}, $field['type']);
$circuit->{$field['name']} = $User->process_field($circuit->{$field['name']}, $field['type']);

print "<td class='hidden-xs hidden-sm hidden-md'>".$circuit->{$field['name']}."</td>";
}
Expand Down
2 changes: 1 addition & 1 deletion app/tools/circuits/physical-circuits/all-circuits.php
Expand Up @@ -116,7 +116,7 @@
foreach($custom_fields as $field) {
if(!in_array($field['name'], $hidden_circuit_fields)) {
// create html links
$circuit->{$field['name']} = $User->create_links($circuit->{$field['name']}, $field['type']);
$circuit->{$field['name']} = $User->process_field($circuit->{$field['name']}, $field['type']);

print "<td class='hidden-xs hidden-sm hidden-md'>".$circuit->{$field['name']}."</td>";
}
Expand Down
14 changes: 3 additions & 11 deletions app/tools/circuits/physical-circuits/circuit-details-general.php
Expand Up @@ -66,18 +66,10 @@
print "<tr>";
print " <td colspan='2'><hr></td>";
print "</tr>";

foreach($custom_fields as $field) {

# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($circuit->{$field['name']}=="0") { $circuit->{$field['name']} = "false"; }
elseif($circuit->{$field['name']}=="1") { $circuit->{$field['name']} = "true"; }
else { $circuit->{$field['name']} = ""; }
}

# create links
$circuit->{$field['name']} = $Tools->create_links ($circuit->{$field['name']});
# prcess field
$circuit->{$field['name']} = $Tools->process_field ($circuit->{$field['name']}, $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand Down
13 changes: 2 additions & 11 deletions app/tools/circuits/physical-circuits/circuit-details-provider.php
Expand Up @@ -35,16 +35,7 @@
print "</tr>";

foreach($custom_provider_fields as $field) {

# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($provider->{$field['name']}=="0") { $provider->{$field['name']} = "false"; }
elseif($provider->{$field['name']}=="1") { $provider->{$field['name']} = "true"; }
else { $provider->{$field['name']} = ""; }
}

# create links
$provider->{$field['name']} = $Tools->create_links ($provider->{$field['name']});
$provider->{$field['name']} = $Tools->process_field ($provider->{$field['name']}, $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand All @@ -53,4 +44,4 @@
}
}

print "</table>";
print "</table>";
2 changes: 1 addition & 1 deletion app/tools/circuits/providers/all-providers.php
Expand Up @@ -90,7 +90,7 @@
foreach($custom_fields as $field) {
if(!in_array($field['name'], $hidden_fields)) {
// create html links
$provider->{$field['name']} = $User->create_links($provider->{$field['name']}, $field['type']);
$provider->{$field['name']} = $User->process_field($provider->{$field['name']}, $field['type']);

print "<td class='hidden-sm hidden-xs hidden-md'>".$provider->{$field['name']}."</td>";
}
Expand Down
13 changes: 2 additions & 11 deletions app/tools/circuits/providers/provider-details.php
Expand Up @@ -61,15 +61,7 @@
print "</tr>";

foreach($custom_fields as $field) {
# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($provider->{$field['name']}=="0") { $provider->{$field['name']} = "false"; }
elseif($provider->{$field['name']}=="1") { $provider->{$field['name']} = "true"; }
else { $provider->{$field['name']} = ""; }
}

# create links
$provider->{$field['name']} = $Tools->create_links ($provider->{$field['name']});
$provider->{$field['name']} = $Tools->process_field ($provider->{$field['name']}, $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand Down Expand Up @@ -172,8 +164,7 @@
if(sizeof(@$custom_fields_circuits) > 0) {
foreach($custom_fields_circuits as $field) {
if(!in_array($field['name'], $hidden_circuit_fields)) {
// create html links
$circuit->{$field['name']} = $User->create_links($circuit->{$field['name']}, $field['type']);
$circuit->{$field['name']} = $User->process_field($circuit->{$field['name']}, $field['type']);

print "<td class='hidden-xs hidden-sm hidden-md'>".$circuit->{$field['name']}."</td>";
}
Expand Down
2 changes: 1 addition & 1 deletion app/tools/customers/all-customers.php
Expand Up @@ -85,7 +85,7 @@
foreach($custom_fields as $field) {
if(!in_array($field['name'], $hidden_fields)) {
// create html links
$customer->{$field['name']} = $User->create_links($customer->{$field['name']}, $field['type']);
$customer->{$field['name']} = $User->process_field($customer->{$field['name']}, $field['type']);

print "<td class='hidden-sm hidden-xs hidden-md'>".$customer->{$field['name']}."</td>";
}
Expand Down
11 changes: 1 addition & 10 deletions app/tools/customers/customer/details.php
Expand Up @@ -79,16 +79,7 @@
print "</tr>";

foreach($custom_fields as $field) {

# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($customer->{$field['name']}=="0") { $customer->{$field['name']} = "false"; }
elseif($customer->{$field['name']}=="1") { $customer->{$field['name']} = "true"; }
else { $customer->{$field['name']} = ""; }
}

# create links
$customer->{$field['name']} = $Tools->create_links ($customer->{$field['name']});
$customer->{$field['name']} = $Tools->process_field ($customer->{$field['name']}, $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand Down
2 changes: 1 addition & 1 deletion app/tools/customers/customer/objects/circuits.php
Expand Up @@ -97,7 +97,7 @@
foreach($custom_fields as $field) {
if(!in_array($field['name'], $hidden_circuit_fields)) {
// create html links
$circuit->{$field['name']} = $User->create_links($circuit->{$field['name']}, $field['type']);
$circuit->{$field['name']} = $User->process_field($circuit->{$field['name']}, $field['type']);

print "<td class='hidden-xs hidden-sm hidden-md'>".$circuit->{$field['name']}."</td>";
}
Expand Down
9 changes: 1 addition & 8 deletions app/tools/customers/customer/objects/subnets.php
Expand Up @@ -91,14 +91,7 @@
# custom
if(isset($visible_fields)) {
foreach ($visible_fields as $key=>$field) {
#booleans
if($field['type']=="tinyint(1)") {
if($slave_subnet[$key] == "0") { $html_custom = _("No"); }
elseif($slave_subnet[$key] == "1") { $html_custom = _("Yes"); }
}
else {
$html_custom = $Tools->create_links($slave_subnet[$key]);
}
$html_custom = $Tools->process_field($slave_subnet[$key], $field['type']);

print "<td>".$html_custom."</td>";
}
Expand Down
13 changes: 2 additions & 11 deletions app/tools/devices/device-details/device-details.php
Expand Up @@ -234,16 +234,7 @@

if(sizeof($custom_fields) > 0) {
foreach($custom_fields as $field) {

# fix for boolean
if($field['type']=="tinyint(1)" || $field['type']=="boolean") {
if($device[$field['name']]=="0") { $device[$field['name']] = "false"; }
elseif($device[$field['name']]=="1") { $device[$field['name']] = "true"; }
else { $device[$field['name']] = ""; }
}

# create links
$device[$field['name']] = $Tools->create_links ($device[$field['name']]);
$device[$field['name']] = $Tools->process_field ($device[$field['name']], $field['type']);

print "<tr>";
print "<th>".$Tools->print_custom_field_name ($field['name'])."</th>";
Expand Down Expand Up @@ -296,4 +287,4 @@
}
else {
$Result->show("danger", _('Invalid ID'), false);
}
}
15 changes: 5 additions & 10 deletions app/tools/devices/device-details/device-pstn.php
Expand Up @@ -102,19 +102,14 @@
if(!in_array($field['name'], $hidden_fields)) {

$html[] = "<td class='hidden-xs hidden-sm hidden-md'>";
//booleans
if($field['type']=="tinyint(1)") {
if($sp->{$field['name']} == "0") { $html[] = _("No"); }
elseif($sp->{$field['name']} == "1") { $html[] = _("Yes"); }
}
//text
elseif($field['type']=="text") {
if(!is_blank($sp->{$field['name']})) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $sp->{$field['name']})."'>"; }

$ff = $Tools->process_field($sp->{$field['name']}, $field['type']);
if($field['type']=="text" || $field['type']=="longtext") {
if(!is_blank($sp->{$field['name']})) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $ff)."'>"; }
else { print ""; }
}
else {
$html[] = $sp->{$field['name']};

$html[] = $ff;
}
$html[] = "</td>";
}
Expand Down
4 changes: 1 addition & 3 deletions app/tools/locations/single-location.php
Expand Up @@ -92,9 +92,7 @@
print "<tr><td colspan='2'><hr></td></tr>";
// fields
foreach($cfields as $key=>$field) {
$location->{$key} = str_replace("\n", "<br>",$location->{$key});
// create links
$location->{$key} = $Tools->create_links($location->{$key});
$location->{$key} = $Tools->process_field($location->{$key}, $field['type']);
print "<tr>";
print " <th>".$Tools->print_custom_field_name ($key)."</th>";
print " <td style='vertical-align:top;align-content:left;'>".$location->{$key}."</td>";
Expand Down
13 changes: 3 additions & 10 deletions app/tools/multicast-networks/index.php
Expand Up @@ -221,21 +221,14 @@
print "<td class='customField hidden-xs hidden-sm hidden-md'>";

// create html links
$address->{$myField['name']} = $Tools->create_links($address->{$myField['name']}, $myField['type']);
$address->{$myField['name']} = $Tools->process_field($address->{$myField['name']}, $myField['type']);

//booleans
if($myField['type']=="tinyint(1)") {
if($address->{$myField['name']} == "0") { print _("No"); }
elseif($address->{$myField['name']} == "1") { print _("Yes"); }
}
//text
elseif($myField['type']=="text") {
if($myField['type']=="text" || $myField['type']=="longtext") {
if(!is_blank($address->{$myField['name']})) { print "<i class='fa fa-gray fa-comment' rel='tooltip' data-container='body' data-html='true' title='".str_replace("\n", "<br>", $address->{$myField['name']})."'>"; }
else { print ""; }
}
else {
print $address->{$myField['name']};

}
print "</td>";
}
Expand Down Expand Up @@ -288,4 +281,4 @@
}

?>
</table>
</table>