tel_type can't be null.
[platal.git] / include / validations.inc.php
index 734a407..085fffc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -42,7 +42,7 @@ class ValidateIterator extends XOrgDBIterator
     public function next ()
     {
         if (list($result, $stamp) = parent::next()) {
-            $result = unserialize($result);
+            $result = Validate::unserialize($result);
             $result->stamp = $stamp;
             return($result);
         } else {
@@ -183,7 +183,7 @@ abstract class Validate
             $mailer->setFrom("validation+{$this->type}@{$globals->mail->domain}");
             $mailer->addTo($globals->core->admin_email);
 
-            $body = "Validation {$this->type} pour {$this->user->id()}\n\n"
+            $body = "Validation {$this->type} pour {$this->user->login()}\n\n"
               . S::user()->login() . " a ajouté le commentaire :\n\n"
               . Env::v('comm') . "\n\n"
               . "cf la discussion sur : " . $globals->baseurl . "/admin/validate";
@@ -280,7 +280,7 @@ abstract class Validate
             $res = XDB::query('SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests WHERE user_id={?} AND type={?} and stamp={?}', $uid, $type, $stamp);
         }
         if ($result = $res->fetchOneCell()) {
-            $result = unserialize($result);
+            $result = Validate::unserialize($result);
         } else {
             $result = false;
         }
@@ -306,7 +306,7 @@ abstract class Validate
         $res = XDB::iterRow('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type);
         $array = array();
         while (list($data) = $res->next()) {
-            $array[] = unserialize($data);
+            $array[] = Validate::unserialize($data);
         }
         return $array;
     }
@@ -385,6 +385,17 @@ abstract class Validate
     }
 
     // }}}
+    // {{{ function unserialize()
+    public static function unserialize($data)
+    {
+        $obj = unserialize($data);
+        /* XXX: Temporary for hruid migration */
+        if (!isset($obj->user) || !is_object($obj)) {
+            $obj->user =& User::get($obj->forlife);
+        }
+        /* XXX: End temporary block */
+        return $obj;
+    }
 }
 
 foreach (glob(dirname(__FILE__).'/validations/*.inc.php') as $file) {