]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Keep excludes setting.
authorWill Budic <redacted>
Mon, 13 Jan 2020 03:55:27 +0000 (14:55 +1100)
committerWill Budic <redacted>
Mon, 13 Jan 2020 03:55:27 +0000 (14:55 +1100)
dbLifeLog/main.cnf
htdocs/cgi-bin/system/modules/Settings.pm

index d7b3149286fa46585970e20cf2c57dc0bb8aee06..6d3c693519bc9d962ecaa2298b5e045561f7bed1 100644 (file)
@@ -11,7 +11,7 @@ Credential format:<<AUTO_LOGIN <{alias}/{password}> , 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:<<AUTO_LOGIN <{alias}/{password}> , 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.
 <<CAT<3>
 01|Unspecified `For quick uncategorised entries.
 03|File System `Operating file system/Application short log.
index ec4b6c5a3e3672a698ff2258f75d6791ac7ae1b4..cbff5062cc2e5daa22f596e80efb56426983fce4 100644 (file)
@@ -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 "<font color=red><b>SERVER ERROR toLog(6,$stamp,$log)</b></font>:" . $_;
     # }
 }
 
-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