Prevents warnings in flags template.
[platal.git] / modules / profile.php
index f38fbfd..fb62e72 100644 (file)
@@ -52,9 +52,6 @@ class ProfileModule extends PLModule
             'profile/name_info'          => $this->make_hook('name_info',                  AUTH_PUBLIC),
 
             'referent'                   => $this->make_hook('referent',                   AUTH_COOKIE),
-            'emploi'                     => $this->make_hook('ref_search',                 AUTH_COOKIE),
-            'jobs'                       => $this->make_hook('ref_search',                 AUTH_COOKIE),
-            'referent/search'            => $this->make_hook('ref_search',                 AUTH_COOKIE),
             'referent/ssect'             => $this->make_hook('ref_sect',                   AUTH_COOKIE, 'user', NO_AUTH),
             'referent/country'           => $this->make_hook('ref_country',                AUTH_COOKIE, 'user', NO_AUTH),
             'referent/autocomplete'      => $this->make_hook('ref_autocomplete',           AUTH_COOKIE, 'user', NO_AUTH),
@@ -256,9 +253,9 @@ class ProfileModule extends PLModule
         $page->changeTpl('profile/profile.tpl', SIMPLE);
 
         // Determines the access level at which the profile will be displayed.
-        if (!S::logged() || Env::v('view') == 'public') {
+        if (!S::logged() || !S::user()->checkPerms('directory_ax') || Env::v('view') == 'public') {
             $view = 'public';
-        } else if (S::logged() && Env::v('view') == 'ax') {
+        } else if (!S::user()->checkPerms('directory_private') || Env::v('view') == 'ax') {
             $view = 'ax';
         } else {
             $view = 'private';
@@ -332,11 +329,15 @@ class ProfileModule extends PLModule
         $this->load('page.inc.php');
         $wiz->addPage('ProfileSettingGeneral', 'Général', 'general');
         $wiz->addPage('ProfileSettingAddresses', 'Adresses personnelles', 'adresses');
-        $wiz->addPage('ProfileSettingGroups', 'Groupes X - Binets', 'poly');
-        $wiz->addPage('ProfileSettingDecos', 'Décorations - Medailles', 'deco');
         $wiz->addPage('ProfileSettingJobs', 'Informations professionnelles', 'emploi');
-        $wiz->addPage('ProfileSettingSkills', 'Compétences diverses', 'skill');
-        $wiz->addPage('ProfileSettingMentor', 'Mentoring', 'mentor');
+        if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
+            $wiz->addPage('ProfileSettingGroups', 'Groupes X - Binets', 'poly');
+        }
+        $wiz->addPage('ProfileSettingDecos', 'Décorations - Medailles', 'deco');
+        if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
+            $wiz->addPage('ProfileSettingSkills', 'Compétences diverses', 'skill');
+            $wiz->addPage('ProfileSettingMentor', 'Mentoring', 'mentor');
+        }
         $wiz->apply($page, 'profile/edit/' . $profile->hrid(), $opened_tab, $mode);
 
         if (!$profile->birthdate) {
@@ -578,36 +579,6 @@ class ProfileModule extends PLModule
         $page->addJsLink('close_on_esc.js');
     }
 
-    function handler_ref_search(&$page, $action = null, $subaction = null)
-    {
-        $wp = new PlWikiPage('Docs.Emploi');
-        $wp->buildCache();
-
-        $page->setTitle('Emploi et Carrières');
-
-        // nb de mentors
-        $res = XDB::query("SELECT count(distinct pid) FROM profile_mentor_term");
-        $page->assign('mentors_number', $res->fetchOneCell());
-
-        $page->addJsLink('jquery.autocomplete.js');
-
-        // On vient d'un formulaire
-        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)
     {
         pl_content_headers("text/html");
@@ -687,7 +658,7 @@ class ProfileModule extends PLModule
         $joins = JobTerms::token_join_query($tokens, 'e');
         if ($type == 'mentor') {
             $count = ', COUNT(DISTINCT pid) AS nb';
-            $countjoin = ' LEFT JOIN  profile_job_term_relation AS r ON(r.jtid_1 = e.jtid) LEFT JOIN  profile_mentor_term AS m ON(r.jtid_2 = m.jtid)';
+            $countjoin = ' INNER JOIN  profile_job_term_relation AS r ON(r.jtid_1 = e.jtid) INNER JOIN  profile_mentor_term AS m ON(r.jtid_2 = m.jtid)';
             $countorder = 'nb DESC, ';
         } else {
             $count = $countjoin = $countorder = '';