]> code.citadel.org Git - citadel.git/blobdiff - webcit/notes.c
* collect sender / read / unread information for calendar items
[citadel.git] / webcit / notes.c
index 667745c7fcbce75ac66e55d94e125ff9b4bfeed0..3896d11cfe21588ca2e3d2bb8110dd36966412dd 100644 (file)
@@ -3,7 +3,7 @@
  */
 /**
  * \defgroup StickyNotes Functions which handle "sticky notes"
- *
+ * \ingroup WebcitDisplayItems
  */
 /*@{*/
 #include "webcit.h"
  * \brief display sticky notes
  * \param msgnum the citadel mesage number
  */
-void display_note(long msgnum)
+void display_note(long msgnum, int unread)
 {
        char buf[SIZ];
        char notetext[SIZ];
        char display_notetext[SIZ];
        char eid[128];
        int in_text = 0;
-       int i;
-
-       wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
+       int i, len;
 
+//     wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
        serv_printf("MSG0 %ld", msgnum);
        serv_getln(buf, sizeof buf);
        if (buf[0] != '1') {
@@ -51,13 +50,34 @@ void display_note(long msgnum)
        }
 
        /** Now sanitize the buffer */
-       for (i=0; i<strlen(notetext); ++i) {
+       len = strlen(notetext);
+       for (i=0; i<len; ++i) {
                if (isspace(notetext[i])) notetext[i] = ' ';
        }
 
        /** Make it HTML-happy and print it. */
-       stresc(display_notetext, notetext, 0, 0);
-       if (strlen(eid) > 0) {
+       stresc(display_notetext, SIZ, notetext, 0, 0);
+/* Lets try it as a draggable */
+       if (!IsEmptyStr(eid)) {
+               wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%s\" alt=\"Note\" ", eid); 
+               wprintf ("class=\"notes\">\n");
+               wprintf ("<script type=\"text/javascript\">\n");
+//             wprintf ("//<![CDATA[\n");
+               wprintf ("new Draggable (\"note_%s\", {revert:true})\n", eid);
+//             wprintf ("//]]>\n");
+               wprintf ("</script>\n");
+       }
+       else {
+               wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%ld\" ", msgnum); 
+               wprintf ("class=\"notes\">\n");
+               wprintf ("<script type=\"text/javascript\">\n");
+//             wprintf ("//<![CDATA[\n");
+               wprintf ("new Draggable (\"note_%ld\", {revert:true})\n", msgnum);
+//             wprintf ("//]]>\n");
+               wprintf ("</script>\n");
+       }
+       
+       if (!IsEmptyStr(eid)) {
                wprintf("<span id=\"note%s\">%s</span><br />\n", eid, display_notetext);
        }
        else {
@@ -65,11 +85,12 @@ void display_note(long msgnum)
        }
 
        /** Offer in-place editing. */
-       if (strlen(eid) > 0) {
+       if (!IsEmptyStr(eid)) {
                wprintf("<script type=\"text/javascript\">"
-                       " new Ajax.InPlaceEditor('note%s', 'updatenote?eid=%s', {rows:5,cols:72}); "
+                       "new Ajax.InPlaceEditor('note%s', 'updatenote?nonce=%ld?eid=%s', {rows:5,cols:72});"
                        "</script>\n",
                        eid,
+                       WC->nonce,
                        eid
                );
        }
@@ -86,12 +107,12 @@ void updatenote(void)
        char display_notetext[SIZ];
        long msgnum;
        int in_text = 0;
-       int i;
+       int i, len;
 
        serv_printf("ENT0 1||0|0||||||%s", bstr("eid"));
        serv_getln(buf, sizeof buf);
        if (buf[0] == '4') {
-               text_to_server(bstr("value"), 0);
+               text_to_server(bstr("value"));
                serv_puts("000");
        }
 
@@ -101,6 +122,7 @@ void updatenote(void)
                serv_printf("MSG0 %ld", msgnum);
                serv_getln(buf, sizeof buf);
                if (buf[0] == '1') {
+                       strcpy(notetext, "");
                        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                
                                /** Fill the buffer */
@@ -113,12 +135,13 @@ void updatenote(void)
                                }
                        }
                        /** Now sanitize the buffer */
-                       for (i=0; i<strlen(notetext); ++i) {
+                       len = strlen(notetext);
+                       for (i=0; i<len; ++i) {
                                if (isspace(notetext[i])) notetext[i] = ' ';
                        }
                
                        /** Make it HTML-happy and print it. */
-                       stresc(display_notetext, notetext, 0, 0);
+                       stresc(display_notetext, SIZ, notetext, 0, 0);
                        wprintf("%s\n", display_notetext);
                }
        }