From d02b8359e75e7a29be2a5ac80c4a2dd4a44323dc Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Tue, 19 Dec 2006 20:43:15 +0000 Subject: [PATCH] Add a flag "Must be validated" for medals instead of hard-coding this git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1297 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/profil/assign_deco.inc.php | 2 +- include/profil/get_deco.inc.php | 10 +++------- include/validations/medals.inc.php | 15 +++++++++++++++ modules/profile.php | 1 + templates/profile/admin_decos.tpl | 2 +- templates/profile/deco.tpl | 1 + upgrade/0.9.13/03_medals.sql | 3 +++ 7 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 upgrade/0.9.13/03_medals.sql diff --git a/include/profil/assign_deco.inc.php b/include/profil/assign_deco.inc.php index 9eaf230..cdcee2a 100644 --- a/include/profil/assign_deco.inc.php +++ b/include/profil/assign_deco.inc.php @@ -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; diff --git a/include/profil/get_deco.inc.php b/include/profil/get_deco.inc.php index 859e17e..ddca970 100644 --- a/include/profil/get_deco.inc.php +++ b/include/profil/get_deco.inc.php @@ -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)); diff --git a/include/validations/medals.inc.php b/include/validations/medals.inc.php index 92a615e..d2c8ec5 100644 --- a/include/validations/medals.inc.php +++ b/include/validations/medals.inc.php @@ -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 () diff --git a/modules/profile.php b/modules/profile.php index 7068623..248a327 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -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'); diff --git a/templates/profile/admin_decos.tpl b/templates/profile/admin_decos.tpl index 4bb456d..dc24387 100644 --- a/templates/profile/admin_decos.tpl +++ b/templates/profile/admin_decos.tpl @@ -20,7 +20,7 @@ {* *} {**************************************************************************} -{include file=table-editor.tpl} +{include file="core/table-editor.tpl"}

Administration Polytechnique.org

diff --git a/templates/profile/deco.tpl b/templates/profile/deco.tpl index de73a9b..e8eb22c 100644 --- a/templates/profile/deco.tpl +++ b/templates/profile/deco.tpl @@ -23,6 +23,7 @@ {literal}