diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 25 | ||||
-rw-r--r-- | lib/private/app.php | 20 | ||||
-rw-r--r-- | lib/private/app/platform.php | 2 | ||||
-rw-r--r-- | lib/private/defaults.php | 2 | ||||
-rw-r--r-- | lib/private/helper.php | 101 | ||||
-rw-r--r-- | lib/private/installer.php | 8 | ||||
-rw-r--r-- | lib/private/legacy/config.php | 94 | ||||
-rw-r--r-- | lib/private/ocs/cloud.php | 2 | ||||
-rw-r--r-- | lib/private/preview.php | 2 | ||||
-rw-r--r-- | lib/private/server.php | 7 | ||||
-rw-r--r-- | lib/private/setup.php | 2 | ||||
-rw-r--r-- | lib/private/systemconfig.php | 17 | ||||
-rw-r--r-- | lib/private/template/functions.php | 4 | ||||
-rw-r--r-- | lib/private/templatelayout.php | 2 | ||||
-rw-r--r-- | lib/private/updater.php | 10 | ||||
-rw-r--r-- | lib/private/user.php | 4 | ||||
-rw-r--r-- | lib/private/util.php | 22 | ||||
-rw-r--r-- | lib/public/util.php | 11 |
18 files changed, 80 insertions, 255 deletions
diff --git a/lib/base.php b/lib/base.php index 8f1432d6fb9..ce4546e8fa3 100644 --- a/lib/base.php +++ b/lib/base.php @@ -113,6 +113,11 @@ class OC { public static $server = null; /** + * @var \OC\Config + */ + private static $config = null; + + /** * @throws \RuntimeException when the 3rdparty directory is missing or * the app path list is empty or contains an invalid path */ @@ -124,7 +129,7 @@ class OC { } else { self::$configDir = OC::$SERVERROOT . '/config/'; } - OC_Config::$object = new \OC\Config(self::$configDir); + self::$config = new \OC\Config(self::$configDir); OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); /** @@ -137,7 +142,7 @@ class OC { 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], ], ]; - $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig())); + $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); $scriptName = $fakeRequest->getScriptName(); if (substr($scriptName, -1) == '/') { $scriptName .= 'index.php'; @@ -152,7 +157,7 @@ class OC { if (OC::$CLI) { - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); } else { if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); @@ -165,7 +170,7 @@ class OC { // This most likely means that we are calling from CLI. // However some cron jobs still need to generate // a web URL, so we use overwritewebroot as a fallback. - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); } // Resolve /owncloud to /owncloud/ to ensure to always have a trailing @@ -178,8 +183,8 @@ class OC { } // search the 3rdparty folder - OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', null); - OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', null); + OC::$THIRDPARTYROOT = self::$config->getValue('3rdpartyroot', null); + OC::$THIRDPARTYWEBROOT = self::$config->getValue('3rdpartyurl', null); if (empty(OC::$THIRDPARTYROOT) && empty(OC::$THIRDPARTYWEBROOT)) { if (file_exists(OC::$SERVERROOT . '/3rdparty')) { @@ -197,7 +202,7 @@ class OC { } // search the apps folder - $config_paths = OC_Config::getValue('apps_paths', array()); + $config_paths = self::$config->getValue('apps_paths', array()); if (!empty($config_paths)) { foreach ($config_paths as $paths) { if (isset($paths['url']) && isset($paths['path'])) { @@ -372,7 +377,7 @@ class OC { // check whether this is a core update or apps update $installedVersion = $systemConfig->getValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $appManager = \OC::$server->getAppManager(); @@ -387,7 +392,7 @@ class OC { } // get third party apps - $ocVersion = OC_Util::getVersion(); + $ocVersion = \OCP\Util::getVersion(); $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); $tmpl->assign('incompatibleAppsList', $appManager->getIncompatibleApps($ocVersion)); $tmpl->assign('productName', 'ownCloud'); // for now @@ -517,7 +522,7 @@ class OC { } // setup the basic server - self::$server = new \OC\Server(\OC::$WEBROOT); + self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); \OC::$server->getEventLogger()->start('boot', 'Initialize'); diff --git a/lib/private/app.php b/lib/private/app.php index e8cc9219224..5f6ca9596c8 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -96,7 +96,7 @@ class OC_App { * if $types is set, only apps of those types will be loaded */ public static function loadApps($types = null) { - if (OC_Config::getValue('maintenance', false)) { + if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { return false; } // Load the enabled apps here @@ -239,7 +239,7 @@ class OC_App { * @return string[] */ public static function getEnabledApps($forceRefresh = false, $all = false) { - if (!OC_Config::getValue('installed', false)) { + if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { return array(); } // in incognito mode or when logged out, $user will be false, @@ -318,8 +318,8 @@ class OC_App { \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); - $download= $ocsClient->getApplicationDownload($app, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); + $download= $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion()); if(isset($download['downloadlink']) and $download['downloadlink']!='') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -374,7 +374,7 @@ class OC_App { $settings = array(); // by default, settings only contain the help menu if (OC_Util::getEditionString() === '' && - OC_Config::getValue('knowledgebaseenabled', true) == true + \OC::$server->getSystemConfig()->getValue('knowledgebaseenabled', true) == true ) { $settings = array( array( @@ -455,7 +455,7 @@ class OC_App { * @return string|false */ public static function getInstallPath() { - if (OC_Config::getValue('appstoreenabled', true) == false) { + if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { return false; } @@ -880,7 +880,7 @@ class OC_App { if (is_null($category)) { - $categoryNames = $ocsClient->getCategories(\OC_Util::getVersion()); + $categoryNames = $ocsClient->getCategories(\OCP\Util::getVersion()); if (is_array($categoryNames)) { // Check that categories of apps were retrieved correctly if (!$categories = array_keys($categoryNames)) { @@ -892,7 +892,7 @@ class OC_App { } $page = 0; - $remoteApps = $ocsClient->getApplications($categories, $page, $filter, \OC_Util::getVersion()); + $remoteApps = $ocsClient->getApplications($categories, $page, $filter, \OCP\Util::getVersion()); $apps = []; $i = 0; $l = \OC::$server->getL10N('core'); @@ -1050,7 +1050,7 @@ class OC_App { $config, \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if (!is_numeric($app)) { @@ -1080,7 +1080,7 @@ class OC_App { if ($app !== false) { // check if the app is compatible with this version of ownCloud $info = self::getAppInfo($app); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); if (!self::isAppCompatible($version, $info)) { throw new \Exception( $l->t('App "%s" cannot be installed because it is not compatible with this version of ownCloud.', diff --git a/lib/private/app/platform.php b/lib/private/app/platform.php index f433ecd9f9e..c16f050e13c 100644 --- a/lib/private/app/platform.php +++ b/lib/private/app/platform.php @@ -52,7 +52,7 @@ class Platform { * @return string */ public function getOcVersion() { - $v = OC_Util::getVersion(); + $v = \OCP\Util::getVersion(); return join('.', $v); } diff --git a/lib/private/defaults.php b/lib/private/defaults.php index 16f45943f54..23f0baad96e 100644 --- a/lib/private/defaults.php +++ b/lib/private/defaults.php @@ -49,7 +49,7 @@ class OC_Defaults { function __construct() { $this->l = \OC::$server->getL10N('lib'); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */ diff --git a/lib/private/helper.php b/lib/private/helper.php index c6223d2147a..64952903712 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -54,60 +54,6 @@ class OC_Helper { private static $templateManager; /** - * Creates an absolute url - * @param string $app app - * @param string $file file - * @param array $args array with param=>value, will be appended to the returned url - * The value of $args will be urlencoded - * @return string the url - * - * Returns a absolute url to the given app and file. - */ - public static function linkToAbsolute($app, $file, $args = array()) { - return OC::$server->getURLGenerator()->getAbsoluteURL( - OC::$server->getURLGenerator()->linkTo($app, $file, $args) - ); - } - - /** - * Makes an $url absolute - * @param string $url the url - * @return string the absolute url - * @deprecated Use \OC::$server->getURLGenerator()->getAbsoluteURL($url) - * - * Returns a absolute url to the given app and file. - */ - public static function makeURLAbsolute($url) { - return OC::$server->getURLGenerator()->getAbsoluteURL($url); - } - - /** - * Creates an url for remote use - * @param string $service id - * @return string the url - * - * Returns a url to the given service. - */ - public static function linkToRemoteBase($service) { - return OC::$server->getURLGenerator()->linkTo('', 'remote.php') . '/' . $service; - } - - /** - * Creates an absolute url for remote use - * @param string $service id - * @param bool $add_slash - * @return string the url - * - * Returns a absolute url to the given service. - */ - public static function linkToRemote($service, $add_slash = true) { - return OC::$server->getURLGenerator()->getAbsoluteURL( - self::linkToRemoteBase($service) - . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '') - ); - } - - /** * Creates an absolute url for public use * @param string $service id * @param bool $add_slash @@ -138,18 +84,6 @@ class OC_Helper { } /** - * get path to icon of file type - * @param string $mimetype mimetype - * @return string the url - * - * Returns the path to the image of this file type. - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype) - */ - public static function mimetypeIcon($mimetype) { - return \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype); - } - - /** * get path to preview of file * @param string $path path * @return string the url @@ -336,39 +270,6 @@ class OC_Helper { } /** - * Try to guess the mimetype based on filename - * - * @param string $path - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->detectPath($path) - */ - static public function getFileNameMimeType($path) { - return \OC::$server->getMimeTypeDetector()->detectPath($path); - } - - /** - * Get a secure mimetype that won't expose potential XSS. - * - * @param string $mimeType - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType) - */ - static function getSecureMimeType($mimeType) { - return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType); - } - - /** - * get the mimetype form a data string - * - * @param string $data - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->detectString($data) - */ - static function getStringMimeType($data) { - return \OC::$server->getMimeTypeDetector()->detectString($data); - } - - /** * detect if a given program is found in the search PATH * * @param string $name @@ -711,7 +612,7 @@ class OC_Helper { */ public static function getStorageInfo($path, $rootInfo = null) { // return storage info without adding mount points - $includeExtStorage = \OC_Config::getValue('quota_include_external_storage', false); + $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false); if (!$rootInfo) { $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false); diff --git a/lib/private/installer.php b/lib/private/installer.php index e1447db0db5..bbd976cda91 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -232,8 +232,8 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($ocsId, \OC_Util::getVersion()); - $download = $ocsClient->getApplicationDownload($ocsId, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($ocsId, \OCP\Util::getVersion()); + $download = $ocsClient->getApplicationDownload($ocsId, \OCP\Util::getVersion()); if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') { $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -342,7 +342,7 @@ class OC_Installer{ } // check if the app is compatible with this version of ownCloud - if(!OC_App::isAppCompatible(OC_Util::getVersion(), $info)) { + if(!OC_App::isAppCompatible(\OCP\Util::getVersion(), $info)) { OC_Helper::rmdirr($extractDir); throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud")); } @@ -400,7 +400,7 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $ocsdata = $ocsClient->getApplication($ocsid, \OC_Util::getVersion()); + $ocsdata = $ocsClient->getApplication($ocsid, \OCP\Util::getVersion()); $ocsversion= (string) $ocsdata['version']; $currentversion=OC_App::getAppVersion($app); if (version_compare($ocsversion, $currentversion, '>')) { diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php deleted file mode 100644 index 1835d4a4b1c..00000000000 --- a/lib/private/legacy/config.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -/** - * @author Bart Visscher <bartv@thisnet.nl> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Michael Gapczynski <GapczynskiM@gmail.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * - * @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 is responsible for reading and writing config.php, the very basic - * configuration file of ownCloud. - * - * @deprecated use \OC::$server->getConfig() to get an \OCP\Config instance - */ -class OC_Config { - - /** @var \OC\Config */ - public static $object; - - /** - * Lists all available config keys - * @return array an array of key names - * - * This function returns all keys saved in config.php. Please note that it - * does not return the values. - */ - public static function getKeys() { - return self::$object->getKeys(); - } - - /** - * Gets a value from config.php - * @param string $key key - * @param mixed $default = null default value - * @return mixed the value or $default - * - * This function gets the value from config.php. If it does not exist, - * $default will be returned. - */ - public static function getValue($key, $default = null) { - return self::$object->getValue($key, $default); - } - - /** - * Sets a value - * @param string $key key - * @param mixed $value value - * - * This function sets the value and writes the config.php. - * - */ - public static function setValue($key, $value) { - self::$object->setValue($key, $value); - } - - /** - * Sets and deletes values and writes the config.php - * - * @param array $configs Associative array with `key => value` pairs - * If value is null, the config key will be deleted - */ - public static function setValues(array $configs) { - self::$object->setValues($configs); - } - - /** - * Removes a key from the config - * @param string $key key - * - * This function removes a key from the config.php. - */ - public static function deleteKey($key) { - self::$object->deleteKey($key); - } -} diff --git a/lib/private/ocs/cloud.php b/lib/private/ocs/cloud.php index 2cf40c449ff..1b04f43d477 100644 --- a/lib/private/ocs/cloud.php +++ b/lib/private/ocs/cloud.php @@ -26,7 +26,7 @@ class OC_OCS_Cloud { public static function getCapabilities() { $result = array(); - list($major, $minor, $micro) = OC_Util::getVersion(); + list($major, $minor, $micro) = \OCP\Util::getVersion(); $result['version'] = array( 'major' => $major, 'minor' => $minor, diff --git a/lib/private/preview.php b/lib/private/preview.php index 38c043030fc..44d38b354a9 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -1168,7 +1168,7 @@ class Preview { */ private function getMimeIcon() { $image = new \OC_Image(); - $mimeIconWebPath = \OC_Helper::mimetypeIcon($this->mimeType); + $mimeIconWebPath = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($this->mimeType); if (empty(\OC::$WEBROOT)) { $mimeIconServerPath = \OC::$SERVERROOT . $mimeIconWebPath; } else { diff --git a/lib/private/server.php b/lib/private/server.php index 5e29dbedc4f..7efe78b7c37 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -84,8 +84,9 @@ class Server extends ServerContainer implements IServerContainer { /** * @param string $webRoot + * @param \OC\Config $config */ - public function __construct($webRoot) { + public function __construct($webRoot, \OC\Config $config) { parent::__construct(); $this->webRoot = $webRoot; @@ -238,8 +239,8 @@ class Server extends ServerContainer implements IServerContainer { $c->getSystemConfig() ); }); - $this->registerService('SystemConfig', function ($c) { - return new \OC\SystemConfig(); + $this->registerService('SystemConfig', function ($c) use ($config) { + return new \OC\SystemConfig($config); }); $this->registerService('AppConfig', function ($c) { return new \OC\AppConfig(\OC_DB::getConnection()); diff --git a/lib/private/setup.php b/lib/private/setup.php index 4d11cb44a83..770f5cdab52 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -322,7 +322,7 @@ class Setup { 'datadirectory' => $dataDir, 'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT, 'dbtype' => $dbType, - 'version' => implode('.', \OC_Util::getVersion()), + 'version' => implode('.', \OCP\Util::getVersion()), ]); try { diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php index 94b815aebd7..fb8c18123d7 100644 --- a/lib/private/systemconfig.php +++ b/lib/private/systemconfig.php @@ -44,12 +44,19 @@ class SystemConfig { 'objectstore' => ['arguments' => ['password' => true]], ]; + /** @var Config */ + private $config; + + public function __construct(Config $config) { + $this->config = $config; + } + /** * Lists all available config keys * @return array an array of key names */ public function getKeys() { - return \OC_Config::getKeys(); + return $this->config->getKeys(); } /** @@ -59,7 +66,7 @@ class SystemConfig { * @param mixed $value the value that should be stored */ public function setValue($key, $value) { - \OC_Config::setValue($key, $value); + $this->config->setValue($key, $value); } /** @@ -69,7 +76,7 @@ class SystemConfig { * If value is null, the config key will be deleted */ public function setValues(array $configs) { - \OC_Config::setValues($configs); + $this->config->setValues($configs); } /** @@ -80,7 +87,7 @@ class SystemConfig { * @return mixed the value or $default */ public function getValue($key, $default = '') { - return \OC_Config::getValue($key, $default); + return $this->config->getValue($key, $default); } /** @@ -106,7 +113,7 @@ class SystemConfig { * @param string $key the key of the value, under which it was saved */ public function deleteValue($key) { - \OC_Config::deleteKey($key); + $this->config->deleteKey($key); } /** diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php index 6298f25edc1..982ecde5850 100644 --- a/lib/private/template/functions.php +++ b/lib/private/template/functions.php @@ -173,11 +173,9 @@ function image_path( $app, $image ) { * make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype * @return string link to the image - * - * For further information have a look at OC_Helper::mimetypeIcon */ function mimetype_icon( $mimetype ) { - return OC_Helper::mimetypeIcon( $mimetype ); + return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype ); } /** diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index 95688268c47..bf25b2d31a9 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -159,7 +159,7 @@ class OC_TemplateLayout extends OC_Template { if(empty(self::$versionHash)) { $v = OC_App::getAppVersions(); - $v['core'] = implode('.', \OC_Util::getVersion()); + $v['core'] = implode('.', \OCP\Util::getVersion()); self::$versionHash = md5(implode(',', $v)); } diff --git a/lib/private/updater.php b/lib/private/updater.php index d5598d339d3..04f8dcf7226 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -155,7 +155,7 @@ class Updater extends BasicEmitter { $this->config->setAppValue('core', 'installedat', microtime(true)); } - $version = \OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $version['installed'] = $this->config->getAppValue('core', 'installedat'); $version['updated'] = $this->config->getAppValue('core', 'lastupdatedat'); $version['updatechannel'] = \OC_Util::getChannel(); @@ -208,7 +208,7 @@ class Updater extends BasicEmitter { } $installedVersion = $this->config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', \OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); $success = true; @@ -353,7 +353,7 @@ class Updater extends BasicEmitter { } // only set the final version if everything went well - $this->config->setSystemValue('version', implode('.', \OC_Util::getVersion())); + $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion())); } } @@ -472,7 +472,7 @@ class Updater extends BasicEmitter { private function checkAppsRequirements() { $isCoreUpgrade = $this->isCodeUpgrade(); $apps = OC_App::getEnabledApps(); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $disabledApps = []; foreach ($apps as $app) { // check if the app is compatible with this version of ownCloud @@ -509,7 +509,7 @@ class Updater extends BasicEmitter { */ private function isCodeUpgrade() { $installedVersion = $this->config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { return true; } diff --git a/lib/private/user.php b/lib/private/user.php index f806aa07251..cfa60d675fe 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -130,7 +130,7 @@ class OC_User { */ public static function setupBackends() { OC_App::loadApps(array('prelogin')); - $backends = OC_Config::getValue('user_backends', array()); + $backends = \OC::$server->getSystemConfig()->getValue('user_backends', array()); foreach ($backends as $i => $config) { $class = $config['class']; $arguments = $config['arguments']; @@ -498,7 +498,7 @@ class OC_User { if ($user) { return $user->getHome(); } else { - return OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; } } diff --git a/lib/private/util.php b/lib/private/util.php index c63befb3f32..12146f6980b 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -72,7 +72,7 @@ class OC_Util { private static function initLocalStorageRootFS() { // mount local file backend as root - $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data"); + $configDataDirectory = \OC::$server->getSystemConfig()->getValue("datadirectory", OC::$SERVERROOT . "/data"); //first set up the local "root" storage \OC\Files\Filesystem::initMountManager(); if (!self::$rootMounted) { @@ -184,7 +184,7 @@ class OC_Util { OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); //check if we are using an object storage - $objectStore = OC_Config::getValue('objectstore'); + $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null); if (isset($objectStore)) { self::initObjectStoreRootFS($objectStore); } else { @@ -848,7 +848,7 @@ class OC_Util { public static function checkDatabaseVersion() { $l = \OC::$server->getL10N('lib'); $errors = array(); - $dbType = \OC_Config::getValue('dbtype', 'sqlite'); + $dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite'); if ($dbType === 'pgsql') { // check PostgreSQL version try { @@ -974,7 +974,7 @@ class OC_Util { */ public static function checkAppEnabled($app) { if (!OC_App::isEnabled($app)) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } } @@ -988,7 +988,7 @@ class OC_Util { public static function checkLoggedIn() { // Check if we are a user if (!OC_User::isLoggedIn()) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php', + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php', [ 'redirect_url' => \OC::$server->getRequest()->getRequestUri() ] @@ -1006,7 +1006,7 @@ class OC_Util { public static function checkAdminUser() { OC_Util::checkLoggedIn(); if (!OC_User::isAdminUser(OC_User::getUser())) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } } @@ -1046,7 +1046,7 @@ class OC_Util { } if (!$isSubAdmin) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } return true; @@ -1108,11 +1108,11 @@ class OC_Util { * @return string */ public static function getInstanceId() { - $id = OC_Config::getValue('instanceid', null); + $id = \OC::$server->getSystemConfig()->getValue('instanceid', null); if (is_null($id)) { // We need to guarantee at least one letter in instanceid so it can be used as the session_name $id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); - OC_Config::$object->setValue('instanceid', $id); + \OC::$server->getSystemConfig()->setValue('instanceid', $id); } return $id; } @@ -1364,7 +1364,7 @@ class OC_Util { * @return string the theme */ public static function getTheme() { - $theme = OC_Config::getValue("theme", ''); + $theme = \OC::$server->getSystemConfig()->getValue("theme", ''); if ($theme === '') { if (is_dir(OC::$SERVERROOT . '/themes/default')) { @@ -1509,7 +1509,7 @@ class OC_Util { public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) { $installedVersion = $config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $versionDiff = version_compare($currentVersion, $installedVersion); if ($versionDiff > 0) { return true; diff --git a/lib/public/util.php b/lib/public/util.php index da4aa6e9deb..a9fe0e47de6 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -269,7 +269,10 @@ class Util { * @since 4.0.0 - parameter $args was added in 4.5.0 */ public static function linkToAbsolute( $app, $file, $args = array() ) { - return(\OC_Helper::linkToAbsolute( $app, $file, $args )); + $urlGenerator = \OC::$server->getURLGenerator(); + return $urlGenerator->getAbsoluteURL( + $urlGenerator->linkTo($app, $file, $args) + ); } /** @@ -279,7 +282,11 @@ class Util { * @since 4.0.0 */ public static function linkToRemote( $service ) { - return(\OC_Helper::linkToRemote( $service )); + $urlGenerator = \OC::$server->getURLGenerator(); + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; + return $urlGenerator->getAbsoluteURL( + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') + ); } /** |