* Final polish for initial round of vCard editing functions. Only show "edit"
authorArt Cancro <ajc@citadel.org>
Thu, 7 Mar 2002 04:56:09 +0000 (04:56 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 7 Mar 2002 04:56:09 +0000 (04:56 +0000)
  link when editing user's own vCard in the My Citadel Config> room.

webcit/ChangeLog
webcit/messages.c
webcit/vcard_edit.c
webcit/webcit.h

index cb15edbfb05d1e6eb49efa5d192a0c3bab662da6..fbdc01f6560a350879feedd7428beb26195e0246 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 323.10  2002/03/07 04:56:09  ajc
+* Final polish for initial round of vCard editing functions.  Only show "edit"
+  link when editing user's own vCard in the My Citadel Config> room.
+
 Revision 323.9  2002/03/06 05:22:33  ajc
 * More vcard editing form stuff
 
@@ -738,3 +742,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 15e514ba3a0b932278c8eeb9ed2da3af042bda7e..3d0502adc8899e9b8878c7b2d44963d3360c4e84 100644 (file)
@@ -98,7 +98,10 @@ void display_vcard(char *vcard_source) {
        wprintf("<TABLE bgcolor=#888888>");
        if (v->numprops) for (i=0; i<(v->numprops); ++i) {
                if (!strcasecmp(v->prop[i].name, "n")) {
-                       wprintf("<TR BGCOLOR=#AAAAAA><TD><FONT SIZE=+1><B>");
+                       wprintf("<TR BGCOLOR=#AAAAAA>"
+                       "<TD BGCOLOR=#FFFFFF>"
+                       "<IMG VALIGN=CENTER SRC=\"/static/vcard.gif\"></TD>"
+                       "<TD><FONT SIZE=+1><B>");
                        escputs(v->prop[i].value);
                        wprintf("</B></FONT></TD></TR>\n");
                }
@@ -392,14 +395,15 @@ void read_message(long msgnum, int is_summary) {
                vcard_source = load_mimepart(msgnum, vcard_partnum);
                if (vcard_source != NULL) {
 
-                       /* FIXME this is a temporary hack to make the screen usable
-                        * while we build it.  We need a more intuitive way of getting
-                        * in.
-                        */
-                       wprintf("<A HREF=\"/edit_vcard?msgnum=%ld&partnum=%s\">",
-                               msgnum, vcard_partnum);
-                       wprintf("(edit)</A>");
+                       /* If it's my vCard I can edit it */
+                       if (!strcasecmp(WC->wc_roomname, USERCONFIGROOM)) {
+                               wprintf("<A HREF=\"/edit_vcard?"
+                                       "msgnum=%ld&partnum=%s\">",
+                                       msgnum, vcard_partnum);
+                               wprintf("(edit)</A>");
+                       }
 
+                       /* In all cases, display it */
                        display_vcard(vcard_source);
                        free(vcard_source);
                }
index e920ec942455ab9c73aed2810316c542c3cc9a96..99c629d842f3e5300dc057e4258f8c8d393f8236 100644 (file)
@@ -39,6 +39,7 @@ void edit_vcard(void) {
        struct vCard *v;
        int i;
        char *key, *value;
+       char whatuser[SIZ];
 
        char lastname[SIZ];
        char firstname[SIZ];
@@ -73,6 +74,28 @@ void edit_vcard(void) {
        extrafields[0] = 0;
 
        output_headers(1);
+
+       strcpy(whatuser, "");
+       sprintf(buf, "MSG0 %s|1", bstr("msgnum") );
+       serv_puts(buf);
+       serv_gets(buf);
+       if (buf[0] != '1') {
+               wDumpContent(1);
+               return;
+       }
+       while (serv_gets(buf), strcmp(buf, "000")) {
+               if (!strncasecmp(buf, "from=", 5)) {
+                       strcpy(whatuser, &buf[5]);
+               }
+               else if (!strncasecmp(buf, "node=", 5)) {
+                       strcat(whatuser, " @ ");
+                       strcat(whatuser, &buf[5]);
+               }
+       }
+
+       total_len = atoi(&buf[4]);
+
+
        sprintf(buf, "OPNA %s|%s", bstr("msgnum"), bstr("partnum") );
        serv_puts(buf);
        serv_gets(buf);
@@ -151,7 +174,9 @@ void edit_vcard(void) {
        /* Display the form */
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/submit_vcard\">\n");
        wprintf("<H2><IMG VALIGN=CENTER SRC=\"/static/vcard.gif\">"
-               "Contact information for FIXME</H2>\n");
+               "Contact information for ");
+       escputs(whatuser);
+       wprintf("</H2>\n");
 
        wprintf("<TABLE border=0><TR>"
                "<TD>Prefix</TD>"
@@ -231,6 +256,10 @@ void edit_vcard(void) {
 void submit_vcard(void) {
        char buf[SIZ];
 
+       if (strcmp(bstr("sc"), "OK")) { 
+               readloop("readnew");
+               return;
+       }
 
        sprintf(buf, "ENT0 1|||4||");
        fprintf(stderr, "%s\n", buf);
@@ -265,5 +294,5 @@ void submit_vcard(void) {
        serv_puts("end:vcard");
        serv_puts("000");
 
-       edit_vcard();
+       readloop("readnew");
 }
index 18cfeea3d77c79a30cb82a0915acb259d6d85384..86a87b5c035b7d1977bd965f7b54fbbe408ca715 100644 (file)
@@ -21,6 +21,8 @@
 #define INITIAL_WORKER_THREADS 5
 #define LISTEN_QUEUE_LENGTH    100             /* listen() backlog queue */
 
+#define USERCONFIGROOM         "My Citadel Config"
+
 
 /* Room flags (from Citadel) */
 #define QR_PERMANENT   1       /* Room does not purge              */