Fix publish-url property & getPublishStatus() fct
This commit is contained in:
parent
981c38f6d9
commit
1652a74feb
|
@ -1501,13 +1501,16 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
*/
|
||||
public function getPublishStatus($calendar) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$result = $query->select(['principaluri', 'access'])
|
||||
$result = $query->select('count(id)')
|
||||
->from('dav_shares')
|
||||
->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
|
||||
->andWhere($query->expr()->eq('type', $query->createNamedParameter(self::CLASSIFICATION_PUBLIC)))
|
||||
->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
|
||||
->execute();
|
||||
|
||||
return count($result->fetch()) > 0;
|
||||
$row = $result->fetch();
|
||||
$result->closeCursor();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,19 +72,18 @@ class PublishPlugin extends ServerPlugin
|
|||
public function propFind(PropFind $propFind, INode $node)
|
||||
{
|
||||
if ($node instanceof Calendar) {
|
||||
$token = md5(\OC::$server->getConfig()->getSystemValue('secret', '').$node->getName());
|
||||
$token = md5(\OC::$server->getConfig()->getSystemValue('secret', '').$node->getName());
|
||||
$publishUrl = $this->server->getBaseUri() . 'public-calendars/' . $token;
|
||||
|
||||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $token) {
|
||||
if ($node->getPublishStatus()) {
|
||||
return new Publisher($token, $node->getPublishStatus());
|
||||
}
|
||||
});
|
||||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) {
|
||||
if ($node->getPublishStatus()) {
|
||||
return new Publisher($publishUrl, $node->getPublishStatus());
|
||||
}
|
||||
});
|
||||
|
||||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $token) {
|
||||
if ($node->getPublishStatus()) {
|
||||
return new Publisher($token, false);
|
||||
}
|
||||
});
|
||||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $publishUrl) {
|
||||
return new Publisher($publishUrl, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ class Publisher implements XmlSerializable {
|
|||
|
||||
$cs = '{' . Plugin::NS_CALENDARSERVER . '}';
|
||||
if (!$this->isPublished) {
|
||||
$writer->write($this->publishUrl);
|
||||
$writer->write($this->publishUrl); // for pre-publish-url
|
||||
} else {
|
||||
$writer->writeElement('{DAV:}href', $this->publishUrl);
|
||||
$writer->writeElement('{DAV:}href', $this->publishUrl); // for publish-url
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue