예제 #1
0
파일: plugin.php 프로젝트: gmurayama/core
 /**
  * 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)
 {
     $this->server = $server;
     $server->resourceTypeMapping['OCA\\DAV\\CardDAV\\ISharedAddressbook'] = '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}shared';
     $this->server->xml->elementMap['{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}share'] = 'OCA\\DAV\\CardDAV\\Sharing\\Xml\\ShareRequest';
     $this->server->on('method:POST', [$this, 'httpPost']);
 }
예제 #2
0
 /**
  * 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']);
 }
예제 #3
0
파일: Plugin.php 프로젝트: afterlogic/dav
 /**
  * Initializes the plugin
  *
  * @param \Sabre\DAV\Server $server
  * @return void
  */
 public function initialize(\Sabre\DAV\Server $server)
 {
     $this->server = $server;
     $this->server->on('beforeMethod', array($this, 'beforeMethod'));
     $this->server->on('beforeBind', array($this, 'beforeBind'), 30);
     $this->server->on('afterUnbind', array($this, 'afterUnbind'), 30);
 }
예제 #4
0
파일: Plugin.php 프로젝트: afterlogic/dav
 /**
  * Initializes the plugin and registers event handlers 
  * 
  * @param \Sabre\DAV\Server $server 
  * @return void
  */
 public function initialize(\Sabre\DAV\Server $server)
 {
     $this->server = $server;
     $this->server->on('beforeMethod', array($this, 'beforeMethod'), 90);
     $this->server->on('afterCreateFile', array($this, 'afterCreateFile'), 90);
     $this->server->on('afterWriteContent', array($this, 'afterWriteContent'), 90);
 }
예제 #5
0
 /** {@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']);
 }
예제 #6
0
 /**
  * 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'));
 }
예제 #7
0
 /**
  * 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->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
     $server->protectedProperties[] = self::ID_PROPERTYNAME;
     $server->on('propFind', array($this, 'handleGetProperties'));
     $server->on('propPatch', array($this, 'handleUpdateProperties'));
     $server->on('method:POST', [$this, 'httpPost']);
     $this->server = $server;
 }
 /**
  * Initializes the plugin
  *
  * @param \Sabre\DAV\Server $server
  * @return void
  */
 public function initialize(\Sabre\DAV\Server $server)
 {
     $this->server = $server;
     $this->server->on('beforeMethod', [$this, 'beforeMethod'], 5);
     $this->server->on('unknownMethod', [$this, 'unknownMethod'], 5);
     $this->server->on('report', [$this, 'report'], 5);
     $this->server->on('beforeGetProperties', [$this, 'beforeGetProperties'], 5);
     $this->log(2, 'Initialized plugin. Request time ' . $this->startTime . ' (' . date(\DateTime::RFC2822, $this->startTime) . '). Version: ' . \Sabre\DAV\Version::VERSION);
 }
예제 #9
0
 /**
  * Initializes the plugin
  *
  * This method is automatically called by the Server class after addPlugin.
  *
  * @param DAV\Server $server
  * @return void
  */
 function initialize(DAV\Server $server)
 {
     $this->server = $server;
     $server->on('method:LOCK', [$this, 'httpLock']);
     $server->on('method:UNLOCK', [$this, 'httpUnlock']);
     $server->on('validateTokens', [$this, 'validateTokens']);
     $server->on('propFind', [$this, 'propFind']);
     $server->on('afterUnbind', [$this, 'afterUnbind']);
 }
예제 #10
0
 /**
  * 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)
 {
     $this->server = $server;
     $server->on('method:GET', [$this, 'httpGet'], 90);
     $server->on('propFind', [$this, 'propFind']);
     $server->xmlNamespaces[self::NS_CALENDARSERVER] = 'cs';
     $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification';
     array_push($server->protectedProperties, '{' . self::NS_CALENDARSERVER . '}notification-URL', '{' . self::NS_CALENDARSERVER . '}notificationtype');
 }
예제 #11
0
 /**
  * Initializes the plugin
  *
  * This method is automatically called by the Server class after addPlugin.
  *
  * @param DAV\Server $server
  * @return void
  */
 function initialize(DAV\Server $server)
 {
     $this->server = $server;
     $this->server->xml->elementMap['{DAV:}lockinfo'] = 'Sabre\\DAV\\Xml\\Request\\Lock';
     $server->on('method:LOCK', [$this, 'httpLock']);
     $server->on('method:UNLOCK', [$this, 'httpUnlock']);
     $server->on('validateTokens', [$this, 'validateTokens']);
     $server->on('propFind', [$this, 'propFind']);
     $server->on('afterUnbind', [$this, 'afterUnbind']);
 }
예제 #12
0
 /**
  * Initializes the plugin and registers event handlers
  *
  * @param \Sabre\DAV\Server $server
  * @return void
  */
 function initialize(DAV\Server $server)
 {
     $this->server = $server;
     $server->on('method:GET', [$this, 'httpGet'], 90);
     $server->on('browserButtonActions', function ($path, $node, &$actions) {
         if ($node instanceof ICalendar) {
             $actions .= '<a href="' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '?export"><span class="oi" data-glyph="calendar"></span></a>';
         }
     });
 }
예제 #13
0
파일: Plugin.php 프로젝트: samj1912/repo
 /**
  * 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;
 }
예제 #14
0
 /**
  * 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)
 {
     $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']);
     $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);
     $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
     $server->on('onBrowserPostAction', [$this, 'browserPostAction']);
 }
예제 #15
0
 /**
  * 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)
 {
     $this->server = $server;
     if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
         return;
     }
     $this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
     $this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) {
         $writer->write($value->format('Y-m-d H:m:i'));
     };
     $this->server->on('report', [$this, 'onReport']);
     $this->server->on('method:POST', [$this, 'httpPost']);
 }
예제 #16
0
 /**
  * Initializes the plugin.
  *
  * This is when the plugin registers it's hooks.
  *
  * @param DAV\Server $server
  * @return void
  */
 function initialize(DAV\Server $server)
 {
     $this->server = $server;
     $self = $this;
     $server->on('report', function ($reportName, $dom, $uri) use($self) {
         if ($reportName === '{DAV:}sync-collection') {
             $this->server->transactionType = 'report-sync-collection';
             $self->syncCollection($uri, $dom);
             return false;
         }
     });
     $server->on('propFind', [$this, 'propFind']);
     $server->on('validateTokens', [$this, 'validateTokens']);
 }
예제 #17
0
 /**
  * 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->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
     $server->protectedProperties[] = self::FILEID_PROPERTYNAME;
     $server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME;
     $server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
     $server->protectedProperties[] = self::SHARE_PERMISSIONS_PROPERTYNAME;
     $server->protectedProperties[] = self::SIZE_PROPERTYNAME;
     $server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME;
     $server->protectedProperties[] = self::OWNER_ID_PROPERTYNAME;
     $server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
     $server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
     $server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
     // normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
     $allowedProperties = ['{DAV:}getetag'];
     $server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties);
     $this->server = $server;
     $this->server->on('propFind', array($this, 'handleGetProperties'));
     $this->server->on('propPatch', array($this, 'handleUpdateProperties'));
     $this->server->on('afterBind', array($this, 'sendFileIdHeader'));
     $this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
     $this->server->on('afterMethod:GET', [$this, 'httpGet']);
     $this->server->on('afterMethod:GET', array($this, 'handleDownloadToken'));
     $this->server->on('afterResponse', function ($request, ResponseInterface $response) {
         $body = $response->getBody();
         if (is_resource($body)) {
             fclose($body);
         }
     });
     $this->server->on('beforeMove', [$this, 'checkMove']);
 }
예제 #18
0
	/**
	 * 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::FILEID_PROPERTYNAME;
		$server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
		$server->protectedProperties[] = self::SIZE_PROPERTYNAME;
		$server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME;

		// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
		$allowedProperties = ['{DAV:}getetag', '{DAV:}getlastmodified'];
		$server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties);

		$this->server = $server;
		$this->server->on('propFind', array($this, 'handleGetProperties'));
		$this->server->on('propPatch', array($this, 'handleUpdateProperties'));
		$this->server->on('afterBind', array($this, 'sendFileIdHeader'));
		$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
		$this->server->on('afterMethod:GET', [$this,'httpGet']);
		$this->server->on('afterResponse', function($request, ResponseInterface $response) {
			$body = $response->getBody();
			if (is_resource($body)) {
				fclose($body);
			}
		});
	}
예제 #19
0
 /**
  * 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)
 {
     $this->server = $server;
     $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest';
     $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite';
     $this->server->on('method:POST', [$this, 'httpPost']);
     $this->server->on('propFind', [$this, 'propFind']);
 }
예제 #20
0
 /**
  * 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
  */
 public function initialize(\Sabre\DAV\Server $server)
 {
     $server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
     $server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
     $server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
     $this->server = $server;
     $this->server->on('propFind', array($this, 'handleGetProperties'));
 }
예제 #21
0
    /**
     * 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->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] =
            '{http://calendarserver.org/ns/}subscribed';

        $server->xml->elementMap['{http://calendarserver.org/ns/}source'] =
            'Sabre\\DAV\\Xml\\Property\\Href';

        $server->on('propFind', [$this, 'propFind'], 150);

    }
 function testUpdatePropertiesEventSuccess()
 {
     $tree = array(new SimpleCollection('foo'));
     $server = new Server($tree);
     $server->on('propPatch', function ($path, PropPatch $propPatch) {
         $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () {
             return ['{DAV:}foo' => 200, '{DAV:}foo2' => 201];
         });
     });
     $result = $server->updateProperties('foo', array('{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla'));
     $expected = array('{DAV:}foo' => 200, '{DAV:}foo2' => 201);
     $this->assertEquals($expected, $result);
 }
예제 #23
0
파일: remote.php 프로젝트: rosarion/core
/**
 * @param Exception $e
 */
function handleException(Exception $e)
{
    $request = \OC::$server->getRequest();
    // in case the request content type is text/xml - we assume it's a WebDAV request
    $isXmlContentType = strpos($request->getHeader('Content-Type'), 'text/xml');
    if ($isXmlContentType === 0) {
        // fire up a simple server to properly process the exception
        $server = new Server();
        if (!$e instanceof RemoteException) {
            // we shall not log on RemoteException
            $server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
        }
        $server->on('beforeMethod', function () use($e) {
            if ($e instanceof RemoteException) {
                switch ($e->getCode()) {
                    case OC_Response::STATUS_SERVICE_UNAVAILABLE:
                        throw new ServiceUnavailable($e->getMessage());
                    case OC_Response::STATUS_NOT_FOUND:
                        throw new \Sabre\DAV\Exception\NotFound($e->getMessage());
                }
            }
            $class = get_class($e);
            $msg = $e->getMessage();
            throw new ServiceUnavailable("{$class}: {$msg}");
        });
        $server->exec();
    } else {
        $statusCode = OC_Response::STATUS_INTERNAL_SERVER_ERROR;
        if ($e instanceof \OC\ServiceUnavailableException) {
            $statusCode = OC_Response::STATUS_SERVICE_UNAVAILABLE;
        }
        if ($e instanceof RemoteException) {
            // we shall not log on RemoteException
            OC_Response::setStatus($e->getCode());
            OC_Template::printErrorPage($e->getMessage());
        } else {
            \OCP\Util::writeLog('remote', $e->getMessage(), \OCP\Util::FATAL);
            OC_Response::setStatus($statusCode);
            OC_Template::printExceptionErrorPage($e);
        }
    }
}
예제 #24
0
파일: Plugin.php 프로젝트: mattes/sabre-dav
 /**
  * Initializes the plugin
  *
  * @param Server $server
  * @return void
  */
 function initialize(Server $server)
 {
     $this->server = $server;
     $server->on('method:POST', [$this, 'httpPost']);
     $server->on('propFind', [$this, 'propFind']);
     $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
     $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
     $server->on('beforeUnbind', [$this, 'beforeUnbind']);
     $server->on('schedule', [$this, 'scheduleLocalDelivery']);
     $ns = '{' . self::NS_CALDAV . '}';
     /**
      * This information ensures that the {DAV:}resourcetype property has
      * the correct values.
      */
     $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns . 'schedule-outbox';
     $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns . 'schedule-inbox';
     /**
      * Properties we protect are made read-only by the server.
      */
     array_push($server->protectedProperties, $ns . 'schedule-inbox-URL', $ns . 'schedule-outbox-URL', $ns . 'calendar-user-address-set', $ns . 'calendar-user-type');
 }
예제 #25
0
 function initialize(DAV\Server $server)
 {
     $server->on('schedule', [$this, 'schedule'], 120);
 }
예제 #26
0
 /**
  * {@inheritdoc}
  */
 public function initialize(\Sabre\DAV\Server $server)
 {
     $this->server = $server;
     $this->server->on('beforeMethod', [$this, 'getLock'], 50);
     $this->server->on('afterMethod', [$this, 'releaseLock'], 50);
 }
예제 #27
0
 /**
  * Initializes the plugin
  *
  * This method is automatically called by the Server class after addPlugin.
  *
  * @param DAV\Server $server
  * @return void
  */
 function initialize(DAV\Server $server)
 {
     $this->server = $server;
     $server->on('method:PATCH', [$this, 'httpPatch']);
 }
예제 #28
0
 function initialize(Server $server)
 {
     $server->on('propFind', [$this, 'propFind']);
     parent::initialize($server);
 }
예제 #29
0
 public function initialize(Server $server)
 {
     $this->server = $server;
     $server->on('beforeLock', [$this, 'beforeLock']);
 }
 /**
  * @param \Sabre\DAV\Server $server
  * @return void
  */
 function initialize(\Sabre\DAV\Server $server)
 {
     $this->server = $server;
     $this->server->on('method:GET', [$this, 'httpGet'], 200);
 }