X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fuseredit.c;h=ca9bf2045eb1102227755fbed07e82c6b582a6a5;hb=47bcaaabae789a2f20de958b84714ff2e23dc5bb;hp=bdd457dc24982236e8c66f29380c41118b7d6162;hpb=7d78c67c340d631d8a884b75837735e7dc4bd55c;p=citadel.git
diff --git a/webcit/useredit.c b/webcit/useredit.c
index bdd457dc2..ca9bf2045 100644
--- a/webcit/useredit.c
+++ b/webcit/useredit.c
@@ -1,103 +1,21 @@
/*
* $Id$
*/
-/**
- * \defgroup AdminTasks Administrative screen to add/change/delete user accounts
- * \ingroup CitadelConfig
- *
- */
-/*@{*/
#include "webcit.h"
#include "webserver.h"
/**
- * \brief show a list of available users to edit them
- * \param message the header message???
- * \param preselect which user should be selected in the browser
+ * show a list of available users to edit them
+ * message the header message???
+ * preselect which user should be selected in the browser
*/
void select_user_to_edit(char *message, char *preselect)
-{/*
- char buf[SIZ];
- char username[SIZ];
- */
+{
output_headers(1, 0, 0, 0, 1, 0);
do_template("edituser_select", NULL);
end_burst();
-
-/*
-
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n");
-
- if (message != NULL) wprintf(message);
-
- wprintf("
\n");
-
- svput("BOXTITLE", WCS_STRING, _("Add users"));
- do_template("beginbox", NULL);
-
- wprintf(_("To create a new user account, enter the desired "
- "user name in the box below and click 'Create'."));
- wprintf("
");
-
- wprintf("\n", _("Create"));
-
- do_template("endbox", NULL);
-
- wprintf(" | ");
-
- svput("BOXTITLE", WCS_STRING, _("Edit or Delete users"));
- do_template("beginbox", NULL);
-
- wprintf(_("To edit an existing user account, select the user "
- "name from the list and click 'Edit'."));
- wprintf("
");
-
- wprintf(""
- "\n");
- do_template("endbox", NULL);
-
- wprintf(" |
\n");
-
- wDumpContent(1);
-*/
}
@@ -279,7 +197,7 @@ int ComparenPostsRev(const void *vUser1, const void *vUser2)
}
-HashList *iterate_load_userlist(WCTemplateToken *Token)
+HashList *iterate_load_userlist(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
HashList *Hash;
char buf[SIZ];
@@ -350,68 +268,67 @@ HashList *iterate_load_userlist(WCTemplateToken *Token)
}
-void tmplput_USERLIST_UserName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_UserName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
-/// TODO: X
- StrBufAppendBuf(Target, ul->UserName, 0);
+ StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, ul->UserName, 0);
}
-void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target, "%d", ul->AccessLevel, 0);
}
-void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendBufPlain(Target, _(axdefs[ul->AccessLevel]), -1, 0);
}
-void tmplput_USERLIST_UID(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_UID(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target, "%d", ul->UID, 0);
}
-void tmplput_USERLIST_LastLogonNo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_LastLogonNo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target,"%ld", ul->LastLogonT, 0);
}
-void tmplput_USERLIST_LastLogonStr(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_LastLogonStr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrEscAppend(Target, NULL, asctime(localtime(&ul->LastLogonT)), 0, 0);
}
-void tmplput_USERLIST_nLogons(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_nLogons(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target, "%d", ul->nLogons, 0);
}
-void tmplput_USERLIST_nPosts(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_nPosts(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target, "%d", ul->nPosts, 0);
}
-void tmplput_USERLIST_Flags(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_Flags(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendPrintf(Target, "%d", ul->Flags, 0);
}
-void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
@@ -448,9 +365,9 @@ int ConditionalUserAccess(WCTemplateToken *Tokens, void *Context, int ContextTyp
}
/**
- * \brief Locate the message number of a user's vCard in the current room
- * \param username the plaintext name of the user
- * \param usernum the number of the user on the citadel server
+ * Locate the message number of a user's vCard in the current room
+ * username the plaintext name of the user
+ * usernum the number of the user on the citadel server
* \return the message id of his vcard
*/
long locate_user_vcard(char *username, long usernum) {
@@ -502,7 +419,7 @@ TRYAGAIN:
}
/** If there's no vcard, create one */
- if (vcard_msgnum < 0) if (already_tried_creating_one == 0) {
+ if ((vcard_msgnum < 0) && (already_tried_creating_one == 0)) {
already_tried_creating_one = 1;
serv_puts("ENT0 1|||4");
serv_getln(buf, sizeof buf);
@@ -521,9 +438,9 @@ TRYAGAIN:
/**
- * \brief Display the form for editing a user's address book entry
- * \param username the name of the user
- * \param usernum the citadel-uid of the user
+ * Display the form for editing a user's address book entry
+ * username the name of the user
+ * usernum the citadel-uid of the user
*/
void display_edit_address_book_entry(char *username, long usernum) {
char roomname[SIZ];
@@ -594,201 +511,25 @@ void display_edituser(char *supplied_username, int is_new) {
}
else {
UL = NewUserListOneEntry(Buf);
- output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("userlist_detailview"), NULL, (void*) UL, CTX_USERLIST);
- end_burst();
+ if (havebstr("edit_abe_button")) {
+ display_edit_address_book_entry(username, UL->UID);
+ }
+ else if (havebstr("delete_button")) {
+ delete_user(username);
+ }
+ else {
+ output_headers(1, 0, 0, 0, 1, 0);
+ DoTemplate(HKEY("userlist_detailview"), NULL, (void*) UL, CTX_USERLIST);
+ end_burst();
+ }
+ DeleteUserListEntry(UL);
}
FreeStrBuf(&Buf);
}
-
-
-/* *
- * \brief 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.
- * \param supplied_username user to look up or NULL if to search in the environment
- * \param is_new should we create the user?
- * /
-void display_edituser(char *supplied_username, int is_new) {
- char buf[1024];
- char error_message[1024];
- time_t now;
-
- char username[256];
- char password[256];
- unsigned int flags;
- int timescalled;
- int msgsposted;
- int axlevel;
- long usernum;
- time_t lastcall;
- int purgedays;
- int i;
-
- if (supplied_username != NULL) {
- safestrncpy(username, supplied_username, sizeof username);
- }
- else {
- safestrncpy(username, bstr("username"), sizeof username);
- }
-
- serv_printf("AGUP %s", username);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- sprintf(error_message,
- "
"
- "%s
\n", &buf[4]);
- select_user_to_edit(error_message, username);
- return;
- }
-
- extract_token(username, &buf[4], 0, '|', sizeof username);
- extract_token(password, &buf[4], 1, '|', sizeof password);
- flags = extract_int(&buf[4], 2);
- timescalled = extract_int(&buf[4], 3);
- msgsposted = extract_int(&buf[4], 4);
- axlevel = extract_int(&buf[4], 5);
- usernum = extract_long(&buf[4], 6);
- lastcall = extract_long(&buf[4], 7);
- purgedays = extract_long(&buf[4], 8);
-
- if (havebstr("edit_abe_button")) {
- display_edit_address_book_entry(username, usernum);
- return;
- }
-
- if (havebstr("delete_button")) {
- delete_user(username);
- return;
- }
-
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n");
- wprintf("
");
- wprintf(_("Edit user account: "));
- escputs(username);
- wprintf("
");
- wprintf("");
-
- wprintf("
\n");
-
- wprintf("
\n");
- wDumpContent(1);
-
-}
-*/
-
/**
- * \brief do the backend operation of the user edit on the server
+ * do the backend operation of the user edit on the server
*/
void edituser(void) {
char message[SIZ];
@@ -859,8 +600,8 @@ void edituser(void) {
}
/*
- * \brief burge a user
- * \param username the name of the user to remove
+ * burge a user
+ * username the name of the user to remove
*/
void delete_user(char *username) {
char buf[SIZ];
@@ -882,7 +623,7 @@ void delete_user(char *username) {
/**
- * \brief create a new user
+ * create a new user
* take the web environment username and create it on the citadel server
*/
void create_user(void) {
@@ -947,6 +688,5 @@ InitModule_USEREDIT
RegisterConditional(HKEY("COND:USERACCESS"), 0, ConditionalUserAccess, CTX_USERLIST);
RegisterConditional(HKEY("COND:USERLIST:FLAG:USE_INTERNET"), 0, ConditionalFlagINetEmail, CTX_USERLIST);
- RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST);
+ RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST, CTX_NONE);
}
-/*@}*/