Add a flag "Must be validated" for medals instead of hard-coding this
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 19 Dec 2006 20:43:15 +0000 (20:43 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 19 Dec 2006 20:43:15 +0000 (20:43 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1297 839d8a87-29fc-0310-9880-83ba4fa771e5

include/profil/assign_deco.inc.php
include/profil/get_deco.inc.php
include/validations/medals.inc.php
modules/profile.php
templates/profile/admin_decos.tpl
templates/profile/deco.tpl
upgrade/0.9.13/03_medals.sql [new file with mode: 0644]

index 9eaf230..cdcee2a 100644 (file)
@@ -26,7 +26,7 @@ while ($tmp = $res->next()) {
     $grades[$tmp['mid']][] = $tmp;
 }
 
-$res    = XDB::iterator("SELECT * FROM profile_medals ORDER BY type, text");
+$res    = XDB::iterator("SELECT *, FIND_IN_SET(flags, 'validation') AS validate FROM profile_medals ORDER BY type, text");
 $mlist  = Array();
 while ($tmp = $res->next()) {
     $mlist[$tmp['type']][] = $tmp;
index 859e17e..ddca970 100644 (file)
@@ -28,12 +28,8 @@ if (Env::has('medal_op')) {
 
     if (Env::v('medal_op')=='ajouter' && Env::i('medal_id')) {
         $req = new MedalReq(S::v('uid',-1),Env::i('medal_id'), Env::i('grade_id'));
-//        if ($req->mid == 20) { // defnat
-//             $req->commit();
-//             unset($_REQUEST['medal_op']); // pour ne pas avoir le message d'attente de validation
-//        } else {
-               $req->submit();
-//             }    
+        $req->submit();
+        unset($_REQUEST['medal_op']); // pour ne pas avoir le message d'attente de validation
     }
 
     if (Env::v('medal_op')=='annuler' && Env::i('medal_id')) {
@@ -48,7 +44,7 @@ if (Post::has('grade')) {
 } 
 
 $res    = XDB::query(
-       "SELECT  m.id, m.text AS medal, m.type, m.img, s.gid
+       "SELECT  m.id, m.text AS medal, m.type, m.img, s.gid
            FROM  profile_medals_sub    AS s
      INNER JOIN  profile_medals        AS m ON ( s.mid = m.id )
           WHERE  s.uid = {?}", S::v('uid', -1));
index 92a615e..d2c8ec5 100644 (file)
@@ -81,6 +81,21 @@ class MedalReq extends Validate
     }
 
     // }}}
+    // {{{ function submit()
+
+    function submit()
+    {
+        $res = XDB::query("SELECT  FIND_IN_SET(flags, 'validation')
+                             FROM  profile_medals
+                            WHERE  id = {?}", $this->mid);
+        if ($res->fetchOneCell()) {
+            parent::submit();
+        } else {
+            $this->commit();
+        }
+    }
+    
+    // }}}
     // {{{ function commit()
 
     function commit ()
index 7068623..248a327 100644 (file)
@@ -770,6 +770,7 @@ class ProfileModule extends PLModule
         $table_editor = new PLTableEditor('admin/medals','profile_medals','id');
         $table_editor->describe('text', 'intitulé',  true);
         $table_editor->describe('img',  'nom de l\'image', false);
+        $table_editor->describe('flags', 'valider', true);
         $table_editor->apply($page, $action, $id);
         if ($id && $action == 'edit') {
             $page->changeTpl('profile/admin_decos.tpl');
index 4bb456d..dc24387 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{include file=table-editor.tpl}
+{include file="core/table-editor.tpl"}
 
 <h1>Administration Polytechnique.org</h1>
 
index de73a9b..e8eb22c 100644 (file)
@@ -23,6 +23,7 @@
 
 {literal}
 <script type="text/javascript">//<![CDATA[
+  var valid = new array();
   function medal_add()
   {
     var selid = document.forms.prof_annu.medal_sel.selectedIndex;
diff --git a/upgrade/0.9.13/03_medals.sql b/upgrade/0.9.13/03_medals.sql
new file mode 100644 (file)
index 0000000..b0a5cbb
--- /dev/null
@@ -0,0 +1,3 @@
+alter table profile_medals add column flags set('validation') not null default 'validation';
+update profile_medals set flags = '' where id = 20;
+# vim:set syntax=mysql: