From 0d4f0ab87182cf2cb588bd3285fe41b46f26ee4d Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 4 Dec 2014 16:48:07 +0100 Subject: reduce OC_Preferences, OC_Config and \OCP\Config usage * files_encryption * files_versions * files_trashbin * tests * status.php * core * server container --- lib/base.php | 2 +- lib/private/allconfig.php | 8 ++++---- lib/private/ocs/cloud.php | 2 +- lib/private/share/mailnotifications.php | 2 +- lib/private/user/session.php | 6 +++--- lib/private/user/user.php | 7 ++++--- lib/public/config.php | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/base.php b/lib/base.php index 141657fe095..af2474c7d76 100644 --- a/lib/base.php +++ b/lib/base.php @@ -236,7 +236,7 @@ class OC { $header = 'Strict-Transport-Security: max-age=31536000'; // If SSL for subdomains is enabled add "; includeSubDomains" to the header - if(\OC::$server->getSystemConfig()->getmValue('forceSSLforSubdomains', false)) { + if(\OC::$server->getSystemConfig()->getValue('forceSSLforSubdomains', false)) { $header .= '; includeSubDomains'; } header($header); diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php index ea919006f96..e20f3698258 100644 --- a/lib/private/allconfig.php +++ b/lib/private/allconfig.php @@ -117,7 +117,7 @@ class AllConfig implements \OCP\IConfig { * @param string $value the value that should be stored */ public function setAppValue($appName, $key, $value) { - \OCP\Config::setAppValue($appName, $key, $value); + \OC::$server->getAppConfig()->setValue($appName, $key, $value); } /** @@ -129,7 +129,7 @@ class AllConfig implements \OCP\IConfig { * @return string the saved value */ public function getAppValue($appName, $key, $default = '') { - return \OCP\Config::getAppValue($appName, $key, $default); + return \OC::$server->getAppConfig()->getValue($appName, $key, $default); } /** @@ -139,7 +139,7 @@ class AllConfig implements \OCP\IConfig { * @param string $key the key of the value, under which it was saved */ public function deleteAppValue($appName, $key) { - \OC_Appconfig::deleteKey($appName, $key); + \OC::$server->getAppConfig()->deleteKey($appName, $key); } /** @@ -148,7 +148,7 @@ class AllConfig implements \OCP\IConfig { * @param string $appName the appName the configs are stored under */ public function deleteAppValues($appName) { - \OC_Appconfig::deleteApp($appName); + \OC::$server->getAppConfig()->deleteApp($appName); } diff --git a/lib/private/ocs/cloud.php b/lib/private/ocs/cloud.php index 3ced0af8ee1..552aa96a26b 100644 --- a/lib/private/ocs/cloud.php +++ b/lib/private/ocs/cloud.php @@ -91,7 +91,7 @@ class OC_OCS_Cloud { } public static function getCurrentUser() { - $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); + $email=\OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'settings', 'email', ''); $data = array( 'id' => OC_User::getUser(), 'display-name' => OC_User::getDisplayName(), diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php index 2f704fb2b3c..342d3d5057a 100644 --- a/lib/private/share/mailnotifications.php +++ b/lib/private/share/mailnotifications.php @@ -79,7 +79,7 @@ class MailNotifications { foreach ($recipientList as $recipient) { $recipientDisplayName = \OCP\User::getDisplayName($recipient); - $to = \OC_Preferences::getValue($recipient, 'settings', 'email', ''); + $to = \OC::$server->getConfig()->getUserValue($recipient, 'settings', 'email', ''); if ($to === '') { $noMail[] = $recipientDisplayName; diff --git a/lib/private/user/session.php b/lib/private/user/session.php index 94abaca3e76..277aa1a047e 100644 --- a/lib/private/user/session.php +++ b/lib/private/user/session.php @@ -211,15 +211,15 @@ class Session implements IUserSession, Emitter { } // get stored tokens - $tokens = \OC_Preferences::getKeys($uid, 'login_token'); + $tokens = \OC::$server->getConfig()->getUserKeys($uid, 'login_token'); // test cookies token against stored tokens if (!in_array($currentToken, $tokens, true)) { return false; } // replace successfully used token with a new one - \OC_Preferences::deleteKey($uid, 'login_token', $currentToken); + \OC::$server->getConfig()->deleteUserValue($uid, 'login_token', $currentToken); $newToken = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(32); - \OC_Preferences::setValue($uid, 'login_token', $newToken, time()); + \OC::$server->getConfig()->setUserValue($uid, 'login_token', $newToken, time()); $this->setMagicInCookie($user->getUID(), $newToken); //login diff --git a/lib/private/user/user.php b/lib/private/user/user.php index fb66f893c61..00ded84f955 100644 --- a/lib/private/user/user.php +++ b/lib/private/user/user.php @@ -68,10 +68,11 @@ class User implements IUser { if ($this->config) { $enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true'); $this->enabled = ($enabled === 'true'); + $this->lastLogin = $this->config->getUserValue($uid, 'login', 'lastLogin', 0); } else { $this->enabled = true; + $this->lastLogin = \OC::$server->getConfig()->getUserValue($uid, 'login', 'lastLogin', 0); } - $this->lastLogin = \OC_Preferences::getValue($uid, 'login', 'lastLogin', 0); } /** @@ -140,7 +141,7 @@ class User implements IUser { */ public function updateLastLoginTimestamp() { $this->lastLogin = time(); - \OC_Preferences::setValue( + \OC::$server->getConfig()->setUserValue( $this->uid, 'login', 'lastLogin', $this->lastLogin); } @@ -163,7 +164,7 @@ class User implements IUser { \OC_Group::removeFromGroup($this->uid, $i); } // Delete the user's keys in preferences - \OC_Preferences::deleteUser($this->uid); + \OC::$server->getConfig()->deleteAllUserValues($this->uid); // Delete user files in /data/ \OC_Helper::rmdirr(\OC_User::getHome($this->uid)); diff --git a/lib/public/config.php b/lib/public/config.php index fc4df3f7567..70ff3a3fed0 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -96,7 +96,7 @@ class Config { * not exist the default value will be returned */ public static function getAppValue( $app, $key, $default = null ) { - return \OC_Appconfig::getValue( $app, $key, $default ); + return \OC::$server->getConfig()->getAppValue( $app, $key, $default ); } /** @@ -111,7 +111,7 @@ class Config { */ public static function setAppValue( $app, $key, $value ) { try { - \OC_Appconfig::setValue( $app, $key, $value ); + \OC::$server->getConfig()->setAppValue( $app, $key, $value ); } catch (\Exception $e) { return false; } -- cgit v1.2.3