X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=e1c70c00abb0acb17879e3d2f213427b15017618;hb=d4c08d89b8fb6cd94f2813eb228fe8a0d133a3aa;hp=3e0e4135b2fef6630b16e405fd686962be2d6aa3;hpb=83ff52812c6ba2904453650bc3e665ef1462f58c;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 3e0e413..e1c70c0 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -1,6 +1,6 @@ $this->make_hook('ref_country', AUTH_COOKIE, 'user', NO_AUTH), 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE), + 'groupes-x/logo' => $this->make_hook('xnetlogo', AUTH_PUBLIC), 'vcard' => $this->make_hook('vcard', AUTH_COOKIE, 'user', NO_HTTPS), 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), @@ -88,36 +89,16 @@ class ProfileModule extends PLModule } // Retrieve the photo and its mime type. - $photo_data = null; - $photo_type = null; - if ($req && S::logged()) { include 'validations.inc.php'; $myphoto = PhotoReq::get_request($user->id()); - if ($myphoto) { - $photo_data = $myphoto->data; - $photo_type = $myphoto->mimetype; - } + $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype); } else { - $res = XDB::query( - "SELECT attachmime, attach, pub - FROM photo - WHERE uid = {?}", $user->id()); - list($photo_type, $photo_data, $photo_pub) = $res->fetchOneRow(); - if ($photo_pub != 'public' && !S::logged()) { - $photo_type = $photo_data = null; - } + $photo = $user->profile()->getPhoto(true); } // Display the photo, or a default one when not available. - if ($photo_type && $photo_data != null) { - header('Content-type: image/' . $photo_type); - echo $photo_data; - } else { - header('Content-type: image/png'); - echo file_get_contents(dirname(__FILE__).'/../htdocs/images/none.png'); - } - exit; + $photo->send(); } function handler_medal(&$page, $mid) @@ -132,8 +113,7 @@ class ProfileModule extends PLModule $img = $thumb ? dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() : dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell(); - $type = mime_content_type($img); - header("Content-Type: $type"); + pl_cached_content_headers(mime_content_type($img)); echo file_get_contents($img); exit; } @@ -205,6 +185,7 @@ class ProfileModule extends PLModule WHERE user_id = {?} AND type="photo"', S::v('uid')); $globals->updateNbValid(); + $page->trigSuccess("Ta photo a bien été supprimée. Elle ne sera plus visible sur le site dans au plus une heure."); } elseif (Env::v('cancel')) { S::assert_xsrf_token(); @@ -335,7 +316,7 @@ class ProfileModule extends PLModule if (!$user->ax_id) { $page->kill("Le matricule AX de {$user->hrid()} est inconnu"); } - http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=" . $user->ax_id); + http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&ancc_id=" . $user->ax_id); } function handler_p_edit(&$page, $user = null, $opened_tab = null, $mode = null, $success = null) @@ -360,8 +341,8 @@ class ProfileModule extends PLModule // Build the page $page->addJsLink('ajax.js'); - $page->addJsLink('education.js'); - $page->addJsLink('grades.js'); + $page->addJsLink('education.js'); /* dynamic content */ + $page->addJsLink('grades.js'); /* dynamic content */ $page->addJsLink('profile.js'); $page->addJsLink('jquery.autocomplete.js'); $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true, false); @@ -390,22 +371,14 @@ class ProfileModule extends PLModule function handler_education_js(&$page) { - header('Content-Type: text/javascript; charset=utf-8'); - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: no-cache, must-revalidate'); - header('Pragma: no-cache'); + pl_cached_content_headers("text/javascript", "utf-8"); $page->changeTpl('profile/education.js.tpl', NO_SKIN); - require_once "education.func.inc.php"; + require_once 'education.func.inc.php'; } function handler_grades_js(&$page) { - header('Content-Type: text/javascript; charset=utf-8'); - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: no-cache, must-revalidate'); - header('Pragma: no-cache'); + pl_cached_content_headers("text/javascript", "utf-8"); $page->changeTpl('profile/grades.js.tpl', NO_SKIN); $res = XDB::iterator("SELECT * FROM profile_medals_grades @@ -428,7 +401,7 @@ class ProfileModule extends PLModule function handler_ajax_address(&$page, $id) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('profile/adresses.address.tpl', NO_SKIN); $page->assign('i', $id); $page->assign('address', array()); @@ -436,7 +409,7 @@ class ProfileModule extends PLModule function handler_ajax_tel(&$page, $prefid, $prefname, $telid) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('profile/phone.tpl', NO_SKIN); $page->assign('prefid', $prefid); $page->assign('prefname', $prefname); @@ -459,7 +432,7 @@ class ProfileModule extends PLModule function handler_ajax_medal(&$page, $id) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('profile/deco.medal.tpl', NO_SKIN); $page->assign('id', $id); $page->assign('medal', array('valid' => 0, 'grade' => 0)); @@ -467,7 +440,7 @@ class ProfileModule extends PLModule function handler_ajax_job(&$page, $id) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('profile/jobs.job.tpl', NO_SKIN); $page->assign('i', $id); $page->assign('job', array()); @@ -481,7 +454,7 @@ class ProfileModule extends PLModule function handler_ajax_sector(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $res = XDB::iterator("SELECT id, name, FIND_IN_SET('optgroup', flags) AS optgroup FROM profile_job_subsector_enum WHERE sectorid = {?}", $sect); @@ -527,7 +500,7 @@ class ProfileModule extends PLModule function handler_ajax_skill(&$page, $cat, $id) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('profile/skill.skill.tpl', NO_SKIN); $page->assign('cat', $cat); $page->assign('id', $id); @@ -667,13 +640,11 @@ class ProfileModule extends PLModule $page->setTitle('Conseil Pro'); + require_once "directory.enums.inc.php"; + // Retrieval of sector names - $res = XDB::iterRow("SELECT id, name AS label - FROM profile_job_sector_enum"); + $sectors = DirEnum::getOptionsArray(DirEnum::SECTORS); $sectors[''] = ''; - while (list($tmp_id, $tmp_label) = $res->next()) { - $sectors[$tmp_id] = $tmp_label; - } $page->assign_by_ref('sectors', $sectors); // nb de mentors @@ -681,44 +652,25 @@ class ProfileModule extends PLModule $page->assign('mentors_number', $res->fetchOneCell()); // On vient d'un formulaire - $where = array(); - $pays_sel = XDB::escape(Env::v('pays_sel')); - $sectorSelection = XDB::escape(Env::v('sector')); - $subSectorSelection = XDB::escape(Env::v('subSector')); - $expertise_champ = XDB::escape(Env::v('expertise')); - - if ($pays_sel != "''") { - $where[] = "mp.country = $pays_sel"; - } - if ($sectorSelection != "''") { - $where[] = "ms.sectorid = " . $sectorSelection; - if ($subSectorSelection != "''") { - $where[] = "ms.subsectorid = " . $subSectorSelection; - } - } - if ($expertise_champ != "''") { - $where[] = "MATCH(m.expertise) AGAINST($expertise_champ)"; - } - - if ($where) { - $where = join(' AND ', $where); - - $set = new UserSet("INNER JOIN profile_mentor AS m ON (m.uid = u.user_id) - LEFT JOIN profile_mentor_country AS mp ON (mp.uid = m.uid) - LEFT JOIN profile_mentor_sector AS ms ON (ms.uid = m.uid)", - $where); + require_once 'ufbuilder.inc.php'; + $ufb = new UFB_MentorSearch(); + if (!$ufb->isEmpty()) { + require_once 'userset.inc.php'; + $ufc = $ufb->getUFC(); + $set = new ProfileSet($ufc); $set->addMod('mentor', 'Référents'); $set->apply('referent/search', $page, $action, $subaction); if ($set->count() > 100) { $page->assign('recherche_trop_large', true); } } + $page->changeTpl('profile/referent.tpl'); } function handler_ref_sect(&$page, $sect) { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('include/field.select.tpl', NO_SKIN); $page->assign('onchange', 'setSSectors()'); $page->assign('id', 'ssect_field'); @@ -731,7 +683,7 @@ class ProfileModule extends PLModule function handler_ref_country(&$page, $sect, $ssect = '') { - header('Content-Type: text/html; charset=utf-8'); + pl_content_headers("text/html"); $page->changeTpl('include/field.select.tpl', NO_SKIN); $page->assign('name', 'pays_sel'); $where = ($ssect ? ' AND ms.subsectorid = {?}' : ''); @@ -753,13 +705,35 @@ class ProfileModule extends PLModule $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) + FROM group_members AS m + INNER JOIN groups AS a ON(m.asso_id = a.id) + LEFT JOIN group_events 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_xnetlogo(&$page, $id) + { + if (is_null($id)) { + return PL_NOT_FOUND; + } + + $res = XDB::query('SELECT logo, logo_mime + FROM groups + WHERE id = {?}', $id); + list($logo, $logo_mime) = $res->fetchOneRow(); + + if (!empty($logo)) { + pl_cached_dynamic_content_headers($logo_mime); + echo $logo; + } else { + pl_cached_dynamic_content_headers("image/jpeg"); + readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg'); + } + + exit; + } + function handler_vcard(&$page, $x = null) { if (is_null($x)) { @@ -789,10 +763,9 @@ class ProfileModule extends PLModule switch ($action) { case "original": - header("Content-type: image/jpeg"); + pl_cached_content_headers("image/jpeg"); readfile("/home/web/trombino/photos" . $user->promo() . "/" . $user->login() . ".jpg"); exit; - break; case "new": S::assert_xsrf_token();