本文整理汇总了PHP中OCP\IConfig::setSystemValue方法的典型用法代码示例。如果您正苦于以下问题:PHP IConfig::setSystemValue方法的具体用法?PHP IConfig::setSystemValue怎么用?PHP IConfig::setSystemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IConfig
的用法示例。
在下文中一共展示了IConfig::setSystemValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
public function __destruct()
{
$this->config->setSystemValue('singleuser', $this->wasSingleUserModeEnabled);
if ($this->wasTrashbinEnabled) {
$this->appManager->enableApp('files_trashbin');
}
}
示例2: resetSingleUserAndTrashbin
/**
* Reset the single user mode and re-enable the trashbin app
*/
protected function resetSingleUserAndTrashbin()
{
$this->config->setSystemValue('singleuser', $this->wasSingleUserModeEnabled);
if ($this->wasTrashbinEnabled) {
$this->appManager->enableApp('files_trashbin');
}
}
示例3: trustedDomains
/**
* Add a new trusted domain
* @param string $newTrustedDomain The newly to add trusted domain
* @return array
*/
public function trustedDomains($newTrustedDomain)
{
$trustedDomains = $this->config->getSystemValue('trusted_domains');
$trustedDomains[] = $newTrustedDomain;
$this->config->setSystemValue('trusted_domains', $trustedDomains);
return $this->returnSuccess();
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$includeExpensive = $input->getOption('include-expensive');
if ($includeExpensive) {
foreach ($this->repair->getExpensiveRepairSteps() as $step) {
$this->repair->addStep($step);
}
}
$maintenanceMode = $this->config->getSystemValue('maintenance', false);
$this->config->setSystemValue('maintenance', true);
$this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'warning', function ($description) use($output) {
$output->writeln(' - WARNING: ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
$output->writeln(' - ERROR: ' . $description);
});
$this->repair->run();
$this->config->setSystemValue('maintenance', $maintenanceMode);
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// collate config setting to the end, to avoid partial configuration
$toBeSet = [];
if ($backend = $input->getOption('backend')) {
$this->validateBackend($backend);
$toBeSet['log_type'] = $backend;
}
if ($level = $input->getOption('level')) {
if (is_numeric($level)) {
$levelNum = $level;
// sanity check
$this->convertLevelNumber($levelNum);
} else {
$levelNum = $this->convertLevelString($level);
}
$toBeSet['loglevel'] = $levelNum;
}
if ($timezone = $input->getOption('timezone')) {
$this->validateTimezone($timezone);
$toBeSet['logtimezone'] = $timezone;
}
// set config
foreach ($toBeSet as $option => $value) {
$this->config->setSystemValue($option, $value);
}
// display configuration
$backend = $this->config->getSystemValue('log_type', self::DEFAULT_BACKEND);
$output->writeln('Enabled logging backend: ' . $backend);
$levelNum = $this->config->getSystemValue('loglevel', self::DEFAULT_LOG_LEVEL);
$level = $this->convertLevelNumber($levelNum);
$output->writeln('Log level: ' . $level . ' (' . $levelNum . ')');
$timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE);
$output->writeln('Log timezone: ' . $timezone);
}
示例6: setLogLevel
/**
* set log level for logger
*
* @param int $level
* @return JSONResponse
*/
public function setLogLevel($level)
{
if ($level < 0 || $level > 4) {
return new JSONResponse(['message' => (string) $this->l10n->t('log-level out of allowed range')], Http::STATUS_BAD_REQUEST);
}
$this->config->setSystemValue('loglevel', $level);
return new JSONResponse(['level' => $level]);
}
示例7: createCredentials
/**
* @return DataResponse
*/
public function createCredentials()
{
// Create a new job and store the creation date
$this->jobList->add('OCA\\UpdateNotification\\ResetTokenBackgroundJob');
$this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
// Create a new token
$newToken = $this->secureRandom->generate(64);
$this->config->setSystemValue('updater.secret', password_hash($newToken, PASSWORD_DEFAULT));
return new DataResponse($newToken);
}
示例8: prepareSettings
/**
* @param string $dataDir
* @param string $userId
* @throws \Exception
*/
function prepareSettings($dataDir, $userId)
{
// hard-coded string as we want a predictable fixed length
// no data will be written there
$this->dataDir = $dataDir;
$this->config->setSystemValue('datadirectory', $this->dataDir);
$this->user = $userId;
$this->legacyStorageId = 'local::' . $this->dataDir . $this->user . '/';
$this->newStorageId = 'home::' . $this->user;
\OC::$server->getUserManager()->createUser($this->user, $this->user);
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('on')) {
$this->config->setSystemValue('maintenance', true);
$output->writeln('Maintenance mode enabled');
} elseif ($input->getOption('off')) {
$this->config->setSystemValue('maintenance', false);
$output->writeln('Maintenance mode disabled');
} else {
if ($this->config->getSystemValue('maintenance', false)) {
$output->writeln('Maintenance mode is currently enabled');
} else {
$output->writeln('Maintenance mode is currently disabled');
}
}
}
示例10: testStreamDecryptLongFileContentWithoutHeader
/**
* @medium
* Test that data that is written by the crypto stream wrapper with AES 128
* @note Encrypted data is manually prepared and decrypted here to avoid dependency on success of stream_read
* @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual
* reassembly of its data
*/
public function testStreamDecryptLongFileContentWithoutHeader()
{
// Generate a a random filename
$filename = 'tmp-' . $this->getUniqueID() . '.test';
$this->config->setSystemValue('cipher', 'AES-128-CFB');
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong . $this->dataLong);
$this->config->deleteSystemValue('cipher');
// Test that data was successfully written
$this->assertTrue(is_int($cryptedFile));
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
// Get file contents without using any wrapper to get it's actual contents on disk
$retreivedCryptedFile = $this->view->file_get_contents($this->userId . '/files/' . $filename);
// Check that the file was encrypted before being written to disk
$this->assertNotEquals($this->dataLong . $this->dataLong, $retreivedCryptedFile);
// remove the header to check if we can also decrypt old files without a header,
// this files should fall back to AES-128
$cryptedWithoutHeader = substr($retreivedCryptedFile, \OCA\Files_Encryption\Crypt::BLOCKSIZE);
$this->view->file_put_contents($this->userId . '/files/' . $filename, $cryptedWithoutHeader);
// Re-enable proxy - our work is done
\OC_FileProxy::$enabled = $proxyStatus;
$decrypted = file_get_contents('crypt:///' . $this->userId . '/files/' . $filename);
$this->assertEquals($this->dataLong . $this->dataLong, $decrypted);
// Teardown
$this->view->unlink($this->userId . '/files/' . $filename);
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$maintenanceMode = $this->config->getSystemValue('maintenance', false);
$this->config->setSystemValue('maintenance', true);
$this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
$output->writeln(' - ' . $description);
});
$this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
$output->writeln(' - ERROR: ' . $description);
});
$this->repair->run();
$this->config->setSystemValue('maintenance', $maintenanceMode);
}
示例12: doUpgrade
/**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
* @param string $currentVersion current version to upgrade to
* @param string $installedVersion previous version from which to upgrade from
*
* @throws \Exception
*/
private function doUpgrade($currentVersion, $installedVersion)
{
// Stop update if the update is over several major versions
$allowedPreviousVersion = $this->getAllowedPreviousVersion();
if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) {
throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
}
// Update .htaccess files
try {
Setup::updateHtaccess();
Setup::protectDataDirectory();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)
file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
$repair->run();
// simulate DB upgrade
if ($this->simulateStepEnabled) {
$this->checkCoreUpgrade();
// simulate apps DB upgrade
$this->checkAppUpgrade($currentVersion);
}
if ($this->updateStepEnabled) {
$this->doCoreUpgrade();
// update all shipped apps
$disabledApps = $this->checkAppsRequirements();
$this->doAppUpgrade();
// upgrade appstore apps
$this->upgradeAppStoreApps($disabledApps);
// install new shipped apps on upgrade
OC_App::loadApps('authentication');
$errors = Installer::installShippedApps(true);
foreach ($errors as $appId => $exception) {
/** @var \Exception $exception */
$this->log->logException($exception, ['app' => $appId]);
$this->emit('\\OC\\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
}
// post-upgrade repairs
$repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
$repair->run();
//Invalidate update feed
$this->config->setAppValue('core', 'lastupdatedat', 0);
// Check for code integrity if not disabled
if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
$this->emit('\\OC\\Updater', 'startCheckCodeIntegrity');
$this->checker->runInstanceVerification();
$this->emit('\\OC\\Updater', 'finishedCheckCodeIntegrity');
}
// only set the final version if everything went well
$this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion()));
}
}
示例13: doUpgrade
/**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
* @param string $currentVersion current version to upgrade to
* @param string $installedVersion previous version from which to upgrade from
*
* @throws \Exception
* @return bool true if the operation succeeded, false otherwise
*/
private function doUpgrade($currentVersion, $installedVersion) {
// Stop update if the update is over several major versions
if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
throw new \Exception('Updates between multiple major versions are unsupported.');
}
// Update .htaccess files
try {
Setup::updateHtaccess();
Setup::protectDataDirectory();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)
file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
$this->emitRepairMessages($repair);
$repair->run();
// simulate DB upgrade
if ($this->simulateStepEnabled) {
$this->checkCoreUpgrade();
// simulate apps DB upgrade
$this->checkAppUpgrade($currentVersion);
}
if ($this->updateStepEnabled) {
$this->doCoreUpgrade();
// update all shipped apps
$disabledApps = $this->checkAppsRequirements();
$this->doAppUpgrade();
// upgrade appstore apps
$this->upgradeAppStoreApps($disabledApps);
// post-upgrade repairs
$repair = new Repair(Repair::getRepairSteps());
$this->emitRepairMessages($repair);
$repair->run();
//Invalidate update feed
$this->config->setAppValue('core', 'lastupdatedat', 0);
// only set the final version if everything went well
$this->config->setSystemValue('version', implode('.', \OC_Util::getVersion()));
}
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$toBeSet = [];
if ($input->getOption('enable')) {
$toBeSet['log_type'] = 'owncloud';
}
if ($file = $input->getOption('file')) {
$toBeSet['logfile'] = $file;
}
if (($rotateSize = $input->getOption('rotate-size')) !== null) {
$rotateSize = \OCP\Util::computerFileSize($rotateSize);
$this->validateRotateSize($rotateSize);
$toBeSet['log_rotate_size'] = $rotateSize;
}
// set config
foreach ($toBeSet as $option => $value) {
$this->config->setSystemValue($option, $value);
}
// display config
if ($this->config->getSystemValue('log_type', 'owncloud') === 'owncloud') {
$enabledText = 'enabled';
} else {
$enabledText = 'disabled';
}
$output->writeln('Log backend ownCloud: ' . $enabledText);
$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$defaultLogFile = rtrim($dataDir, '/') . '/owncloud.log';
$output->writeln('Log file: ' . $this->config->getSystemValue('logfile', $defaultLogFile));
$rotateSize = $this->config->getSystemValue('log_rotate_size', 0);
if ($rotateSize) {
$rotateString = \OCP\Util::humanFileSize($rotateSize);
} else {
$rotateString = 'disabled';
}
$output->writeln('Rotate at: ' . $rotateString);
}
示例15: saveDBInfo
protected function saveDBInfo(InputInterface $input)
{
$type = $input->getArgument('type');
$username = $input->getArgument('username');
$dbhost = $input->getArgument('hostname');
$dbname = $input->getArgument('database');
$password = $input->getOption('password');
if ($input->getOption('port')) {
$dbhost .= ':' . $input->getOption('port');
}
$this->config->setSystemValue('dbtype', $type);
$this->config->setSystemValue('dbname', $dbname);
$this->config->setSystemValue('dbhost', $dbhost);
$this->config->setSystemValue('dbuser', $username);
$this->config->setSystemValue('dbpassword', $password);
}