Automation of the management of associations' mailing lists (Closes #817), Updates...
[platal.git] / include / validations / medals.inc.php
index a742da5..98d14d2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -42,7 +42,7 @@ class MedalReq extends Validate
     // {{{ function formu()
 
     public function formu()
-    { 
+    {
         return 'include/form.valid.medals.tpl';
     }
 
@@ -73,11 +73,11 @@ class MedalReq extends Validate
     {
         //var_dump($this);
         $r = XDB::query("
-            SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text) 
+            SELECT IF (g.text IS NOT NULL, CONCAT(m.text,' - ', g.text), m.text)
               FROM profile_medals AS m
          LEFT JOIN profile_medals_grades AS g ON(g.mid = m.id AND g.gid = {?})
              WHERE m.id = {?}", $this->gid, $this->mid);
-        return $r->fetchOneCell(); 
+        return $r->fetchOneCell();
     }
 
     // }}}
@@ -100,7 +100,25 @@ class MedalReq extends Validate
 
     public function commit ()
     {
-        return XDB::execute('REPLACE INTO profile_medals_sub VALUES({?}, {?}, {?})', $this->uid, $this->mid, $this->gid);
+        require_once 'notifs.inc.php';
+        register_watch_op($this->uid, WATCH_FICHE, 'medals');
+        return XDB::execute('REPLACE INTO  profile_medals_sub
+                                   VALUES  ({?}, {?}, {?})',
+                            $this->uid, $this->mid, $this->gid);
+    }
+
+    // }}}
+    // {{{ function get_request($medal)
+
+    static public function get_request($uid, $type)
+    {
+        $reqs = Validate::get_typed_requests($uid, 'medal');
+        foreach ($reqs as &$req) {
+            if ($req->mid == $type) {
+                return $req;
+            }
+        }
+        return null;
     }
 
     // }}}