From: Florent Bruneau Date: Fri, 6 Mar 2009 21:51:50 +0000 (+0100) Subject: Fetch jobs. X-Git-Tag: xorg/1.0.0~332^2~345 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e718bd187b7460423a8a5b0fba032a6d271d86c7;p=platal.git Fetch jobs. Signed-off-by: Florent Bruneau --- diff --git a/classes/profile.php b/classes/profile.php index d68c959..11b08ed 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -286,6 +286,44 @@ class Profile } + /** Jobs + */ + + public function getJobs($flags, $limit = null) + { + $where = XDB::format('pj.uid = {?}', $this->id()); + $cond = 'TRUE'; + if ($this->visibility) { + $where .= ' AND pj.pub IN ' . XDB::formatArray($this->visibility); + $cond = 'pj.email_pub IN ' . XDB::formatArray($this->visibility); + } + $limit = is_null($limit) ? '' : XDB::format('LIMIT {?}', (int)$limit); + return XDB::iterator('SELECT pje.name, pje.acronym, pje.url, pje.email, pje.NAF_code, + pj.description, pj.url AS user_site, + IF (' . $cond . ', pj.email, NULL) AS user_email, + pjfe.name AS function, pjse.name AS sector, + pjsse.name AS subsector, pjssse.name AS subsubsector + FROM profile_job AS pj + INNER JOIN profile_job_enum AS pje ON (pje.id = pj.jobid) + LEFT JOIN profile_job_function_enum AS pjfe ON (pjfe.id = pj.functionid) + LEFT JOIN profile_job_sector_enum AS pjse ON (pjse.id = pj.sectorid) + LEFT JOIN profile_job_subsector_enum AS pjsse ON (pjsse.id = pj.subsectorid) + LEFT JOIN profile_job_subsubsector_enum AS pjssse ON (pjssse.id = pj.subsubsectorid) + WHERE ' . $where . ' + ORDER BY pj.id + ' . $limit); + } + + public function getMailJob() + { + $job = $this->getJobs(self::JOBS_MAIN, 1); + if ($job->total() != 1) { + return null; + } + return $job->next(); + } + + public function owner() { return User::getSilent($this); diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 4135d20..735b25e 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -115,7 +115,8 @@ {if !$dead} {assign var=address value=$profile->getMainAddress()} {assign var=web value=$profile->getWebSite()} - {if $web || $profile->mobile || $address.country || $c.entreprise || (!$dead && !$registered)} + {assign var=job value=$profile->getMailJob()} + {if $web || $profile->mobile || $address.country || $job || (!$dead && !$registered)} {if $web} @@ -135,12 +136,12 @@ {/if} - {if $c.entreprise} + {if $job} {/if}
{$profile->mobile}
Profession : - {if $c.job_web}{$c.entreprise}{else}{$c.entreprise}{/if} - {if $c.secteur} ({$c.secteur}){/if}{if $c.fonction}
{$c.fonction}{/if} + {if $job.url|default:$job.user_site}{$job.name}{else}{$job.name}{/if} + {if $job.subsubsector} ({$job.subsubsector}){/if}{if $job.description}
{$job.description}{/if}