+ $q = XDB::query(
+ "SELECT a.alias,promo
+ FROM auth_user_md5 AS u
+ INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' )
+ WHERE user_id = {?}", $uid);
+ list($forlife, $promo) = $q->fetchOneRow();
+
+ switch ($action) {
+
+ case "original":
+ header("Content-type: image/jpeg");
+ readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg");
+ exit;
+ break;
+
+ case "new":
+ $data = file_get_contents($_FILES['userfile']['tmp_name']);
+ list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']);
+ $mimetype = substr($_FILES['userfile']['type'], 6);
+ unlink($_FILES['userfile']['tmp_name']);
+ XDB::execute(
+ "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}",
+ $uid, $mimetype, $data, $x, $y);
+ break;
+
+ case "delete":
+ XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid);
+ break;
+ }
+
+ $page->assign('forlife', $forlife);
+ }
+ function handler_admin_binets(&$page, $action = 'list', $id = null) {
+ $page->assign('pl_title','Polytechnique.org - Administration - Binets');
+ $page->assign('title', 'Gestion des binets');
+ $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id');
+ $table_editor->add_join_table('binets_ins','binet_id',true);
+ $table_editor->describe('text','intitulé',true);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_admin_formations(&$page, $action = 'list', $id = null) {
+ $page->assign('pl_title','Polytechnique.org - Administration - Formations');
+ $page->assign('title', 'Gestion des formations');
+ $table_editor = new PLTableEditor('admin/formations','applis_def','id');
+ $table_editor->add_join_table('applis_ins','aid',true);
+ $table_editor->describe('text','intitulé',true);
+ $table_editor->describe('url','site web',false);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_admin_sections(&$page, $action = 'list', $id = null) {
+ $page->assign('pl_title','Polytechnique.org - Administration - 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('pl_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('pl_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('pl_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) {
+ $page->assign('pl_title','Polytechnique.org - Administration - Distinctions');
+ $page->assign('title', 'Gestion des Distinctions');
+ $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');
+
+ $mid = $id;
+
+ if (Post::v('act') == 'del') {
+ XDB::execute('DELETE FROM profile_medals_grades
+ WHERE mid={?} AND gid={?}', $mid, Post::i('gid'));
+ } else {
+ foreach (Post::v('grades', array()) as $gid=>$text) {
+ 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);
+ $page->assign('grades', $res);
+ }