From: Florent Bruneau Date: Wed, 4 Mar 2009 22:05:47 +0000 (+0100) Subject: Fetch educations. X-Git-Tag: xorg/1.0.0~332^2~350 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4bc5b8f0002d9586b8743129d00de984170a5e8e;p=platal.git Fetch educations. Signed-off-by: Florent Bruneau --- diff --git a/classes/profile.php b/classes/profile.php index 7828ceb..b856508 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -35,14 +35,15 @@ class Profile const ADDRESS_POSTAL = 0x000008; const EDUCATION_MAIN = 0x000010; - const EDUCATION_ALL = 0x000020; - const EDUCATION_FINISHED = 0x000040; - const EDUCATION_CURRENT = 0x000080; + const EDUCATION_EXTRA = 0x000020; + const EDUCATION_ALL = 0x000040; + const EDUCATION_FINISHED = 0x000080; + const EDUCATION_CURRENT = 0x000100; - const JOBS_MAIN = 0x000100; - const JOBS_ALL = 0x000200; - const JOBS_FINISHED = 0x000400; - const JOBS_CURRENT = 0x000800; + const JOBS_MAIN = 0x001000; + const JOBS_ALL = 0x002000; + const JOBS_FINISHED = 0x004000; + const JOBS_CURRENT = 0x008000; private $pid; private $hrpid; @@ -154,7 +155,10 @@ class Profile $this->visibility = self::$v_values[$visibility]; } - public function getAddresses($flags) + + /* Addresses + */ + public function getAddresses($flags, $limit = null) { $where = XDB::format('pa.pid = {?}', $this->id()); if ($flags & self::ADDRESS_MAIN) { @@ -176,6 +180,7 @@ class Profile if (count($type) > 0) { $where .= ' AND pa.type IN ' . XDB::formatArray($type); } + $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit); return XDB::iterator('SELECT pa.text, pa.postalCode, pa.type, pa.latitude, pa.longitude, gl.name AS locality, gas.name AS subAdministrativeArea, ga.name AS administrativeArea, gc.countryFR AS country, @@ -188,7 +193,9 @@ class Profile LEFT JOIN geoloc_administrativeareas AS ga ON (ga.id = pa.administrativeAreaId) LEFT JOIN geoloc_administrativeareas AS gas ON (gas.id = pa.subAdministrativeAreaId) LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = pa.countryId) - WHERE ' . $where); + WHERE ' . $where . ' + ORDER BY pa.id + ' . $limit); } public function getMainAddress() @@ -201,6 +208,42 @@ class Profile } } + + /* Educations + */ + public function getEducations($flags, $limit = null) + { + $where = XDB::format('pe.uid = {?}', $this->id()); + if ($flags & self::EDUCATION_MAIN) { + $where .= ' AND FIND_IN_SET(\'primary\', pe.flags)'; + } else if ($flags & self::EDUCATION_EXTRA) { + $where .= ' AND NOT FIND_IN_SET(\'primary\', pe.flags)'; + } else if ($flags & self::EDUCATION_FINISHED) { + $where .= ' AND pe.grad_year <= YEAR(CURDATE())'; + } else if ($flags & self::EDUCATION_CURRENT) { + $where .= ' AND pe.grad_year > YEAR(CURDATE())'; + } + $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit); + return XDB::iterator('SELECT pe.entry_year, pe.grad_year, pe.program, + pee.name AS school, pee.abbreviation AS school_short, pee.url AS school_url, gc.countryFR AS country, + pede.degree, pede.abbreviation AS degree_short, pede.level AS degree_level, pefe.field, + FIND_IN_SET(\'primary\', pe.flags) AS prim + FROM profile_education AS pe + INNER JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) + LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = pee.country) + INNER JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) + LEFT JOIN profile_education_field_enum AS pefe ON (pe.fieldid = pefe.id) + WHERE ' . $where . ' + ORDER BY NOT FIND_IN_SET(\'primary\', pe.flags), pe.entry_year, pe.id + ' . $limit); + } + + public function getExtraEducations($limit = null) + { + return $this->getEducations(self::EDUCATION_EXTRA, $limit); + } + + public function owner() { return User::getSilent($this); diff --git a/include/education.func.inc.php b/include/education.func.inc.php index 68ec9b7..a88b4e3 100644 --- a/include/education.func.inc.php +++ b/include/education.func.inc.php @@ -164,8 +164,16 @@ function education_fmt($name, $url, $degree, $grad_year, $field, $program, $sexe function _education_fmt($params, &$smarty) { - extract($params); - return education_fmt($name, $url, $degree, $grad_year, $field, $program, $sexe, $long); + $params = new PlDict($params); + $edu = $params->v('edu'); + if (!$params->has('sex')) { + $profile = $params->v('profile'); + $sex = $profile->isFemale(); + } else { + $sex = $params->b('sex'); + } + return education_fmt($edu['school_short'], $edu['school_url'], $edu['degree_short'], $edu['grad_year'], + $edu['field'], $edu['program'], $sex, $params->b('long')); } Platal::page()->register_function('education_fmt', '_education_fmt'); diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 1b7177a..6084e29 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -60,17 +60,9 @@ {if $profile->nationality3} {$profile->nationality3}  {/if} - {$profile->promo()} - - {if $c.eduname0}, {education_fmt name=$c.eduname0 url=$c.eduurl0 degree=$c.edudegree0 - grad_year=$c.edugrad_year0 field=$c.edufield0 program=$c.eduprogram0 sexe=$c.sexe}{* - *}{/if}{if $c.eduname1}, {education_fmt name=$c.eduname1 url=$c.eduurl1 degree=$c.edudegree1 - grad_year=$c.edugrad_year1 field=$c.edufield1 program=$c.eduprogram1 sexe=$c.sexe}{* - *}{/if}{if $c.eduname2}, {education_fmt name=$c.eduname2 url=$c.eduurl2 degree=$c.edudegree2 - grad_year=$c.edugrad_year2 field=$c.edufield2 program=$c.eduprogram2 sexe=$c.sexe}{* - *}{/if}{if $c.eduname3}, {education_fmt name=$c.eduname3 url=$c.eduurl3 degree=$c.edudegree3 - grad_year=$c.edugrad_year3 field=$c.edufield3 program=$c.eduprogram3 sexe=$c.sexe}{* - *}{/if}{if $c.dcd}, décédé{if $c.sexe}e{/if} le {$c.deces|date_format}{/if} + {$profile->promo()}{* + *}{iterate from=$profile->getExtraEducations(4) item=edu}, {education_fmt edu=$edu profile=$profile}{/iterate}{* + *}{if $dead}, {"décédé"|sex:"décédée":$user} le {$orfile->deathdate|date_format}{/if} @@ -122,7 +114,7 @@
{if !$dead} {assign var=address value=$profile->getMainAddress()} - {if $c.web || $c.mobile || $address.country || $c.entreprise || (!$c.dcd && !$c.actif )} + {if $c.web || $c.mobile || $address.country || $c.entreprise || (!$dead && !$registered)} {if $c.web}