X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fdirectory.enums.inc.php;h=02c013fe54fbf74d1beacc32085970d55a70e5f0;hb=69fffc4bfc98948ba2357c3d0b1599e90190965a;hp=ad7d694fabbdd1c9bbf58ecb60b921419c7a0004;hpb=30b9ca461594c5976c12c48b3327bf0f3c92be36;p=platal.git diff --git a/include/directory.enums.inc.php b/include/directory.enums.inc.php index ad7d694..02c013f 100644 --- a/include/directory.enums.inc.php +++ b/include/directory.enums.inc.php @@ -30,19 +30,23 @@ class DirEnum * being DE_$basename). */ const BINETS = 'binets'; + const GROUPESX = 'groupesx'; const SECTIONS = 'sections'; - const SCHOOLS = 'schools'; - const DEGREES = 'degrees'; - const STUDIESDOMAINS = 'studiesdomains'; + + const EDUSCHOOLS = 'educationschools'; + const EDUDEGREES = 'educationdegrees'; + const EDUFIELDS = 'educationfields'; + const NATIONALITIES = 'nationalities'; const COUNTRIES = 'countries'; - const GROUPESX = 'groupesx'; + const ADMINAREAS = 'adminareas'; + const LOCALITIES = 'localities'; + + const COMPANIES = 'companies'; const SECTORS = 'sectors'; + const JOBDESCRIPTION = 'jobdescription'; + const NETWORKS = 'networking'; - const ADMINAREAS = 'adminareas'; - const LOCALITIES = 'localities'; // TODO - const COMPANIES = 'companies'; // TODO - const JOBDESCRIPTION = 'jobdescription'; // TODO static private $enumerations = array(); @@ -55,7 +59,6 @@ class DirEnum /** Retrieves all options for a given type * @param $type Type of enum for which options are requested * @return XorgDbIterator over the results - * TODO : Find a way to get either an array, or the adequate PlIterator */ static public function getOptions() { @@ -68,6 +71,21 @@ class DirEnum return call_user_func_array(array($obj, 'getOptions'), $args); } + /** Retrieves all options for a given type + * @param $type Type of enum for which options are requested + * @return Array of the results the results + */ + static public function getOptionsArray() + { + $args = func_get_args(); + $type = array_shift($args); + if (!array_key_exists($type, self::$enumerations)) { + self::init($type); + } + $obj = self::$enumerations[$type]; + return call_user_func_array(array($obj, 'getOptionsArray'), $args); + } + /** Retrieves all options with number of profiles for autocompletion * @param $type Type of enum for which options are requested * @param $text Text to autocomplete @@ -114,7 +132,7 @@ abstract class DirEnumeration /** An internal array of ID => optionTxt */ - protected $options; + protected $options = null; /** Description of the MySQL storage of the fields */ @@ -134,15 +152,29 @@ abstract class DirEnumeration protected $ac_distinct = true; // Whether we want to keep only distinct valfield value protected $ac_withid = true; // Do we want to fetch id too ? - public function __construct() { - $this->loadOptions(); + protected function _fetchOptions() + { + if (is_null($this->options)) { + $this->loadOptions(); + } } public function getOptions() { + $this->_fetchOptions(); return $this->options; } + public function getOptionsArray() + { + $this->_fetchOptions(); + $options = array(); + while ($row = $this->options->next()) { + $options[$row['id']] = $row['field']; + } + return $options; + } + // {{{ function getIDs /** Retrieves possible IDs for given text * @param $text Text to search for IDs @@ -251,6 +283,8 @@ abstract class DirEnumeration } // }}} +/** GROUPS + */ // {{{ class DE_Binets class DE_Binets extends DirEnumeration { @@ -271,8 +305,26 @@ class DE_Sections extends DirEnumeration } // }}} -// {{{ class DE_Schools -class DE_Schools extends DirEnumeration +// {{{ class DE_GroupesX +class DE_GroupesX extends DirEnumeration +{ + protected $idfield = 'asso.id'; + protected $valfield = 'asso.nom'; + protected $valfield2 = 'asso.diminutif'; + protected $from = '#groupex#.asso AS asso'; + protected $where = 'WHERE (cat = \'GroupesX\' OR cat = \'Institutions\') AND pub = \'public\''; + + protected $ac_join = "INNER JOIN #groupex#.membres AS memb ON (asso.id = memb.asso_id + AND (asso.cat = 'GroupesX' OR asso.cat = 'Institutions') + AND asso.pub = 'public')"; + protected $ac_unique = 'memb.uid'; +} +// }}} + +/** EDUCATION + */ +// {{{ class DE_EducationSchools +class DE_EducationSchools extends DirEnumeration { protected $valfield = 'name'; protected $valfield2 = 'abbreviation'; @@ -283,8 +335,8 @@ class DE_Schools extends DirEnumeration } // }}} -// {{{ class DE_Degrees -class DE_Degrees extends DirEnumeration +// {{{ class DE_EducationDegrees +class DE_EducationDegrees extends DirEnumeration { protected $from = 'profile_education_degree_enum'; protected $valfield = 'degree'; @@ -310,6 +362,7 @@ class DE_Degrees extends DirEnumeration public function getOptions($eduid = null) { + $this->_fetchOptions(); if ($eduid == null) { return PlIteratorUtils::fromArray($this->options, 1, true); } @@ -336,8 +389,8 @@ class DE_Degrees extends DirEnumeration } // }}} -// {{{ class DE_StudiesSector -class DE_StudiesSector extends DirEnumeration +// {{{ class DE_EducationFields +class DE_EducationFields extends DirEnumeration { protected $valfield = 'field'; protected $from = 'profile_education_field_enum'; @@ -347,6 +400,8 @@ class DE_StudiesSector extends DirEnumeration } // }}} +/** GEOLOC + */ // {{{ class DE_Nationalities class DE_Nationalities extends DirEnumeration { @@ -397,6 +452,8 @@ class DE_AdminAreas extends DirEnumeration public function getOptions($country = null) { + $this->_fetchOptions(); + if ($country == null) { return PlIteratorUtils::fromArray($this->options, 1, true); } @@ -422,19 +479,28 @@ class DE_AdminAreas extends DirEnumeration } // }}} -// {{{ class DE_GroupesX -class DE_GroupesX extends DirEnumeration +// {{{ class DE_Localities +class DE_Localities extends DirEnumeration { - protected $idfield = 'asso.id'; - protected $valfield = 'asso.nom'; - protected $valfield2 = 'asso.diminutif'; - protected $from = '#groupex#.asso AS asso'; - protected $where = 'WHERE (cat = \'GroupesX\' OR cat = \'Institutions\') AND pub = \'public\''; + protected $valfield = 'gl.name'; + protected $from = 'geoloc_localities AS gl'; - protected $ac_join = "INNER JOIN #groupex#.membres AS memb ON (asso.id = memb.asso_id - AND (asso.cat = 'GroupesX' OR asso.cat = 'Institutions') - AND asso.pub = 'public')"; - protected $ac_unique = 'memb.uid'; + protected $ac_join = 'profile_addresses AS pa ON (pa.localityID = gl.id)'; + protected $ac_unique = 'pa.pid'; +} +// }}} + +/** JOBS + */ +// {{{ class DE_Companies +class DE_Companies extends DirEnumeration +{ + protected $valfield = 'pje.name'; + protected $valfield2 = 'pje.acronym'; + protected $from = 'profile_job_enum AS pje'; + + protected $ac_join = 'INNER JOIN profile_job AS pj ON (pj.jobid = pje.id)'; + protected $ac_unique = 'pj.uid'; } // }}} @@ -449,6 +515,19 @@ class DE_Sectors extends DirEnumeration } // }}} +// {{{ class DE_JobDescription +class DE_JobDescription +{ + protected $valfield = 'pj.description'; + protected $from = 'profile_job AS pj'; + protected $idfield = 'pj.pid'; + + protected $ac_unique = 'pj.pid'; +} +// }}} + +/** NETWORKING + */ // {{{ class DE_Networking class DE_Networking extends DirEnumeration {