[Pkg-owncloud-commits] [php-sabredav] 12/220: {DAV:}share-mode
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit cf6e4961d4a02e55386f629f9389f4f62319d640
Author: Evert Pot <me at evertpot.com>
Date: Wed Jul 29 13:23:04 2015 -0400
{DAV:}share-mode
---
lib/DAV/Sharing/ISharedNode.php | 36 -----------------
lib/DAV/Sharing/Plugin.php | 21 +++++++++-
lib/DAV/Xml/Property/ShareMode.php | 79 ++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+), 38 deletions(-)
diff --git a/lib/DAV/Sharing/ISharedNode.php b/lib/DAV/Sharing/ISharedNode.php
index b0cd03b..41a19f0 100644
--- a/lib/DAV/Sharing/ISharedNode.php
+++ b/lib/DAV/Sharing/ISharedNode.php
@@ -15,40 +15,4 @@ use Sabre\DAV\INode;
*/
interface ISharedNode extends INode {
- /**
- * Updates the list of shares.
- *
- * The first array is a list of people that are to be added to the
- * shared resource.
- *
- * Every element in the add array has the following properties:
- * * href - A url. Usually a mailto: address
- * * summary - A description of the share, can also be false
- * * readOnly - A boolean value
- *
- * In addition to that, the array might have any additional properties,
- * specified in clark-notation, such as '{DAV:}displayname'.
- *
- * Every element in the remove array is just the url of the sharee that's
- * to be removed.
- *
- * @param array $add
- * @param array $remove
- * @return void
- */
- function updateShares(array $add, array $remove);
-
- /**
- * Returns the list of people whom this resource is shared with.
- *
- * Every element in this array should have the following properties:
- * * href - Often a mailto: address
- * * commonName - Optional, for example a first + last name
- * * status - See the Sabre\DAV\Sharing\Plugin::STATUS_ constants.
- * * readOnly - boolean
- *
- * @return array
- */
- function getShares();
-
}
diff --git a/lib/DAV/Sharing/Plugin.php b/lib/DAV/Sharing/Plugin.php
index 16f17b4..11432ae 100644
--- a/lib/DAV/Sharing/Plugin.php
+++ b/lib/DAV/Sharing/Plugin.php
@@ -8,6 +8,7 @@ use Sabre\DAV\INode;
use Sabre\DAV\PropFind;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
+use Sabre\DAV\Xml\Property;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -75,6 +76,12 @@ class Plugin extends ServerPlugin {
$this->server = $server;
$server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource';
+
+ array_push(
+ $server->protectedProperties,
+ '{DAV:}share-mode'
+ );
+
$server->on('method:POST', [$this, 'httpPost']);
$server->on('propFind', [$this, 'propFind']);
@@ -140,10 +147,20 @@ class Plugin extends ServerPlugin {
*/
function propFind(PropFind $propFind, INode $node) {
- if ($node instanceof IShareableNode) {
+ $propFind->handle('{DAV:}share-mode', function() {
+ if (INode instanceof ISharedNode) {
+
+ return new Property\ShareMode(Property\ShareMode::SHARED);
+
+ } elseif (INode instanceof IShareableNode) {
+
+ return new Property\ShareMode(Property\ShareMode::SHAREDOWNER);
+
+ }
+
+ });
- }
}
diff --git a/lib/DAV/Xml/Property/ShareMode.php b/lib/DAV/Xml/Property/ShareMode.php
new file mode 100644
index 0000000..e93d216
--- /dev/null
+++ b/lib/DAV/Xml/Property/ShareMode.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Sabre\DAV\Xml\Property;
+
+use Sabre\Xml\Writer;
+use Sabre\Xml\XmlSerializable;
+
+/**
+ * This class represents the {DAV:}share-mode property.
+ *
+ * This property is defined here:
+ * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-02#section-5.2.1
+ *
+ * This property is used to indicate if a resource is a shared resource, and
+ * whether the instance of the shared resource is the original instance, or
+ * an instance belonging to a sharee.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class ShareMode implements XmlSerializable {
+
+ const SHARED = 1;
+ const SHAREDOWNER = 2;
+
+ /**
+ * Either SHARED or SHAREDOWNER
+ *
+ * @var int
+ */
+ protected $value;
+
+ /**
+ * Creates the property
+ *
+ * @param int $shareModeType Either SHARED or SHAREDOWNER.
+ */
+ function __construct($shareModeType) {
+
+ $this->value = $shareModeType;
+
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+
+ switch($this->value) {
+
+ case self::SHARED :
+ $writer->writeElement('{DAV:}shared');
+ break;
+ case self::SHAREDOWNER :
+ $writer->writeElement('{DAV:}shared-owner');
+ break;
+
+ }
+
+ }
+
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list