X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=efcd84dedfb1b2134bf3f20f52e8cabe0d117a72;hb=3eb25eb3c166163c6e86483e2e4e8330572ab2d1;hp=f32a683f20b5d6e9036fbf4a5507d232db994c5c;hpb=c9d116943fce4c39370be1d3df9d59cf05cb555f;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index f32a683..efcd84d 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -1,6 +1,6 @@ $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'), @@ -115,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'); @@ -123,15 +124,19 @@ class ProfileModule extends PLModule .'/'.S::v('forlife').'.jpg'; if (Env::has('upload')) { - $file = isset($_FILES['userfile']['tmp_name']) - ? $_FILES['userfile']['tmp_name'] - : Env::v('photo'); - if ($data = file_get_contents($file)) { - if ($myphoto = new PhotoReq(S::v('uid'), $data)) { + if (isset($_FILES['userfile']['tmp_name']) + && !is_uploaded_file($_FILES['userfile']['tmp_name'])) { + $page->trig('Une erreur s\'est produite lors du transfert du fichier'); + } else { + $file = is_uploaded_file($_FILES['userfile']['tmp_name']) + ? $_FILES['userfile']['tmp_name'] + : Env::v('photo'); + if ($data = file_get_contents($file)) { + $myphoto = new PhotoReq(S::v('uid'), $data); $myphoto->submit(); + } else { + $page->trig('Fichier inexistant ou vide'); } - } else { - $page->trig('Fichier inexistant ou vide'); } } elseif (Env::has('trombi')) { $myphoto = new PhotoReq(S::v('uid'), @@ -168,7 +173,7 @@ class ProfileModule extends PLModule global $globals; require_once 'user.func.inc.php'; - $page->changeTpl('fiche.tpl', SIMPLE); + $page->changeTpl('profile/profile.tpl', SIMPLE); $view = 'private'; if (!S::logged() || Env::v('view') == 'public') $view = 'public'; @@ -186,13 +191,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); - $user['freetext'] = preg_replace('/((?:https?|ftp):\/\/(?:&|\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i', - '\\0', $user['freetext']); + 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); @@ -245,7 +262,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'); @@ -271,9 +288,8 @@ class ProfileModule extends PLModule 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')); + $mmlist = new MMList(S::v('uid'), S::v('password')); + $mmlist->subscribe("promo".S::v('promo')); } if (is_ax_key_missing()) { @@ -328,7 +344,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; } @@ -349,7 +365,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'); } @@ -363,14 +379,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'; @@ -426,7 +442,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 @@ -484,7 +500,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'); @@ -596,7 +612,7 @@ 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'; @@ -636,9 +652,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)) { @@ -659,34 +673,21 @@ 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 = trim($adr1); - $adr = trim("$adr\n$adr2"); - $adr = trim("$adr\n$adr3"); - 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) + function handler_xnet(&$page) { - if ($escape) { - $text = $this->vcard_escape($text); - } - return str_replace("\n", "\\n", $text); //implode('\n', explode("\n", $text)); + $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)) { @@ -699,53 +700,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('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( - "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(); - - // 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; charset=iso-8859-15"); - header("Content-Transfer-Encoding: 8bit"); + 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); @@ -813,9 +774,10 @@ class ProfileModule extends PLModule $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('admin/gerer_decos.tpl'); + $page->changeTpl('profile/admin_decos.tpl'); $mid = $id;