From: Will Budic Date: Mon, 13 Jan 2020 03:55:27 +0000 (+1100) Subject: Keep excludes setting. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=3b91e8784ac33c51317d199544594b5cba603095;p=LifeLog.git Keep excludes setting. --- diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index d7b3149..6d3c693 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -11,7 +11,7 @@ Credential format:< , dont enable here using AUT 05|$PRC_WIDTH = 80`Default presentation width for pages. 08|$LOG_PATH = ../../dbLifeLog/`Path to folder containing data. 10|$SESSN_EXPR = +30m`Login session expiration time setting, can be minutes or hours. -12|$DATE_UNI = 0`Setting of how dates are displayed, universal yyyy-mm-dd or local dd-mm-yyyy. +12|$DATE_UNI = 0`Setting of how dates are displayed, universal yyyy-mm-dd or local dd-mm-yyyy. 14|$LANGUAGE = English`Default language locale. 18|$IMG_W_H = 210x120`Default embedded image width. 20|$AUTO_WRD_LMT= 200`Autocomplete word gathering limit. @@ -20,6 +20,7 @@ Credential format:< , dont enable here using AUT 26|$RTF_SIZE = 2`RTF Document height, 0 - Large, 1 - Medium, 2- Small. 28|$THEME = Standard`Theme to applay, Standard, Sun, Moon, Earth. 30|$DEBUG = 0`Development page additional debug output, off (default) or on. +32|$KEEP_EXECS = 0`Cache excludes between sessions, off (default) or on. < 01|Unspecified `For quick uncategorised entries. 03|File System `Operating file system/Application short log. diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index ec4b6c5..cbff506 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -22,6 +22,7 @@ our $AUTO_WRD_LMT = 1000; our $FRAME_SIZE = 0; our $RTF_SIZE = 0; our $THEME = 'Standard'; +our $KEEP_EXCS = 0; ### Page specific settings Here our $TH_CSS = 'main.css'; @@ -31,6 +32,12 @@ our $DEBUG = 0; #END OF SETTINGS +### Private Settings sofar (id -> name : def.value): +#200 -> '^REL_RENUM' : this.$RELEASE_VER (Used in login_ctr.cgi) +#201 -> '^EXCLUDES' : 0 (Used in main.cgi) + + + sub new { return bless {}, shift; @@ -48,11 +55,10 @@ sub frameSize {return $FRAME_SIZE;} sub universalDate {return $DATE_UNI;} sub autoWordLimit {return $AUTO_WRD_LMT;} sub windowRTFSize {return $RTF_SIZE;} - - -sub bgcol {return $BGCOL;} -sub css {return $TH_CSS;} -sub debug {my $ret =shift; if($ret){$DEBUG = $ret;}; return $DEBUG;} +sub keepExcludes {return $KEEP_EXCS;} +sub bgcol {return $BGCOL;} +sub css {return $TH_CSS;} +sub debug {my $ret=shift; if($ret){$DEBUG = $ret;}; return $DEBUG;} @@ -78,6 +84,7 @@ sub getConfiguration { case "RTF_SIZE" { $RTF_SIZE = $r[2] } case "THEME" { $THEME = $r[2] } case "DEBUG" { $DEBUG = $r[2] } + case "KEEP_EXCS" { $KEEP_EXCS = $r[2] } } } @@ -163,14 +170,14 @@ sub toLog { # try { #Apostrophe in the log value is doubled to avoid SQL errors. $log =~ s/'/''/g; - $db->do("INSERT INTO LOG (ID_CAT, DATE, LOG) VALUES(6,'$stamp', \"$log\");"); + $db->do("INSERT INTO LOG (ID_CAT, DATE, LOG) VALUES(6,'$stamp', \"$log\");"); # } # catch { # print "SERVER ERROR toLog(6,$stamp,$log):" . $_; # } } -sub removeOldSessions { +sub removeOldSessions { opendir(DIR, $LOG_PATH); my @files = grep(/cgisess_*/,readdir(DIR)); closedir(DIR); @@ -183,4 +190,32 @@ sub removeOldSessions { } } + +#TODO move this subroutine to settings. +sub obtainProperty { + my($db, $name) = @_; + die "Invalid use of subroutine obtainProperty($db, $name)" if(!$db || !$name); + my $dbs = Settings::dbExecute($db, "SELECT ID, VALUE FROM CONFIG WHERE NAME IS '$name';"); + my @row = $dbs->fetchrow_array(); + if(scalar @row > 0){ + return $row[1]; + } + else{ + return 0; + } +} +#TODO move this subroutine to settings. +sub configProperty { + my($db, $id, $name, $value) = @_; + die "Invalid use of subroutine configProperty($db,$name,$value)" if(!$db || !$name|| !$value); + + my $dbs = Settings::dbExecute($db, "SELECT ID, NAME FROM CONFIG WHERE NAME IS '$name';"); + if($dbs->fetchrow_array()){ + Settings::dbExecute($db, "UPDATE CONFIG SET VALUE = '$value' WHERE NAME IS '$name';"); + } + else{ + Settings::dbExecute($db,"INSERT INTO CONFIG (ID, NAME, VALUE) VALUES ($id, '$name', '$value');"); + } +} + 1; \ No newline at end of file