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