Omit 'preset text' on edit of entries

SVN revision: 941
This commit is contained in:
Stefan Ritt 2004-07-07 15:10:50 +00:00
parent d0ac6a01bc
commit 1944d1bc2f

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.370 2004/07/07 15:10:50 midas
Omit 'preset text' on edit of entries
Revision 1.369 2004/07/07 14:29:06 midas Revision 1.369 2004/07/07 14:29:06 midas
Added note about 'stealing' of locks Added note about 'stealing' of locks
@ -6400,6 +6403,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
time_t now, ltime; time_t now, ltime;
char fl[8][NAME_LENGTH]; char fl[8][NAME_LENGTH];
struct tm *pts, ts; struct tm *pts, ts;
BOOL preset_text;
for (i = 0; i < MAX_ATTACHMENTS; i++) for (i = 0; i < MAX_ATTACHMENTS; i++)
att[i][0] = 0; att[i][0] = 0;
@ -7222,13 +7226,24 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsputs("<br>\n"); rsputs("<br>\n");
} }
preset_text = getcfg(lbs->name, "Preset text", str);
if (preset_text) {
/* don't use preset text if editing */
if (bedit)
preset_text = FALSE;
/* user preset on reedit only if preset is under condition */
if (breedit && getcfg(lbs->name, "Preset text", str) == 2)
preset_text = TRUE;
}
if (!getcfg(lbs->name, "Show text", str) if (!getcfg(lbs->name, "Show text", str)
|| atoi(str) == 1) { || atoi(str) == 1) {
rsprintf("<textarea rows=%d cols=%d wrap=hard name=\"Text\" onChange=\"mod();\">", height, width); rsprintf("<textarea rows=%d cols=%d wrap=hard name=\"Text\" onChange=\"mod();\">", height, width);
if (bedit) { if (bedit) {
if (bupload || (!bupload && !breedit) if (!preset_text) {
|| (breedit && !getcfg(lbs->name, "Preset text", str))) {
j = build_subst_list(lbs, slist, svalue, attrib, TRUE); j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
sprintf(mid, "%d", message_id); sprintf(mid, "%d", message_id);
@ -7317,38 +7332,35 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
} }
if ((i = getcfg(lbs->name, "Preset text", str)) > 0) { if (preset_text) {
getcfg(lbs->name, "Preset text", str);
if (!bedit || (breedit && i == 2)) { /* preset on reedit only if preset is under condition */ /* check if file starts with an absolute directory */
if (str[0] == DIR_SEPARATOR || str[1] == ':')
strcpy(file_name, str);
else {
strlcpy(file_name, resource_dir, sizeof(file_name));
strlcat(file_name, str, sizeof(file_name));
}
/* check if file starts with an absolute directory */ /* check if file exists */
if (str[0] == DIR_SEPARATOR || str[1] == ':') fh = open(file_name, O_RDONLY | O_BINARY);
strcpy(file_name, str); if (fh > 0) {
else { length = lseek(fh, 0, SEEK_END);
strlcpy(file_name, resource_dir, sizeof(file_name)); lseek(fh, 0, SEEK_SET);
strlcat(file_name, str, sizeof(file_name)); buffer = malloc(length + 1);
} read(fh, buffer, length);
buffer[length] = 0;
/* check if file exists */ close(fh);
fh = open(file_name, O_RDONLY | O_BINARY); rsputs(buffer);
if (fh > 0) { free(buffer);
length = lseek(fh, 0, SEEK_END); } else {
lseek(fh, 0, SEEK_SET); j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
buffer = malloc(length + 1); strsubst(str, slist, svalue, j);
read(fh, buffer, length); while (strstr(str, "\\n"))
buffer[length] = 0; memcpy(strstr(str, "\\n"), "\r\n", 2);
close(fh); rsputs(str);
rsputs(buffer); }
free(buffer);
} else {
j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
strsubst(str, slist, svalue, j);
while (strstr(str, "\\n"))
memcpy(strstr(str, "\\n"), "\r\n", 2);
rsputs(str);
}
} else
rsputs(text); /* otherwise keep original text */
} }
rsprintf("</textarea><br>\n"); rsprintf("</textarea><br>\n");