Compare commits
5 Commits
a79f73a8ca
...
f74385d8f3
| Author | SHA1 | Date | |
|---|---|---|---|
| f74385d8f3 | |||
| 9e392faa4d | |||
| d2cb1851d0 | |||
| 07a6d352b0 | |||
| 0547e97479 |
@@ -39,5 +39,80 @@ margs="--defaults-extra-file=$mysql_opt_file"
|
||||
# -------------------------------------
|
||||
|
||||
# ---------- version 5.3.0 ------------
|
||||
# Nothing to do
|
||||
#
|
||||
echo "Started database updates for OpenLog version 5.3.0..."
|
||||
|
||||
# Import old flag data from old scheme to new flagmap table
|
||||
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
|
||||
then
|
||||
echo "Importing flag data from old scheme to new flagmap table..."
|
||||
for flagnumber in $(mysql $margs -e "select flagid from flags")
|
||||
do
|
||||
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
|
||||
if [[ -n "$flag_x" ]]
|
||||
then
|
||||
for tgtid in $(mysql $margs -e "select id from flag_$flagnumber")
|
||||
do
|
||||
target=$(mysql $margs -e "select target from flag_$flagnumber where id=$tgtid")
|
||||
if [[ $target == "lognotes" ]]
|
||||
then
|
||||
mysql $margs -e "insert into flagmap(flagid,lognoteid) values($flagnumber,$tgtid)"
|
||||
elif [[ $target == "maintforms" ]]
|
||||
then
|
||||
mysql $margs -e "insert into flagmap(flagid,maintformid) values($flagnumber,$tgtid)"
|
||||
elif [[ $target == "notetemplates" ]]
|
||||
then
|
||||
mysql $margs -e "insert into flagmap(flagid,notetemplateid) values($flagnumber,$tgtid)"
|
||||
fi
|
||||
|
||||
done
|
||||
mysql $margs -e "drop table flag_$flagnumber"
|
||||
fi
|
||||
done
|
||||
echo "...done."
|
||||
fi
|
||||
|
||||
# Import reference chain data into new reflinks table
|
||||
if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]]
|
||||
then
|
||||
echo "Importing lognote reference chain data into new reflinks table..."
|
||||
for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
|
||||
do
|
||||
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
|
||||
oldifs=$IFS
|
||||
IFS=', '
|
||||
for target in $refstring
|
||||
do
|
||||
target=$(echo "$target" | xargs)
|
||||
mysql $margs -e "insert into reflinks(noteid,target) values($note,$target)"
|
||||
done
|
||||
IFS=$oldifs
|
||||
done
|
||||
echo "...done."
|
||||
echo "Importing template reference chain data into new reflinks table..."
|
||||
for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
|
||||
do
|
||||
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
|
||||
oldifs=$IFS
|
||||
IFS=', '
|
||||
for target in $refstring
|
||||
do
|
||||
target=$(echo "$target" | xargs)
|
||||
mysql $margs -e "insert into reflinks(templateid,target) values($template,$target)"
|
||||
done
|
||||
IFS=$oldifs
|
||||
done
|
||||
echo "...done."
|
||||
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1
|
||||
mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# Convert database to utf8mb4/utf8mb4_unicode_ci
|
||||
echo "Converting database to utf8mb4 encoding..."
|
||||
mysql $margs -e "ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"
|
||||
for table in $(mysql $margs -e "show tables")
|
||||
do
|
||||
mysql $margs -e "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||
done
|
||||
echo "...done."
|
||||
# -------------------------------------
|
||||
|
||||
@@ -59,4 +59,24 @@ 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";
|
||||
|
||||
-- Create the flagmap table
|
||||
CREATE TABLE IF NOT EXISTS `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_unicode_ci;
|
||||
|
||||
-- Create the reflinks table
|
||||
CREATE TABLE IF NOT EXISTS `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_unicode_ci;
|
||||
|
||||
-- --------------------------------------
|
||||
|
||||
@@ -931,4 +931,54 @@ function format_message($msgtype,$msgtxt) {
|
||||
";
|
||||
}
|
||||
|
||||
function templateselect($techid,$operation) {
|
||||
// Displays a line enabling selection of a user or global template
|
||||
// $techid is the id number of the current tech
|
||||
// $operation is one of "add" "edit" "delete"
|
||||
global $db;
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
";
|
||||
// generate template selection line
|
||||
echo "
|
||||
<table border=\"0\" cellpadding=\"10\"><tr>
|
||||
";
|
||||
// list user templates
|
||||
echo "
|
||||
<td>
|
||||
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
echo "
|
||||
</select> or
|
||||
";
|
||||
// list global templates
|
||||
echo "
|
||||
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
";
|
||||
// show load button
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"operation\" value=\"$operation\">
|
||||
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
|
||||
</td>
|
||||
<td>
|
||||
<a href=\"templates.php\">Manage templates</a>
|
||||
</td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -34,7 +34,7 @@ $srchpname=$_REQUEST['srchpname'] ?? NULL;
|
||||
$srchploc=$_REQUEST['srchploc'] ?? NULL;
|
||||
$srchnha=$_REQUEST['srchnha'] ?? NULL;
|
||||
$srchrepord=$_REQUEST['srchrepord'] ?? NULL;
|
||||
$srchflags=$_REQUEST['srchflags'] ?? NULL;
|
||||
$srchflags=$_POST['srchflags'] ?? [];
|
||||
$target=$_REQUEST['target'] ?? NULL;
|
||||
|
||||
$doparts=PARTS_FUNCTIONS;
|
||||
@@ -57,6 +57,15 @@ framework("begin","$logname Search","Search",$print);
|
||||
//var_dump($_REQUEST);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
// define the arrays
|
||||
$logfromtables=[];
|
||||
$mffromtables=[];
|
||||
$pfromtables=[];
|
||||
$logconstraints=[];
|
||||
$mfconstraints=[];
|
||||
$pconstraints=[];
|
||||
|
||||
// get the date range of lognotes
|
||||
$logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes");
|
||||
$logdateresults=mysqli_fetch_row($logdateqry);
|
||||
@@ -75,8 +84,6 @@ if ($mfmaxdate == "") $mfmaxdate = $today;
|
||||
$mindate=min($logmindate, $mfmindate);
|
||||
$maxdate=max($logmaxdate, $mfmaxdate);
|
||||
|
||||
|
||||
|
||||
if ($search) {
|
||||
// strip whitespace from beginning and end of text fields
|
||||
$srchtext=trim($srchtext);
|
||||
@@ -122,8 +129,9 @@ if ($search) {
|
||||
$logfromtables[]="lognotes";
|
||||
$logconstraints[]="lognotes.lognote like \"%$srchtext%\"";
|
||||
}
|
||||
// fixme
|
||||
// flags
|
||||
if ($srchflags != NULL) {
|
||||
if (!empty($srchflags)) {
|
||||
foreach ($srchflags as $flagtblnum) {
|
||||
$flagtblname="flag_{$flagtblnum}";
|
||||
$logfromtables[]="lognotes";
|
||||
@@ -231,6 +239,7 @@ if ($search) {
|
||||
$mffromtables[]="maintactions";
|
||||
$mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
|
||||
}
|
||||
// fixme
|
||||
// flags
|
||||
foreach ($srchflags as $flagtblnum) {
|
||||
$flagtblname="flag_{$flagtblnum}";
|
||||
@@ -463,27 +472,37 @@ if (!$print) {
|
||||
<br><br>
|
||||
<b>Flags:</b>
|
||||
";
|
||||
$flagslist=mysqli_query($db,"select * from flags");
|
||||
$flagsperline=8;
|
||||
$flagcount=1;
|
||||
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
||||
if ($srchflags[0]=="") $srchflags=[];
|
||||
if (in_array($flagcheckbox["flagid"],$srchflags)) {
|
||||
printf("<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
$flagslist = mysqli_query($db, "select * from flags");
|
||||
$flagsperline = 8;
|
||||
$flagcount = 1;
|
||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||
if ($srchflags[0] == "") $srchflags = [];
|
||||
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$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("<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
$flagid = $flagcheckbox["flagid"];
|
||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],
|
||||
$flagcheckbox["flagcolor"],
|
||||
$flagcheckbox["flagname"],
|
||||
$flagcheckbox["flagsym"]
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($flagcount<$flagsperline) {
|
||||
if ($flagcount < $flagsperline) {
|
||||
echo " ";
|
||||
$flagcount++;
|
||||
} else {
|
||||
echo "<br>";
|
||||
$flagcount=1;
|
||||
$flagcount = 1;
|
||||
}
|
||||
}
|
||||
echo "
|
||||
@@ -656,20 +675,23 @@ if ($search) {
|
||||
$logsubjname=dblookup($db,"subjects","subjectid","subjectname",$logtablerow['subject']);
|
||||
// create links of urls in note
|
||||
$logfmtnote=convertweblinks($logtablerow['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=\"$logtablerow[lognoteid]\""))) {
|
||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
||||
$flagcolor=$flagparam["flagcolor"];
|
||||
$flagsym=$flagparam["flagsym"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font> ";
|
||||
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$logtablerow[lognoteid]");
|
||||
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."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$logfmtnote=$logfmtnote."<br>".$flagstring." ";
|
||||
} else {
|
||||
$logfmtnote=$logfmtnote."<br>";
|
||||
}
|
||||
if ($flagstring) $logfmtnote=$logfmtnote."<br>".$flagstring;
|
||||
|
||||
printf("<tr>
|
||||
<td valign=\"top\"><a href=logentry.php?edit=1¬eid=%s>%s</a></td>
|
||||
<td valign=\"top\">%s / %s</td>
|
||||
|
||||
@@ -24,9 +24,6 @@ $flags=$_POST['flags'] ?? [];
|
||||
$refstring=$_REQUEST['refstring'] ?? NULL;
|
||||
$submit=$_REQUEST['submit'] ?? NULL;
|
||||
$operation=$_REQUEST['operation'] ?? NULL;
|
||||
//$add=$_REQUEST['add'] ?? NULL;
|
||||
//$edit=$_REQUEST['edit'] ?? NULL;
|
||||
//$delete=$_REQUEST['delete'] ?? NULL;
|
||||
$templateid=$_REQUEST['templateid'] ?? NULL;
|
||||
$templatename=$_REQUEST['templatename'] ?? NULL;
|
||||
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
|
||||
@@ -59,7 +56,7 @@ if ($isadmin) {
|
||||
$authorized=FALSE;
|
||||
}
|
||||
|
||||
var_dump($_REQUEST);
|
||||
// var_dump($_REQUEST);
|
||||
|
||||
function templatetable($db,$techid,$user) {
|
||||
// Show template table
|
||||
@@ -154,53 +151,6 @@ function templatetable($db,$techid,$user) {
|
||||
echo "<br>";
|
||||
}
|
||||
|
||||
function templateselect($db,$techid,$operation) {
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
";
|
||||
// generate template selection line
|
||||
echo "
|
||||
<table border=\"0\" cellpadding=\"10\"><tr>
|
||||
";
|
||||
// list user templates
|
||||
echo "
|
||||
<td>
|
||||
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
echo "
|
||||
</select> or
|
||||
";
|
||||
// list global templates
|
||||
echo "
|
||||
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
";
|
||||
// show load button
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"operation\" value=\"$operation\">
|
||||
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
|
||||
</td>
|
||||
<td>
|
||||
<a href=\"templates.php\">Manage templates</a>
|
||||
</td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
if ($usertemplateid) {
|
||||
@@ -423,9 +373,8 @@ if ($operation=="delete") {
|
||||
<br><b>$optext template</b><br><hr>
|
||||
";
|
||||
|
||||
|
||||
// show the template selection line
|
||||
templateselect($db,$techid,$operation);
|
||||
templateselect($techid,$operation);
|
||||
|
||||
// start template entry section
|
||||
echo "
|
||||
|
||||
11
install.sh
11
install.sh
@@ -12,7 +12,6 @@ APP_VERSION="5.3.0"
|
||||
DOC_ROOT="/var/www"
|
||||
INSTALL_LOC="openlog"
|
||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||
BACKUP_DIR="openlog-previous-installation"
|
||||
LANDING_PAGE="lognotes.php"
|
||||
CONFIG_TABLE="configs"
|
||||
CONFIG_NAME_COLUMN="confname"
|
||||
@@ -202,7 +201,9 @@ then
|
||||
abort_exit
|
||||
else
|
||||
# proceed with upgrade
|
||||
mkdir -p backups
|
||||
datestamp=$(date +%Y-%m-%d_%H:%M:%S)
|
||||
backupdir=backups/$datestamp
|
||||
mkdir -p $backupdir
|
||||
operation="upgraded"
|
||||
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
|
||||
|
||||
@@ -219,11 +220,11 @@ then
|
||||
|
||||
# back up existing database
|
||||
echo "Backing up the current database to the package directory."
|
||||
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
|
||||
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > $backupdir/$curr_dbname-$datestamp-backup.sql
|
||||
|
||||
# back up existing installation
|
||||
echo "Backing up current installation to the package directory."
|
||||
cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
|
||||
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
|
||||
|
||||
# delete all existing installation files except db.php
|
||||
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
|
||||
@@ -267,6 +268,8 @@ then
|
||||
echo ""
|
||||
echo "Setting file ownership . . ."
|
||||
chown -R $httpd_user_group $install_path
|
||||
echo "Backups of the previous openlog files and the previous database were made"
|
||||
echo "and are located in the $backupdir directory."
|
||||
fi
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
|
||||
Reference in New Issue
Block a user