|
|
|
@ -59,7 +59,7 @@ class PublishPlugin extends ServerPlugin |
|
|
|
|
*/ |
|
|
|
|
public function getFeatures() |
|
|
|
|
{ |
|
|
|
|
return ['oc-calendar-publishing']; |
|
|
|
|
return ['oc-calendar-publishing']; // May have to be changed to be detected |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -91,6 +91,7 @@ class PublishPlugin extends ServerPlugin |
|
|
|
|
|
|
|
|
|
$this->server->on('method:POST', [$this, 'httpPost']); |
|
|
|
|
$this->server->on('propFind', [$this, 'propFind']); |
|
|
|
|
$this->server->on('method:GET', [$this, 'httpGet'], 90); // 90 because it needs to be called before auth |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function propFind(PropFind $propFind, INode $node) |
|
|
|
@ -102,12 +103,12 @@ class PublishPlugin extends ServerPlugin |
|
|
|
|
|
|
|
|
|
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) { |
|
|
|
|
if ($node->getPublishStatus()) { |
|
|
|
|
return new Publisher($publishUrl, true); |
|
|
|
|
return new Publisher($publishUrl, true); // We return the publish-url only if the calendar is published. |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $publishUrl) { |
|
|
|
|
return new Publisher($publishUrl, false); |
|
|
|
|
return new Publisher($publishUrl, false); // The pre-publish-url is always returned |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -209,4 +210,31 @@ class PublishPlugin extends ServerPlugin |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* We intercept the GET requests to provide our shared calendars. |
|
|
|
|
* |
|
|
|
|
* @param Sabre\HTTP\RequestInterface $request |
|
|
|
|
* @param Sabre\HTTP\ResponseInterface $response |
|
|
|
|
*/ |
|
|
|
|
public function httpGet(RequestInterface $request, ResponseInterface $response) |
|
|
|
|
{ |
|
|
|
|
$path = $request->getPath(); |
|
|
|
|
|
|
|
|
|
// TODO : Find a better way to do this |
|
|
|
|
list($path, $token) = explode('/', $path); |
|
|
|
|
if ($path !== 'public-calendars') { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// This is where the magic happens |
|
|
|
|
// Find a place to put the functions getResourceIdFromToken($token) and getRessource($id) |
|
|
|
|
|
|
|
|
|
$this->server->transactionType = 'access-published-calendar'; |
|
|
|
|
|
|
|
|
|
$response->setStatus(200); |
|
|
|
|
$response->setBody('Success !'); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|