Adds fields 'gender' and 'email_format' to the PlUser class.
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Sat, 23 Aug 2008 15:41:27 +0000 (17:41 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Sat, 23 Aug 2008 15:43:49 +0000 (17:43 +0200)
Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
classes/pluser.php

index 1dd2873..86cdf26 100644 (file)
@@ -42,6 +42,14 @@ class UserNotFoundException extends Exception
 abstract class PlUser
 {
     /**
+     * User data enumerations.
+     */
+    const GENDER_FEMALE = true;
+    const GENDER_MALE = false;
+    const FORMAT_HTML = "html";
+    const FORMAT_TEXT = "text";
+
+    /**
      * User data storage.
      * By convention, null means the information hasn't been fetched yet, and
      * false means the information is not available.
@@ -60,6 +68,10 @@ abstract class PlUser
     protected $full_name = null;
     protected $promo = null;
 
+    // Other important parameters used when sending emails.
+    protected $gender = null;  // Acceptable values are GENDER_MALE and GENDER_FEMALE
+    protected $email_format = null;  // Acceptable values are FORMAT_HTML and FORMAT_TEXT
+
     // Permissions
     protected $perms = null;
     protected $perm_flags = null;
@@ -137,6 +149,23 @@ abstract class PlUser
         return $this->full_name;
     }
 
+    public function promo()
+    {
+        return $this->promo;
+    }
+
+    // Fallback value is GENDER_MALE.
+    public function isFemale()
+    {
+        return $this->gender == self::GENDER_FEMALE;
+    }
+
+    // Fallback value is FORMAT_TEXT.
+    public function isEmailFormatHtml()
+    {
+        return $this->email_format == self::FORMAT_HTML;
+    }
+
     /**
      * Other properties are available directly through the $data array, or as
      * standard object variables, using a getter.