Merge commit 'origin/platal-0.10.0'
[platal.git] / include / validations / orange.inc.php
index f734421..802d3d7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -27,7 +27,6 @@ class OrangeReq extends Validate
 
     public $unique = true;
 
-    public $promo;
     public $promo_sortie;
 
     public $rules = "A priori accepter (la validation sert à repousser les
@@ -37,12 +36,11 @@ class OrangeReq extends Validate
     // }}}
     // {{{ constructor
 
-    public function __construct($_uid, $_sortie)
+    public function __construct(User &$_user, $_sortie)
     {
-        parent::__construct($_uid, true, 'orange');
+        parent::__construct($_user, true, 'orange');
         $this->promo_sortie  = $_sortie;
-        $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_uid);
-        $this->promo = $res->fetchOneCell();
+        $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_user->id());
     }
 
     // }}}
@@ -58,7 +56,7 @@ class OrangeReq extends Validate
 
     protected function _mail_subj()
     {
-        return "[Polytechnique.org/ORANGE] Changement de nom de promo de sortie";
+        return "[Polytechnique.org/ORANGE] Changement de promo de sortie";
     }
 
     // }}}
@@ -79,7 +77,7 @@ class OrangeReq extends Validate
 
     public function commit()
     {
-        XDB::execute("UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}",$this->promo_sortie ,$this->uid);
+        XDB::execute("UPDATE auth_user_md5 set promo_sortie = {?} WHERE user_id = {?}",$this->promo_sortie, $this->user->id());
         return true;
     }