Merge branch 'xorg/maint' into xorg/master
[platal.git] / include / validations / broken.inc.php
index da22479..2cb486d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -37,7 +37,7 @@ class BrokenReq extends Validate
     // }}}
     // {{{ constructor
 
-    public function __construct(User &$sender, User &$user, $email, $comment = null)
+    public function __construct(User $sender, User $user, $email, $comment = null)
     {
         parent::__construct($sender, false, 'broken');
         $this->m_user      = &$user;
@@ -66,15 +66,16 @@ class BrokenReq extends Validate
 
     protected function _mail_body($isok)
     {
+        $your = ($this->formal ? 'votre' : 'ta');
         if ($isok && !$this->m_reactive) {
             return "  Un email de contact vient d'être envoyé à {$this->m_user->fullName()}"
                 . " ({$this->m_user->promo()})  pour confirmer sa volonté de"
                 . " mettre à jour sa redirection Polytechnique.org !\n\n"
-                . "Merci de ta participation !\n";
+                . "Merci de $your participation !\n";
         } elseif ($isok) {
             return "  L'adresse de redirection {$this->m_email} de {$this->m_user->fullName()} ({$this->m_user->promo()}) "
                 ."vient d'être réactivée. Un email lui a été envoyé pour l'en informer.\n\n"
-                ."Merci de ta participation !\n";
+                ."Merci de $your participation !\n";
         } else {
             return "  Nous n'utiliserons pas cette adresse pour contacter {$this->m_user->fullName()} ({$this->m_user->promo()}).";
         }
@@ -88,9 +89,10 @@ class BrokenReq extends Validate
         global $globals;
         $email =  $this->m_user->bestEmail();
 
-        XDB::execute("UPDATE  emails
-                         SET  flags = 'active', panne_level = 2
-                       WHERE  uid = {?} AND email = {?}", $this->m_user->id(), $this->m_email);
+        XDB::execute('UPDATE  email_redirect_account
+                         SET  flags = \'active\', broken_level = 2
+                       WHERE  uid = {?} AND redirect = {?}',
+                     $this->m_user->id(), $this->m_email);
         if (XDB::affectedRows() > 0) {
             $this->m_reactive = true;
             $mailer = new PlMailer();
@@ -113,7 +115,10 @@ class BrokenReq extends Validate
             $subject = "Ton adresse $email semble ne plus fonctionner";
             $reason  = "Nous avons été informés que ton adresse $email ne fonctionne plus correctement par un camarade";
         } else {
-            $res = XDB::iterRow("SELECT email FROM emails WHERE uid = {?} AND flags = 'panne'", $this->m_user->id());
+            $res = XDB::iterRow('SELECT  redirect
+                                   FROM  email_redirect_account
+                                  WHERE  uid = {?} AND flags = \'broken\'',
+                                $this->m_user->id());
             $redirect = array();
             while (list($red) = $res->next()) {
                 list(, $redirect[]) = explode('@', $red);