PHP5 / Horde4 standards for Turba
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 01:00:12 +0000 (20:00 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 01:00:39 +0000 (20:00 -0500)
29 files changed:
turba/lib/Application.php
turba/lib/Data/Ldif.php
turba/lib/Driver.php
turba/lib/Driver/Facebook.php
turba/lib/Driver/Favourites.php
turba/lib/Driver/Group.php
turba/lib/Driver/Ldap.php
turba/lib/Driver/Prefs.php
turba/lib/Driver/Share.php
turba/lib/Driver/Sql.php
turba/lib/Driver/Vbook.php
turba/lib/Form/AddContact.php
turba/lib/Form/Contact.php
turba/lib/Form/CreateAddressBook.php
turba/lib/Form/DeleteAddressBook.php
turba/lib/Form/EditAddressBook.php
turba/lib/Form/EditContact.php
turba/lib/Form/EditContactGroup.php
turba/lib/List.php
turba/lib/Object.php
turba/lib/Object/Group.php
turba/lib/Turba.php
turba/lib/View/Browse.php
turba/lib/View/Contact.php
turba/lib/View/DeleteContact.php
turba/lib/View/EditContact.php
turba/lib/View/List.php
turba/lib/View/List/AlphaFilter.php [new file with mode: 0644]
turba/lib/View/List/PageFilter.php [new file with mode: 0644]

index 6934c12..a42b018 100644 (file)
@@ -165,7 +165,7 @@ class Turba_Application extends Horde_Registry_Application
      *
      * @param Horde_Menu $menu  The menu object.
      */
-    public function menu($menu)
+    public function menu(Horde_Menu $menu)
     {
         if ($GLOBALS['session']->get('turba', 'has_share')) {
             $menu->add(Horde::url('addressbooks/index.php'), _("_My Address Books"), 'turba.png');
@@ -192,7 +192,7 @@ class Turba_Application extends Horde_Registry_Application
      *
      * @param Horde_Core_Prefs_Ui $ui  The UI object.
      */
-    public function prefsGroup($ui)
+    public function prefsGroup(Horde_Core_Prefs_Ui $ui)
     {
         global $prefs;
 
@@ -250,7 +250,7 @@ class Turba_Application extends Horde_Registry_Application
      *
      * @return string  The HTML code to display on the prefs page.
      */
-    public function prefsSpecial($ui, $item)
+    public function prefsSpecial(Horde_Core_Prefs_Ui $ui, $item)
     {
         switch ($item) {
         case 'addressbookselect':
@@ -360,7 +360,7 @@ class Turba_Application extends Horde_Registry_Application
      *
      * @return boolean  True if preference was updated.
      */
-    public function prefsSpecialUpdate($ui, $item)
+    public function prefsSpecialUpdate(Horde_Core_Prefs_Ui $ui, $item)
     {
         global $prefs;
 
index c3d903d..a78a7c7 100644 (file)
  */
 class Turba_Data_Ldif extends Horde_Data
 {
-    var $_extension = 'ldif';
+    protected $_extension = 'ldif';
 
-    var $_contentType = 'text/ldif';
+    protected $_contentType = 'text/ldif';
 
     /**
      * Useful Mozilla address book attribute names.
      *
-     * @private
      * @var array
      */
-    var $_mozillaAttr = array('cn', 'givenName', 'sn', 'mail', 'mozillaNickname',
+    private $_mozillaAttr = array('cn', 'givenName', 'sn', 'mail', 'mozillaNickname',
                              'homeStreet', 'mozillaHomeStreet2', 'mozillaHomeLocalityName',
                              'mozillaHomeState', 'mozillaHomePostalCode',
                              'mozillaHomeCountryName', 'street',
@@ -34,10 +33,9 @@ class Turba_Data_Ldif extends Horde_Data
     /**
      * Useful Turba address book attribute names.
      *
-     * @private
      * @var array
      */
-    var $_turbaAttr = array('name', 'firstname', 'lastname', 'email', 'alias',
+    private $_turbaAttr = array('name', 'firstname', 'lastname', 'email', 'alias',
                             'homeAddress', 'homeStreet', 'homeCity',
                             'homeProvince', 'homePostalCode', 'homeCountry',
                             'workAddress', 'workStreet', 'workCity', 'workProvince',
@@ -48,10 +46,9 @@ class Turba_Data_Ldif extends Horde_Data
     /**
      * Turba address book attribute names and the corresponding Mozilla name.
      *
-     * @private
      * @var array
      */
-    var $_turbaMozillaMap = array('name' => 'cn',
+    private $_turbaMozillaMap = array('name' => 'cn',
                                   'firstname' => 'givenName',
                                   'lastname' => 'sn',
                                   'email' => 'mail',
@@ -89,7 +86,7 @@ class Turba_Data_Ldif extends Horde_Data
      *
      * @return boolean  True if the string is safe, false otherwise.
      */
-    function _is_safe_string($str)
+    private function _is_safe_string($str)
     {
         /*  SAFE-CHAR         = %x01-09 / %x0B-0C / %x0E-7F
          *                     ; any value <= 127 decimal except NUL, LF,
@@ -116,7 +113,7 @@ class Turba_Data_Ldif extends Horde_Data
         return true;
     }
 
-    function importData($contents, $header = false)
+    public function importData($contents, $header = false)
     {
         $data = array();
         $records = preg_split('/(\r?\n){2}/', $contents);
@@ -151,7 +148,7 @@ class Turba_Data_Ldif extends Horde_Data
      * @param boolean $header   If true, the rows of $data are associative
      *                          arrays with field names as their keys.
      */
-    function exportFile($filename, $data, $header = false)
+    public function exportFile($filename, $data, $header = false)
     {
         $export = $this->exportData($data, $header);
         $GLOBALS['browser']->downloadHeaders($filename, 'text/ldif', false, strlen($export));
@@ -168,7 +165,7 @@ class Turba_Data_Ldif extends Horde_Data
      *
      * @return string  The LDIF data.
      */
-    function exportData($data, $header = false)
+    public function exportData($data, $header = false)
     {
         if (!is_array($data) || !count($data)) {
             return '';
@@ -219,7 +216,7 @@ class Turba_Data_Ldif extends Horde_Data
      *                data set after the final step.
      * @throws Horde_Data_Exception
      */
-    function nextStep($action, $param = array())
+    public function nextStep($action, $param = array())
     {
         switch ($action) {
         case Horde_Data::IMPORT_FILE:
index 9051de1..a5c1eae 100644 (file)
@@ -115,10 +115,11 @@ class Turba_Driver implements Countable
     /**
      * Constructs a new Turba_Driver object.
      *
+     * @param string $name   Source name
      * @param array $params  Hash containing additional configuration
      *                       parameters.
      */
-    public function __construct($name = '', $params = array())
+    public function __construct($name = '', array $params = array())
     {
         $this->_name = $name;
         $this->_params = $params;
@@ -175,7 +176,7 @@ class Turba_Driver implements Countable
      *
      * @return array  Translated version of $hash.
      */
-    public function toDriverKeys($hash)
+    public function toDriverKeys(array $hash)
     {
         /* Handle category. */
         if (!empty($hash['category'])) {
@@ -268,7 +269,7 @@ class Turba_Driver implements Countable
      * search by the driver. The translation is based on the contents of
      * $this->map, and includes nested OR searches for composite fields.
      *
-     * @param array  $hash          Hash of criteria using Turba keys.
+     * @param array  $criteria      Hash of criteria using Turba keys.
      * @param string $search_type   OR search or AND search?
      * @param array  $strict        Fields that must be matched exactly.
      * @param boolean $match_begin  Whether to match only at beginning of
@@ -276,7 +277,7 @@ class Turba_Driver implements Countable
      *
      * @return array  An array of search criteria.
      */
-    public function makeSearch($criteria, $search_type, $strict,
+    public function makeSearch($criteria, $search_type, array $strict,
                                $match_begin = false)
     {
         $search = $search_terms = $subsearch = $strict_search = array();
@@ -448,7 +449,7 @@ class Turba_Driver implements Countable
      *
      * @return array  Translated version of $entry.
      */
-    public function toTurbaKeys($entry)
+    public function toTurbaKeys(array $entry)
     {
         $new_entry = array();
         foreach ($this->map as $key => $val) {
@@ -482,9 +483,9 @@ class Turba_Driver implements Countable
      * @return Turba_List  The sorted, filtered list of search results.
      * @throws Turba_Exception
      */
-    public function search($search_criteria, $sort_order = null,
-                           $search_type = 'AND', $return_fields = array(),
-                           $custom_strict = array(), $match_begin = false)
+    public function search(array $search_criteria, $sort_order = null,
+                           $search_type = 'AND', array $return_fields = array(),
+                           array $custom_strict = array(), $match_begin = false)
     {
         /* If we are not using Horde_Share, enforce the requirement that the
          * current user must be the owner of the addressbook. */
@@ -555,9 +556,9 @@ class Turba_Driver implements Countable
      * Takes an array of object hashes and returns a Turba_List
      * containing the correct Turba_Objects
      *
-     * @param array $objects  An array of object hashes (keyed to backend).
-     * @param array $order    Array of hashes describing sort fields.  Each
-     *                        hash has the following fields:
+     * @param array $objects     An array of object hashes (keyed to backend).
+     * @param array $sort_order  Array of hashes describing sort fields.  Each
+     *                           hash has the following fields:
      * <pre>
      * ascending - (boolean) Indicating sort direction.
      * field - (string) Sort field.
@@ -565,7 +566,7 @@ class Turba_Driver implements Countable
      *
      * @return Turba_List  A list object.
      */
-    protected function _toTurbaObjects($objects, $sort_order = null)
+    protected function _toTurbaObjects(array $objects, array $sort_order = null)
     {
         $list = new Turba_List();
 
@@ -600,12 +601,12 @@ class Turba_Driver implements Countable
      *
      * @param Horde_Date $start  The start date of the valid period.
      * @param Horde_Date $end    The end date of the valid period.
-     * @param $category          The timeObjects category to return.
+     * @param string $category   The timeObjects category to return.
      *
-     * @return mixed  A list of timeObject hashes.
+     * @return array  A list of timeObject hashes.
      * @throws Turba Exception
      */
-    public function listTimeObjects($start, $end, $category)
+    public function listTimeObjects(Horde_Date $start, Horde_Date $end, $category)
     {
         try {
             $res = $this->getTimeObjectTurbaList($start, $end, $category);
@@ -686,7 +687,7 @@ class Turba_Driver implements Countable
      * @return Turba_List  A list of objects.
      * @throws Turba_Exception
      */
-    public function getTimeObjectTurbaList($start, $end, $field)
+    public function getTimeObjectTurbaList(Horde_Date $start, Horde_Date $end, $field)
     {
         return $this->_getTimeObjectTurbaListFallback($start, $end, $field);
     }
@@ -704,7 +705,7 @@ class Turba_Driver implements Countable
      * @return Turba_List  A list of objects.
      * @throws Turba_Exception
      */
-    protected function _getTimeObjectTurbaListFallback($start, $end, $field)
+    protected function _getTimeObjectTurbaListFallback(Horde_Date $start, Horde_Date $end, $field)
     {
         return $this->search(array(), null, 'AND', array('name', $field, 'category'));
     }
@@ -717,7 +718,7 @@ class Turba_Driver implements Countable
      * @return array  The array of retrieved objects (Turba_Objects).
      * @throws Turba_Exception
      */
-    public function getObjects($objectIds)
+    public function getObjects(array $objectIds)
     {
         $objects = $this->_read($this->map['__key'], $objectIds,
                                 $this->getContactOwner(),
@@ -779,7 +780,7 @@ class Turba_Driver implements Countable
      * @return string  The new __key value on success.
      * @throws Turba_Exception
      */
-    public function add($attributes)
+    public function add(array $attributes)
     {
         /* Only set __type and __owner if they are not already set. */
         if (!isset($attributes['__type'])) {
@@ -905,7 +906,7 @@ class Turba_Driver implements Countable
      * @return string  The object id, possibly updated.
      * @throws Turba_Exception
      */
-    public function save($object)
+    public function save(Turba_Object $object)
     {
         $object_id = $this->_save($object);
 
@@ -958,8 +959,8 @@ class Turba_Driver implements Countable
      *
      * @return Horde_Icalendar_Vcard  A vcard object.
      */
-    public function tovCard($object, $version = '2.1', $fields = null,
-                            $skipEmpty = false)
+    public function tovCard(Turba_Object $object, $version = '2.1',
+                            array $fields = null, $skipEmpty = false)
     {
         $hash = $object->getAttributes();
         $vcard = new Horde_Icalendar_Vcard($version);
@@ -2423,7 +2424,7 @@ class Turba_Driver implements Countable
      *
      * @return array  A contact hash.
      */
-    public function fromASContact($message)
+    public function fromASContact(Horde_ActiveSync_Message_Contact $message)
     {
         $hash = array();
         $formattedname = false;
@@ -2583,18 +2584,19 @@ class Turba_Driver implements Countable
     /**
      * Creates a new Horde_Share for this source type.
      *
-     * @param array $params  The params for the share.
+     * @param string $share_name  The share name
+     * @param array  $params      The params for the share.
      *
      * @return Horde_Share  The share object.
      */
-    public function createShare($share_id, $params)
+    public function createShare($share_name, array $params)
     {
         // If the raw address book name is not set, use the share name
         if (empty($params['params']['name'])) {
-            $params['params']['name'] = $share_id;
+            $params['params']['name'] = $share_name;
         }
 
-        return Turba::createShare($share_id, $params);
+        return Turba::createShare($share_name, $params);
     }
 
     /**
@@ -2605,7 +2607,7 @@ class Turba_Driver implements Countable
      *
      * @return string  A unique ID for the new object.
      */
-    protected function _makeKey($attributes)
+    protected function _makeKey(array $attributes)
     {
         return hash('md5', mt_rand());
     }
@@ -2621,7 +2623,7 @@ class Turba_Driver implements Countable
      * @return Turba_Driver  The concrete driver object.
      * @throws Turba_Exception
      */
-    static public function factory($name, $config)
+    static public function factory($name, array $config)
     {
         $class = __CLASS__ . '_' . ucfirst(basename($config['type']));
 
@@ -2682,13 +2684,14 @@ class Turba_Driver implements Countable
      * filtered list of results. If the criteria parameter is an empty array,
      * all records will be returned.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  Array of fields containing binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         throw new Turba_Exception(_("Searching is not available."));
     }
@@ -2700,11 +2703,12 @@ class Turba_Driver implements Countable
      * @param mixed $ids     The ids of the contacts to load.
      * @param string $owner  Only return contacts owned by this user.
      * @param array $fields  List of fields to return.
+     * @param array $blobFields  Array of fields containing binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _read($key, $ids, $owner, $fields, $blobFields = array())
+    protected function _read($key, $ids, $owner, array $fields, array $blobFields = array())
     {
         throw new Turba_Exception(_("Reading contacts is not available."));
     }
@@ -2716,7 +2720,7 @@ class Turba_Driver implements Countable
      *
      * @throws Turba_Exception
      */
-    protected function _add($attributes)
+    protected function _add(array $attributes)
     {
         throw new Turba_Exception(_("Adding contacts is not available."));
     }
@@ -2724,8 +2728,8 @@ class Turba_Driver implements Countable
     /**
      * Deletes the specified contact from the SQL database.
      *
-     * @param $object_key TODO
-     * @param $object_id TODO
+     * @param string $object_key TODO
+     * @param string $object_id  TODO
      *
      * @throws Turba_Exception
      */
@@ -2737,10 +2741,12 @@ class Turba_Driver implements Countable
     /**
      * Saves the specified object in the SQL database.
      *
+     * @param Turba_Object $object  The object to save
+     *
      * @return string  The object id, possibly updated.
      * @throws Turba_Exception
      */
-    protected function _save($object)
+    protected function _save(Turba_Object $object)
     {
         throw new Turba_Exception(_("Saving contacts is not available."));
     }
@@ -2760,12 +2766,12 @@ class Turba_Driver implements Countable
     /**
      * Check if the passed in share is the default share for this source.
      *
-     * @param Horde_Share $share  The share object.
-     * @param array $srcconfig    The cfgSource entry for the share.
+     * @param Horde_Share_Object $share  The share object.
+     * @param array $srcconfig           The cfgSource entry for the share.
      *
      * @return boolean TODO
      */
-    public function checkDefaultShare($share, $srcconfig)
+    public function checkDefaultShare(Horde_Share_Object $share, array $srcconfig)
     {
         $params = @unserialize($share->get('params'));
         if (!isset($params['default'])) {
@@ -2788,7 +2794,13 @@ class Turba_Driver implements Countable
     public function count()
     {
         if (is_null($this->_count)) {
-            $this->_count = count($this->_search(array('AND' => array(array('field' => $this->toDriver('__owner'), 'op' => '=', 'test' => $this->getContactOwner()))), array($this->toDriver('__key'))));
+            $this->_count = count(
+                $this->_search(array('AND' => array(
+                                   array('field' => $this->toDriver('__owner'),
+                                         'op' => '=',
+                                         'test' => $this->getContactOwner()))),
+                               array($this->toDriver('__key')))
+            );
         }
 
         return $this->_count;
index 6e2af82..1ff44b3 100644 (file)
@@ -2,7 +2,6 @@
 /**
  * Read-only Turba directory driver for Facebook friends. Requires a Horde
  * application to be setup on Facebook and configured in horde/config/conf.php.
- * This driver based on the favourites driver.
  *
  * Of limited utility since email addresses are not retrievable via the
  * Facebook API, unless the user allows the Horde application to access it -
@@ -23,6 +22,8 @@ class Turba_Driver_Facebook extends Turba_Driver
 {
     /**
      * TODO
+     *
+     * @var Horde_Service_Facebook
      */
     private $_facebook;
 
@@ -51,13 +52,14 @@ class Turba_Driver_Facebook extends Turba_Driver
      * filtered list of results. If the criteria parameter is an empty array,
      * all records will be returned.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  A list of fields that contain binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         $results = $this->_getAddressBook($fields);
 
@@ -105,12 +107,13 @@ class Turba_Driver_Facebook extends Turba_Driver
      * fields.
      *
      * @param array $criteria  Search criteria.
-     * @param string $id       Data identifier.
+     * @param mixed $ids       Data identifier.
+     * @param string $owner    Restrict contacts to those owned by this user.
      * @param array $fields    List of fields to return.
      *
      * @return array  Hash containing the search results.
      */
-    protected function _read($criteria, $ids, $owner, $fields)
+    protected function _read(array $criteria, $ids, $owner, array $fields)
     {
         return $this->_getEntry($ids, $fields);
     }
@@ -118,7 +121,7 @@ class Turba_Driver_Facebook extends Turba_Driver
     /**
      * TODO
      */
-    protected function _getEntry($keys, $fields)
+    protected function _getEntry(array $keys, array $fields)
     {
         $facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
         $fields = implode(', ', $fields);
@@ -135,7 +138,7 @@ class Turba_Driver_Facebook extends Turba_Driver
     /**
      * TODO
      */
-    protected function _getAddressBook($fields = array())
+    protected function _getAddressBook(array $fields = array())
     {
         $facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
         $fields = implode(', ', $fields);
@@ -164,40 +167,4 @@ class Turba_Driver_Facebook extends Turba_Driver
         return $addressbook;
     }
 
-    /**
-     * TODO
-     *
-     * @throws Turba_Exception
-     */
-    function _getFacebook()
-    {
-        global $conf, $prefs;
-
-        if (!$conf['facebook']['enabled']) {
-            throw new Turba_Exception(_("No Facebook integration exists."));
-        }
-
-        if (empty($this->_facebook)) {
-            $context = array(
-                'http_client' => new Horde_Http_Client(),
-                'http_request' => $GLOBALS['injector']->getInstance('Horde_Controller_Request')
-            );
-            $this->_facebook = new Horde_Service_Facebook(
-                $conf['facebook']['key'],
-                $conf['facebook']['secret'],
-                $context
-            );
-
-            $session = unserialize($prefs->getValue('facebook'));
-            if (!$session ||
-                !isset($session['uid']) ||
-                !isset($session['sid'])) {
-                throw new Turba_Exception(_("You have to connect to Facebook in your address book preferences."));
-            }
-            $this->_facebook->auth->setUser($session['uid'], $session['sid'], 0);
-        }
-
-        return $this->_facebook;
-    }
-
 }
index 63e1fe6..58402cf 100644 (file)
@@ -42,11 +42,12 @@ class Turba_Driver_Favourites extends Turba_Driver
      *
      * @param array $criteria  Array containing the search criteria.
      * @param array $fields    List of fields to return.
+     * @param array $blobFields  A list of fields that contain binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         $results = array();
 
@@ -94,13 +95,14 @@ class Turba_Driver_Favourites extends Turba_Driver
      * fields.
      *
      * @param array $criteria  Search criteria.
-     * @param string $id       Data identifier.
+     * @param mixed $id        Data identifier.
+     * @param string $owner    Filter on contacts owned by this owner.
      * @param array $fields    List of fields to return.
      *
      * @return arry  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _read($criteria, $ids, $owner, $fields)
+    protected function _read(array $criteria, $ids, $owner, array $fields)
     {
         $book = $this->_getAddressBook();
 
index fb8021b..1d78810 100644 (file)
@@ -54,13 +54,14 @@ class Turba_Driver_Group extends Turba_Driver
      *
      * This method 'borrowed' from the favorites driver.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  A list of fields that contain binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         $results = array();
 
@@ -108,12 +109,12 @@ class Turba_Driver_Group extends Turba_Driver
      * Again, this method taken from the favorites driver.
      *
      * @param array $criteria  Search criteria.
-     * @param string $id       Data identifier.
+     * @param mixed $id        Data identifier.
      * @param array $fields    List of fields to return.
      *
      * @return array  Hash containing the search results.
      */
-    protected function _read($criteria, $ids, $fields)
+    protected function _read(array $criteria, $ids, array $fields)
     {
         $book = $this->_getAddressBook();
         $results = array();
index b2a6e5c..436f9c6 100644 (file)
@@ -39,9 +39,12 @@ class Turba_Driver_Ldap extends Turba_Driver
     /**
      * Constructs a new Turba LDAP driver object.
      *
-     * @param $params  Hash containing additional configuration parameters.
+     * @param string $name   The source name
+     * @param array $params  Hash containing additional configuration parameters.
+     *
+     * @return Turba_Driver_Ldap
      */
-    public function __construct($name = '', $params = array())
+    public function __construct($name = '', array $params = array())
     {
         if (!Horde_Util::extensionExists('ldap')) {
             throw new Turba_Exception(_("LDAP support is required but the LDAP module is not available or not loaded."));
@@ -105,7 +108,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *
      * @return array  Translated version of $hash.
      */
-    public function toDriverKeys($hash)
+    public function toDriverKeys(array $hash)
     {
         // First check for combined fields in the dn-fields and add them.
         if (is_array($this->_params['dn'])) {
@@ -135,13 +138,14 @@ class Turba_Driver_Ldap extends Turba_Driver
      * a filtered list of results. If no criteria are specified, all
      * records are returned.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  Fields that contain binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         /* Build the LDAP filter. */
         $filter = '';
@@ -207,7 +211,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _read($key, $ids, $owner, $fields)
+    protected function _read($key, $ids, $owner, array $fields)
     {
         /* Only DN. */
         if ($key != 'dn') {
@@ -257,7 +261,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *
      * @throws Turba_Exception
      */
-    protected function _add($attributes)
+    protected function _add(array $attributes)
     {
         if (empty($attributes['dn'])) {
             throw new Turba_Exception('Tried to add an object with no dn: [' . serialize($attributes) . '].');
@@ -314,7 +318,8 @@ class Turba_Driver_Ldap extends Turba_Driver
     /**
      * Deletes the specified entry from the LDAP directory.
      *
-     * TODO
+     * @param string $object_key
+     * @param string $object_id
      *
      * @throws Turba_Exception
      */
@@ -332,6 +337,8 @@ class Turba_Driver_Ldap extends Turba_Driver
     /**
      * Modifies the specified entry in the LDAP directory.
      *
+     * @param Turba_Object $object  The object we wish to save.
+     *
      * @return string  The object id, possibly updated.
      * @throw Turba_Exception
      */
@@ -416,7 +423,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *
      * @return string  The RDN for the new object.
      */
-    protected function _makeRDN($attributes)
+    protected function _makeRDN(array $attributes)
     {
         if (!is_array($this->_params['dn'])) {
             return '';
@@ -441,7 +448,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *
      * @return string  The DN for the new object.
      */
-    protected function _makeKey($attributes)
+    protected function _makeKey(array $attributes)
     {
         return $this->_makeRDN($attributes) . ',' . $this->_params['root'];
     }
@@ -453,7 +460,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *
      * @return string  An LDAP query fragment.
      */
-    protected function _buildSearchQuery($criteria)
+    protected function _buildSearchQuery(array $criteria)
     {
         $clause = '';
 
@@ -493,7 +500,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      * @return array  Hash containing the results.
      * @throws Turba_Exception
      */
-    protected function _getResults($fields, $res)
+    protected function _getResults(array $fields, $res)
     {
         $entries = @ldap_get_entries($this->_ds, $res);
         if ($entries === false) {
@@ -573,6 +580,8 @@ class Turba_Driver_Ldap extends Turba_Driver
     /**
      * Format and encode attributes including postal addresses,
      * character set encoding, etc.
+     *
+     * @param array $attributes  The attributes array.
      */
     protected function _encodeAttributes(&$attributes)
     {
@@ -608,7 +617,7 @@ class Turba_Driver_Ldap extends Turba_Driver
      *                that have been configured as being required.
      * @throws Turba_Exception
      */
-    protected function _checkRequiredAttributes($objectclasses)
+    protected function _checkRequiredAttributes(array $objectclasses)
     {
        $retval = array();
        $schema = $this->_ldap->schema();
@@ -697,4 +706,5 @@ class Turba_Driver_Ldap extends Turba_Driver
 
         return $this->_syntaxCache[$att];
     }
+
 }
index 670999a..b2919e6 100644 (file)
@@ -19,12 +19,13 @@ class Turba_Driver_Prefs extends Turba_Driver
      * Returns all entries - searching isn't implemented here for now. The
      * parameters are simply ignored.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  Array of fields containing binary data.
      *
      * @return array  Hash containing the search results.
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         return array_values($this->_getAddressBook());
     }
@@ -34,12 +35,12 @@ class Turba_Driver_Prefs extends Turba_Driver
      * fields.
      *
      * @param array $criteria  Search criteria.
-     * @param string $id       Data identifier.
+     * @param mixed $ids       Data identifier(s).
      * @param array $fields    List of fields to return.
      *
      * @return  Hash containing the search results.
      */
-    protected function _read($criteria, $ids, $fields)
+    protected function _read(array $criteria, $ids, array $fields)
     {
         $book = $this->_getAddressBook();
         $results = array();
@@ -60,7 +61,7 @@ class Turba_Driver_Prefs extends Turba_Driver
      *
      * @param array $attributes  TODO
      */
-    protected function _add($attributes)
+    protected function _add(array $attributes)
     {
         $book = $this->_getAddressBook();
         $book[$attributes['id']] = $attributes;
@@ -78,8 +79,8 @@ class Turba_Driver_Prefs extends Turba_Driver
     /**
      * Deletes the specified object from the preferences.
      *
-     * @param $object_key TODO
-     * @param $object_id  TODO
+     * @param string $object_key TODO
+     * @param string $object_id  TODO
      */
     protected function _delete($object_key, $object_id)
     {
@@ -91,7 +92,7 @@ class Turba_Driver_Prefs extends Turba_Driver
     /**
      * Saves the specified object in the preferences.
      *
-     * @param $object TODO
+     * @param Turba_Object $object TODO
      */
     function _save($object)
     {
index 8860e2a..57023a5 100644 (file)
@@ -11,6 +11,7 @@
  *
  * @author   Chuck Hagenbuch <chuck@horde.org>
  * @author   Jon Parise <jon@csh.rit.edu>
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
  * @category Horde
  * @license  http://www.horde.org/licenses/asl.php ASL
  * @package  Turba
@@ -39,7 +40,7 @@ class Turba_Driver_Share extends Turba_Driver
      *
      * @return Turba_Driver
      */
-    public function __construct($name = '', $params = array())
+    public function __construct($name = '', array $params = array())
     {
         parent::__construct($name, $params);
         $this->_share = $this->_params['config']['params']['share'];
@@ -104,13 +105,14 @@ class Turba_Driver_Share extends Turba_Driver
      * filtered list of results. If the criteria parameter is an empty array,
      * all records will be returned.
      *
-     * @param array $criteria  Array containing the search criteria.
-     * @param array $fields    List of fields to return.
+     * @param array $criteria    Array containing the search criteria.
+     * @param array $fields      List of fields to return.
+     * @param array $blobFields  Array of fields containing binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         return $this->_driver->_search($criteria, $fields, $blobFields);
     }
@@ -140,12 +142,13 @@ class Turba_Driver_Share extends Turba_Driver
      * @param mixed $ids     The ids of the contacts to load.
      * @param string $owner  Only return contacts owned by this user.
      * @param array $fields  List of fields to return.
+     * @param array $blobFields  Array of fields containing binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _read($key, $ids, $owner, $fields,
-                             $blob_fields = array())
+    protected function _read($key, $ids, $owner, array $fields,
+                             array $blob_fields = array())
     {
         return $this->_driver->_read($key, $ids, $owner, $fields, $blob_fields);
     }
@@ -153,9 +156,10 @@ class Turba_Driver_Share extends Turba_Driver
     /**
      * Adds the specified object to the SQL database.
      *
-     * TODO
+     * @param array $attributes
+     * @param array $blob_fields
      */
-    protected function _add($attributes, $blob_fields = array())
+    protected function _add(array $attributes, array $blob_fields = array())
     {
         $this->_driver->_add($attributes, $blob_fields);
     }
@@ -181,6 +185,8 @@ class Turba_Driver_Share extends Turba_Driver
     /**
      * Deletes all contacts from a specific address book.
      *
+     * @param string $sourceName  The source to delete all contacts from.
+     *
      * @throws Turba_Exception
      */
     protected function _deleteAll($sourceName = null)
@@ -194,16 +200,20 @@ class Turba_Driver_Share extends Turba_Driver
     /**
      * Saves the specified object in the SQL database.
      *
+     * @param Turba_Object $object The object to save
+     *
      * @return string  The object id, possibly updated.
      * @throws Turba_Exception
      */
-    protected function _save($object)
+    protected function _save(Turba_Object $object)
     {
         return $this->_driver->_save($object);
     }
 
     /**
-     * Stub for removing all data for a specific user.
+     * Remove all data for a specific user.
+     *
+     * @param string $user  The user to remove all data for.
      */
     public function removeUserData($user)
     {
@@ -213,15 +223,21 @@ class Turba_Driver_Share extends Turba_Driver
     }
 
     /**
-     * TODO
+     * @param array $attributes
      */
-    protected function _makeKey($attributes)
+    protected function _makeKey(array $attributes)
     {
         return $this->_driver->_makeKey($attributes);
     }
 
     /**
-     * TODO
+     * @param Horde_Date $start  The starting date.
+     * @param Horde_Date $end    The ending date.
+     * @param string $field      The address book field containing the
+     *                           timeObject information (birthday,
+     *                           anniversary).
+     *
+     * @return array  The list of timeobjects
      */
     public function getTimeObjectTurbaList($start, $end, $field)
     {
index dc18075..3803082 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Turba directory driver implementation for PHP's PEAR database abstraction
+ * Turba directory driver implementation for the Horde_Db database abstraction
  * layer.
  *
  * Copyright 2010 The Horde Project (http://www.horde.org)
@@ -9,6 +9,7 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  *
  * @author   Jon Parise <jon@csh.rit.edu>
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
  * @category Horde
  * @license  http://www.horde.org/licenses/asl.php ASL
  * @package  Turba
@@ -42,13 +43,17 @@ class Turba_Driver_Sql extends Turba_Driver
     /**
      * Constructor.
      *
+     * @param string $name   The source name
      * @param array $params  Additional parameters needed:
      * <pre>
      * 'db' - (Horde_Db_Adapter) A DB Adapter object.
      * </pre>
      */
-    public function __construct($name = '', $params = array())
+    public function __construct($name = '', array $params = array())
     {
+        if (empty($params['db'])) {
+            throw new InvalidArgumentException(_("Missing required Horde_Db_Adapter obejct"));
+        }
         $this->_db = $params['db'];
         unset($params['db']);
 
@@ -317,16 +322,17 @@ class Turba_Driver_Sql extends Turba_Driver
      * Reads the given data from the SQL database and returns the
      * results.
      *
-     * @param string $key    The primary key field to use.
-     * @param mixed $ids     The ids of the contacts to load.
-     * @param string $owner  Only return contacts owned by this user.
-     * @param array $fields  List of fields to return.
+     * @param string $key         The primary key field to use.
+     * @param mixed $ids          The ids of the contacts to load.
+     * @param string $owner       Only return contacts owned by this user.
+     * @param array $fields       List of fields to return.
+     * @param array $blob_fields  List of fields that contain binary data.
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _read($key, $ids, $owner, $fields,
-                             $blob_fields = array())
+    protected function _read($key, $ids, $owner, array $fields,
+                             array $blob_fields = array())
     {
         $values = array();
 
@@ -488,10 +494,12 @@ class Turba_Driver_Sql extends Turba_Driver
     /**
      * Saves the specified object in the SQL database.
      *
+     * @param Turba_Object $object  The object to save.
+     *
      * @return string  The object id, possibly updated.
      * @throws Turba_Exception
      */
-    function _save($object)
+    function _save(Turba_Object $object)
     {
         list($object_key, $object_id) = each($this->toDriverKeys(array('__key' => $object->getValue('__key'))));
         $attributes = $this->toDriverKeys($object->getAttributes());
@@ -523,7 +531,7 @@ class Turba_Driver_Sql extends Turba_Driver
      *
      * @return string  A unique ID for the new object.
      */
-    protected function _makeKey($attributes)
+    protected function _makeKey(array $attributes)
     {
         return strval(new Horde_Support_Randomid());
     }
@@ -537,7 +545,7 @@ class Turba_Driver_Sql extends Turba_Driver
      * @return array  An SQL fragment and a list of values suitable for binding
      *                as an array.
      */
-    protected function _buildSearchQuery($glue, $criteria)
+    protected function _buildSearchQuery($glue, array $criteria)
     {
         $clause = '';
         $values = array();
@@ -626,13 +634,13 @@ class Turba_Driver_Sql extends Turba_Driver
      *
      * @param string $user  The user's data to remove.
      *
-     * @throws Turba_Exception
+     * @throws Horde_Exception_PermissionDenied
      */
     public function removeUserData($user)
     {
         // Make sure we are being called by an admin.
         if (!$GLOBALS['registry']->isAdmin()) {
-            throw new Turba_Exception(_("Permission denied"));
+            throw new Horde_Exception_PermissionDenied(_("Permission denied"));
         }
 
         $this->_deleteAll($user);
index 8c600b2..0aea115 100644 (file)
@@ -29,9 +29,11 @@ class Turba_Driver_Vbook extends Turba_Driver
     public $searchCriteria;
 
     /**
+     *
+     * @see Turba_Driver::__construct
      * @throws Turba_Exception
      */
-    public function __construct($name = '', $params = array())
+    public function __construct($name = '', array $params = array())
     {
         parent::__construct($name, $params);
 
@@ -66,11 +68,12 @@ class Turba_Driver_Vbook extends Turba_Driver
      *
      * @param array $criteria  Array containing the search criteria.
      * @param array $fields    List of fields to return
+     * @param array $blobFileds  Array of fields that contain
      *
      * @return array  Hash containing the search results.
      * @throws Turba_Exception
      */
-    protected function _search($criteria, $fields, $blobFields = array())
+    protected function _search(array $criteria, array $fields, array $blobFields = array())
     {
         /* Add the passed in search criteria to the vbook criteria
          * (which need to be mapped from turba fields to
@@ -90,7 +93,7 @@ class Turba_Driver_Vbook extends Turba_Driver
      *
      * @return array  Hash containing the search results.
      */
-    protected function _read($key, $ids, $owner, $fields)
+    protected function _read($key, $ids, $owner, array $fields)
     {
         return $this->_driver->_read($key, $ids, $owner, $fields);
     }
@@ -98,9 +101,10 @@ class Turba_Driver_Vbook extends Turba_Driver
     /**
      * Not supported for virtual address books.
      *
+     * @see Turba_Driver::_add
      * @throws Turba_Exception
      */
-    protected function _add($attributes)
+    protected function _add(array $attributes)
     {
         throw new Turba_Exception(_("You cannot add new contacts to a virtual address book"));
     }
@@ -108,6 +112,7 @@ class Turba_Driver_Vbook extends Turba_Driver
     /**
      * Not supported for virtual address books.
      *
+     * @see Turba_Driver::_delete
      * @throws Turba_Exception
      */
     protected function _delete($object_key, $object_id)
@@ -116,9 +121,9 @@ class Turba_Driver_Vbook extends Turba_Driver
     }
 
     /**
-     * TODO
+     * @see Turba_Driver::_save
      */
-    protected function _save($object)
+    protected function _save(Turba_Object $object)
     {
         return $this->_driver->save($object);
     }
index f0e088e..a388a89 100644 (file)
@@ -4,14 +4,15 @@
  */
 class Turba_Form_AddContact extends Turba_Form_Contact
 {
-    var $_contact = null;
+    protected $_contact = null;
 
-    public function __construct(&$vars, &$contact)
+    public function __construct($vars, Turba_Object $contact)
     {
+        // @TODO: $addSources should be injected
         global $addSources, $notification;
 
         parent::Horde_Form($vars, _("Add Contact"));
-        $this->_contact = &$contact;
+        $this->_contact = $contact;
 
         $this->setButtons(_("Add"));
         $this->addHidden('', 'url', 'text', false);
@@ -43,7 +44,7 @@ class Turba_Form_AddContact extends Turba_Form_Contact
         }
     }
 
-    function validate()
+    public function validate()
     {
         if (!$this->_vars->get('source')) {
             return false;
@@ -51,8 +52,10 @@ class Turba_Form_AddContact extends Turba_Form_Contact
         return parent::validate($this->_vars);
     }
 
-    function execute()
+    public function execute()
     {
+        // @TODO $driver should be injected, or at the very least, obtained
+        //       via the injector
         global $driver, $notification;
 
         /* Form valid, save data. */
index 86418ec..4956e65 100644 (file)
@@ -4,7 +4,11 @@
  */
 class Turba_Form_Contact extends Horde_Form
 {
-    public function __construct(&$vars, &$contact, $tabs = true)
+    /**
+     * @param array $vars  Array of form variables
+     * @param Turba_Object $contact
+     */
+    public function __construct($vars, Turba_Object $contact, $tabs = true)
     {
         global $conf, $notification;
 
@@ -34,9 +38,12 @@ class Turba_Form_Contact extends Horde_Form
 
     /**
      * Set up the Horde_Form fields for $contact's attributes.
+     *
+     * @param Turba_Object $contact  The contact
      */
-    function _addFields($contact, $useTabs = true)
+    public function _addFields(Turba_Object $contact, $useTabs = true)
     {
+        // @TODO: inject this
         global $attributes;
 
         // Run through once to see what form actions, if any, we need
@@ -81,11 +88,11 @@ class Turba_Form_Contact extends Horde_Form
                 $desc = isset($attribute['desc']) ? $attribute['desc'] : null;
 
                 if (is_array($map[$field])) {
-                    $v = &$this->addVariable($attribute['label'], 'object[' . $field . ']', $attribute['type'], false, false, $desc, $params);
+                    $v = $this->addVariable($attribute['label'], 'object[' . $field . ']', $attribute['type'], false, false, $desc, $params);
                     $v->disable();
                 } else {
                     $readonly = isset($attribute['readonly']) ? $attribute['readonly'] : null;
-                    $v = &$this->addVariable($attribute['label'], 'object[' . $field . ']', $attribute['type'], $attribute['required'], $readonly, $desc, $params);
+                    $v = $this->addVariable($attribute['label'], 'object[' . $field . ']', $attribute['type'], $attribute['required'], $readonly, $desc, $params);
 
                     if (!empty($actions[$field])) {
                         $actionfields = array();
index 6c39f22..c0a6bef 100644 (file)
@@ -17,7 +17,7 @@
  */
 class Turba_Form_CreateAddressBook extends Horde_Form
 {
-    public function __construct(&$vars)
+    public function __construct($vars)
     {
         parent::__construct($vars, _("Create Address Book"));
 
@@ -30,7 +30,7 @@ class Turba_Form_CreateAddressBook extends Horde_Form
     /**
      * @throws Turba_Exception
      */
-    function execute()
+    public function execute()
     {
         // Need a clean cfgSources array
         include TURBA_BASE . '/config/backends.php';
index 0b09708..3bae3e7 100644 (file)
@@ -20,11 +20,11 @@ class Turba_Form_DeleteAddressBook extends Horde_Form
     /**
      * Address book being deleted
      */
-    var $_addressbook;
+    protected $_addressbook;
 
-    public function __construct(&$vars, &$addressbook)
+    public function __construct($vars, $addressbook)
     {
-        $this->_addressbook = &$addressbook;
+        $this->_addressbook = $addressbook;
         parent::__construct($vars, sprintf(_("Delete %s"), $addressbook->get('name')));
 
         $this->addHidden('', 'a', 'text', true);
@@ -38,7 +38,7 @@ class Turba_Form_DeleteAddressBook extends Horde_Form
      *
      * @throws Turba_Exception
      */
-    function execute()
+    public function execute()
     {
         // If cancel was clicked, return false.
         if ($this->_vars->get('submitbutton') == _("Cancel")) {
@@ -55,8 +55,7 @@ class Turba_Form_DeleteAddressBook extends Horde_Form
         // We have a Turba_Driver, try to delete the address book.
         $driver->deleteAll();
 
-        // Address book successfully deleted from backend, remove the
-        // share.
+        // Address book successfully deleted from backend, remove the share.
         try {
             $GLOBALS['turba_shares']->removeShare($this->_addressbook);
         } catch (Horde_Share_Exception $e) {
index df21352..72a9109 100644 (file)
@@ -19,12 +19,14 @@ class Turba_Form_EditAddressBook extends Horde_Form
 {
     /**
      * Address book being edited
+     *
+     * @var Horde_Share_Object
      */
-    var $_addressbook;
+    protected $_addressbook;
 
-    public function __construct(&$vars, &$addressbook)
+    public function __construct($vars, Horde_Share_Object $addressbook)
     {
-        $this->_addressbook = &$addressbook;
+        $this->_addressbook = $addressbook;
         parent::__construct($vars, sprintf(_("Edit %s"), $addressbook->get('name')));
 
         $this->addHidden('', 'a', 'text', true);
@@ -34,16 +36,15 @@ class Turba_Form_EditAddressBook extends Horde_Form
         $this->setButtons(array(_("Save")));
     }
 
-    function execute()
+    public function execute()
     {
         $this->_addressbook->set('name', $this->_vars->get('name'));
         $this->_addressbook->set('desc', $this->_vars->get('description'));
-
         try {
             $this->_addressbook->save();
             return true;
-        } catch (Turba_Exception $e) {
-            return PEAR::raiseError(sprintf(_("Unable to save address book \"%s\": %s"), $id, $e->getMessage()));
+        } catch (Horde_Share_Exception $e) {
+            throw new Turba_Exception(sprintf(_("Unable to save address book \"%s\": %s"), $id, $e->getMessage()));
         }
     }
 
index c4c8368..be06989 100644 (file)
@@ -4,15 +4,19 @@
  */
 class Turba_Form_EditContact extends Turba_Form_Contact
 {
-    var $_source;
-    var $_contact;
+    protected $_source;
+    protected $_contact;
 
-    public function __construct(&$vars, &$contact)
+    /**
+     * @param Turba_Object $contact
+     * @param array $vars
+     */
+    public function __construct($vars, Turba_Object $contact)
     {
         global $conf;
 
         parent::Horde_Form($vars, '', 'Turba_View_EditContact');
-        $this->_contact = &$contact;
+        $this->_contact = $contact;
 
         $this->setButtons(_("Save"));
         $this->addHidden('', 'url', 'text', false);
@@ -36,17 +40,17 @@ class Turba_Form_EditContact extends Turba_Form_Contact
         $vars->set('source', $contact->getSource());
     }
 
-    function getSource()
+    public function getSource()
     {
         return $this->_source;
     }
 
-    function execute()
+    public function execute()
     {
         global $conf, $notification;
 
         if (!$this->validate($this->_vars)) {
-            return PEAR::raiseError('Invalid');
+            throw new Turba_Exception('Invalid');
         }
 
         /* Form valid, save data. */
@@ -71,7 +75,7 @@ class Turba_Form_EditContact extends Turba_Form_Contact
         } catch (Turba_Exception $e) {
             Horde::logMessage($e, 'ERR');
             $notification->push(_("There was an error saving the contact. Contact your system administrator for further help."), 'horde.error');
-            return PEAR::raiseError($e->getMessage());
+            throw $e;
         }
 
         if ($conf['documents']['type'] != 'none' && isset($info['vfs'])) {
index dcb99ac..64bfe93 100644 (file)
@@ -4,7 +4,7 @@
  */
 class Turba_Form_EditContactGroup extends Turba_Form_EditContact
 {
-    public function __construct(&$vars, &$contact)
+    public function __construct($vars, $contact)
     {
         $this->addHidden('', 'objectkeys', 'text', false);
         $this->addHidden('', 'original_source', 'text', false);
@@ -30,7 +30,7 @@ class Turba_Form_EditContactGroup extends Turba_Form_EditContact
         $this->appendButtons(_("Finish"));
     }
 
-    function renderActive($renderer, &$vars, $action, $method)
+    public function renderActive($renderer, $vars, $action, $method)
     {
         parent::renderActive($renderer, $vars, $action, $method);
 
@@ -44,7 +44,7 @@ class Turba_Form_EditContactGroup extends Turba_Form_EditContact
         echo '<br />' . $listView->getPage($numDisplayed);
     }
 
-    function execute()
+    public function execute()
     {
         $result = parent::execute();
 
index a8c231c..9781526 100644 (file)
@@ -33,7 +33,7 @@ class Turba_List implements Countable
     /**
      * Constructor.
      */
-    public function __construct($ids = array())
+    public function __construct(array $ids = array())
     {
         foreach ($ids as $value) {
             list($source, $key) = explode(':', $value);
@@ -49,7 +49,7 @@ class Turba_List implements Countable
      *
      * @param Turba_Object $object  The object to insert.
      */
-    public function insert($object)
+    public function insert(Turba_Object $object)
     {
         if ($object instanceof Turba_Object) {
             $key = $object->getSource() . ':' . $object->getValue('__key');
@@ -179,7 +179,7 @@ class Turba_List implements Countable
      *
      * @return integer  Comparison of the two field values.
      */
-    protected function _cmp($a, $b)
+    protected function _cmp(Turba_Object $a, Turba_Object $b)
     {
         foreach ($this->_usortCriteria as $field) {
             // Set the comparison type based on the type of attribute we're
index 1023475..5cecdca 100644 (file)
@@ -7,35 +7,35 @@
  * @author  Jon Parise <jon@csh.rit.edu>
  * @package Turba
  */
-class Turba_Object {
-
+class Turba_Object
+{
     /**
      * Underlying driver.
      *
      * @var Turba_Driver
      */
-    var $driver;
+    public $driver;
 
     /**
      * Hash of attributes for this contact.
      *
      * @var array
      */
-    var $attributes;
+    public $attributes;
 
     /**
      * Reference to this object's VFS instance.
      *
      * @var VFS
      */
-    var $_vfs;
+    protected $_vfs;
 
     /**
      * Keeps the normalized values of sort columns.
      *
      * @var array
      */
-    var $sortValue = array();
+    public $sortValue = array();
 
     /**
      * Constructs a new Turba_Object object.
@@ -43,9 +43,9 @@ class Turba_Object {
      * @param Turba_Driver $driver  The source that this object came from.
      * @param array $attributes     Hash of attributes for this object.
      */
-    function Turba_Object(&$driver, $attributes = array())
+    public function __construct(Turba_Driver $driver, array $attributes = array())
     {
-        $this->driver = &$driver;
+        $this->driver = $driver;
         $this->attributes = $attributes;
         $this->attributes['__type'] = 'Object';
     }
@@ -55,7 +55,7 @@ class Turba_Object {
      *
      * @return array  All properties of this object.
      */
-    function getAttributes()
+    public function getAttributes()
     {
         return $this->attributes;
     }
@@ -63,7 +63,7 @@ class Turba_Object {
     /**
      * Returns the name of the address book that this object is from.
      */
-    function getSource()
+    public function getSource()
     {
         return $this->driver->getName();
     }
@@ -75,7 +75,7 @@ class Turba_Object {
      *
      * @return string Fully qualified contact id.
      */
-    function getGuid($delimiter = ':')
+    public function getGuid($delimiter = ':')
     {
         return 'turba' . $delimiter . $this->getSource() . $delimiter . $this->getValue('__uid');
     }
@@ -96,7 +96,6 @@ class Turba_Object {
                 return Horde::callHook('decode_attribute', array($attribute, $this->attributes[$attribute]), 'turba');
             } catch (Turba_Exception $e) {}
         }
-
         if (isset($this->driver->map[$attribute]) &&
             is_array($this->driver->map[$attribute])) {
             $args = array();
@@ -127,14 +126,13 @@ class Turba_Object {
      * @param string $attribute  The attribute to set.
      * @param string $value      The value of $attribute.
      */
-    function setValue($attribute, $value)
+    public function setValue($attribute, $value)
     {
         if (Horde::hookExists('encode_attribute', 'turba')) {
             try {
                 $value = Horde::callHook('encode_attribute', array($attribute, $value, isset($this->attributes[$attribute]) ? $this->attributes[$attribute] : null, $this), 'turba');
             } catch (Turba_Exception $e) {}
         }
-
         if (isset($this->driver->map[$attribute]) &&
             is_array($this->driver->map[$attribute]) &&
             !isset($this->driver->map[$attribute]['attribute'])) {
@@ -153,7 +151,7 @@ class Turba_Object {
      *
      * @return boolean  Whether or not there is a value for $attribute.
      */
-    function hasValue($attribute)
+    public function hasValue($attribute)
     {
         if (isset($this->driver->map[$attribute]) &&
             is_array($this->driver->map[$attribute])) {
@@ -175,18 +173,16 @@ class Turba_Object {
      *
      * @return integer  The timestamp of the last modification or zero.
      */
-    function lastModification()
+    public function lastModification()
     {
         $time = $this->getValue('__modified');
         if (!is_null($time)) {
             return $time;
         }
-
         if (!$this->getValue('__uid')) {
             $this->setValue('__modified', 0);
             return 0;
         }
-
         $time = 0;
         try {
             $log = $GLOBALS['injector']
@@ -210,7 +206,7 @@ class Turba_Object {
      *
      * @param Turba_Object $contact  Another contact.
      */
-    function merge(Turba_Object $contact)
+    public function merge(Turba_Object $contact)
     {
         foreach (array_keys($contact->attributes) as $attribute) {
             if (!$this->hasValue($attribute) && $contact->hasValue($attribute)) {
@@ -225,12 +221,11 @@ class Turba_Object {
      * @return array  A hash with the optional entries 'created' and 'modified'
      *                and human readable history information as the values.
      */
-    function getHistory()
+    public function getHistory()
     {
         if (!$this->getValue('__uid')) {
             return array();
         }
-
         $history = array();
         try {
             $log = $GLOBALS['injector']
@@ -263,7 +258,7 @@ class Turba_Object {
      *
      * @return boolean  True if this object is a group of multiple contacts.
      */
-    function isGroup()
+    public function isGroup()
     {
         return false;
     }
@@ -273,7 +268,7 @@ class Turba_Object {
      *
      * @return boolean  Whether or not the current user can edit this object
      */
-    function isEditable()
+    public function isEditable()
     {
         return $this->driver->hasPermission(Horde_Perms::EDIT);
     }
@@ -285,15 +280,20 @@ class Turba_Object {
      *
      * @return boolean True if user has the permission.
      */
-    function hasPermission($perm)
+    public function hasPermission($perm)
     {
         return $this->driver->hasPermission($perm);
     }
 
     /**
      * Contact url.
+     *
+     * @param string $view   The view for the url
+     * @param boolean $full  Generate a full url?
+     *
+     * @return string
      */
-    function url($view = null, $full = false)
+    public function url($view = null, $full = false)
     {
         $url = Horde::url('contact.php', $full)->add(array(
             'source' => $this->driver->getName(),
@@ -314,10 +314,9 @@ class Turba_Object {
      *                     Horde_Form_Type_file.
      * @throws Turba_Exception
      */
-    function addFile($info)
+    public function addFile(array $info)
     {
         $this->_vfsInit();
-
         $dir = TURBA_VFS_PATH . '/' . $this->getValue('__uid');
         $file = $info['name'];
         while ($this->_vfs->exists($dir, $file)) {
@@ -332,7 +331,6 @@ class Turba_Object {
                 }
             }
         }
-
         try {
             $this->_vfs->write($dir, $file, $info['tmp_name'], true);
         } catch (VFS_Exception $e) {
@@ -346,7 +344,7 @@ class Turba_Object {
      * @param string $file  The file name.
      * @throws Turba_Exception
      */
-    function deleteFile($file)
+    public function deleteFile($file)
     {
         $this->_vfsInit();
         try {
@@ -361,7 +359,7 @@ class Turba_Object {
      *
      * @throws Turba_Exception
      */
-    function deleteFiles()
+    public function deleteFiles()
     {
         $this->_vfsInit();
         if ($this->_vfs->exists(TURBA_VFS_PATH, $this->getValue('__uid'))) {
@@ -378,7 +376,7 @@ class Turba_Object {
      *
      * @return array  A list of hashes with file informations.
      */
-    function listFiles()
+    public function listFiles()
     {
         try {
             $this->_vfsInit();
@@ -398,7 +396,7 @@ class Turba_Object {
      *
      * @return string  The HTML code of the generated link.
      */
-    function vfsDisplayUrl($file)
+    public function vfsDisplayUrl($file)
     {
         global $registry, $mime_drivers_map, $mime_drivers;
 
@@ -433,7 +431,7 @@ class Turba_Object {
      *
      * @return string  The HTML code of the generated link.
      */
-    function vfsEditUrl($file)
+    public function vfsEditUrl($file)
     {
         $delform = '<form action="' .
             Horde::url('deletefile.php') .
@@ -463,7 +461,7 @@ class Turba_Object {
      *
      * @throws Turba_Exception
      */
-    function _vfsInit()
+    protected function _vfsInit()
     {
         if (!isset($this->_vfs)) {
             try {
index 156670b..b2502f1 100644 (file)
@@ -7,8 +7,8 @@
  * @author  Jon Parise <jon@csh.rit.edu>
  * @package Turba
  */
-class Turba_Object_Group extends Turba_Object {
-
+class Turba_Object_Group extends Turba_Object
+{
     /**
      * Constructs a new Turba_Object_Group.
      *
@@ -16,7 +16,7 @@ class Turba_Object_Group extends Turba_Object {
      *                              from.
      * @param array $attributes     Hash of attributes for this group.
      */
-    function Turba_Object_Group(&$driver, $attributes = array())
+    public function __construct(Turba_Driver $driver, array $attributes = array())
     {
         parent::Turba_Object($driver, $attributes);
         $this->attributes['__type'] = 'Group';
@@ -27,15 +27,17 @@ class Turba_Object_Group extends Turba_Object {
      *
      * @return boolean  True.
      */
-    function isGroup()
+    public function isGroup()
     {
         return true;
     }
 
     /**
      * Contact url.
+     *
+     * @return Horde_Url
      */
-    function url($view = null, $full = false)
+    public function url($view = null, $full = false)
     {
         return Horde::url('browse.php', $full)->add(array(
             'source' => $this->getSource(),
@@ -51,7 +53,7 @@ class Turba_Object_Group extends Turba_Object {
      *
      * @throws Turba_Exception
      */
-    function addMember($contactId, $sourceId = null)
+    public function addMember($contactId, $sourceId = null)
     {
         // Default to the same source as the group.
         if (is_null($sourceId)) {
@@ -99,7 +101,7 @@ class Turba_Object_Group extends Turba_Object {
      * @param string $contactId  The id of the contact to remove.
      * @param string $sourceId   The source $contactId is from.
      */
-    function removeMember($contactId, $sourceId = null)
+    public function removeMember($contactId, $sourceId = null)
     {
         $members = @unserialize($this->attributes['__members']);
 
@@ -123,7 +125,7 @@ class Turba_Object_Group extends Turba_Object {
      *
      * @return integer
      */
-    function count()
+    public function count()
     {
         $children = @unserialize($this->attributes['__members']);
         if (!is_array($children)) {
@@ -141,7 +143,7 @@ class Turba_Object_Group extends Turba_Object {
      *
      * @return Turba_List   List containing the members of this group
      */
-    function &listMembers($sort = null)
+    public function listMembers($sort = null)
     {
         $list = new Turba_List();
 
index 5ad3b50..48b0a9a 100644 (file)
@@ -9,12 +9,19 @@ define('TURBA_VFS_PATH', '.horde/turba/documents');
  * @author  Jon Parise <jon@horde.org>
  * @package Turba
  */
-class Turba {
-
+class Turba
+{
     /**
      * @todo Consolidate on a single mail/compose method.
+     *
+     * @param mixed $data  Either a single email address or an array of email
+     *                     addresses to format.
+     * @param string $name  The personal name phrase.
+     *
+     * @return mixed Either the formatted address or an array of formatted
+     *               addresses.
      */
-    function formatEmailAddresses($data, $name)
+    static public function formatEmailAddresses($data, $name)
     {
         global $registry;
         static $useRegistry;
@@ -93,10 +100,10 @@ class Turba {
      *
      * @return array  The filtered, ordered $cfgSources entries.
      */
-    function getAddressBooks($permission = Horde_Perms::READ, $options = array())
+    static public function getAddressBooks($permission = Horde_Perms::READ, array $options = array())
     {
         $addressbooks = array();
-        foreach (array_keys(Turba::getAddressBookOrder()) as $addressbook) {
+        foreach (array_keys(self::getAddressBookOrder()) as $addressbook) {
             $addressbooks[$addressbook] = $GLOBALS['cfgSources'][$addressbook];
         }
 
@@ -104,7 +111,7 @@ class Turba {
             $addressbooks = $GLOBALS['cfgSources'];
         }
 
-        return Turba::permissionsFilter($addressbooks, $permission, $options);
+        return self::permissionsFilter($addressbooks, $permission, $options);
     }
 
     /**
@@ -134,7 +141,7 @@ class Turba {
      *
      * @return string  The default address book name.
      */
-    function getDefaultAddressBook()
+    static public function getDefaultAddressBook()
     {
         $lines = json_decode($GLOBALS['prefs']->getValue('addressbooks'));
         if (!empty($lines)) {
@@ -149,7 +156,7 @@ class Turba {
         /* In case of shares select first user owned address book as default */
         if (!empty($_SESSION['turba']['has_share'])) {
             try {
-                $owned_shares = Turba::listShares(true);
+                $owned_shares = self::listShares(true);
                 if (count($owned_shares) > 0) {
                     return key($owned_shares);
                 }
@@ -163,7 +170,7 @@ class Turba {
     /**
      * Returns the sort order selected by the user
      */
-    function getPreferredSortOrder()
+    static public function getPreferredSortOrder()
     {
         return @unserialize($GLOBALS['prefs']->getValue('sortorder'));
     }
@@ -171,7 +178,7 @@ class Turba {
     /**
      * Retrieves a column's field name
      */
-    function getColumnName($i, $columns)
+    static public function getColumnName($i, $columns)
     {
         return $i == 0 ? 'name' : $columns[$i - 1];
     }
@@ -203,7 +210,7 @@ class Turba {
      *
      * @return string  String containing the last name.
      */
-    function guessLastname($name)
+    static public function guessLastname($name)
     {
         $name = trim(preg_replace('|\s|', ' ', $name));
         if (!empty($name)) {
@@ -244,7 +251,7 @@ class Turba {
      *                 or "Lastname, Firstname" depending on $name_format or
      *                 the user's preference.
      */
-    function formatName($ob, $name_format = null)
+    static public function formatName(Turba_Object $ob, $name_format = null)
     {
         static $default_format;
 
@@ -270,7 +277,7 @@ class Turba {
         } else {
             /* One field, we'll have to guess. */
             $name = $ob->getValue('name');
-            $lastname = Turba::guessLastname($name);
+            $lastname = self::guessLastname($name);
             if ($name_format == 'last_first' &&
                 !is_int(strpos($name, ',')) &&
                 Horde_String::length($name) > Horde_String::length($lastname)) {
@@ -283,14 +290,19 @@ class Turba {
                 $name = preg_replace('/' . preg_quote($lastname, '/') . ',\s*/', '', $name);
                 $name = $name . ' ' . $lastname;
             }
+
             return $name;
         }
     }
 
     /**
      * Returns the real name, if available, of a user.
+     *
+     * @param string $uid  The uid of the name to return.
+     *
+     * @return string  The user's full, real name.
      */
-    function getUserName($uid)
+    static public function getUserName($uid)
     {
         static $names = array();
 
@@ -309,12 +321,14 @@ class Turba {
     /**
      * Gets extended permissions on an address book.
      *
-     * @param Turba_Driver $addressBook The address book to get extended permissions for.
-     * @param string $permission  What extended permission to get.
+     * @param Turba_Driver $addressBook  The address book to get extended
+     *                                   permissions for.
+     * @param string $permission         What extended permission to get.
      *
-     * @return mixed  The requested extended permissions value, or true if it doesn't exist.
+     * @return mixed  The requested extended permissions value, or true if it
+     *                doesn't exist.
      */
-    function getExtendedPermission($addressBook, $permission)
+    static public function getExtendedPermission(Turba_Driver $addressBook, $permission)
     {
         // We want to check the base source as extended permissions
         // are enforced per backend, not per share.
@@ -347,7 +361,7 @@ class Turba {
      *
      * @return array  The filtered data.
      */
-    function permissionsFilter($in, $permission = Horde_Perms::READ, $options = array())
+    static public function permissionsFilter(array $in, $permission = Horde_Perms::READ, array $options = array())
     {
         $out = array();
 
@@ -374,19 +388,19 @@ class Turba {
      * Replaces all share-enabled sources in a source list with all shares
      * from this source that the current user has access to.
      *
-     * This will only sync shares that are unique to Horde (basically, a SQL
-     * driver source for now).  Any backend that supports ACLs or similar
-     * mechanism should be configured from within backends.php or
+     * This will only sync shares that are unique to Horde (such as a SQL
+     * source).  Any backend that supports ACLs or similar mechanism should be
+     * configured from within backends.php or
      * _horde_hook_share_* calls.
      *
      * @param array $sources  The default $cfgSources array.
      *
      * @return array  The $cfgSources array.
      */
-    function getConfigFromShares($sources)
+    static public function getConfigFromShares(array $sources)
     {
         try {
-            $shares = Turba::listShares();
+            $shares = self::listShares();
         } catch (Horde_Share_Exception $e) {
             // Notify the user if we failed, but still return the $cfgSource
             // array.
@@ -495,8 +509,10 @@ class Turba {
      * Retrieve a new source config entry based on a Turba share.
      *
      * @param Horde_Share object  The share to base config on.
+     *
+     * @return array  The $cfgSource entry for this share source.
      */
-    function getSourceFromShare($share)
+    static public function getSourceFromShare(Horde_Share $share)
     {
         // Require a fresh config file.
         require TURBA_BASE . '/config/backends.php';
@@ -522,7 +538,7 @@ class Turba {
      *
      * @return array  Shares the user has the requested permissions to.
      */
-    function listShares($owneronly = false, $permission = Horde_Perms::READ)
+    static public function listShares($owneronly = false, $permission = Horde_Perms::READ)
     {
         if (!$GLOBALS['session']->get('turba', 'has_share')) {
             // No backends are configured to provide shares
@@ -548,13 +564,13 @@ class Turba {
     /**
      * Create a new Turba share.
      *
-     * @param string $share_id The id for the new share.
-     * @param array $params Parameters for the new share.
+     * @param string $share_name  The id for the new share.
+     * @param array  $params      Parameters for the new share.
      *
      * @return Horde_Share  The new share object.
      * @throws Turba_Exception
      */
-    static public function createShare($share_id, $params)
+    static public function createShare($share_name, $params)
     {
         if (!isset($params['name'])) {
             /* Sensible default for empty display names */
@@ -567,7 +583,7 @@ class Turba {
 
         /* Generate the new share. */
         try {
-            $share = $GLOBALS['turba_shares']->newShare($GLOBALS['registry']->getAuth(), $share_id);
+            $share = $GLOBALS['turba_shares']->newShare($GLOBALS['registry']->getAuth(), $share_name);
 
             /* Set the display name for this share. */
             $share->set('name', $name);
@@ -588,13 +604,13 @@ class Turba {
 
         /* Update share_id as backends like Kolab change it to the IMAP folder
          * name. */
-        $share_id = $share->getName();
+        $share_name = $share->getName();
 
         /* Add the new addressbook to the user's list of visible address
          * books. */
         $prefs = json_decode($GLOBALS['prefs']->getValue('addressbooks'), true);
-        if (!is_array($prefs) || array_search($share_id, $prefs) === false) {
-            $prefs[] = $share_id;
+        if (!is_array($prefs) || array_search($share_name, $prefs) === false) {
+            $prefs[] = $share_name;
             $GLOBALS['prefs']->setValue('addressbooks', json_encode($prefs));
         }
 
@@ -604,7 +620,7 @@ class Turba {
     /**
      * Add browse.js javascript to page.
      */
-    public function addBrowseJs()
+    static public function addBrowseJs()
     {
         Horde::addScriptFile('browse.js', 'turba');
         Horde::addInlineJsVars(array(
index 7aaea16..9c69e7b 100644 (file)
  * @author  Chuck Hagenbuch <chuck@horde.org>
  * @package Turba
  */
-class Turba_View_Browse {
-
+class Turba_View_Browse
+{
     /**
      * @var array
      */
-    var $_params;
+     protected $_params;
 
     /**
      * Constructor;
      *
      * @param array $params Stuff to import into the view's scope.
      */
-    public function __construct($params)
+    public function __construct(array $params)
     {
         $this->_params = $params;
     }
 
-    function updateSortOrderFromVars()
+    public function updateSortOrderFromVars()
     {
         extract($this->_params, EXTR_REFS);
 
@@ -36,7 +36,6 @@ class Turba_View_Browse {
             $sources = Turba::getColumns();
             $columns = isset($sources[$source]) ? $sources[$source] : array();
             $column_name = Turba::getColumnName($sortby, $columns);
-
             $append = true;
             $ascending = ($vars->get('sortdir') == 0);
             if ($vars->get('sortadd')) {
@@ -58,18 +57,19 @@ class Turba_View_Browse {
         }
     }
 
-    function run()
+    public function run()
     {
         extract($this->_params, EXTR_REFS);
 
         $this->updateSortOrderFromVars();
-
         $title = _("Address Book Listing");
         if (!$browse_source_count && $vars->get('key') != '**search') {
             $notification->push(_("There are no browseable address books."), 'horde.warning');
         } else {
             try {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                $driver = $GLOBALS['injector']
+                    ->getInstance('Turba_Injector_Factory_Driver')
+                    ->create($source);
             } catch (Turba_Exception $e) {
                 $notification->push($e, 'horde.error');
                 unset($driver);
@@ -78,8 +78,6 @@ class Turba_View_Browse {
 
         if (isset($driver)) {
             $actionID = $vars->get('actionID');
-
-            // Run through the action handlers.
             switch ($actionID) {
             case 'delete':
                 $keys = $vars->get('objectkeys');
@@ -94,7 +92,7 @@ class Turba_View_Browse {
                 if ($key && $key != '**search') {
                     // We are removing a contact from a list.
                     $errorCount = 0;
-                    $list = &$driver->getObject($key);
+                    $list = $driver->getObject($key);
                     foreach ($keys as $sourceKey) {
                         list($objectSource, $objectKey) = explode(':', $sourceKey, 2);
                         if (!$list->removeMember($objectKey, $objectSource)) {
@@ -102,11 +100,21 @@ class Turba_View_Browse {
                         }
                     }
                     if (!$errorCount) {
-                        $notification->push(sprintf(_("Successfully removed %d contact(s) from list."), count($keys)), 'horde.success');
+                        $notification->push(
+                            sprintf(_("Successfully removed %d contact(s) from list."),
+                                count($keys)),
+                            'horde.success');
                     } elseif (count($keys) == $errorCount) {
-                        $notification->push(sprintf(_("Error removing %d contact(s) from list."), count($keys)), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Error removing %d contact(s) from list."),
+                                 count($keys)),
+                            'horde.error');
                     } else {
-                        $notification->push(sprintf(_("Error removing %d of %d requested contact(s) from list."), $errorCount, count($keys)), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Error removing %d of %d requested contact(s) from list."),
+                                $errorCount,
+                                count($keys)),
+                            'horde.error');
                     }
                     $list->store();
                 } else {
@@ -121,11 +129,21 @@ class Turba_View_Browse {
                         }
                     }
                     if (!$errorCount) {
-                        $notification->push(sprintf(_("Successfully deleted %d contact(s)."), count($keys)), 'horde.success');
+                        $notification->push(
+                            sprintf(_("Successfully deleted %d contact(s)."),
+                                count($keys)),
+                            'horde.success');
                     } elseif (count($keys) == $errorCount) {
-                        $notification->push(sprintf(_("Error deleting %d contact(s)."), count($keys)), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Error deleting %d contact(s)."),
+                                count($keys)),
+                            'horde.error');
                     } else {
-                        $notification->push(sprintf(_("Error deleting %d of %d requested contacts(s)."), $errorCount, count($keys)), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Error deleting %d of %d requested contacts(s)."),
+                                $errorCount,
+                                count($keys)),
+                            'horde.error');
                     }
                 }
                 break;
@@ -141,7 +159,9 @@ class Turba_View_Browse {
                 $targetSource = $vars->get('targetAddressbook');
 
                 try {
-                    $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource);
+                    $targetDriver = $GLOBALS['injector']
+                        ->getInstance('Turba_Injector_Factory_Driver')
+                        ->create($targetSource);
                 } catch (Turba_Exception $e) {
                     $notification->push($e, 'horde.error');
                     break;
@@ -170,7 +190,9 @@ class Turba_View_Browse {
 
                     // Try and load the driver for the source.
                     try {
-                        $sourceDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($objectSource);
+                        $sourceDriver = $GLOBALS['injector']
+                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->create($objectSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
                         continue;
@@ -179,15 +201,24 @@ class Turba_View_Browse {
                     try {
                         $object = $sourceDriver->getObject($objectKey);
                     } catch (Turba_Exception $e) {
-                        $notification->push(sprintf(_("Failed to find object to be added: %s"), $e->getMessage()), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Failed to find object to be added: %s"),
+                                $e->getMessage()),
+                            'horde.error');
                         continue;
                     }
 
                     if ($object->isGroup()) {
                         if ($actionID == 'move') {
-                            $notification->push(sprintf(_("\"%s\" was not moved because it is a list."), $object->getValue('name')), 'horde.warning');
+                            $notification->push(
+                                sprintf(_("\"%s\" was not moved because it is a list."),
+                                    $object->getValue('name')),
+                                'horde.warning');
                         } else {
-                            $notification->push(sprintf(_("\"%s\" was not copied because it is a list."), $object->getValue('name')), 'horde.warning');
+                            $notification->push(
+                                sprintf(_("\"%s\" was not copied because it is a list."),
+                                    $object->getValue('name')),
+                                'horde.warning');
                         }
                         continue;
                     }
@@ -203,7 +234,10 @@ class Turba_View_Browse {
 
                             // Get 'data' value if object type is image, the
                             // direct value in other case.
-                            $objAttributes[$info_key] = isset($GLOBALS['attributes'][$info_key]) && $GLOBALS['attributes'][$info_key]['type'] == 'image' ? $objectValue['load']['data'] : $objectValue;
+                            $objAttributes[$info_key] =
+                                isset($GLOBALS['attributes'][$info_key]) &&
+                                      $GLOBALS['attributes'][$info_key]['type'] == 'image' ?
+                                        $objectValue['load']['data'] : $objectValue;
                         }
                     }
                     unset($objAttributes['__owner']);
@@ -211,11 +245,20 @@ class Turba_View_Browse {
                     try {
                         $targetDriver->add($objAttributes);
                     } catch (Turba_Exception $e) {
-                        $notification->push(sprintf(_("Failed to add %s to %s: %s"), $object->getValue('name'), $targetDriver->title, $e), 'horde.error');
+                        $notification->push(
+                            sprintf(_("Failed to add %s to %s: %s"),
+                                $object->getValue('name'),
+                                $targetDriver->title,
+                                $e),
+                            'horde.error');
                         break;
                     }
 
-                    $notification->push(sprintf(_("Successfully added %s to %s"), $object->getValue('name'), $targetDriver->title), 'horde.success');
+                    $notification->push(
+                        sprintf(_("Successfully added %s to %s"),
+                            $object->getValue('name'),
+                            $targetDriver->title),
+                        'horde.success');
 
                     // If we're moving objects, and we succeeded,
                     // delete them from the original source now.
@@ -223,7 +266,10 @@ class Turba_View_Browse {
                         try {
                             $sourceDriver->delete($objectKey);
                         } catch (Turba_Exception $e) {
-                            $notification->push(sprintf(_("There was an error deleting \"%s\" from the source address book."), $object->getValue('name')), 'horde.error');
+                            $notification->push(
+                                sprintf(_("There was an error deleting \"%s\" from the source address book."),
+                                    $object->getValue('name')),
+                                'horde.error');
                         }
 
                         /* Log the adding of this item in the history again,
@@ -256,7 +302,9 @@ class Turba_View_Browse {
                     }
 
                     try {
-                        $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource);
+                        $targetDriver = $GLOBALS['injector']
+                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->create($targetSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
                         break;
@@ -271,7 +319,9 @@ class Turba_View_Browse {
                 } else {
                     $targetSource = $vars->get('targetAddressbook');
                     try {
-                        $targetDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($targetSource);
+                        $targetDriver = $GLOBALS['injector']
+                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->create($targetSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
                         break;
@@ -288,11 +338,21 @@ class Turba_View_Browse {
                             }
                         }
                         if (!$errorCount) {
-                            $notification->push(sprintf(_("Successfully added %d contact(s) to list."), count($keys)), 'horde.success');
+                            $notification->push(
+                                sprintf(_("Successfully added %d contact(s) to list."),
+                                    count($keys)),
+                                'horde.success');
                         } elseif ($errorCount == count($keys)) {
-                            $notification->push(sprintf(_("Error adding %d contact(s) to list."), count($keys)), 'horde.error');
+                            $notification->push(
+                                sprintf(_("Error adding %d contact(s) to list."),
+                                    count($keys)),
+                                'horde.error');
                         } else {
-                            $notification->push(sprintf(_("Error adding %d of %d requested contact(s) to list."), $errorCount, count($keys)), 'horde.error');
+                            $notification->push(
+                                sprintf(_("Error adding %d of %d requested contact(s) to list."),
+                                    $errorCount,
+                                    count($keys)),
+                                'horde.error');
                         }
                         $target->store();
                     }
@@ -304,7 +364,9 @@ class Turba_View_Browse {
                         Horde::permissionDeniedError(
                             'turba',
                             'max_contacts',
-                            sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title'])
+                            sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."),
+                                $max_contacts,
+                                $cfgSources[$source]['title'])
                         );
                         break;
                     }
@@ -327,7 +389,10 @@ class Turba_View_Browse {
                         try {
                             $target = $targetDriver->getObject($targetKey);
                             if ($target->isGroup()) {
-                                $notification->push(sprintf(_("Successfully created the contact list \"%s\"."), $newList['name']), 'horde.success');
+                                $notification->push(
+                                    sprintf(_("Successfully created the contact list \"%s\"."),
+                                        $newList['name']),
+                                    'horde.success');
                                 if (is_array($keys)) {
                                     $errorCount = 0;
                                     foreach ($keys as $sourceKey) {
@@ -337,11 +402,21 @@ class Turba_View_Browse {
                                         }
                                     }
                                     if (!$errorCount) {
-                                        $notification->push(sprintf(_("Successfully added %d contact(s) to list."), count($keys)), 'horde.success');
+                                        $notification->push(
+                                            sprintf(_("Successfully added %d contact(s) to list."),
+                                                count($keys)),
+                                            'horde.success');
                                     } elseif ($errorCount == count($keys)) {
-                                        $notification->push(sprintf(_("Error adding %d contact(s) to list."), count($keys)), 'horde.error');
+                                        $notification->push(
+                                            sprintf(_("Error adding %d contact(s) to list."),
+                                                count($keys)),
+                                            'horde.error');
                                     } else {
-                                        $notification->push(sprintf(_("Error adding %d of %d requested contact(s) to list."), $errorCount, count($keys)), 'horde.error');
+                                        $notification->push(
+                                            sprintf(_("Error adding %d of %d requested contact(s) to list."),
+                                                $errorCount,
+                                                count($keys)),
+                                            'horde.error');
                                     }
                                     $target->store();
                                 }
@@ -388,7 +463,11 @@ class Turba_View_Browse {
                         $results = $list->listMembers($sortorder);
                         if (count($results) != count($list)) {
                             $count = count($list) - count($results);
-                            $notification->push(sprintf(ngettext("There is %d contact in this list that is not viewable to you", "There are %d contacts in this list that are not viewable to you", $count), $count), 'horde.message');
+                            $notification->push(
+                                sprintf(ngettext("There is %d contact in this list that is not viewable to you",
+                                                 "There are %d contacts in this list that are not viewable to you", $count),
+                                $count),
+                            'horde.message');
                         }
                         $view = new Turba_View_List($results, null, $columns);
                         $view->setType('list');
index 436a87a..67213e7 100644 (file)
@@ -5,22 +5,22 @@
  * @author  Chuck Hagenbuch <chuck@horde.org>
  * @package Turba
  */
-class Turba_View_Contact {
-
+class Turba_View_Contact
+{
     /**
      * @var Turba_Object
      */
-    var $contact;
+    public $contact;
 
     /**
      * @param Turba_Object &$contact
      */
-    public function __construct(&$contact)
+    public function __construct(Turba_Object $contact)
     {
-        $this->contact = &$contact;
+        $this->contact = $contact;
     }
 
-    function getTitle()
+    public function getTitle()
     {
         if (!$this->contact) {
             return _("Not Found");
@@ -28,7 +28,7 @@ class Turba_View_Contact {
         return $this->contact->getValue('name');
     }
 
-    function html($active = true)
+    public function html($active = true)
     {
         global $conf, $prefs, $registry;
 
@@ -44,9 +44,12 @@ class Turba_View_Contact {
         /* Get the contact's history. */
         $history = $this->contact->getHistory();
         foreach ($history as $what => $when) {
-            $v = &$form->addVariable(
+            $v = $form->addVariable(
                 $what == 'created' ? _("Created") : _("Last Modified"),
-                'object[__' . $what . ']', 'text', false, false);
+                'object[__' . $what . ']',
+                'text',
+                false,
+                false);
             $v->disable();
             $vars->set('object[__' . $what . ']', $when);
         }
index 6e2029f..b7f07dd 100644 (file)
@@ -1,23 +1,28 @@
 <?php
 /**
  * The Turba_View_DeleteContact:: class provides an API for viewing events.
+ * @TODO: Refactor to a Horde_View
  *
  * @author  Chuck Hagenbuch <chuck@horde.org>
  * @package Turba
  */
-class Turba_View_DeleteContact {
-
-    var $contact;
+class Turba_View_DeleteContact
+{
+    /**
+     * @var Turba_Object
+     *
+     */
+    public $contact;
 
     /**
-     * @param Turba_Object &$contact
+     * @param Turba_Object $contact
      */
-    public function __construct($contact)
+    public function __construct(Turba_Object $contact)
     {
         $this->contact = $contact;
     }
 
-    function getTitle()
+    public function getTitle()
     {
         if (!$this->contact) {
             return _("Not Found");
@@ -25,7 +30,7 @@ class Turba_View_DeleteContact {
         return sprintf(_("Delete %s"), $this->contact->getValue('name'));
     }
 
-    function html($active = true)
+    public function html($active = true)
     {
         global $conf, $prefs;
 
@@ -45,19 +50,19 @@ class Turba_View_DeleteContact {
         }
 
         echo '<div id="DeleteContact"' . ($active ? '' : ' style="display:none"') . '>';
-?>
-    <form action="<?php echo Horde::url('delete.php') ?>" method="post">
-<?php echo Horde_Util::formInput() ?>
-<input type="hidden" name="url" value="<?php echo htmlspecialchars(Horde_Util::getFormData('url')) ?>" />
-<input type="hidden" name="source" value="<?php echo htmlspecialchars($this->contact->driver->getName()) ?>" />
-<input type="hidden" name="key" value="<?php echo htmlspecialchars($this->contact->getValue('__key')) ?>" />
-<div class="headerbox" style="padding: 8px">
- <p><?php echo _("Permanently delete this contact?") ?></p>
- <input type="submit" class="button" name="delete" value="<?php echo _("Delete") ?>" />
-</div>
-</form>
-</div>
-<?php
+        ?>
+        <form action="<?php echo Horde::url('delete.php') ?>" method="post">
+        <?php echo Horde_Util::formInput() ?>
+        <input type="hidden" name="url" value="<?php echo htmlspecialchars(Horde_Util::getFormData('url')) ?>" />
+        <input type="hidden" name="source" value="<?php echo htmlspecialchars($this->contact->driver->getName()) ?>" />
+        <input type="hidden" name="key" value="<?php echo htmlspecialchars($this->contact->getValue('__key')) ?>" />
+        <div class="headerbox" style="padding: 8px">
        <p><?php echo _("Permanently delete this contact?") ?></p>
        <input type="submit" class="button" name="delete" value="<?php echo _("Delete") ?>" />
+        </div>
+        </form>
+        </div>
+        <?php
         if ($active && $GLOBALS['browser']->hasFeature('dom')) {
             if ($this->contact->hasPermission(Horde_Perms::READ)) {
                 $view = new Turba_View_Contact($this->contact);
index 622cdb2..9767096 100644 (file)
@@ -5,19 +5,23 @@
  * @author  Chuck Hagenbuch <chuck@horde.org>
  * @package Turba
  */
-class Turba_View_EditContact {
-
-    var $contact;
+class Turba_View_EditContact
+{
+    /**
+     *
+     * @var Turba_Object
+     */
+    public $contact;
 
     /**
      * @param Turba_Object $contact
      */
-    public function __construct($contact)
+    public function __construct(Turba_Object $contact)
     {
         $this->contact = $contact;
     }
 
-    function getTitle()
+    public function getTitle()
     {
         if (!$this->contact) {
             return _("Not Found");
@@ -25,7 +29,7 @@ class Turba_View_EditContact {
         return sprintf(_("Edit %s"), $this->contact->getValue('name'));
     }
 
-    function html($active = true)
+    public function html($active = true)
     {
         global $conf, $prefs, $vars;
 
@@ -45,7 +49,7 @@ class Turba_View_EditContact {
         }
 
         echo '<div id="EditContact"' . ($active ? '' : ' style="display:none"') . '>';
-        $form = &new Turba_Form_EditContact($vars, $this->contact);
+        $form = new Turba_Form_EditContact($vars, $this->contact);
         $form->renderActive(new Horde_Form_Renderer, $vars, Horde::url('edit.php'), 'post');
         echo '</div>';
 
index 5e141d7..02020eb 100644 (file)
@@ -14,84 +14,84 @@ class Turba_View_List implements Countable
      *
      * @var Turba_List
      */
-    var $list;
+    public $list;
 
     /**
      * Show/hide "mark" column in the display.
      *
      * @var boolean
      */
-    var $showMark = false;
+    public $showMark = false;
 
     /**
      * Show/hide "edit" column in the display.
      *
      * @var boolean
      */
-    var $showEdit = false;
+    public $showEdit = false;
 
     /**
      * Show/hide "vcard" column in the display.
      *
      * @var boolean
      */
-    var $showVcard = false;
+    public $showVcard = false;
 
     /**
      * Show/hide "group" column in the display.
      *
      * @var boolean
      */
-    var $showGroup = false;
+    public $showGroup = false;
 
     /**
      * Show/hide "sort" column in the display.
      *
      * @var boolean
      */
-    var $showSort = false;
+    public $showSort = false;
 
     /**
      * Type of list.
      *
      * @var string
      */
-    var $type;
+    public $type;
 
     /**
      * The HTML renderer.
      *
      * @var Horde_Core_Ui_VarRenderer_Html
      */
-    var $renderer;
+    public $renderer;
 
     /**
      * A Horde_Variables object.
      *
      * @var Horde_Variables
      */
-    var $vars;
+    public $vars;
 
     /**
      * A list of Horde_Form_Variable objects.
      *
      * @var array
      */
-    var $variables = array();
+    public $variables = array();
 
     /**
      * A dummy form object.
      *
      * @var Horde_Form
      */
-    var $form = null;
+    public $form = null;
 
     /**
      * Which columns to render
      *
      * @var array
      */
-    var $columns;
+    public $columns;
 
     /**
      * Constructs a new Turba_View_List object.
@@ -99,8 +99,10 @@ class Turba_View_List implements Countable
      * @param Turba_List $list  List of contacts to display.
      * @param array $controls   Which icons to display
      * @param array $columns    The list of columns to display
+     *
+     * @return Turba_View_List
      */
-    function Turba_View_List(&$list, $controls = null, $columns = null)
+    public function __construct($list, array $controls = null, array $columns = null)
     {
         if ($controls === null) {
             $controls = array('Mark' => true,
@@ -110,10 +112,8 @@ class Turba_View_List implements Countable
                               'Sort' => true);
         }
         $this->columns = $columns;
-
-        $this->list = &$list;
+        $this->list = $list;
         $this->setControls($controls);
-
         $this->renderer = Horde_Core_Ui_VarRenderer::factory('Html');
         $this->vars = new Horde_Variables();
     }
@@ -123,7 +123,7 @@ class Turba_View_List implements Countable
      *
      * @param array $controls
      */
-    function setControls($controls)
+    public function setControls(array $controls)
     {
         foreach ($controls as $control => $show) {
             $key = 'show' . $control;
@@ -131,51 +131,61 @@ class Turba_View_List implements Countable
         }
     }
 
-    function setType($type)
+    /**
+     *
+     * @param string $type
+     */
+    public function setType($type)
     {
         $this->type = $type;
     }
 
-    function getType()
+    /**
+     *
+     * @return string
+     */
+    public function getType()
     {
         return $this->type;
     }
 
-    function display()
+    /**
+     * @TODO: these should be injected when we refactor to Horde_View
+     * @global $prefs
+     * @global $session
+     * @global $default_source
+     * @global $copymove_source_options
+     */
+    public function display()
     {
         global $prefs, $session, $default_source, $copymove_source_options;
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($default_source);
-
+        $driver = $GLOBALS['injector']
+            ->getInstance('Turba_Injector_Factory_Driver')
+            ->create($default_source);
         $hasDelete = $driver->hasPermission(Horde_Perms::DELETE);
         $hasEdit = $driver->hasPermission(Horde_Perms::EDIT);
         $hasExport = ($GLOBALS['conf']['menu']['import_export'] && !empty($GLOBALS['cfgSources'][$default_source]['export']));
 
         list($addToList, $addToListSources) = $this->getAddSources();
-
         $viewurl = Horde::url('browse.php')->add(array(
             'key' => Horde_Util::getFormData('key'),
             'url' => Horde::selfUrl(true, false, true)
         ));
-
         if ($this->type == 'search') {
             $page = Horde_Util::getFormData('page', 0);
             $numitem = count($this);
             $maxpage = $prefs->getValue('maxpage');
             $perpage = $prefs->getValue('perpage');
-
             $min = $page * $perpage;
             while ($min > $numitem) {
                 $page--;
                 $min = $page * $perpage;
             }
-
             $max = $min + $perpage;
             $start = ($page * $perpage) + 1;
             $end = min($numitem, $start + $perpage - 1);
-
             $listHtml = $this->getPage($numDisplayed, $min, $max);
-
             $crit = array();
             if ($session->get('turba', 'search_mode') == 'advanced') {
                 $map = $driver->getCriteria();
@@ -194,14 +204,12 @@ class Turba_View_List implements Countable
                 'source' => Horde_Util::getFormData('source', $default_source)
             ));
             $viewurl = Horde::url('search.php')->add($params);
-
             $vars = Horde_Variables::getDefaultVariables();
             $pager = new Horde_Core_Ui_Pager('page', $vars,
                                         array('num' => $numitem,
                                               'url' => $viewurl,
                                               'page_limit' => $maxpage,
                                               'perpage' => $perpage));
-
             $pagerHeader = 'numPager.inc';
         } else {
             $page = Horde_Util::getFormData('page', '*');
@@ -214,7 +222,6 @@ class Turba_View_List implements Countable
                     $page = 'A';
                 }
             }
-
             $listHtml = $this->getAlpha($numDisplayed, $page);
             $pagerHeader = 'alphaPager.inc';
         }
@@ -236,9 +243,10 @@ class Turba_View_List implements Countable
      *                               rendered.
      * @param integer $min           Minimum number of rows to display.
      * @param integer $max           Maximum number of rows to display.
+     *
      * @return string  HTML to echo.
      */
-    function getPage(&$numDisplayed, $min = 0, $max = null)
+    public function getPage(&$numDisplayed, $min = 0, $max = null)
     {
         if (is_null($max)) {
             $max = count($this);
@@ -256,7 +264,7 @@ class Turba_View_List implements Countable
      *
      * @return string HTML of the list.
      */
-    function getAlpha(&$numDisplayed, $alpha)
+    public function getAlpha(&$numDisplayed, $alpha)
     {
         return $this->_get($numDisplayed,
                            new Turba_View_List_AlphaFilter($alpha));
@@ -266,9 +274,10 @@ class Turba_View_List implements Countable
      * Retrieves a column's name
      *
      * @param integer $i  The zero-basd index of the column
+     *
      * @return string
      */
-    function getColumnName($i)
+    public function getColumnName($i)
     {
         return Turba::getColumnName($i, $this->columns);
     }
@@ -276,7 +285,7 @@ class Turba_View_List implements Countable
     /**
      * @param integer $i  The zero-based index of the column
      */
-    function getSortInfoForColumn($i)
+    public function getSortInfoForColumn($i)
     {
         $sortorder = Turba::getPreferredSortOrder();
         $column_name = $this->getColumnName($i);
@@ -290,7 +299,14 @@ class Turba_View_List implements Countable
         return null;
     }
 
-    function getColumnSortImage($i, $title = null)
+    /**
+     *
+     * @param integer $i
+     * @param string $title
+     *
+     * @return string
+     */
+    public function getColumnSortImage($i, $title = null)
     {
         if (is_null($title)) {
             $title = _("Sort Direction");
@@ -305,9 +321,10 @@ class Turba_View_List implements Countable
 
     /**
      * Retrieves a natural language description of the sort order
+     *
      * @return string
      */
-    function getSortOrderDescription()
+    public function getSortOrderDescription()
     {
         $description = array();
         $sortorder = Turba::getPreferredSortOrder();
@@ -318,18 +335,20 @@ class Turba_View_List implements Countable
             }
             $description[] = $GLOBALS['attributes'][$field]['label'];
         }
+
         return join(', ', $description);
     }
 
     /**
      * @param integer $i  The zero-based index of the column
      */
-    function getColumnSortDirection($i)
+    public function getColumnSortDirection($i)
     {
         $result = $this->getSortInfoForColumn($i);
         if (is_null($result)) {
             return null;
         }
+
         return $result['ascending'] ? 0 : 1;
     }
 
@@ -337,28 +356,39 @@ class Turba_View_List implements Countable
      * Determines whether we are sorting on the specified column
      *
      * @param integer $i  The zero-based column index
+     *
      * @return boolean
      */
-    function isSortColumn($i)
+    public function isSortColumn($i)
     {
         return !is_null($this->getSortInfoForColumn($i));
     }
 
     /**
      * Determines whether this is the first column to sort by
+     *
      * @param integer $i  The zero-based column index
+     *
      * @return boolean
      */
-    function isPrimarySortColumn($i)
+    public function isPrimarySortColumn($i)
     {
         $result = $this->getSortInfoForColumn($i);
         if (is_null($result)) {
             return false;
         }
+
         return ($result['rank'] == 0);
     }
 
-    function _get(&$numDisplayed, $filter)
+    /**
+     *
+     * @param integer $numDisplayed
+     * @param object $filter         A Turba_View_List filter object
+     *
+     * @return string
+     */
+    protected function _get(&$numDisplayed, $filter)
     {
         ob_start();
         $width = floor(90 / (count($this->columns) + 1));
@@ -381,7 +411,7 @@ class Turba_View_List implements Countable
         return ob_get_clean();
     }
 
-    function getAddSources()
+    public function getAddSources()
     {
         global $addSources;
 
@@ -450,53 +480,4 @@ class Turba_View_List implements Countable
 
 }
 
-/**
- * Skips objects whose name does not start with the specified letter
- */
-class Turba_View_List_AlphaFilter {
-
-    var $_alpha;
-    var $_format;
-
-    function Turba_View_List_AlphaFilter($alpha)
-    {
-        $this->_alpha = Horde_String::lower($alpha);
-        $this->_format = $GLOBALS['prefs']->getValue('name_sort');
-    }
-
-    function skip(&$ob)
-    {
-        $name = Turba::formatName($ob, $this->_format);
-        if ($this->_alpha != '*' &&
-            Horde_String::lower(substr($name, 0, 1)) != $this->_alpha) {
-            return true;
-        }
-        return false;
-    }
-
-}
-
-/**
- * Skips objects which are not on the current page
- */
-class Turba_View_List_PageFilter {
-
-    var $_min;
-    var $_max;
-    var $_count = 0;
 
-    function Turba_View_List_PageFilter($min, $max)
-    {
-        $this->_min = $min;
-        $this->_max = $max;
-    }
-
-    function skip(&$ob)
-    {
-        if ($this->_count++ < $this->_min) {
-            return true;
-        }
-        return ($this->_count > $this->_max);
-    }
-
-}
diff --git a/turba/lib/View/List/AlphaFilter.php b/turba/lib/View/List/AlphaFilter.php
new file mode 100644 (file)
index 0000000..da02bd9
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * The Turba_View_List:: class provides an interface for objects that
+ * visualize Turba_List objects.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Jon Parise <jon@csh.rit.edu>
+ * @package Turba
+ */
+/**
+ * Skips objects whose name does not start with the specified letter
+ */
+class Turba_View_List_AlphaFilter
+{
+    protected $_alpha;
+    protected $_format;
+
+    public function __construct($alpha)
+    {
+        $this->_alpha = Horde_String::lower($alpha);
+        $this->_format = $GLOBALS['prefs']->getValue('name_sort');
+    }
+
+    public function skip($ob)
+    {
+        $name = Turba::formatName($ob, $this->_format);
+        if ($this->_alpha != '*' &&
+            Horde_String::lower(substr($name, 0, 1)) != $this->_alpha) {
+            return true;
+        }
+
+        return false;
+    }
+
+}
\ No newline at end of file
diff --git a/turba/lib/View/List/PageFilter.php b/turba/lib/View/List/PageFilter.php
new file mode 100644 (file)
index 0000000..9594395
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * The Turba_View_List:: class provides an interface for objects that
+ * visualize Turba_List objects.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Jon Parise <jon@csh.rit.edu>
+ * @package Turba
+ */
+ /**
+  * Skips objects which are not on the current page
+  */
+class Turba_View_List_PageFilter
+{
+    protected $_min;
+    protected $_max;
+    protected $_count = 0;
+
+    public function __construct($min, $max)
+    {
+        $this->_min = $min;
+        $this->_max = $max;
+    }
+
+    public function skip($ob)
+    {
+        if ($this->_count++ < $this->_min) {
+            return true;
+        }
+
+        return ($this->_count > $this->_max);
+    }
+
+}
\ No newline at end of file