Omit 'preset text' on edit of entries
SVN revision: 941
This commit is contained in:
+44
-32
@@ -6,6 +6,9 @@
|
||||
Contents: Web server program for Electronic Logbook ELOG
|
||||
|
||||
$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
|
||||
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;
|
||||
char fl[8][NAME_LENGTH];
|
||||
struct tm *pts, ts;
|
||||
BOOL preset_text;
|
||||
|
||||
for (i = 0; i < MAX_ATTACHMENTS; i++)
|
||||
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");
|
||||
}
|
||||
|
||||
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)
|
||||
|| atoi(str) == 1) {
|
||||
rsprintf("<textarea rows=%d cols=%d wrap=hard name=\"Text\" onChange=\"mod();\">", height, width);
|
||||
|
||||
if (bedit) {
|
||||
if (bupload || (!bupload && !breedit)
|
||||
|| (breedit && !getcfg(lbs->name, "Preset text", str))) {
|
||||
if (!preset_text) {
|
||||
|
||||
j = build_subst_list(lbs, slist, svalue, attrib, TRUE);
|
||||
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 */
|
||||
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 exists */
|
||||
fh = open(file_name, O_RDONLY | O_BINARY);
|
||||
if (fh > 0) {
|
||||
length = lseek(fh, 0, SEEK_END);
|
||||
lseek(fh, 0, SEEK_SET);
|
||||
buffer = malloc(length + 1);
|
||||
read(fh, buffer, length);
|
||||
buffer[length] = 0;
|
||||
close(fh);
|
||||
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 */
|
||||
/* check if file exists */
|
||||
fh = open(file_name, O_RDONLY | O_BINARY);
|
||||
if (fh > 0) {
|
||||
length = lseek(fh, 0, SEEK_END);
|
||||
lseek(fh, 0, SEEK_SET);
|
||||
buffer = malloc(length + 1);
|
||||
read(fh, buffer, length);
|
||||
buffer[length] = 0;
|
||||
close(fh);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
rsprintf("</textarea><br>\n");
|
||||
|
||||
Reference in New Issue
Block a user