introducing new dav property {xmlns:oc="http://owncloud.org/ns}id
parent
2d14daf36b
commit
b60ae11db8
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud
|
||||
*
|
||||
* @author Thomas Müller
|
||||
* @copyright 2013 Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @license AGPL3
|
||||
*/
|
||||
|
||||
class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin
|
||||
{
|
||||
|
||||
// namespace
|
||||
const NS_OWNCLOUD = 'xmlns:oc="http://owncloud.org/ns';
|
||||
|
||||
/**
|
||||
* Reference to main server object
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* This initializes the plugin.
|
||||
*
|
||||
* This function is called by Sabre_DAV_Server, after
|
||||
* addPlugin is called.
|
||||
*
|
||||
* This method should set up the required event subscriptions.
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
||||
$server->xmlNamespaces[self::NS_OWNCLOUD] = 'oc';
|
||||
$server->protectedProperties[] = '{' . self::NS_OWNCLOUD . '}id';
|
||||
|
||||
$this->server = $server;
|
||||
$this->server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all ownCloud-specific properties
|
||||
*
|
||||
* @param string $path
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @param array $requestedProperties
|
||||
* @param array $returnedProperties
|
||||
* @return void
|
||||
*/
|
||||
public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) {
|
||||
|
||||
if ($node instanceof OC_Connector_Sabre_Node) {
|
||||
|
||||
$fileid_propertyname = '{' . self::NS_OWNCLOUD . '}id';
|
||||
unset($requestedProperties[array_search($fileid_propertyname, $requestedProperties)]);
|
||||
|
||||
/** @var $node OC_Connector_Sabre_Node */
|
||||
$returnedProperties[200][$fileid_propertyname] = $node->getFileId();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue