diff --git a/CHANGELOG b/CHANGELOG index 28ba9c0..ed31190 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 @@ -240,7 +240,3 @@ treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. - -5.2.5 - 2026-02-10 - This is just a version number bump to get on a major-minor-patch - scheme. There are no code changes for this release. diff --git a/INSTALL b/INSTALL index c7ced63..68e2883 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,6 @@ INSTALL OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 diff --git a/VERSION.txt b/VERSION.txt index 462faf7..03f488b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.5 +5.3.0 diff --git a/database-initial.sql b/database-initial.sql index 951c5cf..c1b89c9 100644 --- a/database-initial.sql +++ b/database-initial.sql @@ -69,7 +69,7 @@ CREATE TABLE `configs` ( LOCK TABLES `configs` WRITE; /*!40000 ALTER TABLE `configs` DISABLE KEYS */; INSERT INTO `configs` VALUES -(1,'ol_version','5.2.5'), +(1,'ol_version','5.2.4'), (2,'log_name','OpenLog'), (3,'banner','1'), (4,'background_color','#003333'), @@ -232,6 +232,32 @@ LOCK TABLES `flags` WRITE; /*!40000 ALTER TABLE `flags` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `flagmap` +-- + +DROP TABLE IF EXISTS `flagmap`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `flagmap` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `flagid` int(11) NOT NULL, + `lognoteid` int(11) DEFAULT NULL, + `maintformid` int(11) DEFAULT NULL, + `notetemplateid` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `flagmap` +-- + +LOCK TABLES `flagmap` WRITE; +/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */; +/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `links` -- @@ -273,7 +299,6 @@ CREATE TABLE `lognotes` ( `tech` int(11) NOT NULL, `subject` int(11) NOT NULL, `lognote` text DEFAULT NULL, - `refs` tinytext DEFAULT NULL, PRIMARY KEY (`lognoteid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -287,6 +312,31 @@ LOCK TABLES `lognotes` WRITE; /*!40000 ALTER TABLE `lognotes` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `reflinks` +-- + +DROP TABLE IF EXISTS `reflinks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `reflinks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `noteid` int(11) DEFAULT NULL, + `templateid` int(11) DEFAULT NULL, + `target` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `reflinks` +-- + +LOCK TABLES `reflinks` WRITE; +/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */; +/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `logpartactions` -- diff --git a/database-update.sh b/database-update.sh index cc37f86..f166b4c 100755 --- a/database-update.sh +++ b/database-update.sh @@ -37,3 +37,7 @@ margs="--defaults-extra-file=$mysql_opt_file" # ---------- version 5.2.5 ------------ # Nothing to do # ------------------------------------- + +# ---------- version 5.3.0 ------------ +# Nothing to do +# ------------------------------------- diff --git a/database-update.sql b/database-update.sql index 20326fb..ef76257 100644 --- a/database-update.sql +++ b/database-update.sql @@ -55,3 +55,8 @@ UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version"; -- Update version number UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version"; -- -------------------------------------- + +-- ---------- version 5.3.0 ------------- +-- Update version number +UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version"; +-- -------------------------------------- diff --git a/db.php.template b/db.php.template index 084f062..81521ef 100644 --- a/db.php.template +++ b/db.php.template @@ -3,7 +3,7 @@ /* db.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/CHANGELOG b/distfiles/CHANGELOG index dbadc6b..a1ebe30 100644 --- a/distfiles/CHANGELOG +++ b/distfiles/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 @@ -240,8 +240,3 @@ treating the $today variable as global. - In install.php, if a previous installation was found, make upgrade the default choice. - -5.2.5 - 2026-02-10 - This is just a version number bump to get on a major-minor-patch - scheme. There are no code changes for this release. - diff --git a/distfiles/INSTALL b/distfiles/INSTALL index c7ced63..68e2883 100644 --- a/distfiles/INSTALL +++ b/distfiles/INSTALL @@ -1,6 +1,6 @@ INSTALL OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 diff --git a/distfiles/about.php b/distfiles/about.php index af3b950..ccdb1d7 100644 --- a/distfiles/about.php +++ b/distfiles/about.php @@ -2,7 +2,7 @@ /* about.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/admin.php b/distfiles/admin.php index daa09a2..25c8747 100644 --- a/distfiles/admin.php +++ b/distfiles/admin.php @@ -2,7 +2,7 @@ /* admin.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/functions.php b/distfiles/functions.php index baafb08..24f2f7d 100644 --- a/distfiles/functions.php +++ b/distfiles/functions.php @@ -2,7 +2,7 @@ /* functions.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ @@ -181,17 +181,28 @@ function framework($option,$htmltitle,$pagetitle,$print) { } }).datepicker(\"setDate\", defdate); - function insertUrlAtCaret(outputAreaId, inputAreaId) { - var rawlinktext=document.getElementById(inputAreaId).value; - var url='' + rawlinktext + ''; + function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) { + var linktext=document.getElementById(inputTextAreaId).value; + var rawurltext=document.getElementById(inputUrlAreaId).value; + if (rawurltext=='') return; + var lastslashindex=rawurltext.lastIndexOf('/'); + if (lastslashindex==rawurltext.length-1) { + rawurltext=rawurltext.slice(0, -1); + } + if (linktext=='' && rawurltext!= '') { + lastslashindex=rawurltext.lastIndexOf('/'); + var lastpartofurl=rawurltext.substring(lastslashindex+1); + linktext=lastpartofurl; + } + var link='' + linktext + ''; var txtarea = document.getElementById(outputAreaId); var scrollPos = txtarea.scrollTop; var caretPos = txtarea.selectionStart; var front = (txtarea.value).substring(0, caretPos); var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length); - txtarea.value = front + url + back; - caretPos = caretPos + url.length; + txtarea.value = front + link + back; + caretPos = caretPos + link.length; txtarea.selectionStart = caretPos; txtarea.selectionEnd = caretPos; txtarea.focus(); @@ -311,6 +322,7 @@ function sidemenu($noprint=false) { +
Administration
My Profile
Manage Templates
"; if (!isset($_SESSION['login'])) { @@ -375,8 +387,13 @@ function banner($print) { function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) { // look up a single field in a database given a value for a single field - $out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"")); - return($out_data[0]); + $dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""); + if (mysqli_num_rows($dbqry)) { + $out_data=mysqli_fetch_row($dbqry)[0]; + } else { + $out_data=NULL; + } + return($out_data); } function calendar($year,$month,$day,$link_url) { @@ -625,63 +642,53 @@ function islink($il_note) { // determines if the argument is a link in a reference chain // returns 1 if note is a link, 0 if not global $db; - $il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\"")); - if ($il_pq[0]=="") { - $il_hasprev=0; - } else { - $il_hasprev=1; - } - $il_sq=mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where refs like \"%$il_note%\"")); - if ($il_sq) { - $il_hassubs=1; - } else { - $il_hassubs=0; - } - if($il_hassubs || $il_hasprev) { + $refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')"); + if (mysqli_num_rows($refqry)) { return 1; } else { return 0; } } + function generate_chain($chainlink) { // generate a reference chain // takes a single parameter, a noteid // finds all notes that are members of a chain containing the supplied noteid - // returns a sorted array of all notes in chain + // returns a sorted array (chainarray) of all notes in chain global $db; - $refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\""); - $nanote=array(); - $narefs=array(); - while ($allrefs=mysqli_fetch_row($refsqry)) { - $spltrefs=explode(",",$allrefs[1]); - $iptr=0; - while ($iptr"); $note=mysqli_real_escape_string($db,$note); - // remove cruft from references and sanitize - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - $refs=mysqli_real_escape_string($db,$refs); + if (strlen($refstring)) { + // remove everything except numbers and spaces from references and sanitize + $refstring=preg_replace("#[^\d ]{1,}#"," ",$refstring); + $refstring=mysqli_real_escape_string($db,$refstring); + $refstring=trim($refstring); + } if ($doparts==1) { // inspect part data @@ -137,19 +154,29 @@ if ($add) { } if ($authorized) { // add the record to lognotes - mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote,refs) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\",\"$refs\")"); + mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); $newnoteid=mysqli_insert_id($db); - // add this noteid to the appropriate flag_tables + // add references to the reflinks table + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(noteid,target) values($newnoteid,$target)"); + } + } $chainmembers=generate_chain($newnoteid); - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; + + // update the flagmap table + foreach ($flags as $thisflag) { // set flag for this note - mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$newnoteid\")"); + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")"); if ($syncflags) { //set flag for reference chain notes foreach ($chainmembers as $refdnote) { - mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$refdnote\")"); + if ($refdnote != $newnoteid) { + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + } } } } @@ -220,98 +247,17 @@ if ($add) { } } } - } elseif ($loadtemplate) { - if ($templateid) { - $templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); - $defaultshift=$templatevalues["shift"]; - $defaultsubject=$templatevalues["subject"]; - $note=$templatevalues["lognote"]; - $refto=$templatevalues["refs"]; - $techid=$templatevalues["tech"]; + } else { + if ($loadtemplate) { + $templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); + $defaultshift=$templatevalues["shift"]; + $defaultsubject=$templatevalues["subject"]; + $note=$templatevalues["lognote"]; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($thistgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$thistgt[0]; } - } elseif ($savetemplate) { - if ($note) { - // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - - // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - if ($authorized) { - if ($templateid) { - // update the existing template - mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where templateid=\"$templateid\""); - - // update the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $thisflag_tbl="flag_".$thisflagid[0]; - if ($flags[0]=="") $flags=[]; - if (in_array($thisflagid[0],$flags)) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) { - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"notetemplates\",\"$templateid\")"); - } - } else { - if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) { - mysqli_query($db,"delete from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""); - } - } - } - } else { - // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) { - // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")"); - $newtemplateid=mysqli_insert_id($db); - - // add this templateid to the appropriate flag_tables - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; - mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")"); - } - $templateid=$newtemplateid; - } else { - $save_nameexists=TRUE; - } - } - } } - } elseif ($copytemplate) { - if ($note) { - // remove cruft from note text - $note=strip_tags($note,""); - $note=mysqli_real_escape_string($db,$note); - - // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); - if ($authorized) { - // check if supplied name already exists - if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) { - // add the record to notetemplates - mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")"); - $newtemplateid=mysqli_insert_id($db); - - // add this templateid to the appropriate flag_tables - foreach ($flags as $flagtblnum) { - $flagtblname="flag_".$flagtblnum; - mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")"); - } - $templateid=$newtemplateid; - } else { - $copy_nameexists=TRUE; - } - } - } - } elseif ($deltemplate) { - // delete from notetemplates table - mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); - // delete occurances from the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $delflag_tbl="flag_".$thisflagid[0]; - mysqli_query($db,"delete from $delflag_tbl where target=\"notetemplates\" and id=\"$templateid\""); - } - unset($templateid); } } if ($edit) { @@ -323,7 +269,10 @@ if ($edit) { $note=mysqli_real_escape_string($db,$note); // remove cruft from references - $refs=preg_replace("#[a-zA-Z]{1,}#","",$refs); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refstring=preg_replace("#[a-zA-Z]{1,}#","",$refstring); + } if ($doparts==1) { // inspect part data @@ -359,31 +308,37 @@ if ($edit) { if ($authorized) { // update lognotes table - mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where lognoteid=\"$noteid\""); + mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where lognoteid=\"$noteid\""); - // update the flag_tables - $flagids=mysqli_query($db,"select flagid from flags"); + // update the reflinks table + mysqli_query($db,"delete from reflinks where noteid=\"$noteid\""); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach($refarray as $thisref) { + mysqli_query($db,"insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")"); + } + } $chainmembers=generate_chain($noteid); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $thisflag_tbl="flag_".$thisflagid[0]; - if ($flags[0]=="") $flags=[]; - if (in_array($thisflagid[0],$flags)) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { - // set flag for this noteid - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$noteid\")"); - // set flag for reference chain notes - if ($syncflags) { - foreach($chainmembers as $refdnote) { - if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$refdnote\""))) { - mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$refdnote\")"); - } - } - } + + // update the flagmap table + mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + if ($syncflags) { + foreach ($chainmembers as $refdnote) { + if ($refdnote != $noteid) { + mysqli_query($db,"delete from flagmap where lognoteid=\"$refdnote\""); } - } else { - if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { - // clear flag for this note - mysqli_query($db,"delete from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""); + } + } + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")"); + if ($syncflags) { + //set flag for reference chain notes + foreach ($chainmembers as $refdnote) { + if ($refdnote != $noteid) { + mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")"); + } } } } @@ -449,25 +404,48 @@ if ($edit) { } else { // no part info was entered + ; } } } } } } - // refresh the note in question from the database - $getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\""); + if ($loadtemplate) { + // get the note in question from the selected template + $getnote=mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""); + } else { + // refresh the note in question from the database + $getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\""); + } $notetoedit=mysqli_fetch_assoc($getnote); } if ($delete) { + // find notes having this note as a target + $drefnoteqry=mysqli_query($db,"select noteid from reflinks where target=\"$noteid\""); + while ($drefnoterow=mysqli_fetch_assoc($drefnoteqry)) { + $drefnotes[]=$drefnoterow["noteid"]; + } + // find targets for this note + $dreftgtqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); + while ($dreftgtrow=mysqli_fetch_assoc($dreftgtqry)) { + $dreftgts[]=$dreftgtrow["target"]; + } + // for every note having this one as a target, add this note's targets + foreach ($drefnotes as $drefnote) { + foreach ($dreftgts as $dreftgt) { + mysqli_query($db,"insert into reflinks(noteid,target) values(\"$drefnote\",\"$dreftgt\")"); + } + } + // delete this note from reflinks + mysqli_query($db,"delete from reflinks where noteid is not null and (noteid=\"$noteid\" or target=\"$noteid\")"); + // delete from lognotes table mysqli_query($db,"delete from lognotes where lognoteid=\"$noteid\""); - // delete occurances from the flag_ tables - $flagids=mysqli_query($db,"select flagid from flags"); - while ($thisflagid=mysqli_fetch_row($flagids)) { - $delflag_tbl="flag_".$thisflagid[0]; - mysqli_query($db,"delete from $delflag_tbl where target=\"lognotes\" and id=\"$noteid\""); - } + + // delete occurances from the flagmap table + mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\""); + // delete occurances from the logparts table mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\""); } @@ -488,17 +466,23 @@ if ($add) { $notetime=$now; } if ($edit || $delete) { - $notedate=$notetoedit["date"]; - $notetime=$notetoedit["time"]; + $notedate=$notetoedit["date"] ?? $today; + $notetime=$notetoedit["time"] ?? $now; $defaultshift=$notetoedit["shift"]; $defaultsubject=$notetoedit["subject"]; + $note=$notetoedit["lognote"]; - $refto=$notetoedit["refs"]; + // generate reference string for this note + if ($submit) { + $refstring=NULL; + } + $refstringqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\""); + while ($thistgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$thistgt[0]; + } $techid=$notetoedit["tech"]; } $techname=dblookup($db,"techs","techid","techname",$techid); -$copy_nameexists=$copy_nameexists ?? NULL; -$save_nameexists=$save_nameexists ?? NULL; if ($submit) { if ($note) { if ($add) { @@ -514,54 +498,64 @@ if ($submit) { if ($delete) { format_message(0,"Note deleted. Return to main page."); } -if ($copy_nameexists) { - format_message(1,"Template copy failed because the name you supplied already exists."); -} -if ($save_nameexists) { - format_message(1,"Template save failed because the name you supplied already exists."); -} echo "
"; if ($_SESSION['login']) { // generate template line echo " -
- "; - if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$templateid); + // list user templates + echo " + +  or  "; - - if ($loadtemplate) { - echo " - - - "; - } - + // list global templates echo " +    + "; + // show load button + echo " + + +
+    - -   - - - - - + Manage templates +

"; @@ -641,28 +635,32 @@ echo "
-Note: 
+Note: 

- Insert Link
+  +  +Insert Link
"; -// get an array of flagids set for this noteid + +// create an array called theseflags of flagids set for this noteid $allflags=mysqli_query($db,"select flagid from flags"); unset($theseflags); $theseflags=[]; while ($thisflag=mysqli_fetch_row($allflags)) { - $thisflagtbl="flag_".$thisflag[0]; if ($templateid) { - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"notetemplates\" and id=\"$templateid\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { $theseflags[]=$thisflag[0]; } } else { - if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"lognotes\" and id=\"$noteid\""))) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and lognoteid=\"$noteid\""))) { $theseflags[]=$thisflag[0]; } } } + +// if adding a note/template, only show active flags, otherwise, show all flags if ($add) { $flagslist=mysqli_query($db,"select * from flags where status=1"); } else { @@ -670,6 +668,8 @@ if ($add) { } $flagsperline=8; $flagcount=1; + +// display checkboxes for all the flags, selecting the ones that are set for this note/template while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { if (in_array($flagcheckbox["flagid"],$theseflags)) { @@ -692,8 +692,12 @@ while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { } echo "
Set flags on reference chain +"; + +if ($add && $refto) $refstring=$refto; +echo "

References:   -         +                               "; if ($add) { diff --git a/distfiles/login.php b/distfiles/login.php index bef3ff6..ba8f9a8 100644 --- a/distfiles/login.php +++ b/distfiles/login.php @@ -2,7 +2,7 @@ /* login.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/lognotes.php b/distfiles/lognotes.php index 1854e05..13365ca 100644 --- a/distfiles/lognotes.php +++ b/distfiles/lognotes.php @@ -2,7 +2,7 @@ /* lognotes.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ @@ -42,14 +42,14 @@ function shifttable_classic($shift, $tgt_date, $db) { if ($dshdr) { // print the shift header printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "
\n"; echo "\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $reftonote=$tablerow["lognoteid"]; - $refs="    \"Add"; - if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $thisnote=$tablerow["lognoteid"]; + $refs="    \"Add"; + if (islink($thisnote)) { + $refs=$refs."      \"View"; } // convert tech number to name $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); @@ -59,27 +59,24 @@ function shifttable_classic($shift, $tgt_date, $db) { $fmtnote=convertweblinks($tablerow["lognote"]); // generate the flags string $flagstring=""; - $allflagqry=mysqli_query($db,"select flagid from flags"); - while ($allflagids=mysqli_fetch_row($allflagqry)) { - $flagid=$allflagids[0]; - $flag_tbl="flag_".$flagid; - if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagname=$flagparam["flagname"]; - $flagstring=$flagstring."$flagsym  "; - } + $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; } if ($flagstring) { $fmtnote=$fmtnote."
".$flagstring."     "; } else { $fmtnote=$fmtnote."
"; } + if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote=$fmtnote."PARTS"; } } // now print the line in the table @@ -134,14 +131,14 @@ function shifttable_clean($shift, $tgt_date, $db) { if ($dshdr) { // print the shift header printf("%s\n",$shname); - $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); + $note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc"); echo "

"; echo "
Note IDTechSubjectNoteReferences
diff --git a/distfiles/schedmaint.php b/distfiles/schedmaint.php index 62a983a..db5e130 100644 --- a/distfiles/schedmaint.php +++ b/distfiles/schedmaint.php @@ -2,7 +2,7 @@ /* blankpage.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/search.php b/distfiles/search.php index 04d774b..0b9e9cb 100644 --- a/distfiles/search.php +++ b/distfiles/search.php @@ -2,7 +2,7 @@ /* search.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/settings.php b/distfiles/settings.php index a538c53..cebd1a0 100644 --- a/distfiles/settings.php +++ b/distfiles/settings.php @@ -2,7 +2,7 @@ /* settings.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/templates.php b/distfiles/templates.php new file mode 100644 index 0000000..b8fb6d8 --- /dev/null +++ b/distfiles/templates.php @@ -0,0 +1,616 @@ +"; + if ($hastemplates) { + // print the user header + if ($user=="0") { + echo "Global Templates"; + if ($isadmin) { + echo "    Create or copy a global template
"; + } + } else { + if ($user==$techid) { + echo "My templates"; + echo "    Create or copy a template
"; + } else { + echo "Templates for $tblusername"; + } + } + // print the table + echo "
\n"; while ($tablerow = mysqli_fetch_assoc($note)) { - $reftonote=$tablerow["lognoteid"]; - $refs="    \"Add"; + $thisnote=$tablerow["lognoteid"]; + $refs="    \"Add"; if (islink($tablerow["lognoteid"])) { - $refs=$refs."      \"View"; + $refs=$refs."      \"View"; } // convert tech number to name $tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]); @@ -151,17 +148,13 @@ function shifttable_clean($shift, $tgt_date, $db) { $fmtnote=convertweblinks($tablerow["lognote"]); // generate the flags string $flagstring=""; - $allflagqry=mysqli_query($db,"select flagid from flags"); - while ($allflagids=mysqli_fetch_row($allflagqry)) { - $flagid=$allflagids[0]; - $flag_tbl="flag_".$flagid; - if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) { - $flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); - $flagcolor=$flagparam["flagcolor"]; - $flagsym=$flagparam["flagsym"]; - $flagname=$flagparam["flagname"]; - $flagstring=$flagstring."$flagsym  "; - } + $flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; } if ($flagstring) { $fmtnote=$fmtnote."
".$flagstring."     "; @@ -170,8 +163,8 @@ function shifttable_clean($shift, $tgt_date, $db) { } if ($doparts) { // turn on the parts indicator if parts were entered with the note - if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) { - $fmtnote=$fmtnote."PARTS"; + if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) { + $fmtnote=$fmtnote."PARTS"; } } // now print the line in the table diff --git a/distfiles/maintform.php b/distfiles/maintform.php index 933db51..ca15206 100644 --- a/distfiles/maintform.php +++ b/distfiles/maintform.php @@ -2,7 +2,7 @@ /* maintform.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/maintformentry.php b/distfiles/maintformentry.php index 46a4e26..a714180 100644 --- a/distfiles/maintformentry.php +++ b/distfiles/maintformentry.php @@ -2,7 +2,7 @@ /* maintformentry.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/partentry.php b/distfiles/partentry.php index fdd1b94..08a5490 100644 --- a/distfiles/partentry.php +++ b/distfiles/partentry.php @@ -2,7 +2,7 @@ /* partentry.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/parts.php b/distfiles/parts.php index 5dbcc08..9d6b6d1 100644 --- a/distfiles/parts.php +++ b/distfiles/parts.php @@ -2,7 +2,7 @@ /* parts.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/profile.php b/distfiles/profile.php index c299f66..15af5cb 100644 --- a/distfiles/profile.php +++ b/distfiles/profile.php @@ -2,7 +2,7 @@ /* profile.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ diff --git a/distfiles/refchain.php b/distfiles/refchain.php index db77d8c..d871b7e 100644 --- a/distfiles/refchain.php +++ b/distfiles/refchain.php @@ -2,14 +2,14 @@ /* refchain.php OpenLog Online Logbook - Copyright (C) 2025 Rod Wright + Copyright (C) 2026 Rod Wright SPDX-License-Identifier: GPL-2.0 */ include("functions.php"); -$print=$_REQUEST['print']; +$print=$_REQUEST['print'] ?? ""; $chainnote=$_REQUEST['chainnote']; $logname=LOG_NAME; @@ -59,17 +59,29 @@ while($mptr$flagsym  "; } } + + //$allflagqry=mysqli_query($db,"select flagid from flags"); + //while ($allflagids=mysqli_fetch_row($allflagqry)) { + //$flagid=$allflagids[0]; + //$flag_tbl="flag_".$flagid; + //if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) { + //$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\"")); + //$flagcolor=$flagparam["flagcolor"]; + //$flagsym=$flagparam["flagsym"]; + //$flagstring=$flagstring."$flagsym  "; + //} + //} + if ($flagstring) $fmtnote=$fmtnote."
".$flagstring; printf("
"; + echo ""; + while ($tablerow = mysqli_fetch_assoc($templatequery)) { + $templateid=$tablerow["templateid"]; + $templatename=$tablerow["templatename"]; + // convert shift number to name + $shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]); + // convert subject number to name + $subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]); + // create links of urls in note + $fmtnote=convertweblinks($tablerow["lognote"]); + // generate the flags string + $flagstring=""; + $flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid"); + while ($flagid=mysqli_fetch_row($flagqry)) { + $flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\"")); + $flagcolor=$flagparams["flagcolor"]; + $flagsym=$flagparams["flagsym"]; + $flagname=$flagparams["flagname"]; + $flagstring=$flagstring."$flagsym  "; + } + if ($flagstring) { + $fmtnote=$fmtnote."
".$flagstring."     "; + } else { + $fmtnote=$fmtnote."
"; + } + // generate a reference string + $refstring=NULL; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($tgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$tgt[0]; + } + // now print the line in the table + if (!$isadmin && $user=="0") { + $nameblock="$templatename"; + } else { + $nameblock="$templatename"; + } + printf( + " + + + + + + \n", + $nameblock, + $shiftname, + $subjname, + $fmtnote, + $refstring + ); + }; + echo "
Template NameShiftSubjectNoteReferences
%s %s%s%s%s



"; + } else { + if ($user=="0") { + echo "There are no global templates"; + if ($isadmin) { + echo "    Add a new global template"; + } + } else { + if ($user==$techid) { + echo "You have no templates"; + } else { + echo "$tblusername has no templates"; + } + if (($user==$techid) || $isadmin) { + echo "    Add a new template
"; + } + } + echo "

"; + } + echo "
"; +} + +function templateselect($db,$techid) { + echo " + + "; + // generate template selection line + echo " + + "; + // list user templates + echo " + + +
+  or  + "; + // list global templates + echo " +    + "; + // show load button + echo " + + + Manage templates +
+
+
+ "; +} + +// ******** begin database manipulation ******** + +if ($usertemplateid) { + $templateid=$usertemplateid; +} else if ($globaltemplateid) { + $templateid=$globaltemplateid; +} else { + $loadtemplate=NULL; +} + +if ($add) { + if ($submit) { + if ($note) { + // remove cruft from note text + $note=strip_tags($note,""); + $note=mysqli_real_escape_string($db,$note); + + if ($add_auth) { + // check if name supplied + if ($templatename) { + $namesupplied=TRUE; + // check if supplied name already exists + if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) { + // add the record to notetemplates + mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")"); + $newtemplateid=mysqli_insert_id($db); + + // update the flagmap table + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")"); + } + + // add references to the reflinks table + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)"); + } + } + $templateid=$newtemplateid; + } else { + $nameexists=TRUE; + } + } else { + $namesupplied=FALSE; + } + } + } + } +} +if ($edit) { + if ($submit) { + if ($note) { + // remove cruft from note text + $note=strip_tags($note,""); + $note=mysqli_real_escape_string($db,$note); + + if ($edit_auth) { + // check if name was supplied + if ($templatename) { + $namesupplied=TRUE; + // update notetemplates + mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\""); + + // update the flagmap table + mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + foreach ($flags as $thisflag) { + // set flag for this note + mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")"); + } + + // update the reflinks table + mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + if (strlen($refstring)) { + $refstring=trim($refstring); + $refarray=explode(" ",$refstring); + foreach ($refarray as $target) { + mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)"); + } + } + } else { + $namesupplied=FALSE; + } + } + } + } + if ($delete) { + if ($del_auth) { + // update notetemplates + mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\""); + // update the flagmap table + mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\""); + // update the reflinks table + mysqli_query($db,"delete from reflinks where templateid=\"$templateid\""); + $templateid=NULL; + $note=NULL; + } + } +} + +// ******** end database manipulation ******** + +pagetable("begin"); +if (!$print) { + pageblock("left","begin"); + sidemenu(); + pageblock("left","end"); +} +pageblock("right","begin"); +banner($print); + + +if ($submit || $delete) { + // show success/failure messages + $nameexists=$nameexists ?? NULL; + $namesupplied=$namesupplied ?? NULL; + if ($delete) { + format_message(0,"Template deleted."); + } else { + $addfail=FALSE; + if ($add) { + if ($nameexists) { + format_message(1,"Template save failed because the name you supplied already exists. Please try again."); + $addfail=TRUE; + } + if (!$namesupplied) { + format_message(1,"Template save failed because you didn't supply a name. Please try again."); + $addfail=TRUE; + } + if (!$note) { + format_message(1,"Template save failed because you didn't enter any note text. Please try again."); + $addfail=TRUE; + } + if (!$addfail) format_message(0,"Template added."); + } + $editfail=FALSE; + if ($edit) { + if (!$namesupplied) { + format_message(1,"Template save failed because you didn't supply a name. Please try again."); + $editfail=TRUE; + } + if (!$note) { + format_message(1,"Template save failed because you didn't enter any note text. Please try again."); + $editfail=TRUE; + } + if (!$editfail) format_message(0,"Template modified."); + } + } +} + +if ($delete) { + // just show the link back to the templates page + echo " +
Manage templates



+ "; +} else if ($add || $edit) { + // Display the input form + if ($loadtemplate) { + // make templateid the selected template + if ($usertemplateid) { + $templateid=$usertemplateid; + } else if ($globaltemplateid) { + $templateid=$globaltemplateid; + } else { + $templateid=NULL; + } + } + if ($edit || $loadtemplate) { + // use values from the templateid supplied with a defined tech id + $loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"")); + $filltemplatename=$loadeddata["templatename"]; + if ($tech) { + $filltech=$tech; + } else if ($efftechid) { + $filltech=$efftechid; + } else { + $filltech=$techid; + } + $fillshift=$loadeddata["shift"]; + $fillsubject=$loadeddata["subject"]; + $fillnote=$loadeddata["lognote"]; + } else { + // use empty values with a defined tech id + $filltemplatename=NULL; + if ($tech) { + $filltech=$tech; + } else if ($efftechid) { + $filltech=$efftechid; + } else { + $filltech=$techid; + } + $fillshift=$defaultshift; + $fillsubject=NULL; + $fillnote=NULL; + } + + if ($add) $optext="Adding new"; + if ($edit) $optext="Editing"; + if ($isadmin && $filltech==0) { + echo " +
$optext global template

+ "; + } else { + echo " +
$optext user template

+ "; + } + + // show the template selection line + templateselect($db,$techid); + + // start template entry section + echo " +
+ + + "; + if ($isadmin) { + if ($filltech!="0") { + // allow tech selection + echo " + + "; + } else { + // don't show tech line, just force value to 0 + echo " + + "; + } + } else { + $add_auth=TRUE; + $edit_auth=TRUE; + echo " + + "; + } + echo " + + + +
Template Name:   +
Tech:   +
Shift:   + Subject:   +
+ + Note: 
+
+   +   + Insert Link
+ "; + + // create an array called theseflags and optionally load it with flagids set for this template + unset($theseflags); + $theseflags=[]; + if ($templateid) { + $allflags=mysqli_query($db,"select flagid from flags"); + while ($thisflag=mysqli_fetch_row($allflags)) { + if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) { + $theseflags[]=$thisflag[0]; + } + } + } + + $flagslist=mysqli_query($db,"select * from flags where status=1"); + $flagsperline=8; + $flagcount=1; + + // display checkboxes for all the flags, selecting the ones that are set for this template + while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) { + if ($edit && in_array($flagcheckbox["flagid"],$theseflags)) { + printf("%s", + $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + } else { + $flagid=$flagcheckbox["flagid"]; + if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) { + printf("%s", + $flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]); + } + } + if ($flagcount<$flagsperline) { + echo "   "; + $flagcount++; + } else { + echo "
"; + $flagcount=1; + } + } + + if ($edit || $loadtemplate) { + // generate a reference string + $refstring=NULL; + $refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\""); + while ($tgt=mysqli_fetch_row($refstringqry)) { + $refstring=$refstring." ".$tgt[0]; + } + } + echo " +

References:   +          +                       + "; + + if ($add && $add_auth) { + echo " + + + "; + } + if ($edit && $edit_auth) { + echo " + + + + "; + if ($del_auth) { + echo" +      

+ Deleted templates are irretrievable! + "; + } + } + + echo " +
+
+ "; +} else { + echo "
"; + // Show my user template table + templatetable($db,$techid,$techid); + + // Show global template table + templatetable($db,$techid,"0"); + + if ($isadmin) { + // Show template tables for other users + $techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0"); + while ($techtblrow=(mysqli_fetch_row($techqry))) { + templatetable($db,$techid,$techtblrow[0]); + } + } +} + + +banner($print); +pageblock("right","end"); +pagetable("end"); + +framework("end","","",$print); + +?> diff --git a/files-update.sh b/files-update.sh index de5086f..962ad47 100755 --- a/files-update.sh +++ b/files-update.sh @@ -41,8 +41,3 @@ fi # ---------- version 5.2.4.4 ----------- # No changes # -------------------------------------- - -# ---------- version 5.2.5 ------------- -# No changes -# -------------------------------------- - diff --git a/install.sh b/install.sh index 46fe055..c26db53 100755 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ APP_NAME="OpenLog" DEFAULT_DB_NAME="openlog" -APP_VERSION="5.2.5" +APP_VERSION="5.3.0" DOC_ROOT="/var/www" INSTALL_LOC="openlog" APACHE_CONF_DIR="/etc/apache2/conf-available"