本文整理汇总了PHP中OC_Appconfig::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Appconfig::setValue方法的具体用法?PHP OC_Appconfig::setValue怎么用?PHP OC_Appconfig::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Appconfig
的用法示例。
在下文中一共展示了OC_Appconfig::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: check
/**
* Check if a new version is available
* @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
* @return array | bool
*/
public function check($updaterUrl)
{
// Look up the cache - it is invalidated all 30 minutes
if (\OC_Appconfig::getValue('core', 'lastupdatedat') + 1800 > time()) {
return json_decode(\OC_Appconfig::getValue('core', 'lastupdateResult'), true);
}
\OC_Appconfig::setValue('core', 'lastupdatedat', time());
if (\OC_Appconfig::getValue('core', 'installedat', '') == '') {
\OC_Appconfig::setValue('core', 'installedat', microtime(true));
}
$version = \OC_Util::getVersion();
$version['installed'] = \OC_Appconfig::getValue('core', 'installedat');
$version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat');
$version['updatechannel'] = \OC_Util::getChannel();
$version['edition'] = \OC_Util::getEditionString();
$version['build'] = \OC_Util::getBuild();
$versionString = implode('x', $version);
//fetch xml data from updater
$url = $updaterUrl . '?version=' . $versionString;
// set a sensible timeout of 10 sec to stay responsive even if the update server is down.
$ctx = stream_context_create(array('http' => array('timeout' => 10)));
$xml = @file_get_contents($url, 0, $ctx);
if ($xml == false) {
return array();
}
$data = @simplexml_load_string($xml);
$tmp = array();
$tmp['version'] = $data->version;
$tmp['versionstring'] = $data->versionstring;
$tmp['url'] = $data->url;
$tmp['web'] = $data->web;
// Cache the result
\OC_Appconfig::setValue('core', 'lastupdateResult', json_encode($data));
return $tmp;
}
示例3: check
/**
* Check if a new version is available
*/
public static function check()
{
OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
if (OC_Appconfig::getValue('core', 'installedat', '') == '') {
OC_Appconfig::setValue('core', 'installedat', microtime(true));
}
$updaterurl = 'http://apps.owncloud.com/updater.php';
$version = OC_Util::getVersion();
$version['installed'] = OC_Appconfig::getValue('core', 'installedat');
$version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
$version['updatechannel'] = 'stable';
$version['edition'] = OC_Util::getEditionString();
$versionstring = implode('x', $version);
//fetch xml data from updater
$url = $updaterurl . '?version=' . $versionstring;
// set a sensible timeout of 10 sec to stay responsive even if the update server is down.
$ctx = stream_context_create(array('http' => array('timeout' => 10)));
$xml = @file_get_contents($url, 0, $ctx);
if ($xml == false) {
return array();
}
$data = @simplexml_load_string($xml);
$tmp = array();
$tmp['version'] = $data->version;
$tmp['versionstring'] = $data->versionstring;
$tmp['url'] = $data->url;
$tmp['web'] = $data->web;
return $tmp;
}
示例4: check
/**
* Check if a new version is available
*/
public static function check()
{
OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
if (OC_Appconfig::getValue('core', 'installedat', '') == '') {
OC_Appconfig::setValue('core', 'installedat', microtime(true));
}
$updaterurl = 'http://apps.owncloud.com/updater.php';
$version = OC_Util::getVersion();
$version['installed'] = OC_Appconfig::getValue('core', 'installedat');
$version['updated'] = OC_Appconfig::getValue('core', 'lastupdatedat');
$version['updatechannel'] = 'stable';
$version['edition'] = OC_Util::getEditionString();
$versionstring = implode('x', $version);
//fetch xml data from updater
$url = $updaterurl . '?version=' . $versionstring;
$xml = @file_get_contents($url);
if ($xml == FALSE) {
return array();
}
$data = @simplexml_load_string($xml);
$tmp = array();
$tmp['version'] = $data->version;
$tmp['versionstring'] = $data->versionstring;
$tmp['url'] = $data->url;
$tmp['web'] = $data->web;
return $tmp;
}
示例5: setExecutionType
/**
* sets the background jobs execution type
* @param string $type execution type
* @return false|null
*
* This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
*/
public static function setExecutionType($type)
{
if (!in_array($type, array('none', 'ajax', 'webcron', 'cron'))) {
return false;
}
return OC_Appconfig::setValue('core', 'backgroundjobs_mode', $type);
}
示例6: testSetValue
public function testSetValue()
{
\OC_Appconfig::setValue('testapp', 'installed_version', '1.33.7');
$query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?');
$result = $query->execute(array('testapp', 'installed_version'));
$value = $result->fetchRow();
$this->assertEquals('1.33.7', $value['configvalue']);
\OC_Appconfig::setValue('someapp', 'somekey', 'somevalue');
$query = \OC_DB::prepare('SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?');
$result = $query->execute(array('someapp', 'somekey'));
$value = $result->fetchRow();
$this->assertEquals('somevalue', $value['configvalue']);
}
示例7: checkNext
public static function checkNext()
{
// check both 1 file and 1 folder, this way new files are detected quicker because there are less folders than files usually
$previousFile = \OC_Appconfig::getValue('files', 'backgroundwatcher_previous_file', 0);
$previousFolder = \OC_Appconfig::getValue('files', 'backgroundwatcher_previous_folder', 0);
$nextFile = self::getNextFileId($previousFile, false);
$nextFolder = self::getNextFileId($previousFolder, true);
\OC_Appconfig::setValue('files', 'backgroundwatcher_previous_file', $nextFile);
\OC_Appconfig::setValue('files', 'backgroundwatcher_previous_folder', $nextFolder);
if ($nextFile > 0) {
self::checkUpdate($nextFile);
}
if ($nextFolder > 0) {
self::checkUpdate($nextFolder);
}
}
示例8: __construct
/**
* @brief if session is started, check if ownCloud key pair is set up, if not create it
* @param \OC_FilesystemView $view
*
* @note The ownCloud key pair is used to allow public link sharing even if encryption is enabled
*/
public function __construct($view)
{
$this->view = $view;
if (!$this->view->is_dir('owncloud_private_key')) {
$this->view->mkdir('owncloud_private_key');
}
$publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId');
if ($publicShareKeyId === null) {
$publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8);
\OC_Appconfig::setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId);
}
if (!$this->view->file_exists("/public-keys/" . $publicShareKeyId . ".public.key") || !$this->view->file_exists("/owncloud_private_key/" . $publicShareKeyId . ".private.key")) {
$keypair = Crypt::createKeypair();
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
// Save public key
if (!$view->is_dir('/public-keys')) {
$view->mkdir('/public-keys');
}
$this->view->file_put_contents('/public-keys/' . $publicShareKeyId . '.public.key', $keypair['publicKey']);
// Encrypt private key empty passphrase
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], '');
// Save private key
$this->view->file_put_contents('/owncloud_private_key/' . $publicShareKeyId . '.private.key', $encryptedPrivateKey);
\OC_FileProxy::$enabled = $proxyStatus;
}
if (\OCA\Encryption\Helper::isPublicAccess()) {
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$encryptedKey = $this->view->file_get_contents('/owncloud_private_key/' . $publicShareKeyId . '.private.key');
$privateKey = Crypt::decryptPrivateKey($encryptedKey, '');
$this->setPublicSharePrivateKey($privateKey);
\OC_FileProxy::$enabled = $proxyStatus;
}
}
示例9: getParams
public function getParams()
{
$array = array();
foreach ($this->params as $key => $param) {
$array[$param] = OC_Appconfig::getValue('user_wordpress', $param, '');
}
if (empty($array['wordpress_db_host'])) {
$array['wordpress_db_host'] = OC_Config::getValue("dbhost", "");
}
if (empty($array['wordpress_db_name'])) {
$array['wordpress_db_name'] = OC_Config::getValue("dbname", "owncloud");
}
if (empty($array['wordpress_db_user'])) {
$array['wordpress_db_user'] = OC_Config::getValue("dbuser", "");
}
if (empty($array['wordpress_db_password'])) {
$array['wordpress_db_password'] = OC_Config::getValue("dbpassword", "");
}
if (empty($array['wordpress_have_to_be_logged'])) {
$array['wordpress_have_to_be_logged'] = '0';
OC_Appconfig::setValue('user_wordpress', 'wordpress_have_to_be_logged', '0');
}
return $array;
}
示例10: setAppValue
/**
* @brief sets a value in the appconfig
* @param string $app app
* @param string $key key
* @param string $value value
* @return string true/false
*
* Sets a value. If the key did not exist before it will be created.
*/
public static function setAppValue($app, $key, $value)
{
return \OC_Appconfig::setValue($app, $key, $value);
}
示例11: install
public static function install($options)
{
$error = array();
$dbtype = $options['dbtype'];
if (empty($options['adminlogin'])) {
$error[] = 'Set an admin username.';
}
if (empty($options['adminpass'])) {
$error[] = 'Set an admin password.';
}
if (empty($options['directory'])) {
$error[] = 'Specify a data folder.';
}
if ($dbtype == 'mysql' or $dbtype == 'pgsql') {
//mysql and postgresql needs more config options
if ($dbtype == 'mysql') {
$dbprettyname = 'MySQL';
} else {
$dbprettyname = 'PostgreSQL';
}
if (empty($options['dbuser'])) {
$error[] = "{$dbprettyname} enter the database username.";
}
if (empty($options['dbname'])) {
$error[] = "{$dbprettyname} enter the database name.";
}
if (empty($options['dbhost'])) {
$error[] = "{$dbprettyname} set the database host.";
}
}
if (count($error) == 0) {
//no errors, good
$username = htmlspecialchars_decode($options['adminlogin']);
$password = htmlspecialchars_decode($options['adminpass']);
$datadir = htmlspecialchars_decode($options['directory']);
//use sqlite3 when available, otherise sqlite2 will be used.
if ($dbtype == 'sqlite' and class_exists('SQLite3')) {
$dbtype = 'sqlite3';
}
//generate a random salt that is used to salt the local user passwords
$salt = OC_Util::generate_random_bytes(30);
OC_Config::setValue('passwordsalt', $salt);
//write the config file
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
if ($dbtype == 'mysql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
$dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
OC_Config::setValue('dbname', $dbname);
OC_Config::setValue('dbhost', $dbhost);
OC_Config::setValue('dbtableprefix', $dbtableprefix);
//check if the database user has admin right
$connection = @mysql_connect($dbhost, $dbuser, $dbpass);
if (!$connection) {
$error[] = array('error' => 'MySQL username and/or password not valid', 'hint' => 'You need to enter either an existing account or the administrator.');
return $error;
} else {
$oldUser = OC_Config::getValue('dbuser', false);
$oldPassword = OC_Config::getValue('dbpassword', false);
$query = "SELECT user FROM mysql.user WHERE user='{$dbuser}'";
//this should be enough to check for admin rights in mysql
if (mysql_query($query, $connection)) {
//use the admin login data for the new database user
//add prefix to the mysql user name to prevent collissions
$dbusername = substr('oc_' . $username, 0, 16);
if ($dbusername != $oldUser) {
//hash the password so we don't need to store the admin config in the config file
$dbpassword = md5(time() . $password);
self::createDBUser($dbusername, $dbpassword, $connection);
OC_Config::setValue('dbuser', $dbusername);
OC_Config::setValue('dbpassword', $dbpassword);
}
//create the database
self::createDatabase($dbname, $dbusername, $connection);
} else {
if ($dbuser != $oldUser) {
OC_Config::setValue('dbuser', $dbuser);
OC_Config::setValue('dbpassword', $dbpass);
}
//create the database
self::createDatabase($dbname, $dbuser, $connection);
}
//fill the database if needed
$query = "select count(*) from information_schema.tables where table_schema='{$dbname}' AND table_name = '{$dbtableprefix}users';";
$result = mysql_query($query, $connection);
if ($result) {
$row = mysql_fetch_row($result);
}
if (!$result or $row[0] == 0) {
OC_DB::createDbFromStructure('db_structure.xml');
}
mysql_close($connection);
}
} elseif ($dbtype == 'pgsql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
//.........这里部分代码省略.........
示例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
* @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 for apache hosts
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
\OC_Setup::updateHtaccess();
}
// 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(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
/*
* START CONFIG CHANGES FOR OLDER VERSIONS
*/
if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) {
// Add the trusted_domains config if it is not existant
// This is added to prevent host header poisoning
\OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
}
/*
* STOP CONFIG CHANGES FOR OLDER VERSIONS
*/
// pre-upgrade repairs
$repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
$repair->run();
// simulate DB upgrade
if ($this->simulateStepEnabled) {
$this->checkCoreUpgrade();
// simulate apps DB upgrade
$this->checkAppUpgrade($currentVersion);
}
// upgrade from OC6 to OC7
// TODO removed it again for OC8
$sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
if ($sharePolicy === 'groups_only') {
\OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
}
if ($this->updateStepEnabled) {
$this->doCoreUpgrade();
$disabledApps = \OC_App::checkAppsRequirements();
if (!empty($disabledApps)) {
$this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps));
}
$this->doAppUpgrade();
// post-upgrade repairs
$repair = new \OC\Repair(\OC\Repair::getRepairSteps());
$repair->run();
//Invalidate update feed
\OC_Appconfig::setValue('core', 'lastupdatedat', 0);
// only set the final version if everything went well
\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
}
}
示例13: checkUpgrade
/**
* check if the app needs updating and update when needed
*/
public static function checkUpgrade($app)
{
if (in_array($app, self::$checkedApps)) {
return;
}
self::$checkedApps[] = $app;
$versions = self::getAppVersions();
$currentVersion = OC_App::getAppVersion($app);
if ($currentVersion) {
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
$info = self::getAppInfo($app);
OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
try {
OC_App::updateApp($app);
OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app');
} catch (Exception $e) {
OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage());
$l = OC_L10N::get('lib');
throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e);
}
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
}
示例14: installShippedApp
/**
* install an app already placed in the app folder
* @param string $app id of the app to install
* @returns array see OC_App::getAppInfo
*/
public static function installShippedApp($app)
{
//install the database
if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml")) {
OC_DB::createDbFromStructure(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml");
}
//run appinfo/install.php
if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/install.php")) {
include OC::$APPSROOT . "/apps/{$app}/appinfo/install.php";
}
$info = OC_App::getAppInfo($app);
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
//set remote/public handelers
foreach ($info['remote'] as $name => $path) {
OCP\CONFIG::setAppValue('core', 'remote_' . $name, '/apps/' . $app . '/' . $path);
}
foreach ($info['public'] as $name => $path) {
OCP\CONFIG::setAppValue('core', 'public_' . $name, '/apps/' . $app . '/' . $path);
}
OC_App::setAppTypes($info['id']);
return $info;
}
示例15: checkUpgrade
/**
* check if the app need updating and update when needed
*/
public static function checkUpgrade($app)
{
if (in_array($app, self::$checkedApps)) {
return;
}
self::$checkedApps[] = $app;
$versions = self::getAppVersions();
$currentVersion = OC_App::getAppVersion($app);
if ($currentVersion) {
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
try {
OC_App::updateApp($app);
} catch (Exception $e) {
echo 'Failed to upgrade "' . $app . '". Exception="' . $e->getMessage() . '"';
die;
}
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
}