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