Overview

Packages

  • Horde
    • Data
  • None
  • Turba

Classes

  • Turba
  • Turba_Api
  • Turba_Driver
  • Turba_Driver_Facebook
  • Turba_Driver_Favourites
  • Turba_Driver_Group
  • Turba_Driver_Imsp
  • Turba_Driver_Kolab
  • Turba_Driver_Ldap
  • Turba_Driver_Prefs
  • Turba_Driver_Share
  • Turba_Driver_Sql
  • Turba_Driver_Vbook
  • Turba_Exception
  • Turba_Factory_Driver
  • Turba_Form_AddContact
  • Turba_Form_Contact
  • Turba_Form_ContactBase
  • Turba_Form_CreateAddressBook
  • Turba_Form_DeleteAddressBook
  • Turba_Form_EditAddressBook
  • Turba_Form_EditContact
  • Turba_Form_EditContactGroup
  • Turba_List
  • Turba_LoginTasks_SystemTask_Upgrade
  • Turba_Object
  • Turba_Object_Group
  • Turba_Test
  • Turba_View_Browse
  • Turba_View_Contact
  • Turba_View_DeleteContact
  • Turba_View_Duplicates
  • Turba_View_EditContact
  • Turba_View_List
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Turba directory driver implementation for virtual address books.
  4:  *
  5:  * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file LICENSE for license information (ASL).  If you
  8:  * did not receive this file, see http://www.horde.org/licenses/apache.
  9:  *
 10:  * @author   Michael J. Rubinsky <mrubinsk@horde.org>
 11:  * @category Horde
 12:  * @license  http://www.horde.org/licenses/apache ASL
 13:  * @package  Turba
 14:  */
 15: class Turba_Driver_Vbook extends Turba_Driver
 16: {
 17:     /**
 18:      * Search type for this virtual address book.
 19:      *
 20:      * @var string
 21:      */
 22:     public $searchType;
 23: 
 24:     /**
 25:      * The search criteria that defines this virtual address book.
 26:      *
 27:      * @var array
 28:      */
 29:     public $searchCriteria;
 30: 
 31:     /**
 32:      *
 33:      * @see Turba_Driver::__construct
 34:      * @throws Turba_Exception
 35:      */
 36:     public function __construct($name = '', array $params = array())
 37:     {
 38:         parent::__construct($name, $params);
 39: 
 40:         /* Grab a reference to the share for this vbook. */
 41:         $this->_share = $this->_params['share'];
 42: 
 43:         /* Load the underlying driver. */
 44:         $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['source']);
 45: 
 46:         $this->searchCriteria = empty($this->_params['criteria'])
 47:             ? array()
 48:             : $this->_params['criteria'];
 49:         $this->searchType = (count($this->searchCriteria) > 1)
 50:             ? 'advanced'
 51:             : 'basic';
 52:     }
 53: 
 54:     /**
 55:      * Return the owner to use when searching or creating contacts in
 56:      * this address book.
 57:      *
 58:      * @return string
 59:      */
 60:     protected function _getContactOwner()
 61:     {
 62:         return $this->_driver->getContactOwner();
 63:     }
 64: 
 65:     /**
 66:      * Return all entries matching the combined searches represented by
 67:      * $criteria and the vitural address book's search criteria.
 68:      *
 69:      * @param array $criteria  Array containing the search criteria.
 70:      * @param array $fields    List of fields to return
 71:      * @param array $blobFileds  Array of fields that contain
 72:      *
 73:      * @return array  Hash containing the search results.
 74:      * @throws Turba_Exception
 75:      */
 76:     protected function _search(array $criteria, array $fields, array $blobFields = array(), $count_only = false)
 77:     {
 78:         /* Add the passed in search criteria to the vbook criteria
 79:          * (which need to be mapped from turba fields to
 80:          * driver-specific fields). */
 81:         $criteria['AND'][] = $this->makeSearch($this->searchCriteria, 'AND', array());
 82:         $results = $this->_driver->_search($criteria, $fields, $blobFields);
 83: 
 84:         return $count_only ? count($results) : $results;
 85:     }
 86: 
 87:     /**
 88:      * Reads the requested entries from the underlying source.
 89:      *
 90:      * @param string $key        The primary key field to use.
 91:      * @param mixed $ids         The ids of the contacts to load.
 92:      * @param string $owner      Only return contacts owned by this user.
 93:      * @param array $fields      List of fields to return.
 94:      * @param array $blobFields  Array of fields containing binary data.
 95:      *
 96:      * @return array  Hash containing the search results.
 97:      * @throws Turba_Exception
 98:      */
 99:     protected function _read($key, $ids, $owner, array $fields,
100:                              array $blobFields = array())
101:     {
102:         return $this->_driver->_read($key, $ids, $owner, $fields, $blobFields);
103:     }
104: 
105:     /**
106:      * Adds the specified contact to the addressbook.
107:      *
108:      * @param array $attributes  The attribute values of the contact.
109:      * @param array $blob_fields TODO
110:      *
111:      * @throws Turba_Exception
112:      */
113:     protected function _add(array $attributes, array $blob_fields = array())
114:     {
115:         throw new Turba_Exception(_("You cannot add new contacts to a virtual address book"));
116:     }
117: 
118:     /**
119:      * Not supported for virtual address books.
120:      *
121:      * @see Turba_Driver::_delete
122:      * @throws Turba_Exception
123:      */
124:     protected function _delete($object_key, $object_id)
125:     {
126:         throw new Turba_Exception(_("You cannot delete contacts from a virtual address book"));
127:     }
128: 
129:     /**
130:      * @see Turba_Driver::_save
131:      */
132:     protected function _save(Turba_Object $object)
133:     {
134:         return $this->_driver->save($object);
135:     }
136: 
137:     /**
138:      * Check to see if the currently logged in user has requested permissions.
139:      *
140:      * @param integer $perm  The permissions to check against.
141:      *
142:      * @return boolean  True or False.
143:      */
144:     public function hasPermission($perm)
145:     {
146:         return $this->_driver->hasPermission($perm);
147:     }
148: 
149: }
150: 
API documentation generated by ApiGen