5
* @author Frank Karlitschek
7
* @copyright 2012 Frank Karlitschek frank@owncloud.org
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
* License as published by the Free Software Foundation; either
12
* version 3 of the License, or any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
19
* You should have received a copy of the GNU Affero General Public
20
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
25
* This class provides an easy way for storing user preferences.
27
OC_Preferences::$object = new \OC\Preferences(OC_DB::getConnection());
29
public static $object;
31
* @brief Get all users using the preferences
32
* @return array with user ids
34
* This function returns a list of all users that have at least one entry
35
* in the preferences table.
37
public static function getUsers() {
38
return self::$object->getUsers();
42
* @brief Get all apps of a user
43
* @param string $user user
44
* @return array with app ids
46
* This function returns a list of all apps of the user that have at least
47
* one entry in the preferences table.
49
public static function getApps( $user ) {
50
return self::$object->getApps( $user );
54
* @brief Get the available keys for an app
55
* @param string $user user
56
* @param string $app the app we are looking for
57
* @return array with key names
59
* This function gets all keys of an app of an user. Please note that the
60
* values are not returned.
62
public static function getKeys( $user, $app ) {
63
return self::$object->getKeys( $user, $app );
67
* @brief Gets the preference
68
* @param string $user user
69
* @param string $app app
70
* @param string $key key
71
* @param string $default = null, default value if the key does not exist
72
* @return string the value or $default
74
* This function gets a value from the preferences table. If the key does
75
* not exist the default value will be returned
77
public static function getValue( $user, $app, $key, $default = null ) {
78
return self::$object->getValue( $user, $app, $key, $default );
82
* @brief sets a value in the preferences
83
* @param string $user user
84
* @param string $app app
85
* @param string $key key
86
* @param string $value value
89
* Adds a value to the preferences. If the key did not exist before, it
90
* will be added automagically.
92
public static function setValue( $user, $app, $key, $value ) {
93
self::$object->setValue( $user, $app, $key, $value );
98
* @brief Deletes a key
99
* @param string $user user
100
* @param string $app app
101
* @param string $key key
105
public static function deleteKey( $user, $app, $key ) {
106
self::$object->deleteKey( $user, $app, $key );
111
* @brief Remove app of user from preferences
112
* @param string $user user
113
* @param string $app app
116
* Removes all keys in preferences belonging to the app and the user.
118
public static function deleteApp( $user, $app ) {
119
self::$object->deleteApp( $user, $app );
124
* @brief Remove user from preferences
125
* @param string $user user
128
* Removes all keys in preferences belonging to the user.
130
public static function deleteUser( $user ) {
131
self::$object->deleteUser( $user );
136
* @brief Remove app from all users
137
* @param string $app app
140
* Removes all keys in preferences belonging to the app.
142
public static function deleteAppFromAllUsers( $app ) {
143
self::$object->deleteAppFromAllUsers( $app );