Moves phone fetch request into ProfilePhones
authorGuillaume Bandet <guillaume.bandet@polytechnique.org>
Mon, 8 Dec 2008 13:21:45 +0000 (14:21 +0100)
committerGuillaume Bandet <guillaume.bandet@polytechnique.org>
Mon, 8 Dec 2008 20:01:20 +0000 (21:01 +0100)
Signed-off-by: Guillaume Bandet <guillaume.bandet@polytechnique.org>
modules/profile/general.inc.php
modules/profile/page.inc.php

index 7620240..3f13936 100644 (file)
@@ -336,14 +336,6 @@ class ProfileGeneral extends ProfilePage
                             ORDER BY  sn.name_type, search_score, search_name",
                           S::v('uid'));
 
-        // Retreive phones
-        $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
-                                FROM profile_phones AS t
-                               WHERE t.uid = {?} AND t.link_type = 'user'
-                            ORDER BY t.tel_id",
-                             S::v('uid'));
-        $this->values['tels'] = $res->fetchAllAssoc();
-
         // Proposes choice for promo_display
         if ($this->values['entry_year'] != $this->values['grad_year'] - 3) {
             for ($i = $this->values['entry_year']; $i < $this->values['grad_year'] - 2; $i++) {
index 7c60a6d..d852b5b 100644 (file)
@@ -133,11 +133,14 @@ class ProfilePhones implements ProfileSetting
     public function value(ProfilePage &$page, $field, $value, &$success)
     {
         $success = true;
-        if (is_null($value)) {
-            $value = isset($page->values[$field]) ? $page->values[$field] : array();
-        }
-        if (!is_array($value)) {
+        if (is_null($value) || !is_array($value)) {
             $value = array();
+            $res = XDB::iterator("SELECT t.display_tel AS tel, t.tel_type AS type, t.pub, t.comment
+                                    FROM profile_phones AS t
+                                   WHERE t.uid = {?} AND t.link_type = {?}
+                                ORDER BY t.tel_id",
+                                 S::v('uid'), $this->link_type);
+            $value = $res->fetchAllAssoc();
         }
         foreach ($value as $key=>&$phone) {
             if (@$phone['removed']) {