Fix admin/logger when the user has no entry in the aliases table.
[platal.git] / modules / search.php
index c4f90a6..5d474f5 100644 (file)
@@ -29,9 +29,9 @@ class SearchModule extends PLModule
             'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC),
             'search/autocomplete' => $this->make_hook('autocomplete',   AUTH_COOKIE, 'directory_ax', NO_AUTH),
             'search/list'         => $this->make_hook('list',           AUTH_COOKIE, 'directory_ax', NO_AUTH),
-            'jobs'                => $this->make_hook('referent',     AUTH_COOKIE),
-            'emploi'              => $this->make_hook('referent',     AUTH_COOKIE),
-            'referent/search'     => $this->make_hook('referent',     AUTH_COOKIE),
+            'jobs'                => $this->make_hook('referent',       AUTH_COOKIE),
+            'emploi'              => $this->make_hook('referent',       AUTH_COOKIE),
+            'referent/search'     => $this->make_hook('referent',       AUTH_COOKIE),
             'search/referent/countries' => $this->make_hook('referent_countries',     AUTH_COOKIE),
         );
     }
@@ -150,7 +150,6 @@ class SearchModule extends PLModule
     function handler_advanced(&$page, $model = null, $byletter = null)
     {
         global $globals;
-        require_once 'geocoding.inc.php';
         $page->assign('advanced',1);
         $page->addJsLink('jquery.autocomplete.js');
 
@@ -163,19 +162,24 @@ class SearchModule extends PLModule
 
             require_once 'userset.inc.php';
             $view = new SearchSet(false);
-            $view->addMod('minifiche', 'Mini-fiches', true, array('starts_with' => $byletter));
-            $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true));
-            // TODO: Reactivate when the new map is completed.
-            // $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
-            $view->apply('search/adv', $page, $model);
-
-            $nb_tot = $view->count();
-            if ($nb_tot > $globals->search->private_max) {
-                $this->form_prepare();
-                $page->trigError('Recherche trop générale.');
-            } else if ($nb_tot == 0) {
+            if (!$view->isValid()) {
                 $this->form_prepare();
-                $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !');
+                $page->trigError('Recherche invalide.');
+            } else {
+                $view->addMod('minifiche', 'Mini-fiches', true, array('starts_with' => $byletter));
+                $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true));
+                // TODO: Reactivate when the new map is completed.
+                // $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
+                $view->apply('search/adv', $page, $model);
+
+                $nb_tot = $view->count();
+                if ($nb_tot > $globals->search->private_max) {
+                    $this->form_prepare();
+                    $page->trigError('Recherche trop générale.');
+                } else if ($nb_tot == 0) {
+                    $this->form_prepare();
+                    $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !');
+                }
             }
         }
 
@@ -308,9 +312,6 @@ class SearchModule extends PLModule
           case 'section':
             $ids = DirEnum::getOptionsIter(DirEnum::SECTIONS);
             break;
-          case 'secteur':
-            $ids = DirEnum::getOptionsIter(DirEnum::SECTORS);
-            break;
           case 'jobterm':
             if (Env::has('jtid')) {
                 JobTerms::ajaxGetBranch(&$page, JobTerms::ONLY_JOBS);
@@ -348,13 +349,13 @@ class SearchModule extends PLModule
 
         $page->setTitle('Emploi et Carrières');
 
-        // nb de mentors
+        // Count 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
+        // Search for mentors matching filters
         require_once 'ufbuilder.inc.php';
         $ufb = new UFB_MentorSearch();
         if (!$ufb->isEmpty()) {