Take directory_* permissions into account when accessing a profile.
[platal.git] / modules / profile.php
index f38fbfd..d7cd55f 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';
@@ -578,36 +575,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 +654,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 = '';