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