From d60d2d1fd8991be3fc1f80eb82d8a30c390a3047 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 23 Mar 2011 16:10:17 +0100 Subject: [PATCH 1/1] Seperates graduated phd from pending phd. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/admin.php | 62 ++++++++++++++++++++++++++++++++++-- templates/admin/index.tpl | 6 ++++ templates/admin/phd.tpl | 80 +++++++++++++++++++++++++++++++++++++++++++++++ upgrade/1.1.0/18_phd.sql | 3 ++ 4 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 templates/admin/phd.tpl create mode 100644 upgrade/1.1.0/18_phd.sql diff --git a/modules/admin.php b/modules/admin.php index c5827ea..2666c6f 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -53,7 +53,8 @@ class AdminModule extends PLModule 'admin/account/types' => $this->make_hook('account_types', AUTH_MDP, 'admin'), 'admin/xnet_without_group' => $this->make_hook('xnet_without_group', AUTH_MDP, 'admin'), 'admin/jobs' => $this->make_hook('jobs', AUTH_MDP, 'admin,edit_directory'), - 'admin/profile' => $this->make_hook('profile', AUTH_MDP, 'admin,edit_directory') + 'admin/profile' => $this->make_hook('profile', AUTH_MDP, 'admin,edit_directory'), + 'admin/phd' => $this->make_hook('phd', AUTH_MDP, 'admin') ); } @@ -831,12 +832,12 @@ class AdminModule extends PLModule $degreeid = $eduDegrees[Profile::DEGREE_D]; $grad_year = $promotion; $entry_year = $promotion - 3; - $promo = 'D' . $promotion; + $promo = 'D (en cours)'; $hrpromo = $promo; $type = 'phd'; break; default: - $page->killError("La formation n'est pas reconnue:" . Env::t('edu_type') . '.'); + $page->killError("La formation n'est pas reconnue : " . Env::t('edu_type') . '.'); } XDB::startTransaction(); @@ -1824,6 +1825,61 @@ class AdminModule extends PLModule ORDER BY pd.directory_name'); $page->assign('updates', $res); } + + function handler_phd($page, $promo = null, $validate = false) + { + $page->changeTpl('admin/phd.tpl'); + $eduDegrees = DirEnum::getOptions(DirEnum::EDUDEGREES); + $eduDegrees = array_flip($eduDegrees); + + if (is_null($promo)) { + $promo_list = XDB::fetchColumn('SELECT DISTINCT(grad_year) + FROM profile_education + WHERE FIND_IN_SET(\'primary\', flags) AND NOT FIND_IN_SET(\'completed\', flags) AND degreeid = {?} + ORDER BY grad_year', + $eduDegrees[Profile::DEGREE_D]); + $page->assign('promo_list', $promo_list); + $page->assign('nothing', count($promo_list) == 0); + return; + } + + if ($validate) { + S::assert_xsrf_token(); + + $list = XDB::iterator('SELECT pe.pid, pd.directory_name + FROM profile_education AS pe + INNER JOIN profile_display AS pd ON (pe.pid = pd.pid) + WHERE FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags) + AND pe.degreeid = {?} AND pe.grad_year = {?}', + $eduDegrees[Profile::DEGREE_D], $promo); + while ($res = $list->next()) { + $pid = $res['pid']; + $name = $res['directory_name']; + if (Post::b('completed_' . $pid)) { + $grad_year = Post::t('grad_year_' . $pid); + XDB::execute('UPDATE profile_education + SET flags = \'primary,completed\', grad_year = {?} + WHERE FIND_IN_SET(\'primary\', flags) AND pid = {?}', + $grad_year, $pid); + XDB::execute('UPDATE profile_display + SET promo = {?} + WHERE pid = {?}', + 'D' . $grad_year, $pid); + $page->trigSuccess("Promotion de $name validée."); + } + } + } + + $list = XDB::iterator('SELECT pe.pid, pd.directory_name + FROM profile_education AS pe + INNER JOIN profile_display AS pd ON (pe.pid = pd.pid) + WHERE FIND_IN_SET(\'primary\', pe.flags) AND NOT FIND_IN_SET(\'completed\', pe.flags) + AND pe.degreeid = {?} AND pe.grad_year = {?} + ORDER BY pd.directory_name', + $eduDegrees[Profile::DEGREE_D], $promo); + $page->assign('list', $list); + $page->assign('promo', $promo); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 0c01066..e491163 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -113,6 +113,12 @@ Google Apps + + Promotions + + Doctorants + + {icon name=user_gray} Champs diff --git a/templates/admin/phd.tpl b/templates/admin/phd.tpl new file mode 100644 index 0000000..9c86162 --- /dev/null +++ b/templates/admin/phd.tpl @@ -0,0 +1,80 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2011 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +{if t($nothing)} +

Rien à faire.

+{elseif t($promo_list)} +

+ Années de soutenance de thèse prévues pour lesquelles il reste des doctorants n'ayant pas soutenus :
| + {foreach from=$promo_list item=promo} + {$promo} | + {/foreach} +

+{else} + + +
+ {xsrf_token_field} + + + + + + + {iterate item=profile from=$list} + + + + + + {/iterate} + + + +
NomAnnée de soutenance prévueA soutenu {icon name="arrow_refresh" title="Tout (dé)cocher"}
{$profile.directory_name} + + + +
+ +
+
+ +

+ Revenir à la liste des années de soutenance de thèse prévues pour lesquelles il reste des doctorants n'ayant pas soutenus. +

+{/if} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/upgrade/1.1.0/18_phd.sql b/upgrade/1.1.0/18_phd.sql new file mode 100644 index 0000000..3beca31 --- /dev/null +++ b/upgrade/1.1.0/18_phd.sql @@ -0,0 +1,3 @@ +ALTER TABLE profile_education MODIFY COLUMN flags SET('primary', 'completed') NOT NULL DEFAULT ''; + +-- vim:set syntax=mysql: -- 2.1.4