本文整理汇总了PHP中OC_Config::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Config::setValue方法的具体用法?PHP OC_Config::setValue怎么用?PHP OC_Config::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Config
的用法示例。
在下文中一共展示了OC_Config::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
//clear all proxies and hooks so we can do clean testing
\OC_FileProxy::clearProxies();
\OC_Hook::clear('OC_Filesystem');
//disabled atm
//enable only the encryption hook if needed
//if(OC_App::isEnabled('files_encryption')) {
// OC_FileProxy::register(new OC_FileProxy_Encryption());
//}
//set up temporary storage
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/');
$datadir = str_replace('local::', '', $storage->getId());
$this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
\OC_Config::setValue('cachedirectory', $datadir);
\OC_User::clearBackends();
\OC_User::useBackend(new \OC_User_Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
//set up the users dir
$rootView = new \OC\Files\View('');
$rootView->mkdir('/test');
$this->instance = new \OC\Cache\UserCache();
}
示例2: tearDown
protected function tearDown()
{
\OC_Config::setValue('datadirectory', $this->datadir);
\OC_User::setUserId($this->uid);
\OC_Util::setupFS($this->uid);
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
parent::tearDown();
}
示例3: tearDown
protected function tearDown()
{
\OC_User::setUserId($this->user);
\OC_Config::setValue('cachedirectory', $this->datadir);
// Restore the original mount point
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->storage, array(), '/');
parent::tearDown();
}
示例4: setSystemValue
/**
* Sets a value
* @param string $key key
* @param string $value value
* @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
*/
public static function setSystemValue($key, $value)
{
try {
\OC_Config::setValue($key, $value);
} catch (Exception $e) {
return false;
}
return true;
}
示例5: tearDownAfterClass
public static function tearDownAfterClass()
{
// cleanup test user
\OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
\OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
\OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
\OC_Hook::clear();
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
parent::tearDownAfterClass();
}
示例6: setupDatabase
public function setupDatabase($username)
{
//check if the database user has admin right
$connection = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword);
if (!$connection) {
throw new \OC\DatabaseSetupException($this->trans->t('MySQL/MariaDB username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.'));
}
//user already specified in config
$oldUser = \OC_Config::getValue('dbuser', false);
//we don't have a dbuser specified in config
if ($this->dbuser != $oldUser) {
//add prefix to the admin username to prevent collisions
$adminUser = substr('oc_' . $username, 0, 16);
$i = 1;
while (true) {
//this should be enough to check for admin rights in mysql
$query = "SELECT user FROM mysql.user WHERE user='{$adminUser}'";
$result = mysql_query($query, $connection);
//current dbuser has admin rights
if ($result) {
//new dbuser does not exist
if (mysql_num_rows($result) === 0) {
//use the admin login data for the new database user
$this->dbuser = $adminUser;
//create a random password so we don't need to store the admin password in the config file
$this->dbpassword = \OC_Util::generateRandomBytes(30);
$this->createDBUser($connection);
break;
} else {
//repeat with different username
$length = strlen((string) $i);
$adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
$i++;
}
} else {
break;
}
}
\OC_Config::setValue('dbuser', $this->dbuser);
\OC_Config::setValue('dbpassword', $this->dbpassword);
}
//create the database
$this->createDatabase($connection);
//fill the database if needed
$query = 'select count(*) from information_schema.tables' . " where table_schema='" . $this->dbname . "' AND table_name = '" . $this->tableprefix . "users';";
$result = mysql_query($query, $connection);
if ($result) {
$row = mysql_fetch_row($result);
}
if (!$result or $row[0] == 0) {
\OC_DB::createDbFromStructure($this->dbDefinitionFile);
}
mysql_close($connection);
}
示例7: tearDownAfterClass
public static function tearDownAfterClass()
{
// cleanup test user
\OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
if (self::$encryptionStatus === true) {
\OC_App::enable('files_encryption');
}
\OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
\OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
\OC_Hook::clear();
}
示例8: tearDownAfterClass
public static function tearDownAfterClass()
{
// cleanup test user
\OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
\OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
\OC_Hook::clear();
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
if (self::$trashBinStatus) {
\OC::$server->getAppManager()->enableApp('files_trashbin');
}
parent::tearDownAfterClass();
}
示例9: testIsMaxSizeWorking
public function testIsMaxSizeWorking()
{
$maxX = 250;
$maxY = 250;
\OC_Config::setValue('preview_max_x', $maxX);
\OC_Config::setValue('preview_max_y', $maxY);
$sampleFile = '/' . $this->user . '/files/test.txt';
$this->rootView->file_put_contents($sampleFile, 'dummy file data');
$preview = new \OC\Preview($this->user, 'files/', 'test.txt', 1000, 1000);
$image = $preview->getPreview();
$this->assertEquals($image->width(), $maxX);
$this->assertEquals($image->height(), $maxY);
}
示例10: execute
/**
* Execute the upgrade command
*
* @param InputInterface $input input interface
* @param OutputInterface $output output interface
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
global $RUNTIME_NOAPPS;
$RUNTIME_NOAPPS = true;
//no apps, yet
require_once \OC::$SERVERROOT . '/lib/base.php';
// Don't do anything if ownCloud has not been installed
if (!\OC_Config::getValue('installed', false)) {
$output->writeln('<error>ownCloud has not yet been installed</error>');
return self::ERROR_NOT_INSTALLED;
}
if (\OC::checkUpgrade(false)) {
$updater = new Updater();
$updater->listen('\\OC\\Updater', 'maintenanceStart', function () use($output) {
$output->writeln('<info>Turned on maintenance mode</info>');
});
$updater->listen('\\OC\\Updater', 'maintenanceEnd', function () use($output) {
$output->writeln('<info>Turned off maintenance mode</info>');
$output->writeln('<info>Update successful</info>');
});
$updater->listen('\\OC\\Updater', 'dbUpgrade', function () use($output) {
$output->writeln('<info>Updated database</info>');
});
$updater->listen('\\OC\\Updater', 'filecacheStart', function () use($output) {
$output->writeln('<info>Updating filecache, this may take really long...</info>');
});
$updater->listen('\\OC\\Updater', 'filecacheDone', function () use($output) {
$output->writeln('<info>Updated filecache</info>');
});
$updater->listen('\\OC\\Updater', 'filecacheProgress', function ($out) use($output) {
$output->writeln('... ' . $out . '% done ...');
});
$updater->listen('\\OC\\Updater', 'failure', function ($message) use($output) {
$output->writeln($message);
\OC_Config::setValue('maintenance', false);
});
$updater->upgrade();
$this->postUpgradeCheck($input, $output);
return self::ERROR_SUCCESS;
} else {
if (\OC_Config::getValue('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;
}
}
}
示例11: testMicrosecondsLogTimestamp
public function testMicrosecondsLogTimestamp()
{
# delete old logfile
unlink(OC_Config::getValue('logfile'));
# set format & write log line
OC_Config::setValue('logdateformat', 'u');
OC_Log_Owncloud::write('test', 'message', \OCP\Util::ERROR);
# read log line
$handle = @fopen(OC_Config::getValue('logfile'), 'r');
$line = fread($handle, 1000);
fclose($handle);
# check timestamp has microseconds part
$values = (array) json_decode($line);
$microseconds = $values['time'];
$this->assertNotEquals(0, $microseconds);
}
示例12: testFindLanguage
/**
* @dataProvider findLanguageData
*/
public function testFindLanguage($default, $preference, $expected)
{
OC_User::setUserId(null);
if (is_null($default)) {
OC_Config::deleteKey('default_language');
} else {
OC_Config::setValue('default_language', $default);
}
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $preference;
$reflection = new \ReflectionClass('OC_L10N');
$prop = $reflection->getProperty('language');
$prop->setAccessible(1);
$prop->setValue('');
$prop->setAccessible(0);
$this->assertSame($expected, OC_L10N::findLanguage());
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('on')) {
\OC_Config::setValue('singleuser', true);
$output->writeln('Single user mode enabled');
} elseif ($input->getOption('off')) {
\OC_Config::setValue('singleuser', false);
$output->writeln('Single user mode disabled');
} else {
if (\OC_Config::getValue('singleuser', false)) {
$output->writeln('Single user mode is currently enabled');
} else {
$output->writeln('Single user mode is currently disabled');
}
}
}
示例14: initialize
public function initialize($config)
{
$dbuser = $config['dbuser'];
$dbpass = $config['dbpass'];
$dbname = $config['dbname'];
$dbhost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
$dbtableprefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
\OC_Config::setValue('dbname', $dbname);
\OC_Config::setValue('dbhost', $dbhost);
\OC_Config::setValue('dbtableprefix', $dbtableprefix);
$this->dbuser = $dbuser;
$this->dbpassword = $dbpass;
$this->dbname = $dbname;
$this->dbhost = $dbhost;
$this->tableprefix = $dbtableprefix;
}
示例15: testCheckServerSkipDataDirValidityOnUpgrade
/**
* Test that checkServer() does not check the data dir validity
* when an upgrade is required (else the upgrade cannot be
* performed...)
*/
public function testCheckServerSkipDataDirValidityOnUpgrade()
{
// simulate old version that didn't have it
unlink($this->datadir . '/.ocdata');
$session = \OC::$server->getSession();
$oldCurrentVersion = $session->get('OC_Version');
$oldInstallVersion = \OC_Config::getValue('version', '0.0.0');
// upgrade condition to simulate needUpgrade() === true
$session->set('OC_Version', array(6, 0, 0, 2));
\OC_Config::setValue('version', '6.0.0.1');
// even though ".ocdata" is missing, the error isn't
// triggered to allow for upgrade
$result = \OC_Util::checkServer();
$this->assertEmpty($result);
// restore versions
$session->set('OC_Version', $oldCurrentVersion);
\OC_Config::setValue('version', $oldInstallVersion);
}