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