Various (minor) fixes on jobterms.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 13 Sep 2010 09:49:39 +0000 (11:49 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 13 Sep 2010 09:50:00 +0000 (11:50 +0200)
More comments, bug fixed too.

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/profile.php
classes/userfilter.php
modules/search.php

index d6763a4..8ec98b9 100644 (file)
@@ -412,7 +412,7 @@ class Profile
         return $this->visibility->isVisible($visibility);
     }
 
-    /** Stores the list of fields which have already been fetched for this Profile
+    /** Stores the list of fields which have already fetched for this Profile
      */
     public function setFetchedFields($fields)
     {
@@ -423,10 +423,12 @@ class Profile
         $this->fetched_fields = $fields;
     }
 
+    /** Have we already fetched this field ?
+     */
     private function fetched($field)
     {
-        if (($fields | self::FETCH_ALL) != self::FETCH_ALL) {
-            Platal::page()->kill("Invalid fetched fields: $fields");
+        if (!array_key_exists($field, ProfileField::$fields)) {
+            Platal::page()->kill("Invalid field: $field");
         }
 
         return ($this->fetched_fields & $field);
@@ -456,6 +458,7 @@ class Profile
      */
     private function consolidateFields()
     {
+        // Link phones to addresses
         if ($this->phones != null) {
             if ($this->addresses != null) {
                 $this->addresses->addPhones($this->phones);
@@ -466,9 +469,12 @@ class Profile
             }
         }
 
+        // Link addresses to jobs
         if ($this->addresses != null && $this->jobs != null) {
             $this->jobs->addAddresses($this->addresses);
         }
+
+        // Link jobterms to jobs
         if ($this->jobs != null && $this->jobterms != null) {
             $this->jobs->addJobTerms($this->jobterms);
         }
index 050c663..743ff44 100644 (file)
@@ -1025,7 +1025,7 @@ class UFC_Job_Terms implements UserFilterCondition
         $sub = $uf->addJobTermsFilter(count($this->val));
         $conditions = array();
         foreach ($this->val as $i => $jtid) {
-            $conditions[] = $sub[$i] . ' = ' . XDB::escape($jtid);
+            $conditions[] = $sub[$i] . '.jtid_1 = ' . XDB::escape($jtid);
         }
         $jsub = $uf->addJobFilter();
         $conditions[] = $uf->getVisibilityCondition($jsub . '.pub');
@@ -2652,14 +2652,13 @@ class UserFilter extends PlFilter
      * Adds a filter on job terms of profile.
      * @param $nb the number of job terms to use
      * @return an array of the fields to filter (one for each term).
-     * Code using this function should used returned field as is (contains table and field name).
      */
     public function addJobTermsFilter($nb = 1)
     {
         $this->with_pjt = $nb;
         $jobtermstable = array();
         for ($i = 1; $i <= $nb; ++$i) {
-            $jobtermstable[] = 'pjtr_'.$i.'.jtid_1';
+            $jobtermstable[] = 'pjtr_'.$i;
         }
         return $jobtermstable;
     }
index c4f90a6..b55348e 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),
         );
     }
@@ -348,13 +348,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()) {