本文整理汇总了PHP中OCA\Files_Sharing\Helper类的典型用法代码示例。如果您正苦于以下问题:PHP Helper类的具体用法?PHP Helper怎么用?PHP Helper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Helper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateTarget
/**
* create unique target
* @param string $filePath
* @param string $shareWith
* @param string $exclude
* @return string
*/
public function generateTarget($filePath, $shareWith, $exclude = null)
{
$shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
$target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
// for group shares we return the target right away
if ($shareWith === false) {
return $target;
}
\OC\Files\Filesystem::initMountPoints($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files');
if (!$view->is_dir($shareFolder)) {
$dir = '';
$subdirs = explode('/', $shareFolder);
foreach ($subdirs as $subdir) {
$dir = $dir . '/' . $subdir;
if (!$view->is_dir($dir)) {
$view->mkdir($dir);
}
}
}
$excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
if (is_array($exclude)) {
$excludeList = array_merge($excludeList, $exclude);
}
return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
\OC_Hook::clear('OC_Filesystem');
\OC_Hook::clear('OC_User');
\OC_Hook::clear('OCP\\Share');
// trashbin hooks
\OCA\Files_Trashbin\Trashbin::registerHooks();
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// register share hooks
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
// Sharing related hooks
\OCA\Encryption\Helper::registerShareHooks();
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// clear and register hooks
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Files\Share\Proxy());
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create test user
self::loginHelper(self::TEST_ENCRYPTION_TRASHBIN_USER2, true);
self::loginHelper(self::TEST_ENCRYPTION_TRASHBIN_USER1, true);
}
示例3: __construct
public function __construct(array $urlParams = array())
{
parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer();
$server = $container->getServer();
/**
* Controllers
*/
$container->registerService('ShareController', function (SimpleContainer $c) use($server) {
return new ShareController($c->query('AppName'), $c->query('Request'), $c->query('UserSession'), $server->getAppConfig(), $server->getConfig(), $c->query('URLGenerator'), $c->query('UserManager'), $server->getLogger(), $server->getActivityManager());
});
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
return new ExternalSharesController($c->query('AppName'), $c->query('Request'), $c->query('IsIncomingShareEnabled'), $c->query('ExternalManager'), $c->query('HttpClientService'));
});
/**
* Core class wrappers
*/
$container->registerService('UserSession', function (SimpleContainer $c) use($server) {
return $server->getUserSession();
});
$container->registerService('URLGenerator', function (SimpleContainer $c) use($server) {
return $server->getUrlGenerator();
});
$container->registerService('UserManager', function (SimpleContainer $c) use($server) {
return $server->getUserManager();
});
$container->registerService('HttpClientService', function (SimpleContainer $c) use($server) {
return $server->getHTTPClientService();
});
$container->registerService('IsIncomingShareEnabled', function (SimpleContainer $c) {
return Helper::isIncomingServer2serverShareEnabled();
});
$container->registerService('ExternalManager', function (SimpleContainer $c) use($server) {
$user = $server->getUserSession()->getUser();
$uid = $user ? $user->getUID() : null;
return new \OCA\Files_Sharing\External\Manager($server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPHelper(), $server->getNotificationManager(), $uid);
});
/**
* Middleware
*/
$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use($server) {
return new SharingCheckMiddleware($c->query('AppName'), $server->getConfig(), $server->getAppManager());
});
// Execute middlewares
$container->registerMiddleware('SharingCheckMiddleware');
$container->registerService('MountProvider', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new MountProvider($server->getConfig(), $c->query('PropagationManager'));
});
$container->registerService('PropagationManager', function (IContainer $c) {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new PropagationManager($server->getUserSession(), $server->getConfig());
});
/*
* Register capabilities
*/
$container->registerCapability('OCA\\Files_Sharing\\Capabilities');
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// enable resharing
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
// register share hooks
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
// Sharing related hooks
\OCA\Encryption\Helper::registerShareHooks();
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// clear and register hooks
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Files\Share\Proxy());
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create users
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
// create group and assign users
\OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
}
示例5: testSetGetShareFolder
/**
* test set and get share folder
*/
function testSetGetShareFolder()
{
$this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder());
\OCA\Files_Sharing\Helper::setShareFolder('/Shared');
$this->assertSame('/Shared', \OCA\Files_Sharing\Helper::getShareFolder());
// cleanup
\OCP\Config::deleteSystemValue('share_folder');
}
示例6: testSetGetShareFolder
/**
* test set and get share folder
*/
function testSetGetShareFolder()
{
$this->assertSame('/', \OCA\Files_Sharing\Helper::getShareFolder());
\OCA\Files_Sharing\Helper::setShareFolder('/Shared/Folder');
$sharedFolder = \OCA\Files_Sharing\Helper::getShareFolder();
$this->assertSame('/Shared/Folder', \OCA\Files_Sharing\Helper::getShareFolder());
$this->assertTrue(\OC\Files\Filesystem::is_dir($sharedFolder));
// cleanup
\OCP\Config::deleteSystemValue('share_folder');
}
示例7: getCloudId
private function getCloudId()
{
$this->requireLogin();
if (!method_exists($this->user, 'getCloudId')) {
$uid = \OC::$server->getUserSession()->getUser()->getUID();
$server = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
return $uid . '@' . rtrim(\OCA\Files_Sharing\Helper::removeProtocolFromUrl($server), '/');
}
// Nextcloud 9
return $this->user->getCloudId();
}
示例8: verifyMountPoint
/**
* check if the parent folder exists otherwise move the mount point up
*
* @param \OCP\Share\IShare $share
* @param SharedMount[] $mountpoints
* @return string
*/
private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints)
{
$mountPoint = basename($share->getTarget());
$parent = dirname($share->getTarget());
if (!$this->recipientView->is_dir($parent)) {
$parent = Helper::getShareFolder();
}
$newMountPoint = $this->generateUniqueTarget(\OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), $this->recipientView, $mountpoints);
if ($newMountPoint !== $share->getTarget()) {
$this->updateFileTarget($newMountPoint, $share);
}
return $newMountPoint;
}
示例9: generateTarget
/**
* create unique target
* @param string $filePath
* @param string $shareWith
* @param string $exclude
* @return string
*/
public function generateTarget($filePath, $shareWith, $exclude = null)
{
$target = '/' . basename($filePath);
// for group shares we return the target right away
if ($shareWith === false) {
return $target;
}
\OC\Files\Filesystem::initMountPoints($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files');
$excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
if (is_array($exclude)) {
$excludeList = array_merge($excludeList, $exclude);
}
return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
}
示例10: verifyMountPoint
/**
* check if the parent folder exists otherwise move the mount point up
*/
private function verifyMountPoint(&$share, $user)
{
$mountPoint = basename($share['file_target']);
$parent = dirname($share['file_target']);
if (!\OC\Files\Filesystem::is_dir($parent)) {
$parent = Helper::getShareFolder();
}
$newMountPoint = \OCA\Files_Sharing\Helper::generateUniqueTarget(\OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), array(), new \OC\Files\View('/' . $user . '/files'));
if ($newMountPoint !== $share['file_target']) {
self::updateFileTarget($newMountPoint, $share);
$share['file_target'] = $newMountPoint;
$share['unique_name'] = true;
}
return $newMountPoint;
}
示例11: verifyMountPoint
/**
* check if the parent folder exists otherwise move the mount point up
*
* @param array $share
* @return string
*/
private function verifyMountPoint(&$share)
{
$mountPoint = basename($share['file_target']);
$parent = dirname($share['file_target']);
if (!$this->recipientView->is_dir($parent)) {
$parent = Helper::getShareFolder();
}
$newMountPoint = \OCA\Files_Sharing\Helper::generateUniqueTarget(\OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), [], $this->recipientView);
if ($newMountPoint !== $share['file_target']) {
$this->updateFileTarget($newMountPoint, $share);
$share['file_target'] = $newMountPoint;
$share['unique_name'] = true;
}
return $newMountPoint;
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// enable resharing
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
// register share hooks
\OC::registerShareHooks();
\OCA\Files_Sharing\Helper::registerHooks();
// clear and register hooks
\OC_FileProxy::register(new \OCA\Files\Share\Proxy());
// create users
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3, true);
self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER4, true);
// create group and assign users
\OC_Group::createGroup(self::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER3, self::TEST_ENCRYPTION_SHARE_GROUP1);
\OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER4, self::TEST_ENCRYPTION_SHARE_GROUP1);
}
示例13: setupMounts
private function setupMounts()
{
// don't setup server-to-server shares if the admin disabled it
if (\OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false) {
return false;
}
if ($this->uid) {
$query = $this->connection->prepare('
SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner`
FROM `*PREFIX*share_external`
WHERE `user` = ?
');
$query->execute(array($this->uid));
while ($row = $query->fetch()) {
$row['manager'] = $this;
$row['token'] = $row['share_token'];
$this->mountShare($row);
}
}
}
示例14: correctFolders
/**
* Correct the parent folders' ETags for all users shared the file at $target
*
* @param string $target
*/
public static function correctFolders($target)
{
// ignore part files
if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
return false;
}
// Correct Shared folders of other users shared with
$shares = \OCA\Files_Sharing\Helper::getSharesFromItem($target);
foreach ($shares as $share) {
if ((int) $share['share_type'] === \OCP\Share::SHARE_TYPE_USER) {
self::correctUsersFolder($share['share_with'], $share['file_target']);
} elseif ((int) $share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
$users = \OC_Group::usersInGroup($share['share_with']);
foreach ($users as $user) {
self::correctUsersFolder($user, $share['file_target']);
}
} else {
//unique name for group share
self::correctUsersFolder($share['share_with'], $share['file_target']);
}
}
}
示例15: __construct
/**
* @param array $urlParams
*/
public function __construct(array $urlParams = array())
{
parent::__construct('files_sharing', $urlParams);
$container = $this->getContainer();
/**
* Controllers
*/
$container->registerService('ShareController', function (SimpleContainer $c) {
return new ShareController($c->query('AppName'), $c->query('Request'), $c->query('UserSession'), $c->query('ServerContainer')->getAppConfig(), $c->query('ServerContainer')->getConfig(), $c->query('URLGenerator'), $c->query('ServerContainer')->getUserManager(), $c->query('ServerContainer')->getLogger(), $c->query('ServerContainer')->getActivityManager());
});
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
return new ExternalSharesController($c->query('AppName'), $c->query('Request'), $c->query('IsIncomingShareEnabled'), $c->query('ExternalManager'));
});
/**
* Core class wrappers
*/
$container->registerService('UserSession', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getUserSession();
});
$container->registerService('URLGenerator', function (SimpleContainer $c) {
return $c->query('ServerContainer')->getUrlGenerator();
});
$container->registerService('IsIncomingShareEnabled', function (SimpleContainer $c) {
return Helper::isIncomingServer2serverShareEnabled();
});
$container->registerService('ExternalManager', function (SimpleContainer $c) {
return new \OCA\Files_Sharing\External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getUserSession(), \OC::$server->getHTTPHelper());
});
/**
* Middleware
*/
$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) {
return new SharingCheckMiddleware($c->query('AppName'), $c->query('ServerContainer')->getAppConfig(), $c->getCoreApi());
});
// Execute middlewares
$container->registerMiddleware('SharingCheckMiddleware');
}