X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fdirenum.php;h=5350f0e815284442104bbfa8cf80b3b9375230ac;hb=4ad7b8ca262ce5badfff6d5f23deb091913f0606;hp=c6fbf0ddceccfdffa24b4e73d153505764bdfb5f;hpb=843a2191e4c76f0beb00c754f06974de76791238;p=platal.git diff --git a/classes/direnum.php b/classes/direnum.php index c6fbf0d..5350f0e 100644 --- a/classes/direnum.php +++ b/classes/direnum.php @@ -49,24 +49,28 @@ class DirEnum const LOCALITIES = 'localities'; const COMPANIES = 'companies'; - const SECTORS = 'sectors'; const JOBDESCRIPTION = 'jobdescription'; + const JOBTERMS = 'jobterms'; const NETWORKS = 'networking'; const MEDALS = 'medals'; + const ACCOUNTTYPES = 'accounttypes'; + const SKINS = 'skins'; + static private $enumerations = array(); static private function init($type) { - if (S::has('__DE_' . $type)) { + if (Platal::globals()->cacheEnabled() && S::has('__DE_' . $type)) { self::$enumerations[$type] = S::v('__DE_' . $type); } else { $cls = "DE_" . ucfirst($type); $obj = new $cls(); self::$enumerations[$type] = $obj; - if ($obj->capabilities & DirEnumeration::SAVE_IN_SESSION) { + if (Platal::globals()->cacheEnabled() + && $obj->capabilities & DirEnumeration::SAVE_IN_SESSION) { S::set('__DE_' . $type, $obj); } } @@ -531,26 +535,26 @@ class DE_EducationFields extends DirEnumeration // {{{ class DE_Corps class DE_Corps extends DirEnumeration { - protected $idfield = 'corps_enum.id'; - protected $valfield = 'corps_enum.name'; - protected $valfield2 = 'corps_enum.abbrev'; - protected $from = 'corps_enum'; + protected $idfield = 'profile_corps_enum.id'; + protected $valfield = 'profile_corps_enum.name'; + protected $valfield2 = 'profile_corps_enum.abbrev'; + protected $from = 'profile_corps_enum'; - protected $ac_unique = 'corps.pid'; - protected $ac_join = 'INNER JOIN corps ON (corps.current_corpsid = corps_enum.id)'; + protected $ac_unique = 'profile_corps.pid'; + protected $ac_join = 'INNER JOIN profile_corps ON (profile_corps.current_corpsid = profile_corps_enum.id)'; } // }}} // {{{ class DE_CorpsRanks class DE_CorpsRanks extends DirEnumeration { - protected $idfield = 'corps_rank_enum.id'; - protected $valfield = 'corps_rank_enum.name'; - protected $valfield2 = 'corps_rank_enum.abbrev'; - protected $from = 'corps_rank_enum'; + protected $idfield = 'profile_corps_rank_enum.id'; + protected $valfield = 'profile_corps_rank_enum.name'; + protected $valfield2 = 'profile_corps_rank_enum.abbrev'; + protected $from = 'profile_corps_rank_enum'; - protected $ac_unique = 'corps.pid'; - protected $ac_join = 'INNER JOIN corps ON (corps.rankid = corps_rank_enum.id)'; + protected $ac_unique = 'profile_corps.pid'; + protected $ac_join = 'INNER JOIN profile_corps ON (profile_corps.rankid = profile_corps_rank_enum.id)'; } // }}} @@ -623,18 +627,6 @@ class DE_Companies extends DirEnumeration } // }}} -// {{{ class DE_Sectors -class DE_Sectors extends DirEnumeration -{ - protected $idfield = 'profile_job_sector_enum.id'; - protected $valfield = 'profile_job_sector_enum.name'; - protected $from = 'profile_job_sector_enum'; - - protected $ac_join = 'INNER JOIN profile_job ON (profile_job_sector_enum.id = profile_job.sectorid)'; - protected $ac_unique = 'profile_job.pid'; -} -// }}} - // {{{ class DE_JobDescription class DE_JobDescription extends DirEnumeration { @@ -646,6 +638,30 @@ class DE_JobDescription extends DirEnumeration } // }}} +// {{{ class DE_JobTerms +class DE_JobTerms extends DirEnumeration +{ + // {{{ function getAutoComplete + public function getAutoComplete($text) + { + $tokens = JobTerms::tokenize($text.'%'); + if (count($tokens) == 0) { + return PlIteratorUtils::fromArray(array()); + } + $token_join = JobTerms::token_join_query($tokens, 'e'); + return XDB::iterator('SELECT e.jtid AS id, e.full_name AS field, COUNT(DISTINCT p.pid) AS nb + FROM profile_job_term_enum AS e + INNER JOIN profile_job_term_relation AS r ON (r.jtid_1 = e.jtid) + INNER JOIN profile_job_term AS p ON (r.jtid_2 = p.jtid) + '.$token_join.' + GROUP BY e.jtid + ORDER BY nb DESC, field + LIMIT ' . self::AUTOCOMPLETE_LIMIT); + } + // }}} +} +// }}} + /** NETWORKING */ // {{{ class DE_Networking @@ -673,5 +689,29 @@ class DE_Medals extends DirEnumeration } // }}} +/** ACCOUNTS + */ +// {{{ class DE_AccountTypes +class DE_AccountTypes extends DirEnumeration +{ + public $capabilities = 0x005; // self::HAS_OPTIONS | self::SAVE_IN_SESSION; + + protected $from = 'account_types'; + protected $valfield = 'perms'; + protected $idfield = 'type'; +} +// }}} + +// {{{ class DE_Skins +class DE_Skins extends DirEnumeration +{ + public $capabilities = 0x005; // self::HAS_OPTIONS | self::SAVE_IN_SESSION; + + protected $from = 'skins'; + protected $valfield = 'name'; + protected $idfield = 'skin_tpl'; +} +// }}} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>