本文整理汇总了PHP中Sabre_DAV_Server::addPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_Server::addPlugin方法的具体用法?PHP Sabre_DAV_Server::addPlugin怎么用?PHP Sabre_DAV_Server::addPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre_DAV_Server
的用法示例。
在下文中一共展示了Sabre_DAV_Server::addPlugin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
// Set the root directory
$webdavPath = Phprojekt::getInstance()->getConfig()->webdavPath;
if (Phprojekt_Auth::isLoggedIn()) {
$project = new Project_Models_Project();
$project = $project->find(1);
$rootDirectory = new WebDAV_Models_ProjectDirectory($project);
} else {
// Some clients seem to send some queries without http auth. We need the dummy to serve those.
$rootDirectory = new WebDAV_Models_EmptyDir();
}
// The server object is responsible for making sense out of the WebDAV protocol
$server = new Sabre_DAV_Server($rootDirectory);
$server->setBaseUri($this->view->baseUrl('index.php/WebDAV/index/index/'));
// The lock manager is reponsible for making sure users don't overwrite each others changes.
// Change 'data' to a different directory, if you're storing your data somewhere else.
$lockBackend = new Sabre_DAV_Locks_Backend_File($webdavPath . 'data/locks');
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
$server->addPlugin($lockPlugin);
// Authentication
$authBackend = new WebDAV_Helper_Auth();
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'WebDAV');
$server->addPlugin($authPlugin);
// All we need to do now, is to fire up the server
$server->exec();
}
示例2: process
public function process()
{
// initialize authentication
$auth = new Sabre_HTTP_DigestAuth();
$auth->setRealm($this->app->config->site->auth_realm);
$auth->init();
// authenticate and get correct user
$email = $auth->getUsername();
$class_name = SwatDBClassMap::get('PinholeAdminUser');
$user = new $class_name();
$user->setDatabase($this->app->db);
if (!$user->loadFromEmail($email) || !$auth->validateA1($user->digest_ha1)) {
$auth->requireLogin();
echo Pinhole::_('Authentication required') . "\n";
exit;
}
// create directory for account and object tree for dav server
$root = new PinholeDavDirectory($this->app, $user);
$tree = new Sabre_DAV_ObjectTree($root);
// create server
$server = new Sabre_DAV_Server($tree);
$server->setBaseUri($this->getDavBaseUri());
// don't save temp files in the database
$tempFilePlugin = new Sabre_DAV_TemporaryFileFilterPlugin($this->getDataDir('dav/temp'));
$server->addPlugin($tempFilePlugin);
// set up lock plugin
$lockBackend = new Sabre_DAV_Locks_Backend_FS($this->getDataDir('dav/locks'));
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
$server->addPlugin($lockPlugin);
// also allow regular web browsing
$browserPlugin = new Sabre_DAV_Browser_Plugin(false);
$server->addPlugin($browserPlugin);
// serve it up!
$server->exec();
}
示例3: indexAction
/**
* Fire up the SabreDAV server with our custom backends.
*
* This is mostly copied from the sabredav wiki
*/
public function indexAction()
{
// Backends
$authBackend = new WebDAV_Helper_Auth();
$principalBackend = new Phprojekt_CalDAV_PrincipalBackend();
$calendarBackend = new Calendar2_CalDAV_CalendarBackend();
// Directory tree
$tree = array(new Sabre_DAVACL_PrincipalCollection($principalBackend), new Sabre_CalDAV_CalendarRootNode($principalBackend, $calendarBackend));
$server = new Sabre_DAV_Server($tree);
$server->setBaseUri('/index.php/Calendar2/caldav/index');
// Authentication plugin
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'CalDAV');
$server->addPlugin($authPlugin);
// CalDAV plugin
$caldavPlugin = new Sabre_CalDAV_Plugin();
$server->addPlugin($caldavPlugin);
// ACL plugin
$aclPlugin = new Sabre_DAVACL_Plugin();
$server->addPlugin($aclPlugin);
// Support for html frontend
$browser = new Sabre_DAV_Browser_Plugin();
$server->addPlugin($browser);
// And off we go!
$server->exec();
}
示例4: setUp
function setUp()
{
$this->setUpBackends();
$this->setUpTree();
$this->server = new Sabre_DAV_Server($this->tree);
$this->server->debugExceptions = true;
if ($this->setupCalDAV) {
$this->caldavPlugin = new Sabre_CalDAV_Plugin();
$this->server->addPlugin($this->caldavPlugin);
}
if ($this->setupCalDAVSharing) {
$this->caldavSharingPlugin = new Sabre_CalDAV_SharingPlugin();
$this->server->addPlugin($this->caldavSharingPlugin);
}
if ($this->setupCardDAV) {
$this->carddavPlugin = new Sabre_CardDAV_Plugin();
$this->server->addPlugin($this->carddavPlugin);
}
if ($this->setupACL) {
$this->aclPlugin = new Sabre_DAVACL_Plugin();
$this->server->addPlugin($this->aclPlugin);
}
if ($this->autoLogin) {
$authBackend = new Sabre_DAV_Auth_MockBackend();
$authBackend->defaultUser = $this->autoLogin;
$this->authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
$this->server->addPlugin($this->authPlugin);
}
}
示例5: setup
function setup()
{
if (!SABRE_HASSQLITE) {
$this->markTestSkipped('No PDO SQLite support');
}
$this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend();
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1'));
$principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1'));
$principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read'));
$principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write'));
$calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend);
$principals = new Sabre_CalDAV_Principal_Collection($principalBackend);
$root = new Sabre_DAV_SimpleCollection('root');
$root->addChild($calendars);
$root->addChild($principals);
$objectTree = new Sabre_DAV_ObjectTree($root);
$this->server = new Sabre_DAV_Server($objectTree);
$this->server->debugExceptions = true;
$this->server->setBaseUri('/');
$this->plugin = new Sabre_CalDAV_Plugin();
$this->server->addPlugin($this->plugin);
$this->response = new Sabre_HTTP_ResponseMock();
$this->server->httpResponse = $this->response;
}
示例6: setUp
function setUp()
{
$nodes = array(new Sabre_DAV_SimpleCollection('testdir'));
$this->server = new Sabre_DAV_Server($nodes);
$this->plugin = new Sabre_DAVACL_Plugin();
$this->plugin->allowAccessToNodesWithoutACL = false;
$this->server->addPlugin($this->plugin);
}
示例7: setUp
function setUp()
{
$this->backend = new Sabre_CardDAV_Backend_Mock();
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$tree = array(new Sabre_CardDAV_AddressBookRoot($principalBackend, $this->backend), new Sabre_DAVACL_PrincipalCollection($principalBackend));
$this->plugin = new Sabre_CardDAV_Plugin();
$this->plugin->directories = array('directory');
$this->server = new Sabre_DAV_Server($tree);
$this->server->addPlugin($this->plugin);
$this->server->debugExceptions = true;
}
示例8: setUp
function setUp()
{
$calendars = array(array('id' => 'calendar1', 'principaluri' => 'principals/admin', 'uri' => 'calendar1', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO', 'VJOURNAL'))), array('id' => 'calendar2', 'principaluri' => 'principals/admin', 'uri' => 'calendar2', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VTODO', 'VJOURNAL'))));
$this->calBackend = new Sabre_CalDAV_Backend_Mock($calendars, array());
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$tree = array(new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->calBackend));
$this->server = new Sabre_DAV_Server($tree);
$this->server->debugExceptions = true;
$plugin = new Sabre_CalDAV_Plugin();
$this->server->addPlugin($plugin);
$response = new Sabre_HTTP_ResponseMock();
$this->server->httpResponse = $response;
}
示例9: setUp
function setUp()
{
$calendars = array(array('id' => 'calendar1', 'principaluri' => 'principals/admin', 'uri' => 'calendar1'));
$this->calBackend = new Sabre_CalDAV_Backend_Mock($calendars, array());
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$tree = array(new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->calBackend));
$this->server = new Sabre_DAV_Server($tree);
$this->server->debugExceptions = true;
$plugin = new Sabre_CalDAV_Plugin();
$this->server->addPlugin($plugin);
$response = new Sabre_HTTP_ResponseMock();
$this->server->httpResponse = $response;
}
示例10: setUp
function setUp()
{
$this->setUpBackends();
$this->setUpTree();
$this->server = new Sabre_DAV_Server($this->tree);
if ($this->setupCalDAV) {
$this->caldavPlugin = new Sabre_CalDAV_Plugin();
$this->server->addPlugin($this->caldavPlugin);
}
if ($this->setupCardDAV) {
$this->carddavPlugin = new Sabre_CardDAV_Plugin();
$this->server->addPlugin($this->carddavPlugin);
}
}
示例11: testGetCurrentUserPrivilegeSet
function testGetCurrentUserPrivilegeSet()
{
$acl = array(array('principal' => 'principals/admin', 'privilege' => '{DAV:}read'), array('principal' => 'principals/user1', 'privilege' => '{DAV:}read'), array('principal' => 'principals/admin', 'privilege' => '{DAV:}write'));
$tree = array(new Sabre_DAVACL_MockACLNode('foo', $acl), new Sabre_DAV_SimpleDirectory('principals', array(new Sabre_DAVACL_MockPrincipal('admin', 'principals/admin'))));
$server = new Sabre_DAV_Server($tree);
$aclPlugin = new Sabre_DAVACL_Plugin();
$server->addPlugin($aclPlugin);
$auth = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'SabreDAV');
$server->addPlugin($auth);
//forcing login
$auth->beforeMethod('GET', '/');
$expected = array('{DAV:}read', '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', '{DAV:}write', '{DAV:}write-acl', '{DAV:}write-properties', '{DAV:}write-content', '{DAV:}bind', '{DAV:}unbind', '{DAV:}unlock');
$this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo'));
}
示例12: testBeforeMethodNoExport
function testBeforeMethodNoExport()
{
$p = new Sabre_CalDAV_ICSExportPlugin();
$s = new Sabre_DAV_Server();
$s->addPlugin($p);
$this->assertNull($p->beforeMethod('GET', 'UUID-123467'));
}
示例13: testLockEtc
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/mstest');
$server = new Sabre_DAV_Server($tree);
$server->debugExceptions = true;
$locksBackend = new Sabre_DAV_Locks_Backend_File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Sabre_DAV_Locks_Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new Sabre_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 Sabre_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 Sabre_HTTP_ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status);
}
示例14: testGetCurrentUserPrincipal
/**
* @depends testInit
*/
function testGetCurrentUserPrincipal()
{
$fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
$fakeServer->addPlugin($plugin);
$fakeServer->broadCastEvent('beforeMethod', array('GET', '/'));
$this->assertEquals('admin', $plugin->getCurrentUser());
}
示例15: testAdminAccess
/**
* @depends testNoAdminAccess
*/
function testAdminAccess()
{
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$tree = array(new Sabre_DAVACL_MockACLNode('adminonly', array()), new Sabre_DAVACL_PrincipalCollection($principalBackend));
$fakeServer = new Sabre_DAV_Server($tree);
$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
$fakeServer->addPlugin($plugin);
$plugin = new Sabre_DAVACL_Plugin();
$plugin->adminPrincipals = array('principals/admin');
$fakeServer->addPlugin($plugin);
$request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'OPTIONS', 'HTTP_DEPTH' => 1, 'REQUEST_URI' => '/adminonly'));
$response = new Sabre_HTTP_ResponseMock();
$fakeServer->httpRequest = $request;
$fakeServer->httpResponse = $response;
$fakeServer->exec();
$this->assertEquals('HTTP/1.1 200 OK', $response->status);
}