summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-12-09 09:36:38 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-12-09 09:36:38 +0100
commitc36bac3abdd4b41620bdebbc3391612aac620fb8 (patch)
tree81367a95e82769d78f862426b37e015a665642ea /lib/public
parent8f8f9deb66af0e32c508bbca033573824b1388f5 (diff)
parent9a7362dd0d4e0f738089302329ce10817377433e (diff)
downloadnextcloud-server-c36bac3abdd4b41620bdebbc3391612aac620fb8.tar.gz
nextcloud-server-c36bac3abdd4b41620bdebbc3391612aac620fb8.zip
Merge pull request #12406 from owncloud/drop-getApps-getUsers
Config cleanup - OC_Preferences refactoring
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/config.php22
-rw-r--r--lib/public/iappconfig.php7
-rw-r--r--lib/public/iconfig.php46
-rw-r--r--lib/public/preconditionnotmetexception.php30
4 files changed, 94 insertions, 11 deletions
diff --git a/lib/public/config.php b/lib/public/config.php
index 65dde39cdce..70ff3a3fed0 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -37,6 +37,7 @@ namespace OCP;
/**
* This class provides functions to read and write configuration data.
* configuration can be on a system, application or user level
+ * @deprecated use methods of \OCP\IConfig
*/
class Config {
/**
@@ -44,12 +45,13 @@ class Config {
* @param string $key key
* @param mixed $default = null default value
* @return mixed the value or $default
+ * @deprecated use method getSystemValue of \OCP\IConfig
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
*/
public static function getSystemValue( $key, $default = null ) {
- return \OC_Config::getValue( $key, $default );
+ return \OC::$server->getConfig()->getSystemValue( $key, $default );
}
/**
@@ -57,13 +59,14 @@ class Config {
* @param string $key key
* @param mixed $value value
* @return bool
+ * @deprecated use method setSystemValue of \OCP\IConfig
*
* 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 );
+ \OC::$server->getConfig()->setSystemValue( $key, $value );
} catch (\Exception $e) {
return false;
}
@@ -73,11 +76,12 @@ class Config {
/**
* Deletes a value from config.php
* @param string $key key
+ * @deprecated use method deleteSystemValue of \OCP\IConfig
*
* This function deletes the value from config.php.
*/
public static function deleteSystemValue( $key ) {
- return \OC_Config::deleteKey( $key );
+ \OC::$server->getConfig()->deleteSystemValue( $key );
}
/**
@@ -86,12 +90,13 @@ class Config {
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @return string the value or $default
+ * @deprecated use method getAppValue of \OCP\IConfig
*
* This function gets a value from the appconfig table. If the key does
* 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 );
}
/**
@@ -100,12 +105,13 @@ class Config {
* @param string $key key
* @param string $value value
* @return boolean true/false
+ * @deprecated use method setAppValue of \OCP\IConfig
*
* Sets a value. If the key did not exist before it will be created.
*/
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;
}
@@ -119,12 +125,13 @@ class Config {
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @return string the value or $default
+ * @deprecated use method getUserValue of \OCP\IConfig
*
* This function gets a value from the preferences table. If the key does
* not exist the default value will be returned
*/
public static function getUserValue( $user, $app, $key, $default = null ) {
- return \OC_Preferences::getValue( $user, $app, $key, $default );
+ return \OC::$server->getConfig()->getUserValue( $user, $app, $key, $default );
}
/**
@@ -134,13 +141,14 @@ class Config {
* @param string $key key
* @param string $value value
* @return bool
+ * @deprecated use method setUserValue of \OCP\IConfig
*
* Adds a value to the preferences. If the key did not exist before, it
* will be added automagically.
*/
public static function setUserValue( $user, $app, $key, $value ) {
try {
- \OC_Preferences::setValue( $user, $app, $key, $value );
+ \OC::$server->getConfig()->setUserValue( $user, $app, $key, $value );
} catch (\Exception $e) {
return false;
}
diff --git a/lib/public/iappconfig.php b/lib/public/iappconfig.php
index d43eb70ee04..cbd1a7e0573 100644
--- a/lib/public/iappconfig.php
+++ b/lib/public/iappconfig.php
@@ -26,6 +26,7 @@ interface IAppConfig {
* @param string $key key
* @param string $default = null, default value if the key does not exist
* @return string the value or $default
+ * @deprecated use method getAppValue of \OCP\IConfig
*
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
@@ -37,8 +38,7 @@ interface IAppConfig {
* @param string $app app
* @param string $key key
* @return bool
- *
- * Deletes a key.
+ * @deprecated use method deleteAppValue of \OCP\IConfig
*/
public function deleteKey($app, $key);
@@ -46,6 +46,7 @@ interface IAppConfig {
* Get the available keys for an app
* @param string $app the app we are looking for
* @return array an array of key names
+ * @deprecated use method getAppKeys of \OCP\IConfig
*
* This function gets all keys of an app. Please note that the values are
* not returned.
@@ -66,6 +67,7 @@ interface IAppConfig {
* @param string $app app
* @param string $key key
* @param string $value value
+ * @deprecated use method setAppValue of \OCP\IConfig
*
* Sets a value. If the key did not exist before it will be created.
* @return void
@@ -85,6 +87,7 @@ interface IAppConfig {
* Remove app from appconfig
* @param string $app app
* @return bool
+ * @deprecated use method deleteAppValue of \OCP\IConfig
*
* Removes all keys in appconfig belonging to the app.
*/
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
index 554fee5b22f..fe0f1273a80 100644
--- a/lib/public/iconfig.php
+++ b/lib/public/iconfig.php
@@ -94,6 +94,13 @@ interface IConfig {
*/
public function deleteAppValue($appName, $key);
+ /**
+ * Removes all keys in appconfig belonging to the app
+ *
+ * @param string $appName the appName the configs are stored under
+ */
+ public function deleteAppValues($appName);
+
/**
* Set a user defined value
@@ -102,9 +109,10 @@ interface IConfig {
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
* @param string $value the value that you want to store
- * @return void
+ * @param string $preCondition only update if the config value was previously the value passed as $preCondition
+ * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
*/
- public function setUserValue($userId, $appName, $key, $value);
+ public function setUserValue($userId, $appName, $key, $value, $preCondition = null);
/**
* Shortcut for getting a user defined value
@@ -118,6 +126,16 @@ interface IConfig {
public function getUserValue($userId, $appName, $key, $default = '');
/**
+ * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs.
+ *
+ * @param $appName app to get the value for
+ * @param $key the key to get the value for
+ * @param $userIds the user IDs to fetch the values for
+ * @return array Mapped values: userId => value
+ */
+ public function getUserValueForUsers($appName, $key, $userIds);
+
+ /**
* Get the keys of all stored by an app for the user
*
* @param string $userId the userId of the user that we want to store the value under
@@ -134,4 +152,28 @@ interface IConfig {
* @param string $key the key under which the value is being stored
*/
public function deleteUserValue($userId, $appName, $key);
+
+ /**
+ * Delete all user values
+ *
+ * @param string $userId the userId of the user that we want to remove all values from
+ */
+ public function deleteAllUserValues($userId);
+
+ /**
+ * Delete all user related values of one app
+ *
+ * @param string $appName the appName of the app that we want to remove all values from
+ */
+ public function deleteAppFromAllUsers($appName);
+
+ /**
+ * Determines the users that have the given value set for a specific app-key-pair
+ *
+ * @param string $appName the app to get the user for
+ * @param string $key the key to get the user for
+ * @param string $value the value to get the user for
+ * @return array of user IDs
+ */
+ public function getUsersForUserValue($appName, $key, $value);
}
diff --git a/lib/public/preconditionnotmetexception.php b/lib/public/preconditionnotmetexception.php
new file mode 100644
index 00000000000..ceba01a0b4b
--- /dev/null
+++ b/lib/public/preconditionnotmetexception.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Morris Jobke
+ * @copyright 2014 Morris Jobke <hey@morrisjobke.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP;
+
+/**
+ * Exception if the precondition of the config update method isn't met
+ */
+class PreConditionNotMetException extends \Exception {}