* Cleaned up the rcs/cvs Id tags and leading comments at the top of some files
[citadel.git] / webcit / useredit.c
index 494bd4fed5355c1acea821563fdc5882ce586ea6..78fa28ba68da3498603832480ba8a6903aaeeeee 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * $Id$
+ *
  * Administrative screen to add/change/delete user accounts
  *
  */
@@ -35,20 +37,20 @@ void select_user_to_edit(char *message, char *preselect)
        char buf[SIZ];
        char username[SIZ];
 
-       output_headers(3);      /* No room banner on this screen */
+       output_headers(1, 1, 0, 0, 0, 0, 0);    /* No room banner on this screen */
 
        if (message != NULL) wprintf(message);
 
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>"
-               "Add/change/delete user accounts"
-               "</B></FONT></TD></TR></TABLE>\n");
+       wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>\n");
+
+       svprintf("BOXTITLE", WCS_STRING, "Edit or Delete users");
+       do_template("beginbox");
 
-       wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
-               "<TD>To edit an existing user account, select the user "
-               "name from the list and click 'Edit'.<BR><BR>");
+       wprintf("To edit an existing user account, select the user "
+               "name from the list and click 'Edit'.<br /><br />");
        
-        wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_edituser\">\n");
+        wprintf("<CENTER>"
+               "<FORM METHOD=\"POST\" ACTION=\"/display_edituser\">\n");
         wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
         serv_puts("LIST");
         serv_gets(buf);
@@ -64,22 +66,28 @@ void select_user_to_edit(char *message, char *preselect)
                         wprintf("\n");
                 }
         }
-        wprintf("</SELECT><BR>\n");
+        wprintf("</SELECT><br />\n");
 
         wprintf("<input type=submit name=sc value=\"Edit configuration\">");
         wprintf("<input type=submit name=sc value=\"Edit address book entry\">");
         wprintf("</FORM></CENTER>\n");
+       do_template("endbox");
+
+       wprintf("</TD><TD>");
 
-       wprintf("</TD><TD>"
-               "To create a new user account, enter the desired "
-               "user name in the box below and click 'Create'.<BR><BR>");
+       svprintf("BOXTITLE", WCS_STRING, "Add users");
+       do_template("beginbox");
+
+       wprintf("To create a new user account, enter the desired "
+               "user name in the box below and click 'Create'.<br /><br />");
 
         wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/create_user\">\n");
         wprintf("New user: ");
-        wprintf("<input type=text name=username><BR>\n"
+        wprintf("<input type=text name=username><br />\n"
                "<input type=submit value=\"Create\">"
                "</FORM></CENTER>\n");
 
+       do_template("endbox");
        wprintf("</TD></TR></TABLE>\n");
 
        wDumpContent(1);
@@ -178,7 +186,7 @@ void display_edit_address_book_entry(char *username, long usernum) {
                if (buf[0] != '2') {
                        sprintf(error_message,
                                "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                               "%s<BR><BR>\n", &buf[4]);
+                               "%s<br /><br />\n", &buf[4]);
                        select_user_to_edit(error_message, username);
                        return;
                }
@@ -190,7 +198,7 @@ void display_edit_address_book_entry(char *username, long usernum) {
                sprintf(error_message,
                        "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
                        "Could not create/edit vCard"
-                       "<BR><BR>\n"
+                       "<br /><br />\n"
                );
                select_user_to_edit(error_message, username);
                return;
@@ -205,8 +213,11 @@ void display_edit_address_book_entry(char *username, long usernum) {
 /*
  * Edit a user.  If supplied_username is null, look in the "username"
  * web variable for the name of the user to edit.
+ * 
+ * If "is_new" is set to nonzero, this screen will set the web variables
+ * to send the user to the vCard editor next.
  */
-void display_edituser(char *supplied_username) {
+void display_edituser(char *supplied_username, int is_new) {
        char buf[SIZ];
        char error_message[SIZ];
        time_t now;
@@ -234,7 +245,7 @@ void display_edituser(char *supplied_username) {
        if (buf[0] != '2') {
                sprintf(error_message,
                        "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                       "%s<BR><BR>\n", &buf[4]);
+                       "%s<br /><br />\n", &buf[4]);
                select_user_to_edit(error_message, username);
                return;
        }
@@ -254,17 +265,23 @@ void display_edituser(char *supplied_username) {
                return;
        }
 
-       output_headers(3);      /* No room banner on this screen */
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>"
+       output_headers(1, 1, 2, 0, 0, 0, 0);
+       wprintf("<div id=\"banner\">\n");
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
+       wprintf("<SPAN CLASS=\"titlebar\">"
                "Edit user account: ");
        escputs(username);
-       wprintf("</B></FONT></TD></TR></TABLE>\n");
+       wprintf("</SPAN></TD></TR></TABLE>\n");
+       wprintf("</div>\n<div id=\"content\">\n");
 
+       do_template("beginbox_nt");
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/edituser\">\n"
                "<INPUT TYPE=\"hidden\" NAME=\"username\" VALUE=\"");
        escputs(username);
        wprintf("\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"is_new\" VALUE=\"%d\">\n"
+               "<INPUT TYPE=\"hidden\" NAME=\"usernum\" VALUE=\"%ld\">\n",
+               is_new, usernum);
 
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"flags\" VALUE=\"%d\">\n", flags);
 
@@ -324,10 +341,12 @@ void display_edituser(char *supplied_username) {
        wprintf("</TABLE>\n");
 
        wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"OK\">\n"
+               "&nbsp;"
                "<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n"
-               "<BR><BR></FORM>\n");
+               "<br /><br /></FORM>\n");
 
        wprintf("</CENTER>\n");
+       do_template("endbox");
 
        wDumpContent(1);
 
@@ -338,6 +357,9 @@ void display_edituser(char *supplied_username) {
 void edituser(void) {
        char message[SIZ];
        char buf[SIZ];
+       int is_new = 0;
+
+       is_new = atoi(bstr("is_new"));
 
        if (strcasecmp(bstr("action"), "OK")) {
                strcpy(message, "Edit user cancelled.");
@@ -360,14 +382,22 @@ void edituser(void) {
                if (buf[0] != '2') {
                        sprintf(message,
                                "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                               "%s<BR><BR>\n", &buf[4]);
+                               "%s<br /><br />\n", &buf[4]);
                }
                else {
                        strcpy(message, "");
                }
        }
 
-       select_user_to_edit(message, bstr("username"));
+       /* If we are in the middle of creating a new user, move on to
+        * the vCard edit screen.
+        */
+       if (is_new) {
+               display_edit_address_book_entry( bstr("username"), atol(bstr("usernum")) );
+       }
+       else {
+               select_user_to_edit(message, bstr("username"));
+       }
 }
 
 
@@ -384,13 +414,14 @@ void create_user(void) {
        serv_gets(buf);
 
        if (buf[0] == '2') {
-               sprintf(error_message, "<b>User has been created.</b>");
-               select_user_to_edit(error_message, username);
+               /* sprintf(error_message, "<b>User has been created.</b>");
+               select_user_to_edit(error_message, username); */
+               display_edituser(username, 1);
        }
        else {
                sprintf(error_message,
                        "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
-                       "%s<BR><BR>\n", &buf[4]);
+                       "%s<br /><br />\n", &buf[4]);
                select_user_to_edit(error_message, NULL);
        }