diff --git a/elogd.c b/elogd.c index acb75d4e..eefb62d4 100755 --- a/elogd.c +++ b/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 2.71 2002/09/10 05:59:04 midas + Made selections work with 'copy to' and 'move to' + Revision 2.70 2002/09/09 08:04:58 midas Added select boxes @@ -5423,7 +5426,10 @@ char str[256], in_reply_to[80], reply_to[256]; strcpy(str, getparam("nextmsg")); if (atoi(str) == 0) sprintf(str, "%d", el_search_message(lbs, EL_LAST, 0, TRUE)); - redirect(str); + if (atoi(str) == 0) + redirect(""); + else + redirect(str); return; } } @@ -5746,7 +5752,7 @@ FILE *f; { /* show select box */ if (select) - rsprintf("\n", col, message_id); + rsprintf("\n", col, (*n_display)++, message_id); for (index=0 ; index\n", gt("Border width"), gt("Categories cellpadding")); @@ -6265,11 +6275,76 @@ char str[256]; rsprintf("\n", loc("Toggle all")); if (!getcfg(lbs->name, "Menu commands", str) || - strstr(str, "Delete")) + strstr(str, loc("Delete"))) { rsprintf("\n"); } + if (getcfg(lbs->name, "Menu commands", str) && + strstr(str, loc("Copy to"))) + { + rsprintf("\n", loc("Copy to")); + rsprintf("\n"); + } + + if (getcfg(lbs->name, "Menu commands", str) && + strstr(str, loc("Move to"))) + { + rsprintf("\n", loc("Move to")); + rsprintf("\n"); + } + + rsprintf("
\n\n"); } @@ -7478,7 +7553,7 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id; void copy_to(LOGBOOK *lbs, int src_id, char *dest_logbook, int move) { -int size, i, status, fh, message_id; +int size, i, n, n_done, index, status, fh, source_id, message_id; char str[256], file_name[256], attrib[MAX_N_ATTR][NAME_LENGTH]; char date[80], text[TEXT_SIZE], msg_str[32], in_reply_to[80], reply_to[256], attachment[MAX_ATTACHMENTS][256], encoding[80]; @@ -7491,83 +7566,106 @@ LOGBOOK *lbs_dest; return; lbs_dest = &lb_list[i]; - /* get message */ - size = sizeof(text); - status = el_retrieve(lbs, src_id, date, attr_list, attrib, lbs->n_attr, - text, &size, in_reply_to, reply_to, - attachment, encoding); + if (src_id) + n = 1; + else + n = atoi(getparam("nsel")); - if (status != EL_SUCCESS) + n_done = 0; + for (index=0 ; indexname); - show_error(str); - return; - } - - /* read attachments */ - for (i=0 ; idata_dir); - strcat(file_name, attachment[i]); + sprintf(str, "s%d", index); + if (!isparam(str)) + continue; - fh = open(file_name, O_RDONLY | O_BINARY); - if (fh > 0) - { - lseek(fh, 0, SEEK_END); - _attachment_size[i] = TELL(fh); - lseek(fh, 0, SEEK_SET); - - _attachment_buffer[i] = malloc(_attachment_size[i]); - - if (_attachment_buffer[i]) - read(fh, _attachment_buffer[i], _attachment_size[i]); - - close(fh); - } - - /* stip date/time from file name */ - strcpy(str, attachment[i]); - strcpy(attachment[i], str+14); + source_id = atoi(getparam(str)); } - /* submit in destination logbook without links */ + /* get message */ + size = sizeof(text); + status = el_retrieve(lbs, source_id, date, attr_list, attrib, lbs->n_attr, + text, &size, in_reply_to, reply_to, + attachment, encoding); - message_id = el_submit(lbs_dest, 0, date, attr_list, attrib, lbs_dest->n_attr, text, - "", "", encoding, - attachment, - _attachment_buffer, - _attachment_size); + if (status != EL_SUCCESS) + { + sprintf(msg_str, "%d", source_id); + sprintf(str, loc("Message %s cannot be read from logbook \"%s\""), msg_str, lbs->name); + show_error(str); + return; + } - for (i=0 ; idata_dir); + strcat(file_name, attachment[i]); - if (message_id <= 0) - { - sprintf(str, loc("New message cannot be written to directory \"%s\""), lbs_dest->data_dir); - strcat(str, "\n

"); - strcat(str, loc("Please check that it exists and elogd has write access")); - show_error(str); - return; - } + fh = open(file_name, O_RDONLY | O_BINARY); + if (fh > 0) + { + lseek(fh, 0, SEEK_END); + _attachment_size[i] = TELL(fh); + lseek(fh, 0, SEEK_SET); - /* delete original message for move */ - if (move) - { - el_delete_message(lbs, src_id, TRUE, NULL, TRUE); + + _attachment_buffer[i] = malloc(_attachment_size[i]); - /* check if this was the last message */ - src_id = el_search_message(lbs, EL_NEXT, src_id, FALSE); + if (_attachment_buffer[i]) + read(fh, _attachment_buffer[i], _attachment_size[i]); - /* if yes, force display of new last message */ - if (src_id <= 0) - src_id = el_search_message(lbs, EL_LAST, 0, FALSE); + close(fh); + } + + /* stip date/time from file name */ + strcpy(str, attachment[i]); + strcpy(attachment[i], str+14); + } + + /* submit in destination logbook without links */ + + message_id = el_submit(lbs_dest, 0, date, attr_list, attrib, lbs_dest->n_attr, text, + "", "", encoding, + attachment, + _attachment_buffer, + _attachment_size); + + for (i=0 ; idata_dir); + strcat(str, "\n

"); + strcat(str, loc("Please check that it exists and elogd has write access")); + show_error(str); + return; + } + + n_done++; + + /* delete original message for move */ + if (move) + { + el_delete_message(lbs, source_id, TRUE, NULL, TRUE); + + /* check if this was the last message */ + source_id = el_search_message(lbs, EL_NEXT, source_id, FALSE); + + /* if yes, force display of new last message */ + if (source_id <= 0) + source_id = el_search_message(lbs, EL_LAST, 0, FALSE); + } } /* display status message */ - sprintf(str, "%d", src_id); + sprintf(str, "%d", source_id); show_standard_header(loc("Copy ELog entry"), str); rsprintf("

", @@ -7575,14 +7673,29 @@ LOGBOOK *lbs_dest; rsprintf("
\n", gt("Frame color")); rsprintf("\n"); - rsprintf("\n", - gt("Cell BGColor"), loc("Go to"), lbs->name, src_id, lbs->name); + if (src_id) + rsprintf("\n", + gt("Cell BGColor"), loc("Go to"), lbs->name, source_id, lbs->name); + else + rsprintf("\n", + gt("Cell BGColor"), loc("Go to"), lbs->name, getparam("cmdline"), lbs->name); + rsprintf("\n", gt("Cell BGColor"), loc("Go to"), lbs_dest->name, lbs_dest->name); @@ -7603,7 +7716,7 @@ char date[80], text[TEXT_SIZE], menu_str[1000], other_str[1000], cmd[256], orig_tag[80], reply_tag[80], attachment[MAX_ATTACHMENTS][256], encoding[80], att[256], lattr[256]; char menu_item[MAX_N_LIST][NAME_LENGTH], format[80], admin_user[80], slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH], *p; -char lb_list[MAX_N_LIST][NAME_LENGTH]; +char lbk_list[MAX_N_LIST][NAME_LENGTH]; FILE *f; BOOL first; @@ -8205,10 +8318,10 @@ BOOL first; if (str[0]) { - n_log = strbreak(str, lb_list, MAX_N_LIST); + n_log = strbreak(str, lbk_list, MAX_N_LIST); for (j=0 ; j%s\n", lb_list[j], lb_list[j]); + rsprintf("
"); - if (move) - rsprintf(loc("Message moved successfully from \"%s\" to \"%s\""), lbs->name, lbs_dest->name); + if (n>1) + { + if (move) + rsprintf(loc("%d messages moved successfully from \"%s\" to \"%s\""), n_done, lbs->name, lbs_dest->name); + else + rsprintf(loc("%d messages copied successfully from \"%s\" to \"%s\""), n_done, lbs->name, lbs_dest->name); + } else - rsprintf(loc("Message copied successfully from \"%s\" to \"%s\""), lbs->name, lbs_dest->name); + { + if (move) + rsprintf(loc("Message moved successfully from \"%s\" to \"%s\""), lbs->name, lbs_dest->name); + else + rsprintf(loc("Message copied successfully from \"%s\" to \"%s\""), lbs->name, lbs_dest->name); + } rsprintf("
%s %s
%s %s
%s %s
%s %s