X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=b75fbe0a9f09fa64dadd0497fb3604e6c4b60b7b;hb=a5878ac19cc6ea75a753470cf68b7d2180d6cd51;hp=bde1cf20b0f758f72e0e219699779d6d88244dc3;hpb=24f4c06a1bfdc57d45e4dae8ce5085a9f62b76e1;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index bde1cf2..b75fbe0 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -59,6 +59,8 @@ class ProfileModule extends PLModule 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'), 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), + 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'), + 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'), ); } @@ -105,11 +107,16 @@ class ProfileModule extends PLModule function handler_medal(&$page, $mid) { + $thumb = ($mid == 'thumb'); + $mid = $thumb ? @func_get_arg(2) : $mid; + $res = XDB::query("SELECT img FROM profile_medals WHERE id = {?}", $mid); - $img = dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); + $img = $thumb ? + dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() : + dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); $type = mime_content_type($img); header("Content-Type: $type"); echo file_get_contents($img); @@ -297,9 +304,9 @@ class ProfileModule extends PLModule // Build the page $page->addJsLink('ajax.js'); - $page->addJsLink('profile.js'); $page->addJsLink('applis.js'); $page->addJsLink('grades.js'); + $page->addJsLink('profile.js'); $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true); require_once dirname(__FILE__) . '/profile/page.inc.php'; $wiz->addPage('ProfileGeneral', 'Général', 'general'); @@ -758,16 +765,32 @@ class ProfileModule extends PLModule } function handler_admin_sections(&$page, $action = 'list', $id = null) { $page->assign('xorg_title','Polytechnique.org - Administration - Sections'); - $page->assign('title', 'Gestion des Sections'); + $page->assign('title', 'Gestion des sections'); $table_editor = new PLTableEditor('admin/sections','sections','id'); $table_editor->describe('text','intitulé',true); $table_editor->apply($page, $action, $id); } + function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) { + $page->assign('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs'); + $page->assign('title', 'Gestion des sous-secteurs'); + $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true); + $table_editor->describe('label', 'intitulé', true); + $table_editor->apply($page, $action, $id); + } + function handler_admin_fonctions(&$page, $action = 'list', $id = null) { + $page->assign('xorg_title', 'Polytechnique.org - Administration - Fonctions'); + $page->assign('title', 'Gestion des fonctions'); + $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true); + $table_editor->describe('fonction_fr', 'intitulé', true); + $table_editor->describe('fonction_en', 'intitulé (ang)', true); + $table_editor->describe('flags', 'titre', true); + $table_editor->apply($page, $action, $id); + } function handler_admin_secteurs(&$page, $action = 'list', $id = null) { - $page->assign('xorg_title','Polytechnique.org - Administration - Secteurs'); - $page->assign('title', 'Gestion des Secteurs'); - $table_editor = new PLTableEditor('admin/secteurs','emploi_secteur','id'); - $table_editor->describe('label','intitulé',true); + $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs'); + $page->assign('title', 'Gestion des secteurs'); + $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true); + $table_editor->describe('label', 'intitulé', true); $table_editor->apply($page, $action, $id); } function handler_admin_medals(&$page, $action = 'list', $id = null) { @@ -786,15 +809,24 @@ class ProfileModule extends PLModule if (Post::v('act') == 'del') { XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::i('gid')); - } elseif (Post::v('act') == 'new') { - XDB::execute('INSERT INTO profile_medals_grades (mid,gid) - VALUES ({?},{?})', - $mid, max(array_keys(Post::v('grades', array(0))))+1); } else { foreach (Post::v('grades', array()) as $gid=>$text) { - XDB::execute('UPDATE profile_medals_grades - SET pos={?}, text={?} - WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); + if ($gid === 0) { + if (!empty($text)) { + $res = XDB::query('SELECT MAX(gid) + FROM profile_medals_grades + WHERE mid = {?}', $mid); + $gid = $res->fetchOneCell() + 1; + + XDB::execute('INSERT INTO profile_medals_grades (mid, gid, text, pos) + VALUES ({?}, {?}, {?}, {?})', + $mid, $gid, $text, $_POST['pos']['0']); + } + } else { + XDB::execute('UPDATE profile_medals_grades + SET pos={?}, text={?} + WHERE gid={?} AND mid={?}', $_POST['pos'][$gid], $text, $gid, $mid); + } } } $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);