X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Faccount.inc.php;h=68b10a51a2a0ad63dfd70104cbabba93d12089ca;hb=7f3ac125d8b532fd0fc643e3504e5bd06be01fc4;hp=2ce9e09ef07ca21ef14728429d3d5e5552d9f295;hpb=bc6e8005beb0f4154ac96660f69dcd688c0c7893;p=platal.git diff --git a/include/validations/account.inc.php b/include/validations/account.inc.php index 2ce9e09..68b10a5 100644 --- a/include/validations/account.inc.php +++ b/include/validations/account.inc.php @@ -28,6 +28,7 @@ class AccountReq extends Validate public $hruid; public $email; public $group; + public $groups; public $rules = "Accepter si l'adresse email parait correcte, et pas absurde (ou si le demandeur est de confiance). Si le demandeur marque sa propre @@ -46,6 +47,12 @@ class AccountReq extends Validate FROM accounts WHERE hruid = {?}', $hruid); + $this->groups = implode(',', XDB::fetchColumn('SELECT g.nom + FROM groups AS g + INNER JOIN group_members AS m ON (g.id = m.asso_id) + WHERE m.uid = {?} + ORDER BY g.nom', + $this->uid)); } // }}} @@ -82,17 +89,9 @@ class AccountReq extends Validate public function commit() { $hash = rand_url_id(12); - XDB::execute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash) - VALUES ({?}, {?}, {?}, NOW(), {?})', - $this->uid, $this->hruid, $this->email, $hash); - - $mailer = new PlMailer('xnet/account.mail.tpl'); - $mailer->addTo($this->email); - $mailer->assign('hash', $hash); - $mailer->assign('hruid', $this->hruid); - $mailer->assign('group', $this->group); - $mailer->assign('user', $this->user); - $mailer->send(); + XDB::execute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name) + VALUES ({?}, {?}, {?}, NOW(), {?}, {?}, {?})', + $this->uid, $this->hruid, $this->email, $hash, $this->user->fullName(), $this->group); return true; } @@ -107,12 +106,13 @@ class AccountReq extends Validate WHERE type = \'account\' ORDER BY stamp'); - $is_pending = false; while (list($data) = $res->next()) { $request = Validate::unserialize($data); - $is_pending = ($is_pending || ($request->uid == $uid)); + if ($request->uid == $uid) { + return true; + } } - return $is_pending; + return false; } // }}}