Fix referent display
[platal.git] / modules / profile.php
index 6c2dc9f..8423d29 100644 (file)
@@ -94,7 +94,7 @@ class ProfileModule extends PLModule
             $myphoto = PhotoReq::get_request($profile->owner()->id());
             $photo = PlImage::fromData($myphoto->data, $myphoto->mimetype);
         } else {
-            $photo = $profile->getPhoto(true);
+            $photo = $profile->getPhoto(true, true);
         }
 
         // Display the photo, or a default one when not available.
@@ -233,7 +233,7 @@ class ProfileModule extends PLModule
 
         // Fetches profile's and profile's owner information and redirects to
         // marketing if the owner has not subscribed and the requirer has logged in.
-        $profile = Profile::getBulkProfilesWithPIDs(array($pid), Profile::FETCH_ALL, $view);
+        $profile = Profile::get($pid, Profile::FETCH_ALL, $view);
         $owner = $profile->owner();
         if (S::logged() && !is_null($owner) && $owner->state == 'pending') {
             pl_redirect('marketing/public/' . $profile->hrid());
@@ -247,21 +247,15 @@ class ProfileModule extends PLModule
         // Sets the title of the html page.
         $page->setTitle($profile->fullName());
 
-        // Is that really useful???
-        /*$photo = 'photo/' . $profile->hrid() . ($new ? '/req' : '');
-        if (!isset($user['photo_pub']) || !has_user_right($user['photo_pub'], $view)) {
-            $photo = "";
-        }
-        $page->assign('photo_url', $photo);
-        }*/
-
         // Determines and displays the virtual alias.
         if (!is_null($owner)) {
             $page->assign('virtualalias', $owner->emailAlias());
         }
 
-        $page->assign_by_ref('profile', $profile);
-        $page->assign_by_ref('owner', $owner);
+        $page->assign_by_ref('p', $profile);
+        $page->assign_by_ref('o', $owner);
+        $page->assign('view', $view);
+        $page->assign('logged', S::logged());
 
         $page->addJsLink('close_on_esc.js');
         header('Last-Modified: ' . date('r', strtotime($profile->last_change)));
@@ -544,28 +538,19 @@ class ProfileModule extends PLModule
         }
     }
 
-    function handler_referent(&$page, $user)
+    function handler_referent(&$page, $pf)
     {
         $page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
 
-        $user = Profile::get($user);
-        if (!$user) {
+        $pf = Profile::get($pf);
+        if (!$pf) {
             return PL_NOT_FOUND;
         }
 
-        $page->assign_by_ref('user', $user);
-        $page->assign('cv', MiniWiki::WikiToHTML($user->cv, true));
-        //TODO: waiting for job refactoring to be done
-        //$page->assign('adr_pro', get_user_details_pro($user->id()));
+        $page->assign_by_ref('profile', $pf);
 
         /////  recuperations infos referent
 
-        //expertise
-        $res = XDB::query('SELECT  expertise
-                             FROM  profile_mentor
-                            WHERE  pid = {?}', $user->id());
-        $page->assign('expertise', $res->fetchOneCell());
-
         // Sectors
         $sectors = $subSectors = Array();
         $res = XDB::iterRow(
@@ -573,7 +558,7 @@ class ProfileModule extends PLModule
                    FROM  profile_mentor_sector      AS m
               LEFT JOIN  profile_job_sector_enum    AS s  ON(m.sectorid = s.id)
               LEFT JOIN  profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id)
-                  WHERE  pid = {?}", $user->id());
+                  WHERE  pid = {?}", $pf->id());
         while (list($sector, $subSector) = $res->next()) {
             $sectors[]    = $sector;
             $subSectors[] = $subSector;
@@ -586,7 +571,7 @@ class ProfileModule extends PLModule
                 "SELECT  gc.countryFR
                    FROM  profile_mentor_country AS m
               LEFT JOIN  geoloc_countries       AS gc ON (m.country = gc.iso_3166_1_a2)
-                  WHERE  pid = {?}", $user->id());
+                  WHERE  pid = {?}", $pf->id());
         $page->assign('pays', $res->fetchColumn());
 
         $page->addJsLink('close_on_esc.js');