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