+ function handler_ref_country(&$page, $sect, $ssect = '')
+ {
+ header('Content-Type: text/html; charset=utf-8');
+ $page->changeTpl('include/field.select.tpl', NO_SKIN);
+ $page->assign('name', 'pays_sel');
+ $where = ($ssect ? ' AND ms.ss_secteur = {?}' : '');
+ $it = XDB::iterator("SELECT a2 AS id, pays AS field
+ FROM geoloc_pays AS g
+ INNER JOIN mentor_pays AS mp ON (mp.pid = g.a2)
+ INNER JOIN mentor_secteurs AS ms ON (ms.uid = mp.uid)
+ WHERE ms.secteur = {?} $where
+ GROUP BY a2
+ ORDER BY pays", $sect, $ssect);
+ $page->assign('list', $it);
+ }
+
+ function handler_p_usage(&$page)
+ {
+ $page->changeTpl('profile/nomusage.tpl');
+
+ require_once 'validations.inc.php';
+ require_once 'xorg.misc.inc.php';
+
+ $res = XDB::query(
+ "SELECT u.nom, u.nom_usage, u.flags, e.alias
+ FROM auth_user_md5 AS u
+ LEFT JOIN aliases AS e ON(u.user_id = e.id
+ AND FIND_IN_SET('usage', e.flags))
+ WHERE user_id={?}", S::v('uid'));
+
+ list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
+ $flags = new flagset($flags);
+ $page->assign('usage_old', $usage_old);
+ $page->assign('alias_old', $alias_old);
+
+ $nom_usage = replace_accent(trim(Env::v('nom_usage')));
+ $nom_usage = strtoupper($nom_usage);
+ $page->assign('usage_req', $nom_usage);
+
+ if (Env::has('submit') && ($nom_usage != $usage_old)) {
+ // on vient de recevoir une requete, differente de l'ancien nom d'usage
+ if ($nom_usage == $nom) {
+ $page->assign('same', true);
+ } else { // le nom de mariage est distinct du nom à l'X
+ // on calcule l'alias pour l'afficher
+ $reason = Env::v('reason');
+ if ($reason == 'other') {
+ $reason = Env::v('other_reason');
+ }
+ $myusage = new UsageReq(S::v('uid'), $nom_usage, $reason);
+ $myusage->submit();
+ $page->assign('myusage', $myusage);
+ }
+ }
+ }
+
+ function handler_xnet(&$page)
+ {
+ $page->changeTpl('profile/groupesx.tpl');
+ $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
+
+ $req = XDB::query('
+ SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
+ COUNT(e.eid) AS events, mail_domain AS lists
+ FROM groupex.membres AS m
+ INNER JOIN groupex.asso AS a ON(m.asso_id = a.id)
+ LEFT JOIN groupex.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0)
+ WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S::i('uid'));
+ $page->assign('assos', $req->fetchAllAssoc());
+ }
+
+ function handler_vcard(&$page, $x = null)
+ {
+ if (is_null($x)) {
+ return PL_NOT_FOUND;
+ }
+
+ global $globals;
+
+ if (substr($x, -4) == '.vcf') {
+ $x = substr($x, 0, strlen($x) - 4);
+ }
+
+ $vcard = new VCard($x);
+ $vcard->do_page($page);
+ }
+
+ function handler_admin_trombino(&$page, $uid = null, $action = null) {
+ $page->changeTpl('profile/admin_trombino.tpl');
+ $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
+ $page->assign('uid', $uid);
+
+ $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_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);
+ $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'));
+ } 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);
+ }
+ }
+ $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid);
+ $page->assign('grades', $res);
+ }