~pvigo/+junk/owncloud-14.04

« back to all changes in this revision

Viewing changes to share/owncloud/lib/private/legacy/preferences.php

  • Committer: Pablo Vigo
  • Date: 2014-12-15 13:36:46 UTC
  • Revision ID: pvigo@xtec.cat-20141215133646-7d6it90e1dbsijc2
2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * ownCloud
 
4
 *
 
5
 * @author Frank Karlitschek
 
6
 * @author Jakob Sack
 
7
 * @copyright 2012 Frank Karlitschek frank@owncloud.org
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
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/>.
 
21
 *
 
22
 */
 
23
 
 
24
/**
 
25
 * This class provides an easy way for storing user preferences.
 
26
 */
 
27
OC_Preferences::$object = new \OC\Preferences(OC_DB::getConnection());
 
28
class OC_Preferences{
 
29
        public static $object;
 
30
        /**
 
31
         * @brief Get all users using the preferences
 
32
         * @return array with user ids
 
33
         *
 
34
         * This function returns a list of all users that have at least one entry
 
35
         * in the preferences table.
 
36
         */
 
37
        public static function getUsers() {
 
38
                return self::$object->getUsers();
 
39
        }
 
40
 
 
41
        /**
 
42
         * @brief Get all apps of a user
 
43
         * @param string $user user
 
44
         * @return array with app ids
 
45
         *
 
46
         * This function returns a list of all apps of the user that have at least
 
47
         * one entry in the preferences table.
 
48
         */
 
49
        public static function getApps( $user ) {
 
50
                return self::$object->getApps( $user );
 
51
        }
 
52
 
 
53
        /**
 
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
 
58
         *
 
59
         * This function gets all keys of an app of an user. Please note that the
 
60
         * values are not returned.
 
61
         */
 
62
        public static function getKeys( $user, $app ) {
 
63
                return self::$object->getKeys( $user, $app );
 
64
        }
 
65
 
 
66
        /**
 
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
 
73
         *
 
74
         * This function gets a value from the preferences table. If the key does
 
75
         * not exist the default value will be returned
 
76
         */
 
77
        public static function getValue( $user, $app, $key, $default = null ) {
 
78
                return self::$object->getValue( $user, $app, $key, $default );
 
79
        }
 
80
 
 
81
        /**
 
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
 
87
         * @return bool
 
88
         *
 
89
         * Adds a value to the preferences. If the key did not exist before, it
 
90
         * will be added automagically.
 
91
         */
 
92
        public static function setValue( $user, $app, $key, $value ) {
 
93
                self::$object->setValue( $user, $app, $key, $value );
 
94
                return true;
 
95
        }
 
96
 
 
97
        /**
 
98
         * @brief Deletes a key
 
99
         * @param string $user user
 
100
         * @param string $app app
 
101
         * @param string $key key
 
102
         *
 
103
         * Deletes a key.
 
104
         */
 
105
        public static function deleteKey( $user, $app, $key ) {
 
106
                self::$object->deleteKey( $user, $app, $key );
 
107
                return true;
 
108
        }
 
109
 
 
110
        /**
 
111
         * @brief Remove app of user from preferences
 
112
         * @param string $user user
 
113
         * @param string $app app
 
114
         * @return bool
 
115
         *
 
116
         * Removes all keys in preferences belonging to the app and the user.
 
117
         */
 
118
        public static function deleteApp( $user, $app ) {
 
119
                self::$object->deleteApp( $user, $app );
 
120
                return true;
 
121
        }
 
122
 
 
123
        /**
 
124
         * @brief Remove user from preferences
 
125
         * @param string $user user
 
126
         * @return bool
 
127
         *
 
128
         * Removes all keys in preferences belonging to the user.
 
129
         */
 
130
        public static function deleteUser( $user ) {
 
131
                self::$object->deleteUser( $user );
 
132
                return true;
 
133
        }
 
134
 
 
135
        /**
 
136
         * @brief Remove app from all users
 
137
         * @param string $app app
 
138
         * @return bool
 
139
         *
 
140
         * Removes all keys in preferences belonging to the app.
 
141
         */
 
142
        public static function deleteAppFromAllUsers( $app ) {
 
143
                self::$object->deleteAppFromAllUsers( $app );
 
144
                return true;
 
145
        }
 
146
}