* New user registration, as well as existing user re-registration, now
authorArt Cancro <ajc@citadel.org>
Sat, 1 Mar 2003 22:07:19 +0000 (22:07 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 1 Mar 2003 22:07:19 +0000 (22:07 +0000)
  uses the vCard editing screen.
* Administratively editing users' address book entries now works again,
  mainly due to a fix in the Citadel server.  Now requiring Citadel 6.06
  in order to enforce this.

webcit/ChangeLog
webcit/auth.c
webcit/preferences.c
webcit/useredit.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h

index b6c7d4d7bf6e243501df4394bd1bc6aaf8ab6fb0..b8a5d6f8890a053522f647fe00af6f6103ed8e23 100644 (file)
@@ -1,4 +1,11 @@
 $Log$
+Revision 410.1  2003/03/01 22:07:19  ajc
+* New user registration, as well as existing user re-registration, now
+  uses the vCard editing screen.
+* Administratively editing users' address book entries now works again,
+  mainly due to a fix in the Citadel server.  Now requiring Citadel 6.06
+  in order to enforce this.
+
 Revision 410.0  2003/02/19 03:49:33  ajc
 * THIS IS 4.10
 
@@ -1273,3 +1280,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 814a43b6896205639627fb835d0c1c9001828e8a..c0f23ae309b2425bb751f122bd2b104574964e5a 100644 (file)
@@ -286,9 +286,6 @@ void validate(void)
 
 
 
-
-
-
 /* 
  * Display form for registration.
  * (Set during_login to 1 if this registration is being performed during
@@ -296,105 +293,29 @@ void validate(void)
  */
 void display_reg(int during_login)
 {
-       char buf[SIZ];
-       int a;
+       long vcard_msgnum;
 
-       output_headers(3);
-
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Enter registration info</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
-
-       wprintf("<CENTER>");
-       serv_puts("MESG register");
-       serv_gets(buf);
-       if (buf[0] == '1')
-               fmout(NULL);
-
-       wprintf("<FORM ACTION=\"/register\" METHOD=\"POST\">\n");
-       wprintf("<INPUT TYPE=\"hidden\" NAME=\"during_login\" VALUE=\"%d\">\n", during_login);
-
-       serv_puts("GREG _SELF_");
-       serv_gets(buf);
-       if (buf[0] != '1') {
-               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
-       } else {
-
-               wprintf("<H1>%s</H1><TABLE border>\n", &buf[4]);
-               a = 0;
-               while (serv_gets(buf), strcmp(buf, "000")) {
-                       ++a;
-                       wprintf("<TR><TD>");
-                       switch (a) {
-                       case 3:
-                               wprintf("Real Name:</TD><TD><INPUT TYPE=\"text\" NAME=\"realname\" VALUE=\"%s\" MAXLENGTH=\"29\"><BR>\n", buf);
-                               break;
-                       case 4:
-                               wprintf("Street Address:</TD><TD><INPUT TYPE=\"text\" NAME=\"address\" VALUE=\"%s\" MAXLENGTH=\"24\"><BR>\n", buf);
-                               break;
-                       case 5:
-                               wprintf("City/town:</TD><TD><INPUT TYPE=\"text\" NAME=\"city\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
-                               break;
-                       case 6:
-                               wprintf("State/province:</TD><TD><INPUT TYPE=\"text\" NAME=\"state\" VALUE=\"%s\" MAXLENGTH=\"2\"><BR>\n", buf);
-                               break;
-                       case 7:
-                               wprintf("ZIP/postal code:</TD><TD><INPUT TYPE=\"text\" NAME=\"zip\" VALUE=\"%s\" MAXLENGTH=\"10\"><BR>\n", buf);
-                               break;
-                       case 8:
-                               wprintf("Telephone:</TD><TD><INPUT TYPE=\"text\" NAME=\"phone\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
-                               break;
-                       case 10:
-                               wprintf("E-Mail:</TD><TD><INPUT TYPE=\"text\" NAME=\"email\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n", buf);
-                               break;
-                       case 11:
-                               wprintf("Country:</TD><TD><INPUT TYPE=\"text\" NAME=\"country\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n", buf);
-                               break;
-                       }
-                       wprintf("</TD></TR>\n");
-               }
-               wprintf("</TABLE><P>");
+       if (goto_config_room() != 0) {
+               if (during_login) do_welcome();
+               else display_main_menu();
+               return;
        }
-       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Register\">\n");
-       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
-       wprintf("</CENTER>\n");
-       wDumpContent(1);
-}
-
-/*
- * register
- */
-void register_user(void)
-{
-       char buf[SIZ];
 
-       if (strcmp(bstr("action"), "Register")) {
-               display_error("Cancelled.  Registration was not saved.");
+       vcard_msgnum = locate_user_vcard(WC->wc_username, -1);
+       if (vcard_msgnum < 0L) {
+               if (during_login) do_welcome();
+               else display_main_menu();
                return;
        }
-       serv_puts("REGI");
-       serv_gets(buf);
-       if (buf[0] != '4') {
-               display_error(&buf[4]);
+
+       if (during_login) {
+               do_edit_vcard(vcard_msgnum, "1", "/do_welcome");
        }
-       serv_puts(bstr("realname"));
-       serv_puts(bstr("address"));
-       serv_puts(bstr("city"));
-       serv_puts(bstr("state"));
-       serv_puts(bstr("zip"));
-       serv_puts(bstr("phone"));
-       serv_puts(bstr("email"));
-       serv_puts(bstr("country"));
-       serv_puts("000");
-
-       if (atoi(bstr("during_login"))) {
-               do_welcome();
-       } else {
-               display_success("Registration information has been saved.");
+       else {
+               do_edit_vcard(vcard_msgnum, "1", "/display_main_menu");
        }
-}
 
+}
 
 
 
index 916f55824c1686855618d93309cf75407576a5f1..9ae4de5f9e448b06518c69fba9267fd05d8d1368 100644 (file)
@@ -34,8 +34,6 @@ void load_preferences(void) {
        char buf[SIZ];
        long msgnum = 0L;
 
-       lprintf(9, "entering load_preferences()\n");
-
        serv_printf("GOTO %s", USERCONFIGROOM);
        serv_gets(buf);
        if (buf[0] != '2') return;
@@ -80,14 +78,15 @@ void load_preferences(void) {
        /* Go back to the room we're supposed to be in */
        serv_printf("GOTO %s", WC->wc_roomname);
        serv_gets(buf);
-       lprintf(9, "exiting load_preferences()\n");
 }
 
-void save_preferences(void) {
+/*
+ * Goto the user's configuration room, creating it if necessary.
+ * Returns 0 on success or nonzero upon failure.
+ */
+int goto_config_room(void) {
        char buf[SIZ];
-       long msgnum = 0L;
 
-       lprintf(9, "entering save_preferences()\n");
        serv_printf("GOTO %s", USERCONFIGROOM);
        serv_gets(buf);
        if (buf[0] != '2') { /* try to create the config room if not there */
@@ -95,9 +94,17 @@ void save_preferences(void) {
                serv_gets(buf);
                serv_printf("GOTO %s", USERCONFIGROOM);
                serv_gets(buf);
-               if (buf[0] != '2') return;      /* oh well. */
+               if (buf[0] != '2') return(1);
        }
+       return(0);
+}
+
+
+void save_preferences(void) {
+       char buf[SIZ];
+       long msgnum = 0L;
 
+       if (goto_config_room() != 0) return;    /* oh well. */
        serv_puts("MSGS ALL|0|1");
        serv_gets(buf);
        if (buf[0] == '8') {
@@ -124,7 +131,6 @@ void save_preferences(void) {
        /* Go back to the room we're supposed to be in */
        serv_printf("GOTO %s", WC->wc_roomname);
        serv_gets(buf);
-       lprintf(9, "exiting save_preferences()\n");
 }
 
 void get_preference(char *key, char *value) {
@@ -133,7 +139,6 @@ void get_preference(char *key, char *value) {
        char buf[SIZ];
        char thiskey[SIZ];
 
-       lprintf(9, "entering get_preference(%s)\n", key);
        strcpy(value, "");
 
        num_prefs = num_tokens(WC->preferences, '\n');
@@ -144,7 +149,6 @@ void get_preference(char *key, char *value) {
                        extract_token(value, buf, 1, '|');
                }
        }
-       lprintf(9, "exiting get_preference() = %s\n", value);
 }
 
 void set_preference(char *key, char *value) {
@@ -154,7 +158,6 @@ void set_preference(char *key, char *value) {
        char thiskey[SIZ];
        char *newprefs = NULL;
 
-       lprintf(9, "entering set_preference(%s, %s)\n", key, value);
        num_prefs = num_tokens(WC->preferences, '\n');
        for (i=0; i<num_prefs; ++i) {
                extract_token(buf, WC->preferences, i, '\n');
@@ -179,5 +182,4 @@ void set_preference(char *key, char *value) {
        WC->preferences = newprefs;
 
        save_preferences();
-       lprintf(9, "exiting set_preference()\n");
 }
index 8424f9d91960d87a72f3a1a4424d894a8d7146b2..494bd4fed5355c1acea821563fdc5882ce586ea6 100644 (file)
@@ -88,12 +88,10 @@ void select_user_to_edit(char *message, char *preselect)
 
 
 /* 
- * Display the form for editing a user's address book entry
+ * Locate the message number of a user's vCard in the current room
  */
-void display_edit_address_book_entry(char *username, long usernum) {
-       char roomname[SIZ];
+long locate_user_vcard(char *username, long usernum) {
        char buf[SIZ];
-       char error_message[SIZ];
        long vcard_msgnum = (-1L);
        char content_type[SIZ];
        char partnum[SIZ];
@@ -107,25 +105,6 @@ void display_edit_address_book_entry(char *username, long usernum) {
        struct stuff_t *stuff = NULL;
        struct stuff_t *ptr;
 
-
-       /* Locate the user's config room, creating it if necessary */
-       sprintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
-       serv_printf("GOTO %s||1", roomname);
-       serv_gets(buf);
-       if (buf[0] != '2') {
-               serv_printf("CRE8 1|%s|5|||1|", roomname);
-               serv_gets(buf);
-               serv_printf("GOTO %s||1", roomname);
-               serv_gets(buf);
-               if (buf[0] != '2') {
-                       sprintf(error_message,
-                               "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                               "%s<BR><BR>\n", &buf[4]);
-                       select_user_to_edit(error_message, username);
-                       return;
-               }
-       }
-
 TRYAGAIN:
        /* Search for the user's vCard */
        serv_puts("MSGS ALL");
@@ -137,7 +116,7 @@ TRYAGAIN:
                stuff = ptr;
        }
 
-       /* Iterate throught the message list looking for vCards */
+       /* Iterate through the message list looking for vCards */
        while (stuff != NULL) {
                serv_printf("MSG0 %ld|2", stuff->msgnum);
                serv_gets(buf);
@@ -159,8 +138,6 @@ TRYAGAIN:
                stuff = ptr;
        }
 
-       lprintf(9, "vcard_msgnum == %ld\n", vcard_msgnum);
-
        /* If there's no vcard, create one */
        if (vcard_msgnum < 0) if (already_tried_creating_one == 0) {
                already_tried_creating_one = 1;
@@ -176,10 +153,45 @@ TRYAGAIN:
                goto TRYAGAIN;
        }
 
+       return(vcard_msgnum);
+}
+
+
+/* 
+ * Display the form for editing a user's address book entry
+ */
+void display_edit_address_book_entry(char *username, long usernum) {
+       char roomname[SIZ];
+       char buf[SIZ];
+       char error_message[SIZ];
+       long vcard_msgnum = (-1L);
+
+       /* Locate the user's config room, creating it if necessary */
+       sprintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
+       serv_printf("GOTO %s||1", roomname);
+       serv_gets(buf);
+       if (buf[0] != '2') {
+               serv_printf("CRE8 1|%s|5|||1|", roomname);
+               serv_gets(buf);
+               serv_printf("GOTO %s||1", roomname);
+               serv_gets(buf);
+               if (buf[0] != '2') {
+                       sprintf(error_message,
+                               "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
+                               "%s<BR><BR>\n", &buf[4]);
+                       select_user_to_edit(error_message, username);
+                       return;
+               }
+       }
+
+       vcard_msgnum = locate_user_vcard(username, usernum);
+
        if (vcard_msgnum < 0) {
                sprintf(error_message,
                        "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                       "Could not create/edit vCard<BR><BR>\n");
+                       "Could not create/edit vCard"
+                       "<BR><BR>\n"
+               );
                select_user_to_edit(error_message, username);
                return;
        }
index 8a9d1b429979e295ad6c84027c465084cdb11c63..8365b54c837799f299703d98cac2403372e76877 100644 (file)
@@ -250,7 +250,6 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) {
                 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
                 wprintf("</CENTER></FORM>\n");
 
-        
        wDumpContent(1);
 }
 
@@ -319,6 +318,9 @@ void submit_vcard(void) {
        if (!strcmp(bstr("return_to"), "/select_user_to_edit")) {
                select_user_to_edit(NULL, NULL);
        }
+       else if (!strcmp(bstr("return_to"), "/do_welcome")) {
+               do_welcome();
+       }
        else {
                readloop("readnew");
        }
index 1233b04a4ab7530d8f1e0328355398fbe2291fcc..26c0e06d230a4a2891db6858e4f9a8a8cce50b6c 100644 (file)
@@ -1039,8 +1039,6 @@ void session_loop(struct httprequest *req)
                do_graphics_upload(buf);
        } else if (!strcasecmp(action, "display_reg")) {
                display_reg(0);
-       } else if (!strcasecmp(action, "register")) {
-               register_user();
        } else if (!strcasecmp(action, "display_changepw")) {
                display_changepw();
        } else if (!strcasecmp(action, "changepw")) {
index cd7bfc4ccc2eb71f1c30fc9d1d0e67bf8908ffd2..08473b0d97f9c4cf4513473f719ee3a828fa4e6e 100644 (file)
@@ -28,7 +28,7 @@
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4
 #define CLIENT_VERSION         410             /* This version of WebCit */
-#define MINIMUM_CIT_VERSION    605             /* min required Citadel vers */
+#define MINIMUM_CIT_VERSION    606             /* min required Citadel vers */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */
@@ -292,7 +292,6 @@ void serv_puts(char *string);
 void serv_printf(const char *format,...);
 void load_floorlist(void);
 void display_reg(int);
-void register_user(void);
 void display_changepw(void);
 void changepw(void);
 void display_edit_node(void);
@@ -388,4 +387,6 @@ void partstat_as_string(char *buf, icalproperty *attendee);
 extern char *months[];
 extern char *days[];
 void read_server_binary(char *buffer, size_t total_len);
+int goto_config_room(void);
+long locate_user_vcard(char *username, long usernum);
 void sleeeeeeeeeep(int);