X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fdirenum.php;h=567f4de1314bac4c22dc3953be246691e691a384;hb=a81ee98706ff11231e6d708270e2fb1c97775650;hp=7dbf40c213033027534a31f779fa07fce2af7e3f;hpb=3ad5702f73027ae3ec5f87afc9eb2ab7b16f30af;p=platal.git diff --git a/classes/direnum.php b/classes/direnum.php index 7dbf40c..567f4de 100644 --- a/classes/direnum.php +++ b/classes/direnum.php @@ -40,6 +40,9 @@ class DirEnum const EDUDEGREES = 'educationdegrees'; const EDUFIELDS = 'educationfields'; + const CORPS = 'corps'; + const CORPSRANKS = 'corpsranks'; + const NATIONALITIES = 'nationalities'; const COUNTRIES = 'countries'; const ADMINAREAS = 'adminareas'; @@ -48,6 +51,7 @@ class DirEnum const COMPANIES = 'companies'; const SECTORS = 'sectors'; const JOBDESCRIPTION = 'jobdescription'; + const JOBTERMS = 'jobterms'; const NETWORKS = 'networking'; @@ -57,13 +61,14 @@ class DirEnum 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); } } @@ -525,6 +530,32 @@ class DE_EducationFields extends DirEnumeration } // }}} +// {{{ class DE_Corps +class DE_Corps extends DirEnumeration +{ + 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 = '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 = '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 = 'profile_corps.pid'; + protected $ac_join = 'INNER JOIN profile_corps ON (profile_corps.rankid = profile_corps_rank_enum.id)'; +} +// }}} + /** GEOLOC */ // {{{ class DE_Nationalities @@ -617,6 +648,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