X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=795c99de88b2b41d43a272bd80caf2e9c80b4853;hb=3845b13170e776ed0a52943edd22f8e866aec4df;hp=22513ecfe499d299976cb572d663e9a0e5cf4ccb;hpb=089a5801075ffba573c547f1283d42d87065b5e4;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 22513ec..795c99d 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -39,6 +39,12 @@ class ProfileModule extends PLModule 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), 'vcard' => $this->make_hook('vcard', AUTH_COOKIE), + 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), + 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP, 'admin'), + 'admin/formations' => $this->make_hook('admin_formations', AUTH_MDP, 'admin'), + 'admin/groupes-x' => $this->make_hook('admin_groupesx', AUTH_MDP, 'admin'), + 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), + ); } @@ -184,6 +190,8 @@ class ProfileModule extends PLModule $new = Env::v('modif') == 'new'; $user = get_user_details($login, S::v('uid'), $view); + $user['freetext'] = preg_replace('/((?:https?|ftp):\/\/(?:&|\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i', + '\\0', $user['freetext']); $title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage']; $page->assign('xorg_title', $title); @@ -229,7 +237,7 @@ class ProfileModule extends PLModule $user['forlife'].'@'.$globals->mail->domain2); $page->assign('virtualalias', $res->fetchOneCell()); - $page->addJsLink('javascript/close_on_esc.js'); + $page->addJsLink('close_on_esc.js'); } function handler_p_edit(&$page, $opened_tab = 'general') @@ -238,19 +246,34 @@ class ProfileModule extends PLModule $page->changeTpl('profil.tpl'); - $page->addCssLink('css/profil.css'); + $page->addCssLink('profil.css'); $page->assign('xorg_title', 'Polytechnique.org - Mon Profil'); require_once 'tabs.inc.php'; require_once 'profil.func.inc.php'; require_once 'synchro_ax.inc.php'; - if (Post::has('register_from_ax_question')) { - XDB::query('UPDATE auth_user_quick + if (Post::v('register_from_ax_question')) { + XDB::execute('UPDATE auth_user_quick SET profile_from_ax = 1 WHERE user_id = {?}', S::v('uid')); } + if (Post::v('add_to_nl')) { + require_once 'newsletter.inc.php'; + subscribe_nl(); + } + if (Post::v('add_to_promo')) { + $r = XDB::query('SELECT id FROM groupex.asso WHERE diminutif = {?}', + S::v('promo')); + $asso_id = $r->fetchOneCell(); + XDB::execute('REPLACE INTO groupex.membres (uid,asso_id) + VALUES ({?}, {?})', + S::v('uid'), $asso_id); + require_once 'lists.inc.php'; + $client =& lists_xmlrpc(S::v('uid'), S::v('password')); + $client->subscribe("promo".S::v('promo')); + } if (is_ax_key_missing()) { $page->assign('no_private_key', true); @@ -455,7 +478,7 @@ class ProfileModule extends PLModule WHERE uid = {?}", $user_id); $page->assign('pays', $res->fetchColumn()); - $page->addJsLink('javascript/close_on_esc.js'); + $page->addJsLink('close_on_esc.js'); } function handler_ref_search(&$page) @@ -576,7 +599,7 @@ class ProfileModule extends PLModule require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; - require_once 'diogenes/diogenes.flagset.inc.php'; + require_once dirname(__FILE__).'/../classes/Flagset.php'; $res = XDB::query( "SELECT u.nom, u.nom_usage, u.flags, e.alias @@ -640,10 +663,18 @@ class ProfileModule extends PLModule { // $adr1, $adr2, $adr3, $postcode, $city, $region, $country extract($params['adr']); - $adr = $adr1; + $adr = trim($adr1); $adr = trim("$adr\n$adr2"); $adr = trim("$adr\n$adr3"); - return quoted_printable_encode(";;$adr;$city;$region;$postcode;$country"); + return $this->quoted_printable_encode(";;$adr;$city;$region;$postcode;$country"); + } + + function quoted_printable_encode($text) + { + return implode("\n", + array_map('trim', + explode("\n", + quoted_printable_encode($text)))); } function handler_vcard(&$page, $x = null) @@ -662,11 +693,15 @@ class ProfileModule extends PLModule require_once 'xorg.misc.inc.php'; require_once 'user.func.inc.php'; - $page->register_modifier('qp_enc', 'quoted_printable_encode'); + $page->register_modifier('qp_enc', array($this, 'quoted_printable_encode')); $page->register_function('format_adr', array($this, 'format_adr')); $login = get_user_forlife($x); $user = get_user_details($login); + + if (strlen(trim($user['freetext']))) { + $user['freetext'] = html_entity_decode($user['freetext']); + } // alias virtual $res = XDB::query( @@ -681,7 +716,16 @@ class ProfileModule extends PLModule $user['forlife'].'@'.$globals->mail->domain2); $user['virtualalias'] = $res->fetchOneCell(); - + + // get photo + $res = XDB::query( + "SELECT attach + FROM photo AS p + INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie') + WHERE a.alias = {?}", $login); + if ($res->numRows()) { + $user['photo'] = $res->fetchOneCell(); + } $page->assign_by_ref('vcard', $user); header("Pragma: "); @@ -689,6 +733,100 @@ class ProfileModule extends PLModule header("Content-type: text/x-vcard\n"); header("Content-Transfer-Encoding: Quoted-Printable\n"); } + + function handler_admin_trombino(&$page, $uid = null, $action = null) { + $page->changeTpl('admin/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) { + require_once('../classes/PLTableEditor.php'); + $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) { + require_once('../classes/PLTableEditor.php'); + $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_groupesx(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $page->assign('xorg_title','Polytechnique.org - Administration - Groupes X'); + $page->assign('title', 'Gestion des Groupes X'); + $table_editor = new PLTableEditor('admin/groupes-x','groupesx_def','id'); + $table_editor->add_join_table('groupesx_ins','gid',true); + $table_editor->describe('text','intitulé',true); + $table_editor->describe('url','site web',false); + $table_editor->apply($page, $action, $id); + } + function handler_admin_medals(&$page, $action = 'list', $id = null) { + require_once('../classes/PLTableEditor.php'); + $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->apply($page, $action, $id); + if ($id && $action == 'edit') { + $page->changeTpl('admin/gerer_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={?}', $_POST['pos'][$gid], $text, $gid); + } + } + $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); + $page->assign('grades', $res); + } + } } ?>