Author: Chuck Hagenbuch (chuck@horde.org)
Author: Jon Parise (jon@csh.rit.edu)
Inheritance: implements Countable
Beispiel #1
0
 /**
  * Constructor
  *
  * @param string $name
  * @param array $params
  */
 public function __construct($name = '', array $params = array())
 {
     parent::__construct($name, $params);
     $this->_facebook = $params['storage'];
     unset($params['storage']);
     $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
 }
Beispiel #2
0
 /**
  * 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 = '', array $params = array())
 {
     if (empty($params['db'])) {
         throw new InvalidArgumentException('Missing required Horde_Db_Adapter object');
     }
     $this->_db = $params['db'];
     unset($params['db']);
     parent::__construct($name, $params);
 }
Beispiel #3
0
 /**
  * Retrieves an SQL driver instance.
  *
  * @return object Initialized Turba_Driver_sql:: instance connected to the
  *                test database.
  */
 function getDriver()
 {
     if (is_null($this->_driver)) {
         $this->_driver = Turba_Driver::factory('_test_sql', $this->getDriverConfig());
         $this->assertOk($this->_driver);
         $this->assertOk($this->_driver->_init());
     }
     return $this->_driver;
 }
Beispiel #4
0
 /**
  *
  * @see Turba_Driver::__construct
  * @throws Turba_Exception
  */
 public function __construct($name = '', array $params = array())
 {
     parent::__construct($name, $params);
     /* Grab a reference to the share for this vbook. */
     $this->_share = $this->_params['share'];
     /* Load the underlying driver. */
     $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['source']);
     $this->searchCriteria = empty($this->_params['criteria']) ? array() : $this->_params['criteria'];
     $this->searchType = count($this->searchCriteria) > 1 ? 'advanced' : 'basic';
 }
Beispiel #5
0
 /**
  * Constructs a new Turba imsp driver object.
  *
  * @param array $params  Hash containing additional configuration
  *                       parameters.
  */
 public function __construct($name = '', $params)
 {
     parent::__construct($name, $params);
     $this->params = $params;
     $this->_groupField = $params['group_id_field'];
     $this->_groupValue = $params['group_id_value'];
     $this->_myRights = $params['my_rights'];
     $this->_perms = $this->_aclToHordePerms($params['my_rights']);
     $this->_bookName = $this->getContactOwner();
     try {
         $this->_imsp = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imsp')->create('Book', $this->params);
     } catch (Horde_Exception $e) {
         $this->_authenticated = false;
         throw new Turba_Exception($e);
     }
     $this->_authenticated = true;
 }
Beispiel #6
0
 /**
  * Renders this view.
  */
 public function display()
 {
     $view = new Horde_View(array('templatePath' => TURBA_TEMPLATES . '/search/duplicate'));
     new Horde_View_Helper_Text($view);
     $hasDuplicate = $this->_type && $this->_duplicate && isset($this->_duplicates[$this->_type]) && isset($this->_duplicates[$this->_type][$this->_duplicate]);
     if ($hasDuplicate) {
         $vars = new Horde_Variables();
         $view->type = $GLOBALS['attributes'][$this->_type]['label'];
         $view->value = $this->_duplicate;
         echo $view->render('header');
         $view->contactUrl = Horde::url('contact.php');
         $view->mergeUrl = Horde::url('merge.php');
         $view->first = true;
         $duplicate = $this->_duplicates[$this->_type][$this->_duplicate];
         while ($contact = $duplicate->next()) {
             $contact->lastModification();
         }
         $duplicate->sort(array(array('field' => '__modified', 'ascending' => false)));
         $view->mergeTarget = $duplicate->reset()->getValue('__key');
         while ($contact = $duplicate->next()) {
             $view->source = $contact->getSource();
             $view->id = $contact->getValue('__key');
             $history = $contact->getHistory();
             if (isset($history['modified'])) {
                 $view->changed = $history['modified'];
             } elseif (isset($history['created'])) {
                 $view->changed = $history['created'];
             } else {
                 unset($view->changed);
             }
             echo $view->render('contact_header');
             $contactView = new Turba_Form_Contact($vars, $contact, false);
             $contactView->renderInactive($contactView->getRenderer(), $vars);
             echo $view->render('contact_footer');
             $view->first = false;
         }
         echo $view->render('footer');
     }
     $view->duplicates = $this->_duplicates;
     $view->hasDuplicate = (bool) $hasDuplicate;
     $view->attributes = $GLOBALS['attributes'];
     $view->link = Horde::url('search.php')->add(array('source' => $this->_driver->getName(), 'search_mode' => 'duplicate'));
     echo $view->render('list');
 }
Beispiel #7
0
 protected function toHash($vcard, $map = array())
 {
     $driver = new Turba_Driver();
     foreach ($map as $field => $config) {
         $driver->map[$field] = $config;
     }
     $ical = new Horde_Icalendar();
     $ical->parsevCalendar($vcard);
     return $driver->toHash($ical->getComponent(0));
 }
Beispiel #8
0
 /**
  * Saves the current state of the object to the storage backend.
  *
  * @throws Turba_Exception
  */
 public function store()
 {
     $this->_ensureEmail();
     return $this->setValue('__key', $this->driver->save($this));
 }
Beispiel #9
0
 /**
  * Extends parent function to build composed fields needed for the dn
  * based on the contents of $this->map.
  *
  * @param array $hash  Hash using Turba keys.
  *
  * @return array  Translated version of $hash.
  */
 public function toDriverKeys(array $hash)
 {
     // First check for combined fields in the dn-fields and add them.
     if (is_array($this->_params['dn'])) {
         foreach ($this->_params['dn'] as $param) {
             foreach ($this->map as $turbaname => $ldapname) {
                 if (is_array($ldapname) && isset($ldapname['attribute']) && $ldapname['attribute'] == $param) {
                     $fieldarray = array();
                     foreach ($ldapname['fields'] as $mapfield) {
                         $fieldarray[] = isset($hash[$mapfield]) ? $hash[$mapfield] : '';
                     }
                     $hash[$turbaname] = Turba::formatCompositeField($ldapname['format'], $fieldarray);
                 }
             }
         }
     }
     // Now convert the turba-fieldnames to ldap-fieldnames
     return parent::toDriverKeys($hash);
 }
Beispiel #10
0
 /**
  * Check to see if the currently logged in user has requested permissions.
  *
  * @param integer $perm  The permissions to check against.
  *
  * @return boolean  True or False.
  */
 public function hasPermission($perm)
 {
     return $this->_driver->hasPermission($perm);
 }
Beispiel #11
0
 /**
  * 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.
  *
  * @return mixed  The requested extended permissions value, or true if it
  *                doesn't exist.
  */
 public static function getExtendedPermission(Turba_Driver $addressBook, $permission)
 {
     // We want to check the base source as extended permissions
     // are enforced per backend, not per share.
     $key = $addressBook->getName() . ':' . $permission;
     $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
     if (!$perms->exists('turba:sources:' . $key)) {
         return true;
     }
     $allowed = $perms->getPermissions('turba:sources:' . $key, $GLOBALS['registry']->getAuth());
     if (is_array($allowed)) {
         switch ($permission) {
             case 'max_contacts':
                 $allowed = max($allowed);
                 break;
         }
     }
     return $allowed;
 }
Beispiel #12
0
 function Turba_Driver_pogi($params)
 {
     parent::Turba_Driver($params);
 }
Beispiel #13
0
 /**
  * Translates a hash from being keyed on driver-specific fields to being
  * keyed on the generalized Turba attributes. The translation is based on
  * the contents of $this->map.
  *
  * @param array $entry  A hash using driver-specific keys.
  *
  * @return array  Translated version of $entry.
  */
 public function toTurbaKeys(array $entry)
 {
     if (isset($entry['__type']) && $entry['__type'] == 'Group' && isset($entry['display-name'])) {
         $entry['last-name'] = $entry['display-name'];
     }
     return parent::toTurbaKeys($entry);
 }
Beispiel #14
0
 /**
  * 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(Turba_Object $object)
 {
     return $this->_driver->_save($object);
 }
Beispiel #15
0
 /**
  * Saves the current state of the object to the storage backend.
  *
  * @throws Turba_Exception
  */
 public function store()
 {
     return $this->setValue('__key', $this->driver->save($this));
 }