X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations.inc.php;h=fef4df2f294d589f0eebf20790bea61c64e22b0a;hb=8a43972f58f0a77015ae9e509f1c073d188874d2;hp=c0c60e6b363fe50acd138eec27325828eb0694ef;hpb=5daf68f6846682e439570b5245a6109ada8d9304;p=platal.git diff --git a/include/validations.inc.php b/include/validations.inc.php index c0c60e6..fef4df2 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -1,6 +1,6 @@ stamp = $stamp; return($result); } else { @@ -79,12 +79,16 @@ abstract class Validate * @param $_unique requête pouvant être multiple ou non * @param $_type type de la donnée comme dans le champ type de x4dat.requests */ - public function __construct(User $_user, $_unique, $_type) + public function __construct(User &$_user, $_unique, $_type) { - $this->user = $_user; + $this->user = &$_user; $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; + $res = XDB::query("SELECT promo + FROM profile_display + WHERE pid={?}", $this->user->id()); + $this->promo = $res->fetchOneCell(); } // }}} @@ -183,7 +187,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 +284,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 +310,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 +389,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) {