wvrzel / simpleCalDAV

A simple php CalDAV-Client library. Connect, create, change, delete... easy to use
GNU General Public License v2.0
114 stars 58 forks source link

Sabre Delegation support #32

Open Trickscenique opened 7 years ago

Trickscenique commented 7 years ago

Hi,

Does the function FindCalendars( ) can reach the calendars shared with Sabre delegation ?

I use baikal, and i've done theses records like explain in the sabre's docs but i just see the calendars affected to the main user :

If you want to give user A access to user B's calendars, this means that principal/userA needs to be part of the principal/userB/calendar-proxy-write group.

To do this through the database, you need to look up the id for principal/userA and principal/userB/calendar-proxy-write. You add these id's to the groupmembers table.

The id for principal/userA will become the member_id field value, and the id for principal/userB/calendar-proxy-write should be put in the principal_id field. http://sabre.io/dav/caldav-proxy/

This is my code

$client = new SimpleCalDAVClient();

$client->connect('http://baikalserver.example/cal.php/calendars/userB/default', 'userA', 'userApassword');

$client->findCalendars();
Trickscenique commented 7 years ago

I resolve my problem by adding this function in SimpleCalDAVClient.php

function getCalendarDetailsByURL($url)
    {
        if(!isset($this->client)) throw new Exception('No connection. Try connect().');

        return $this->client->GetCalendarDetailsByURL($url);
    }

Then my code become :

$client = new SimpleCalDAVClient();

$client->connect('http://baikalserver.example/cal.php/calendars/userB/default', 'userA', 'userApassword');

$client->getCalendarDetailsByURL('http://baikalserver.example/cal.php/calendars/userB/default');

It can not list all the delegated calendars but it permit to access to one if you know the name :)