Turba::getAddressBooks PHP Method

getAddressBooks() public static method

Get all the address books the user has the requested permissions to and return them in the user's preferred order.
public static getAddressBooks ( integer $permission = Horde_Perms::READ, array $options = [] ) : array
$permission integer The Horde_Perms::* constant to filter on.
$options array Any additional options.
return array The filtered, ordered $cfgSources entries.
    public static function getAddressBooks($permission = Horde_Perms::READ, array $options = array())
    {
        return self::permissionsFilter($GLOBALS['cfgSources'], $permission, $options);
    }

Usage Example

Example #1
0
 /**
  */
 protected function _initPages()
 {
     global $injector;
     $this->view->list = array();
     if ($GLOBALS['browse_source_count']) {
         foreach (Turba::getAddressBooks() as $key => $val) {
             if (!empty($val['browse'])) {
                 try {
                     $driver = $injector->getInstance('Turba_Factory_Driver')->create($key);
                 } catch (Turba_Exception $e) {
                     continue;
                 }
                 try {
                     $contacts = $driver->search(array(), null, 'AND', array('__key', 'name'));
                     $contacts->reset();
                 } catch (Turba_Exception $e) {
                     continue;
                 }
                 $url = new Horde_Core_Smartmobile_Url();
                 $url->add('source', $key);
                 $url->setAnchor('entry');
                 $tmp = array();
                 while ($contact = $contacts->next()) {
                     $name = Turba::formatName($contact);
                     $tmp[] = array('group' => $contact->isGroup(), 'name' => strlen($name) ? $name : '[' . _("No Name") . ']', 'url' => strval($url->add('key', $contact->getValue('__key'))));
                 }
                 $this->view->list[$val['title']] = $tmp;
             }
         }
     }
 }
All Usage Examples Of Turba::getAddressBooks