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
32 public $rules = "Accepter si les adresses email paraissent correctes, et pas
33 absurdes et si le demandeur est de confiance.";
37 public function __construct(User
$user, array $uids, $group, $dim)
39 parent
::__construct($user, false
, 'bulkaccounts');
40 $this->group
= $group;
42 $this->users
= XDB
::fetchAllAssoc('SELECT uid, hruid, email
49 // {{{ function formu()
51 public function formu()
53 return 'include/form.valid.bulk_accounts.tpl';
57 // {{{ function _mail_subj
59 protected function _mail_subj()
61 return "[Polytechnique.org] Création de comptes Polytechnique.net";
65 // {{{ function _mail_body
67 protected function _mail_body($isok)
70 return " Un email vient d'être envoyé aux personnes concernées pour qu'elles puissent activer leur compte sur Polytechnique.net.";
72 return " Nous n'avons pas jugé bon d'activer les comptes Polytechnique.net demandés.";
77 // {{{ function commit()
79 public function commit()
83 foreach ($this->users
as $user) {
84 $values[] = XDB
::format('({?}, {?}, {?}, NOW(), {?}, {?}, {?})',
85 $user['uid'], $user['hruid'], $user['email'], rand_url_id(12), $this->user
->fullName(), $this->group
);
87 if ($i == $this->limit
) {
88 XDB
::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
89 VALUES ' . implode(', ', $values));
96 XDB
::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
97 VALUES ' . implode(', ', $values));
103 // {{{ function isPending()
105 static public function isPending($uid)
107 $res = XDB
::iterRow('SELECT data
109 WHERE type = \'bulk_accounts\'
112 while (list($data) = $res->next()) {
113 $request = Validate
::unserialize($data);
114 foreach ($request->users
as $user) {
115 if ($user['uid'] == $uid) {
126 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: