-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Horde Api calendars (timeobjects) to DAV in readonly mode #226
base: master
Are you sure you want to change the base?
Conversation
kronolith/lib/Application.php
Outdated
'principaluri' => 'principals/' . $user, | ||
'{http://sabredav.org/ns}owner-principal' => | ||
'principals/-system-', // TODO: Not sure who should really own these, system or the calling user | ||
'{DAV:}displayname' => sprintf("%s: %s", ucfirst($calendar->api()), $calendar->name()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be $registry->get('name', $calendar->api())
.
kronolith/lib/Application.php
Outdated
'{http://sabredav.org/ns}owner-principal' => | ||
'principals/-system-', // TODO: Not sure who should really own these, system or the calling user | ||
'{DAV:}displayname' => sprintf("%s: %s", ucfirst($calendar->api()), $calendar->name()), | ||
'{' . CalDAV\Plugin::NS_CALDAV . '}calendar-description' => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually leave this off until there is a better value to get than the duplication of the calendar name.
kronolith/lib/Application.php
Outdated
$calendar->caldavUrl(), | ||
'principaluri' => 'principals/' . $user, | ||
'{http://sabredav.org/ns}owner-principal' => | ||
'principals/-system-', // TODO: Not sure who should really own these, system or the calling user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to own this to the user. In fact we have both, global and per-user resourced provided through the timeobjects API. But it makes more sense IMO to have different per-user calendars with the same data, than single global calendars with individual data.
kronolith/lib/Application.php
Outdated
@@ -945,6 +945,35 @@ public function davGetCollections($user) | |||
'{http://sabredav.org/ns}read-only' => !$share->hasPermission($hordeUser, Horde_Perms::EDIT), | |||
); | |||
} | |||
// External Calendars from other Horde Apps | |||
foreach ($calendar_manager->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $calendarId => $calendar) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indention
kronolith/lib/Application.php
Outdated
'principaluri' => 'principals/' . $user, | ||
'{http://sabredav.org/ns}owner-principal' => | ||
'principals/-system-', // TODO: Not sure who should really own these, system or the calling user | ||
'{DAV:}displayname' => sprintf("%s: %s", ucfirst($calendar->api()), $calendar->name()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes please; spacing.
kronolith/lib/Application.php
Outdated
$exploded = explode(':', $internal, 2); | ||
$driverType = null; | ||
if ($exploded[0] == "external") { | ||
$driverType = "Horde"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes please.
kronolith/lib/Application.php
Outdated
$driverType = null; | ||
if ($exploded[0] == "external") { | ||
$driverType = "Horde"; | ||
$internalName = str_replace(':', '/', $exploded[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using a different separator in Kronolith_Calendar_External in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the original separator "/", caldav misbehaves as it uses the calendar id string in several occassions for creating URLs. Calendars won't be accessible without creating additional caldav directory hierarchies.
kronolith/lib/Application.php
Outdated
if ($share) { | ||
$ical->setAttribute('X-WR-CALNAME', $share->get('name')); | ||
} else { | ||
// TODO: Get Calendar object and run ->name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be implemented.
kronolith/lib/Calendar/External.php
Outdated
@@ -96,6 +96,24 @@ public function api() | |||
{ | |||
return $this->_api; | |||
} | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vertical spacing
*/ | ||
public function internalId() | ||
{ | ||
return sprintf("external:%s:%s", $this->_api, str_replace('/', ':', $this->_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above about the different separator.
kronolith/lib/Application.php
Outdated
'{DAV:}displayname' => sprintf("%s: %s", ucfirst($calendar->api()), $calendar->name()), | ||
'{' . CalDAV\Plugin::NS_CALDAV . '}calendar-description' => | ||
$calendar->name(), // TODO: Implement an interface for description and fallback to name if none given | ||
'', // TODO: Implement an interface for description and fallback to empty if none given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave that property out completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
kronolith/lib/Application.php
Outdated
$internalName = str_replace(':', '/', $exploded[1]); | ||
} elseif (!Kronolith::hasPermission($internal, Horde_Perms::SHOW)) { | ||
throw new Kronolith_Exception(_("Calendar does not exist or no permission to edit")); | ||
throw new Kronolith_Exception(_('Calendar does not exist or no permission to edit')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gettext strings OTOH must have double quotes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I was not aware.
CODING_STANDARDS shows the double quote example in section 23 internatl. , but does not instruct to use double quotes. In 27 quotes it says Should be used in the gettext shortcut _("") format.
The patch is fine now, many thanks! |
On 16.08.2017 11:42, Jan Schneider wrote:
It doesn't work as expected yet, though. One of my address books
returning anniversaries results in a 500 error from Sabre, stating "The
objectData argument must contain an 'uri' property". Other paths return
a 404 right away.
I will check on this - I tested with whups and one other not yet
released application as data provider.
I will add some aniversaries and try to reproduce.
…--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: [email protected]
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
|
On 16.08.2017 11:43, Ralf Lang wrote:
On 16.08.2017 11:42, Jan Schneider wrote:
> It doesn't work as expected yet, though. One of my address books
> returning anniversaries results in a 500 error from Sabre, stating
> "The objectData argument must contain an 'uri' property". Other paths
> return a 404 right away.
I will check on this - I tested with whups and one other not yet
released application as data provider.
I will add some aniversaries and try to reproduce.
Now the previously working stuff is broken too. Seems like one of the
refactoring steps changed something.
This call winds down to calling calendarobject->get() with missing
properties. I am checking why...
#3
Sabre\DAV\Server->getPropertiesForPath(calendars/lang/calendar~external:tickets:created,
Array ([0] => {DAV:}displayname,[1] => {DAV:}resourcetype,[2] =>
{DAV:}getcontenttype,[3] => {DAV:}getcontentlength,[4] =>
{DAV:}getlastmodified), 1) called at
[/usr/share/php5/PEAR/Sabre/DAV/Browser/Plugin.php:252]
…--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: [email protected]
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
|
…n exception. Fixes whups items in horde 5.2 TODO: prevent eternal recursion for birthdays in turba, probably due to recurrences TODO: Test again against master
I have implemented providing a crafted UID.
This works both against our production horde (whups, turba) and against
a master 6.0.0 checkout from yesterday.
If it still crashes for you, can you provide an example event?
Regards
Ralf
|
I still see a few issues:
We also need to think about the UIDs once again. First of all, the timeobject APIs should probably export any existing UIDs. On the other hand, this would lead to the same UIDs for two different kind of objects (contact + event). This is probably a bad idea. |
Both fixed.
_contacts (_api) is a prefix added to the item id to prevent any clashes with existing IDs. horde/kronolith/lib/Event/Horde.php Line 105 in 8aba6f7
It gets removed for toTimeObject. --
|
I don't agree. If Kronolith is converting this object from one format to a different (incompatible) format, it basically creates a new object, and thus shouldn't reuse the original UiD. Unless we agree it's perfectly fine to have a contact (or any other object FWIW) and an event with the same UID. |
Am 28.08.2017 um 10:19 schrieb Jan Schneider:
It is either the exporting application's responsibility to make sure
the timeobjects, cost objects etc do not have the same uid as the
original application object (like a contact or ticket) or it needs
to be handled by the infrastructure. Either way it should not be the
receiver's (kronolith's) task. For example, the uid could be
***@***.***
I don't agree. If Kronolith is converting this object from one format to
a different (incompatible) format, it basically creates a new object,
and thus shouldn't reuse the original UiD. Unless we agree it's
perfectly fine to have a contact (or any other object FWIW) and an event
with the same UID.
I agree with the first part - We currently do not reuse uids but craft
them inside kronolith.
The second part does not feel right to me, but I can do as you think.
You're the expert in caldav and kronolith. Currently I see no app
exporting timeobjects including UIDs. If an app exports timeobjects (or other api hashes like cost objects, clients) WITH UIDs, it should know if the uid must be same or different from the original item.
Should I simply ignore the exported uid (if any) in favor of the
kronolith-provided one or amend it to make it different?
…--
Ralf Lang
Linux Consultant / Developer
|
Expose Horde Api calendars (timeobjects) to DAV in readonly mode
Omit tasks as they already have their own backend.
External calendars are attributed to the viewing user's principal.
External calendar IDs are transformed as they may contain slash / which is interpreted as directory separator and breaks stuff.
Tested this patch against a production horde 5.2 but there is no real difference with current master.