本文整理汇总了PHP中OCP\Config::setSystemValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setSystemValue方法的具体用法?PHP Config::setSystemValue怎么用?PHP Config::setSystemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\Config
的用法示例。
在下文中一共展示了Config::setSystemValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareSettings
function prepareSettings($dataDir, $userId)
{
// hard-coded string as we want a predictable fixed length
// no data will be written there
$this->dataDir = $dataDir;
\OCP\Config::setSystemValue('datadirectory', $this->dataDir);
$this->user = $userId;
$this->legacyStorageId = 'local::' . $this->dataDir . $this->user . '/';
$this->newStorageId = 'home::' . $this->user;
\OC_User::createUser($this->user, $this->user);
}
示例2: 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';
\OCP\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);
\OCP\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, 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);
Encryption\Keymanager::deleteFileKey($this->view, $filename);
}
示例3: testDefaultApps
/**
* Test default apps
*
* @dataProvider defaultAppsProvider
*/
function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps)
{
$oldDefaultApps = \OCP\Config::getSystemValue('core', 'defaultapp', '');
// CLI is doing messy stuff with the webroot, so need to work it around
$oldWebRoot = \OC::$WEBROOT;
\OC::$WEBROOT = '';
Dummy_OC_App::setEnabledApps($enabledApps);
\OCP\Config::setSystemValue('defaultapp', $defaultAppConfig);
$this->assertEquals('http://localhost/' . $expectedPath, \OC_Util::getDefaultPageUrl());
// restore old state
\OC::$WEBROOT = $oldWebRoot;
Dummy_OC_App::restore();
\OCP\Config::setSystemValue('defaultapp', $oldDefaultApps);
}
示例4: setSystemValue
/**
* Sets a new system wide value
*
* @param string $key the key of the value, under which will be saved
* @param mixed $value the value that should be stored
*/
public function setSystemValue($key, $value) {
\OCP\Config::setSystemValue($key, $value);
}
示例5: testDefaultApps
/**
* Test default apps
*
* @dataProvider defaultAppsProvider
*/
function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps)
{
$oldDefaultApps = \OCP\Config::getSystemValue('defaultapp', '');
// CLI is doing messy stuff with the webroot, so need to work it around
$oldWebRoot = \OC::$WEBROOT;
\OC::$WEBROOT = '';
$appManager = $this->getMock('\\OCP\\App\\IAppManager');
$appManager->expects($this->any())->method('isEnabledForUser')->will($this->returnCallback(function ($appId) use($enabledApps) {
return in_array($appId, $enabledApps);
}));
Dummy_OC_Util::$appManager = $appManager;
// need to set a user id to make sure enabled apps are read from cache
\OC_User::setUserId($this->getUniqueID());
\OCP\Config::setSystemValue('defaultapp', $defaultAppConfig);
$this->assertEquals('http://localhost/' . $expectedPath, Dummy_OC_Util::getDefaultPageUrl());
// restore old state
\OC::$WEBROOT = $oldWebRoot;
\OCP\Config::setSystemValue('defaultapp', $oldDefaultApps);
\OC_User::setUserId(null);
}
示例6:
<?php
$state = \OCP\Config::getSystemValue('markup_configuration_history', 'doSet');
if ($state === 'doSet') {
\OCP\Config::setSystemValue('markup_configuration_history', true);
}
示例7: setShareFolder
/**
* set default share folder
*
* @param string $shareFolder
*/
public static function setShareFolder($shareFolder)
{
\OCP\Config::setSystemValue('share_folder', $shareFolder);
}
示例8: setPreview
/**
* @brief enable/disable preview for selected format
*
* @param string format
* @param bool enable (true = enable, false = disable, default = false)
* @return bool
*/
public static function setPreview($format, $enable = 'false')
{
$enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null);
if ($enable == 'true') {
if ($enablePreviewProviders === null) {
// set up default providers
$enablePreviewProviders = array();
array_push($enablePreviewProviders, 'OC\\Preview\\Image', 'OC\\Preview\\MP3', 'OC\\Preview\\TXT', 'OC\\Preview\\MarkDown');
}
if (!in_array($format, $enablePreviewProviders)) {
array_push($enablePreviewProviders, $format);
}
} else {
if (!($enablePreviewProviders == null)) {
$enablePreviewProviders = array_diff($enablePreviewProviders, array($format));
}
}
if (!\OCP\Config::setSystemValue('enabledPreviewProviders', $enablePreviewProviders)) {
logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
return true;
}
}