### v.2.2 EARTH RC 1
+* ✔ Page categories exclusion option in main.cnf. Log view server side is modified not to include excluded categories
+older by certain amount of days, default is 0, for from today older.
* Search on multiple words should rank by encounter of words specified and display first. (That one is difficult)
* Auto collapse/expand on multi line logs by 0-none as default. Setting to 1 or more shows only that number of lines. (That one is difficult)
# By default this setting is disabled with 0, making alias name, its own log database, per user.
<<DBI_MULTI_USER_DB<>
-#Timezoning, if set to 1, country locale setting for timezone in config page is ignored.
+# Timezoning, if set to 1, country locale setting for timezone in config page is ignored.
<<AUTO_SET_TIMEZONE<0>
+# Setting to modify the page view to exclude older log entries by a list of categories from today minus days back.
+# This is to avoid and page only list relevant logs on logon. Searching by category will list them and still make visible.
+# value: {days=}{category id},.. days default to zero, if you don't want from yesterday to the past category entries listed.
+<<!PAGE_VIEW_EXCLUDES<0=88,6,69> <- (Diary,System Log,Poetry) category id's only, does set in the config page also work.
+
# Public, enabled list of categories. Remove -> '!' prefix before tag name, to enable. Be careful what category you add/enable here.
# Public records view feature only, it doesn't allow new log entries to be added and have pin point searching of all existing.
print "\n\nMerging from backup LOG table...\n";
my $insLOG = $db->prepare('INSERT INTO LOG (ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY) VALUES(?,?,?,?,?,?,?);')or die "Failed LOG prepare.";
- $b_pst = Settings::selectRecords($b_db,'SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM VW_LOG;');
+ $b_pst = Settings::selectRecords($b_db,'SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM '.Settings->VW_LOG);
while ( @br = $b_pst->fetchrow_array() ) {
- my $pst = Settings::selectRecords($db,"SELECT DATE FROM VW_LOG WHERE DATE='".$br[3]."';");
+ my $pst = Settings::selectRecords($db,"SELECT DATE FROM ".Settings->VW_LOG." WHERE DATE='".$br[3]."';");
my @ext = $pst->fetchrow_array();
if(scalar(@ext)==0){
$insLOG->execute($br[1],$br[2],$br[3],$br[4],$br[5],$br[6],$br[7]);
my $BACKUP_ENABLED = 0;
my $AUTO_SET_TIMEZONE = 0;
my $TIME_ZONE_MAP = 0;
-my $DB_NAME;
+my ($DB_NAME,$PAGE_EXCLUDES);
try{
checkAutologinSet();
$TIME_ZONE_MAP .= $line . "\n";
}
next;
- }
+ }
+ $v = Settings::parseAutonom('PAGE_VIEW_EXCLUDES',$line);
+ if($v){$PAGE_EXCLUDES=$v;next}
last if Settings::parseAutonom('CONFIG',$line); #By specs the config tag, is not an autonom, if found we stop reading. So better be last one spec. in file.
}
close $fh;
+ # Autologin credential in file next.
if(@cre &&scalar(@cre)>1){
if($alias && $passw && $alias ne $cre[0]){ # Is this an new alias login attempt? If so, autologin is of the agenda.
$db = Settings::connectDB($alias, $passw);
#check if autologin enabled.
my $st = Settings::selectRecords($db,"SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';");
- if($st){my @set = $st->fetchrow_array();
+ if($st){
+ my @set = $st->fetchrow_array();
if($set[0]=="1"){
$alias = $cre[0];
$passw = $passw;
}
-
sub checkPreparePGDB {
my $create =1;
$passw = $cgi->param('passw'); #We let PG handles password encryption (security) itself.
}
if($DB_VERSION > 1.6){
#is above v.1.6 notes table.
- $db->do('DROP TABLE VW_LOG;');
+ $db->do('DROP TABLE '.Settings->VW_LOG);
}
$db->do('DROP TABLE LOG;');
#v.1.8 Has fixes, time also properly to take into the sort. Not crucial to drop.
}
elsif($hasLogTbl && $SCRIPT_RELEASE > $DB_VERSION && $DB_VERSION < 2.0){
#dev 1.9 main log view has changed in 1.8..1.9, above scope will perform anyway, its drop, to be recreated later.
- $db->do('DROP VIEW VW_LOG;');delete($curr_tables{'VW_LOG'});
- delete($curr_tables{'VW_LOG'});
+ $db->do('DROP VIEW '.Settings->VW_LOG);delete($curr_tables{Settings->VW_LOG});
+ delete($curr_tables{Settings->VW_LOG});
$changed = 1;
}elsif($SCRIPT_RELEASE > $DB_VERSION){$changed = 1;}
# From v.1.6 view uses server side views, for pages and correct record by ID and PID lookups.
# This should make queries faster, less convulsed, and log renumeration less needed for accurate pagination.
- if(!$curr_tables{'VW_LOG'}) {
- $db->do(Settings::createViewLOGStmt()) or LifeLogException -> throw("ERROR:".$@) ;
+ if(!$curr_tables{Settings->VW_LOG}) {
+ $db->do(Settings::createViewLOGStmt()) or LifeLogException -> throw("ERROR:".$@);
+ }
+ if(!$curr_tables{Settings->VW_LOG_WITH_EXCLUDES}) {
+ # To cover all possible situations, this test elses too.
+ # As an older existing view might need to be recreated, to keep in synch.
+ if($PAGE_EXCLUDES){
+ $db->do(createPageViewExcludeSQL());
+ Settings::configProperty($db, 204, '^PAGE_EXCLUDES',$PAGE_EXCLUDES);
+ }
+ }else{ # Updating here too if excludes in config file have been removed.
+ my @ret=Settings::selectRecords($db, "SELECT value FROM CONFIG WHERE NAME='^PAGE_EXCLUDES';")->fetchrow_array();
+ if(!$ret[0] && $PAGE_EXCLUDES){
+ $db->do('DROP VIEW '.Settings->VW_LOG_WITH_EXCLUDES);
+ $db->do(createPageViewExcludeSQL());
+ Settings::configProperty($db, 204, '^PAGE_EXCLUDES',$PAGE_EXCLUDES);
+
+ }elsif($ret[0]){
+ if($PAGE_EXCLUDES && $PAGE_EXCLUDES ne $ret[0]){
+ $db->do('DROP VIEW '.Settings->VW_LOG_WITH_EXCLUDES);
+ $db->do(createPageViewExcludeSQL());
+ }{
+ $db->do("DELETE FROM CONFIG WHERE NAME='^PAGE_EXCLUDES'");
+ }
+ }
}
if(!$curr_tables{'CAT'}) {
my $t = uc substr($_,7);
$curr_tables{$t} = 1;
}
- if(!$curr_tables{'VW_LOG'}) {
- LifeLogException -> throw("VW_LOG not created! Try logging in again.");
+ if(!$curr_tables{Settings->VW_LOG}) {
+ LifeLogException -> throw(Settings->VW_LOG." not created! Try logging in again.");
}
}
}
}
+sub createPageViewExcludeSQL {
+
+ my $days = 0;
+ my $parse = $PAGE_EXCLUDES;
+ my @a = split('=',$parse);
+ if(scalar(@a)==2){
+ $days = $a[0];
+ $parse = $a[1];
+ }
+ my $where =qq(WHERE date >= date('now', '-$days day') OR);
+ @a = split(',',$parse);
+ foreach (@a){
+ $where .= " ID_CAT!=$_ AND";
+ }
+ $where =~ s/\s+OR$//;
+ $where =~ s/\s+AND$//;
+ return Settings::createViewLOGStmt(Settings->VW_LOG_WITH_EXCLUDES,$where);
+
+}
+
sub populate {
my $dbname = Settings::dbName();
my $alias = Settings::alias();
my $passw = Settings::pass();
+my $VW_PAGE = Settings->VW_LOG;
my $sssCDB = $sss->param('cdb');
my ($vmode, $imgw, $imgh );
my $rs_prev = $cgi->param('rs_prev');
my $rs_cur = $cgi->param('rs_cur');
my $rs_page = $cgi->param('rs_page');
-my $sqlView = 'SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY, PID FROM VW_LOG';#Only to be found here, the main SQL select statement.
+if(Settings::anon('^PAGE_EXCLUDES')){
+ if(!$cgi->param('srch_reset')&&!$prm_vc&&!$prm_vc_lst&&!$prm_aa&&!$prm_rtf&&!$prm_xc&&!$prm_xc_lst&&!$rs_dat_from&&!$rs_dat_to&&!$rs_keys){
+ $VW_PAGE = Settings->VW_LOG_WITH_EXCLUDES;
+ }
+}
+
+my $sqlView = 'SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY, PID FROM '.$VW_PAGE;#Only to be found here, the main SQL select statement.
my $stmS = $sqlView." WHERE";
my $stmE = ' LIMIT '.&Settings::viewAllLimit.';';
my $stmD = "";
if ( $log_start > 0 ) {
#check if we are at the beggining of the LOG table?
- my $stc = traceDBExe('SELECT PID from VW_LOG LIMIT 1;');
+ my $stc = traceDBExe('SELECT PID from '.$VW_PAGE.' LIMIT 1;');
my @row = $stc->fetchrow_array();
$log_top = $row[0];
if ($log_top == $rs_prev && $rs_cur == $rs_prev ) {
return $st;
}catch{
#BUG 31 fix.
- if(Settings::isProgressDB() && index($sql,'VW_LOG')>0){
+ if(Settings::isProgressDB() && index($sql,Settings->VW_LOG)>0){
$db -> do(Settings::createViewLOGStmt());
my $st = $db->prepare($sql);
- $st -> execute() or LifeLogException->throw("Execute failed [$DBI::errstri]", show_trace=>1);
+ $st -> execute() or LifeLogException->throw("Execute failed [$DBI::errstri]", show_trace=>1);
return $st;
}
LifeLogException->throw(error=>"DSN: [".Settings::dsn()."] Error encountered -> $@", show_trace=>1);
}
if($rtf){ #Update 0 ground NOTES entry to the just inserted log.
- $st = traceDBExe('SELECT ID FROM VW_LOG LIMIT 1;');
+ $st = traceDBExe('SELECT ID FROM '.Settings->VW_LOG.' LIMIT 1;');
my @lid = $st->fetchrow_array();
$st = traceDBExe('SELECT DOC FROM NOTES WHERE LID = 0;');
my @gzero = $st->fetchrow_array();
}
sub fetchAutocomplete {
- my $st = traceDBExe('SELECT LOG from LOG' . $stmE );
+ my $st = traceDBExe('SELECT LOG from LOG' . $stmE.';;' );
while ( my @row = $st->fetchrow_array() ) {
my ($wl,$log) = ("",$row[0]);
# Settings obtains from file escalated for anons to database configuration
# Currently we don't have an database set, and don't need it for this tester script.
# So we read and process the main.cnf file in via parser and transfer into Settings;
-my $cnf = CNFParser->new($ENV{'PWD'}.'/dbLifeLog/main.cnf');
-my $ptr = $cnf->anons();
-Settings::anonsSet($ptr);
-my $time = Settings::today();
-my $cnf_tz = Settings::timezone();
-my $ret = Settings::setTimezone(undef, 'America/Texas');
-my $a = Settings::anon('TIME_ZONE_MAP');
+# my $cnf = CNFParser->new($ENV{'PWD'}.'/dbLifeLog/main.cnf');
+# my $ptr = $cnf->anons();
+# Settings::anonsSet($ptr);
+# my $time = Settings::today();
+# my $cnf_tz = Settings::timezone();
+# my $ret = Settings::setTimezone(undef, 'America/Texas');
+# my $a = Settings::anon('TIME_ZONE_MAP');
+use constant VW_LOG_WITH_EXCLUDES => "TEST_VIEW";
+# print "tz:".$cnf_tz." time:". $time. "\n", $a , "\n\nTime America/Texas:$ret\n";
+my $PAGE_EXCLUDES = "1=88,6";
+
+print "SELECT * from LOG ",createPageViewSQL(), "\n";
+
+# SELECT rowid as ID,*, (select count(rowid) from LOG as recount where a.rowid >= recount.rowid) as PID
+# FROM LOG as a WHERE (ID_CAT!=88 AND ID_CAT!=6) OR date >= date('now', '-1 day') ORDER BY Date(DATE) DESC, Time(DATE) DESC;
+
+ sub createPageViewSQL {
+ my $days = 1;
+ my $parse = $PAGE_EXCLUDES;
+ my @a = split('=',$parse);
+ if(scalar(@a)==2){
+ $days = $a[0];
+ $parse = $a[1];
+ }
+ my $where =qq(WHERE date >= date('now', '-$days day') OR);
+ @a = split(',',$parse);
+ foreach (@a){
+ $where .= " ID_CAT!=$_ AND";
+ }
+ $where =~ s/\s+OR$//;
+ $where =~ s/\s+AND$//;
+ return Settings::createViewLOGStmt(VW_LOG_WITH_EXCLUDES,$where);
+ }
-print "tz:".$cnf_tz." time:". $time. "\n", $a , "\n\nTime America/Texas:$ret\n";
1;
\ No newline at end of file