+ $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('xorg_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('xorg_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('xorg_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('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', true);
+ $table_editor->describe('label', 'intitulé', true);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_admin_networking(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking');
+ $page->assign('title', 'Gestion des types de networking');
+ $table_editor = new PLTableEditor('admin/networking', 'profile_networking_enum', 'network_type');
+ $table_editor->describe('name', 'intitulé', true);
+ $table_editor->describe('icon', 'nom de l\'icône', false);
+ $table_editor->describe('filter', 'nom du filtre à appliquer', true);
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_admin_phones_format_display(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_title', 'Polytechnique.org - Administration - Format d\'affichage des numéros de téléphone ');
+ $page->assign('title', 'Gestion des formats d\'affichage des numéros de téléphone');
+ $table_editor = new PLTableEditor('admin/phones_format_display', 'phone_formats', 'phoneprf',true);
+ $table_editor->describe('format', 'format d\'Affichage (ex: (+p) ### ## ## ##)', true);
+ if ($action == 'update') {
+ if ((Post::has('phoneprf')) && (Post::v('phoneprf') == $id)) {
+ $res = XDB::query("SELECT format
+ FROM phone_formats
+ WHERE phoneprf = {?}",
+ $id);
+ $old_val = $res->fetchOneCell();
+ if (Post::has('format')) {
+ $new_val = Post::v('format');
+ } else {
+ $new_val = '';
+ }
+ if ($new_val != $old_val){
+ require_once("profil.func.inc.php");
+ XDB::execute("UPDATE phone_formats
+ SET format = {?}
+ WHERE phoneprf = {?}",
+ $new_val, $id);
+ $prefixe = $id . '%';
+ $res = XDB::iterator("SELECT uid, link_type, link_id, tel_id, tel_type, search_tel, pub
+ FROM telephone
+ WHERE search_tel LIKE {?}",
+ $prefixe);
+ $req = '';
+ $i = 0;
+ while($phonenumber = $res->next()) {
+ if ($req != '') {
+ $req .= ",\n";
+ }
+ $req .= "('" . addslashes($phonenumber['uid']) . "', '" . addslashes($phonenumber['link_type']) . "', '" . addslashes($phonenumber['link_id'])
+ . "', '" . addslashes($phonenumber['tel_id']) . "', '" . addslashes($phonenumber['tel_type'])
+ . "', '" . addslashes($phonenumber['search_tel']) . "', '"
+ . addslashes(format_display_number($phonenumber['search_tel'], &$erreur, array('format' => $new_val, 'phoneprf' => $id)))
+ . "', '" . addslashes($phonenumber['pub']) . "')";
+ $i++;
+ if( $i == 1000) {
+ XDB::execute("INSERT INTO telephone(uid, link_type, link_id, tel_id ,tel_type,
+ search_tel, display_tel, pub)
+ VALUES " . $req . "
+ ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
+ $req = '';
+ $i = 0;
+ }
+ }
+ if ($req != '') {
+ XDB::execute("INSERT INTO telephone(uid, link_type, link_id, tel_id ,tel_type,
+ search_tel, display_tel, pub)
+ VALUES " . $req . "
+ ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)");
+ }
+ }
+ }
+ $action = 'list';
+ $id = null;
+ }
+ $table_editor->apply($page, $action, $id);
+ }
+ function handler_admin_medals(&$page, $action = 'list', $id = null) {
+ $page->assign('xorg_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);
+ }