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