diff --git a/src/elogd.c b/src/elogd.c index 03d19f71..bb140c68 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.711 2005/07/22 21:13:12 ritt + Made conditional attributes also work for email notification + Revision 1.710 2005/07/22 12:34:47 ritt Added
to [code]
@@ -1655,6 +1658,7 @@ void compose_base_url(LOGBOOK * lbs, char *base_url, int size);
void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command);
char *loc(char *orig);
void strencode(char *text);
+int scan_attributes(char *logbook);
/*---- Funcions from the MIDAS library -----------------------------*/
@@ -3501,6 +3505,42 @@ void set_condition(char *c)
/*-------------------------------------------------------------------*/
+void evaluate_conditions(LOGBOOK *lbs, char attrib[MAX_N_ATTR][NAME_LENGTH])
+{
+ char condition[256], str[256];
+ int index, i;
+
+ condition[0] = 0;
+ for (index = 0; index < lbs->n_attr; index++) {
+ for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) {
+
+ if (strchr(attr_options[index][i], '{') && strchr(attr_options[index][i], '}')) {
+
+ strlcpy(str, attr_options[index][i], sizeof(str));
+ *strchr(str, '{') = 0;
+
+ if (strieq(str, attrib[index])) {
+ strlcpy(str, strchr(attr_options[index][i], '{') + 1, sizeof(str));
+ if (*strchr(str, '}'))
+ *strchr(str, '}') = 0;
+
+ if (condition[0] == 0)
+ strlcpy(condition, str, sizeof(condition));
+ else {
+ strlcat(condition, ",", sizeof(condition));
+ strlcat(condition, str, sizeof(condition));
+ }
+
+ set_condition(condition);
+ scan_attributes(lbs->name);
+ }
+ }
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*/
+
BOOL match_param(char *str, char *param, int conditional_only)
{
int ncl, npl, nand, i, j, k;
@@ -8816,7 +8856,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
attrib[MAX_N_ATTR][NAME_LENGTH], *text, orig_tag[80], 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], mid[80], title[256], login_name[256], cookie[256], orig_author[256];
+ ua[NAME_LENGTH], mid[80], title[256], login_name[256], cookie[256], orig_author[256];
time_t now, ltime;
char fl[8][NAME_LENGTH];
struct tm *pts;
@@ -8965,38 +9005,11 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
/* evaluate conditional attributes */
- condition[0] = 0;
- for (index = 0; index < lbs->n_attr; index++) {
- for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) {
- if (strchr(attr_options[index][i], '{') && strchr(attr_options[index][i], '}')) {
-
- strlcpy(str, attr_options[index][i], sizeof(str));
- *strchr(str, '{') = 0;
-
- if (strieq(str, attrib[index])) {
- strlcpy(str, strchr(attr_options[index][i], '{') + 1, sizeof(str));
- if (*strchr(str, '}'))
- *strchr(str, '}') = 0;
-
- if (condition[0] == 0)
- strlcpy(condition, str, sizeof(condition));
- else {
- strlcat(condition, ",", sizeof(condition));
- strlcat(condition, str, sizeof(condition));
- }
-
- set_condition(condition);
- n_attr = scan_attributes(lbs->name);
- }
- }
- }
- }
-
- set_condition(condition);
+ evaluate_conditions(lbs, attrib);
/* rescan attributes if condition set */
- if (condition[0]) {
+ if (_condition[0]) {
n_attr = scan_attributes(lbs->name);
if (breedit)
attrib_from_param(n_attr, attrib);
@@ -9478,8 +9491,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("%s\n", str);
rsprintf(" \n", date);
- if (condition[0])
- rsprintf("\n", condition);
+ if (_condition[0])
+ rsprintf("\n", _condition);
/* retrieve attribute flags */
for (i = 0; i < n_attr; i++) {
@@ -10419,7 +10432,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("