From 70d01d43a05b2d2937bbdc9b0a80c39d72b81789 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Fri, 5 Mar 2004 22:35:15 +0000 Subject: [PATCH] Added Prepend/Append on Edit/Reply SVN revision: 812 --- doc/config.html | 27 ++++++++++---- doc/wishlist.html | 3 +- src/elogd.c | 93 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 87 insertions(+), 36 deletions(-) diff --git a/doc/config.html b/doc/config.html index 29094f89..69ce813e 100755 --- a/doc/config.html +++ b/doc/config.html @@ -1528,15 +1528,28 @@ resulting in all messages being locked. In those cases locking has to be turned Default for "Use Lock" is 0.

-

  • Date on reply = 0|1|2 -
    -If this flag is nozero, the current date is placed between the quoted original entry -and the new entry. 1 causes the date to appear on top of the quoted entry, -2 cuses the date to appear below the quoted entry. -This can be useful for email notifications, if one wants to see the -time history of all replies in the email messages. Default is 0. +
  • Prepend on reply = <string> +
    +With this option a string can be placed on top of a reply. Using string substition, +this can be useful for adding the author and the date of a reply, like
    +
    +Prepend on reply = Added $date by $long_name\n\n
    +
    +where "\n" causes a line break.

    +

  • Apend on reply = <string> +
    +Same as before, but gets added after the previous entry. +

    + +

  • Prepend on edit = <string> +
  • Apend on edit = <string> +
    +Same as before, but for editing entries. +

    + +


    diff --git a/doc/wishlist.html b/doc/wishlist.html index 8e28c35b..2ce13bb3 100755 --- a/doc/wishlist.html +++ b/doc/wishlist.html @@ -45,7 +45,8 @@ starting at the items with the most votes. You can vote for a feature, or sugges Add/Remove logbooks though the web interface1 Specify date format explicitly for substitutions, like $entry date{%Y}1 Implement attribute substituions including message id (or change message id display fromat)1 -Only display a subset of attributes if not logged in (guest mode)1 +Only display a subset of attributes if not logged in (guest mode)2 +Only display a subset of attributes in edit, entry and list mode1

    diff --git a/src/elogd.c b/src/elogd.c index 366657d9..49263af9 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.279 2004/03/05 22:35:15 midas + Added Prepend/Append on Edit/Reply + Revision 1.278 2004/03/05 21:40:01 midas Substitution of $message id and $entry time now works on all possible places @@ -6170,7 +6173,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL reply_tag[MAX_REPLY_TO * 10], att[MAX_ATTACHMENTS][256], encoding[80], slist[MAX_N_ATTR + 10][NAME_LENGTH], svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], class_value[80], class_name[80], condition[256], - ua[NAME_LENGTH]; + ua[NAME_LENGTH], mid[80]; time_t now, ltime; char fl[8][NAME_LENGTH]; struct tm *pts, ts; @@ -6902,22 +6905,42 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (text[0]) { if (bedit) { if (bupload || (!bupload && !breedit) - || (breedit && !getcfg_cond(lbs->name, condition, "Preset text", str))) + || (breedit && !getcfg_cond(lbs->name, condition, "Preset text", str))) { + + j = build_subst_list(lbs, slist, svalue, attrib); + sprintf(mid, "%d", message_id); + add_subst_list(slist, svalue, "message id", mid, &j); + add_subst_time(lbs, slist, svalue, "entry time", date, &j); + + if (getcfg_cond(lbs->name, condition, "Prepend on edit", str)) { + strsubst(str, slist, svalue, j); + while (strstr(str, "\\n")) + memcpy(strstr(str, "\\n"), "\r\n", 2); + rsprintf(str); + } + rsputs(text); + + if (getcfg_cond(lbs->name, condition, "Append on edit", str)) { + strsubst(str, slist, svalue, j); + while (strstr(str, "\\n")) + memcpy(strstr(str, "\\n"), "\r\n", 2); + rsprintf(str); + } + } } else { if (!getcfg_cond(lbs->name, condition, "Quote on reply", str) || atoi(str) > 0) { - if (getcfg_cond(lbs->name, condition, "Date on reply", str) - && atoi(str) == 1) { - time(&now); - pts = localtime(&now); - if (getcfg_cond(lbs->name, condition, "Time format", format)) - strftime(str, sizeof(str), format, pts); - else { - strcpy(str, ctime(&now)); - str[strlen(str) - 1] = 0; - } - rsprintf("%s\n\n", str); + if (getcfg_cond(lbs->name, condition, "Prepend on reply", str)) { + j = build_subst_list(lbs, slist, svalue, attrib); + sprintf(mid, "%d", message_id); + add_subst_list(slist, svalue, "message id", mid, &j); + add_subst_time(lbs, slist, svalue, "entry time", date, &j); + + strsubst(str, slist, svalue, j); + while (strstr(str, "\\n")) + memcpy(strstr(str, "\\n"), "\r\n", 2); + rsprintf(str); } p = text; @@ -6954,17 +6977,16 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } while (TRUE); - if (getcfg_cond(lbs->name, condition, "Date on reply", str) - && atoi(str) == 2) { - time(&now); - pts = localtime(&now); - if (getcfg_cond(lbs->name, condition, "Time format", format)) - strftime(str, sizeof(str), format, pts); - else { - strcpy(str, ctime(&now)); - str[strlen(str) - 1] = 0; - } - rsprintf("%s\n\n", str); + if (getcfg_cond(lbs->name, condition, "Append on reply", str)) { + + j = build_subst_list(lbs, slist, svalue, attrib); + sprintf(mid, "%d", message_id); + add_subst_list(slist, svalue, "message id", mid, &j); + add_subst_time(lbs, slist, svalue, "entry time", date, &j); + strsubst(str, slist, svalue, j); + while (strstr(str, "\\n")) + memcpy(strstr(str, "\\n"), "\r\n", 2); + rsprintf(str); } } } @@ -10327,7 +10349,12 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, (char (*)[NAME_LENGTH])svalue, j); rsprintf("", ref); - rsputs2(display); + + if (is_html(display)) + rsputs(display); + else + rsputs2(display); + rsprintf("\n"); } else { /* show select box */ @@ -10425,7 +10452,10 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, } else rsprintf(", "); - rsputs2(attrib[i]); + if (is_html(attrib[i])) + rsputs(attrib[i]); + else + rsputs2(attrib[i]); rsprintf(" "); } @@ -10444,7 +10474,11 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, } else rsprintf(", "); - rsputs2(attrib[i]); + if (is_html(attrib[i])) + rsputs(attrib[i]); + else + rsputs2(attrib[i]); + } } else { if (strieq(attr_options[i][0], "boolean")) { @@ -10488,7 +10522,10 @@ void display_line(LOGBOOK * lbs, int message_id, int number, char *mode, rsputs(attrib[i]); else { rsprintf("", ref); - rsputs2(attrib[i]); + if (is_html(attrib[i])) + rsputs(attrib[i]); + else + rsputs2(attrib[i]); rsprintf(""); }