本文整理汇总了PHP中OC类的典型用法代码示例。如果您正苦于以下问题:PHP OC类的具体用法?PHP OC怎么用?PHP OC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user1 = uniqid('user1_');
$this->user2 = uniqid('user2_');
$this->user3 = uniqid('user3_');
$this->user4 = uniqid('user4_');
OC_User::createUser($this->user1, 'pass');
OC_User::createUser($this->user2, 'pass');
OC_User::createUser($this->user3, 'pass');
OC_User::createUser($this->user4, 'pass');
OC_User::setUserId($this->user1);
OC_Group::clearBackends();
OC_Group::useBackend(new OC_Group_Dummy());
$this->group1 = uniqid('group_');
$this->group2 = uniqid('group_');
OC_Group::createGroup($this->group1);
OC_Group::createGroup($this->group2);
OC_Group::addToGroup($this->user1, $this->group1);
OC_Group::addToGroup($this->user2, $this->group1);
OC_Group::addToGroup($this->user3, $this->group1);
OC_Group::addToGroup($this->user2, $this->group2);
OC_Group::addToGroup($this->user4, $this->group2);
OCP\Share::registerBackend('test', 'Test_Share_Backend');
OC_Hook::clear('OCP\\Share');
OC::registerShareHooks();
$this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes');
OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
// 20 Minutes in the past, 20 minutes in the future.
$now = time();
$dateFormat = 'Y-m-d H:i:s';
$this->dateInPast = date($dateFormat, $now - 20 * 60);
$this->dateInFuture = date($dateFormat, $now + 20 * 60);
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appManager = \OC::$server->getAppManager();
self::$trashBinStatus = $appManager->isEnabledForUser('files_trashbin');
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
$application = new \OCA\Files_Sharing\AppInfo\Application();
$application->registerMountProviders();
//disable encryption
\OC_App::disable('encryption');
$config = \OC::$server->getConfig();
//configure trashbin
self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', Files_Trashbin\Expiration::DEFAULT_RETENTION_OBLIGATION);
$config->setSystemValue('trashbin_retention_obligation', 'auto, 2');
// register hooks
Files_Trashbin\Trashbin::registerHooks();
// create test user
self::loginHelper(self::TEST_TRASHBIN_USER2, true);
self::loginHelper(self::TEST_TRASHBIN_USER1, true);
}
示例3: run
/**
*
*/
function run()
{
if ($this->checkGet('app', 'usv2')) {
$uid = $this->tokens->getUserId();
if ($uid === false || $uid === null) {
if ($this->appConfig->getValue('user_servervars2', 'stop_if_empty', false)) {
throw new \Exception('token error');
}
// Danger: possibilité de fabriquer une boucle avec janus
$ssoURL = $this->appConfig->getValue('user_servervars2', 'sso_url', 'http://localhost/sso');
$this->redirector->redirectTo($ssoURL);
} else {
$isLoggedIn = $this->uag->isLoggedIn();
if (!$isLoggedIn) {
$isLoggedIn = $this->uag->login($uid);
}
if (!$isLoggedIn) {
// if ( !$this->uag->isLoggedIn()) {
\OC_Log::write('servervars', 'Error trying to log-in the user' . $uid, \OC_Log::DEBUG);
return;
}
\OC::$REQUESTEDAPP = '';
$this->redirector->redirectToDefaultPage();
}
}
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// note: not using a data provider because these
// files all need to coexist to make sure the
// share keys are found properly (pattern matching)
self::$testFiles = array('t est.txt', 't est_.txt', 't est.doc.txt', 't est(.*).txt', 'multiple.dots.can.happen.too.txt', 't est.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.txt', 't est_.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey.txt', 'who would upload their.shareKey', 'user ones file.txt', 'user ones file.txt.backup', '.t est.txt');
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
\OC_Hook::clear('OC_Filesystem');
\OC_Hook::clear('OC_User');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
// Filesystem related hooks
\OCA\Encryption\Helper::registerFilesystemHooks();
// Sharing related hooks
\OCA\Encryption\Helper::registerShareHooks();
// clear and register proxies
\OC_FileProxy::clearProxies();
\OC_FileProxy::register(new OCA\Encryption\Proxy());
// create test user
self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// enable resharing
\OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
// 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\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);
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$application = new Application();
$application->registerMountProviders();
// reset backend
\OC_User::clearBackends();
\OC_Group::clearBackends();
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
// create users
$backend = new \Test\Util\User\Dummy();
\OC_User::useBackend($backend);
$backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
$backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
$backend->createUser(self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER4);
// create group
$groupBackend = new \OC_Group_Dummy();
$groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
$groupBackend->createGroup('group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
\OC_Group::useBackend($groupBackend);
}
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// remember files_encryption state
self::$stateFilesEncryption = \OC_App::isEnabled('files_encryption');
//we don't want to tests with app files_encryption enabled
\OC_App::disable('files_encryption');
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
// create users
$backend = new \OC_User_Dummy();
\OC_User::useBackend($backend);
$backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
$backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
// create group
$groupBackend = new \OC_Group_Dummy();
$groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
$groupBackend->createGroup('group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
\OC_Group::useBackend($groupBackend);
}
示例8: 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);
}
示例9: setUp
public function setUp()
{
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user1 = uniqid('user1_');
$this->user2 = uniqid('user2_');
$this->user3 = uniqid('user3_');
$this->user4 = uniqid('user4_');
OC_User::createUser($this->user1, 'pass');
OC_User::createUser($this->user2, 'pass');
OC_User::createUser($this->user3, 'pass');
OC_User::createUser($this->user4, 'pass');
OC_User::setUserId($this->user1);
OC_Group::clearBackends();
OC_Group::useBackend(new OC_Group_Dummy());
$this->group1 = uniqid('group_');
$this->group2 = uniqid('group_');
OC_Group::createGroup($this->group1);
OC_Group::createGroup($this->group2);
OC_Group::addToGroup($this->user1, $this->group1);
OC_Group::addToGroup($this->user2, $this->group1);
OC_Group::addToGroup($this->user3, $this->group1);
OC_Group::addToGroup($this->user2, $this->group2);
OC_Group::addToGroup($this->user4, $this->group2);
OCP\Share::registerBackend('test', 'Test_Share_Backend');
OC_Hook::clear('OCP\\Share');
OC::registerShareHooks();
}
示例10: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::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
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
self::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);
}
示例11: addRegularTask
/**
* @deprecated 6.0.0
* creates a regular task
* @param string $klass class name
* @param string $method method name
* @return boolean|null
* @since 4.5.0
*/
public static function addRegularTask($klass, $method)
{
if (!\OC::needUpgrade()) {
self::registerJob('OC\\BackgroundJob\\Legacy\\RegularJob', array($klass, $method));
return true;
}
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
// reset backend
\OC_User::clearBackends();
\OC_Group::clearBackends();
// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
\OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
// create users
$backend = new \OC_User_Dummy();
\OC_User::useBackend($backend);
$backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
$backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
// create group
$groupBackend = new \OC_Group_Dummy();
$groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
$groupBackend->createGroup('group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
\OC_Group::useBackend($groupBackend);
}
示例13: testGetAbsoluteURLSubDir
/**
* @small
* test absolute URL construction
* @dataProvider provideSubDirURLs
*/
function testGetAbsoluteURLSubDir($url, $expectedResult)
{
\OC::$WEBROOT = '/owncloud';
$urlGenerator = new \OC\URLGenerator(null);
$result = $urlGenerator->getAbsoluteURL($url);
$this->assertEquals($expectedResult, $result);
}
示例14: tearDown
protected function tearDown()
{
$data = new Data($this->getMock('\\OCP\\Activity\\IManager'), \OC::$server->getDatabaseConnection(), $this->getMock('\\OCP\\IUserSession'));
$this->deleteUser($data, 'activity-api-user1');
$this->deleteUser($data, 'activity-api-user2');
$data->deleteActivities(array('app' => 'app1'));
\OC::$WEBROOT = $this->originalWEBROOT;
parent::tearDown();
}
示例15: execute
/**
* Execute the upgrade command
*
* @param InputInterface $input input interface
* @param OutputInterface $output output interface
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$simulateStepEnabled = true;
$updateStepEnabled = true;
if ($input->getOption('skip-migration-test')) {
$simulateStepEnabled = false;
}
if ($input->getOption('dry-run')) {
$updateStepEnabled = false;
}
if (!$simulateStepEnabled && !$updateStepEnabled) {
$output->writeln('<error>Only one of "--skip-migration-test" or "--dry-run" ' . 'can be specified at a time.</error>');
return self::ERROR_INVALID_ARGUMENTS;
}
if (\OC::checkUpgrade(false)) {
$self = $this;
$updater = new Updater(\OC::$server->getHTTPHelper(), \OC::$server->getAppConfig());
$updater->setSimulateStepEnabled($simulateStepEnabled);
$updater->setUpdateStepEnabled($updateStepEnabled);
$updater->listen('\\OC\\Updater', 'maintenanceStart', function () use($output) {
$output->writeln('<info>Turned on maintenance mode</info>');
});
$updater->listen('\\OC\\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled, $self) {
$output->writeln('<info>Turned off maintenance mode</info>');
$mode = $updateStepEnabled ? 'Update' : 'Update simulation';
$status = $self->upgradeFailed ? 'failed' : 'successful';
$message = "<info>{$mode} {$status}</info>";
$output->writeln($message);
});
$updater->listen('\\OC\\Updater', 'dbUpgrade', function () use($output) {
$output->writeln('<info>Updated database</info>');
});
$updater->listen('\\OC\\Updater', 'dbSimulateUpgrade', function () use($output) {
$output->writeln('<info>Checked database schema update</info>');
});
$updater->listen('\\OC\\Updater', 'disabledApps', function ($appList) use($output) {
$output->writeln('<info>Disabled incompatible apps: ' . implode(', ', $appList) . '</info>');
});
$updater->listen('\\OC\\Updater', 'failure', function ($message) use($output, $self) {
$output->writeln("<error>{$message}</error>");
$self->upgradeFailed = true;
});
$updater->upgrade();
$this->postUpgradeCheck($input, $output);
return self::ERROR_SUCCESS;
} else {
if ($this->config->getSystemValue('maintenance', false)) {
//Possible scenario: ownCloud core is updated but an app failed
$output->writeln('<warning>ownCloud is in maintenance mode</warning>');
$output->write('<comment>Maybe an upgrade is already in process. Please check the ' . 'logfile (data/owncloud.log). If you want to re-run the ' . 'upgrade procedure, remove the "maintenance mode" from ' . 'config.php and call this script again.</comment>', true);
return self::ERROR_MAINTENANCE_MODE;
} else {
$output->writeln('<info>ownCloud is already latest version</info>');
return self::ERROR_UP_TO_DATE;
}
}
}