*
* @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');
*
* @param Horde_Core_Prefs_Ui $ui The UI object.
*/
- public function prefsGroup($ui)
+ public function prefsGroup(Horde_Core_Prefs_Ui $ui)
{
global $prefs;
*
* @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':
*
* @return boolean True if preference was updated.
*/
- public function prefsSpecialUpdate($ui, $item)
+ public function prefsSpecialUpdate(Horde_Core_Prefs_Ui $ui, $item)
{
global $prefs;
*/
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',
/**
* 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',
/**
* 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',
*
* @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,
return true;
}
- function importData($contents, $header = false)
+ public function importData($contents, $header = false)
{
$data = array();
$records = preg_split('/(\r?\n){2}/', $contents);
* @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));
*
* @return string The LDIF data.
*/
- function exportData($data, $header = false)
+ public function exportData($data, $header = false)
{
if (!is_array($data) || !count($data)) {
return '';
* 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:
/**
* 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;
*
* @return array Translated version of $hash.
*/
- public function toDriverKeys($hash)
+ public function toDriverKeys(array $hash)
{
/* Handle category. */
if (!empty($hash['category'])) {
* 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
*
* @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();
*
* @return array Translated version of $entry.
*/
- public function toTurbaKeys($entry)
+ public function toTurbaKeys(array $entry)
{
$new_entry = array();
foreach ($this->map as $key => $val) {
* @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. */
* 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.
*
* @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();
*
* @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);
* @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);
}
* @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'));
}
* @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(),
* @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'])) {
* @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);
*
* @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);
*
* @return array A contact hash.
*/
- public function fromASContact($message)
+ public function fromASContact(Horde_ActiveSync_Message_Contact $message)
{
$hash = array();
$formattedname = false;
/**
* 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);
}
/**
*
* @return string A unique ID for the new object.
*/
- protected function _makeKey($attributes)
+ protected function _makeKey(array $attributes)
{
return hash('md5', mt_rand());
}
* @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']));
* 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."));
}
* @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."));
}
*
* @throws Turba_Exception
*/
- protected function _add($attributes)
+ protected function _add(array $attributes)
{
throw new Turba_Exception(_("Adding contacts is not available."));
}
/**
* 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
*/
/**
* 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."));
}
/**
* 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'])) {
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;
/**
* 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 -
{
/**
* TODO
+ *
+ * @var Horde_Service_Facebook
*/
private $_facebook;
* 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);
* 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);
}
/**
* TODO
*/
- protected function _getEntry($keys, $fields)
+ protected function _getEntry(array $keys, array $fields)
{
$facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
$fields = implode(', ', $fields);
/**
* TODO
*/
- protected function _getAddressBook($fields = array())
+ protected function _getAddressBook(array $fields = array())
{
$facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
$fields = implode(', ', $fields);
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;
- }
-
}
*
* @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();
* 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();
*
* 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();
* 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();
/**
* 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."));
*
* @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'])) {
* 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 = '';
* @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') {
*
* @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) . '].');
/**
* Deletes the specified entry from the LDAP directory.
*
- * TODO
+ * @param string $object_key
+ * @param string $object_id
*
* @throws Turba_Exception
*/
/**
* 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
*/
*
* @return string The RDN for the new object.
*/
- protected function _makeRDN($attributes)
+ protected function _makeRDN(array $attributes)
{
if (!is_array($this->_params['dn'])) {
return '';
*
* @return string The DN for the new object.
*/
- protected function _makeKey($attributes)
+ protected function _makeKey(array $attributes)
{
return $this->_makeRDN($attributes) . ',' . $this->_params['root'];
}
*
* @return string An LDAP query fragment.
*/
- protected function _buildSearchQuery($criteria)
+ protected function _buildSearchQuery(array $criteria)
{
$clause = '';
* @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) {
/**
* Format and encode attributes including postal addresses,
* character set encoding, etc.
+ *
+ * @param array $attributes The attributes array.
*/
protected function _encodeAttributes(&$attributes)
{
* 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();
return $this->_syntaxCache[$att];
}
+
}
* 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());
}
* 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();
*
* @param array $attributes TODO
*/
- protected function _add($attributes)
+ protected function _add(array $attributes)
{
$book = $this->_getAddressBook();
$book[$attributes['id']] = $attributes;
/**
* 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)
{
/**
* Saves the specified object in the preferences.
*
- * @param $object TODO
+ * @param Turba_Object $object TODO
*/
function _save($object)
{
*
* @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
*
* @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'];
* 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);
}
* @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);
}
/**
* 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);
}
/**
* 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)
/**
* 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)
{
}
/**
- * 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)
{
<?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)
* 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
/**
* 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']);
* 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();
/**
* 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());
*
* @return string A unique ID for the new object.
*/
- protected function _makeKey($attributes)
+ protected function _makeKey(array $attributes)
{
return strval(new Horde_Support_Randomid());
}
* @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();
*
* @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);
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);
*
* @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
*
* @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);
}
/**
* 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"));
}
/**
* Not supported for virtual address books.
*
+ * @see Turba_Driver::_delete
* @throws Turba_Exception
*/
protected function _delete($object_key, $object_id)
}
/**
- * TODO
+ * @see Turba_Driver::_save
*/
- protected function _save($object)
+ protected function _save(Turba_Object $object)
{
return $this->_driver->save($object);
}
*/
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);
}
}
- function validate()
+ public function validate()
{
if (!$this->_vars->get('source')) {
return false;
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. */
*/
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;
/**
* 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
$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();
*/
class Turba_Form_CreateAddressBook extends Horde_Form
{
- public function __construct(&$vars)
+ public function __construct($vars)
{
parent::__construct($vars, _("Create Address Book"));
/**
* @throws Turba_Exception
*/
- function execute()
+ public function execute()
{
// Need a clean cfgSources array
include TURBA_BASE . '/config/backends.php';
/**
* 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);
*
* @throws Turba_Exception
*/
- function execute()
+ public function execute()
{
// If cancel was clicked, return false.
if ($this->_vars->get('submitbutton') == _("Cancel")) {
// 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) {
{
/**
* 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);
$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()));
}
}
*/
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);
$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. */
} 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'])) {
*/
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);
$this->appendButtons(_("Finish"));
}
- function renderActive($renderer, &$vars, $action, $method)
+ public function renderActive($renderer, $vars, $action, $method)
{
parent::renderActive($renderer, $vars, $action, $method);
echo '<br />' . $listView->getPage($numDisplayed);
}
- function execute()
+ public function execute()
{
$result = parent::execute();
/**
* Constructor.
*/
- public function __construct($ids = array())
+ public function __construct(array $ids = array())
{
foreach ($ids as $value) {
list($source, $key) = explode(':', $value);
*
* @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');
*
* @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
* @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.
* @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';
}
*
* @return array All properties of this object.
*/
- function getAttributes()
+ public function getAttributes()
{
return $this->attributes;
}
/**
* Returns the name of the address book that this object is from.
*/
- function getSource()
+ public function getSource()
{
return $this->driver->getName();
}
*
* @return string Fully qualified contact id.
*/
- function getGuid($delimiter = ':')
+ public function getGuid($delimiter = ':')
{
return 'turba' . $delimiter . $this->getSource() . $delimiter . $this->getValue('__uid');
}
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();
* @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'])) {
*
* @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])) {
*
* @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']
*
* @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)) {
* @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']
*
* @return boolean True if this object is a group of multiple contacts.
*/
- function isGroup()
+ public function isGroup()
{
return false;
}
*
* @return boolean Whether or not the current user can edit this object
*/
- function isEditable()
+ public function isEditable()
{
return $this->driver->hasPermission(Horde_Perms::EDIT);
}
*
* @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(),
* 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)) {
}
}
}
-
try {
$this->_vfs->write($dir, $file, $info['tmp_name'], true);
} catch (VFS_Exception $e) {
* @param string $file The file name.
* @throws Turba_Exception
*/
- function deleteFile($file)
+ public function deleteFile($file)
{
$this->_vfsInit();
try {
*
* @throws Turba_Exception
*/
- function deleteFiles()
+ public function deleteFiles()
{
$this->_vfsInit();
if ($this->_vfs->exists(TURBA_VFS_PATH, $this->getValue('__uid'))) {
*
* @return array A list of hashes with file informations.
*/
- function listFiles()
+ public function listFiles()
{
try {
$this->_vfsInit();
*
* @return string The HTML code of the generated link.
*/
- function vfsDisplayUrl($file)
+ public function vfsDisplayUrl($file)
{
global $registry, $mime_drivers_map, $mime_drivers;
*
* @return string The HTML code of the generated link.
*/
- function vfsEditUrl($file)
+ public function vfsEditUrl($file)
{
$delform = '<form action="' .
Horde::url('deletefile.php') .
*
* @throws Turba_Exception
*/
- function _vfsInit()
+ protected function _vfsInit()
{
if (!isset($this->_vfs)) {
try {
* @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.
*
* 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';
*
* @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(),
*
* @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)) {
* @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']);
*
* @return integer
*/
- function count()
+ public function count()
{
$children = @unserialize($this->attributes['__members']);
if (!is_array($children)) {
*
* @return Turba_List List containing the members of this group
*/
- function &listMembers($sort = null)
+ public function listMembers($sort = null)
{
$list = new Turba_List();
* @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;
*
* @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];
}
$addressbooks = $GLOBALS['cfgSources'];
}
- return Turba::permissionsFilter($addressbooks, $permission, $options);
+ return self::permissionsFilter($addressbooks, $permission, $options);
}
/**
*
* @return string The default address book name.
*/
- function getDefaultAddressBook()
+ static public function getDefaultAddressBook()
{
$lines = json_decode($GLOBALS['prefs']->getValue('addressbooks'));
if (!empty($lines)) {
/* 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);
}
/**
* Returns the sort order selected by the user
*/
- function getPreferredSortOrder()
+ static public function getPreferredSortOrder()
{
return @unserialize($GLOBALS['prefs']->getValue('sortorder'));
}
/**
* Retrieves a column's field name
*/
- function getColumnName($i, $columns)
+ static public function getColumnName($i, $columns)
{
return $i == 0 ? 'name' : $columns[$i - 1];
}
*
* @return string String containing the last name.
*/
- function guessLastname($name)
+ static public function guessLastname($name)
{
$name = trim(preg_replace('|\s|', ' ', $name));
if (!empty($name)) {
* 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;
} 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)) {
$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();
/**
* 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.
*
* @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();
* 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.
* 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';
*
* @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
/**
* 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 */
/* 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);
/* 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));
}
/**
* Add browse.js javascript to page.
*/
- public function addBrowseJs()
+ static public function addBrowseJs()
{
Horde::addScriptFile('browse.js', 'turba');
Horde::addInlineJsVars(array(
* @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);
$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')) {
}
}
- 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);
if (isset($driver)) {
$actionID = $vars->get('actionID');
-
- // Run through the action handlers.
switch ($actionID) {
case 'delete':
$keys = $vars->get('objectkeys');
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)) {
}
}
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 {
}
}
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;
$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;
// 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;
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;
}
// 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']);
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.
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,
}
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;
} 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;
}
}
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();
}
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;
}
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) {
}
}
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();
}
$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');
* @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");
return $this->contact->getValue('name');
}
- function html($active = true)
+ public function html($active = true)
{
global $conf, $prefs, $registry;
/* 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);
}
<?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");
return sprintf(_("Delete %s"), $this->contact->getValue('name'));
}
- function html($active = true)
+ public function html($active = true)
{
global $conf, $prefs;
}
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);
* @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");
return sprintf(_("Edit %s"), $this->contact->getValue('name'));
}
- function html($active = true)
+ public function html($active = true)
{
global $conf, $prefs, $vars;
}
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>';
*
* @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.
* @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,
'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();
}
*
* @param array $controls
*/
- function setControls($controls)
+ public function setControls(array $controls)
{
foreach ($controls as $control => $show) {
$key = 'show' . $control;
}
}
- 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();
'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', '*');
$page = 'A';
}
}
-
$listHtml = $this->getAlpha($numDisplayed, $page);
$pagerHeader = 'alphaPager.inc';
}
* 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);
*
* @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));
* 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);
}
/**
* @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);
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");
/**
* Retrieves a natural language description of the sort order
+ *
* @return string
*/
- function getSortOrderDescription()
+ public function getSortOrderDescription()
{
$description = array();
$sortorder = Turba::getPreferredSortOrder();
}
$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;
}
* 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));
return ob_get_clean();
}
- function getAddSources()
+ public function getAddSources()
{
global $addSources;
}
-/**
- * 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);
- }
-
-}
--- /dev/null
+<?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
--- /dev/null
+<?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