Removes useless getters from Phone class.
authorStéphane Jacob <sj@m4x.org>
Mon, 3 Jan 2011 23:55:18 +0000 (00:55 +0100)
committerStéphane Jacob <sj@m4x.org>
Wed, 5 Jan 2011 17:55:38 +0000 (18:55 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/address.php
classes/phone.php
classes/userfilter/conditions.inc.php
include/profilefields.inc.php
include/vcard.inc.php
modules/profile/jobs.inc.php

index fa10d6d..d271bb7 100644 (file)
@@ -366,7 +366,7 @@ class Address
 
     public function addPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_ADDRESS && $phone->pid() == $this->pid) {
+        if ($phone->link_type == Phone::LINK_ADDRESS && $phone->pid == $this->pid) {
             $this->phones[$phone->uniqueId()] = $phone;
         }
     }
@@ -897,7 +897,7 @@ class AddressIterator implements PlIterator
         // Adds phones to addresses.
         $it = Phone::iterate(array($data['pid']), array(Phone::LINK_ADDRESS), array($data['id']));
         while ($phone = $it->next()) {
-            $data['phones'][$phone->id()] = $phone->toFormArray();
+            $data['phones'][$phone->id] = $phone->toFormArray();
         }
         return new Address($data);
     }
index 9a9f1b0..8a63d66 100644 (file)
@@ -59,17 +59,17 @@ class Phone
     /** The following fields, but $error, all correspond to the fields of the
      * database table profile_phones.
      */
-    private $id = 0;
-    private $pid = 0;
-    private $search = '';
-    private $link_type = 'user';
-    private $link_id = 0;
+    public $id = 0;
+    public $pid = 0;
+    public $search = '';
+    public $link_type = 'user';
+    public $link_id = 0;
     // The following fields are the fields of the form in the profile edition.
-    private $type = 'fixed';
+    public $type = 'fixed';
     public $display = '';
     public $pub = 'ax';
     public $comment = '';
-    private $error = false;
+    public $error = false;
 
     public function __construct(array $data = array())
     {
@@ -80,31 +80,6 @@ class Phone
         }
     }
 
-    public function linkType()
-    {
-        return $this->link_type;
-    }
-
-    public function linkId()
-    {
-        return $this->link_id;
-    }
-
-    public function id()
-    {
-        return $this->id;
-    }
-
-    public function pid()
-    {
-        return $this->pid;
-    }
-
-    public function search()
-    {
-        return $this->search;
-    }
-
     public function setId($id)
     {
         $this->id = $id;
index 817fa4d..c7d5bb3 100644 (file)
@@ -1344,7 +1344,7 @@ class UFC_Phone extends UserFilterCondition
     {
         $phone = new Phone(array('display' => $number));
         $phone->format();
-        $this->number = $phone->search();
+        $this->number = $phone->search;
         $this->num_type = $num_type;
         $this->phone_type = $phone_type;
     }
index a3c26fd..f34e3b8 100644 (file)
@@ -150,7 +150,7 @@ class Company
 
     public function setPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_COMPANY && $phone->linkId() == $this->id) {
+        if ($phone->link_type == Phone::LINK_COMPANY && $phone->link_id == $this->id) {
             $this->phone = $phone;
         }
     }
@@ -223,7 +223,7 @@ class Job
 
     public function addPhone(Phone &$phone)
     {
-        if ($phone->linkType() == Phone::LINK_JOB && $phone->linkId() == $this->id && $phone->pid() == $this->pid) {
+        if ($phone->link_type == Phone::LINK_JOB && $phone->link_id == $this->id && $phone->pid == $this->pid) {
             $this->phones[$phone->uniqueId()] = $phone;
         }
     }
@@ -544,10 +544,10 @@ class ProfileAddresses extends ProfileField
         $p = $phones->get(Profile::PHONE_LINK_ADDRESS | Profile::PHONE_TYPE_ANY);
         foreach ($p as $phone) {
             /* We must iterate on the addresses because id is not uniq thus,
-             * $this->addresse[$phone->linkId()] is invalid.
+             * $this->addresse[$phone->link_id] is invalid.
              */
             foreach ($this->addresses as $address) {
-                if ($address->type == Address::LINK_PROFILE && $address->id == $phone->linkId()) {
+                if ($address->type == Address::LINK_PROFILE && $address->id == $phone->link_id) {
                     $address->addPhone($phone);
                 }
             }
@@ -634,8 +634,8 @@ class ProfileJobs extends ProfileField
     {
         $p = $phones->get(Profile::PHONE_LINK_JOB | Profile::PHONE_TYPE_ANY);
         foreach ($p as $phone) {
-            if ($phone->linkType() == Phone::LINK_JOB && array_key_exists($phone->linkId(), $this->jobs)) {
-                $this->jobs[$phone->linkId()]->addPhone($phone);
+            if ($phone->link_type == Phone::LINK_JOB && array_key_exists($phone->link_id, $this->jobs)) {
+                $this->jobs[$phone->link_id]->addPhone($phone);
             }
         }
     }
@@ -756,7 +756,7 @@ class CompanyList
         if (count($newcompanies)) {
             $it = Phone::iterate(array(), array(Phone::LINK_COMPANY), $newcompanies);
             while ($phone = $it->next()) {
-                self::$companies[$phone->linkId()]->setPhone($phone);
+                self::$companies[$phone->link_id]->setPhone($phone);
             }
         }
 
index 4db685c..6e29640 100644 (file)
@@ -96,10 +96,10 @@ class VCard extends PlVCard
                                 $adr->hasFlag('current'), $adr->hasFlag('mail'), $adr->hasFlag('mail'));
             }
             foreach ($adr->phones() as $phone) {
-                if ($phone->linkType() == Phone::TYPE_FIXED) {
+                if ($phone->link_type == Phone::TYPE_FIXED) {
                     $entry->addTel($group, $phone->display, false, true, true, false, false,
                                    $adr->hasFlag('current') && empty($pf->mobile));
-                } else if ($phone->linkType() == Phone::TYPE_FAX) {
+                } else if ($phone->link_type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true, false, false, false, false, false);
                 }
             }
@@ -119,9 +119,9 @@ class VCard extends PlVCard
                                          $adr->locality, $adr->administrativeArea, $adr->country);
             }
             foreach ($adr->phones() as $phone) {
-                if ($phone->linkType() == Phone::TYPE_FIXED) {
+                if ($phone->link_type == Phone::TYPE_FIXED) {
                     $entry->addTel($group, $phone->display);
-                } else if ($phone->linkType() == Phone::TYPE_FAX) {
+                } else if ($phone->link_type == Phone::TYPE_FAX) {
                     $entry->addTel($group, $phone->display, true);
                 }
             }
index 2898004..8e2b35d 100644 (file)
@@ -92,7 +92,7 @@ class ProfileSettingJob implements ProfileSetting
         }
         $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB));
         while ($phone = $it->next()) {
-            $jobs[$phone->linkId()]['w_phone'][$phone->id()] = $phone->toFormArray();
+            $jobs[$phone->link_id]['w_phone'][$phone->id] = $phone->toFormArray();
         }
         $res = XDB::iterator("SELECT  e.jtid, e.full_name, j.jid
                                 FROM  profile_job_term_enum AS e