Fix fetching of phones associated to companies
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 23 Jun 2010 23:33:21 +0000 (01:33 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Wed, 23 Jun 2010 23:33:21 +0000 (01:33 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/profilefields.inc.php

index edeb6cb..0f6d3df 100644 (file)
@@ -841,13 +841,15 @@ class CompanyList
 
         // TODO: determine whether there can be phones attached to a hq's address
         // Add phones to hq
-        $it = XDB::iterator('SELECT  search_tel AS search, display_tel AS display, comment, link_id, tel_type AS type, link_type, tel_id AS id
-                               FROM  profile_phones
-                              WHERE  link_id IN {?} AND link_type = \'hq\'',
-                                $newcompanies);
-        while ($row = $it->next()) {
-            $p = new Phone($row);
-            self::$companies[$row['link_id']]->setPhone($p);
+        if (count($newcompanies)) {
+            $it = XDB::iterator('SELECT  search_tel AS search, display_tel AS display, comment, link_id, tel_type AS type, link_type, tel_id AS id
+                                   FROM  profile_phones
+                                  WHERE  link_id IN {?} AND link_type = \'hq\'',
+                                    $newcompanies);
+            while ($row = $it->next()) {
+                $p = new Phone($row);
+                self::$companies[$row['link_id']]->setPhone($p);
+            }
         }
 
         if (count($pids) == 0) {