From: Florent Bruneau Date: Mon, 4 Oct 2010 15:41:32 +0000 (+0200) Subject: Allow edition of the email of the user from the admin page. X-Git-Tag: xorg/1.0.1~101 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=a8a11a70d5fb7a251c74426400f757486c4c7159;p=platal.git Allow edition of the email of the user from the admin page. This is possible only if the user email is not managed by the site (so for user without the 'mail' permission). Changing the email update the subscription in mailman. Signed-off-by: Florent Bruneau --- diff --git a/bin/lists.rpc.py b/bin/lists.rpc.py index 8441ed4..5ce3c68 100755 --- a/bin/lists.rpc.py +++ b/bin/lists.rpc.py @@ -849,6 +849,27 @@ def get_all_user_lists(userdesc, perms, vhost, email): continue return result +def change_user_email(userdesc, perms, vhost, from_email, to_email): + """ Change the email of a user + @root + """ + from_email = from_email.lower() + to_email = to_email.lower() + for list in Utils.list_names(): + try: + mlist = MailList.MailList(list, lock=0) + except: + continue + try: + mlist.Lock() + mlist.ApprovedChangeMemberAddress(from_email, to_email, 0) + mlist.Save() + mlist.Unlock() + except: + mlist.Unlock() + return 1 + + def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, inslevel, owners, members): """ Create a new list. @root @@ -1041,6 +1062,7 @@ server.register_function(check_options) # create + del server.register_function(get_all_lists) server.register_function(get_all_user_lists) +server.register_function(change_user_email) server.register_function(create_list) server.register_function(delete_list) # utilisateurs.php diff --git a/modules/admin.php b/modules/admin.php index da4b804..5c3a1ac 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -385,6 +385,7 @@ class AdminModule extends PLModule pl_redirect('admin/accounts'); } + $listClient = new MMList(S::user()); $login = $user->login(); $registered = ($user->state != 'pending'); @@ -488,6 +489,10 @@ class AdminModule extends PLModule if (Post::t('comment') != $user->comment) { $to_update['comment'] = Post::blank('comment') ? null : Post::t('comment'); } + if (!$user->checkPerms(User::PERM_MAIL) && Post::t('email') != $user->forlifeEmail()) { + $to_update['email'] = Post::t('email'); + $listClient->change_user_email($user->forlifeEmail(), Post::t('email')); + } } if (!empty($to_update)) { $res = XDB::query('SELECT * @@ -504,9 +509,9 @@ class AdminModule extends PLModule $diff[$k] = array($oldValues[$k], trim($value, "'")); unset($oldValues[$k]); } - XDB::execute('UPDATE accounts - SET ' . implode(', ', $set) . ' - WHERE uid = ' . XDB::format('{?}', $user->id())); + XDB::rawExecute('UPDATE accounts + SET ' . implode(', ', $set) . ' + WHERE uid = ' . XDB::format('{?}', $user->id())); $page->trigSuccess('Données du compte mise à jour avec succès'); $user = User::getWithUID($user->id()); @@ -672,8 +677,7 @@ class AdminModule extends PLModule $page->assign('host', $host); // Display mailing lists - $list = new MMList(S::user()); - $page->assign('mlists', $list->get_all_user_lists($user->forlifeEmail())); + $page->assign('mlists', $listClient->get_all_user_lists($user->forlifeEmail())); // Display active aliases. $page->assign('virtuals', $user->emailAliases()); diff --git a/templates/admin/user.tpl b/templates/admin/user.tpl index ece9ad6..3a20e9d 100644 --- a/templates/admin/user.tpl +++ b/templates/admin/user.tpl @@ -160,6 +160,10 @@ $(document).ready(function() { + + Email + {if $user->checkPerms('mail')}{$user->forlifeEmail()}{else}{/if} + Mot de passe