* 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();
/** 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()
{
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
/** An internal array of ID => optionTxt
*/
- protected $options;
+ protected $options = null;
/** Description of the MySQL storage of the fields
*/
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
}
// }}}
+/** GROUPS
+ */
// {{{ class DE_Binets
class DE_Binets 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';
}
// }}}
-// {{{ 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';
public function getOptions($eduid = null)
{
+ $this->_fetchOptions();
if ($eduid == null) {
return PlIteratorUtils::fromArray($this->options, 1, true);
}
}
// }}}
-// {{{ 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';
}
// }}}
+/** GEOLOC
+ */
// {{{ class DE_Nationalities
class DE_Nationalities extends DirEnumeration
{
public function getOptions($country = null)
{
+ $this->_fetchOptions();
+
if ($country == null) {
return PlIteratorUtils::fromArray($this->options, 1, true);
}
}
// }}}
-// {{{ 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';
}
// }}}
}
// }}}
+// {{{ 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
{