Commit | Line | Data |
---|---|---|
e39e72a6 RB |
1 | <?php |
2 | /*************************************************************************** | |
3 | * Copyright (C) 2003-2010 Polytechnique.org * | |
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 | ||
98925aab | 22 | // {{{ class DirEnum |
e39e72a6 RB |
23 | /** This class stores all data for the different kinds of fields. |
24 | * It is only a dispatcher for the various DirEnum_XXX classes. | |
25 | */ | |
26 | class DirEnum | |
27 | { | |
28 | /** Name of availables Enumerations | |
29 | * Each of these consts contains the basename of the class (its full name | |
30 | * being DE_$basename). | |
31 | */ | |
5c32cc1a RB |
32 | const NAMETYPES = 'nametypes'; |
33 | ||
21b67462 | 34 | const BINETS = 'binets'; |
5ab3ef57 | 35 | const GROUPESX = 'groupesx'; |
21b67462 | 36 | const SECTIONS = 'sections'; |
5ab3ef57 | 37 | |
fb3b6547 RB |
38 | const EDUSCHOOLS = 'educationschools'; |
39 | const EDUDEGREES = 'educationdegrees'; | |
40 | const EDUFIELDS = 'educationfields'; | |
5ab3ef57 | 41 | |
21b67462 RB |
42 | const NATIONALITIES = 'nationalities'; |
43 | const COUNTRIES = 'countries'; | |
5ab3ef57 RB |
44 | const ADMINAREAS = 'adminareas'; |
45 | const LOCALITIES = 'localities'; | |
46 | ||
47 | const COMPANIES = 'companies'; | |
21b67462 | 48 | const SECTORS = 'sectors'; |
5ab3ef57 RB |
49 | const JOBDESCRIPTION = 'jobdescription'; |
50 | ||
21b67462 | 51 | const NETWORKS = 'networking'; |
e39e72a6 RB |
52 | |
53 | static private $enumerations = array(); | |
54 | ||
55 | static private function init($type) | |
56 | { | |
57 | $cls = "DE_" . ucfirst($type); | |
58 | self::$enumerations[$type] = new $cls(); | |
59 | } | |
60 | ||
61 | /** Retrieves all options for a given type | |
62 | * @param $type Type of enum for which options are requested | |
2998edf1 | 63 | * @return Array of the results |
e39e72a6 RB |
64 | */ |
65 | static public function getOptions() | |
66 | { | |
67 | $args = func_get_args(); | |
68 | $type = array_shift($args); | |
69 | if (!array_key_exists($type, self::$enumerations)) { | |
70 | self::init($type); | |
71 | } | |
72 | $obj = self::$enumerations[$type]; | |
2998edf1 RB |
73 | if ($obj->capabilities & DirEnumeration::HAS_OPTIONS) { |
74 | return call_user_func_array(array($obj, 'getOptions'), $args); | |
75 | } else { | |
76 | return array(); | |
77 | } | |
e39e72a6 | 78 | } |
21b67462 | 79 | |
a137e407 RB |
80 | /** Retrieves all options for a given type |
81 | * @param $type Type of enum for which options are requested | |
2998edf1 | 82 | * @return PlIterator over the results |
a137e407 | 83 | */ |
2998edf1 | 84 | static public function getOptionsIter() |
a137e407 RB |
85 | { |
86 | $args = func_get_args(); | |
87 | $type = array_shift($args); | |
88 | if (!array_key_exists($type, self::$enumerations)) { | |
89 | self::init($type); | |
90 | } | |
91 | $obj = self::$enumerations[$type]; | |
2998edf1 RB |
92 | if ($obj->capabilities & DirEnumeration::HAS_OPTIONS) { |
93 | return call_user_func_array(array($obj, 'getOptionsIter'), $args); | |
94 | } else { | |
95 | return PlIteratorUtils::fromArray(array()); | |
96 | } | |
a137e407 RB |
97 | } |
98 | ||
30b9ca46 RB |
99 | /** Retrieves all options with number of profiles for autocompletion |
100 | * @param $type Type of enum for which options are requested | |
101 | * @param $text Text to autocomplete | |
2998edf1 | 102 | * @return PlIterator over the results |
30b9ca46 RB |
103 | */ |
104 | static public function getAutoComplete() | |
105 | { | |
106 | $args = func_get_args(); | |
107 | $type = array_shift($args); | |
108 | if (!array_key_exists($type, self::$enumerations)) { | |
109 | self::init($type); | |
110 | } | |
111 | $obj = self::$enumerations[$type]; | |
2998edf1 RB |
112 | if ($obj->capabilities & DirEnumeration::HAS_AUTOCOMP) { |
113 | return call_user_func_array(array($obj, 'getAutoComplete'), $args); | |
114 | } else { | |
115 | return PlIteratorUtils::fromArray(array()); | |
116 | } | |
30b9ca46 RB |
117 | } |
118 | ||
98925aab RB |
119 | /** Retrieves a list of IDs for a given type |
120 | * @param $type Type of enum for which IDs are requested | |
121 | * @param $text Text to search in enum valuees | |
122 | * @param $mode Mode of search for those IDs (prefix/suffix/infix) | |
123 | */ | |
69ef14a5 | 124 | static public function getIDs($type, $text, $mode = XDB::WILDCARD_EXACT) |
21b67462 | 125 | { |
21b67462 RB |
126 | if (!array_key_exists($type, self::$enumerations)) { |
127 | self::init($type); | |
128 | } | |
129 | $obj = self::$enumerations[$type]; | |
2998edf1 | 130 | if ($obj->capabilities & DirEnumeration::HAS_OPTIONS) { |
69ef14a5 | 131 | return call_user_func(array($obj, 'getIDs'), $text, $mode); |
2998edf1 RB |
132 | } else { |
133 | return array(); | |
134 | } | |
21b67462 | 135 | } |
69ef14a5 FB |
136 | |
137 | /** Retrieves a single ID for a given type. | |
138 | * @param $type Type of the enum for which an ID is requested | |
139 | * @param $text Text to search in enum values | |
140 | * @param $mode Mode of search of that ID (prefix/suffix/infix/exact) | |
141 | */ | |
142 | static public function getID($type, $text, $mode = XDB::WILDCARD_EXACT) | |
143 | { | |
144 | return array_shift(self::getIDs($type, $text, $mode)); | |
145 | } | |
e39e72a6 | 146 | } |
98925aab | 147 | // }}} |
e39e72a6 | 148 | |
98925aab | 149 | // {{{ class DirEnumeration |
e39e72a6 RB |
150 | abstract class DirEnumeration |
151 | { | |
2998edf1 RB |
152 | const AUTOCOMPLETE_LIMIT = 11; |
153 | ||
154 | const HAS_OPTIONS = 0x001; | |
155 | const HAS_AUTOCOMP = 0x002; | |
156 | ||
157 | public $capabilities = 0x003; // self::HAS_OPTIONS | self::HAS_AUTOCOMP; | |
158 | ||
e39e72a6 RB |
159 | /** An internal array of ID => optionTxt |
160 | */ | |
9ed7f5bc | 161 | protected $options = null; |
e39e72a6 | 162 | |
21b67462 RB |
163 | /** Description of the MySQL storage of the fields |
164 | */ | |
e39e72a6 RB |
165 | protected $idfield = 'id'; |
166 | protected $valfield = 'text'; | |
30b9ca46 | 167 | protected $valfield2 = null; |
e39e72a6 | 168 | protected $from; |
21b67462 | 169 | protected $join = ''; |
e39e72a6 RB |
170 | protected $where = ''; |
171 | ||
30b9ca46 RB |
172 | /** Fields for autocompletion |
173 | */ | |
174 | protected $ac_join = ''; // Additional joins | |
175 | protected $ac_where = null; // Additional where | |
176 | protected $ac_beginwith = true; // Whether to search for 'x%' or for '%x%' | |
177 | protected $ac_unique; // Which field is to be taken as unique | |
178 | protected $ac_distinct = true; // Whether we want to keep only distinct valfield value | |
179 | protected $ac_withid = true; // Do we want to fetch id too ? | |
180 | ||
9ed7f5bc RB |
181 | protected function _fetchOptions() |
182 | { | |
183 | if (is_null($this->options)) { | |
184 | $this->loadOptions(); | |
185 | } | |
e39e72a6 RB |
186 | } |
187 | ||
188 | public function getOptions() | |
189 | { | |
9ed7f5bc | 190 | $this->_fetchOptions(); |
e39e72a6 RB |
191 | return $this->options; |
192 | } | |
193 | ||
2998edf1 | 194 | public function getOptionsIter() |
a137e407 | 195 | { |
2998edf1 | 196 | return PlIteratorUtils::fromArray(self::expandArray($this->getOptions()), 1, true); |
a137e407 RB |
197 | } |
198 | ||
30b9ca46 | 199 | // {{{ function getIDs |
21b67462 RB |
200 | /** Retrieves possible IDs for given text |
201 | * @param $text Text to search for IDs | |
202 | * @param $mode Mode of search (PREFIX, SUFFIX, CONTAINS) | |
203 | * @return An array of matching IDs ; if empty, input should be considered invalid | |
204 | */ | |
205 | public function getIDs($text, $mode) | |
206 | { | |
658b4c83 | 207 | if ($mode == XDB::WILDCARD_EXACT) { |
21b67462 RB |
208 | $options = $this->getOptions(); |
209 | return array_keys($options, $text); | |
210 | } else { | |
211 | if ($this->where == null) { | |
212 | $where = 'WHERE '; | |
213 | } else { | |
214 | $where = $this->where . ' AND '; | |
215 | } | |
30b9ca46 | 216 | $conds = array(); |
658b4c83 | 217 | $conds[] = $this->valfield . XDB::formatWildcards($mode, $text); |
30b9ca46 | 218 | if ($this->valfield2 != null) { |
658b4c83 | 219 | $conds[] = $this->valfield2 . XDB::formatWildcards($mode, $text); |
30b9ca46 RB |
220 | } |
221 | $where .= '(' . implode(' OR ', $conds) . ')'; | |
222 | ||
21b67462 RB |
223 | return XDB::fetchColumn('SELECT ' . $this->idfield . ' |
224 | FROM ' . $this->from . ' | |
225 | ' . $this->join . ' | |
30b9ca46 | 226 | ' . $where . ' |
21b67462 RB |
227 | GROUP BY ' . $this->idfield); |
228 | } | |
229 | } | |
30b9ca46 | 230 | // }}} |
21b67462 | 231 | |
30b9ca46 RB |
232 | private function mkTests($field, $text) |
233 | { | |
234 | $tests = array(); | |
658b4c83 | 235 | $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_PREFIX, $text); |
30b9ca46 | 236 | if (!$this->ac_beginwith) { |
658b4c83 RB |
237 | $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, ' ' . $text); |
238 | $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, '-' . $text); | |
30b9ca46 RB |
239 | } |
240 | return $tests; | |
241 | } | |
242 | ||
2998edf1 RB |
243 | static protected function expandArray(array $tab, $keyname = 'id', $valname = 'field') |
244 | { | |
245 | $res = array(); | |
246 | foreach ($tab as $key => $val) { | |
247 | $res[$key] = array( | |
248 | $keyname => $key, | |
249 | $valname => $val, | |
250 | ); | |
251 | } | |
252 | return $res; | |
253 | } | |
254 | ||
30b9ca46 RB |
255 | // {{{ function getAutoComplete |
256 | public function getAutoComplete($text) | |
257 | { | |
258 | $text = str_replace(array('%', '_'), '', $text); | |
259 | ||
260 | if (is_null($this->ac_where) || $this->ac_where == '') { | |
261 | $where = ''; | |
262 | } else { | |
263 | $where = $this->ac_where . ' AND '; | |
264 | } | |
265 | ||
266 | $tests = $this->mkTests($this->valfield, $text); | |
267 | if (!is_null($this->valfield2)) { | |
268 | $tests = array_merge($tests, $this->mkTests($this->valfield2, $text)); | |
269 | } | |
270 | ||
271 | $where .= '(' . implode(' OR ', $tests) . ')'; | |
272 | ||
273 | return XDB::iterator('SELECT ' . $this->valfield . ' AS field' | |
274 | . ($this->ac_distinct ? (', COUNT(DISTINCT ' . $this->ac_unique . ') AS nb') : '') | |
275 | . ($this->ac_withid ? (', ' . $this->idfield . ' AS id') : '') . ' | |
276 | FROM ' . $this->from . ' | |
277 | ' . $this->ac_join . ' | |
278 | WHERE ' . $where . ' | |
279 | GROUP BY ' . $this->valfield . ' | |
280 | ORDER BY ' . ($this->ac_distinct ? 'nb DESC' : $this->valfield) . ' | |
2998edf1 | 281 | LIMIT ' . self::AUTOCOMPLETE_LIMIT); |
30b9ca46 RB |
282 | } |
283 | // }}} | |
284 | ||
30b9ca46 | 285 | // {{{ function loadOptions |
e39e72a6 RB |
286 | /** The function used to load options |
287 | */ | |
288 | protected function loadOptions() | |
289 | { | |
2998edf1 RB |
290 | $this->options = XDB::fetchAllAssoc('id', 'SELECT ' . $this->valfield . ' AS field, |
291 | ' . $this->idfield . ' AS id | |
292 | FROM ' . $this->from . ' | |
293 | ' . $this->join . ' | |
294 | ' . $this->where . ' | |
295 | GROUP BY ' . $this->valfield . ' | |
296 | ORDER BY ' . $this->valfield); | |
e39e72a6 | 297 | } |
30b9ca46 | 298 | // }}} |
e39e72a6 | 299 | } |
98925aab | 300 | // }}} |
e39e72a6 | 301 | |
2998edf1 RB |
302 | // {{{ class DE_WithSuboption |
303 | /** A class for DirEnum with possibility to select only suboptions for a given parameter (country, school, ...) | |
304 | */ | |
305 | abstract class DE_WithSuboption extends DirEnumeration | |
306 | { | |
307 | protected $optfield; | |
308 | ||
309 | protected $suboptions = null; | |
310 | ||
311 | protected function loadOptions() | |
312 | { | |
313 | $opts = XDB::fetchAllAssoc('id', 'SELECT ' . $this->valfield . ' AS field, | |
314 | ' . $this->optfield . ' AS subid, | |
315 | ' . $this->idfield . ' AS id | |
316 | FROM ' . $this->from . ' | |
317 | ' . $this->join . ' | |
318 | ' . $this->where . ' | |
319 | GROUP BY ' . $this->valfield . ' | |
320 | ORDER BY ' . $this->valfield); | |
321 | $this->options = array(); | |
322 | $this->suboptions = array(); | |
323 | foreach ($opts as $id => $opt) { | |
324 | $this->options[$id] = $opt['field']; | |
325 | if (!array_key_exists($opt['subid'], $this->suboptions)) { | |
326 | $this->suboptions[$opt['subid']] = array(); | |
327 | } | |
328 | $this->suboptions[$opt['subid']][$id] = $opt['field']; | |
329 | } | |
330 | } | |
331 | ||
332 | public function getOptions($subid = null) | |
333 | { | |
334 | $this->_fetchOptions(); | |
335 | if ($subid == null) { | |
336 | return $this->options; | |
337 | } else if (array_key_exists($subid, $this->suboptions)) { | |
338 | return $this->suboptions[$subid]; | |
339 | } else { | |
340 | return false; | |
341 | } | |
342 | } | |
343 | ||
344 | public function getOptionsIter($subid = null) | |
345 | { | |
346 | return PlIteratorUtils::fromArray(self::expandArray($this->getOptions($subid)), 1, true); | |
347 | } | |
348 | ||
349 | public function getIDs($text, $mode, $subid = null) | |
350 | { | |
351 | if ($mode == XDB::WILDCARD_EXACT) { | |
352 | $options = $this->getOptions($subid); | |
353 | return array_keys($options, $text); | |
354 | } else { | |
355 | if ($this->where == null) { | |
356 | $where = 'WHERE '; | |
357 | } else { | |
358 | $where = $this->where . ' AND '; | |
359 | } | |
360 | if ($subid != null && array_key_exists($subid, $this->suboptions)) { | |
361 | $where .= XDB::format($this->optfield . ' = {?} AND ', $subid); | |
362 | } | |
363 | ||
364 | $conds = array(); | |
365 | $conds[] = $this->valfield . XDB::formatWildcards($mode, $text); | |
366 | if ($this->valfield2 != null) { | |
367 | $conds[] = $this->valfield2 . XDB::formatWildcards($mode, $text); | |
368 | } | |
369 | $where .= '(' . implode(' OR ', $conds) . ')'; | |
370 | ||
371 | return XDB::fetchColumn('SELECT ' . $this->idfield . ' | |
372 | FROM ' . $this->from . ' | |
373 | ' . $this->join . ' | |
374 | ' . $where . ' | |
375 | GROUP BY ' . $this->idfield); | |
376 | } | |
377 | } | |
378 | ||
379 | public function getAutoComplete($text, $subid = null) | |
380 | { | |
381 | $text = str_replace(array('%', '_'), '', $text); | |
382 | ||
383 | if (is_null($this->ac_where) || $this->ac_where == '') { | |
384 | $where = ''; | |
385 | } else { | |
386 | $where = $this->ac_where . ' AND '; | |
387 | } | |
388 | ||
389 | if ($subid != null && array_key_exists($subid, $this->suboptions)) { | |
390 | $where .= XDB::format($this->optfield . ' = {?} AND ', $subid); | |
391 | } | |
392 | ||
393 | $tests = $this->mkTests($this->valfield, $text); | |
394 | if (!is_null($this->valfield2)) { | |
395 | $tests = array_merge($tests, $this->mkTests($this->valfield2, $text)); | |
396 | } | |
397 | ||
398 | $where .= '(' . implode(' OR ', $tests) . ')'; | |
399 | ||
400 | return XDB::iterator('SELECT ' . $this->valfield . ' AS field' | |
401 | . ($this->ac_distinct ? (', COUNT(DISTINCT ' . $this->ac_unique . ') AS nb') : '') | |
402 | . ($this->ac_withid ? (', ' . $this->idfield . ' AS id') : '') . ' | |
403 | FROM ' . $this->from . ' | |
404 | ' . $this->ac_join . ' | |
405 | WHERE ' . $where . ' | |
406 | GROUP BY ' . $this->valfield . ' | |
407 | ORDER BY ' . ($this->ac_distinct ? 'nb DESC' : $this->valfield) . ' | |
408 | LIMIT ' . self::AUTOCOMPLETE_LIMIT); | |
409 | } | |
410 | } | |
411 | // }}} | |
412 | ||
5c32cc1a RB |
413 | // {{{ class DE_NameTypes |
414 | // returns 'system' names ('lastname', 'lastname_marital', ...) | |
415 | class DE_NameTypes extends DirEnumeration | |
416 | { | |
2998edf1 RB |
417 | public $capabilities = self::HAS_OPTIONS; |
418 | ||
5c32cc1a RB |
419 | protected $from = 'profile_name_enum'; |
420 | protected $valfield = 'type'; | |
421 | } | |
422 | // }}} | |
423 | ||
5ab3ef57 RB |
424 | /** GROUPS |
425 | */ | |
98925aab | 426 | // {{{ class DE_Binets |
e39e72a6 RB |
427 | class DE_Binets extends DirEnumeration |
428 | { | |
5c8a71f2 | 429 | protected $from = 'profile_binet_enum'; |
30b9ca46 | 430 | |
5c8a71f2 | 431 | protected $ac_join = 'INNER JOIN profile_binets ON (profile_binet_enum.id = profile_binets.binet_id)'; |
bdd977d7 | 432 | protected $ac_unique = 'profile_binets.pid'; |
e39e72a6 | 433 | } |
98925aab RB |
434 | // }}} |
435 | ||
436 | // {{{ class DE_Sections | |
e39e72a6 RB |
437 | class DE_Sections extends DirEnumeration |
438 | { | |
5c8a71f2 | 439 | protected $from = 'profile_section_enum'; |
30b9ca46 | 440 | |
5c8a71f2 | 441 | protected $ac_join = 'INNER JOIN profiles ON (profiles.section = profile_section_enum.id)'; |
30b9ca46 | 442 | protected $ac_unique = 'profiles.pid'; |
e39e72a6 | 443 | } |
98925aab RB |
444 | // }}} |
445 | ||
5ab3ef57 RB |
446 | // {{{ class DE_GroupesX |
447 | class DE_GroupesX extends DirEnumeration | |
448 | { | |
2998edf1 RB |
449 | protected $idfield = 'groups.id'; |
450 | protected $valfield = 'groups.nom'; | |
451 | protected $valfield2 = 'groups.diminutif'; | |
452 | protected $from = 'groups'; | |
5ab3ef57 RB |
453 | protected $where = 'WHERE (cat = \'GroupesX\' OR cat = \'Institutions\') AND pub = \'public\''; |
454 | ||
2998edf1 RB |
455 | protected $ac_join = "INNER JOIN group_members ON (groups.id = memb.asso_id |
456 | AND (groups.cat = 'GroupesX' OR groups.cat = 'Institutions') | |
457 | AND groups.pub = 'public')"; | |
458 | protected $ac_unique = 'group_members.uid'; | |
5ab3ef57 RB |
459 | } |
460 | // }}} | |
461 | ||
462 | /** EDUCATION | |
463 | */ | |
fb3b6547 RB |
464 | // {{{ class DE_EducationSchools |
465 | class DE_EducationSchools extends DirEnumeration | |
e39e72a6 | 466 | { |
2998edf1 RB |
467 | protected $valfield = 'profile_education_enum.name'; |
468 | protected $valfield2 = 'profile_education_enum.abbreviation'; | |
30b9ca46 RB |
469 | protected $from = 'profile_education_enum'; |
470 | ||
471 | protected $ac_join = 'INNER JOIN profile_education ON (profile_education.eduid = profile_education_enum.id)'; | |
ce0b2c6f | 472 | protected $ac_unique = 'profile_education.pid'; |
e39e72a6 | 473 | } |
98925aab RB |
474 | // }}} |
475 | ||
fb3b6547 RB |
476 | // {{{ class DE_EducationDegrees |
477 | class DE_EducationDegrees extends DirEnumeration | |
e39e72a6 | 478 | { |
2998edf1 | 479 | public $capabilities = self::HAS_OPTIONS; |
21b67462 | 480 | |
2998edf1 RB |
481 | protected $idfield = 'profile_education_degree.degreeid'; |
482 | protected $optfield = 'profile_education_degree.eduid'; | |
483 | protected $valfield = 'profile_education_degree_enum.degree'; | |
484 | protected $from = 'profile_education_degree_enum'; | |
485 | protected $join = 'INNER JOIN profile_education_degree ON (profile_education_degree.degreeid = profile_education_degree_enum.id)'; | |
e5fb8f87 | 486 | |
21b67462 | 487 | } |
98925aab RB |
488 | // }}} |
489 | ||
fb3b6547 RB |
490 | // {{{ class DE_EducationFields |
491 | class DE_EducationFields extends DirEnumeration | |
21b67462 | 492 | { |
2998edf1 | 493 | protected $valfield = 'profile_education_field_enum.field'; |
30b9ca46 RB |
494 | protected $from = 'profile_education_field_enum'; |
495 | ||
496 | protected $ac_join = 'INNER JOIN profile_education ON (profile_education.fieldid = profile_education_field_enum.id)'; | |
ce0b2c6f | 497 | protected $ac_unique = 'profile_education.pid'; |
e39e72a6 | 498 | } |
98925aab RB |
499 | // }}} |
500 | ||
5ab3ef57 RB |
501 | /** GEOLOC |
502 | */ | |
98925aab | 503 | // {{{ class DE_Nationalities |
e39e72a6 RB |
504 | class DE_Nationalities extends DirEnumeration |
505 | { | |
2998edf1 RB |
506 | protected $idfield = 'geoloc_countries.iso_3166_1_a2'; |
507 | protected $valfield = 'geoloc_countries.nationalityFR'; | |
508 | protected $valfield2 = 'geoloc_countries.nationality'; | |
509 | protected $from = 'geoloc_countries'; | |
510 | protected $join = 'INNER JOIN profiles ON (geoloc_countries.iso_3166_1_a2 IN (profiles.nationality1, profiles.nationality2, profiles.nationality3))'; | |
30b9ca46 | 511 | |
2998edf1 | 512 | protected $ac_join = 'INNER JOIN profiles ON (geoloc_countries.iso_3166_1_a2 IN (profiles.nationality1, profiles.nationality2, profiles.nationality3))'; |
30b9ca46 | 513 | protected $ac_unique = 'profiles.pid'; |
e39e72a6 | 514 | } |
98925aab RB |
515 | // }}} |
516 | ||
517 | // {{{ class DE_Countries | |
e39e72a6 RB |
518 | class DE_Countries extends DirEnumeration |
519 | { | |
2998edf1 RB |
520 | protected $idfield = 'geoloc_countries.iso_3166_1_a2'; |
521 | protected $valfield = 'geoloc_countries.countryFR'; | |
522 | protected $valfield2 = 'geoloc_countries.country'; | |
30b9ca46 RB |
523 | protected $from = 'geoloc_countries'; |
524 | ||
525 | protected $ac_join = 'INNER JOIN profile_addresses ON (geoloc_countries.iso_3166_1_a2 = profile_addresses.countryFR'; | |
526 | protected $ac_unique = 'profile_addresses.pid'; | |
e39e72a6 | 527 | } |
98925aab RB |
528 | // }}} |
529 | ||
530 | // {{{ class DE_AdminAreas | |
2998edf1 | 531 | class DE_AdminAreas extends DE_WithSuboption |
e39e72a6 | 532 | { |
2998edf1 RB |
533 | protected $idfield = 'geoloc_administrativeareas.id'; |
534 | protected $optfield = 'geoloc_administrativeareas.country'; | |
535 | protected $valfield = 'geoloc_administrativeareas.name'; | |
536 | protected $from = 'geoloc_administrativeareas'; | |
9ed7f5bc | 537 | |
2998edf1 RB |
538 | protected $ac_join = 'INNER JOIN profile_addresses ON (profile_addresses.administrativeAreaId = geoloc_administrativeareas.id)'; |
539 | protected $ac_unique = 'profile_addresses.pid'; | |
e39e72a6 | 540 | } |
98925aab RB |
541 | // }}} |
542 | ||
5ab3ef57 RB |
543 | // {{{ class DE_Localities |
544 | class DE_Localities extends DirEnumeration | |
e39e72a6 | 545 | { |
2998edf1 RB |
546 | protected $valfield = 'geoloc_localities.name'; |
547 | protected $from = 'geoloc_localities'; | |
30b9ca46 | 548 | |
2998edf1 RB |
549 | protected $ac_join = 'profile_addresses ON (profile_addresses.localityID = geoloc_localities.id)'; |
550 | protected $ac_unique = 'profile_addresses.pid'; | |
5ab3ef57 RB |
551 | } |
552 | // }}} | |
553 | ||
554 | /** JOBS | |
555 | */ | |
556 | // {{{ class DE_Companies | |
557 | class DE_Companies extends DirEnumeration | |
558 | { | |
2998edf1 RB |
559 | protected $valfield = 'profile_job_enum.name'; |
560 | protected $valfield2 = 'profile_job_enum.acronym'; | |
561 | protected $from = 'profile_job_enum'; | |
5ab3ef57 | 562 | |
2998edf1 | 563 | protected $ac_join = 'INNER JOIN profile_job ON (profile_job.jobid = profile_job_enum.id)'; |
ce0b2c6f | 564 | protected $ac_unique = 'profile_job.pid'; |
e39e72a6 | 565 | } |
98925aab RB |
566 | // }}} |
567 | ||
568 | // {{{ class DE_Sectors | |
e39e72a6 RB |
569 | class DE_Sectors extends DirEnumeration |
570 | { | |
2998edf1 | 571 | protected $valfield = 'profile_job_sector_enum.name'; |
30b9ca46 RB |
572 | protected $from = 'profile_job_sector_enum'; |
573 | ||
574 | protected $ac_join = 'INNER JOIN profile_job ON (profile_job_sector_enum.id = profile_job.sectorid)'; | |
ce0b2c6f | 575 | protected $ac_unique = 'profile_job.pid'; |
e39e72a6 | 576 | } |
98925aab RB |
577 | // }}} |
578 | ||
5ab3ef57 RB |
579 | // {{{ class DE_JobDescription |
580 | class DE_JobDescription | |
581 | { | |
2998edf1 RB |
582 | protected $valfield = 'profile_job.description'; |
583 | protected $from = 'profile_job'; | |
584 | protected $idfield = 'profile_job.pid'; | |
5ab3ef57 | 585 | |
2998edf1 | 586 | protected $ac_unique = 'profile_job.pid'; |
5ab3ef57 RB |
587 | } |
588 | // }}} | |
589 | ||
590 | /** NETWORKING | |
591 | */ | |
98925aab | 592 | // {{{ class DE_Networking |
e39e72a6 RB |
593 | class DE_Networking extends DirEnumeration |
594 | { | |
30b9ca46 RB |
595 | protected $idfield = 'profile_networking_enum.network_type'; |
596 | protected $valfield = 'profile_networking_enum.name'; | |
e39e72a6 | 597 | protected $from = 'profile_networking_enum'; |
30b9ca46 RB |
598 | |
599 | ||
600 | protected $ac_join = 'INNER JOIN profile_networking ON (profile_networking.network_type = profile_networking_enum.network_type'; | |
ce0b2c6f | 601 | protected $ac_unique = 'profile_networking.pid'; |
e39e72a6 | 602 | } |
98925aab | 603 | // }}} |
69ef14a5 FB |
604 | |
605 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
e39e72a6 | 606 | ?> |