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