本文整理汇总了PHP中OC_App类的典型用法代码示例。如果您正苦于以下问题:PHP OC_App类的具体用法?PHP OC_App怎么用?PHP OC_App使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_App类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApps
/**
* @param array $parameters
* @return OC_OCS_Result
*/
public function getApps($parameters)
{
$apps = OC_App::listAllApps();
$list = [];
foreach ($apps as $app) {
$list[] = $app['id'];
}
$filter = isset($_GET['filter']) ? $_GET['filter'] : false;
if ($filter) {
switch ($filter) {
case 'enabled':
return new OC_OCS_Result(array('apps' => \OC_App::getEnabledApps()));
break;
case 'disabled':
$enabled = OC_App::getEnabledApps();
return new OC_OCS_Result(array('apps' => array_diff($list, $enabled)));
break;
default:
// Invalid filter variable
return new OC_OCS_Result(null, 101);
break;
}
} else {
return new OC_OCS_Result(array('apps' => $list));
}
}
示例2: setUp
public function setUp()
{
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable on travis');
}
\OC_App::disable('files_sharing');
\OC_App::disable('files_versions');
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
\OC_User::deleteUser($userName);
\OC_User::createUser($userName, $userName);
}
// main test user
$userName = 'test';
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7);
$params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName));
$this->objectStorage = new ObjectStoreToTest($params);
$params['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($params);
}
示例3: enableApp
function enableApp($app) {
try {
OC_App::enable($app);
} catch (Exception $e) {
echo $e;
}
}
示例4: unlink
/**
* Deletes the given file by moving it into the trashbin.
*
* @param string $path
*/
public function unlink($path)
{
if (self::$disableTrash || !\OC_App::isEnabled('files_trashbin')) {
return $this->storage->unlink($path);
}
$normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
$result = true;
if (!isset($this->deletedFiles[$normalized])) {
$view = Filesystem::getView();
$this->deletedFiles[$normalized] = $normalized;
if ($filesPath = $view->getRelativePath($normalized)) {
$filesPath = trim($filesPath, '/');
$result = \OCA\Files_Trashbin\Trashbin::move2trash($filesPath);
// in cross-storage cases the file will be copied
// but not deleted, so we delete it here
if ($result) {
$this->storage->unlink($path);
}
} else {
$result = $this->storage->unlink($path);
}
unset($this->deletedFiles[$normalized]);
} else {
if ($this->storage->file_exists($path)) {
$result = $this->storage->unlink($path);
}
}
return $result;
}
示例5: doFind
/**
* @param string $script
*/
public function doFind($script)
{
$theme_dir = 'themes/' . $this->theme . '/';
if (strpos($script, '3rdparty') === 0 && $this->appendIfExist($this->thirdpartyroot, $script . '.js')) {
return;
}
if (strpos($script, '/l10n/') !== false) {
// For language files we try to load them all, so themes can overwrite
// single l10n strings without having to translate all of them.
$found = 0;
$found += $this->appendIfExist($this->serverroot, 'core/' . $script . '.js');
$found += $this->appendIfExist($this->serverroot, $theme_dir . 'core/' . $script . '.js');
$found += $this->appendIfExist($this->serverroot, $script . '.js');
$found += $this->appendIfExist($this->serverroot, $theme_dir . $script . '.js');
$found += $this->appendIfExist($this->serverroot, $theme_dir . 'apps/' . $script . '.js');
if ($found) {
return;
}
} else {
if ($this->appendIfExist($this->serverroot, $theme_dir . 'apps/' . $script . '.js') || $this->appendIfExist($this->serverroot, $theme_dir . $script . '.js') || $this->appendIfExist($this->serverroot, $script . '.js') || $this->appendIfExist($this->serverroot, $theme_dir . 'core/' . $script . '.js') || $this->appendIfExist($this->serverroot, 'core/' . $script . '.js')) {
return;
}
}
$app = substr($script, 0, strpos($script, '/'));
$script = substr($script, strpos($script, '/') + 1);
$app_path = \OC_App::getAppPath($app);
$app_url = \OC_App::getAppWebPath($app);
// missing translations files fill be ignored
if (strpos($script, 'l10n/') === 0) {
$this->appendIfExist($app_path, $script . '.js', $app_url);
return;
}
$this->append($app_path, $script . '.js', $app_url);
}
示例6: update
public function update($tmpDir = '') {
Helper::mkdir($tmpDir, true);
$this->collect();
try {
foreach ($this->appsToUpdate as $appId) {
if (!@file_exists($this->newBase . '/' . $appId)){
continue;
}
$path = \OC_App::getAppPath($appId);
if ($path) {
Helper::move($path, $tmpDir . '/' . $appId);
// ! reverted intentionally
$this->done [] = array(
'dst' => $path,
'src' => $tmpDir . '/' . $appId
);
Helper::move($this->newBase . '/' . $appId, $path);
} else {
// The app is new and doesn't exist in the current instance
$pathData = first(\OC::$APPSROOTS);
Helper::move($this->newBase . '/' . $appId, $pathData['path'] . '/' . $appId);
}
}
$this->finalize();
} catch (\Exception $e) {
$this->rollback(true);
throw $e;
}
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('shipped') === 'true' || $input->getOption('shipped') === 'false') {
$shouldFilterShipped = true;
$shippedFilter = $input->getOption('shipped') === 'true';
} else {
$shouldFilterShipped = false;
}
$apps = \OC_App::getAllApps();
$enabledApps = $disabledApps = [];
$versions = \OC_App::getAppVersions();
//sort enabled apps above disabled apps
foreach ($apps as $app) {
if ($shouldFilterShipped && \OC_App::isShipped($app) !== $shippedFilter) {
continue;
}
if (\OC_App::isEnabled($app)) {
$enabledApps[] = $app;
} else {
$disabledApps[] = $app;
}
}
$apps = ['enabled' => [], 'disabled' => []];
sort($enabledApps);
foreach ($enabledApps as $app) {
$apps['enabled'][$app] = isset($versions[$app]) ? $versions[$app] : true;
}
sort($disabledApps);
foreach ($disabledApps as $app) {
$apps['disabled'][$app] = null;
}
$this->writeAppList($input, $output, $apps);
}
示例8: call
/**
* handles an api call
* @param array $parameters
*/
public static function call($parameters)
{
$request = \OC::$server->getRequest();
$method = $request->getMethod();
// Prepare the request variables
if ($method === 'PUT') {
$parameters['_put'] = $request->getParams();
} else {
if ($method === 'DELETE') {
$parameters['_delete'] = $request->getParams();
}
}
$name = $parameters['_route'];
// Foreach registered action
$responses = array();
foreach (self::$actions[$name] as $action) {
// Check authentication and availability
if (!self::isAuthorised($action)) {
$responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised'), 'shipped' => OC_App::isShipped($action['app']));
continue;
}
if (!is_callable($action['action'])) {
$responses[] = array('app' => $action['app'], 'response' => new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'Api method not found'), 'shipped' => OC_App::isShipped($action['app']));
continue;
}
// Run the action
$responses[] = array('app' => $action['app'], 'response' => call_user_func($action['action'], $parameters), 'shipped' => OC_App::isShipped($action['app']));
}
$response = self::mergeResponses($responses);
$format = self::requestedFormat();
if (self::$logoutRequired) {
OC_User::logout();
}
self::respond($response, $format);
}
示例9: finalize
protected function finalize()
{
foreach ($this->appsToDisable as $appId) {
\OC_App::disable($appId);
}
parent::finalize();
}
示例10: loadCommands
/**
* @param OutputInterface $output
*/
public function loadCommands(OutputInterface $output)
{
// $application is required to be defined in the register_command scripts
$application = $this->application;
require_once \OC::$SERVERROOT . '/core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if (!\OCP\Util::needUpgrade()) {
OC_App::loadApps();
foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
$appPath = \OC_App::getAppPath($app);
\OC::$loader->addValidRoot($appPath);
$file = $appPath . '/appinfo/register_command.php';
if (file_exists($file)) {
require $file;
}
}
} else {
$output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
}
} else {
$output->writeln("ownCloud is not installed - only a limited number of commands are available");
}
$input = new ArgvInput();
if ($input->getFirstArgument() !== 'check') {
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
if (!empty($errors)) {
foreach ($errors as $error) {
$output->writeln((string) $error['error']);
$output->writeln((string) $error['hint']);
$output->writeln('');
}
throw new \Exception("Environment not properly prepared.");
}
}
}
示例11: 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);
}
示例12: sendEmail
public static function sendEmail($args)
{
$isEncrypted = OC_App::isEnabled('files_encryption');
if (!$isEncrypted || isset($_POST['continue'])) {
$continue = true;
} else {
$continue = false;
}
if (OC_User::userExists($_POST['user']) && $continue) {
$token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
// Hash the token again to prevent timing attacks
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {
$link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
$link = OC_Helper::makeURLAbsolute($link);
$tmpl = new OC_Template('core/lostpassword', 'email');
$tmpl->assign('link', $link, false);
$msg = $tmpl->fetchPage();
$l = OC_L10N::get('core');
$from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
try {
OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
} catch (Exception $e) {
OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
}
self::displayLostPasswordPage(false, true);
} else {
self::displayLostPasswordPage(true, false);
}
} else {
self::displayLostPasswordPage(true, false);
}
}
示例13: checkAppEnabled
/**
* Check if the app is enabled, send json error msg if not
*/
public static function checkAppEnabled($app) {
if( !OC_App::isEnabled($app)) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') )));
exit();
}
}
示例14: showShare
public static function showShare($args)
{
\OC_Util::checkAppEnabled('files_sharing');
$token = $args['token'];
\OC_App::loadApp('files_sharing');
\OC_User::setIncognitoMode(true);
require_once \OC_App::getAppPath('files_sharing') . '/public.php';
}
示例15: analyse
/**
* @param string $appId
* @return array
*/
public function analyse($appId)
{
$appPath = \OC_App::getAppPath($appId);
if ($appPath === false) {
throw new \RuntimeException("No app with given id <{$appId}> known.");
}
return $this->analyseFolder($appPath);
}