Skip to content

Commit

Permalink
Fix displayed URLs for shared collections (Bug #12380).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jul 31, 2014
1 parent 2a2998f commit 6530311
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 20 deletions.
44 changes: 35 additions & 9 deletions kronolith/lib/Calendar/External/Tasks.php
Expand Up @@ -42,8 +42,10 @@ public function __construct($params = array())
*/
public function toHash()
{
$owner = $GLOBALS['registry']->getAuth() &&
$this->_share->get('owner') == $GLOBALS['registry']->getAuth();
global $calendar_manager, $conf, $injector, $registry;

$owner = $registry->getAuth() &&
$this->_share->get('owner') == $registry->getAuth();

$hash = parent::toHash();
$hash['name'] = Kronolith::getLabel($this->_share);
Expand All @@ -52,17 +54,41 @@ public function toHash()
$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(), $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS));
$hash['edit'] = $this->_share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
$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
);
try {
$hash['caldav'] = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . ($GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? '/rpc/calendars/' : '/rpc.php/calendars/'), true, -1)
. ($this->_share->get('owner') ? $this->_share->get('owner') : '-system-') . '/'
. $GLOBALS['injector']->getInstance('Horde_Dav_Storage')->getExternalCollectionId($this->_share->getName(), 'tasks')
$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($this->_share->getName(), 'tasks')
. '/';
} catch (Horde_Exception $e) {
}
$hash['sub'] = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . ($GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? '/rpc/nag/' : '/rpc.php/nag/'), true, -1)
. ($this->_share->get('owner') ? $this->_share->get('owner') : '-system-') . '/'
$hash['sub'] = Horde::url(
$registry->get('webroot', 'horde')
. ($conf['urls']['pretty'] == 'rewrite'
? '/rpc/nag/'
: '/rpc.php/nag/'),
true,
-1
)
. ($this->_share->get('owner')
? $this->_share->get('owner')
: '-system-')
. '/'
. $this->_share->getName() . '.ics';
if ($owner) {
$hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission());
Expand Down
34 changes: 27 additions & 7 deletions kronolith/lib/Calendar/Internal.php
Expand Up @@ -128,24 +128,44 @@ public function share()
*/
public function toHash()
{
global $calendar_manager, $conf, $injector, $registry;

$id = $this->_share->getName();
$owner = $GLOBALS['registry']->getAuth() &&
$this->owner() == $GLOBALS['registry']->getAuth();
$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, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS));
$hash['show'] = in_array(
$id,
$calendar_manager->get(Kronolith::DISPLAY_CALENDARS)
);
$hash['edit'] = $this->hasPermission(Horde_Perms::EDIT);
try {
$hash['caldav'] = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . ($GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? '/rpc/calendars/' : '/rpc.php/calendars/'), true, -1)
. ($this->owner() ? $this->owner() : '-system-') . '/'
. $GLOBALS['injector']->getInstance('Horde_Dav_Storage')->getExternalCollectionId($id, 'calendar')
$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($GLOBALS['registry']->get('webroot', 'horde') . ($GLOBALS['conf']['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1)
$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);
Expand Down
4 changes: 1 addition & 3 deletions nag/lib/Nag.php
Expand Up @@ -731,9 +731,7 @@ public static function getUrl($type, $tasklist)
$url .= '/rpc.php/calendars/';
}
$url = Horde::url($url, true, -1)
. ($tasklist->get('owner')
? $tasklist->get('owner')
: '-system-')
. $registry->getAuth()
. '/'
. $injector->getInstance('Horde_Dav_Storage')
->getExternalCollectionId($tasklist->getName(), 'tasks')
Expand Down
2 changes: 1 addition & 1 deletion turba/lib/Form/EditAddressBook.php
Expand Up @@ -73,7 +73,7 @@ public function __construct($vars, Horde_Share_Object $addressbook)
. 'principals/'. $GLOBALS['registry']->getAuth() . '/';
if ($addressbook->get('owner')) {
$carddavUrl = Horde::url($carddavUrl, true, -1)
. $addressbook->get('owner')
. $GLOBALS['registry']->getAuth()
. '/'
. $GLOBALS['injector']->getInstance('Horde_Dav_Storage')->getExternalCollectionId($addressbook->getName(), 'contacts')
. '/';
Expand Down

0 comments on commit 6530311

Please sign in to comment.