2 /***************************************************************************
3 * Copyright (C) 2003-2011 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
23 class BulkAccountsReq
extends Validate
31 public $rules = "Accepter si les adresses email paraissent correctes, et pas
32 absurdes et si le demandeur est de confiance.";
36 public function __construct(User
$user, array $uids, $group)
38 parent
::__construct($user, false
, 'bulkaccounts');
39 $this->group
= $group;
40 $this->users
= XDB
::fetchAllAssoc('SELECT uid, hruid, email
47 // {{{ function formu()
49 public function formu()
51 return 'include/form.valid.bulk_accounts.tpl';
55 // {{{ function _mail_subj
57 protected function _mail_subj()
59 return "[Polytechnique.org] Création de comptes Polytechnique.net";
63 // {{{ function _mail_body
65 protected function _mail_body($isok)
68 return " Un email vient d'être envoyé aux personnes concernées pour qu'elles puissent activer leur compte sur Polytechnique.net.";
70 return " Nous n'avons pas jugé bon d'activer les comptes Polytechnique.net demandés.";
75 // {{{ function commit()
77 public function commit()
81 foreach ($this->users
as $user) {
82 $values[] = XDB
::format('({?}, {?}, {?}, NOW(), {?}, {?}, {?})',
83 $user['uid'], $user['hruid'], $user['email'], rand_url_id(12), $this->user
->fullName(), $this->group
);
85 if ($i == $this->limit
) {
86 XDB
::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
87 VALUES ' . implode(', ', $values));
94 XDB
::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
95 VALUES ' . implode(', ', $values));
101 // {{{ function isPending()
103 static public function isPending($uid)
105 $res = XDB
::iterRow('SELECT data
107 WHERE type = \'bulk_accounts\'
110 while (list($data) = $res->next()) {
111 $request = Validate
::unserialize($data);
112 foreach ($request->users
as $user) {
113 if ($user['uid'] == $uid) {
124 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: