-void select_user_to_edit(char *message)
+void select_user_to_edit(char *message, char *preselect)
{
char buf[SIZ];
char username[SIZ];
if (message != NULL) wprintf(message);
- wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
- wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"<B>"
+ wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
+ wprintf("<SPAN CLASS=\"titlebar\">"
"Add/change/delete user accounts"
- "</B></FONT></TD></TR></TABLE>\n");
+ "</SPAN></TD></TR></TABLE>\n");
wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
"<TD>To edit an existing user account, select the user "
if (buf[0] == '1') {
while (serv_gets(buf), strcmp(buf, "000")) {
extract(username, buf, 0);
- wprintf("<OPTION>");
+ wprintf("<OPTION");
+ if (preselect != NULL)
+ if (!strcasecmp(username, preselect))
+ wprintf(" SELECTED");
+ wprintf(">");
escputs(username);
wprintf("\n");
}
/*
- * 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];
struct stuff_t *stuff = NULL;
struct stuff_t *ptr;
-
- /* Locate the user's config room, creating it if necessary */
- sprintf(roomname, "%010ld.My Citadel Config", usernum);
- serv_printf("GOTO %s", roomname);
- serv_gets(buf);
- if (buf[0] != '2') {
- serv_printf("CRE8 1|%s|5|", roomname);
- serv_gets(buf);
- serv_printf("GOTO %s", roomname);
- serv_gets(buf);
- if (buf[0] != '2') {
- sprintf(error_message,
- "<IMG SRC=\"static/error.gif\" VALIGN=CENTER>"
- "%s<BR><BR>\n", &buf[4]);
- select_user_to_edit(error_message);
- return;
- }
- }
-
TRYAGAIN:
/* Search for the user's vCard */
serv_puts("MSGS ALL");
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);
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;
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\" VALIGN=CENTER>"
- "Could not create/edit vCard<BR><BR>\n");
- select_user_to_edit(error_message);
+ "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
+ "Could not create/edit vCard"
+ "<BR><BR>\n"
+ );
+ select_user_to_edit(error_message, username);
return;
}
serv_gets(buf);
if (buf[0] != '2') {
sprintf(error_message,
- "<IMG SRC=\"static/error.gif\" VALIGN=CENTER>"
+ "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
"%s<BR><BR>\n", &buf[4]);
- select_user_to_edit(error_message);
+ select_user_to_edit(error_message, 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>"
+ wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><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("<FORM METHOD=\"POST\" ACTION=\"/edituser\">\n"
"<INPUT TYPE=\"hidden\" NAME=\"username\" VALUE=\"");
"<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n"
"<BR><BR></FORM>\n");
- wprintf("<A HREF=\"/dotgoto&room=%010ld.My%%20Citadel%%20Config\">",
- usernum);
- wprintf("Click here to access the configuration room for ");
- escputs(username);
- wprintf("</A><BR>\n"
- "(Contact information, Internet e-mail addresses, etc.)<BR>"
- "</CENTER>\n");
+ wprintf("</CENTER>\n");
wDumpContent(1);
serv_gets(buf);
if (buf[0] != '2') {
sprintf(message,
- "<IMG SRC=\"static/error.gif\" VALIGN=CENTER>"
+ "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
"%s<BR><BR>\n", &buf[4]);
}
else {
}
}
- select_user_to_edit(message);
+ select_user_to_edit(message, bstr("username"));
}
serv_gets(buf);
if (buf[0] == '2') {
- display_edituser(username);
+ sprintf(error_message, "<b>User has been created.</b>");
+ select_user_to_edit(error_message, username);
}
else {
sprintf(error_message,
- "<IMG SRC=\"static/error.gif\" VALIGN=CENTER>"
+ "<IMG SRC=\"static/error.gif\" ALIGN=CENTER>"
"%s<BR><BR>\n", &buf[4]);
- select_user_to_edit(error_message);
+ select_user_to_edit(error_message, NULL);
}
}