Commit | Line | Data |
---|---|---|
09824164 | 1 | <?php |
2 | /*************************************************************************** | |
5e1513f6 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
09824164 | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
22 | class SearchModule extends PLModule | |
23 | { | |
24 | function handlers() | |
25 | { | |
26 | return array( | |
5ae3e9a9 SJ |
27 | 'search' => $this->make_hook('quick', AUTH_PUBLIC), |
28 | 'search/adv' => $this->make_hook('advanced', AUTH_COOKIE, 'directory_ax'), | |
29 | 'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC), | |
30 | 'search/autocomplete' => $this->make_hook('autocomplete', AUTH_COOKIE, 'directory_ax', NO_AUTH), | |
31 | 'search/list' => $this->make_hook('list', AUTH_COOKIE, 'directory_ax', NO_AUTH), | |
a67a14b4 | 32 | 'search/list/count' => $this->make_hook('list_count', AUTH_COOKIE, 'directory_ax', NO_AUTH), |
e5ceaa8c RB |
33 | 'jobs' => $this->make_hook('referent', AUTH_COOKIE, 'user'), |
34 | 'emploi' => $this->make_hook('referent', AUTH_COOKIE, 'user'), | |
35 | 'referent/search' => $this->make_hook('referent', AUTH_COOKIE, 'user'), | |
36 | 'search/referent/countries' => $this->make_hook('referent_countries', AUTH_COOKIE, 'user'), | |
09824164 | 37 | ); |
38 | } | |
39 | ||
26ba053e | 40 | function handler_redir_advanced($page, $mode = null) |
ba2afb88 | 41 | { |
42 | pl_redirect('search/adv'); | |
43 | exit; | |
44 | } | |
45 | ||
09824164 | 46 | function form_prepare() |
47 | { | |
d7610c35 | 48 | Platal::page()->assign('formulaire',1); |
3c640222 | 49 | } |
50 | ||
8eb6931f RB |
51 | /** |
52 | * $model: The way of presenting the results: minifiche, trombi, geoloc. | |
53 | * $byletter: Show only names beginning with this letter | |
54 | */ | |
26ba053e | 55 | function handler_quick($page, $model = null, $byletter = null) |
09824164 | 56 | { |
57 | global $globals; | |
58 | ||
8eb6931f | 59 | if (Env::has('quick') || $model == 'geoloc') { |
dd23c027 | 60 | $quick = Env::t('quick'); |
85bb670b | 61 | if (S::logged() && !Env::has('page')) { |
732e5855 | 62 | S::logger()->log('search', 'quick=' . $quick); |
e31c1c3e | 63 | } |
dd23c027 SJ |
64 | |
65 | if ($quick == '') { | |
66 | $page->trigWarning('Aucun critère de recherche n\'est spécifié.'); | |
67 | $page->changeTpl('search/index.tpl'); | |
68 | $page->setTitle('Annuaire'); | |
69 | $page->assign('formulaire', 1); | |
dd23c027 SJ |
70 | return; |
71 | } | |
72 | ||
383bcdec | 73 | $list = 'profile|prf|fiche|fic|referent|ref|mentor'; |
dd70cd28 | 74 | if (S::admin()) { |
383bcdec | 75 | $list .= '|admin|adm|ax'; |
76 | } | |
251ac585 FB |
77 | $suffixes = array_keys(DirEnum::getOptions(DirEnum::ACCOUNTTYPES)); |
78 | $suffixes = implode('|', $suffixes); | |
79 | if (preg_match('/^(' . $list . '):([-a-z]+(\.[-a-z]+(\.(?:[md]?\d{2,4}|' . $suffixes . '))?)?)$/', replace_accent($quick), $matches)) { | |
4514bea3 | 80 | $login = $matches[2]; |
383bcdec | 81 | switch($matches[1]) { |
82 | case 'admin': case 'adm': | |
83 | $base = 'admin/user/'; | |
84 | break; | |
85 | case 'ax': | |
86 | $base = 'profile/ax/'; | |
87 | break; | |
88 | case 'profile': case 'prf': case 'fiche': case 'fic': | |
89 | $base = 'profile/'; | |
90 | break; | |
91 | case 'referent': case 'ref': case 'mentor': | |
92 | $base = 'referent/'; | |
93 | break; | |
94 | } | |
7511200d | 95 | |
4514bea3 VZ |
96 | $user = User::getSilent($login); |
97 | if ($user) { | |
98 | pl_redirect($base . $user->login()); | |
7511200d | 99 | } |
ed06daba | 100 | Get::set('quick', $login); |
8fee4fbd | 101 | } elseif (strpos($quick, 'doc:') === 0) { |
102 | $url = 'Docs/Recherche?'; | |
103 | $url .= 'action=search&q=' . urlencode(substr($quick, 4)); | |
7511200d | 104 | $url .= '&group=' . urlencode('-Equipe,-Main,-PmWiki,-Site,-Review'); |
8fee4fbd | 105 | pl_redirect($url); |
85b45717 FB |
106 | } elseif (strpos($quick, 'trombi:') === 0) { |
107 | $promo = substr($quick, 7); | |
108 | $res = XDB::query("SELECT diminutif | |
109 | FROM groups | |
110 | WHERE cat = 'Promotions' AND diminutif = {?}", | |
111 | $promo); | |
112 | if ($res->numRows() == 0) { | |
113 | $page->trigWarning("La promotion demandée n'est pas valide: $promo"); | |
114 | } else { | |
115 | http_redirect('http://www.polytechnique.net/login/' . $promo . '/annuaire/trombi'); | |
116 | } | |
383bcdec | 117 | } |
8fee4fbd | 118 | |
09824164 | 119 | $page->assign('formulaire', 0); |
120 | ||
8c4a0c30 | 121 | require_once 'userset.inc.php'; |
78a47eb4 | 122 | $view = new QuickSearchSet(); |
8eb6931f | 123 | $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter)); |
6bcd8813 | 124 | $view->addMod('map', 'Planisphère'); |
35fa92e8 | 125 | if (S::logged() && !Env::i('nonins')) { |
126 | $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true)); | |
35fa92e8 | 127 | } |
8eb6931f | 128 | $view->apply('search', $page, $model); |
09824164 | 129 | |
8c4a0c30 | 130 | $nb_tot = $view->count(); |
e35882be | 131 | $page->assign('search_results_nb', $nb_tot); |
cab08090 | 132 | if (!S::logged() && $nb_tot > $globals->search->public_max) { |
825a13a4 | 133 | $page->trigError('Votre recherche a généré trop de résultats pour un affichage public.'); |
09824164 | 134 | } elseif ($nb_tot > $globals->search->private_max) { |
825a13a4 | 135 | $page->trigError('Recherche trop générale. Une <a href="search/adv">recherche avancée</a> permet de préciser la recherche.'); |
09824164 | 136 | } elseif (empty($nb_tot)) { |
825a13a4 | 137 | $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !'); |
09824164 | 138 | } |
139 | } else { | |
140 | $page->assign('formulaire',1); | |
141 | } | |
142 | ||
eaf30d86 | 143 | $page->changeTpl('search/index.tpl'); |
46f272fe | 144 | $page->setTitle('Annuaire'); |
09824164 | 145 | } |
146 | ||
8eb6931f RB |
147 | /** $model is the way of presenting the results: minifiche, trombi, geoloc. |
148 | */ | |
26ba053e | 149 | function handler_advanced($page, $model = null, $byletter = null) |
09824164 | 150 | { |
151 | global $globals; | |
23ccdf38 | 152 | $page->addJsLink('jquery.ui.xorg.js'); |
e16215c4 | 153 | $page->addJsLink('search.js'); |
bc67c37c | 154 | $page->assign('advanced',1); |
155 | ||
1d364832 RB |
156 | $networks = DirEnum::getOptions(DirEnum::NETWORKS); |
157 | $networks[-1] = 'Tous types'; | |
158 | $networks[0] = '-'; | |
159 | ksort($networks); | |
160 | $page->assign('networking_types', $networks); | |
00f25ab1 SJ |
161 | $origin_corps_list = DirEnum::getOptions(DirEnum::CURRENTCORPS); |
162 | $current_corps_list = DirEnum::getOptions(DirEnum::ORIGINCORPS); | |
163 | $corps_rank_list = DirEnum::getOptions(DirEnum::CORPSRANKS); | |
164 | $origin_corps_list[0] = '-'; | |
165 | $current_corps_list[0] = '-'; | |
166 | $corps_rank_list[0] = '-'; | |
167 | ksort($origin_corps_list); | |
168 | ksort($current_corps_list); | |
169 | ksort($corps_rank_list); | |
170 | $page->assign('origin_corps_list', $origin_corps_list); | |
171 | $page->assign('current_corps_list', $current_corps_list); | |
172 | $page->assign('corps_rank_list', $corps_rank_list); | |
1d364832 | 173 | |
8eb6931f | 174 | if (!Env::has('rechercher') && $model != 'geoloc') { |
09824164 | 175 | $this->form_prepare(); |
176 | } else { | |
e31c1c3e | 177 | if (!Env::has('page')) { |
732e5855 | 178 | S::logger()->log('search', 'adv=' . var_export($_GET, true)); |
e31c1c3e | 179 | } |
137e819f | 180 | |
8c4a0c30 | 181 | require_once 'userset.inc.php'; |
0f567f55 RB |
182 | // Enable X.org fields for X.org admins, and AX fields for AX secretaries. |
183 | $view = new AdvancedSearchSet(S::admin(), | |
184 | S::user()->checkPerms(User::PERM_EDIT_DIRECTORY)); | |
185 | ||
51fcda84 | 186 | if (!$view->isValid()) { |
09824164 | 187 | $this->form_prepare(); |
51fcda84 RB |
188 | $page->trigError('Recherche invalide.'); |
189 | } else { | |
190 | $view->addMod('minifiche', 'Mini-fiches', true, array('starts_with' => $byletter)); | |
191 | $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true)); | |
0a928a2f | 192 | $view->addMod('map', 'Planisphère'); |
39394cbf | 193 | if (S::user()->checkPerms(User::PERM_EDIT_DIRECTORY) || S::admin()) { |
c442573a | 194 | $view->addMod('addresses', 'Adresses postales', false); |
39394cbf | 195 | } |
51fcda84 RB |
196 | $view->apply('search/adv', $page, $model); |
197 | ||
198 | $nb_tot = $view->count(); | |
199 | if ($nb_tot > $globals->search->private_max) { | |
200 | $this->form_prepare(); | |
39394cbf SJ |
201 | if ($model != 'addresses' && (S::user()->checkPerms(User::PERM_EDIT_DIRECTORY) || S::admin())) { |
202 | $page->assign('suggestAddresses', true); | |
203 | } | |
51fcda84 RB |
204 | $page->trigError('Recherche trop générale.'); |
205 | } else if ($nb_tot == 0) { | |
206 | $this->form_prepare(); | |
207 | $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !'); | |
208 | } | |
09824164 | 209 | } |
09824164 | 210 | } |
211 | ||
8eb6931f | 212 | $page->changeTpl('search/index.tpl', $model == 'mini' ? SIMPLE : SKINNED); |
8c4a0c30 | 213 | $page->assign('public_directory',0); |
09824164 | 214 | } |
3c640222 | 215 | |
658cffd4 | 216 | static public function format_autocomplete(array $item) |
23ccdf38 SJ |
217 | { |
218 | return $item['field'] . ' (' . $item['nb'] . ' camarade' . ($item['nb'] > 1 ? 's' : '') . ')'; | |
219 | } | |
220 | ||
38f35d89 | 221 | function handler_autocomplete($page, $type = null, $sub_id = null) |
838cc16a | 222 | { |
223 | // Autocompletion : according to type required, return | |
224 | // a list of results matching with the number of matches. | |
225 | // The output format is : | |
226 | // result1|nb1 | |
227 | // result2|nb2 | |
228 | // ... | |
3cb500d5 | 229 | pl_content_headers("text/plain"); |
ff3eb9b7 | 230 | $q = preg_replace(array('/\*+$/', // always look for $q* |
231 | '/([\^\$\[\]])/', // escape special regexp char | |
232 | '/\*/'), // replace joker by regexp joker | |
233 | array('', | |
234 | '\\\\\1', | |
235 | '.*'), | |
23ccdf38 SJ |
236 | Get::t('term')); |
237 | if (!$q) { | |
238 | exit(); | |
239 | } | |
38f35d89 SJ |
240 | if (!is_null($sub_id)) { |
241 | $query = $q . "\t" . $sub_id; | |
242 | } else { | |
243 | $query = $q; | |
244 | } | |
c15afc4e | 245 | |
23ccdf38 SJ |
246 | // Try to look in cached results. |
247 | $cached = false; | |
78e4b1f6 FB |
248 | $cache = XDB::query('SELECT result |
249 | FROM search_autocomplete | |
23ccdf38 | 250 | WHERE name = {?} AND query = {?} AND generated > NOW() - INTERVAL 1 DAY', |
38f35d89 | 251 | $type, $query); |
838cc16a | 252 | |
23ccdf38 SJ |
253 | if ($cache->numRows() > 0) { |
254 | $cached = true; | |
255 | $data = explode("\n", $cache->fetchOneCell()); | |
256 | $list = array(); | |
257 | foreach ($data as $line) { | |
258 | if ($line != '') { | |
259 | $aux = explode("\t", $line); | |
260 | $item = array( | |
261 | 'field' => $aux[0], | |
262 | 'nb' => $aux[1], | |
263 | 'id' => $aux[2] | |
264 | ); | |
658cffd4 | 265 | $item['value'] = self::format_autocomplete($item); |
23ccdf38 | 266 | array_push($list, $item); |
ff3eb9b7 | 267 | } |
23ccdf38 SJ |
268 | } |
269 | } else { | |
270 | $enums = array( | |
271 | 'binet_text' => DirEnum::BINETS, | |
272 | 'groupex_text' => DirEnum::GROUPESX, | |
273 | 'section_text' => DirEnum::SECTIONS, | |
274 | 'networking_type_text' => DirEnum::NETWORKS, | |
275 | 'locality_text' => DirEnum::LOCALITIES, | |
276 | 'country_text' => DirEnum::COUNTRIES, | |
277 | 'entreprise' => DirEnum::COMPANIES, | |
278 | 'jobterm_text' => DirEnum::JOBTERMS, | |
279 | 'description' => DirEnum::JOBDESCRIPTION, | |
280 | 'nationalite_text' => DirEnum::NATIONALITIES, | |
281 | 'school_text' => DirEnum::EDUSCHOOLS, | |
282 | ); | |
283 | if (!array_key_exists($type, $enums)) { | |
284 | exit(); | |
285 | } | |
286 | ||
38f35d89 SJ |
287 | if (is_null($sub_id)) { |
288 | $list = DirEnum::getAutoComplete($enums[$type], $q); | |
289 | } else { | |
290 | $list = DirEnum::getAutoComplete($enums[$type], $q, $sub_id); | |
291 | } | |
23ccdf38 SJ |
292 | $to_cache = ''; |
293 | foreach ($list as &$item) { | |
294 | $to_cache .= $item['field'] . "\t" . $item['nb'] . "\t" . $item['id'] . "\n"; | |
658cffd4 | 295 | $item['value'] = self::format_autocomplete($item); |
838cc16a | 296 | } |
297 | } | |
23ccdf38 SJ |
298 | |
299 | $count = count($list); | |
300 | if ($count == DirEnumeration::AUTOCOMPLETE_LIMIT) { | |
301 | $list[] = array( | |
302 | 'value' => '…', | |
303 | 'field' => '', | |
304 | 'nb' => 0, | |
305 | 'id' => -1 | |
306 | ); | |
307 | } elseif ($count == 0) { | |
308 | $list[] = array( | |
309 | 'value' => 'Aucun camarade trouvé pour ' . $q . '.', | |
310 | 'field' => '', | |
311 | 'nb' => 0, | |
312 | 'id' => -1 | |
313 | ); | |
314 | } | |
315 | ||
316 | if (!$cached) { | |
317 | XDB::query('INSERT INTO search_autocomplete (name, query, result, generated) | |
318 | VALUES ({?}, {?}, {?}, NOW()) | |
319 | ON DUPLICATE KEY UPDATE result = VALUES(result), generated = VALUES(generated)', | |
38f35d89 | 320 | $type, $query, $to_cache); |
fb6dc875 | 321 | } |
23ccdf38 | 322 | echo json_encode($list); |
838cc16a | 323 | exit(); |
324 | } | |
eaf30d86 | 325 | |
26ba053e | 326 | function handler_list($page, $type = null, $idVal = null) |
2ab7a09f | 327 | { |
ffd70398 PC |
328 | $page->assign('name', $type); |
329 | $page->assign('with_text_value', true); | |
330 | $page->assign('onchange', "document.forms.recherche.{$type}Txt.value = this.options[this.selectedIndex].text"); | |
331 | ||
ff3eb9b7 | 332 | // Give the list of all values possible of type and builds a select input for it |
8e720253 | 333 | $ids = null; |
ff3eb9b7 | 334 | |
335 | switch ($type) { | |
8e720253 | 336 | case 'binet': |
2998edf1 | 337 | $ids = DirEnum::getOptionsIter(DirEnum::BINETS); |
ff3eb9b7 | 338 | break; |
92c3f9e5 | 339 | case 'networking_type': |
2998edf1 | 340 | $ids = DirEnum::getOptionsIter(DirEnum::NETWORKS); |
92c3f9e5 | 341 | break; |
ff3eb9b7 | 342 | case 'country': |
2998edf1 | 343 | $ids = DirEnum::getOptionsIter(DirEnum::COUNTRIES); |
a67a14b4 SJ |
344 | $page->assign('onchange', 'changeAddressComponents(\'' . $type . '\', this.value)'); |
345 | break; | |
346 | case 'administrative_area_level_1': | |
347 | case 'administrative_area_level_2': | |
a67a14b4 SJ |
348 | case 'locality': |
349 | $page->assign('onchange', 'changeAddressComponents(\'' . $type . '\', this.value)'); | |
e76e94fb | 350 | case 'postal_code': |
a67a14b4 SJ |
351 | $ids = XDB::iterator("SELECT pace1.id, pace1.long_name AS field |
352 | FROM profile_addresses_components_enum AS pace1 | |
353 | INNER JOIN profile_addresses_components AS pac1 ON (pac1.component_id = pace1.id) | |
354 | INNER JOIN profile_addresses_components AS pac2 ON (pac1.pid = pac2.pid AND pac1.jobid = pac2.jobid AND pac1.id = pac2.id | |
355 | AND pac1.groupid = pac2.groupid AND pac1.type = pac2.type) | |
356 | INNER JOIN profile_addresses_components_enum AS pace2 ON (pac2.component_id = pace2.id AND FIND_IN_SET({?}, pace2.types)) | |
7757efd6 | 357 | WHERE pace2.id = {?} AND FIND_IN_SET({?}, pace1.types) AND pac1.type = 'home' |
a67a14b4 SJ |
358 | GROUP BY pace1.long_name", |
359 | Env::v('previous'), Env::v('value'), $type); | |
ff3eb9b7 | 360 | break; |
ff3eb9b7 | 361 | case 'diploma': |
8e720253 | 362 | if (Env::has('school') && Env::i('school') != 0) { |
2998edf1 | 363 | $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES, Env::i('school')); |
8e720253 | 364 | } else { |
2998edf1 | 365 | $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES); |
8e720253 RB |
366 | } |
367 | break; | |
ff3eb9b7 | 368 | case 'groupex': |
2998edf1 | 369 | $ids = DirEnum::getOptionsIter(DirEnum::GROUPESX); |
ff3eb9b7 | 370 | break; |
371 | case 'nationalite': | |
2998edf1 | 372 | $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES); |
ff3eb9b7 | 373 | break; |
ff3eb9b7 | 374 | case 'school': |
2998edf1 | 375 | $ids = DirEnum::getOptionsIter(DirEnum::EDUSCHOOLS); |
ff3eb9b7 | 376 | $page->assign('onchange', 'changeSchool(this.value)'); |
377 | break; | |
378 | case 'section': | |
2998edf1 | 379 | $ids = DirEnum::getOptionsIter(DirEnum::SECTIONS); |
ff3eb9b7 | 380 | break; |
3ac45f10 PC |
381 | case 'jobterm': |
382 | if (Env::has('jtid')) { | |
26ba053e | 383 | JobTerms::ajaxGetBranch($page, JobTerms::ONLY_JOBS); |
3ac45f10 PC |
384 | return; |
385 | } else { | |
386 | pl_content_headers('text/xml'); | |
387 | echo '<div>'; // global container so that response is valid xml | |
388 | echo '<input name="jobtermTxt" type="text" style="display:none" size="32" />'; | |
389 | echo '<input name="jobterm" type="hidden"/>'; | |
390 | echo '<div class="term_tree"></div>'; // container where to create the tree | |
391 | echo '<script type="text/javascript" src="javascript/jquery.jstree.js"></script>'; | |
392 | echo '<script type="text/javascript" src="javascript/jobtermstree.js"></script>'; | |
393 | echo '<script type="text/javascript">createJobTermsTree(".term_tree", "search/list/jobterm", "search", "searchForJobTerm");</script>'; | |
394 | echo '</div>'; | |
395 | exit(); | |
396 | } | |
ff3eb9b7 | 397 | default: exit(); |
398 | } | |
399 | if (isset($idVal)) { | |
3cb500d5 | 400 | pl_content_headers("text/plain"); |
8e720253 | 401 | echo $ids[$idVal]; |
ff3eb9b7 | 402 | exit(); |
403 | } | |
3cb500d5 | 404 | pl_content_headers("text/xml"); |
05cb05c0 | 405 | $page->changeTpl('include/field.select.tpl', NO_SKIN); |
8e720253 | 406 | $page->assign('list', $ids); |
2ab7a09f | 407 | } |
9dc65790 | 408 | |
26ba053e | 409 | function handler_referent($page, $action = null, $subaction = null) |
9dc65790 | 410 | { |
459e6f81 PC |
411 | global $globals; |
412 | ||
9dc65790 PC |
413 | $wp = new PlWikiPage('Docs.Emploi'); |
414 | $wp->buildCache(); | |
415 | ||
416 | $page->setTitle('Emploi et Carrières'); | |
658cffd4 | 417 | $page->addJsLink('jquery.ui.xorg.js'); |
9dc65790 | 418 | |
4ec03752 | 419 | // Count mentors |
9dc65790 PC |
420 | $res = XDB::query("SELECT count(distinct pid) FROM profile_mentor_term"); |
421 | $page->assign('mentors_number', $res->fetchOneCell()); | |
422 | ||
4ec03752 | 423 | // Search for mentors matching filters |
9dc65790 PC |
424 | require_once 'ufbuilder.inc.php'; |
425 | $ufb = new UFB_MentorSearch(); | |
426 | if (!$ufb->isEmpty()) { | |
427 | require_once 'userset.inc.php'; | |
428 | $ufc = $ufb->getUFC(); | |
429 | $set = new ProfileSet($ufc); | |
430 | $set->addMod('mentor', 'Référents'); | |
431 | $set->apply('referent/search', $page, $action, $subaction); | |
459e6f81 PC |
432 | $nb_tot = $set->count(); |
433 | if ($nb_tot > $globals->search->private_max) { | |
434 | $this->form_prepare(); | |
435 | $page->trigError('Recherche trop générale.'); | |
436 | $page->assign('plset_count', 0); | |
437 | } else if ($nb_tot == 0) { | |
438 | $this->form_prepare(); | |
439 | $page->trigError('Il n\'existe personne correspondant à ces critères dans la base.'); | |
9dc65790 PC |
440 | } |
441 | } | |
442 | ||
443 | $page->changeTpl('search/referent.tpl'); | |
444 | } | |
445 | ||
459e6f81 PC |
446 | /** |
447 | * Builds a select field to choose among countries that referents | |
448 | * know about. Only referents linked to term (jtid) are displayed. | |
449 | * @param $jtid id of job term to restrict referents | |
450 | */ | |
26ba053e | 451 | function handler_referent_countries($page, $jtid = null) |
459e6f81 PC |
452 | { |
453 | pl_content_headers("text/xml"); | |
454 | $page->changeTpl('include/field.select.tpl', NO_SKIN); | |
455 | $page->assign('name', 'country'); | |
1c305d4c | 456 | $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.country AS field |
459e6f81 PC |
457 | FROM geoloc_countries AS gc |
458 | INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2) | |
459 | INNER JOIN profile_mentor_term AS mt ON (mt.pid = mp.pid) | |
460 | INNER JOIN profile_job_term_relation AS jtr ON (jtr.jtid_2 = mt.jtid) | |
461 | WHERE jtr.jtid_1 = {?} | |
d6f2c926 SJ |
462 | GROUP BY gc.iso_3166_1_a2 |
463 | ORDER BY gc.country", $jtid); | |
459e6f81 PC |
464 | $page->assign('list', $it); |
465 | } | |
09824164 | 466 | } |
467 | ||
a7de4ef7 | 468 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
09824164 | 469 | ?> |