X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprofile.php;h=f32a683f20b5d6e9036fbf4a5507d232db994c5c;hb=2ce6d1a63b8a0943937aac9ee21a71ccb35b7c96;hp=906ffe865ee87d175cc563133f141101f9fb14dd;hpb=924231449d16c87d373b7cce27efcf787ee3dcbc;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 906ffe8..f32a683 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -29,6 +29,7 @@ class ProfileModule extends PLModule 'fiche.php' => $this->make_hook('fiche', AUTH_PUBLIC), 'profile' => $this->make_hook('profile', AUTH_PUBLIC), + 'profile/private' => $this->make_hook('profile', AUTH_COOKIE), 'profile/edit' => $this->make_hook('p_edit', AUTH_MDP), 'profile/orange' => $this->make_hook('p_orange', AUTH_MDP), 'profile/usage' => $this->make_hook('p_usage', AUTH_MDP), @@ -190,6 +191,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); @@ -235,7 +238,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') @@ -244,19 +247,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); @@ -461,7 +479,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) @@ -582,7 +600,6 @@ class ProfileModule extends PLModule require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; - require_once 'diogenes/diogenes.flagset.inc.php'; $res = XDB::query( "SELECT u.nom, u.nom_usage, u.flags, e.alias @@ -630,7 +647,7 @@ class ProfileModule extends PLModule $this->promo = $promo = intval($promo); - if ($promo >= 1900 && $promo < intval(date('Y')) + if ($promo >= 1900 && ($promo < intval(date('Y')) || ($promo == intval(date('Y')) && intval(date('m')) >= 9)) || ($promo == -1 && S::has_perms())) { $trombi = new Trombi(array($this, '_trombi_getlist')); @@ -642,14 +659,32 @@ class ProfileModule extends PLModule } } + function vcard_escape($text) + { + return preg_replace('/[,;]/', '\\\\$0', $text); + } + function format_adr($params, &$smarty) { // $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->vcard_text_encode(';;' + . $this->vcard_escape($adr) . ';' + . $this->vcard_escape($city) . ';' + . $this->vcard_escape($region) . ';' + . $this->vcard_escape($postcode) . ';' + . $this->vcard_escape($country), false); + } + + function vcard_text_encode($text, $escape = true) + { + if ($escape) { + $text = $this->vcard_escape($text); + } + return str_replace("\n", "\\n", $text); //implode('\n', explode("\n", $text)); } function handler_vcard(&$page, $x = null) @@ -668,11 +703,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('vcard_enc', array($this, 'vcard_text_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( @@ -687,13 +726,22 @@ class ProfileModule extends PLModule $user['forlife'].'@'.$globals->mail->domain2); $user['virtualalias'] = $res->fetchOneCell(); - - $page->assign_by_ref('vcard', $user); + + // get photo + $res = XDB::query( + "SELECT attach, attachmime + 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->fetchOneAssoc(); + } + $page->assign('users', array($user)); header("Pragma: "); header("Cache-Control: "); - header("Content-type: text/x-vcard\n"); - header("Content-Transfer-Encoding: Quoted-Printable\n"); + header("Content-type: text/x-vcard; charset=iso-8859-15"); + header("Content-Transfer-Encoding: 8bit"); } function handler_admin_trombino(&$page, $uid = null, $action = null) { @@ -734,7 +782,6 @@ class ProfileModule extends PLModule $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'); @@ -743,7 +790,6 @@ class ProfileModule extends PLModule $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'); @@ -753,7 +799,6 @@ class ProfileModule extends PLModule $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'); @@ -763,7 +808,6 @@ class ProfileModule extends PLModule $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');