/** * * @param array $vars * @param Horde_Share_Object $tasklist */ public function __construct($vars, Horde_Share_Object $tasklist) { $this->_tasklist = $tasklist; parent::__construct($vars, sprintf(_("Delete %s"), $tasklist->get('name'))); $this->addHidden('', 't', 'text', true); $this->addVariable(sprintf(_("Really delete the task list \"%s\"? This cannot be undone and all data on this task list will be permanently removed."), htmlspecialchars($this->_tasklist->get('name'))), 'desc', 'description', false); $this->setButtons(array(array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
/** * Builds a query object from a share object. * * @param Horde_Share_Object $share A share object representing a query. * * @return Whups_Query The query object built from the share. */ protected function _getQuery(Horde_Share_Object $share) { $queryDetails = $GLOBALS['whups_driver']->getQuery($share->getId()); $queryDetails['query_id'] = $share->getId(); $queryDetails['query_name'] = $share->get('name'); $queryDetails['query_slug'] = $share->get('slug'); return new Whups_Query($this, $queryDetails); }
/** * Implemented to stand in as a share object. * * @param string $property The property to get * * @return mixed The value of $property */ public function get($property) { $property = str_replace('resource_', '', $property); if ($property == 'type' && empty($this->_params['type'])) { return $this instanceof Kronolith_Resource_Single ? 'Single' : 'Group'; } $value = $this->_share->get($property); return $property == 'members' ? unserialize($value) : $value; }
/** * Returns a hash representing this calendar. * * @return array A simple hash. */ public function toHash() { global $calendar_manager, $conf, $injector, $registry; $owner = $registry->getAuth() && $this->_share->get('owner') == $registry->getAuth(); $hash = parent::toHash(); $hash['name'] = Kronolith::getLabel($this->_share); $hash['desc'] = (string) $this->_share->get('desc'); $hash['owner'] = $owner; $hash['users'] = Kronolith::listShareUsers($this->_share); $hash['fg'] = Kronolith::foregroundColor($this->_share); $hash['bg'] = Kronolith::backgroundColor($this->_share); $hash['show'] = in_array('tasks/' . $this->_share->getName(), $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)); $hash['edit'] = $this->_share->hasPermission($registry->getAuth(), Horde_Perms::EDIT); $hash['caldav'] = $this->caldavUrl(); $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/nag/' : '/rpc.php/nag/'), true, -1) . ($this->_share->get('owner') ? $registry->convertUsername($this->_share->get('owner'), false) : '-system-') . '/' . $this->_share->getName() . '.ics'; if ($owner) { $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission(), is_null($this->_share->get('owner'))); } return $hash; }
public function execute() { switch ($this->_vars->submitbutton) { case _("Save"): $this->_addressbook->set('name', $this->_vars->get('name')); $this->_addressbook->set('desc', $this->_vars->get('description')); try { $this->_addressbook->save(); } catch (Horde_Share_Exception $e) { throw new Turba_Exception(sprintf(_("Unable to save address book \"%s\": %s"), $this->_vars->get('name'), $e->getMessage())); } break; case _("Delete"): Horde::url('addressbooks/delete.php')->add('a', $this->_vars->a)->redirect(); break; case _("Cancel"): Horde::url('', true)->redirect(); break; } }
/** * Returns a json representation of this gallery. * * @param boolean $full Return all information (subgalleries and images)? * * @return StdClass An object describing the gallery * <pre> * 'id' - gallery id * 'p' - gallery's parent's id (null if top level) * 'pn' - gallery's parent's name (null if top level) * 'n' - gallery name * 'dc' - date created * 'dm' - date modified * 'd' - description * 'ki' - key image * 'sg' - an object with the following properties: * 'n' - gallery name * 'dc' - date created * 'dm' - date modified * 'd' - description * 'ki' - key image * * 'imgs' - an array of image objects with the following properties: * 'id' - the image id * 'url' - the image url * </pre> */ public function toJson($full = false) { // @TODO: Support date grouped galleries $vMode = $this->get('view_mode'); if ($vMode != 'Normal') { $this->_setModeHelper('Normal'); } $style = Ansel::getStyleDefinition('ansel_mobile'); $json = new StdClass(); $json->id = $this->id; $json->n = $this->get('name'); $json->dc = $this->get('date_created'); $json->dm = $this->get('last_modified'); $json->d = $this->get('desc'); $json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'thumb', false, $style)->toString(true); $json->imgs = array(); // Parent $parents = $this->getParents(); if (empty($parents)) { $json->p = null; $json->pn = null; } else { $p = array_pop($parents); $json->p = $p->id; $json->pn = $p->get('name'); } if ($full) { $json->tiny = $GLOBALS['conf']['image']['tiny'] && ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ)); $json->sg = array(); if ($this->hasSubGalleries()) { $sgs = $this->getChildren($GLOBALS['registry']->getAuth(), Horde_Perms::READ, false); //GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('parent' => $this->id, 'all_levels' => false)); foreach ($sgs as $g) { $json->sg[] = $g->toJson(); } } $images = $this->getImages(); foreach ($images as $img) { $i = new StdClass(); $i->id = $img->id; $i->url = Ansel::getImageUrl($img->id, 'thumb', false, $style)->toString(true); $i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString(true); $i->fn = $img->filename; $json->imgs[] = $i; } } if ($vMode != 'Normal') { $this->_setModeHelper($vMode); } return $json; }
/** * * @param array $vars * @param Horde_Share_Object $tasklist */ public function __construct($vars, Horde_Share_Object $tasklist) { $this->_tasklist = $tasklist; $owner = $tasklist->get('owner') == $GLOBALS['registry']->getAuth() || is_null($tasklist->get('owner')) && $GLOBALS['registry']->isAdmin(); parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $tasklist->get('name')) : $tasklist->get('name')); $this->addHidden('', 't', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); if (!$owner) { $v = $this->addVariable(_("Owner"), 'owner', 'text', false); $owner_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($tasklist->get('owner'))->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = $tasklist->get('owner'); } $v->setDefault($owner_name ? $owner_name : _("System")); } $this->addVariable(_("Color"), 'color', 'colorpicker', false); if ($GLOBALS['registry']->isAdmin()) { $this->addVariable(_("System Task List"), 'system', 'boolean', false, false, _("System task lists don't have an owner. Only administrators can change the task list settings and permissions.")); } $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); /* Display URL. */ $url = Horde::url('list.php', true, -1)->add('display_tasklist', $tasklist->getName()); $this->addVariable(_("Display URL"), '', 'link', false, false, null, array(array('url' => $url, 'text' => $url, 'title' => _("Click or copy this URL to display this task list"), 'target' => '_blank'))); /* Subscription URLs. */ try { $accountUrl = Nag::getUrl(Nag::DAV_ACCOUNT, $tasklist); $caldavUrl = Nag::getUrl(Nag::DAV_CALDAV, $tasklist); $this->addVariable(_("CalDAV Subscription URL"), '', 'link', false, false, null, array(array('url' => $caldavUrl, 'text' => $caldavUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to this task list"), 'target' => '_blank'))); $this->addVariable(_("CalDAV Account URL"), '', 'link', false, false, null, array(array('url' => $accountUrl, 'text' => $accountUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to all your task lists"), 'target' => '_blank'))); } catch (Horde_Exception $e) { } $webdavUrl = Nag::getUrl(Nag::DAV_WEBDAV, $tasklist); $this->addVariable(_("WebDAV/ICS Subscription URL"), '', 'link', false, false, null, array(array('url' => $webdavUrl, 'text' => $webdavUrl, 'title' => _("Copy this URL to a WebDAV or ICS client to subscribe to this task list"), 'target' => '_blank'))); /* Permissions link. */ if (empty($GLOBALS['conf']['share']['no_sharing']) && $owner) { $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php')->add(array('app' => 'nag', 'share' => $tasklist->getName())); $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank'))); } $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
/** * Returns a hash representing this calendar. * * @return array A simple hash. */ public function toHash() { global $calendar_manager, $conf, $injector, $registry; $id = $this->_share->getName(); $owner = $registry->getAuth() && ($this->owner() == $registry->getAuth() || $this->isSystem() && $registry->isAdmin()); $hash = parent::toHash(); $hash['name'] = $this->name(); $hash['owner'] = $owner; $hash['system'] = $this->isSystem(); $hash['users'] = Kronolith::listShareUsers($this->_share); $hash['show'] = in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)); $hash['edit'] = $this->hasPermission(Horde_Perms::EDIT); $hash['caldav'] = $this->caldavUrl(); $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1) . ($this->owner() ? $registry->convertUsername($this->owner(), false) : '-system-') . '/' . $id . '.ics'; $hash['feed'] = (string) Kronolith::feedUrl($id); $hash['embed'] = Kronolith::embedCode($id); $hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR)); if ($owner) { $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission()); } return $hash; }
/** * Returns a hash representing this calendar. * * @return array A simple hash. */ public function toHash() { global $calendar_manager, $conf, $injector, $registry; $id = $this->_share->getName(); $owner = $registry->getAuth() && $this->owner() == $registry->getAuth(); $hash = parent::toHash(); $hash['name'] = $this->name(); $hash['owner'] = $owner; $hash['users'] = Kronolith::listShareUsers($this->_share); $hash['show'] = in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)); $hash['edit'] = $this->hasPermission(Horde_Perms::EDIT); try { $hash['caldav'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/calendars/' : '/rpc.php/calendars/'), true, -1) . $registry->getAuth() . '/' . $injector->getInstance('Horde_Dav_Storage')->getExternalCollectionId($id, 'calendar') . '/'; } catch (Horde_Exception $e) { } $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1) . ($this->owner() ? $this->owner() : '-system-') . '/' . $id . '.ics'; $hash['feed'] = (string) Kronolith::feedUrl($id); $hash['embed'] = Kronolith::embedCode($id); $hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR)); if ($owner) { $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission()); } return $hash; }
/** * Retrieve a new source config entry based on a Turba share. * * @param Horde_Share_Object object The share to base config on. * * @return array The $cfgSource entry for this share source. */ public static function getSourceFromShare(Horde_Share_Object $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; }
/** * Check if the passed in share is the default share for this source. * * @param Horde_Share_Object $share The share object. * @param array $srcconfig The cfgSource entry for the share. * * @return boolean TODO */ public function checkDefaultShare(Horde_Share_Object $share, array $srcconfig) { $params = @unserialize($share->get('params')); return isset($params['default']) ? $params['default'] : false; }
/** * Renames a share in the shares system. * * @param Horde_Share_Object $share The share to rename. * @param string $name The share's new name. * * @throws Horde_Share_Exception */ protected function _renameShare(Horde_Share_Object $share, $name) { $share->set('share_name', $name); }
/** * Reads a submitted permissions form and updates the share permissions. * * @param Horde_Share_Object|Kronolith_Resource_Base $share The share to update. * * @return array A list of error messages. * @throws Kronolith_Exception */ public static function readPermsForm($share) { $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); $perm = $share->getPermission(); $errors = array(); if ($GLOBALS['conf']['share']['notify']) { $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create(); $mail = new Horde_Mime_Mail(array('From' => $identity->getDefaultFromAddress(true), 'User-Agent' => 'Kronolith ' . $GLOBALS['registry']->getVersion())); $image = self::getImagePart('big_share.png'); $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/share')); new Horde_View_Helper_Text($view); $view->identity = $identity; $view->calendar = $share->get('name'); $view->imageId = $image->getContentId(); } // Process owner and owner permissions. if (!$share instanceof Kronolith_Resource_Base) { $old_owner = $share->get('owner'); $new_owner_backend = Horde_Util::getFormData('owner_select', Horde_Util::getFormData('owner_input', $old_owner)); $new_owner = $GLOBALS['registry']->convertUsername($new_owner_backend, true); // Only set new owner if this isn't a system calendar, and the // owner actually changed and the new owner is set at all. if (!is_null($old_owner) && $old_owner !== $new_owner && !empty($new_owner)) { if ($old_owner != $GLOBALS['registry']->getAuth() && !$GLOBALS['registry']->isAdmin()) { $errors[] = _("Only the owner or system administrator may change ownership or owner permissions for a share"); } elseif ($auth->hasCapability('list') && !$auth->exists($new_owner_backend)) { $errors[] = sprintf(_("The user \"%s\" does not exist."), $new_owner_backend); } else { $share->set('owner', $new_owner); $share->save(); if ($GLOBALS['conf']['share']['notify']) { $view->ownerChange = true; $multipart = self::buildMimeMessage($view, 'notification', $image); $to = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($new_owner)->getDefaultFromAddress(true); $mail->addHeader('Subject', _("Ownership assignment")); $mail->addHeader('To', $to); $mail->setBasePart($multipart); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); $view->ownerChange = false; } } } } if ($GLOBALS['conf']['share']['notify']) { if ($GLOBALS['conf']['share']['hidden']) { $view->subscribe = Horde::url('calendars/subscribe.php', true)->add('calendar', $share->getName()); } $multipart = self::buildMimeMessage($view, 'notification', $image); } if ($GLOBALS['registry']->isAdmin() || !empty($GLOBALS['conf']['share']['world'])) { // Process default permissions. if (Horde_Util::getFormData('default_show')) { $perm->addDefaultPermission(Horde_Perms::SHOW, false); } else { $perm->removeDefaultPermission(Horde_Perms::SHOW, false); } if (Horde_Util::getFormData('default_read')) { $perm->addDefaultPermission(Horde_Perms::READ, false); } else { $perm->removeDefaultPermission(Horde_Perms::READ, false); } if (Horde_Util::getFormData('default_edit')) { $perm->addDefaultPermission(Horde_Perms::EDIT, false); } else { $perm->removeDefaultPermission(Horde_Perms::EDIT, false); } if (Horde_Util::getFormData('default_delete')) { $perm->addDefaultPermission(Horde_Perms::DELETE, false); } else { $perm->removeDefaultPermission(Horde_Perms::DELETE, false); } if (Horde_Util::getFormData('default_delegate')) { $perm->addDefaultPermission(self::PERMS_DELEGATE, false); } else { $perm->removeDefaultPermission(self::PERMS_DELEGATE, false); } // Process guest permissions. if (Horde_Util::getFormData('guest_show')) { $perm->addGuestPermission(Horde_Perms::SHOW, false); } else { $perm->removeGuestPermission(Horde_Perms::SHOW, false); } if (Horde_Util::getFormData('guest_read')) { $perm->addGuestPermission(Horde_Perms::READ, false); } else { $perm->removeGuestPermission(Horde_Perms::READ, false); } if (Horde_Util::getFormData('guest_edit')) { $perm->addGuestPermission(Horde_Perms::EDIT, false); } else { $perm->removeGuestPermission(Horde_Perms::EDIT, false); } if (Horde_Util::getFormData('guest_delete')) { $perm->addGuestPermission(Horde_Perms::DELETE, false); } else { $perm->removeGuestPermission(Horde_Perms::DELETE, false); } if (Horde_Util::getFormData('guest_delegate')) { $perm->addGuestPermission(self::PERMS_DELEGATE, false); } else { $perm->removeGuestPermission(self::PERMS_DELEGATE, false); } } // Process creator permissions. if (Horde_Util::getFormData('creator_show')) { $perm->addCreatorPermission(Horde_Perms::SHOW, false); } else { $perm->removeCreatorPermission(Horde_Perms::SHOW, false); } if (Horde_Util::getFormData('creator_read')) { $perm->addCreatorPermission(Horde_Perms::READ, false); } else { $perm->removeCreatorPermission(Horde_Perms::READ, false); } if (Horde_Util::getFormData('creator_edit')) { $perm->addCreatorPermission(Horde_Perms::EDIT, false); } else { $perm->removeCreatorPermission(Horde_Perms::EDIT, false); } if (Horde_Util::getFormData('creator_delete')) { $perm->addCreatorPermission(Horde_Perms::DELETE, false); } else { $perm->removeCreatorPermission(Horde_Perms::DELETE, false); } if (Horde_Util::getFormData('creator_delegate')) { $perm->addCreatorPermission(self::PERMS_DELEGATE, false); } else { $perm->removeCreatorPermission(self::PERMS_DELEGATE, false); } // Process user permissions. $u_names = Horde_Util::getFormData('u_names'); $u_show = Horde_Util::getFormData('u_show'); $u_read = Horde_Util::getFormData('u_read'); $u_edit = Horde_Util::getFormData('u_edit'); $u_delete = Horde_Util::getFormData('u_delete'); $u_delegate = Horde_Util::getFormData('u_delegate'); $current = $perm->getUserPermissions(); if ($GLOBALS['conf']['share']['notify']) { $mail->addHeader('Subject', _("Access permissions")); } $perm->removeUserPermission(null, null, false); foreach ($u_names as $key => $user_backend) { // Apply backend hooks $user = $GLOBALS['registry']->convertUsername($user_backend, true); // If the user is empty, or we've already set permissions // via the owner_ options, don't do anything here. if (empty($user) || $user == $new_owner) { continue; } if ($auth->hasCapability('list') && !$auth->exists($user_backend)) { $errors[] = sprintf(_("The user \"%s\" does not exist."), $user_backend); continue; } $has_perms = false; if (!empty($u_show[$key])) { $perm->addUserPermission($user, Horde_Perms::SHOW, false); $has_perms = true; } if (!empty($u_read[$key])) { $perm->addUserPermission($user, Horde_Perms::READ, false); $has_perms = true; } if (!empty($u_edit[$key])) { $perm->addUserPermission($user, Horde_Perms::EDIT, false); $has_perms = true; } if (!empty($u_delete[$key])) { $perm->addUserPermission($user, Horde_Perms::DELETE, false); $has_perms = true; } if (!empty($u_delegate[$key])) { $perm->addUserPermission($user, self::PERMS_DELEGATE, false); $has_perms = true; } // Notify users that have been added. if ($GLOBALS['conf']['share']['notify'] && !isset($current[$user]) && $has_perms) { $to = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($user)->getDefaultFromAddress(true); $mail->addHeader('To', $to); $mail->setBasePart($multipart); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } // Process group permissions. $g_names = Horde_Util::getFormData('g_names'); $g_show = Horde_Util::getFormData('g_show'); $g_read = Horde_Util::getFormData('g_read'); $g_edit = Horde_Util::getFormData('g_edit'); $g_delete = Horde_Util::getFormData('g_delete'); $g_delegate = Horde_Util::getFormData('g_delegate'); $current = $perm->getGroupPermissions(); $perm->removeGroupPermission(null, null, false); foreach ($g_names as $key => $group) { if (empty($group)) { continue; } $has_perms = false; if (!empty($g_show[$key])) { $perm->addGroupPermission($group, Horde_Perms::SHOW, false); $has_perms = true; } if (!empty($g_read[$key])) { $perm->addGroupPermission($group, Horde_Perms::READ, false); $has_perms = true; } if (!empty($g_edit[$key])) { $perm->addGroupPermission($group, Horde_Perms::EDIT, false); $has_perms = true; } if (!empty($g_delete[$key])) { $perm->addGroupPermission($group, Horde_Perms::DELETE, false); $has_perms = true; } if (!empty($g_delegate[$key])) { $perm->addGroupPermission($group, self::PERMS_DELEGATE, false); $has_perms = true; } // Notify users that have been added. if ($GLOBALS['conf']['share']['notify'] && !isset($current[$group]) && $has_perms) { $groupOb = $GLOBALS['injector']->getInstance('Horde_Group')->getData($group); if (!empty($groupOb['email'])) { $mail->addHeader('To', $groupOb['name'] . ' <' . $groupOb['email'] . '>'); $mail->setBasePart($multipart); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } } try { $share->setPermission($perm); } catch (Horde_Share_Exception $e) { throw new Kronolith_Exception($e); } return $errors; }
/** * Removes a share from the shares system permanently. * * @param Horde_Share_Object $share The share to remove. * * @throws Horde_Share_Exception */ public function removeShare(Horde_Share_Object $share) { // Run the results through the callback, if configured. $this->runCallback('remove', array($share)); /* Remove share from the caches. */ $id = $share->getId(); unset($this->_shareMap[$id]); unset($this->_cache[$share->getName()]); /* Reset caches that depend on unknown criteria. */ $this->expireListCache(); $this->_removeShare($share); }
/** * Deletes a task list. * * @param Horde_Share_Object $tasklist The task list to delete. * * @throws Nag_Exception * @throws Horde_Exception_PermissionDenied */ public static function deleteTasklist(Horde_Share_Object $tasklist) { if (!$GLOBALS['registry']->getAuth() || $tasklist->get('owner') != $GLOBALS['registry']->getAuth() && (!is_null($tasklist->get('owner')) || !$GLOBALS['registry']->isAdmin())) { throw new Horde_Exception_PermissionDenied(_("You are not allowed to delete this task list.")); } // Delete the task list. $storage =& $GLOBALS['injector']->getInstance('Nag_Factory_Driver')->create($tasklist->getName()); $result = $storage->deleteAll(); // Remove share and all groups/permissions. try { $GLOBALS['nag_shares']->removeShare($tasklist); } catch (Horde_Share_Exception $e) { throw new Nag_Exception($e); } }
/** * Renames a share in the shares system. * * @param Horde_Share_Object $share The share to rename. * @param string $name The share's new name. * * @throws Horde_Share_Exception */ protected function _renameShare(Horde_Share_Object $share, $name) { try { $this->_db->update('UPDATE ' . $this->_table . ' SET share_name = ? WHERE share_id = ?', array($name, $share->getId())); } catch (Horde_Db_Exception $e) { throw new Horde_Share_Exception($e); } }
/** * Check if the passed in share is the default share for this source. * * @param Horde_Share_Object $share The share object. * @param array $srcconfig The cfgSource entry for the share. * * @return boolean TODO */ public function checkDefaultShare(Horde_Share_Object $share, array $srcconfig) { $params = @unserialize($share->get('params')); if (!isset($params['default'])) { $params['default'] = $params['name'] == $GLOBALS['registry']->getAuth(); $share->set('params', serialize($params)); $share->save(); } return $params['default']; }
/** * Translates IMSP acl into share permissions and sets them in share. * * @param Horde_Share_Object $share The share to assign perms to * @param string $acl The IMSP acl string. */ protected static function _setPerms(&$share, $acl) { $hPerms = 0; if (strpos($acl, 'w') !== false) { $hPerms |= Horde_Perms::EDIT; } if (strpos($acl, 'r') !== false) { $hPerms |= Horde_Perms::READ; } if (strpos($acl, 'd') !== false) { $hPerms |= Horde_Perms::DELETE; } if (strpos($acl, 'l') !== false) { $hPerms |= Horde_Perms::SHOW; } $share->addUserPermission($GLOBALS['registry']->getAuth(), $hPerms); }
/** * Add any modifiers required to the share in order to mark it as default. * * @param Horde_Share_Object $share The new default share. */ protected function _prepareDefaultShare($share) { $share->set('default', true); }