--- /dev/null
+<?=("head")>
+<?=("important_msg")>
+<?ICONBAR>
+<div id="banner">
+ <h1><?_("Edit user account: ")><?USERLIST:USERNAME("X")></h1>
+</div>
+<div id="content" class="service">
+<div class="fix_scrollbar_bug">
+<table class="useredit_background"><tr><td>
+<form method="POST" action="edituser">
+<input type="hidden" name="username" value="<?USERLIST:USERNAME("X")>">
+<input type="hidden" name="is_new" value="<?BSTR("is_new")>">
+<input type="hidden" name="usernum" value="<?USERLIST:UID>">
+<input type="hidden" name="nonce" value="<?NONCE>">
+<input type="hidden" name="flags" value="<?USERLIST:FLAGS>">
+<center><table>
+<tr><td><?_("User name:")></td><td><input type="text" name="newname" value="<?USERLIST:USERNAME("X")>" maxlength="63"></td></tr>
+<tr><td><?_("Password")></td><td><input type="password" name="password" value="<?USERLIST:PASSWD("X")>" maxlength="20"></td></tr>
+<tr><td><?_("Permission to send Internet mail")></td><td><input type="checkbox" name="inetmail" value="yes" <?%("COND:USERLIST:FLAG:USE_INTERNET", 1, 1, 1, "checked", "")>></td></tr>
+<tr><td><?_("Number of logins")></td><td><input type="text" name="timescalled" value="<?USERLIST:NLOGONS>" maxlength="6"></td></tr>
+<tr><td><?_("Messages submitted")></td><td><input type="text" name="msgsposted" value="<?USERLIST:NPOSTS>" maxlength="6"></td></tr>
+<tr><td><?_("Access level")></td><td><select name="axlevel">
+ <option <?%("COND:USERACCESS", 1, 1, 0, 'selected="selected"', "")> value="0">0 - <?_("Deleted")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 1, 'selected="selected"', "")> value="1">1 - <?_("New User")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 2, 'selected="selected"', "")> value="2">2 - <?_("Problem User")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 3, 'selected="selected"', "")> value="3">3 - <?_("Local User")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 4, 'selected="selected"', "")> value="4">4 - <?_("Network User")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 5, 'selected="selected"', "")> value="5">5 - <?_("Preferred User")></option>
+ <option <?%("COND:USERACCESS", 1, 1, 6, 'selected="selected"', "")> value="6">6 - <?_("Aide")></option>
+</select></td></tr>
+<tr><td><?_("User ID number")></td><td><input type="text" name="usernum" value="<?USERLIST:UID>" maxlength="7"></td></tr>
+<tr><td><?_("Date and time of last login")></td><td><select name="lastcall">
+ <option selected value="<?USERLIST:LASTLOGON:NO>"><?USERLIST:LASTLOGON:STR></option>
+ <option value="<?TIME:NOW:NO>"><?TIME:NOW:STR></option>
+</select></td></tr>
+
+<tr><td><?_("Auto-purge after this many days")></td><td><input type="text" name="purgedays" value="<?USERLIST:DAYSTILLPURGE>" maxlength="5"></td></tr>
+</table>
+<input type="submit" name="ok_button" value="<?_("Save changes")>"> <input type="submit" name="cancel" value="<?_("Cancel")>"><br /><br /></form>
+</center>
+</td></tr></table></div>
+<?=("trailing")>
ChrPtr(pTmpl->FileName),
Token->Line,
ChrPtr(Token->FlatToken));
+ return 0;
}
Cond = (ConditionalStruct *) vConditional;
* \brief Display a variable-substituted template
* \param templatename template file to load
*/
-void DoTemplate(const char *templatename, long len, void *Context, StrBuf *Target, int ContextType)
+void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType)
{
HashList *Static;
HashList *StaticLocal;
It->DoSubTemplate(SubBuf, vContext, Tokens);
DoTemplate(Tokens->Params[1]->Start,
Tokens->Params[1]->len,
- vContext, SubBuf,
+ SubBuf, vContext,
It->ContextType);
StrBufAppendBuf(Target, SubBuf, 0);
StrBuf *Headline = NewStrBuf();
DoTemplate(Tokens->Params[1]->Start,
Tokens->Params[1]->len,
- Context,
Headline,
+ Context,
ContextType);
SVPutBuf("BOXTITLE", Headline, 0);
}
- DoTemplate(HKEY("beginbox"), Context, Target, ContextType);
+ DoTemplate(HKEY("beginbox"), Target, Context, ContextType);
DoTemplate(Tokens->Params[0]->Start,
Tokens->Params[0]->len,
- Context,
Target,
+ Context,
ContextType);
- DoTemplate(HKEY("endbox"), Context, Target, ContextType);
+ DoTemplate(HKEY("endbox"), Target, Context, ContextType);
}
void tmpl_do_tabbed(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
if (Tokens->Params[i * 2]->len > 0) {
DoTemplate(Tokens->Params[i * 2]->Start,
Tokens->Params[i * 2]->len,
- Context,
TabNames[i],
+ Context,
ContextType);
}
else {
DoTemplate(Tokens->Params[i * 2 + 1]->Start,
Tokens->Params[i * 2 + 1]->len,
- Context,
Target,
+ Context,
ContextType);
StrEndTab(Target, i, nTabs);
}
typedef struct _UserListEntry {
- StrBuf *UserName;
- int AccessLevel;
int UID;
- StrBuf *LastLogon;
- time_t LastLogonT;
+ int AccessLevel;
int nLogons;
int nPosts;
+
+ StrBuf *UserName;
StrBuf *Passvoid;
+ StrBuf *LastLogon;
+ time_t LastLogonT;
+ /* Just available for Single users to view: */
+ unsigned int Flags;
+ int DaysTillPurge;
} UserListEntry;
+
+UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser)
+{
+ UserListEntry *ul;
+
+ if (StrLength(SerializedUser) < 8)
+ return NULL;
+
+ ul = (UserListEntry*) malloc(sizeof(UserListEntry));
+ ul->UserName = NewStrBuf();
+ ul->LastLogon = NewStrBuf();
+ ul->Passvoid = NewStrBuf();
+
+ StrBufExtract_token(ul->UserName, SerializedUser, 0, '|');
+ StrBufExtract_token(ul->Passvoid, SerializedUser, 1, '|');
+ ul->Flags = (unsigned int)StrBufExtract_long(SerializedUser, 2, '|');
+ ul->nLogons = StrBufExtract_int(SerializedUser, 3, '|');
+ ul->nPosts = StrBufExtract_int(SerializedUser, 4, '|');
+ ul->AccessLevel = StrBufExtract_int(SerializedUser, 5, '|');
+ ul->UID = StrBufExtract_int(SerializedUser, 6, '|');
+ StrBufExtract_token(ul->LastLogon, SerializedUser, 7, '|');
+ /// TODO: ul->LastLogon -> ulLastLogonT
+ ul->DaysTillPurge = StrBufExtract_int(SerializedUser, 8, '|');
+ return ul;
+}
+
void DeleteUserListEntry(void *vUserList)
{
UserListEntry *ul = (UserListEntry*) vUserList;
ul->nLogons = StrBufExtract_int(SerializedUserList, 4, '|');
ul->nPosts = StrBufExtract_int(SerializedUserList, 5, '|');
StrBufExtract_token(ul->Passvoid, SerializedUserList, 6, '|');
-
+ ul->Flags = 0;
+ ul->DaysTillPurge = -1;
return ul;
}
StrBufAppendPrintf(Target, "%d", ul->UID, 0);
}
-void tmplput_USERLIST_LastLogon(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+void tmplput_USERLIST_LastLogonNo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
StrBufAppendBuf(Target, ul->LastLogon, 0);
}
+void tmplput_USERLIST_LastLogonStr(StrBuf *Target, int nArgs, WCTemplateToken *Token, 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)
{
StrBufAppendPrintf(Target, "%d", ul->nPosts, 0);
}
+void tmplput_USERLIST_Flags(StrBuf *Target, int nArgs, WCTemplateToken *Token, 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)
+{
+ UserListEntry *ul = (UserListEntry*) Context;
+
+ StrBufAppendPrintf(Target, "%d", ul->DaysTillPurge, 0);
+}
+
int ConditionalUser(WCTemplateToken *Tokens, void *Context, int ContextType)
{
UserListEntry *ul = (UserListEntry*) Context;
else
return 0;
}
-
+
+int ConditionalFlagINetEmail(WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+ UserListEntry *ul = (UserListEntry*) Context;
+ return (ul->Flags & US_INTERNET) != 0;
+}
+
+int ConditionalUserAccess(WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+ UserListEntry *ul = (UserListEntry*) Context;
+
+ if (Tokens->Params[3]->Type == TYPE_LONG)
+ return (Tokens->Params[3]->lvalue == ul->AccessLevel);
+ else
+ return 0;
+}
+
/**
* \brief Locate the message number of a user's vCard in the current room
* \param username the plaintext name of the user
}
+void display_edituser(char *supplied_username, int is_new) {
+ UserListEntry* UL;
+ StrBuf *Buf;
+ char error_message[1024];
+ char MajorStatus;
+ char username[256];
+
+ if (supplied_username != NULL) {
+ safestrncpy(username, supplied_username, sizeof username);
+ }
+ else {
+ safestrncpy(username, bstr("username"), sizeof username);
+ }
+
+ Buf = NewStrBuf();
+ serv_printf("AGUP %s", username);
+ StrBuf_ServGetln(Buf);
+ MajorStatus = ChrPtr(Buf)[0];
+ StrBufCutLeft(Buf, 4);
+ if (MajorStatus != '2') {
+ ///TODO ImportantMessage
+ sprintf(error_message,
+ "<img src=\"static/error.gif\" align=center>"
+ "%s<br /><br />\n", ChrPtr(Buf));
+ select_user_to_edit(error_message, username);
+ FreeStrBuf(&Buf);
+ return;
+ }
+ else {
+ UL = NewUserListOneEntry(Buf);
+ output_headers(1, 0, 0, 0, 1, 0);
+ DoTemplate(HKEY("userlist_detailview"), NULL, (void*) UL, CTX_USERLIST);
+ end_burst();
+
+ }
+ 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.
* 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];
wDumpContent(1);
}
-
+*/
/**
* \brief do the backend operation of the user edit on the server
WebcitAddUrlHandler(HKEY("edituser"), edituser, 0);
WebcitAddUrlHandler(HKEY("create_user"), create_user, 0);
- RegisterNamespace("USERLIST:USERNAME", 0, 1, tmplput_USERLIST_UserName, CTX_USERLIST);
- RegisterNamespace("USERLIST:ACCLVLNO", 0, 0, tmplput_USERLIST_AccessLevelNo, CTX_USERLIST);
- RegisterNamespace("USERLIST:ACCLVLSTR", 0, 0, tmplput_USERLIST_AccessLevelStr, CTX_USERLIST);
- RegisterNamespace("USERLIST:UID", 0, 0, tmplput_USERLIST_UID, CTX_USERLIST);
- RegisterNamespace("USERLIST:LASTLOGON", 0, 0, tmplput_USERLIST_LastLogon, CTX_USERLIST);
- RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, CTX_USERLIST);
- RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, CTX_USERLIST);
+ RegisterNamespace("USERLIST:USERNAME", 0, 1, tmplput_USERLIST_UserName, CTX_USERLIST);
+ RegisterNamespace("USERLIST:ACCLVLNO", 0, 0, tmplput_USERLIST_AccessLevelNo, CTX_USERLIST);
+ RegisterNamespace("USERLIST:ACCLVLSTR", 0, 0, tmplput_USERLIST_AccessLevelStr, CTX_USERLIST);
+ RegisterNamespace("USERLIST:UID", 0, 0, tmplput_USERLIST_UID, CTX_USERLIST);
+ RegisterNamespace("USERLIST:LASTLOGON:STR", 0, 0, tmplput_USERLIST_LastLogonStr, CTX_USERLIST);
+ RegisterNamespace("USERLIST:LASTLOGON:NO", 0, 0, tmplput_USERLIST_LastLogonNo, CTX_USERLIST);
+ RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, CTX_USERLIST);
+ RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, CTX_USERLIST);
+
+ RegisterNamespace("USERLIST:FLAGS", 0, 0, tmplput_USERLIST_Flags, CTX_USERLIST);
+ RegisterNamespace("USERLIST:DAYSTILLPURGE", 0, 0, tmplput_USERLIST_DaysTillPurge, CTX_USERLIST);
+
+ RegisterConditional(HKEY("COND:USERNAME"), 0, ConditionalUser, CTX_USERLIST);
+ RegisterConditional(HKEY("COND:USERACCESS"), 0, ConditionalUserAccess, CTX_USERLIST);
+ RegisterConditional(HKEY("COND:USERLIST:FLAG:USE_INTERNET"), 0, ConditionalFlagINetEmail, CTX_USERLIST);
RegisterConditional(HKEY("COND:USERNAME"), 0, ConditionalUser, CTX_USERLIST);
RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST);