Implemented OR'ing of MOptions values in find page

SVN revision: 1179
This commit is contained in:
Stefan Ritt 2005-01-21 22:06:02 +00:00
parent 0b128e4550
commit 375e549de7

View File

@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG Contents: Web server program for Electronic Logbook ELOG
$Log$ $Log$
Revision 1.541 2005/01/21 22:06:02 ritt
Implemented OR'ing of MOptions values in find page
Revision 1.540 2005/01/21 20:17:20 ritt Revision 1.540 2005/01/21 20:17:20 ritt
Display current entry in thread bold Display current entry in thread bold
@ -8957,6 +8960,18 @@ void show_find_form(LOGBOOK * lbs)
} }
} }
/* display check boxes (or'ed) */
else if (attr_flags[i] & AF_MULTI) {
for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) {
sprintf(str, "%s_%d", attr_list[i], j);
rsprintf("<nobr><input type=checkbox id=\"%s\" name=\"%s\" value=\"%s\"\">\n",
str, str, attr_options[i][j]);
rsprintf("<label for=\"%s\">%s</label></nobr>\n", str, attr_options[i][j]);
}
}
else { else {
rsprintf("<select name=\"%s\">\n", attr_list[i]); rsprintf("<select name=\"%s\">\n", attr_list[i]);
rsprintf("<option value=\"\">\n"); rsprintf("<option value=\"\">\n");
@ -14647,8 +14662,9 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
str[NAME_LENGTH], ref[256], img[80], comment[NAME_LENGTH], mode[80], mid[80], str[NAME_LENGTH], ref[256], img[80], comment[NAME_LENGTH], mode[80], mid[80],
menu_str[1000], menu_item[MAX_N_LIST][NAME_LENGTH], param[NAME_LENGTH], format[80], menu_str[1000], menu_item[MAX_N_LIST][NAME_LENGTH], param[NAME_LENGTH], format[80],
sort_attr[MAX_N_ATTR + 4][NAME_LENGTH]; sort_attr[MAX_N_ATTR + 4][NAME_LENGTH];
char *p, *pt, *pt1, *pt2, *slist, *svalue, *gattr; char *p, *pt, *pt1, *pt2, *slist, *svalue, *gattr, line[1024], iattr[256];
BOOL show_attachments, threaded, csv, xml, mode_commands, expand, filtering, disp_filter, show_text; BOOL show_attachments, threaded, csv, xml, mode_commands, expand, filtering, disp_filter,
show_text, searched, found;
time_t ltime, ltime_start, ltime_end, now, ltime1, ltime2; time_t ltime, ltime_start, ltime_end, now, ltime1, ltime2;
struct tm tms, *ptms; struct tm tms, *ptms;
MSG_LIST *msg_list; MSG_LIST *msg_list;
@ -14986,6 +15002,17 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
break; break;
} }
if (attr_flags[i] & AF_MULTI) {
for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) {
sprintf(str, "%s_%d", attr_list[i], j);
if (*getparam(str)) {
filtering = TRUE;
break;
}
}
}
/* check if sort by attribute */ /* check if sort by attribute */
if (strieq(getparam("sort"), attr_list[i]) if (strieq(getparam("sort"), attr_list[i])
|| strieq(getparam("rsort"), attr_list[i])) || strieq(getparam("rsort"), attr_list[i]))
@ -15058,70 +15085,81 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
text, &size, in_reply_to, reply_to, attachment, encoding, locked_by); text, &size, in_reply_to, reply_to, attachment, encoding, locked_by);
if (status != EL_SUCCESS) if (status != EL_SUCCESS)
break; break;
}
for (i = 0; i < lbs->n_attr; i++) { /* apply filter for AF_MULTI attributes */
if (*getparam(attr_list[i])) { for (i = 0; i < lbs->n_attr; i++) {
if (attr_flags[i] & AF_MULTI) {
if (attr_flags[i] & AF_DATE) {
ltime = atoi(getparam(attr_list[i])); /* OR of any of the values */
searched = found = FALSE;
/* today 12h noon */ for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) {
time(&now); sprintf(str, "%s_%d", attr_list[i], j);
memcpy(&tms, localtime(&now), sizeof(struct tm)); if (*getparam(str)) {
tms.tm_hour = 12; searched = TRUE;
tms.tm_min = 0; if (strstr(attrib[i], getparam(str))) {
tms.tm_sec = 0; found = TRUE;
now = mktime(&tms); break;
}
/* negative i: last [i] days */ }
if (ltime < 0)
if (atoi(attrib[i]) < now + ltime * 3600 * 24 || atoi(attrib[i]) > now)
break;
/* positive i: next [i] days */
if (ltime > 0)
if (atoi(attrib[i]) > now + ltime * 3600 * 24 || atoi(attrib[i]) < now)
break;
} else {
strcpy(str, getparam(attr_list[i]));
/* if value starts with '$', substitute it */
if (str[0] == '$') {
j = build_subst_list(lbs,
(char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, attrib, TRUE);
sprintf(mid, "%d", message_id);
add_subst_list((char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, "message id", mid, &j);
add_subst_time(lbs, (char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, "entry time", date, &j);
strsubst(str, (char (*)[NAME_LENGTH]) slist, (char (*)[NAME_LENGTH]) svalue, j);
setparam(attr_list[i], str);
} }
for (j = 0; j < (int) strlen(str); j++) if (found)
str[j] = toupper(str[j]); break;
str[j] = 0;
for (j = 0; j < (int) strlen(attrib[i]); j++)
text1[j] = toupper(attrib[i][j]);
text1[j] = 0;
status = regexec(re_buf + 1 + i, attrib[i], 10, pmatch, 0); if (searched && !found)
if (status == REG_NOMATCH)
break; break;
} }
} }
}
if (i < lbs->n_attr) {
msg_list[index].lbs = NULL;
continue;
}
/* apply filter for AF_DATE attributes */ if (searched && !found) {
if (filtering) msg_list[index].lbs = NULL;
continue;
break;
}
searched = found = 0;
for (i = 0; i < lbs->n_attr; i++) {
if (*getparam(attr_list[i])) {
/* check non-multi attributes */
if ((attr_flags[i] & AF_MULTI) == 0) {
searched = TRUE;
strcpy(str, getparam(attr_list[i]));
/* if value starts with '$', substitute it */
if (str[0] == '$') {
j = build_subst_list(lbs,
(char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, attrib, TRUE);
sprintf(mid, "%d", message_id);
add_subst_list((char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, "message id", mid, &j);
add_subst_time(lbs, (char (*)[NAME_LENGTH]) slist,
(char (*)[NAME_LENGTH]) svalue, "entry time", date, &j);
strsubst(str, (char (*)[NAME_LENGTH]) slist, (char (*)[NAME_LENGTH]) svalue, j);
setparam(attr_list[i], str);
}
status = regexec(re_buf + 1 + i, attrib[i], 10, pmatch, 0);
if (status != REG_NOMATCH) {
found = TRUE;
break;
}
}
}
}
if (searched && !found) {
msg_list[index].lbs = NULL;
continue;
}
/* apply filter for AF_DATE attributes */
for (i = 0; i < lbs->n_attr; i++) for (i = 0; i < lbs->n_attr; i++)
if (attr_flags[i] & AF_DATE) { if (attr_flags[i] & AF_DATE) {
@ -15140,27 +15178,28 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
} }
} }
if (*getparam("subtext")) { if (*getparam("subtext")) {
status = regexec(re_buf, text, 10, pmatch, 0); status = regexec(re_buf, text, 10, pmatch, 0);
if (atoi(getparam("sall")) && status == REG_NOMATCH) { if (atoi(getparam("sall")) && status == REG_NOMATCH) {
// search text in attributes // search text in attributes
for (i = 0; i < lbs->n_attr; i++) { for (i = 0; i < lbs->n_attr; i++) {
status = regexec(re_buf, attrib[i], 10, pmatch, 0); status = regexec(re_buf, attrib[i], 10, pmatch, 0);
if (status != REG_NOMATCH) if (status != REG_NOMATCH)
break; break;
} }
if (i == lbs->n_attr) { if (i == lbs->n_attr) {
msg_list[index].lbs = NULL;
continue;
}
} else if (status == REG_NOMATCH) {
msg_list[index].lbs = NULL; msg_list[index].lbs = NULL;
continue; continue;
} }
} else if (status == REG_NOMATCH) {
msg_list[index].lbs = NULL;
continue;
} }
} } /* if (filtering) */
/* in threaded mode, find message head */ /* in threaded mode, find message head */
if (threaded && in_reply_to_id) { if (threaded && in_reply_to_id) {
@ -15505,7 +15544,7 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
if (*getparam(attr_list[i]) && (attr_flags[i] & AF_DATE) == 0) if (*getparam(attr_list[i]) && (attr_flags[i] & AF_DATE) == 0)
disp_filter = TRUE; disp_filter = TRUE;
for (i = 0; i < lbs->n_attr; i++) for (i = 0; i < lbs->n_attr; i++) {
if (attr_flags[i] & AF_DATE) { if (attr_flags[i] & AF_DATE) {
sprintf(str, "%da", i); sprintf(str, "%da", i);
ltime = retrieve_date(str, TRUE); ltime = retrieve_date(str, TRUE);
@ -15516,6 +15555,14 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
if (ltime > 0) if (ltime > 0)
disp_filter = TRUE; disp_filter = TRUE;
} }
if (attr_flags[i] & AF_MULTI) {
for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) {
sprintf(str, "%s_%d", attr_list[i], j);
if (*getparam(str))
disp_filter = TRUE;
}
}
}
if (disp_filter) { if (disp_filter) {
rsprintf("<tr><td class=\"listframe\">\n"); rsprintf("<tr><td class=\"listframe\">\n");
@ -15591,6 +15638,35 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
rsprintf("</td></tr>", comment); rsprintf("</td></tr>", comment);
} }
} else if (attr_flags[i] & AF_MULTI) {
line[0] = 0;
for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) {
sprintf(iattr, "%s_%d", attr_list[i], j);
if (*getparam(iattr)) {
comment[0] = 0;
if (attr_flags[i] & AF_ICON) {
sprintf(str, "Icon comment %s", getparam(iattr));
getcfg(lbs->name, str, comment, sizeof(comment));
}
if (line[0])
strlcat(line, " | ", sizeof(line));
if (comment[0] == 0)
strlcat(line, getparam(iattr), sizeof(line));
else
strlcat(line, comment, sizeof(line));
}
}
if (line[0]) {
rsprintf("<tr><td nowrap width=\"10%%\" class=\"attribname\">%s:</td>", attr_list[i]);
rsprintf("<td class=\"attribvalue\">%s</td></tr>", line);
}
} else if (*getparam(attr_list[i])) { } else if (*getparam(attr_list[i])) {
comment[0] = 0; comment[0] = 0;
if (attr_flags[i] & AF_ICON) { if (attr_flags[i] & AF_ICON) {