X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fmarketing.php;h=894497b259def75e265eb61492483477720617c2;hb=1f53925a716bf5cb97ed624a6787a8319eb2bcff;hp=68541b05b136884ef07c9d7c1f4d39aab029a4b7;hpb=089a5801075ffba573c547f1283d42d87065b5e4;p=platal.git diff --git a/modules/marketing.php b/modules/marketing.php index 68541b0..894497b 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -32,6 +32,7 @@ class MarketingModule extends PLModule '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), ); } @@ -152,12 +153,54 @@ class MarketingModule extends PLModule $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, a.alias AS forlife + FROM auth_user_md5 AS u + INNER JOIN aliases AS a ON a.id = u.user_id + WHERE a.alias = {?}", $forlife); + if (!$res->numRows()) { + return PL_NOT_FOUND; + } + $user = $res->fetchOneAssoc(); + $page->assign('user', $user); + + $email = trim(Post::v('mail')); + if (Post::has('valide') && strlen($email) > 0) { + $mailer = new PlMailer(); + $mailer->setFrom(S::v('bestalias') . '@polytechnique.org'); + $mailer->addTo('resetpass@polytechnique.org'); + $mailer->setSubject("Proposition d'adresse mail pour " . $user['forlife']); + + $message = S::v('nom') . ' ' . S::v('prenom') . ' (X' . S::v('promo') . ') ' + . 'propose l\'adresse suivante pour un camarade qui n\'a plus de ' + . 'redirections actives :' . "\n\n" + . '* ' . $user['forlife'] . ' => ' . $email . "\n"; + $mailer->setTxtBody(wordwrap($message, 78)); + $mailer->send(); + $page->assign('sent', true); + } + } + function handler_promo(&$page, $promo = null) { $page->changeTpl('marketing/promo.tpl');