From 4ec03752ab489b6414915b98a459db4bbc5dc95d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 13 Sep 2010 11:49:39 +0200 Subject: [PATCH] Various (minor) fixes on jobterms. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit More comments, bug fixed too. Signed-off-by: Raphaël Barrois --- classes/profile.php | 12 +++++++++--- classes/userfilter.php | 5 ++--- modules/search.php | 10 +++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index d6763a4..8ec98b9 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -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); } diff --git a/classes/userfilter.php b/classes/userfilter.php index 050c663..743ff44 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -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; } diff --git a/modules/search.php b/modules/search.php index c4f90a6..b55348e 100644 --- a/modules/search.php +++ b/modules/search.php @@ -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()) { -- 2.1.4