Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
593ef76e
Commit
593ef76e
authored
Nov 20, 2014
by
Morris Jobke
Browse files
Revert "drop OC_Preferences::getUsers and getApps"
This reverts commit
09fd34ee
.
parent
78d9d491
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/private/legacy/preferences.php
View file @
593ef76e
...
...
@@ -28,6 +28,28 @@ OC_Preferences::$object = new \OC\Preferences(OC_DB::getConnection());
*/
class
OC_Preferences
{
public
static
$object
;
/**
* Get all users using the preferences
* @return array an array of user ids
*
* This function returns a list of all users that have at least one entry
* in the preferences table.
*/
public
static
function
getUsers
()
{
return
self
::
$object
->
getUsers
();
}
/**
* Get all apps of a user
* @param string $user user
* @return integer[] with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
*/
public
static
function
getApps
(
$user
)
{
return
self
::
$object
->
getApps
(
$user
);
}
/**
* Get the available keys for an app
...
...
lib/private/preferences.php
View file @
593ef76e
...
...
@@ -67,6 +67,25 @@ class Preferences {
$this
->
conn
=
$conn
;
}
/**
* Get all users using the preferences
* @return array an array of user ids
*
* This function returns a list of all users that have at least one entry
* in the preferences table.
*/
public
function
getUsers
()
{
$query
=
'SELECT DISTINCT `userid` FROM `*PREFIX*preferences`'
;
$result
=
$this
->
conn
->
executeQuery
(
$query
);
$users
=
array
();
while
(
$userid
=
$result
->
fetchColumn
())
{
$users
[]
=
$userid
;
}
return
$users
;
}
/**
* @param string $user
* @return array[]
...
...
@@ -89,6 +108,19 @@ class Preferences {
return
$data
;
}
/**
* Get all apps of an user
* @param string $user user
* @return integer[] with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
*/
public
function
getApps
(
$user
)
{
$data
=
$this
->
getUserValues
(
$user
);
return
array_keys
(
$data
);
}
/**
* Get the available keys for an app
* @param string $user user
...
...
tests/lib/preferences-singleton.php
View file @
593ef76e
...
...
@@ -40,6 +40,34 @@ class Test_Preferences extends \Test\TestCase {
parent
::
tearDownAfterClass
();
}
public
function
testGetUsers
()
{
$query
=
\
OC_DB
::
prepare
(
'SELECT DISTINCT `userid` FROM `*PREFIX*preferences`'
);
$result
=
$query
->
execute
();
$expected
=
array
();
while
(
$row
=
$result
->
fetchRow
())
{
$expected
[]
=
$row
[
'userid'
];
}
sort
(
$expected
);
$users
=
\
OC_Preferences
::
getUsers
();
sort
(
$users
);
$this
->
assertEquals
(
$expected
,
$users
);
}
public
function
testGetApps
()
{
$query
=
\
OC_DB
::
prepare
(
'SELECT DISTINCT `appid` FROM `*PREFIX*preferences` WHERE `userid` = ?'
);
$result
=
$query
->
execute
(
array
(
'Someuser'
));
$expected
=
array
();
while
(
$row
=
$result
->
fetchRow
())
{
$expected
[]
=
$row
[
'appid'
];
}
sort
(
$expected
);
$apps
=
\
OC_Preferences
::
getApps
(
'Someuser'
);
sort
(
$apps
);
$this
->
assertEquals
(
$expected
,
$apps
);
}
public
function
testGetKeys
()
{
$query
=
\
OC_DB
::
prepare
(
'SELECT DISTINCT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?'
);
$result
=
$query
->
execute
(
array
(
'Someuser'
,
'getkeysapp'
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment