]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* Set up framework for "notes" view, and added a skeleton function for
[citadel.git] / webcit / messages.c
index c9e0c5588aa1d0ec15c83ca6fb58a97f06bbcaea..5092c6abce64ffbb326c43c13e294f3802159684 100644 (file)
@@ -498,51 +498,46 @@ void read_message(long msgnum) {
                wprintf("****");
        }
 
-       wprintf("</SPAN></TD>");
-
-       wprintf("<TD ALIGN=RIGHT>\n"
-               "<TABLE BORDER=0><TR>\n");
+       wprintf("</SPAN>");
+       if (strlen(m_subject) > 0) {
+               wprintf("<BR>"
+                       "<SPAN CLASS=\"message_subject\">"
+                       "Subject: %s"
+                       "</SPAN>", m_subject
+               );
+       }
+       wprintf("</TD>\n");
 
-       wprintf("<TD BGCOLOR=\"#AAAADD\">"
-               "<A HREF=\"/display_enter?recp=");
+       /* start msg buttons */
+       wprintf("<TD ALIGN=RIGHT>\n");
+       wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_one_msg\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%ld\">\n",
+               msgnum);
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
        urlescputs(reply_to);
+       wprintf("\">\n");
+
        if (!strncasecmp(m_subject, "Re:", 2)) {
-               wprintf("&subject=");
+               wprintf("<INPUT TYPE=\"hidden\" NAME=\"subject\" VALUE=\"");
                escputs(m_subject);
+               wprintf("\">\n");
        }
        else if (strlen(m_subject) > 0) {
-               wprintf("&subject=Re:%%20");
+               wprintf("<INPUT TYPE=\"hidden\" NAME=\"subject\" VALUE=\"Re: ");
                escputs(m_subject);
+               wprintf("\">\n");
        }
-       wprintf("\"><FONT SIZE=-1>Reply</FONT></A></TD>\n", msgnum);
 
-       if (WC->is_room_aide) {
-               wprintf("<TD BGCOLOR=\"#AAAADD\">"
-                       "<A HREF=\"/confirm_move_msg"
-                       "&msgid=%ld"
-                       "\"><FONT SIZE=-1>Move</FONT></A>"
-                       "</TD>\n", msgnum);
+       wprintf("<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\" VALUE=\"Reply\">\n");
 
-               wprintf("<TD BGCOLOR=\"#AAAADD\">"
-                       "<A HREF=\"/delete_msg"
-                       "&msgid=%ld\""
-                       "onClick=\"return confirm('Delete this message?');\""
-                       "><FONT SIZE=-1>Del</FONT></A>"
-                       "</TD>\n", msgnum);
+       if (WC->is_room_aide)  {
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\"VALUE=\"Move\">\n"
+                       "<INPUT TYPE=\"submit\" NAME=\"msg_oper\" STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif; font-size: 7pt; background: blue; color: #FFFFFF;\" VALUE=\"Delete\""
+                       "onClick=\"return confirm('Delete this message?');\">\n");
        }
 
-       wprintf("</TR></TABLE>\n"
-               "</TD>\n");
-
-       if (strlen(m_subject) > 0) {
-               wprintf("<TR><TD>"
-                       "<SPAN CLASS=\"message_subject\">"
-                       "Subject: %s"
-                       "</SPAN>"
-                       "</TD><TD>&nbsp;</TD></TR>\n", m_subject);
-       }
-
-       wprintf("</TR></TABLE>\n");
+       wprintf("</FORM>\n"
+               "</TD></TR></TABLE>\n");
 
        /* Begin body */
        wprintf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=#FFFFFF "
@@ -577,11 +572,11 @@ void read_message(long msgnum) {
                                buf[strlen(buf) - 1] = 0;
                        if ((bq == 0) &&
                        ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
-                               wprintf("<SPAN CLASS=\"pull_quote\">");
+                               wprintf("<BLOCKQUOTE>");
                                bq = 1;
                        } else if ((bq == 1) &&
                                (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
-                               wprintf("</SPAN>");
+                               wprintf("</BLOCKQUOTE>");
                                bq = 0;
                        }
                        wprintf("<TT>");
@@ -1037,6 +1032,7 @@ void readloop(char *oper)
        int is_singlecard = 0;
        int is_calendar = 0;
        int is_tasks = 0;
+       int is_notes = 0;
        int remaining_messages;
        int lo, hi;
        int lowest_displayed = (-1);
@@ -1107,13 +1103,17 @@ void readloop(char *oper)
                is_tasks = 1;
                strcpy(cmd, "MSGS ALL");
                maxmsgs = 32767;
-               wprintf("<UL>");
+       }
+       if (WC->wc_view == VIEW_NOTES) {                /* notes */
+               is_notes = 1;
+               strcpy(cmd, "MSGS ALL");
+               maxmsgs = 32767;
        }
 
        nummsgs = load_msg_ptrs(cmd);
        if (nummsgs == 0) {
 
-               if ((!is_tasks) && (!is_calendar)) {
+               if ((!is_tasks) && (!is_calendar) && (!is_notes)) {
                        if (!strcmp(oper, "readnew")) {
                                wprintf("<EM>No new messages.</EM>\n");
                        } else if (!strcmp(oper, "readold")) {
@@ -1194,6 +1194,9 @@ void readloop(char *oper)
                        else if (is_tasks) {
                                display_task(WC->msgarr[a]);
                        }
+                       else if (is_notes) {
+                               display_note(WC->msgarr[a]);
+                       }
                        else {
                                read_message(WC->msgarr[a]);
                        }
@@ -1215,10 +1218,6 @@ void readloop(char *oper)
                wprintf("</TABLE>\n");
        }
 
-       if (is_tasks) {
-               wprintf("</UL>\n");
-       }
-
        /* Bump these because although we're thinking in zero base, the user
         * is a drooling idiot and is thinking in one base.
         */
@@ -1227,7 +1226,7 @@ void readloop(char *oper)
 
        /* If we're only looking at one message, do a prev/next thing */
        if (num_displayed == 1) {
-          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) {
+          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
 
                wprintf("<CENTER>"
                        "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
@@ -1276,7 +1275,7 @@ void readloop(char *oper)
         * messages, then display the selector bar
         */
        if (num_displayed > 1) {
-          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_singlecard)) {
+          if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
                wprintf("<CENTER>"
                        "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
                        "Reading #%d-%d of %d messages.</TD>\n"
@@ -1331,9 +1330,7 @@ void readloop(char *oper)
 
 DONE:
        if (is_tasks) {
-               wprintf("<A HREF=\"/display_edit_task?msgnum=0\">"
-                       "Add new task</A>\n"
-               );
+               do_tasks_view();        /* Render the task list */
        }
 
        if (is_calendar) {
@@ -1517,7 +1514,7 @@ void display_enter(void)
        struct wc_attachment *att;
 
        if (strlen(bstr("force_room")) > 0) {
-               gotoroom(bstr("force_room"), 0);
+               gotoroom(bstr("force_room"));
        }
 
        /* Are we perhaps in an address book view?  If so, then an "enter
@@ -1528,6 +1525,7 @@ void display_enter(void)
                return;
        }
 
+#ifdef WEBCIT_WITH_CALENDAR_SERVICE
        /* Are we perhaps in a calendar view?  If so, then an "enter
         * message" command really means "add new calendar item."
         */
@@ -1543,6 +1541,7 @@ void display_enter(void)
                display_edit_task();
                return;
        }
+#endif
 
        /* Otherwise proceed normally */
        output_headers(1);
@@ -1589,18 +1588,24 @@ void display_enter(void)
                bstr("recp"));
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
                now);
+
+       wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
+       wprintf("<TR><TD ALIGN=LEFT>");
        wprintf("<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \">");
                /* "onLoad=\"document.enterform.msgtext.focus();\" " */
        wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
                "<INPUT TYPE=\"text\" NAME=\"subject\" VALUE=\"");
        escputs(bstr("subject"));
-       wprintf("\" MAXLENGTH=70>"
+       wprintf("\" SIZE=40 MAXLENGTH=70>"
                "&nbsp;"
        );
+       wprintf("</TD>");
 
+       wprintf("<TD ALIGN=RIGHT>");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
                "&nbsp;"
                "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
+       wprintf("</TD></TR></TABLE>\n");
 
        wprintf("<SCRIPT language=\"JavaScript\" type=\"text/javascript\" "
                "src=\"static/richtext_compressed.js\"></SCRIPT>\n"
@@ -1748,8 +1753,37 @@ void move_msg(void)
        wDumpContent(1);
 }
 
+/*
+ * This gets called when a user selects Reply/Move/Del etc. on *one* message.
+ */
+void do_stuff_to_one_msg(void) {
+       char *msg_oper;
+
+       msg_oper = bstr("msg_oper");
+
+       if (!strcasecmp(msg_oper, "Delete")) {
+               delete_msg();   /* It's already been confirmed using JS */
+               return;
+       }
+       if (!strcasecmp(msg_oper, "Move")) {
+               confirm_move_msg();
+               return;
+       }
+       if (!strcasecmp(msg_oper, "Reply")) {
+               display_enter();        /* recp and subject already set */
+               return;
+       }
+
+       /* should never get here.  FIXME: display an error */
+
+}
 
 
+/*
+ * This gets called when a user selects multiple messages in a summary
+ * list and then clicks to perform a transformation of some sort on them
+ * (such as deleting them).
+ */
 void do_stuff_to_msgs(void) {
        char buf[SIZ];
        char sc[SIZ];