Fetch jobs.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 6 Mar 2009 21:51:50 +0000 (22:51 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 6 Mar 2009 21:51:50 +0000 (22:51 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/profile.php
templates/include/minifiche.tpl

index d68c959..11b08ed 100644 (file)
@@ -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);
index 4135d20..735b25e 100644 (file)
   {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)}
     <table cellspacing="0" cellpadding="0">
       {if $web}
       <tr>
         <td class="rt">{$profile->mobile}</td>
       </tr>
       {/if}
-      {if $c.entreprise}
+      {if $job}
       <tr>
         <td class="lt">Profession&nbsp;:</td>
         <td class="rt">
-          {if $c.job_web}<a href="{$c.job_web}">{$c.entreprise}</a>{else}{$c.entreprise}{/if}
-          {if $c.secteur} ({$c.secteur}){/if}{if $c.fonction}<br />{$c.fonction}{/if}
+          {if $job.url|default:$job.user_site}<a href="{$job.url|default:$job.user_site}">{$job.name}</a>{else}{$job.name}{/if}
+          {if $job.subsubsector}&nbsp;({$job.subsubsector}){/if}{if $job.description}<br />{$job.description}{/if}
         </td>
       </tr>
       {/if}