From 3c1bfa7c5dd6c2965e1bc62d3f41cc11f9aa56b4 Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Thu, 31 Mar 2005 20:37:05 +0000 Subject: [PATCH] Implemented 'Duplicate' command SVN revision: 1306 --- doc/config.html | 5 ++-- src/elogd.c | 65 +++++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/doc/config.html b/doc/config.html index c25b5ad2..05ae5168 100755 --- a/doc/config.html +++ b/doc/config.html @@ -521,6 +521,7 @@ commands are possible:
  • Edit - Edit current logbook entry
  • Delete - Delete current logbook entry
  • Reply - Submit a reply to current entry +
  • Duplicate - Duplicate the current entry with the possibility to change some values
  • Download - Download a message in ASCII format
  • Find - Search entries in logbooks
  • Last day - Display entries from last day @@ -541,7 +542,7 @@ setting, and are automatically translated into the specified language.

    If this option is not present, following default is used:
    -
    Menu commands = List, New, Edit, Delete, Reply, Find, Config, Help
    +
    Menu commands = List, New, Edit, Delete, Reply, Duplicate, Find, Config, Help

  • Copy to = <logbook list> @@ -580,7 +581,7 @@ menu, with which one can login as a real user (username and password have to mat from the password file), which then allowes full access via the "Menu commands" list. A typical example for the menu settings for this scenario are:

    -Menu commands = List, New, Edit, Reply, Find, Config, Logout, Help
    +Menu commands = List, New, Edit, Reply, Duplicate, Find, Config, Logout, Help
     Guest menu commands = List, Find, Login, Help
     

    diff --git a/src/elogd.c b/src/elogd.c index 751cdacd..fa3f70ed 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.613 2005/03/31 20:37:05 ritt + Implemented 'Duplicate' command + Revision 1.612 2005/03/31 18:15:32 ritt Implemented seconds for datetime @@ -7831,7 +7834,7 @@ void attrib_from_param(int n_attr, char attrib[MAX_N_ATTR][NAME_LENGTH]) /*------------------------------------------------------------------*/ -void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL bupload, BOOL breedit) +void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL bupload, BOOL breedit, BOOL bduplicate) { int i, j, n, index, aindex, size, width, height, fh, length, input_size, input_maxlen, format_flags[MAX_N_ATTR], year, month, day, hour, min, sec, n_attr, n_disp_attr, attr_index[MAX_N_ATTR]; @@ -8845,7 +8848,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL /* leave space for '> ' */ - if (!bedit) + if (!bedit && !bduplicate) width += 2; } @@ -8877,7 +8880,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (preset_text) { /* don't use preset text if editing */ - if (bedit) + if (bedit || bduplicate) preset_text = FALSE; /* user preset on reedit only if preset is under condition */ @@ -8904,12 +8907,13 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL add_subst_list(slist, svalue, "message id", mid, &j); add_subst_time(lbs, slist, svalue, "entry time", date, &j); - if (getcfg(lbs->name, "Prepend on edit", str, sizeof(str))) { - strsubst(str, slist, svalue, j); - while (strstr(str, "\\n")) - memcpy(strstr(str, "\\n"), "\r\n", 2); - rsprintf(str); - } + if (!bupload) + if (getcfg(lbs->name, "Prepend on edit", str, sizeof(str))) { + strsubst(str, slist, svalue, j); + while (strstr(str, "\\n")) + memcpy(strstr(str, "\\n"), "\r\n", 2); + rsputs3(str); + } /* use rsputs3 which just converts "<", ">", "&", "\"" to > etc. */ /* otherwise some HTML statments would break the page syntax */ @@ -8923,6 +8927,10 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL rsputs3(str); } } + } else if (bduplicate) { + + rsputs3(text); + } else if (breply) { if (!getcfg(lbs->name, "Quote on reply", str, sizeof(str)) || atoi(str) > 0) { @@ -9129,7 +9137,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL if (!getcfg(lbs->name, "Enable attachments", str, sizeof(str)) || atoi(str) > 0) { i = 0; - if (bedit) { + if (bedit || bduplicate) { /* show existing attachments */ for (i = 0; i < MAX_ATTACHMENTS; i++) if (att[i][0]) { @@ -14414,7 +14422,7 @@ BOOL is_command_allowed(LOGBOOK * lbs, char *command) /* default menu commands */ if (menu_str[0] == 0) { - strcpy(menu_str, "List, New, Edit, Delete, Reply, Find, "); + strcpy(menu_str, "List, New, Edit, Delete, Reply, Duplicate, Find, "); if (getcfg(lbs->name, "Password file", str, sizeof(str))) { @@ -18867,6 +18875,8 @@ BOOL convert_password_file(char *file_name) char *buf, *p; PMXML_NODE root, list, node; + printf("Converting password file \"%s\" to new XML format ... ", file_name); + fh = open(file_name, O_RDONLY | O_BINARY); if (fh < 0) return FALSE; @@ -18958,6 +18968,8 @@ BOOL convert_password_file(char *file_name) mxml_write_tree(file_name, root); mxml_free_tree(root); + printf("Ok\n"); + free(buf); return TRUE; } @@ -20229,18 +20241,16 @@ void interprete(char *lbook, char *path) return; } - if (strieq(command, loc("New")) || - strieq(command, loc("Edit")) || strieq(command, loc("Reply")) || strieq(command, loc("Delete")) - || strieq(command, loc("Upload")) - || strieq(command, loc("Submit"))) { + if (strieq(command, loc("New")) || strieq(command, loc("Edit")) || strieq(command, loc("Reply")) || + strieq(command, loc("Duplicate")) || strieq(command, loc("Delete")) || strieq(command, loc("Upload")) || + strieq(command, loc("Submit"))) { sprintf(str, "%s?cmd=%s", path, command); if (!check_password(lbs, "Write password", getparam("wpwd"), str)) return; } - if (strieq(command, loc("Delete")) || strieq(command, loc("Config")) - || strieq(command, loc("Copy to")) - || strieq(command, loc("Move to"))) { + if (strieq(command, loc("Delete")) || strieq(command, loc("Config")) || + strieq(command, loc("Copy to")) || strieq(command, loc("Move to"))) { sprintf(str, "%s?cmd=%s", path, command); if (!check_password(lbs, "Admin password", getparam("apwd"), str)) return; @@ -20456,7 +20466,7 @@ void interprete(char *lbook, char *path) } if (strieq(command, loc("New"))) { - show_edit_form(lbs, 0, FALSE, FALSE, FALSE, FALSE); + show_edit_form(lbs, 0, FALSE, FALSE, FALSE, FALSE, FALSE); return; } @@ -20481,34 +20491,41 @@ void interprete(char *lbook, char *path) unsetparam(str); } - show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE); + show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE); return; } } message_id = atoi(dec_path); if (strieq(command, loc("Upload"))) { - show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE); + show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE); return; } if (strieq(command, loc("Edit"))) { if (message_id) { - show_edit_form(lbs, message_id, FALSE, TRUE, FALSE, FALSE); + show_edit_form(lbs, message_id, FALSE, TRUE, FALSE, FALSE, FALSE); return; } } if (strieq(command, loc("Reply"))) { - show_edit_form(lbs, message_id, TRUE, FALSE, FALSE, FALSE); + show_edit_form(lbs, message_id, TRUE, FALSE, FALSE, FALSE, FALSE); return; } if (strieq(command, loc("Update"))) { - show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, FALSE, TRUE); + show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, FALSE, TRUE, FALSE); return; } + if (strieq(command, loc("Duplicate"))) { + if (message_id) { + show_edit_form(lbs, message_id, FALSE, FALSE, FALSE, FALSE, TRUE); + return; + } + } + if (strieq(command, loc("Submit")) || strieq(command, "Submit")) {