From 469d259ed45155683f929edb04cbaa9b3ad92eb5 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Tue, 15 Aug 2006 11:08:23 +0000 Subject: [PATCH] Added 'preset on duplicate' SVN revision: 1713 --- doc/config.html | 6 ++++++ src/elogd.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/doc/config.html b/doc/config.html index e4e4acf8..b225e720 100755 --- a/doc/config.html +++ b/doc/config.html @@ -1066,6 +1066,12 @@ XYZ-2005-Nov-002 Same as Preset <attribute>, but evaluated for replies. +
  • + Preset on duplicate <attribute> = + <string>
    + Same as Preset <attribute>, but evaluated for + duplicted entries. +
  • Locked Attributes = <list>
    The attributes specified here cannot be modified when a new entry is diff --git a/src/elogd.c b/src/elogd.c index 3249da8d..305910ab 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -8607,6 +8607,28 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } } + sprintf(str, "Preset on duplicate %s", attr_list[index]); + if ((i = getcfg(lbs->name, str, preset, sizeof(preset))) > 0 && bduplicate) { + + 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); + } + } + /* check for p */ sprintf(str, "p%s", attr_list[index]); if (isparam(str)) @@ -8670,6 +8692,28 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(attrib[index], preset); } } + + sprintf(str, "Preset on duplicate %s", attr_list[index]); + if ((i = getcfg(lbs->name, str, preset, sizeof(preset))) > 0 && bduplicate) { + + 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); + } + } } } else // if (_condition[0])