# # Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-04 12:46:00 # # # Routines to be edited by the developer to provide content and validation for parameters # and provison of the control data for table(s) # use esmith::util; use esmith::util::network; use esmith::ConfigDB; use esmith::HostsDB; use esmith::AccountsDB; use esmith::NetworksDB; use esmith::DomainsDB; use constant FALSE => 0; use constant TRUE => 1; #The most common ones #my $cdb #my $adb #my $ndb #my $hdb #my $ddb # Validation routines - parameters for each panel sub validate_TABLE { my $c = shift; my $prefix_data = shift; #Data hash as parameter # Validation for each field my $ret = ""; if (! TRUE) #validate $c->param('StatsDate') {$ret .= 'Validation for StatsDate failed';} if ($ret eq "") {$ret = 'ok';} return $ret; } sub validate_CONFIG { my $c = shift; my $prefix_data = shift; #Data hash as parameter # Validation for each field my $ret = ""; if (! TRUE) #validate $c->param('TextorHTML') {$ret .= 'Validation for TextorHTML failed';} if (! TRUE) #validate $c->param('Email') {$ret .= 'Validation for Email failed';} if (! TRUE) #validate $c->param('EmailHost') {$ret .= 'Validation for EmailHost failed';} if (! TRUE) #validate $c->param('EmailUser') {$ret .= 'Validation for EmailUser failed';} if (! TRUE) #validate $c->param('DBSave') {$ret .= 'Validation for DBSave failed';} if (! TRUE) #validate $c->param('DBHost') {$ret .= 'Validation for DBHost failed';} if (! TRUE) #validate $c->param('DBUser') {$ret .= 'Validation for DBUser failed';} if (! TRUE) #validate $c->param('CountrySelect') {$ret .= 'Validation for CountrySelect failed';} if (! TRUE) #validate $c->param('AccumCountryCodes') {$ret .= 'Validation for AccumCountryCodes failed';} if (! TRUE) #validate $c->param('EnableRHSBL') {$ret .= 'Validation for EnableRHSBL failed';} if (! TRUE) #validate $c->param('EnableRHSBL') {$ret .= 'Validation for EnableRHSBL failed';} if (! TRUE) #validate $c->param('RBLLIST') {$ret .= 'Validation for RBLLIST failed';} if (! TRUE) #validate $c->param('SBLLIST') {$ret .= 'Validation for SBLLIST failed';} if (! TRUE) #validate $c->param('UBLLIST') {$ret .= 'Validation for UBLLIST failed';} if ($ret eq "") {$ret = 'ok';} return $ret; } # Get singleton data for each panel sub get_data_for_panel_TABLE { # Return a hash with the fields required which will be loaded into the shared data my $c = shift; my %ret = ( 'Data1'=>'Data for TABLE', #Example # fields from Inputs in TABLE $fields['TABLE'] 'StatsDate'=>'StatsDate contents', ); return %ret; } sub get_data_for_panel_CONFIG { # Return a hash with the fields required which will be loaded into the shared data my $c = shift; my %ret = ( 'Data1'=>'Data for CONFIG', #Example # fields from Inputs in CONFIG $fields['CONFIG'] 'TextorHTML'=>'TextorHTML contents', 'Email'=>'Email contents', 'EmailHost'=>'EmailHost contents', 'EmailUser'=>'EmailUser contents', 'DBSave'=>'DBSave contents', 'DBHost'=>'DBHost contents', 'DBUser'=>'DBUser contents', 'CountrySelect'=>'CountrySelect contents', 'AccumCountryCodes'=>'AccumCountryCodes contents', 'EnableRHSBL'=>'EnableRHSBL contents', 'EnableRHSBL'=>'EnableRHSBL contents', 'RBLLIST'=>'RBLLIST contents', 'SBLLIST'=>'SBLLIST contents', 'UBLLIST'=>'UBLLIST contents', ); return %ret; } # Get control data for table(s) # Return hash with values from row in which link clicked on table sub get_selected_TABLE { my $c = shift; my $selected = shift; #Parameter is name of selected row. my $is_new_record = shift; #Indicates new record required (defaults) my %ret = {}; return %ret; } sub get_selected_CONFIG { my $c = shift; my $selected = shift; #Parameter is name of selected row. my $is_new_record = shift; #Indicates new record required (defaults) my %ret = {}; return %ret; } #after sucessful modify or create or whatever and submit then perfom (if the params validate) sub perform_TABLE { my $c = shift; my $prefix_data = shift; #Data hash as parameter my $ret = ""; my $db = $cdb; #maybe one of the others 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." if (! TRUE) #copy or perform with value: StatsDate e.g. $db->set_prop($dbkey,'StatsDate',$c->param('StatsDate'),type=>'service')) {$ret .= 'Perform/save failed for StatsDate';} if ($ret eq "") {$ret = 'ok';} return $ret; } sub perform_CONFIG { my $c = shift; my $prefix_data = shift; #Data hash as parameter my $ret = ""; my $db = $cdb; #maybe one of the others 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." if (! TRUE) #copy or perform with value: TextorHTML e.g. $db->set_prop($dbkey,'TextorHTML',$c->param('TextorHTML'),type=>'service')) {$ret .= 'Perform/save failed for TextorHTML';} if (! TRUE) #copy or perform with value: Email e.g. $db->set_prop($dbkey,'Email',$c->param('Email'),type=>'service')) {$ret .= 'Perform/save failed for Email';} if (! TRUE) #copy or perform with value: EmailHost e.g. $db->set_prop($dbkey,'EmailHost',$c->param('EmailHost'),type=>'service')) {$ret .= 'Perform/save failed for EmailHost';} if (! TRUE) #copy or perform with value: EmailUser e.g. $db->set_prop($dbkey,'EmailUser',$c->param('EmailUser'),type=>'service')) {$ret .= 'Perform/save failed for EmailUser';} if (! TRUE) #copy or perform with value: DBSave e.g. $db->set_prop($dbkey,'DBSave',$c->param('DBSave'),type=>'service')) {$ret .= 'Perform/save failed for DBSave';} if (! TRUE) #copy or perform with value: DBHost e.g. $db->set_prop($dbkey,'DBHost',$c->param('DBHost'),type=>'service')) {$ret .= 'Perform/save failed for DBHost';} if (! TRUE) #copy or perform with value: DBUser e.g. $db->set_prop($dbkey,'DBUser',$c->param('DBUser'),type=>'service')) {$ret .= 'Perform/save failed for DBUser';} if (! TRUE) #copy or perform with value: CountrySelect e.g. $db->set_prop($dbkey,'CountrySelect',$c->param('CountrySelect'),type=>'service')) {$ret .= 'Perform/save failed for CountrySelect';} if (! TRUE) #copy or perform with value: AccumCountryCodes e.g. $db->set_prop($dbkey,'AccumCountryCodes',$c->param('AccumCountryCodes'),type=>'service')) {$ret .= 'Perform/save failed for AccumCountryCodes';} if (! TRUE) #copy or perform with value: EnableRHSBL e.g. $db->set_prop($dbkey,'EnableRHSBL',$c->param('EnableRHSBL'),type=>'service')) {$ret .= 'Perform/save failed for EnableRHSBL';} if (! TRUE) #copy or perform with value: EnableRHSBL e.g. $db->set_prop($dbkey,'EnableRHSBL',$c->param('EnableRHSBL'),type=>'service')) {$ret .= 'Perform/save failed for EnableRHSBL';} if (! TRUE) #copy or perform with value: RBLLIST e.g. $db->set_prop($dbkey,'RBLLIST',$c->param('RBLLIST'),type=>'service')) {$ret .= 'Perform/save failed for RBLLIST';} if (! TRUE) #copy or perform with value: SBLLIST e.g. $db->set_prop($dbkey,'SBLLIST',$c->param('SBLLIST'),type=>'service')) {$ret .= 'Perform/save failed for SBLLIST';} if (! TRUE) #copy or perform with value: UBLLIST e.g. $db->set_prop($dbkey,'UBLLIST',$c->param('UBLLIST'),type=>'service')) {$ret .= 'Perform/save failed for UBLLIST';} if ($ret eq "") {$ret = 'ok';} return $ret; } sub create_link{ # WIP my ($c,$route, $panel, $index) = @_; my $link = "$route?trt=$panel&Selected=$index"; return $link; } sub get_StatsDate{ return ['yesterday'] } sub get_CountrCodes{ return ['UK'] } 1;