correct get published status and minor fixes
This commit is contained in:
parent
aca305332a
commit
2df69ec7f4
|
@ -1569,37 +1569,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$row = $result->fetch();
|
$row = $result->fetch();
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
|
|
||||||
return $row;
|
return $row[0] > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $token
|
|
||||||
* @param string secret
|
|
||||||
* @return int | boolean
|
|
||||||
*
|
|
||||||
* Function to get the ressource we're insteressed in. Most probably to put somewhere else.
|
|
||||||
*/
|
|
||||||
public function getResourceIdFromToken($token, $secret) {
|
|
||||||
$query = $this->db->getQueryBuilder();
|
|
||||||
$result = $query->select('resourceid')
|
|
||||||
->from('dav_shares')
|
|
||||||
->where($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$publications = [];
|
|
||||||
while($row = $result->fetch()) {
|
|
||||||
$publications[] = $row['resourceid'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$found = false;
|
|
||||||
while ($i < count($publications) && !$found) {
|
|
||||||
$found = md5($secret.$publications[$i]) === $token;
|
|
||||||
if (!$found) $i++;
|
|
||||||
}
|
|
||||||
return ($found) ? $publications[$i] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $resourceId
|
* @param int $resourceId
|
||||||
* @param array $acl
|
* @param array $acl
|
||||||
|
|
|
@ -6,6 +6,7 @@ use Sabre\DAV\PropFind;
|
||||||
use Sabre\DAV\INode;
|
use Sabre\DAV\INode;
|
||||||
use Sabre\DAV\Server;
|
use Sabre\DAV\Server;
|
||||||
use Sabre\DAV\ServerPlugin;
|
use Sabre\DAV\ServerPlugin;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
use Sabre\HTTP\RequestInterface;
|
use Sabre\HTTP\RequestInterface;
|
||||||
use Sabre\HTTP\ResponseInterface;
|
use Sabre\HTTP\ResponseInterface;
|
||||||
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
|
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
|
||||||
|
@ -102,14 +103,14 @@ class PublishPlugin extends ServerPlugin
|
||||||
$publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token;
|
$publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token;
|
||||||
|
|
||||||
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) {
|
$propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node, $publishUrl) {
|
||||||
if ($node->getPublishStatus()) {
|
if ($node->getPublishStatus()) {
|
||||||
return new Publisher($publishUrl, true); // We return the publish-url only if the calendar is published.
|
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) {
|
$propFind->handle('{'.self::NS_CALENDARSERVER.'}pre-publish-url', function () use ($node, $publishUrl) {
|
||||||
return new Publisher($publishUrl, false); // The pre-publish-url is always returned
|
return new Publisher($publishUrl, false); // The pre-publish-url is always returned
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ class PublishPlugin extends ServerPlugin
|
||||||
// Making sure the node exists
|
// Making sure the node exists
|
||||||
try {
|
try {
|
||||||
$node = $this->server->tree->getNodeForPath($path);
|
$node = $this->server->tree->getNodeForPath($path);
|
||||||
} catch (DAV\Exception\NotFound $e) {
|
} catch (NotFound $e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue