X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetgrp.php;h=b004fde7f367bbe287c0ff8deaeedae493639310;hb=c9910f7559bb0cfd787b4fb73f864000f28e38cc;hp=54e7938f9c10b60b6cbab6a64ebdd49593e0775e;hpb=58328dc0a9ef01044bb0ad81c6d66c1b841616be;p=platal.git diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 54e7938..b004fde 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -729,20 +729,7 @@ class XnetGrpModule extends PLModule $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) { @@ -758,6 +745,25 @@ class XnetGrpModule extends PLModule } } + // 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'); @@ -888,11 +894,10 @@ class XnetGrpModule extends PLModule } 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)); } @@ -928,28 +933,13 @@ class XnetGrpModule extends PLModule $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); @@ -1006,7 +996,7 @@ class XnetGrpModule extends PLModule // 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 = {?} @@ -1024,6 +1014,12 @@ class XnetGrpModule extends PLModule $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'); @@ -1100,6 +1096,7 @@ class XnetGrpModule extends PLModule $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']); $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));