From b77f048d13d975e7484cc5ad46c1ca8f154445fb Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 10 Mar 2008 17:55:22 +0000 Subject: [PATCH] Text mode user interface -- added UI for rename user --- citadel/citadel_ipc.c | 16 ++++++++++++++++ citadel/citadel_ipc.h | 1 + citadel/routines.c | 29 +++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 004f8ad36..a402ec129 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -367,6 +367,22 @@ int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret) } +/* RENU */ +int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret) +{ + register int ret; + char cmd[256]; + + if (!oldname) return -2; + if (!newname) return -2; + if (!cret) return -2; + + snprintf(cmd, sizeof cmd, "RENU %s|%s", oldname, newname); + ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret); + return ret; +} + + /* GOTO */ int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret) diff --git a/citadel/citadel_ipc.h b/citadel/citadel_ipc.h index 4254b6ef3..635d39f2e 100644 --- a/citadel/citadel_ipc.h +++ b/citadel/citadel_ipc.h @@ -299,6 +299,7 @@ time_t CtdlIPCServerTime(CtdlIPC *ipc, char *crert); int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret); int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret); +int CtdlIPCRenameUser(CtdlIPC *ipc, char *oldname, char *newname, char *cret); int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, int which, struct ExpirePolicy **policy, char *cret); int CtdlIPCSetMessageExpirationPolicy(CtdlIPC *ipc, int which, diff --git a/citadel/routines.c b/citadel/routines.c index de5b4cf71..c8e85a7f7 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -108,9 +108,13 @@ void edituser(CtdlIPC *ipc, int cmd) { char buf[SIZ]; char who[USERNAME_SIZE]; + char newname[USERNAME_SIZE]; struct ctdluser *user = NULL; int newnow = 0; int r; /* IPC response code */ + int change_name = 0; + + strcpy(newname, ""); newprompt("User name: ", who, 29); while ((r = CtdlIPCAideGetUserParameters(ipc, who, &user, buf)) / 100 != 2) { @@ -133,14 +137,31 @@ void edituser(CtdlIPC *ipc, int cmd) if (cmd == 25) { val_user(ipc, user->fullname, 0); /* Display registration */ + if (!newnow) { + change_name = 1; + while (change_name == 1) { + if (boolprompt("Change name", 0)) { + strprompt("New name", newname, USERNAME_SIZE-1); + r = CtdlIPCRenameUser(ipc, user->fullname, newname, buf); + if (r / 100 != 2) { + scr_printf("%s\n", buf); + } + else { + strcpy(user->fullname, newname); + change_name = 0; + } + } + else { + change_name = 0; + } + } + } + if (newnow || boolprompt("Change password", 0)) { strprompt("Password", user->password, -19); } user->axlevel = intprompt("Access level", user->axlevel, 0, 6); -/* user->flags = set_attr(ipc, user->flags, - "Permission to send Internet mail", - US_INTERNET, 0); */ if (boolprompt("Permission to send Internet mail", (user->flags & US_INTERNET))) user->flags |= US_INTERNET; else @@ -167,7 +188,7 @@ void edituser(CtdlIPC *ipc, int cmd) } user->axlevel = 0; } - + r = CtdlIPCAideSetUserParameters(ipc, user, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); -- 2.39.2