Merge branch 'platal-0.10.0'
[platal.git] / include / validations / medals.inc.php
index 441a7b9..e448358 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   *
@@ -31,11 +31,14 @@ class MedalReq extends Validate
     // }}}
     // {{{ constructor
 
-    public function __construct(User $_user, $_idmedal, $_subidmedal, $_stamp=0)
+    public function __construct(User &$_user, $_idmedal, $_subidmedal, $_stamp=0)
     {
         parent::__construct($_user, false, 'medal', $_stamp);
         $this->mid = $_idmedal;
         $this->gid = $_subidmedal;
+        if (is_null($this->gid)) {
+            $this->gid = 0;
+        }
     }
 
     // }}}
@@ -101,10 +104,11 @@ class MedalReq extends Validate
     public function commit ()
     {
         require_once 'notifs.inc.php';
-        register_watch_op($this->user->id(), WATCH_FICHE, 'medals');
+        register_watch_op($this->user->id(), WATCH_FICHE, '', 'medals');
         return XDB::execute('REPLACE INTO  profile_medals_sub
                                    VALUES  ({?}, {?}, {?})',
-                            $this->user->id(), $this->mid, $this->gid);
+                            $this->user->id(), $this->mid,
+                            is_null($this->gid) ? 0 : $this->gid);
     }
 
     // }}}