Make sure all plain string constants are in single quotes

This commit is contained in:
Brian Read 2025-06-15 06:07:49 +01:00
parent 40e83a4bee
commit ae2ba92597
2 changed files with 25 additions and 25 deletions

View File

@ -70,11 +70,11 @@ sub main {
$c->app->log->info( $c->log_req ); $c->app->log->info( $c->log_req );
#The most common ones #The most common ones
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB->open() || die('Couldn't open config db');
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB->open() || die('Couldn't open Accounts db');
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die('Couldn't open Network db');
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB->open() || die('Couldn't open Hosts db');
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db');
%${prefix}_data = (); %${prefix}_data = ();
my $title = $c->l('${prefix}_${MenuDescription}'); my $title = $c->l('${prefix}_${MenuDescription}');
@ -86,7 +86,7 @@ sub main {
# which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE # which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE
my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config
<tal:block tal:repeat="dbfield dbfields"> <tal:block tal:repeat="dbfield dbfields">
$$${prefix}_data{'${dbfield}'} = $db->prop('${dbfield}') || ${dbdefault | ""} || ""; $$${prefix}_data{'${dbfield}'} = $db->prop('${dbfield}') || ${dbdefault | ''} || '';
</tal:block> </tal:block>
$c->do_display($$${prefix}_data{'trt'}); $c->do_display($$${prefix}_data{'trt'});
@ -107,7 +107,7 @@ sub do_update {
#render back to current panel with error message in stash #render back to current panel with error message in stash
#otherwise: #otherwise:
#By panel (series of if statements - only one executed): #By panel (series of if statements - only one executed):
#do whatever is required: call perform-PANEL() - return "ok" or Error Message #do whatever is required: call perform-PANEL() - return 'ok' or Error Message
#call signal-event for any global actions specified (check it exists - error and continue?) #call signal-event for any global actions specified (check it exists - error and continue?)
#if action smeserver-<whatever>-update exists #if action smeserver-<whatever>-update exists
#signal_event smeserver-<whatever>-update #signal_event smeserver-<whatever>-update
@ -124,11 +124,11 @@ sub do_update {
my $modul = ''; my $modul = '';
#The most common ones - you might want to comment out any not used. #The most common ones - you might want to comment out any not used.
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB->open() || die('Couldn't open config db');
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB->open() || die('Couldn't open Accounts db');
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die('Couldn't open Network db');
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB->open() || die('Couldn't open Hosts db');
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db');
my $title = $c->l('${prefix}_${MenuDescription}'); my $title = $c->l('${prefix}_${MenuDescription}');
@ -156,7 +156,7 @@ sub do_update {
$thispanel = '${panel}'; $thispanel = '${panel}';
} }
</tal:block> </tal:block>
if ($ret ne "ok"){ if ($ret ne 'ok'){
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->do_display($thispanel); $c->do_display($thispanel);
} else { } else {
@ -166,7 +166,7 @@ sub do_update {
if ($trt eq '${panel}'){ if ($trt eq '${panel}'){
#do whatever is required ... #do whatever is required ...
$ret = $c->perform_${panel}(\%${prefix}_data); $ret = $c->perform_${panel}(\%${prefix}_data);
if ($ret ne "ok") { if ($ret ne 'ok') {
# return to the panel with error message # return to the panel with error message
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->stash( $c->stash(
@ -208,14 +208,14 @@ sub do_display {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
#The most common ones - you might want to comment out any not used. #The most common ones - you might want to comment out any not used.
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB->open() || die('Couldn't open config db');
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB->open() || die('Couldn't open Accounts db');
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die('Couldn't open Network db');
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB->open() || die('Couldn't open Hosts db');
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB->open() || die('Couldn't open Domains db');
my $title = $c->l('${prefix}_${MenuDescription}'); my $title = $c->l('${prefix}_${MenuDescription}');
my $modul = ""; my $modul = '';
# Accessing all parameters # Accessing all parameters
my $params = $c->req->params->to_hash; my $params = $c->req->params->to_hash;

View File

@ -30,11 +30,11 @@ my $ddb;
my $c = shift; my $c = shift;
my $$${prefix}_data = shift; #Data hash as parameter my $$${prefix}_data = shift; #Data hash as parameter
# Validation for each field # Validation for each field
my $ret = ""; my $ret = '';
<tal:block tal:repeat="field fields[panel]"> <tal:block tal:repeat="field fields[panel]">
if (! TRUE) #validate $c->param('${field}') if (! TRUE) #validate $c->param('${field}')
{$ret .= 'Validation for ${field} failed';} </tal:block> {$ret .= 'Validation for ${field} failed';} </tal:block>
if ($ret eq "") {$ret = 'ok';} if ($ret eq '') {$ret = 'ok';}
return $ret; return $ret;
} }
</tal:block> </tal:block>
@ -114,14 +114,14 @@ sub get_${tablecontrol[0]} {
sub perform_${panel} { sub perform_${panel} {
my $c = shift; my $c = shift;
my $$${prefix}_data = shift; #Data hash as parameter my $$${prefix}_data = shift; #Data hash as parameter
my $ret = ""; my $ret = '';
my $db = $cdb; #maybe one of the others my $db = $cdb; #maybe one of the others
my $dbkey = 'ChangeThis'; my $dbkey = 'ChangeThis';
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g." # To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
<tal:block tal:repeat="field fields[panel]"> <tal:block tal:repeat="field fields[panel]">
if (! TRUE) #copy or perform with value: ${field} e.g. $db->set_prop($dbkey,'${field}',$c->param('${field}'),type=>'service')) if (! TRUE) #copy or perform with value: ${field} e.g. $db->set_prop($dbkey,'${field}',$c->param('${field}'),type=>'service'))
{$ret .= 'Perform/save failed for ${field}';}</tal:block> {$ret .= 'Perform/save failed for ${field}';}</tal:block>
if ($ret eq "") {$ret = 'ok';} if ($ret eq '') {$ret = 'ok';}
return $ret; return $ret;
} }
</tal:block> </tal:block>