X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=70686239a7db0cb6e92e99c5260f65e627bdb893;hb=8b1f8e12d444062ef63a0db3a8fa94582a9778c3;hp=14f22504f80aea9c46f4ad17b8113d9a47511cfa;hpb=7cca6eec5b6395c8e60d6638dec0acd8be20e631;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 14f2250..7068623 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), @@ -37,6 +38,7 @@ class ProfileModule extends PLModule 'referent/search' => $this->make_hook('ref_search', AUTH_COOKIE), 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE), 'vcard' => $this->make_hook('vcard', AUTH_COOKIE), 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), @@ -114,7 +116,7 @@ class ProfileModule extends PLModule function handler_photo_change(&$page) { - $page->changeTpl('trombino.tpl'); + $page->changeTpl('profile/trombino.tpl'); require_once('validations.inc.php'); @@ -167,7 +169,7 @@ class ProfileModule extends PLModule global $globals; require_once 'user.func.inc.php'; - $page->changeTpl('fiche.tpl', SIMPLE); + $page->changeTpl('profile/fiche.tpl', SIMPLE); $view = 'private'; if (!S::logged() || Env::v('view') == 'public') $view = 'public'; @@ -185,11 +187,25 @@ class ProfileModule extends PLModule } if (empty($login)) { + if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) { + $matches = str_replace('-', '_', $matches); + $res = XDB::query("SELECT user_id + FROM auth_user_md5 + WHERE prenom LIKE {?} AND nom LIKE {?} AND promo = {?} + AND perms = 'pending'", + $matches[1], $matches[2], $matches[3]); + if ($res->numRows() == 1) { + $uid = $res->fetchOneCell(); + pl_redirect('marketing/public/' . $uid); + } + } return PL_NOT_FOUND; } $new = Env::v('modif') == 'new'; $user = get_user_details($login, S::v('uid'), $view); + require_once('url_catcher.inc.php'); + $user['freetext'] = url_catcher($user['freetext'], false); $title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage']; $page->assign('xorg_title', $title); @@ -242,7 +258,7 @@ class ProfileModule extends PLModule { global $globals; - $page->changeTpl('profil.tpl'); + $page->changeTpl('profile/edit.tpl'); $page->addCssLink('profil.css'); $page->assign('xorg_title', 'Polytechnique.org - Mon Profil'); @@ -251,12 +267,26 @@ class ProfileModule extends PLModule 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); + $mmlist = new MMList(S::v('uid'), S::v('password')); + $mmlist->subscribe("promo".S::v('promo')); + } if (is_ax_key_missing()) { $page->assign('no_private_key', true); @@ -310,7 +340,7 @@ class ProfileModule extends PLModule if($page->nb_errs()) { require_once "profil/assign_{$opened_tab}.inc.php"; $page->assign('onglet', $opened_tab); - $page->assign('onglet_tpl', "profil/$opened_tab.tpl"); + $page->assign('onglet_tpl', "profile/$opened_tab.tpl"); return; } @@ -331,7 +361,7 @@ class ProfileModule extends PLModule // mise a jour des champs relatifs au tab ouvert require_once "profil/update_{$opened_tab}.inc.php"; - $log =& S::v('log'); + $log =& $_SESSION['log']; $log->log('profil', $opened_tab); $page->assign('etat_update', 'ok'); } @@ -345,14 +375,14 @@ class ProfileModule extends PLModule require_once "profil/assign_{$opened_tab}.inc.php"; $page->assign('onglet', $opened_tab); - $page->assign('onglet_tpl', "profil/$opened_tab.tpl"); + $page->assign('onglet_tpl', "profile/$opened_tab.tpl"); return; } function handler_p_orange(&$page) { - $page->changeTpl('orange.tpl'); + $page->changeTpl('profile/orange.tpl'); require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; @@ -408,7 +438,7 @@ class ProfileModule extends PLModule return PL_NOT_FOUND; } - $page->changeTpl('fiche_referent.tpl', SIMPLE); + $page->changeTpl('profile/fiche_referent.tpl', SIMPLE); $res = XDB::query( "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias @@ -466,7 +496,7 @@ class ProfileModule extends PLModule function handler_ref_search(&$page) { - $page->changeTpl('referent.tpl'); + $page->changeTpl('profile/referent.tpl'); $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro'); @@ -578,11 +608,10 @@ class ProfileModule extends PLModule function handler_p_usage(&$page) { - $page->changeTpl('nomusage.tpl'); + $page->changeTpl('profile/nomusage.tpl'); require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; - require_once dirname(__FILE__).'/../classes/Flagset.php'; $res = XDB::query( "SELECT u.nom, u.nom_usage, u.flags, e.alias @@ -619,9 +648,7 @@ class ProfileModule extends PLModule function handler_trombi(&$page, $promo = null) { - require_once 'trombi.inc.php'; - - $page->changeTpl('trombipromo.tpl'); + $page->changeTpl('profile/trombipromo.tpl'); $page->assign('xorg_title', 'Polytechnique.org - Trombi Promo'); if (is_null($promo)) { @@ -630,7 +657,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,16 +669,21 @@ class ProfileModule extends PLModule } } - function format_adr($params, &$smarty) + function handler_xnet(&$page) { - // $adr1, $adr2, $adr3, $postcode, $city, $region, $country - extract($params['adr']); - $adr = $adr1; - $adr = trim("$adr\n$adr2"); - $adr = trim("$adr\n$adr3"); - return quoted_printable_encode(";;$adr;$city;$region;$postcode;$country"); + $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)) { @@ -664,40 +696,13 @@ class ProfileModule extends PLModule $x = substr($x, 0, strlen($x) - 4); } - $page->changeTpl('vcard.tpl', NO_SKIN); - require_once 'xorg.misc.inc.php'; - require_once 'user.func.inc.php'; - - $page->register_modifier('qp_enc', 'quoted_printable_encode'); - $page->register_function('format_adr', array($this, 'format_adr')); - - $login = get_user_forlife($x); - $user = get_user_details($login); - - // alias virtual - $res = XDB::query( - "SELECT alias - FROM virtual - INNER JOIN virtual_redirect USING(vid) - INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' ) - WHERE ( redirect={?} OR redirect={?} ) - AND alias LIKE '%@{$globals->mail->alias_dom}'", - S::v('uid'), - $user['forlife'].'@'.$globals->mail->domain, - $user['forlife'].'@'.$globals->mail->domain2); - - $user['virtualalias'] = $res->fetchOneCell(); - - $page->assign_by_ref('vcard', $user); - - header("Pragma: "); - header("Cache-Control: "); - header("Content-type: text/x-vcard\n"); - header("Content-Transfer-Encoding: Quoted-Printable\n"); + require_once('vcard.inc.php'); + $vcard = new VCard($x); + $vcard->do_page($page); } function handler_admin_trombino(&$page, $uid = null, $action = null) { - $page->changeTpl('admin/admin_trombino.tpl'); + $page->changeTpl('profile/admin_trombino.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Trombino'); $page->assign('uid', $uid); @@ -734,7 +739,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 +747,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 +756,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 +765,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'); @@ -771,7 +772,7 @@ class ProfileModule extends PLModule $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'); + $page->changeTpl('profile/admin_decos.tpl'); $mid = $id;