<?php
/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
+ * Copyright (C) 2003-2007 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
'marketing/private' => $this->make_hook('private', AUTH_MDP, 'admin'),
'marketing/public' => $this->make_hook('public', AUTH_COOKIE),
+ 'marketing/broken' => $this->make_hook('broken', AUTH_COOKIE),
);
}
WHERE user_id={?} AND perms='pending'", $uid);
if (list($nom, $prenom, $promo, $matricule) = $res->fetchOneRow()) {
- require_once('register.inc.php');
+ require_once('user.func.inc.php');
$matricule_X = get_X_mat($matricule);
$page->assign('nom', $nom);
$page->assign('prenom', $prenom);
$res = XDB::query("SELECT date, relance FROM register_pending
WHERE uid = {?}", $uid);
- if (list($pending, $relance) = $res->fetchOneCell()) {
+ if (list($pending, $relance) = $res->fetchOneRow()) {
$page->assign('pending', $pending);
$page->assign('relance', $relance);
}
}
+ function handler_broken(&$page, $uid = null)
+ {
+ require_once('user.func.inc.php');
+ $page->changeTpl('marketing/broken.tpl');
+
+ if (is_null($uid)) {
+ return PL_NOT_FOUND;
+ }
+ $forlife = get_user_forlife($uid);
+ if (!$forlife) {
+ return PL_NOT_FOUND;
+ } elseif ($forlife == S::v('forlife')) {
+ pl_redirect('emails/redirect');
+ }
+
+ $res = Xdb::query("SELECT u.nom, u.prenom, u.promo, FIND_IN_SET('femme', u.flags) AS sexe,
+ a.alias AS forlife, b.alias AS bestalias, e.email, e.last
+ FROM auth_user_md5 AS u
+ INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie')
+ INNER JOIN aliases AS b ON (b.id = u.user_id AND FIND_IN_SET('bestalias', b.flags))
+ LEFT JOIN emails AS e ON (e.flags = 'active' AND e.uid = u.user_id)
+ WHERE a.alias = {?}
+ ORDER BY e.panne_level, e.last", $forlife);
+ if (!$res->numRows()) {
+ return PL_NOT_FOUND;
+ }
+ $user = $res->fetchOneAssoc();
+ $page->assign('user', $user);
+
+ $email = null;
+ if (Post::has('mail')) {
+ require_once 'emails.inc.php';
+ $email = valide_email(Post::v('mail'));
+ }
+ if (Post::has('valide') && isvalid_email_redirection($email)) {
+ // security stuff
+ check_email($email, "Proposition d'une adresse surveillee pour " . $user['forlife'] . " par " . S::v('forlife'));
+ if ($user['email'] && !trim(Post::v('comment'))) {
+ $page->trig("Il faut que tu ajoutes un commentaire à ta proposition pour justifier le "
+ ."besoin de changer la redirection de " . $user['prenom']);
+ } else {
+ require_once 'validations.inc.php';
+ $valid = new BrokenReq(S::i('uid'), $user, $email, trim(Post::v('comment')));
+ $valid->submit();
+ $page->assign('sent', true);
+ }
+ } elseif ($email) {
+ $page->trig("L'adresse proposée n'est pas une adresse acceptable pour une redirection");
+ }
+ }
+
function handler_promo(&$page, $promo = null)
{
$page->changeTpl('marketing/promo.tpl');
$page->assign('already', true);
} else {
$page->assign('ok', true);
+ check_email($email, "Une adresse surveillée est proposée au marketing par " . S::v('forlife'));
XDB::execute(
"INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash)
VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')",