From: Vincent Zanotti Date: Sat, 23 Aug 2008 15:58:55 +0000 (+0200) Subject: Updates the test email sender method to the new User model. X-Git-Tag: xorg/0.10.0~86^2~38 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d0c3e04d0ef9d627bafcb396b970e28309985d8a;p=platal.git Updates the test email sender method to the new User model. Signed-off-by: Vincent Zanotti --- diff --git a/modules/email.php b/modules/email.php index f499509..e085ee1 100644 --- a/modules/email.php +++ b/modules/email.php @@ -438,7 +438,7 @@ class EmailModule extends PLModule $page->assign('maxsize', ini_get('upload_max_filesize') . 'o'); } - function handler_test(&$page, $forlife = null) + function handler_test(&$page, $hruid = null) { global $globals; require_once 'emails.inc.php'; @@ -446,23 +446,26 @@ class EmailModule extends PLModule if (!S::has_xsrf_token()) { return PL_FORBIDDEN; } - if (!S::has_perms() || !$forlife) { - $forlife = S::v('bestalias'); + + // Retrieves the User object for the test email recipient. + if (S::has_perms() && $hruid) { + $user = User::getSilent($hruid); + } else { + $user = S::user(); + } + if (!$user) { + return PL_NOT_FOUND; } - $res = XDB::query("SELECT FIND_IN_SET('femme', u.flags), prenom, user_id - FROM auth_user_md5 AS u - INNER JOIN aliases AS a ON (a.id = u.user_id) - WHERE a.alias = {?}", $forlife); - list($sexe, $prenom, $uid) = $res->fetchOneRow(); - $redirect = new Redirect($uid); + // Sends the test email. + $redirect = new Redirect($user->id()); $mailer = new PlMailer('emails/test.mail.tpl'); - $mailer->assign('email', $forlife . '@' . $globals->mail->domain); + $mailer->assign('email', $user->bestEmail()); $mailer->assign('redirects', $redirect->active_emails()); - $mailer->assign('sexe', $sexe); - $mailer->assign('prenom', $prenom); - $mailer->send(); + $mailer->assign('display_name', $user->displayName()); + $mailer->assign('sexe', $user->isFemale()); + $mailer->send($user->isEmailFormatHtml()); exit; } diff --git a/templates/emails/test.mail.tpl b/templates/emails/test.mail.tpl index a2fae6d..5737395 100644 --- a/templates/emails/test.mail.tpl +++ b/templates/emails/test.mail.tpl @@ -26,7 +26,7 @@ {to addr=$email} {subject text="Test de ton adresse `$email`"} {elseif $mail_part eq 'wiki'} -{if $sexe}Chère{else}Cher{/if} {$prenom}, +{if $sexe}Chère{else}Cher{/if} {$display_name}, Tu reçois cet email car tu as demandé la confirmation du bon fonctionnement de ton adresse polytechnicienne {$email}. {if count($redirects) gt 1}Si toutes tes redirections fonctionnent correctement tu devrais recevoir une copie de cet email