Remove OC_Appconfig
This commit is contained in:
parent
d3ac73c0c9
commit
1385b1ec48
|
@ -168,7 +168,7 @@ class OC_App {
|
|||
private static function getAppTypes($app) {
|
||||
//load the cache
|
||||
if (count(self::$appTypes) == 0) {
|
||||
self::$appTypes = OC_Appconfig::getValues(false, 'types');
|
||||
self::$appTypes = \OC::$server->getAppConfig()->getValues(false, 'types');
|
||||
}
|
||||
|
||||
if (isset(self::$appTypes[$app])) {
|
||||
|
@ -190,7 +190,7 @@ class OC_App {
|
|||
$appTypes = '';
|
||||
}
|
||||
|
||||
OC_Appconfig::setValue($app, 'types', $appTypes);
|
||||
\OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -821,7 +821,7 @@ class OC_App {
|
|||
continue;
|
||||
}
|
||||
|
||||
$enabled = OC_Appconfig::getValue($app, 'enabled', 'no');
|
||||
$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'no');
|
||||
$info['groups'] = null;
|
||||
if ($enabled === 'yes') {
|
||||
$active = true;
|
||||
|
@ -1173,9 +1173,9 @@ class OC_App {
|
|||
//set remote/public handlers
|
||||
$appData = self::getAppInfo($appId);
|
||||
if (array_key_exists('ocsid', $appData)) {
|
||||
OC_Appconfig::setValue($appId, 'ocsid', $appData['ocsid']);
|
||||
} elseif(OC_Appconfig::getValue($appId, 'ocsid', null) !== null) {
|
||||
OC_Appconfig::deleteKey($appId, 'ocsid');
|
||||
\OC::$server->getAppConfig()->setValue($appId, 'ocsid', $appData['ocsid']);
|
||||
} elseif(\OC::$server->getAppConfig()->getValue($appId, 'ocsid', null) !== null) {
|
||||
\OC::$server->getAppConfig()->deleteKey($appId, 'ocsid');
|
||||
}
|
||||
foreach ($appData['remote'] as $name => $path) {
|
||||
OCP\CONFIG::setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
|
||||
|
@ -1187,7 +1187,7 @@ class OC_App {
|
|||
self::setAppTypes($appId);
|
||||
|
||||
$version = \OC_App::getAppVersion($appId);
|
||||
\OC_Appconfig::setValue($appId, 'installed_version', $version);
|
||||
\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class OC_Installer{
|
|||
|
||||
//install the database
|
||||
if(is_file($basedir.'/appinfo/database.xml')) {
|
||||
if (OC_Appconfig::getValue($info['id'], 'installed_version') === null) {
|
||||
if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
|
||||
OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
|
||||
} else {
|
||||
OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml');
|
||||
|
@ -127,8 +127,8 @@ class OC_Installer{
|
|||
}
|
||||
|
||||
//set the installed version
|
||||
OC_Appconfig::setValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
|
||||
OC_Appconfig::setValue($info['id'], 'enabled', 'no');
|
||||
\OC::$server->getAppConfig()->setValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
|
||||
\OC::$server->getAppConfig()->setValue($info['id'], 'enabled', 'no');
|
||||
|
||||
//set remote/public handelers
|
||||
foreach($info['remote'] as $name=>$path) {
|
||||
|
@ -151,7 +151,7 @@ class OC_Installer{
|
|||
* Checks whether or not an app is installed, i.e. registered in apps table.
|
||||
*/
|
||||
public static function isInstalled( $app ) {
|
||||
return (OC_Appconfig::getValue($app, "installed_version") !== null);
|
||||
return (\OC::$server->getAppConfig()->getValue($app, "installed_version") !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +184,7 @@ class OC_Installer{
|
|||
* -# setting the installed version
|
||||
*
|
||||
* upgrade.php can determine the current installed version of the app using
|
||||
* "OC_Appconfig::getValue($appid, 'installed_version')"
|
||||
* "\OC::$server->getAppConfig()->getValue($appid, 'installed_version')"
|
||||
*/
|
||||
public static function updateApp( $info=array(), $isShipped=false) {
|
||||
list($extractDir, $path) = self::downloadApp($info);
|
||||
|
@ -387,7 +387,7 @@ class OC_Installer{
|
|||
return false;
|
||||
}
|
||||
|
||||
$ocsid=OC_Appconfig::getValue( $app, 'ocsid', '');
|
||||
$ocsid=\OC::$server->getAppConfig()->getValue( $app, 'ocsid', '');
|
||||
|
||||
if($ocsid<>'') {
|
||||
$ocsClient = new OCSClient(
|
||||
|
@ -503,7 +503,7 @@ class OC_Installer{
|
|||
$enabled = isset($info['default_enable']);
|
||||
if( $enabled ) {
|
||||
OC_Installer::installShippedApp($filename);
|
||||
OC_Appconfig::setValue($filename, 'enabled', 'yes');
|
||||
\OC::$server->getAppConfig()->setValue($filename, 'enabled', 'yes');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -533,9 +533,9 @@ class OC_Installer{
|
|||
if (is_null($info)) {
|
||||
return false;
|
||||
}
|
||||
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
|
||||
\OC::$server->getAppConfig()->setValue($app, 'installed_version', OC_App::getAppVersion($app));
|
||||
if (array_key_exists('ocsid', $info)) {
|
||||
OC_Appconfig::setValue($app, 'ocsid', $info['ocsid']);
|
||||
\OC::$server->getAppConfig()->setValue($app, 'ocsid', $info['ocsid']);
|
||||
}
|
||||
|
||||
//set remote/public handlers
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Bart Visscher <bartv@thisnet.nl>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Robin Appelman <icewind@owncloud.com>
|
||||
* @author Robin McCorkell <rmccorkell@karoshi.org.uk>
|
||||
* @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
|
||||
* @author Vincent Petry <pvince81@owncloud.com>
|
||||
*
|
||||
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides an easy way for apps to store config values in the
|
||||
* database.
|
||||
*
|
||||
* @deprecated use \OC::$server->getAppConfig() to get an \OCP\IAppConfig instance
|
||||
*/
|
||||
class OC_Appconfig {
|
||||
/**
|
||||
* @return \OCP\IAppConfig
|
||||
*/
|
||||
private static function getAppConfig() {
|
||||
return \OC::$server->getAppConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all apps using the config
|
||||
* @return array an array of app ids
|
||||
*
|
||||
* This function returns a list of all apps that have at least one
|
||||
* entry in the appconfig table.
|
||||
*/
|
||||
public static function getApps() {
|
||||
return self::getAppConfig()->getApps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available keys for an app
|
||||
* @param string $app the app we are looking for
|
||||
* @return array an array of key names
|
||||
*
|
||||
* This function gets all keys of an app. Please note that the values are
|
||||
* not returned.
|
||||
*/
|
||||
public static function getKeys($app) {
|
||||
return self::getAppConfig()->getKeys($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the config value
|
||||
* @param string $app app
|
||||
* @param string $key key
|
||||
* @param string $default = null, default value if the key does not exist
|
||||
* @return string the value or $default
|
||||
*
|
||||
* This function gets a value from the appconfig table. If the key does
|
||||
* not exist the default value will be returned
|
||||
*/
|
||||
public static function getValue($app, $key, $default = null) {
|
||||
return self::getAppConfig()->getValue($app, $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a key is set in the appconfig
|
||||
* @param string $app
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasKey($app, $key) {
|
||||
return self::getAppConfig()->hasKey($app, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a value in the appconfig
|
||||
* @param string $app app
|
||||
* @param string $key key
|
||||
* @param string $value value
|
||||
*
|
||||
* Sets a value. If the key did not exist before it will be created.
|
||||
*/
|
||||
public static function setValue($app, $key, $value) {
|
||||
self::getAppConfig()->setValue($app, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a key
|
||||
* @param string $app app
|
||||
* @param string $key key
|
||||
*
|
||||
* Deletes a key.
|
||||
*/
|
||||
public static function deleteKey($app, $key) {
|
||||
self::getAppConfig()->deleteKey($app, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove app from appconfig
|
||||
* @param string $app app
|
||||
*
|
||||
* Removes all keys in appconfig belonging to the app.
|
||||
*/
|
||||
public static function deleteApp($app) {
|
||||
self::getAppConfig()->deleteApp($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* get multiply values, either the app or key can be used as wildcard by setting it to false
|
||||
*
|
||||
* @param string|false $app
|
||||
* @param string|false $key
|
||||
* @return array
|
||||
*/
|
||||
public static function getValues($app, $key) {
|
||||
return self::getAppConfig()->getValues($app, $key);
|
||||
}
|
||||
}
|
|
@ -102,7 +102,7 @@ class Share extends Constants {
|
|||
* The Share API is enabled by default if not configured
|
||||
*/
|
||||
public static function isEnabled() {
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') {
|
||||
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_enabled', 'yes') == 'yes') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -703,7 +703,7 @@ class Share extends Constants {
|
|||
$shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner));
|
||||
} else if ($shareType === self::SHARE_TYPE_LINK) {
|
||||
$updateExistingShare = false;
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
|
||||
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
|
||||
|
||||
// when updating a link share
|
||||
// FIXME Don't delete link if we update it
|
||||
|
@ -1365,7 +1365,7 @@ class Share extends Constants {
|
|||
*/
|
||||
public static function isResharingAllowed() {
|
||||
if (!isset(self::$isResharingAllowed)) {
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
|
||||
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
|
||||
self::$isResharingAllowed = true;
|
||||
} else {
|
||||
self::$isResharingAllowed = false;
|
||||
|
@ -1509,7 +1509,7 @@ class Share extends Constants {
|
|||
$queryArgs = array($itemType);
|
||||
}
|
||||
}
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
|
||||
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
|
||||
$where .= ' AND `share_type` != ?';
|
||||
$queryArgs[] = self::SHARE_TYPE_LINK;
|
||||
}
|
||||
|
@ -2504,7 +2504,7 @@ class Share extends Constants {
|
|||
* @return bool
|
||||
*/
|
||||
public static function shareWithGroupMembersOnly() {
|
||||
$value = \OC_Appconfig::getValue('core', 'shareapi_only_share_with_group_members', 'no');
|
||||
$value = \OC::$server->getAppConfig()->getValue('core', 'shareapi_only_share_with_group_members', 'no');
|
||||
return ($value === 'yes') ? true : false;
|
||||
}
|
||||
|
||||
|
|
|
@ -212,9 +212,9 @@ class OC_Util {
|
|||
* @return boolean
|
||||
*/
|
||||
public static function isSharingDisabledForUser() {
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
|
||||
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
|
||||
$user = \OCP\User::getUser();
|
||||
$groupsList = \OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', '');
|
||||
$groupsList = \OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups_list', '');
|
||||
$excludedGroups = explode(',', $groupsList);
|
||||
$usersGroups = \OC_Group::getUserGroups($user);
|
||||
if (!empty($usersGroups)) {
|
||||
|
@ -999,7 +999,7 @@ class OC_Util {
|
|||
if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) {
|
||||
$location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url']));
|
||||
} else {
|
||||
$defaultPage = OC_Appconfig::getValue('core', 'defaultpage');
|
||||
$defaultPage = \OC::$server->getAppConfig()->getValue('core', 'defaultpage');
|
||||
if ($defaultPage) {
|
||||
$location = $urlGenerator->getAbsoluteURL($defaultPage);
|
||||
} else {
|
||||
|
|
|
@ -54,7 +54,7 @@ if($username) {
|
|||
if($quota === 'default') {//'default' as default quota makes no sense
|
||||
$quota='none';
|
||||
}
|
||||
OC_Appconfig::setValue('files', 'default_quota', $quota);
|
||||
\OC::$server->getAppConfig()->setValue('files', 'default_quota', $quota);
|
||||
}
|
||||
OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota)));
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ class Test_Share extends \Test\TestCase {
|
|||
OCP\Share::registerBackend('test', 'Test_Share_Backend');
|
||||
OC_Hook::clear('OCP\\Share');
|
||||
OC::registerShareHooks();
|
||||
$this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes');
|
||||
OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
|
||||
$this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes');
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
|
||||
|
||||
// 20 Minutes in the past, 20 minutes in the future.
|
||||
$now = time();
|
||||
|
@ -87,7 +87,7 @@ class Test_Share extends \Test\TestCase {
|
|||
protected function tearDown() {
|
||||
$query = OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
|
||||
$query->execute(array('test'));
|
||||
OC_Appconfig::setValue('core', 'shareapi_allow_resharing', $this->resharing);
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing);
|
||||
|
||||
OC_User::deleteUser($this->user1);
|
||||
OC_User::deleteUser($this->user2);
|
||||
|
@ -486,8 +486,8 @@ class Test_Share extends \Test\TestCase {
|
|||
);
|
||||
|
||||
// exclude group2 from sharing
|
||||
\OC_Appconfig::setValue('core', 'shareapi_exclude_groups_list', $this->group2);
|
||||
\OC_Appconfig::setValue('core', 'shareapi_exclude_groups', "yes");
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', $this->group2);
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', "yes");
|
||||
|
||||
OC_User::setUserId($this->user4);
|
||||
|
||||
|
@ -496,8 +496,8 @@ class Test_Share extends \Test\TestCase {
|
|||
$this->assertSame(\OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_SHARE, $share['permissions'],
|
||||
'Failed asserting that user 4 is excluded from re-sharing');
|
||||
|
||||
\OC_Appconfig::deleteKey('core', 'shareapi_exclude_groups_list');
|
||||
\OC_Appconfig::deleteKey('core', 'shareapi_exclude_groups');
|
||||
\OC::$server->getAppConfig()->deleteKey('core', 'shareapi_exclude_groups_list');
|
||||
\OC::$server->getAppConfig()->deleteKey('core', 'shareapi_exclude_groups');
|
||||
|
||||
}
|
||||
|
||||
|
@ -569,8 +569,8 @@ class Test_Share extends \Test\TestCase {
|
|||
} catch (Exception $exception) {
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
$policy = OC_Appconfig::getValue('core', 'shareapi_only_share_with_group_members', 'no');
|
||||
OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
|
||||
$policy = \OC::$server->getAppConfig()->getValue('core', 'shareapi_only_share_with_group_members', 'no');
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_only_share_with_group_members', 'yes');
|
||||
$message = 'Sharing test.txt failed, because '.$this->user1.' is not a member of the group '.$this->group2;
|
||||
try {
|
||||
OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group2, \OCP\Constants::PERMISSION_READ);
|
||||
|
@ -578,7 +578,7 @@ class Test_Share extends \Test\TestCase {
|
|||
} catch (Exception $exception) {
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', $policy);
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_only_share_with_group_members', $policy);
|
||||
|
||||
// Valid share
|
||||
$this->shareUserOneTestFileWithGroupOne();
|
||||
|
@ -1224,9 +1224,9 @@ class Test_Share extends \Test\TestCase {
|
|||
public function testClearExpireDateWhileEnforced() {
|
||||
OC_User::setUserId($this->user1);
|
||||
|
||||
\OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes');
|
||||
\OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2');
|
||||
\OC_Appconfig::setValue('core', 'shareapi_enforce_expire_date', 'yes');
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_default_expire_date', 'yes');
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_expire_after_n_days', '2');
|
||||
\OC::$server->getAppConfig()->setValue('core', 'shareapi_enforce_expire_date', 'yes');
|
||||
|
||||
$token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
|
||||
$this->assertInternalType(
|
||||
|
@ -1247,9 +1247,9 @@ class Test_Share extends \Test\TestCase {
|
|||
|
||||
$this->assertTrue($setExpireDateFailed);
|
||||
|
||||
\OC_Appconfig::deleteKey('core', 'shareapi_default_expire_date');
|
||||
\OC_Appconfig::deleteKey('core', 'shareapi_expire_after_n_days');
|
||||
\OC_Appconfig::deleteKey('core', 'shareapi_enforce_expire_date');
|
||||
\OC::$server->getAppConfig()->deleteKey('core', 'shareapi_default_expire_date');
|
||||
\OC::$server->getAppConfig()->deleteKey('core', 'shareapi_expire_after_n_days');
|
||||
\OC::$server->getAppConfig()->deleteKey('core', 'shareapi_enforce_expire_date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue