Exemplo n.º 1
0
 /**
  * Return the owner to use when searching or creating contacts in
  * this address book.
  *
  * @return string  TODO
  * @throws Turba_Exception
  */
 protected function _getContactOwner()
 {
     $params = @unserialize($this->_share->get('params'));
     if (!empty($params['name'])) {
         return $params['name'];
     }
     throw new Turba_Exception(_("Unable to find contact owner."));
 }
Exemplo n.º 2
0
 /**
  * @param Whups_Query $query The query to delete.
  */
 public function delete(Whups_Query $query)
 {
     if (!$query->id) {
         // Queries that aren't saved yet shouldn't be able to be deleted.
         return;
     }
     try {
         $share = $this->_shareManager->getShareById($query->id);
         $this->_shareManager->removeShare($share);
     } catch (Exception $e) {
         throw new Whups_Exception($e);
     }
     $GLOBALS['whups_driver']->deleteQuery($query->id);
 }
Exemplo n.º 3
0
 /**
  * Synchronize Horde_Shares to existing IMSP address books.
  *
  * @param Horde_Share $share_obj  The Horde_Share object to use.
  * @param array $serverInfo       Information about the IMSP server and
  *                                the current user.
  *
  * @return mixed  Array describing any shares added or removed  | PEAR_Error.
  */
 public function synchShares($share_obj, array $serverInfo)
 {
     $found_shares = array();
     $return = array('added' => array(), 'removed' => array());
     $params = array();
     $imsp = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imsp')->create('Book', $serverInfo['params']);
     $abooks = $imsp->getAddressBookList();
     // Do we have a default address book? If not, create one.
     if (array_search($serverInfo['params']['username'], $abooks) === false) {
         $imsp->createAddressbook($serverInfo['params']['username']);
         // Make sure we add it to our list of books.
         $abooks[] = $serverInfo['params']['username'];
     }
     $shares = $share_obj->listShares($GLOBALS['registry']->getAuth());
     // A share for each IMSP adress book we can see.
     foreach ($abooks as $abook_uid) {
         $found = false;
         foreach ($shares as $share) {
             $params = @unserialize($share->get('params'));
             if (!empty($params['name']) && $params['name'] == $abook_uid && $params['source'] == 'imsp') {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $shareparams = array('name' => $abook_uid, 'source' => 'imsp');
             $params['uid'] = hash('md5', mt_rand());
             $params['name'] = $abook_uid . ' (IMSP)';
             $params['acl'] = $imsp->myRights($abook_uid);
             if ($abook_uid == $serverInfo['params']['username']) {
                 // This is the default address book
                 $shareparams['default'] = true;
             } else {
                 $shareparams['default'] = false;
             }
             if (self::_isOwner($abook_uid, $serverInfo['params']['username'], $params['acl'])) {
                 $params['owner'] = $GLOBALS['registry']->getAuth();
             } else {
                 // TODO: What to do for the owner when it's not current user?
                 //       We'd have to try to match the owner per IMSP
                 //       address book name to a Horde user...how to do that
                 //       without assuming usernames are equal?
             }
             self::_createShare($share_obj, $params, $shareparams);
             $return['added'][] = $params['uid'];
         } else {
             // Share already exists, just update the acl.
             $params['acl'] = $imsp->myRights($abook_uid);
         }
         $found_shares[] = $abook_uid;
     }
     // Now prune any shares that no longer exist on the IMSP server.
     $existing = $share_obj->listShares($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::READ));
     foreach ($existing as $share) {
         $temp = unserialize($share->get('params'));
         if (is_array($temp)) {
             $sourceType = $temp['source'];
             if ($sourceType == 'imsp' && array_search($temp['name'], $found_shares) === false) {
                 $share_obj->removeShare($share);
                 $return['removed'][] = $share->getName();
             }
         }
     }
     return $return;
 }
Exemplo n.º 4
0
 /**
  * Returns a list of ALL galleries, regardless of permissions.
  *
  * @return array
  */
 public function listAllGalleries()
 {
     return $this->buildGalleries($this->_shares->listAllShares());
 }
Exemplo n.º 5
0
 /**
  * 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.
  */
 public static function getSourceFromShare(Horde_Share $share)
 {
     // Require a fresh config file.
     $cfgSources = self::availableSources();
     $params = @unserialize($share->get('params'));
     $newConfig = $cfgSources[$params['source']];
     $newConfig['params']['config'] = $cfgSources[$params['source']];
     $newConfig['params']['config']['params']['share'] = $share;
     $newConfig['params']['config']['params']['name'] = $params['name'];
     $newConfig['title'] = $share->get('name');
     $newConfig['type'] = 'share';
     $newConfig['use_shares'] = false;
     return $newConfig;
 }
Exemplo n.º 6
0
 /**
  * Deletes a share.
  *
  * @param Horde_Share $calendar  The share to delete.
  *
  * @throws Kronolith_Exception
  */
 public static function deleteShare($calendar)
 {
     if (!$GLOBALS['registry']->getAuth() || $calendar->get('owner') != $GLOBALS['registry']->getAuth() && (!is_null($calendar->get('owner')) || !$GLOBALS['registry']->isAdmin())) {
         throw new Kronolith_Exception(_("You are not allowed to delete this calendar."));
     }
     // Delete the calendar.
     try {
         self::getDriver()->delete($calendar->getName());
     } catch (Exception $e) {
         throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $calendar->get('name'), $e->getMessage()));
     }
     // Remove share and all groups/permissions.
     try {
         $GLOBALS['injector']->getInstance('Kronolith_Shares')->removeShare($calendar);
     } catch (Horde_Share_Exception $e) {
         throw new Kronolith_Exception($e);
     }
 }
Exemplo n.º 7
0
 * Copyright 2002-2004 Chuck Hagenbuch <*****@*****.**>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */
$fieldsList['show'] = 0;
$fieldsList['read'] = 1;
$fieldsList['edit'] = 2;
$fieldsList['delete'] = 3;
@define('HORDE_BASE', dirname(__FILE__) . '/../..');
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Menu.php';
require_once HORDE_LIBS . 'Horde/Share.php';
require_once HORDE_LIBS . 'Horde/Group.php';
$app = Util::getFormData('app');
$shares =& Horde_Share::singleton($app);
$groups =& Group::singleton();
$auth =& Auth::singleton($conf['auth']['driver']);
$form = null;
$reload = false;
$actionID = Util::getFormData('actionID', 'edit');
switch ($actionID) {
    case 'edit':
        $share =& $shares->getShareById(Util::getFormData('cid'));
        if (!is_a($share, 'PEAR_Error')) {
            $form = 'edit.inc';
            $perm =& $share->getPermission();
        } elseif (($category = Util::getFormData('share')) !== null) {
            $share =& $shares->getShare($category);
            if (!is_a($share, 'PEAR_Error')) {
                $form = 'edit.inc';