================================================================================
VERSION 1.1.1 XX XX XXXX
+New:
+
+ * XnetGrp:
+ - Enables creation of multiple Xnet accounts for groups -JAC
+
Bug/Wish:
* Auth:
--- /dev/null
+#!/usr/bin/php5 -q
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2011 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+require_once 'connect.db.inc.php';
+require_once 'plmailer.php';
+$limit = 60;
+
+$users = XDB::fetchAllAssoc('SELECT a.uid, a.hruid, r.hash, r.group_name, r.sender_name, r.email
+ FROM register_pending_xnet AS r
+ INNER JOIN accounts AS a ON (r.uid = a.uid)
+ WHERE a.state = \'disabled\'
+ ORDER BY r.date, a.uid');
+
+$mailer = new PlMailer('xnet/account.mail.tpl');
+
+$i = 0;
+foreach ($users as $user) {
+ $mailer->setTo($user['email']);
+ $mailer->assign('hash', $user['hash']);
+ $mailer->assign('hruid', $user['hruid']);
+ $mailer->assign('group', $user['group_name']);
+ $mailer->assign('sender_name', $user['sender_name']);
+ $mailer->send();
+
+ XDB::execute('UPDATE accounts
+ SET state = \'pending\'
+ WHERE uid = {?}',
+ $user['uid']);
+
+ if ($i == $limit) {
+ $i = 0;
+ sleep(60);
+ } else {
+ ++$i;
+ }
+}
+
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
# Clean-up of our logging tables
45 0 1 * * web cd $WD; ./compliance.php | mail -e -s "Logging compliance" br@staff.m4x.org
+# xnet accounts creation
+0 * * * * web cd $WD; ./cron_xnet_accounts.php
+
# vim:set noet syntax=crontab ts=8 sw=8 sts=8 enc=utf-8:
public function commit()
{
$hash = rand_url_id(12);
- XDB::execute('UPDATE accounts
- SET state = \'pending\'
- WHERE uid = {?}',
- $this->uid);
- 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->setTo($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;
}
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2011 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+
+class BulkAccountsReq extends Validate
+{
+ // {{{ properties
+
+ private $limit = 50;
+ public $users;
+ public $group;
+
+ public $rules = "Accepter si les adresses email paraissent correctes, et pas
+ absurdes et si le demandeur est de confiance.";
+ // }}}
+ // {{{ constructor
+
+ public function __construct(User $user, array $uids, $group)
+ {
+ parent::__construct($user, false, 'bulkaccounts');
+ $this->group = $group;
+ $this->users = XDB::fetchAllAssoc('SELECT uid, hruid, email
+ FROM accounts
+ WHERE uid IN {?}',
+ $uids);
+ }
+
+ // }}}
+ // {{{ function formu()
+
+ public function formu()
+ {
+ return 'include/form.valid.bulk_accounts.tpl';
+ }
+
+ // }}}
+ // {{{ function _mail_subj
+
+ protected function _mail_subj()
+ {
+ return "[Polytechnique.org] Création de comptes Polytechnique.net";
+ }
+
+ // }}}
+ // {{{ function _mail_body
+
+ protected function _mail_body($isok)
+ {
+ if ($isok) {
+ return " Un email vient d'être envoyé aux personnes concernées pour qu'elles puissent activer leur compte sur Polytechnique.net.";
+ } else {
+ return " Nous n'avons pas jugé bon d'activer les comptes Polytechnique.net demandés.";
+ }
+ }
+
+ // }}}
+ // {{{ function commit()
+
+ public function commit()
+ {
+ $values = array();
+ $i = 0;
+ foreach ($this->users as $user) {
+ $values[] = XDB::format('({?}, {?}, {?}, NOW(), {?}, {?}, {?})',
+ $user['uid'], $user['hruid'], $user['email'], rand_url_id(12), $this->user->fullName(), $this->group);
+
+ if ($i == $this->limit) {
+ XDB::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
+ VALUES ' . implode(', ', $values));
+ $i = 0;
+ $values = array();
+ } else {
+ ++$i;
+ }
+ }
+ XDB::rawExecute('INSERT INTO register_pending_xnet (uid, hruid, email, date, hash, sender_name, group_name)
+ VALUES ' . implode(', ', $values));
+
+ return true;
+ }
+
+ // }}}
+ // {{{ function isPending()
+
+ static public function isPending($uid)
+ {
+ $res = XDB::iterRow('SELECT data
+ FROM requests
+ WHERE type = \'bulk_accounts\'
+ ORDER BY stamp');
+
+ while (list($data) = $res->next()) {
+ $request = Validate::unserialize($data);
+ foreach ($request->users as $user) {
+ if ($user['uid'] == $uid) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ // }}}
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
'%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP, 'groupmember:groupannu'),
'%grp/annuaire/csv' => $this->make_hook('csv', AUTH_MDP, 'groupmember:groupannu'),
'%grp/directory/sync' => $this->make_hook('directory_sync', AUTH_MDP, 'groupadmin'),
+ '%grp/directory/unact' => $this->make_hook('non_active', AUTH_MDP, 'groupadmin'),
'%grp/trombi' => $this->make_hook('trombi', AUTH_MDP, 'groupannu'),
'%grp/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'groupannu'),
'%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP),
$page->assign('nonusers', $nonusers);
}
+ function handler_non_active($page)
+ {
+ global $globals;
+ $page->changeTpl('xnetgrp/non_active.tpl');
+
+ $uids = XDB::fetchColumn('SELECT g.uid
+ FROM group_members AS g
+ INNER JOIN accounts AS a ON (a.uid = g.uid)
+ LEFT JOIN register_pending_xnet AS p ON (p.uid = g.uid)
+ WHERE a.uid = g.uid AND g.asso_id = {?} AND a.type = \'xnet\' AND a.state = \'disabled\' AND p.uid IS NULL',
+ $globals->asso('id'));
+ foreach ($uids as $key => $uid) {
+ if (AccountReq::isPending($uid) || BulkAccountsReq::isPending($uid)) {
+ unset($uids[$key]);
+ }
+ }
+
+ if (Post::has('enable_accounts')) {
+ S::assert_xsrf_token();
+
+ $uids_to_enable = array_intersect(array_keys(Post::v('enable_accounts')), $uids);
+
+ $user = S::user();
+ $group = Platal::globals()->asso('nom');
+ $request = new BulkAccountsReq($user, $uids_to_enable, $group);
+ $request->submit();
+ $page->trigSuccess('Un email va bientôt être envoyé aux personnes sélectionnées pour l\'activation de leur compte.');
+
+ foreach ($uids as $key => $uid) {
+ if (in_array($uid, $uids_to_enable)) {
+ unset($uids[$key]);
+ }
+ }
+ }
+
+ $users = User::getBulkUsersWithUIDs($uids);
+ $page->assign('users', $users);
+ }
+
private function removeSubscriptionRequest($uid)
{
global $globals;
FROM register_pending_xnet
WHERE uid = {?}',
$user->id());
- $requested = AccountReq::isPending($user->id());
+ $requested = AccountReq::isPending($user->id()) || BulkAccountsReq::isPending($user->id());
if ($active || $pending || $requested) {
return false;
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+<tr class="pair">
+ <td class="titre">Groupe demandeur :</td>
+ <td>{$valid->group}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Adresses emails :</td>
+ <td>
+ |
+ {foreach from=$valid->users item=user}
+ {$user.email} |
+ {/foreach}
+ </td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{elseif $mail_part eq 'text'}
Bonjour,
-{$user->fullName()} nous a demandé de vous créer un compte pour que vous puissiez disposer pleinement de toutes les fonctionnalités liées au groupe {$group}.
+{$sender_name} nous a demandé de vous créer un compte pour que vous puissiez disposer pleinement de toutes les fonctionnalités liées au groupe {$group}.
Après activation, vos paramètres de connexion seront :
Synchroniser avec les listes
</a>
</li>
+ <li>
+ <a href="{$platal->ns}directory/unact">
+ {icon name=group_gear title="Lister les membres du groupe sans compte actif"}
+ Lister les membres du groupe sans compte actif
+ </a>
+ </li>
{if $asso->has_ml}
<li>
<a href="{$platal->ns}admin/annuaire">
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+{if $users|@count}
+<form action="{$platal->ns}directory/unact" method="post">
+ {xsrf_token_field}
+ <table cellspacing="2" cellpadding="0" class="tiny">
+ <tr>
+ <th>Nom</th>
+ <th>Email</th>
+ <th>
+ <a href="javascript:toggleAll()">{icon name="arrow_refresh" title="Tout (dé)cocher"}</a>
+ </th>
+ </tr>
+ {foreach from=$users item=user}
+ <tr>
+ <td class="checkboxToggle">{profile user=$user promo=true}</td>
+ <td class="checkboxToggle">{$user->email}</td>
+ <td class="checkboxToggle"><input type="checkbox" class="moderate_email" name="enable_accounts[{$user->id()}]" /></td>
+ </tr>
+ {/foreach}
+ <tr>
+ <td colspan="3" class="center">
+ <input type="submit" value="Inscrire au groupe" />
+ </td>
+ </tr>
+ </table>
+
+ <script type="text/javascript">//<![CDATA[
+ {literal}
+ var toggleState = false;
+ function toggleAll() {
+ toggleState = !toggleState;
+ var boxes = $(':checkbox.moderate_email');
+ if (toggleState) {
+ boxes.attr('checked', 'checked');
+ } else {
+ boxes.removeAttr('checked');
+ }
+ }
+
+ $('.checkboxToggle').click(function (event) {
+ // Don't uncheck the checkbox when clicking it
+ if (event.target.tagName === 'INPUT') {
+ return;
+ }
+
+ var checkbox = $(this).parent().find(':checkbox');
+ checkbox = checkbox.attr('checked', !checkbox.attr('checked'));
+ event.stopPropagation();
+ });
+ {/literal}
+ //]]></script>
+
+</form>
+{else}
+<p>Tous les inscrits au groupe ont un compte leur permettant d'accéder aux pages du groupe.</p>
+{/if}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /dev/null
+ALTER TABLE register_pending_xnet ADD COLUMN sender_name VARCHAR(255) NOT NULL DEFAULT '';
+ALTER TABLE register_pending_xnet ADD COLUMN group_name VARCHAR(255) NOT NULL DEFAULT '';
+
+-- vim:set syntax=mysql: