Fix bug in jobs, fix problem with empty fields
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Thu, 18 Mar 2010 20:49:25 +0000 (21:49 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 22 Mar 2010 12:49:28 +0000 (13:49 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/profile.php
include/profilefields.inc.php

index f4c4244..7ba72a6 100644 (file)
@@ -368,6 +368,10 @@ class Profile
         if ($this->addresses == null) {
             $this->setAddresses($this->getProfileField('ProfileAddresses'));
         }
+
+        if ($this->addresses == null) {
+            return PlIteratorUtils::emptyIterator();
+        }
         return $this->addresses->get($flags, $limit);
     }
 
@@ -395,6 +399,10 @@ class Profile
         if ($this->educations == null) {
             $this->setEducations($this->getProfileField('ProfileEducation'));
         }
+
+        if ($this->educations == null) {
+            return PlIteratorUtils::emptyIterator();
+        }
         return $this->educations->get($flags, $limit);
     }
 
@@ -417,6 +425,9 @@ class Profile
         if ($this->networks == null) {
             $this->setNetworking($this->getProfileField('ProfileNetworking'));
         }
+        if ($this->networks == null) {
+            return PlIteratorUtils::emptyIterator();
+        }
         return $this->networks->get($flags, $limit);
     }
 
@@ -446,6 +457,9 @@ class Profile
             $this->setJobs($this->getProfileField('ProfileJobs'));
         }
 
+        if ($this->jobs == null) {
+            return PlIteratorUtils::emptyIterator();
+        }
         return $this->jobs->get($flags, $limit);
     }
 
index 874c764..b8a2098 100644 (file)
@@ -581,14 +581,14 @@ class ProfileJobs extends ProfileField
     public function __construct(PlIterator $jobs)
     {
         while ($job = $jobs->next()) {
-            $this->jobs[$job['id']] = Jobs::buildFromData($job);
+            $this->jobs[$job['id']] = new Job($job);
         }
     }
 
     public static function fetchData(array $pids, $visibility)
     {
         $data = XDB::iterator('SELECT  id, pid, description, url,
-                                       jobid, sectorid, subsctorid, subsubsectorid,
+                                       jobid, sectorid, subsectorid, subsubsectorid,
                                        IF(email_pub IN {?}, email, NULL) AS email
                                  FROM  profile_job
                                 WHERE  pid IN {?} AND pub IN {?}