From 8b0be8d8211afbce3158a3edb93c40ed9d6ad2ab Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 20 Nov 2006 21:17:21 +0000 Subject: [PATCH] Implemented muserlist SVN revision: 1758 --- doc/config.html | 8 ++- src/elogd.c | 162 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 153 insertions(+), 17 deletions(-) diff --git a/doc/config.html b/doc/config.html index c8fd3f75..6a3b53d6 100755 --- a/doc/config.html +++ b/doc/config.html @@ -1402,7 +1402,7 @@ Subst on edit author = $full_name
  • Type <attribute> = date | datetime | numeric | - userlist | useremail
    + userlist | useremail | muserlist
    A normal attribute can contain strings of any type. With this option, attributes can be forced to be numeric or to be a date/time, or to consist of a list of all users from the password file. When new logbook @@ -1431,7 +1431,11 @@ Subst on edit author = $full_name useremail is similar, just a list of email addresses of all registered users. This can be used to send email notification to assigned people by using this attribute in an - Email all = <attribute> statement. + Email all = <attribute> statement. The type + muserlist and museremail are the + same that userlist and useremail, + except that several user names or user emails can be selected at once + using check boxes.
  • Change <attribute> = <string>
    diff --git a/src/elogd.c b/src/elogd.c index 2709c0d2..57466c74 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -255,8 +255,10 @@ char author_list[MAX_N_LIST][NAME_LENGTH] = { #define AF_TIME (1<<10) #define AF_NUMERIC (1<<11) #define AF_USERLIST (1<<12) -#define AF_USEREMAIL (1<<13) -#define AF_HIDDEN (1<<14) +#define AF_MUSERLIST (1<<13) +#define AF_USEREMAIL (1<<14) +#define AF_MUSEREMAIL (1<<15) +#define AF_HIDDEN (1<<16) /* attribute format flags */ #define AFF_SAME_LINE 1 @@ -6777,9 +6779,12 @@ and attr_flags arrays */ attr_flags[i] |= AF_NUMERIC; if (strieq(type, "userlist")) attr_flags[i] |= AF_USERLIST; + if (strieq(type, "muserlist")) + attr_flags[i] |= AF_MUSERLIST; if (strieq(type, "useremail")) attr_flags[i] |= AF_USEREMAIL; - + if (strieq(type, "museremail")) + attr_flags[i] |= AF_MUSEREMAIL; } } @@ -8381,7 +8386,7 @@ void attrib_from_param(int n_attr, char attrib[MAX_N_ATTR][NAME_LENGTH]) for (i = 0; i < n_attr; i++) { strcpy(ua, attr_list[i]); btou(ua); - if (attr_flags[i] & AF_MULTI) { + if ((attr_flags[i] & (AF_MULTI) | AF_MUSERLIST)) { attrib[i][0] = 0; first = 1; for (j = 0; j < MAX_N_LIST; j++) { @@ -8503,7 +8508,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], - 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], full_name[256], cookie[256], orig_author[256], attr_moptions[MAX_N_LIST][NAME_LENGTH], ref[256], file_enc[256]; time_t now, ltime; char fl[8][NAME_LENGTH]; @@ -8932,7 +8937,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL /* convert dots to underscores */ dtou(ua); - if (attr_flags[i] & AF_MULTI) { + if (attr_flags[i] & (AF_MULTI | AF_MUSERLIST)) { rsprintf(" if (\n"); for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) { sprintf(str, "%s_%d", ua, j); @@ -9345,6 +9350,18 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (strstr(attrib[index], attr_options[index][i])) rsprintf("\n", str, attr_options[index][i]); } + } else if (attr_flags[index] & AF_MUSERLIST) { + + for (i = 0;; i++) { + if (!enum_user_line(lbs, i, login_name, sizeof(login_name))) + break; + get_user_line(lbs, login_name, NULL, full_name, NULL, NULL, NULL); + + sprintf(str, "%s_%d", ua, i); + + if (strstr(attrib[index], full_name)) + rsprintf("\n", str, full_name); + } } else if (attr_flags[index] & AF_ICON) { for (i = 0; i < MAX_N_LIST && attr_options[index][i][0]; i++) { sprintf(str, "%s_%d", ua, i); @@ -9426,6 +9443,43 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf("\n"); + } else if (attr_flags[index] & AF_MUSERLIST) { + + /* display multiple check boxes with user names */ + rsprintf("\n", title); + + n_moptions = strbreak(attrib[index], attr_moptions, MAX_N_LIST, "|"); + for (i = 0;; i++) { + if (!enum_user_line(lbs, i, login_name, sizeof(login_name))) + break; + get_user_line(lbs, login_name, NULL, full_name, NULL, NULL, NULL); + + sprintf(str, "%s_%d", ua, i); + + rsprintf("\n"); + + for (j = 0; j < n_moptions; j++) + if (strcmp(attr_moptions[j], full_name) == 0) + break; + + if (j < n_moptions) + rsprintf + ("\n", + str, str, full_name); + else + rsprintf + ("\n", + str, str, full_name); + + rsprintf("\n", str, full_name); + rsprintf("\n"); + + if (format_flags[index] & AFF_MULTI_LINE) + rsprintf("
    "); + } + + rsprintf("\n"); + } else if (attr_flags[index] & AF_USEREMAIL) { rsprintf("\n", title); @@ -9486,7 +9540,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsprintf(loc("Add new option here"), attr_list[index]); rsprintf(" : \n"); - if (attr_flags[index] & AF_MULTI) + if (attr_flags[index] & (AF_MULTI | AF_MUSERLIST)) rsprintf ("\n", input_maxlen, ua, attrib[index]); @@ -10323,7 +10377,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL void show_find_form(LOGBOOK * lbs) { int i, j; - char str[NAME_LENGTH], mode[NAME_LENGTH], comment[NAME_LENGTH], option[NAME_LENGTH]; + char str[NAME_LENGTH], mode[NAME_LENGTH], comment[NAME_LENGTH], option[NAME_LENGTH], + login_name[256], full_name[256]; /*---- header ----*/ @@ -10509,6 +10564,21 @@ void show_find_form(LOGBOOK * lbs) rsprintf("\n"); + } else if (attr_flags[i] & AF_MUSERLIST) { + + for (j = 0;; j++) { + if (!enum_user_line(lbs, j, login_name, sizeof(login_name))) + break; + get_user_line(lbs, login_name, NULL, full_name, NULL, NULL, NULL); + + sprintf(str, "%s_%d", attr_list[i], j); + + rsprintf("\n", + str, str, full_name); + + rsprintf("\n", str, full_name); + } + } else { rsprintf("\n", attr_list[i]); @@ -17199,6 +17269,16 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa } } + if (attr_flags[i] & AF_MUSERLIST) { + for (j = 0; j < MAX_N_LIST ; j++) { + sprintf(str, "%s_%d", attr_list[i], j); + if (isparam(str)) { + filtering = TRUE; + break; + } + } + } + /* check if sort by attribute */ if ((isparam("sort") && strieq(getparam("sort"), attr_list[i])) || (isparam("rsort") && strieq(getparam("rsort"), attr_list[i]))) @@ -17314,6 +17394,33 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa found = TRUE; } + if (searched && !found) + break; + } + + /* check for multi user list */ + else if (attr_flags[i] & AF_MUSERLIST) { + + /* OR of any of the values */ + searched = found = FALSE; + for (j = 0; j < MAX_N_LIST ; j++) { + sprintf(str, "%s_%d", attr_list[i], j); + if (isparam(str)) { + searched = TRUE; + if (strstr(attrib[i], getparam(str))) { + found = TRUE; + break; + } + } + } + + /* search for parameter without '_' coming from quick filter */ + if (isparam(attr_list[i])) { + searched = TRUE; + if (strstr(attrib[i], getparam(attr_list[i]))) + found = TRUE; + } + if (searched && !found) break; @@ -17799,8 +17906,8 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa if (ltime > 0) disp_filter = TRUE; } - if (attr_flags[i] & AF_MULTI) { - for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) { + if (attr_flags[i] & (AF_MULTI | AF_MUSERLIST)) { + for (j = 0; j < MAX_N_LIST ; j++) { sprintf(str, "%s_%d", attr_list[i], j); if (isparam(str)) disp_filter = TRUE; @@ -17944,6 +18051,31 @@ void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL defa rsprintf("%s", line); } + } else if (attr_flags[i] & AF_MUSERLIST) { + + line[0] = 0; + + for (j = 0; j < MAX_N_LIST ; j++) { + sprintf(iattr, "%s_%d", attr_list[i], j); + if (isparam(iattr)) { + if (line[0]) + strlcat(line, " | ", sizeof(line)); + strlcat(line, getparam(iattr), sizeof(line)); + } + } + + if (isparam(attr_list[i])) { + if (line[0]) + strlcat(line, " | ", sizeof(line)); + strlcat(line, getparam(attr_list[i]), sizeof(line)); + } + + if (line[0]) { + rsprintf("%s:", attr_list[i]); + rsprintf(""); + rsprintf("%s", line); + } + } else if (isparam(attr_list[i])) { comment[0] = 0; if (attr_flags[i] & AF_ICON) { @@ -19374,7 +19506,7 @@ void submit_elog(LOGBOOK * lbs) missing = 1; if (missing) break; - } else if ((attr_flags[i] & AF_MULTI)) { + } else if ((attr_flags[i] & (AF_MULTI | AF_MUSERLIST))) { for (j = 0; j < MAX_N_LIST; j++) { sprintf(str, "%s_%d", ua, j); if (isparam(str)) @@ -19439,7 +19571,7 @@ void submit_elog(LOGBOOK * lbs) strcpy(ua, attr_list[i]); btou(ua); dtou(ua); - if (attr_flags[i] & AF_MULTI) + if (attr_flags[i] & (AF_MULTI | AF_MUSERLIST)) strcat(ua, "_0"); if (isparam(ua) && *getparam(ua) && attr_options[i][0][0]) { @@ -19529,7 +19661,7 @@ void submit_elog(LOGBOOK * lbs) btou(ua); dtou(ua); - if (attr_flags[i] & AF_MULTI) { + if (attr_flags[i] & (AF_MULTI | AF_MUSERLIST)) { if (isparam(ua)) { strlcpy(attrib[i], getparam(ua), NAME_LENGTH); @@ -19781,7 +19913,7 @@ void submit_elog(LOGBOOK * lbs) strlcat(str, attr_list[index], sizeof(str)); strcat(str, " "); - if (attr_flags[index] & AF_MULTI) { + if (attr_flags[index] & (AF_MULTI | AF_MUSERLIST)) { sprintf(str2, "%s_%d", ua, mindex); mindex++; @@ -20795,7 +20927,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command) rsprintf("\"%s\"", attrib[i], attrib[i], attrib[i]); } rsprintf(" \n"); - } else if ((attr_flags[i] & AF_MULTI) + } else if ((attr_flags[i] & (AF_MULTI | AF_MUSERLIST)) && (format_flags[i] & AFF_MULTI_LINE)) { rsprintf("%s:\n", attr_list[i], class_value);