$user = User::get($hruid);
}
- // Check if the user is has a pending or active account.
- $active = XDB::fetchOneCell('SELECT state = \'active\'
- FROM accounts
- WHERE uid = {?}',
- $user->id());
- $pending = XDB::fetchOneCell('SELECT uid
- FROM register_pending_xnet
- WHERE uid = {?}',
- $user->id());
- $requested = AccountReq::isPending($user->id());
-
- if (!($active || $pending || $requested)) {
- $suggest_account_activation = true;
- }
+ $suggest_account_activation = $this->suggest($user);
}
if ($user) {
}
}
+ // Check if the user has a pending or active account, and thus if we should her account's activation.
+ private function suggest(PlUser $user)
+ {
+ $active = XDB::fetchOneCell('SELECT state = \'active\'
+ FROM accounts
+ WHERE uid = {?}',
+ $user->id());
+ $pending = XDB::fetchOneCell('SELECT uid
+ FROM register_pending_xnet
+ WHERE uid = {?}',
+ $user->id());
+ $requested = AccountReq::isPending($user->id());
+
+ if ($active || $pending || $requested) {
+ return false;
+ }
+ return true;
+ }
+
function handler_admin_member_suggest($page, $hruid, $email)
{
$page->changeTpl('xnetgrp/membres-suggest.tpl');
} else {
$page->trigWarning('Tu as été désinscrit du groupe, mais des erreurs se sont produites lors des désinscriptions des alias et des listes de diffusion.');
}
- if ($user->type == 'xnet' && $hasSingleGroup && Post::has('accountDeletion')) {
- XDB::execute('DELETE FROM acounts
- WHERE uid = {?}',
- $user->id());
- $page->trigSuccess('Ton compte a bien été supprimé.');
+
+ // If user is of type xnet account and this was her last group, disable the account.
+ if ($user->type == 'xnet' && $hasSingleGroup) {
+ $user->clear(true);
}
$page->assign('is_member', is_member(true));
}
$page->trigWarning("{$user->fullName()} a été désinscrit du groupe, mais des erreurs subsistent !");
}
- // Either deletes or notifies site administrators if it was the last group
- // of a xnet account.
+ // If user is of type xnet account and this was her last group, disable the account.
if ($user->type == 'xnet' && $hasSingleGroup) {
- if ($user->state == 'pending') {
- // If the user has never logged in the site, we delete her account.
- XDB::execute('DELETE FROM acounts
- WHERE uid = {?}',
- $user->id());
- } else {
- // It the user has already logged in the site, we notify site
- // administrators that there is a new xnet account without any
- // group.
- $mailer = new PlMailer('xnetgrp/unsubscription.mail.tpl');
- $mailer->assign('user', $user);
- $mailer->assign('groupId', $globals->asso('id'));
- $mailer->assign('groupName', $globals->asso('nom'));
- $mailer->send();
- }
+ $user->clear(true);
}
}
- private function changeLogin(PlPage &$page, PlUser &$user, $login)
+ private function changeLogin(PlPage $page, PlUser $user, $login)
{
// Search the user's uid.
$xuser = User::getSilent($login);
// Update user info
$email_changed = (!$user->profile() && strtolower($user->forlifeEmail()) != strtolower(Post::v('email')));
$from_email = $user->forlifeEmail();
- if ($user->type == 'virtual' || $user->type == 'xnet') {
+ if ($user->type == 'virtual' || ($user->type == 'xnet' && !$user->perms)) {
XDB::query('UPDATE accounts
SET full_name = {?}, directory_name = {?}, display_name = {?},
sex = {?}, email = {?}, type = {?}
Post::t('full_name'), Post::t('directory_name'), Post::t('display_name'),
(Post::t('sex') == 'male') ? 'male' : 'female', Post::t('email'),
(Post::t('type') == 'xnet') ? 'xnet' : 'virtual', $user->id());
- // If user is of type xnet and new password is given.
- if (!Post::blank('pwhash') && Post::t('type') == 'xnet') {
- XDB::query('UPDATE accounts
- SET password = {?}
- WHERE uid = {?}',
- Post::t('pwhash'), $user->id());
- }
} else if (!$user->perms) {
XDB::query('UPDATE accounts
SET email = {?}
$page->trigSuccess('Données de l\'utilisateur mises à jour.');
}
+ if (($user->type == 'xnet' && !$user->perms) && Post::b('suggest')) {
+ $request = new AccountReq(S::user(), $user->hruid, Post::t('email'), $globals->asso('nom'));
+ $request->submit();
+ $page->trigSuccess('Le compte va bientôt être activé.');
+ }
+
// Update group params for user
$perms = Post::v('group_perms');
$comm = Post::t('comm');
$res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\'');
$positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']);
- $page->addJsLink('password.js');
- $page->assign('onlyGroup', ($user->groupCount() == 1));
$page->assign('user', $user);
+ $page->assign('suggest', $this->suggest($user));
$page->assign('listes', $mmlist->get_lists($user->forlifeEmail()));
$page->assign('alias', $user->emailGroupAliases($globals->asso('mail_domain')));
$page->assign('positions', explode(',', $positions));