* summary.c: summary screen is now updated using ajax instead of refreshing
[citadel.git] / webcit / messages.c
index 96c597cf10d60258040aa2b4417609c1a39695b2..5f11916181b900c4f152af3f1ff15acb803fef27 100644 (file)
@@ -482,7 +482,8 @@ void read_message(long msgnum, int suppress_buttons) {
        char node[256];
        char rfca[256];
        char reply_to[512];
-       char now[256];
+       char reply_all[4096];
+       char now[64];
        int format_type = 0;
        int nhdr = 0;
        int bq = 0;
@@ -503,6 +504,7 @@ void read_message(long msgnum, int suppress_buttons) {
        strcpy(node, "");
        strcpy(rfca, "");
        strcpy(reply_to, "");
+       strcpy(reply_all, "");
        strcpy(vcard_partnum, "");
        strcpy(cal_partnum, "");
        strcpy(mime_http, "");
@@ -562,6 +564,11 @@ void read_message(long msgnum, int suppress_buttons) {
                }
                if (!strncasecmp(buf, "cccc=", 5)) {
                        safestrncpy(m_cc, &buf[5], sizeof m_cc);
+                       if (strlen(reply_all) > 0) {
+                               strcat(reply_all, ", ");
+                       }
+                       safestrncpy(&reply_all[strlen(reply_all)], &buf[5],
+                               (sizeof reply_all - strlen(reply_all)) );
                }
                if ((!strncasecmp(buf, "hnod=", 5))
                    && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
@@ -594,6 +601,11 @@ void read_message(long msgnum, int suppress_buttons) {
                        wprintf(_("to "));
                        escputs(&buf[5]);
                        wprintf(" ");
+                       if (strlen(reply_all) > 0) {
+                               strcat(reply_all, ", ");
+                       }
+                       safestrncpy(&reply_all[strlen(reply_all)], &buf[5],
+                               (sizeof reply_all - strlen(reply_all)) );
                }
                if (!strncasecmp(buf, "time=", 5)) {
                        fmt_date(now, atol(&buf[5]), 0);
@@ -701,6 +713,18 @@ void read_message(long msgnum, int suppress_buttons) {
                urlescputs(m_subject);
                wprintf("\">[%s]</a> ", _("Reply"));
 
+               /* ReplyAll */
+               if (WC->wc_view == VIEW_MAILBOX) {
+                       wprintf("<a href=\"/display_enter?recp=");
+                       urlescputs(reply_to);
+                       wprintf("?cc=");
+                       urlescputs(reply_all);
+                       wprintf("?subject=");
+                       if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                       urlescputs(m_subject);
+                       wprintf("\">[%s]</a> ", _("ReplyAll"));
+               }
+
                /* Forward */
                if (WC->wc_view == VIEW_MAILBOX) {
                        wprintf("<a href=\"/display_enter?pullquote=%ld?subject=", msgnum);
@@ -900,7 +924,7 @@ void embed_message(void) {
        targetdiv = bstr("targetdiv");
        print_it = bstr("print_it");
 
-       output_headers(1, 0, 0, 0, 0, 1, 0);
+       output_headers(1, 0, 0, 0, 1, 0);
        begin_burst();
 
        wprintf("<html><head>");
@@ -1462,9 +1486,9 @@ void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
        char tablast_label[SIZ];
 
        if (num_ab == 0) {
-               wprintf("<I>");
+               wprintf("<br /><br /><br /><div align=\"center\"><i>");
                wprintf(_("This address book is empty."));
-               wprintf("</I>\n");
+               wprintf("</i></div>\n");
                return;
        }
 
@@ -1742,7 +1766,7 @@ void readloop(char *oper)
        if (strlen(sortby) == 0) sortby = sortpref_value;
        if (strlen(sortby) == 0) sortby = "msgid";
 
-       output_headers(1, 1, 1, 0, 0, 0, 0);
+       output_headers(1, 1, 1, 0, 0, 0);
 
        /* When in summary mode, always show ALL messages instead of just
         * new or old.  Otherwise, show what the user asked for.
@@ -1808,7 +1832,7 @@ void readloop(char *oper)
        nummsgs = load_msg_ptrs(cmd, is_summary);
        if (nummsgs == 0) {
 
-               if ((!is_tasks) && (!is_calendar) && (!is_notes)) {
+               if ((!is_tasks) && (!is_calendar) && (!is_notes) && (!is_addressbook)) {
                        wprintf("<em>");
                        if (!strcmp(oper, "readnew")) {
                                wprintf(_("No new messages."));
@@ -2350,9 +2374,9 @@ void display_enter(void)
 
        /*
         * Otherwise proceed normally.
-`       * Do a custom room banner with no navbar...
+        * Do a custom room banner with no navbar...
         */
-       output_headers(1, 1, 2, 0, 0, 0, 0);
+       output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">\n");
        embed_room_banner(NULL, navbar_none);
        wprintf("</div>\n");
@@ -2360,29 +2384,48 @@ void display_enter(void)
                "<div id=\"fix_scrollbar_bug\">"
                "<table width=100%% border=0 bgcolor=\"#ffffff\"><tr><td>");
 
-       sprintf(buf, "ENT0 0|%s|0|0||||%s|%s", bstr("recp"), bstr("cc"), bstr("bcc"));
-       serv_puts(buf);
+       /* First test to see whether this is a room that requires recipients to be entered */
+       serv_puts("ENT0 0");
        serv_getln(buf, sizeof buf);
-
-       if (!strncmp(buf, "570", 3)) {
+       if (!strncmp(buf, "570", 3)) {          /* 570 means that we need a recipient here */
                recipient_required = 1;
-               if (strlen(bstr("recp")) + strlen(bstr("cc")) + strlen(bstr("bcc")) > 0) {
-                       recipient_bad = 1;
-               }
        }
-       else if (buf[0] != '2') {
+       else if (buf[0] != '2') {               /* Any other error means that we cannot continue */
                wprintf("<EM>%s</EM><br />\n", &buf[4]);
                goto DONE;
        }
 
+       /* Now check our actual recipients if there are any */
+       if (recipient_required) {
+               sprintf(buf, "ENT0 0|%s|0|0||||%s|%s", bstr("recp"), bstr("cc"), bstr("bcc"));
+               serv_puts(buf);
+               serv_getln(buf, sizeof buf);
+
+               if (!strncmp(buf, "570", 3)) {  /* 570 means we have an invalid recipient listed */
+                       if (strlen(bstr("recp")) + strlen(bstr("cc")) + strlen(bstr("bcc")) > 0) {
+                               recipient_bad = 1;
+                       }
+               }
+               else if (buf[0] != '2') {       /* Any other error means that we cannot continue */
+                       wprintf("<EM>%s</EM><br />\n", &buf[4]);
+                       goto DONE;
+               }
+       }
+
+       /* If we got this far, we can display the message entry screen. */
+
        now = time(NULL);
        fmt_date(buf, now, 0);
        strcat(&buf[strlen(buf)], _(" <I>from</I> "));
        stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
+
+       /* Don't need this anymore, it's in the input box below
        if (strlen(bstr("recp")) > 0) {
                strcat(&buf[strlen(buf)], _(" <I>to</I> "));
                stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
        }
+       */
+
        strcat(&buf[strlen(buf)], _(" <I>in</I> "));
        stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
 
@@ -2433,17 +2476,11 @@ void display_enter(void)
                wprintf("<div class=\"auto_complete\" id=\"bcc_name_choices\"></div>");
                wprintf("</td><td></td></tr>\n");
 
-               /* Initialize the autocomplete ajax helpers */
-               wprintf("<script type=\"text/javascript\">                              \n"
-                       " new Ajax.Autocompleter('cc_id', 'cc_name_choices',            \n"
-                       "       '/cc_autocomplete', {} );                               \n"
-                       " new Ajax.Autocompleter('bcc_id', 'bcc_name_choices',          \n"
-                       "       '/bcc_autocomplete', {} );                              \n"
-                       " new Ajax.Autocompleter('recp_id', 'recp_name_choices',        \n"
-                       "       '/recp_autocomplete', {} );                             \n"
-                       "</script>                                                      \n"
+               /* Initialize the autocomplete ajax helpers (found in wclib.js) */
+               wprintf("<script type=\"text/javascript\">      \n"
+                       " activate_entmsg_autocompleters();     \n"
+                       "</script>                              \n"
                );
-
        }
 
        wprintf("<tr><td>");
@@ -2538,7 +2575,7 @@ void delete_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1, 1, 1, 0, 0, 0, 0);
+       output_headers(1, 1, 1, 0, 0, 0);
 
        sprintf(buf, "DELE %ld", msgid);
        serv_puts(buf);
@@ -2562,7 +2599,7 @@ void confirm_move_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1, 1, 1, 0, 0, 0, 0);
+       output_headers(1, 1, 1, 0, 0, 0);
 
        wprintf("<div id=\"fix_scrollbar_bug\">"
                "<table width=100%% border=0 bgcolor=\"#444455\"><tr><td>");
@@ -2614,7 +2651,7 @@ void move_msg(void)
 
        msgid = atol(bstr("msgid"));
 
-       output_headers(1, 1, 1, 0, 0, 0, 0);
+       output_headers(1, 1, 1, 0, 0, 0);
 
        if (strlen(bstr("move_button")) > 0) {
                sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));