作者:MetallianFR6
项目:myroundcub
/**
* 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 Server $server
* @return void
*/
function initialize(Server $server)
{
$server->on('propFind', [$this, 'propFind'], 130);
$server->on('propPatch', [$this, 'propPatch'], 300);
$server->on('afterMove', [$this, 'afterMove']);
$server->on('afterUnbind', [$this, 'afterUnbind']);
}
作者:MetallianFR6
项目:myroundcub
function testBrief()
{
$httpRequest = HTTP\Sapi::createFromServerArray(array('HTTP_BRIEF' => 't'));
$server = new Server();
$server->httpRequest = $httpRequest;
$this->assertEquals(array('strict' => false, 'lenient' => false, 'wait' => null, 'return-asynch' => false, 'return-minimal' => true, 'return-representation' => false), $server->getHTTPPrefer());
}
作者:bartv
项目:SecotrustSabreDavBundl
/**
* Constructor.
*
* @param Server $dav
* @param EventDispatcherInterface $dispatcher
* @param RouterInterface $router
*/
public function __construct(Server $dav, EventDispatcherInterface $dispatcher, RouterInterface $router)
{
$this->dav = $dav;
$this->dav->setBaseUri($router->generate('secotrust_sabre_dav', array()));
$this->dispatcher = $dispatcher;
// TODO needed?
}
作者:hallnewma
项目:webmail-lit
/**
* Initializes the plugin
*
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$this->server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'));
$this->server->subscribeEvent('beforeBind', array($this, 'beforeBind'), 30);
$this->server->subscribeEvent('afterUnbind', array($this, 'afterUnbind'), 30);
}
作者:pkdevbox
项目:webmail-lit
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $prop
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $prop)
{
$doc = $prop->ownerDocument;
foreach ($this->locks as $lock) {
$activeLock = $doc->createElementNS('DAV:', 'd:activelock');
$prop->appendChild($activeLock);
$lockScope = $doc->createElementNS('DAV:', 'd:lockscope');
$activeLock->appendChild($lockScope);
$lockScope->appendChild($doc->createElementNS('DAV:', 'd:' . ($lock->scope == DAV\Locks\LockInfo::EXCLUSIVE ? 'exclusive' : 'shared')));
$lockType = $doc->createElementNS('DAV:', 'd:locktype');
$activeLock->appendChild($lockType);
$lockType->appendChild($doc->createElementNS('DAV:', 'd:write'));
/* {DAV:}lockroot */
if (!self::$hideLockRoot) {
$lockRoot = $doc->createElementNS('DAV:', 'd:lockroot');
$activeLock->appendChild($lockRoot);
$href = $doc->createElementNS('DAV:', 'd:href');
$href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
$lockRoot->appendChild($href);
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:depth', $lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth));
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:timeout', 'Second-' . $lock->timeout));
if ($this->revealLockToken) {
$lockToken = $doc->createElementNS('DAV:', 'd:locktoken');
$activeLock->appendChild($lockToken);
$lockToken->appendChild($doc->createElementNS('DAV:', 'd:href', 'opaquelocktoken:' . $lock->token));
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:owner', $lock->owner));
}
}
作者:samj191
项目:rep
/**
* Initializes the plugin
*
* @param DAV\Server $server
* @return void
*/
function initialize(DAV\Server $server)
{
/* Events */
$server->on('propFind', [$this, 'propFindEarly']);
$server->on('propFind', [$this, 'propFindLate'], 150);
$server->on('propPatch', [$this, 'propPatch']);
$server->on('report', [$this, 'report']);
$server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
$server->on('onBrowserPostAction', [$this, 'browserPostAction']);
$server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
$server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
$server->on('afterMethod:GET', [$this, 'httpAfterGet']);
/* Namespaces */
$server->xmlNamespaces[self::NS_CARDDAV] = 'card';
/* Mapping Interfaces to {DAV:}resourcetype values */
$server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook';
$server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{' . self::NS_CARDDAV . '}directory';
/* Adding properties that may never be changed */
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}addressbook-home-set';
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-collation-set';
$server->propertyMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre\\DAV\\Property\\Href';
$this->server = $server;
}
作者:nbe
项目:Emergence-Skeleto
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$server->subscribeEvent('beforeMethod', array($this, 'httpGetInterceptor'));
$server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'));
$server->subscribeEvent('beforeCreateFile', array($this, 'beforeCreateFile'));
}
作者:sebbie4
项目:casebo
function testBrief()
{
$httpRequest = HTTP\Sapi::createFromServerArray(['HTTP_BRIEF' => 't']);
$server = new Server();
$server->httpRequest = $httpRequest;
$this->assertEquals(['respond-async' => false, 'return' => 'minimal', 'handling' => null, 'wait' => null], $server->getHTTPPrefer());
}
作者:yheric45504
项目:owncloud8
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $dom)
{
$document = $dom->ownerDocument;
$properties = $this->responseProperties;
$xresponse = $document->createElement('d:response');
$dom->appendChild($xresponse);
$uri = DAV\URLUtil::encodePath($this->href);
// Adding the baseurl to the beginning of the url
$uri = $server->getBaseUri() . $uri;
$xresponse->appendChild($document->createElement('d:href', $uri));
// The properties variable is an array containing properties, grouped by
// HTTP status
foreach ($properties as $httpStatus => $propertyGroup) {
// The 'href' is also in this array, and it's special cased.
// We will ignore it
if ($httpStatus == 'href') {
continue;
}
// If there are no properties in this group, we can also just carry on
if (!count($propertyGroup)) {
continue;
}
$xpropstat = $document->createElement('d:propstat');
$xresponse->appendChild($xpropstat);
$xprop = $document->createElement('d:prop');
$xpropstat->appendChild($xprop);
$nsList = $server->xmlNamespaces;
foreach ($propertyGroup as $propertyName => $propertyValue) {
$propName = null;
preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName);
// special case for empty namespaces
if ($propName[1] == '') {
$currentProperty = $document->createElement($propName[2]);
$xprop->appendChild($currentProperty);
$currentProperty->setAttribute('xmlns', '');
} else {
if (!isset($nsList[$propName[1]])) {
$nsList[$propName[1]] = 'x' . count($nsList);
}
// If the namespace was defined in the top-level xml namespaces, it means
// there was already a namespace declaration, and we don't have to worry about it.
if (isset($server->xmlNamespaces[$propName[1]])) {
$currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
} else {
$currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]);
}
$xprop->appendChild($currentProperty);
}
if (is_scalar($propertyValue)) {
$text = $document->createTextNode($propertyValue);
$currentProperty->appendChild($text);
} elseif ($propertyValue instanceof DAV\PropertyInterface) {
$propertyValue->serialize($server, $currentProperty);
} elseif (!is_null($propertyValue)) {
throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
}
}
$xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
}
}
作者:sebbie4
项目:casebo
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
$server = new DAV\Server($tree);
$server->debugExceptions = true;
$locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest();
$server->httpResponse = $response1;
$server->sapi = new HTTP\SapiMock();
$server->exec();
$this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:' . $response1->getBodyAsString());
$this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
$lockToken = $server->httpResponse->getHeader('Lock-Token');
//sleep(10);
$response2 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest2();
$server->httpResponse = $response2;
$server->exec();
$this->assertEquals(201, $server->httpResponse->status);
$this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
//sleep(10);
$response3 = new HTTP\ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals(204, $server->httpResponse->status);
}
作者:biggtfis
项目:cm
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $dom)
{
$prefix = $server->xmlNamespaces['DAV:'];
$elem = $dom->ownerDocument->createElement($prefix . ':href');
$elem->nodeValue = ($this->autoPrefix ? $server->getBaseUri() : '') . $this->href;
$dom->appendChild($elem);
}
作者:samj191
项目:rep
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
$server = new DAV\Server($tree);
$server->debugExceptions = true;
$locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest();
$server->httpResponse = $response1;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
$lockToken = $server->httpResponse->headers['Lock-Token'];
//sleep(10);
$response2 = new HTTP\ResponseMock();
$server->httpRequest = $this->getLockRequest2();
$server->httpResponse = $response2;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
//sleep(10);
$response3 = new HTTP\ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status);
}
作者:nbe
项目:Emergence-Skeleto
/**
* Initializes the plugin
*
* This method is automatically called by the Server class after addPlugin.
*
* @param DAV\Server $server
* @return void
*/
public function initialize(DAV\Server $server)
{
$this->server = $server;
$server->subscribeEvent('unknownMethod', array($this, 'unknownMethod'));
$server->subscribeEvent('beforeMethod', array($this, 'beforeMethod'), 50);
$server->subscribeEvent('afterGetProperties', array($this, 'afterGetProperties'));
}
作者:BlaBlaNe
项目:hubzill
function init()
{
if (!is_dir('store')) {
os_mkdir('store', STORAGE_DEFAULT_PERMISSIONS, false);
}
$which = null;
if (argc() > 1) {
$which = argv(1);
}
$profile = 0;
\App::$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . z_root() . '/feed/' . $which . '" />' . "\r\n";
if ($which) {
profile_load($which, $profile);
}
$auth = new \Zotlabs\Storage\BasicAuth();
$ob_hash = get_observer_hash();
if ($ob_hash) {
if (local_channel()) {
$channel = \App::get_channel();
$auth->setCurrentUser($channel['channel_address']);
$auth->channel_id = $channel['channel_id'];
$auth->channel_hash = $channel['channel_hash'];
$auth->channel_account_id = $channel['channel_account_id'];
if ($channel['channel_timezone']) {
$auth->setTimezone($channel['channel_timezone']);
}
}
$auth->observer = $ob_hash;
}
if ($_GET['davguest']) {
$_SESSION['davguest'] = true;
}
$_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']);
$_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']);
$_SERVER['QUERY_STRING'] = preg_replace('/[\\?&]davguest=(.*?)([\\?&]|$)/ism', '', $_SERVER['QUERY_STRING']);
$_SERVER['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI'] = preg_replace('/[\\?&]davguest=(.*?)([\\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
$rootDirectory = new \Zotlabs\Storage\Directory('/', $auth);
// A SabreDAV server-object
$server = new SDAV\Server($rootDirectory);
// prevent overwriting changes each other with a lock backend
$lockBackend = new SDAV\Locks\Backend\File('store/[data]/locks');
$lockPlugin = new SDAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
$is_readable = false;
// provide a directory view for the cloud in Hubzilla
$browser = new \Zotlabs\Storage\Browser($auth);
$auth->setBrowserPlugin($browser);
$server->addPlugin($browser);
// Experimental QuotaPlugin
// require_once('\Zotlabs\Storage/QuotaPlugin.php');
// $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth));
ob_start();
// All we need to do now, is to fire up the server
$server->exec();
ob_end_flush();
killme();
}
作者:open-stea
项目:bidowlap
public function idAction($id)
{
$server = new Server(new RootId($id));
$server->setBaseUri(WEBDAV_BASE_URI . "id/" . $id . "/");
$this->initDavPlugins($server);
$server->exec();
exit;
}
作者:Kevin-Z
项目:vaneDis
/**
* 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->propertyMap[self::TAGS_PROPERTYNAME] = 'OC\\Connector\\Sabre\\TagList';
$this->server = $server;
$this->server->on('propFind', array($this, 'handleGetProperties'));
$this->server->on('propPatch', array($this, 'handleUpdateProperties'));
}
作者:stwei
项目:owncloud-cor
/** {@inheritDoc} */
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
$this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
$server->on('propFind', [$this, 'propFind']);
$server->on('validateTokens', [$this, 'validateTokens']);
}
作者:LobbyO
项目:serve
function schedule(Message $message)
{
$plugin = new IMip\MockPlugin('system@example.org');
$server = new Server();
$server->addPlugin($plugin);
$server->emit('schedule', [$message]);
return $plugin->getSentEmails();
}
作者:ingoratsdor
项目:Tine-2.0-Open-Source-Groupware-and-CR
/**
* Initializes the plugin
*
* @param \Sabre\DAV\Server $server
* @return void
*/
public function initialize(\Sabre\DAV\Server $server)
{
$this->server = $server;
$this->server->subscribeEvent('unknownMethod', array($this, 'httpPOSTHandler'));
$server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
$server->xmlNamespaces[\Sabre\CalDAV\Plugin::NS_CALENDARSERVER] = 'cs';
$server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
}
作者:TamirA
项目:hubzill
/**
* @depends testInit
*/
function testGetCurrentUserPrincipal()
{
$fakeServer = new DAV\Server(new DAV\SimpleCollection('bla'));
$plugin = new Plugin(new Backend\Mock(), 'realm');
$fakeServer->addPlugin($plugin);
$fakeServer->broadCastEvent('beforeMethod', array('GET', '/'));
$this->assertEquals('admin', $plugin->getCurrentUser());
}