Fix smarty assigns for full profile display
[platal.git] / classes / profile.php
index 7ba72a6..4758abb 100644 (file)
@@ -82,16 +82,17 @@ class Profile
     const NETWORKING_IM      = 0x020000;
     const NETWORKING_SOCIAL  = 0x040000;
 
-    const FETCH_ADDRESSES  = 0x00001;
-    const FETCH_CORPS      = 0x00002;
-    const FETCH_EDU        = 0x00004;
-    const FETCH_JOBS       = 0x00008;
-    const FETCH_MEDALS     = 0x00010;
-    const FETCH_NETWORKING = 0x00020;
-    const FETCH_PHONES     = 0x00040;
-    const FETCH_PHOTO      = 0x00080;
-
-    const FETCH_ALL        = 0x000FF;
+    const FETCH_ADDRESSES    = 0x000001;
+    const FETCH_CORPS        = 0x000002;
+    const FETCH_EDU          = 0x000004;
+    const FETCH_JOBS         = 0x000008;
+    const FETCH_MEDALS       = 0x000010;
+    const FETCH_NETWORKING   = 0x000020;
+    const FETCH_PHONES       = 0x000040;
+    const FETCH_PHOTO        = 0x000080;
+
+    // xor of all FETCH_XYZ
+    const FETCH_ALL          = 0x0000FF;
 
     private $pid;
     private $hrpid;
@@ -463,7 +464,7 @@ class Profile
         return $this->jobs->get($flags, $limit);
     }
 
-    public function getMailJob()
+    public function getMainJob()
     {
         $job = $this->getJobs(self::JOBS_MAIN, 1);
         if ($job->total() != 1) {
@@ -480,7 +481,32 @@ class Profile
                                    FROM  profile_binets
                                   WHERE  pid = {?}', $this->id());
     }
+    public function getBinetsNames()
+    {
+        return XDB::fetchColumn('SELECT  text
+                                   FROM  profile_binets AS pb
+                              LEFT JOIN  profile_binet_enum AS pbe ON (pbe.id = pb.binet_id)
+                                  WHERE  pb.pid = {?}', $this->id());
+    }
+
+    /* Medals
+     */
+    private $medals = null;
+    public function setMedals(ProfileMedals $medals)
+    {
+        $this->medals = $medals;
+    }
 
+    public function getMedals()
+    {
+        if ($this->medals == null) {
+            $this->setMedals($this->getProfileField('ProfileMedals'));
+        }
+        if ($this->medals == null) {
+            return array();
+        }
+        return $this->medals->medals;
+    }
 
     public function owner()
     {
@@ -519,7 +545,7 @@ class Profile
         }
 
 
-        $it = XDB::Iterator('SELECT  p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year,
+        $it = XDB::Iterator('SELECT  p.*, p.sex = \'female\' AS sex, pe.entry_year, pe.grad_year, pse.text AS section,
                                      pn_f.name AS firstname, pn_l.name AS lastname, pn_n.name AS nickname,
                                      IF(pn_uf.name IS NULL, pn_f.name, pn_uf.name) AS firstname_ordinary,
                                      IF(pn_ul.name IS NULL, pn_l.name, pn_ul.name) AS lastname_ordinary,
@@ -531,6 +557,7 @@ class Profile
                                FROM  profiles AS p
                          INNER JOIN  profile_display AS pd ON (pd.pid = p.pid)
                          INNER JOIN  profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET(\'primary\', pe.flags))
+                          LEFT JOIN  profile_section_enum AS pse ON (pse.id = p.section)
                          INNER JOIN  profile_name AS pn_f ON (pn_f.pid = p.pid
                                                               AND pn_f.typeid = ' . self::getNameTypeId('firstname', true) . ')
                          INNER JOIN  profile_name AS pn_l ON (pn_l.pid = p.pid
@@ -830,7 +857,7 @@ class ProfileIterator implements PlIterator
             $pf->setCorps($vals[Profile::FETCH_CORPS]);
         }
         if ($this->hasData(Profile::FETCH_EDU, $vals)) {
-            $pf->setEdu($vals[Profile::FETCH_EDU]);
+            $pf->setEducations($vals[Profile::FETCH_EDU]);
         }
         if ($this->hasData(Profile::FETCH_MEDALS, $vals)) {
             $pf->setMedals($vals[Profile::FETCH_MEDALS]);