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