From fc8b059303ff6f452dd04b3ec4bcd61ebbd6d28e Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Thu, 26 Nov 2009 16:38:43 +0000 Subject: [PATCH] Implemented "Preset on first reply" SVN revision: 2271 --- src/elogd.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index fb36ae6f..77982dbf 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -9314,20 +9314,13 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } } - sprintf(str, "Preset on reply %s", attr_list[index]); + sprintf(str, "Preset on first reply %s", attr_list[index]); if ((i = getcfg(lbs->name, str, preset, sizeof(preset))) > 0 && breply) { - if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ + el_retrieve(lbs, message_id, NULL, NULL, NULL, 0, NULL, 0, str, NULL, NULL, NULL, NULL); - /* check for multiple substitution */ - strlcpy(str, preset, sizeof(str)); - if (strchr(str, '$')) - *strchr(str, '$') = 0; - if (strchr(str, '%')) - *strchr(str, '%') = 0; - if (strchr(str, '#')) - *strchr(str, '#') = 0; - if (strncmp(str, attrib[index], strlen(str)) != 0) { + if (str[0] == 0) { + if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ /* do not format date for date attributes */ i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) @@ -9347,6 +9340,28 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } } + sprintf(str, "Preset on reply %s", attr_list[index]); + if ((i = getcfg(lbs->name, str, preset, sizeof(preset))) > 0 && breply) { + + if (!breedit || (breedit && i == 2)) { /* subst on reedit only if preset is under condition */ + + /* do not format date for date attributes */ + i = build_subst_list(lbs, slist, svalue, attrib, (attr_flags[index] & (AF_DATE | AF_DATETIME)) + == 0); + strsubst_list(preset, sizeof(preset), slist, svalue, i); + + /* check for index substitution */ + if (!bedit && (strchr(preset, '%') || strchr(preset, '#'))) { + /* get index */ + get_auto_index(lbs, index, preset, str, sizeof(str)); + strcpy(preset, str); + } + + if (!strchr(preset, '%')) + strcpy(attrib[index], preset); + } + } + sprintf(str, "Preset on duplicate %s", attr_list[index]); if ((i = getcfg(lbs->name, str, preset, sizeof(preset))) > 0 && bduplicate) {