X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fprofile.php;h=249de86e58336680d22dfaaf180472609c63ea34;hb=e4860774e45eac2d62cf80d4fd70fac2e0cf1da1;hp=df2771e75e8e99929f3344ff4b2728affea9ad4c;hpb=c52be69950d31821a8a091f08ad9170e1042eaf8;p=platal.git diff --git a/classes/profile.php b/classes/profile.php index df2771e..249de86 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -1,6 +1,6 @@ 'polytechnicien', + self::DEGREE_M => 'master', + self::DEGREE_D => 'docteur' + ); + static public $cycle_prefixes = array( + self::DEGREE_X => 'X', + self::DEGREE_M => 'M', + self::DEGREE_D => 'D' + ); + static public $name_variants = array( self::LASTNAME => array(self::VN_MARITAL, self::VN_ORDINARY), self::FIRSTNAME => array(self::VN_ORDINARY, self::VN_INI, self::VN_OTHER) @@ -113,6 +124,7 @@ class Profile 'networking' => 'Messageries…', 'tels' => 'Téléphones', 'edus' => 'Formations', + 'main_edus' => 'Formations à l\'X', 'promo' => 'Promotion de sortie', 'birthdate' => 'Date de naissance', 'yourself' => 'Nom affiché', @@ -181,14 +193,26 @@ class Profile return false; } - public function promo() + public function promo($details = false) { + if ($details && ($this->program || $this->fieldid)) { + $text = array(); + if ($this->program) { + $text[] = $this->program; + } + if ($this->fieldid) { + $fieldsList = DirEnum::getOptions(DirEnum::EDUFIELDS); + $text[] = $fieldsList[$this->fieldid]; + } + return $this->promo . ' (' . implode(', ', $text) . ')'; + } + return $this->promo; } public function yearpromo() { - return intval(substr($this->promo, 1, 4)); + return $this->promo_year; } /** Check if user is an orange (associated with several promos) @@ -527,8 +551,10 @@ class Profile } return $this->photo; } else if ($fallback) { - return PlImage::fromFile(dirname(__FILE__).'/../htdocs/images/none.png', - 'image/png'); + if ($this->mainEducation() == 'X') { + return PlImage::fromFile(dirname(__FILE__) . '/../htdocs/images/none_x.png', 'image/png'); + } + return PlImage::fromFile(dirname(__FILE__) . '/../htdocs/images/none_md.png', 'image/png'); } return null; } @@ -841,6 +867,24 @@ class Profile return ($isOk && ($maxlen > 2 || $maxlen == strlen($_lastname))); } + /* Export to JSON + */ + public function export() + { + return array( + 'hrpid' => $this->hrid(), + 'display_name' => $this->shortName(), + 'full_name' => $this->fullName(), + 'directory_name' => $this->directory_name, + 'promo' => $this->promo(), + 'year_promo' => $this->yearpromo(), + 'is_active' => $this->isActive(), + 'first_name' => $this->firstName(), + 'last_name' => $this->lastName(), + 'is_female' => $this->isFemale(), + ); + } + private static function fetchProfileData(array $pids, $respect_order = true, $fields = 0x0000, $visibility = null) { if (count($pids) == 0) { @@ -860,7 +904,7 @@ class Profile IF ({?}, p.cv, NULL) AS cv, p.medals_pub, p.alias_pub, p.email_directory, p.last_change, p.nationality1, p.nationality2, p.nationality3, IF (p.freetext_pub IN {?}, p.freetext, NULL) AS freetext, - pe.entry_year, pe.grad_year, + pe.entry_year, pe.grad_year, pe.promo_year, pe.program, pe.fieldid, IF ({?}, pse.text, NULL) AS section, pn_f.name AS firstname, pn_l.name AS lastname, IF( {?}, pn_n.name, NULL) AS nickname, @@ -1067,8 +1111,8 @@ class Profile continue; } $pid = $key['pid']; - $toks = preg_split('/[ \'\-]+/', strtolower(replace_accent($key['name'])), - -1, PREG_SPLIT_NO_EMPTY); + require_once 'name.func.inc.php'; + $toks = split_name_for_search($key['name']); $toks = array_reverse($toks); /* Split the score between the tokens to avoid the user to be over-rated.