Change the email format directly via the User object to ensure the changes
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 23 Jun 2010 08:12:19 +0000 (10:12 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 23 Jun 2010 08:13:47 +0000 (10:13 +0200)
are immediately taken into account (Closes #1112)

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/user.php
modules/platal.php

index c69e234..9b1d41e 100644 (file)
@@ -405,6 +405,20 @@ class User extends PlUser
     }
 
 
+    /** Format of the emails sent by the site
+     */
+    public function setEmailFormat($format)
+    {
+        Platal::assert($format == self::FORMAT_HTML || $format == self::FORMAT_TEXT,
+                       "Invalid email format \"$format\"");
+        XDB::execute("UPDATE  accounts
+                         SET  email_format = {?}
+                       WHERE  uid = {?}",
+                     $format, $this->uid);
+        $this->email_format = $format;
+    }
+
+
     /** Get watch informations
      */
     private function fetchWatchData()
index 197728e..2ad9317 100644 (file)
@@ -132,10 +132,7 @@ class PlatalModule extends PLModule
 
         if (Post::has('email_format')) {
             $fmt = Post::s('email_format');
-            XDB::execute("UPDATE accounts
-                             SET email_format = {?}
-                           WHERE uid = {?}",
-                         $fmt, S::v('uid'));
+            S::user()->setEmailFormat($fmt);
             S::set('email_format', $fmt);
         }