Add DirEnum for medals
[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
eb872b24
RB
241 /** Builds a list of query parts for searching @$text in @$field :
242 * field LIKE 'text%', field LIKE '% text%', field LIKE '%-text%'
243 */
30b9ca46
RB
244 private function mkTests($field, $text)
245 {
246 $tests = array();
658b4c83 247 $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_PREFIX, $text);
30b9ca46 248 if (!$this->ac_beginwith) {
658b4c83
RB
249 $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, ' ' . $text);
250 $tests[] = $field . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, '-' . $text);
30b9ca46
RB
251 }
252 return $tests;
253 }
254
2998edf1
RB
255 static protected function expandArray(array $tab, $keyname = 'id', $valname = 'field')
256 {
257 $res = array();
258 foreach ($tab as $key => $val) {
259 $res[$key] = array(
260 $keyname => $key,
261 $valname => $val,
262 );
263 }
264 return $res;
265 }
266
30b9ca46
RB
267 // {{{ function getAutoComplete
268 public function getAutoComplete($text)
269 {
270 $text = str_replace(array('%', '_'), '', $text);
271
272 if (is_null($this->ac_where) || $this->ac_where == '') {
273 $where = '';
274 } else {
275 $where = $this->ac_where . ' AND ';
276 }
277
278 $tests = $this->mkTests($this->valfield, $text);
279 if (!is_null($this->valfield2)) {
280 $tests = array_merge($tests, $this->mkTests($this->valfield2, $text));
281 }
282
283 $where .= '(' . implode(' OR ', $tests) . ')';
284
285 return XDB::iterator('SELECT ' . $this->valfield . ' AS field'
286 . ($this->ac_distinct ? (', COUNT(DISTINCT ' . $this->ac_unique . ') AS nb') : '')
70bcaa84 287 . ($this->ac_withid ? (', ' . $this->idfield . ' AS id') : '') . '
30b9ca46
RB
288 FROM ' . $this->from . '
289 ' . $this->ac_join . '
290 WHERE ' . $where . '
291 GROUP BY ' . $this->valfield . '
292 ORDER BY ' . ($this->ac_distinct ? 'nb DESC' : $this->valfield) . '
2998edf1 293 LIMIT ' . self::AUTOCOMPLETE_LIMIT);
30b9ca46
RB
294 }
295 // }}}
296
30b9ca46 297 // {{{ function loadOptions
e39e72a6
RB
298 /** The function used to load options
299 */
300 protected function loadOptions()
301 {
2998edf1
RB
302 $this->options = XDB::fetchAllAssoc('id', 'SELECT ' . $this->valfield . ' AS field,
303 ' . $this->idfield . ' AS id
304 FROM ' . $this->from . '
305 ' . $this->join . '
306 ' . $this->where . '
307 GROUP BY ' . $this->valfield . '
308 ORDER BY ' . $this->valfield);
e39e72a6 309 }
30b9ca46 310 // }}}
e39e72a6 311}
98925aab 312// }}}
e39e72a6 313
2998edf1
RB
314// {{{ class DE_WithSuboption
315/** A class for DirEnum with possibility to select only suboptions for a given parameter (country, school, ...)
316 */
317abstract class DE_WithSuboption extends DirEnumeration
318{
319 protected $optfield;
320
321 protected $suboptions = null;
322
323 protected function loadOptions()
324 {
325 $opts = XDB::fetchAllAssoc('id', 'SELECT ' . $this->valfield . ' AS field,
326 ' . $this->optfield . ' AS subid,
327 ' . $this->idfield . ' AS id
328 FROM ' . $this->from . '
329 ' . $this->join . '
330 ' . $this->where . '
331 GROUP BY ' . $this->valfield . '
332 ORDER BY ' . $this->valfield);
333 $this->options = array();
334 $this->suboptions = array();
335 foreach ($opts as $id => $opt) {
336 $this->options[$id] = $opt['field'];
337 if (!array_key_exists($opt['subid'], $this->suboptions)) {
338 $this->suboptions[$opt['subid']] = array();
339 }
340 $this->suboptions[$opt['subid']][$id] = $opt['field'];
341 }
342 }
343
344 public function getOptions($subid = null)
345 {
346 $this->_fetchOptions();
347 if ($subid == null) {
348 return $this->options;
349 } else if (array_key_exists($subid, $this->suboptions)) {
350 return $this->suboptions[$subid];
351 } else {
ffd70398 352 return array();
2998edf1
RB
353 }
354 }
355
356 public function getOptionsIter($subid = null)
357 {
358 return PlIteratorUtils::fromArray(self::expandArray($this->getOptions($subid)), 1, true);
359 }
360
361 public function getIDs($text, $mode, $subid = null)
362 {
363 if ($mode == XDB::WILDCARD_EXACT) {
364 $options = $this->getOptions($subid);
365 return array_keys($options, $text);
366 } else {
367 if ($this->where == null) {
368 $where = 'WHERE ';
369 } else {
370 $where = $this->where . ' AND ';
371 }
372 if ($subid != null && array_key_exists($subid, $this->suboptions)) {
373 $where .= XDB::format($this->optfield . ' = {?} AND ', $subid);
374 }
375
376 $conds = array();
377 $conds[] = $this->valfield . XDB::formatWildcards($mode, $text);
378 if ($this->valfield2 != null) {
379 $conds[] = $this->valfield2 . XDB::formatWildcards($mode, $text);
380 }
381 $where .= '(' . implode(' OR ', $conds) . ')';
382
383 return XDB::fetchColumn('SELECT ' . $this->idfield . '
384 FROM ' . $this->from . '
385 ' . $this->join . '
386 ' . $where . '
387 GROUP BY ' . $this->idfield);
388 }
389 }
390
391 public function getAutoComplete($text, $subid = null)
392 {
393 $text = str_replace(array('%', '_'), '', $text);
394
395 if (is_null($this->ac_where) || $this->ac_where == '') {
396 $where = '';
397 } else {
398 $where = $this->ac_where . ' AND ';
399 }
400
401 if ($subid != null && array_key_exists($subid, $this->suboptions)) {
402 $where .= XDB::format($this->optfield . ' = {?} AND ', $subid);
403 }
404
405 $tests = $this->mkTests($this->valfield, $text);
406 if (!is_null($this->valfield2)) {
407 $tests = array_merge($tests, $this->mkTests($this->valfield2, $text));
408 }
409
410 $where .= '(' . implode(' OR ', $tests) . ')';
411
412 return XDB::iterator('SELECT ' . $this->valfield . ' AS field'
413 . ($this->ac_distinct ? (', COUNT(DISTINCT ' . $this->ac_unique . ') AS nb') : '')
414 . ($this->ac_withid ? (', ' . $this->idfield . ' AS id') : '') . '
415 FROM ' . $this->from . '
416 ' . $this->ac_join . '
417 WHERE ' . $where . '
418 GROUP BY ' . $this->valfield . '
419 ORDER BY ' . ($this->ac_distinct ? 'nb DESC' : $this->valfield) . '
420 LIMIT ' . self::AUTOCOMPLETE_LIMIT);
421 }
422}
423// }}}
424
5c32cc1a
RB
425// {{{ class DE_NameTypes
426// returns 'system' names ('lastname', 'lastname_marital', ...)
427class DE_NameTypes extends DirEnumeration
428{
cf570028 429 public $capabilities = 0x005; // self::HAS_OPTIONS | self::SAVE_IN_SESSION;
2998edf1 430
5c32cc1a
RB
431 protected $from = 'profile_name_enum';
432 protected $valfield = 'type';
433}
434// }}}
435
b270577e
SJ
436// {{{ class DE_Names
437// returns 'system' names ('lastname', 'lastname_marital', ...)
438class DE_Names extends DirEnumeration
439{
440 public $capabilities = 0x005; // self::HAS_OPTIONS | self::SAVE_IN_SESSION;
441
442 protected $from = 'profile_name_enum';
443 protected $idfield = 'type';
444 protected $valfield = 'name';
445}
446// }}}
447
5ab3ef57
RB
448/** GROUPS
449 */
98925aab 450// {{{ class DE_Binets
e39e72a6
RB
451class DE_Binets extends DirEnumeration
452{
5c8a71f2 453 protected $from = 'profile_binet_enum';
30b9ca46 454
5c8a71f2 455 protected $ac_join = 'INNER JOIN profile_binets ON (profile_binet_enum.id = profile_binets.binet_id)';
bdd977d7 456 protected $ac_unique = 'profile_binets.pid';
e39e72a6 457}
98925aab
RB
458// }}}
459
460// {{{ class DE_Sections
e39e72a6
RB
461class DE_Sections extends DirEnumeration
462{
5c8a71f2 463 protected $from = 'profile_section_enum';
30b9ca46 464
5c8a71f2 465 protected $ac_join = 'INNER JOIN profiles ON (profiles.section = profile_section_enum.id)';
30b9ca46 466 protected $ac_unique = 'profiles.pid';
e39e72a6 467}
98925aab
RB
468// }}}
469
5ab3ef57
RB
470// {{{ class DE_GroupesX
471class DE_GroupesX extends DirEnumeration
472{
2998edf1
RB
473 protected $idfield = 'groups.id';
474 protected $valfield = 'groups.nom';
475 protected $valfield2 = 'groups.diminutif';
476 protected $from = 'groups';
5ab3ef57
RB
477 protected $where = 'WHERE (cat = \'GroupesX\' OR cat = \'Institutions\') AND pub = \'public\'';
478
70bcaa84 479 protected $ac_join = "INNER JOIN group_members ON (groups.id = group_members.asso_id
2998edf1
RB
480 AND (groups.cat = 'GroupesX' OR groups.cat = 'Institutions')
481 AND groups.pub = 'public')";
482 protected $ac_unique = 'group_members.uid';
5ab3ef57
RB
483}
484// }}}
485
486/** EDUCATION
487 */
fb3b6547
RB
488// {{{ class DE_EducationSchools
489class DE_EducationSchools extends DirEnumeration
e39e72a6 490{
70bcaa84 491 protected $idfield = 'profile_education_enum.id';
2998edf1
RB
492 protected $valfield = 'profile_education_enum.name';
493 protected $valfield2 = 'profile_education_enum.abbreviation';
30b9ca46
RB
494 protected $from = 'profile_education_enum';
495
496 protected $ac_join = 'INNER JOIN profile_education ON (profile_education.eduid = profile_education_enum.id)';
ce0b2c6f 497 protected $ac_unique = 'profile_education.pid';
e39e72a6 498}
98925aab
RB
499// }}}
500
fb3b6547
RB
501// {{{ class DE_EducationDegrees
502class DE_EducationDegrees extends DirEnumeration
e39e72a6 503{
2998edf1 504 public $capabilities = self::HAS_OPTIONS;
21b67462 505
2998edf1
RB
506 protected $idfield = 'profile_education_degree.degreeid';
507 protected $optfield = 'profile_education_degree.eduid';
508 protected $valfield = 'profile_education_degree_enum.degree';
509 protected $from = 'profile_education_degree_enum';
510 protected $join = 'INNER JOIN profile_education_degree ON (profile_education_degree.degreeid = profile_education_degree_enum.id)';
e5fb8f87 511
21b67462 512}
98925aab
RB
513// }}}
514
fb3b6547
RB
515// {{{ class DE_EducationFields
516class DE_EducationFields extends DirEnumeration
21b67462 517{
2998edf1 518 protected $valfield = 'profile_education_field_enum.field';
30b9ca46
RB
519 protected $from = 'profile_education_field_enum';
520
521 protected $ac_join = 'INNER JOIN profile_education ON (profile_education.fieldid = profile_education_field_enum.id)';
ce0b2c6f 522 protected $ac_unique = 'profile_education.pid';
e39e72a6 523}
98925aab
RB
524// }}}
525
5ab3ef57
RB
526/** GEOLOC
527 */
98925aab 528// {{{ class DE_Nationalities
e39e72a6
RB
529class DE_Nationalities extends DirEnumeration
530{
2998edf1
RB
531 protected $idfield = 'geoloc_countries.iso_3166_1_a2';
532 protected $valfield = 'geoloc_countries.nationalityFR';
533 protected $valfield2 = 'geoloc_countries.nationality';
534 protected $from = 'geoloc_countries';
535 protected $join = 'INNER JOIN profiles ON (geoloc_countries.iso_3166_1_a2 IN (profiles.nationality1, profiles.nationality2, profiles.nationality3))';
30b9ca46 536
2998edf1 537 protected $ac_join = 'INNER JOIN profiles ON (geoloc_countries.iso_3166_1_a2 IN (profiles.nationality1, profiles.nationality2, profiles.nationality3))';
30b9ca46 538 protected $ac_unique = 'profiles.pid';
e39e72a6 539}
98925aab
RB
540// }}}
541
542// {{{ class DE_Countries
e39e72a6
RB
543class DE_Countries extends DirEnumeration
544{
2998edf1
RB
545 protected $idfield = 'geoloc_countries.iso_3166_1_a2';
546 protected $valfield = 'geoloc_countries.countryFR';
547 protected $valfield2 = 'geoloc_countries.country';
30b9ca46
RB
548 protected $from = 'geoloc_countries';
549
70bcaa84 550 protected $ac_join = 'INNER JOIN profile_addresses ON (geoloc_countries.iso_3166_1_a2 = profile_addresses.countryId)';
30b9ca46 551 protected $ac_unique = 'profile_addresses.pid';
e39e72a6 552}
98925aab
RB
553// }}}
554
555// {{{ class DE_AdminAreas
2998edf1 556class DE_AdminAreas extends DE_WithSuboption
e39e72a6 557{
2998edf1
RB
558 protected $idfield = 'geoloc_administrativeareas.id';
559 protected $optfield = 'geoloc_administrativeareas.country';
560 protected $valfield = 'geoloc_administrativeareas.name';
561 protected $from = 'geoloc_administrativeareas';
9ed7f5bc 562
2998edf1
RB
563 protected $ac_join = 'INNER JOIN profile_addresses ON (profile_addresses.administrativeAreaId = geoloc_administrativeareas.id)';
564 protected $ac_unique = 'profile_addresses.pid';
e39e72a6 565}
98925aab
RB
566// }}}
567
5ab3ef57
RB
568// {{{ class DE_Localities
569class DE_Localities extends DirEnumeration
e39e72a6 570{
70bcaa84 571 protected $idfield = 'geoloc_localities.id';
2998edf1
RB
572 protected $valfield = 'geoloc_localities.name';
573 protected $from = 'geoloc_localities';
30b9ca46 574
70bcaa84 575 protected $ac_join = 'INNER JOIN profile_addresses ON (profile_addresses.localityID = geoloc_localities.id)';
2998edf1 576 protected $ac_unique = 'profile_addresses.pid';
5ab3ef57
RB
577}
578// }}}
579
580/** JOBS
581 */
582// {{{ class DE_Companies
583class DE_Companies extends DirEnumeration
584{
70bcaa84 585 protected $idfield = 'profile_job_enum.id';
2998edf1
RB
586 protected $valfield = 'profile_job_enum.name';
587 protected $valfield2 = 'profile_job_enum.acronym';
588 protected $from = 'profile_job_enum';
5ab3ef57 589
2998edf1 590 protected $ac_join = 'INNER JOIN profile_job ON (profile_job.jobid = profile_job_enum.id)';
ce0b2c6f 591 protected $ac_unique = 'profile_job.pid';
e39e72a6 592}
98925aab
RB
593// }}}
594
595// {{{ class DE_Sectors
e39e72a6
RB
596class DE_Sectors extends DirEnumeration
597{
70bcaa84 598 protected $idfield = 'profile_job_sector_enum.id';
2998edf1 599 protected $valfield = 'profile_job_sector_enum.name';
30b9ca46
RB
600 protected $from = 'profile_job_sector_enum';
601
602 protected $ac_join = 'INNER JOIN profile_job ON (profile_job_sector_enum.id = profile_job.sectorid)';
ce0b2c6f 603 protected $ac_unique = 'profile_job.pid';
e39e72a6 604}
98925aab
RB
605// }}}
606
5ab3ef57 607// {{{ class DE_JobDescription
70bcaa84 608class DE_JobDescription extends DirEnumeration
5ab3ef57 609{
2998edf1
RB
610 protected $valfield = 'profile_job.description';
611 protected $from = 'profile_job';
612 protected $idfield = 'profile_job.pid';
5ab3ef57 613
2998edf1 614 protected $ac_unique = 'profile_job.pid';
5ab3ef57
RB
615}
616// }}}
617
618/** NETWORKING
619 */
98925aab 620// {{{ class DE_Networking
e39e72a6
RB
621class DE_Networking extends DirEnumeration
622{
1f5cd004 623 protected $idfield = 'profile_networking_enum.nwid';
30b9ca46 624 protected $valfield = 'profile_networking_enum.name';
e39e72a6 625 protected $from = 'profile_networking_enum';
30b9ca46
RB
626
627
1f5cd004 628 protected $ac_join = 'INNER JOIN profile_networking ON (profile_networking.nwid = profile_networking_enum.nwid)';
ce0b2c6f 629 protected $ac_unique = 'profile_networking.pid';
e39e72a6 630}
98925aab 631// }}}
69ef14a5 632
eb872b24
RB
633/** MEDALS
634 */
635// {{{ class DE_Medals
636class DE_Medals extends DirEnumeration
637{
638 protected $from = 'profile_medal_enum';
639
640 protected $ac_join = 'INNER JOIN profile_medals ON (profile_medals.mid = profile_medal_enum.id)';
641 protected $ac_unique = 'profile_medals.pid';
642}
643// }}}
644
69ef14a5 645// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
e39e72a6 646?>