[newsletter_schedule_mailing]
from="Gestion des NLs" <support@polytechnique.org>
to=br@staff.polytechnique.org
+
+[xnet_registration]
+from=register@polytechnique.org
+cc=register@polytechnique.org
+subject="Inscription à Polytechnique.net"
--- /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 AccountReq extends Validate
+{
+ // {{{ properties
+
+ public $uid;
+ public $hruid;
+ public $email;
+ public $group;
+
+ 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
+ adresse email, refuser dans tous les cas. Sauf abus flagrant, il n'y a
+ pas de raison de refuser des marketing perso répétés.";
+ // }}}
+ // {{{ constructor
+
+ public function __construct(User $user, $hruid, $email, $group)
+ {
+ parent::__construct($user, false, 'account');
+ $this->hruid = $hruid;
+ $this->email = $email;
+ $this->group = $group;
+ $this->uid = XDB::fetchOneCell('SELECT uid
+ FROM accounts
+ WHERE hruid = {?}',
+ $hruid);
+ }
+
+ // }}}
+ // {{{ function formu()
+
+ public function formu()
+ {
+ return 'include/form.valid.account.tpl';
+ }
+
+ // }}}
+ // {{{ function _mail_subj
+
+ protected function _mail_subj()
+ {
+ return "[Polytechnique.org] Création d'un compte Polytechnique.net";
+ }
+
+ // }}}
+ // {{{ function _mail_body
+
+ protected function _mail_body($isok)
+ {
+ if ($isok) {
+ return " Un email vient d'être envoyé à {$this->email} pour qu'il puisse activer son compte sur Polytechnique.net.";
+ } else {
+ return " Nous n'avons pas jugé bon d'envoyer d'email à {$this->email} pour qu'il puisse activer son compte sur Polytechnique.net.";
+ }
+ }
+
+ // }}}
+ // {{{ function commit()
+
+ 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();
+
+ return true;
+ }
+
+ // }}}
+ // {{{ function isPending()
+
+ static public function isPending($uid)
+ {
+ $res = XDB::iterRow('SELECT data
+ FROM requests
+ 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));
+ }
+ return $is_pending;
+ }
+
+ // }}}
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
'%grp/member/new' => $this->make_hook('admin_member_new', AUTH_MDP, 'groupadmin'),
'%grp/member/new/ajax' => $this->make_hook('admin_member_new_ajax', AUTH_MDP, 'user', NO_AUTH),
'%grp/member/del' => $this->make_hook('admin_member_del', AUTH_MDP, 'groupadmin'),
+ '%grp/member/suggest' => $this->make_hook('admin_member_suggest', AUTH_MDP, 'groupadmin'),
'%grp/rss' => $this->make_token_hook('rss', AUTH_PUBLIC),
'%grp/announce/new' => $this->make_hook('edit_announce', AUTH_MDP, 'groupadmin'),
}
S::assert_xsrf_token();
+ $suggest_account_activation = false;
// Finds or creates account: first cases are for users with an account.
if (!User::isForeignEmailAddress($email)) {
}
}
} else {
- // User is of type xnet.
+ // User is of type xnet. There are 3 possible cases:
+ // * the email is not known yet: we create a new account and
+ // propose to send an email to the user so he can activate
+ // his account,
+ // * the email is known but the user was not contacted in order to
+ // activate yet: we propose to send an email to the user so he
+ // can activate his account,
+ // * the email is known and the user was already contacted or has
+ // an active account: nothing to be done.
list($mbox, $domain) = explode('@', strtolower($email));
$hruid = User::makeHrid($mbox, $domain, 'ext');
// User might already have an account (in another group for example).
$hruid, $display_name, $full_name, $directory_name, $email);
$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;
+ }
}
if ($user) {
VALUES ({?}, {?})',
$user->id(), $globals->asso('id'));
$this->removeSubscriptionRequest($user->id());
- pl_redirect('member/' . $user->login());
+ if ($suggest_account_activation) {
+ pl_redirect('member/suggest/' . $user->login() . '/' . $email . '/' . $globals->asso('nom'));
+ } else {
+ pl_redirect('member/' . $user->login());
+ }
+ }
+ }
+
+ function handler_admin_member_suggest($page, $hruid, $email)
+ {
+ $page->changeTpl('xnetgrp/membres-suggest.tpl');
+
+ if (Post::has('suggest')) {
+ if (Post::t('suggest') == 'yes') {
+ $user = S::user();
+ $group = Platal::globals()->asso('nom');
+ $request = new AccountReq($user, $hruid, $email, $group);
+ $request->submit();
+ $page->trigSuccessRedirect('Un email va bien être envoyé à ' . $email . ' pour l\'activation de son compte.',
+ $group . '/member/' . $hruid);
+ } else {
+ pl_redirect('member/' . $hruid);
+ }
}
+ $page->assign('email', $email);
+ $page->assign('hruid', $hruid);
}
function handler_admin_member_new_ajax($page)
--- /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 :</td>
+ <td>{$valid->group}</td>
+</tr>
+<tr class="pair">
+ <td class="titre">Adresse email :</td>
+ <td>{$valid->email}</td>
+</tr>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /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 *}
+{* *}
+{**************************************************************************}
+
+{config_load file="mails.conf" section="xnet_registration"}
+{if $mail_part eq 'head'}
+{subject text=#subject#}
+{from full=#from#}
+{cc full=#cc#}
+{to addr="$to"}
+{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}.
+
+Après activation, vos paramètres de connexion seront :
+
+identifiant : {$hruid}
+mot de passe : celui que vous choisirez
+
+Vous pouvez, dès à présent et pendant une période d'un mois, activer votre compte en cliquant sur le lien suivant :
+
+http://www.polytechnique.net/register/{$hash}
+
+Si le lien ne fonctionne pas, copiez intégralement ce lien dans la barre d'adresse de votre navigateur.
+
+Nous espérons que vous profiterez pleinement des services en ligne de Polytechnique.net.
+{include file="include/signature.mail.tpl"}
+{/if}
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /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 *}
+{* *}
+{**************************************************************************}
+
+<h1>{$asso->nom} : Ajout d'un membre (suite)</h1>
+
+<p>
+ L'adresse email <strong>{$email}</strong> ne correspond actuellement à aucun
+ compte. Souhaites-tu qu'un compte « Extérieur » soit créé pour lui et que nous
+ lui envoyions un email afin qu'il ait accès aux nombreuses fonctionnalités de
+ Polytechnique.net (inscription aux évènements, télépaiement, modération des
+ listes de diffusion…) ?
+</p>
+<form action="{$platal->ns}member/suggest/{$hruid}/{$email}" method="post" class="center">
+ {xsrf_token_field}
+ <p>
+ <label>Oui <input type="radio" name="suggest" value="yes" checked="checked" /></label>
+ -
+ <label><input type="radio" name="suggest" value="no" /> Non</label>
+ </p>
+ <p><input type="submit" value="continuer" /></p>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
--- /dev/null
+DROP TABLE IF EXISTS register_pending_xnet;
+
+CREATE TABLE register_pending_xnet (
+ uid INT(11) UNSIGNED NOT NULL DEFAULT 0,
+ hruid VARCHAR(255) NOT NULL DEFAULT '',
+ email VARCHAR(255) NOT NULL DEFAULT '',
+ date DATE NOT NULL DEFAULT '0000-00-00',
+ hash VARCHAR(12) NOT NULL DEFAULT '',
+ PRIMARY KEY (uid),
+ UNIQUE KEY hruid (hruid),
+ KEY hash (hash),
+ FOREIGN KEY (uid) REFERENCES accounts (uid) ON DELETE CASCADE ON UPDATE CASCADE,
+ FOREIGN KEY (hruid) REFERENCES accounts (hruid) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB, CHARSET=utf8;
+
+-- vim:set syntax=mysql: