Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
2f79e94a
Commit
2f79e94a
authored
11 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Style fixes
parent
ca88cf93
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/appconfig.php
+25
-21
25 additions, 21 deletions
lib/appconfig.php
with
25 additions
and
21 deletions
lib/appconfig.php
+
25
−
21
View file @
2f79e94a
...
...
@@ -42,8 +42,14 @@ use \OC\DB\Connection;
* database.
*/
class
AppConfig
{
/**
* @var \OC\DB\Connection $conn
*/
protected
$conn
;
/**
* @param \OC\DB\Connection $conn
*/
public
function
__construct
(
Connection
$conn
)
{
$this
->
conn
=
$conn
;
}
...
...
@@ -57,10 +63,10 @@ class AppConfig {
*/
public
function
getApps
()
{
$query
=
'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig`'
;
$result
=
$this
->
conn
->
executeQuery
(
$query
);
$result
=
$this
->
conn
->
executeQuery
(
$query
);
$apps
=
array
();
while
(
$appid
=
$result
->
fetchColumn
())
{
while
(
$appid
=
$result
->
fetchColumn
())
{
$apps
[]
=
$appid
;
}
return
$apps
;
...
...
@@ -74,12 +80,12 @@ class AppConfig {
* This function gets all keys of an app. Please note that the values are
* not returned.
*/
public
function
getKeys
(
$app
)
{
public
function
getKeys
(
$app
)
{
$query
=
'SELECT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = ?'
;
$result
=
$this
->
conn
->
executeQuery
(
$query
,
array
(
$app
));
$result
=
$this
->
conn
->
executeQuery
(
$query
,
array
(
$app
));
$keys
=
array
();
while
(
$key
=
$result
->
fetchColumn
())
{
while
(
$key
=
$result
->
fetchColumn
())
{
$keys
[]
=
$key
;
}
...
...
@@ -96,11 +102,11 @@ class AppConfig {
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
*/
public
function
getValue
(
$app
,
$key
,
$default
=
null
)
{
public
function
getValue
(
$app
,
$key
,
$default
=
null
)
{
$query
=
'SELECT `configvalue` FROM `*PREFIX*appconfig`'
.
' WHERE `appid` = ? AND `configkey` = ?'
;
$row
=
$this
->
conn
->
fetchAssoc
(
$query
,
array
(
$app
,
$key
));
if
(
$row
)
{
$row
=
$this
->
conn
->
fetchAssoc
(
$query
,
array
(
$app
,
$key
));
if
(
$row
)
{
return
$row
[
'configvalue'
];
}
else
{
return
$default
;
...
...
@@ -114,8 +120,8 @@ class AppConfig {
* @return bool
*/
public
function
hasKey
(
$app
,
$key
)
{
$exists
=
$this
->
getKeys
(
$app
);
return
in_array
(
$key
,
$exists
);
$exists
=
$this
->
getKeys
(
$app
);
return
in_array
(
$key
,
$exists
);
}
/**
...
...
@@ -126,9 +132,9 @@ class AppConfig {
*
* Sets a value. If the key did not exist before it will be created.
*/
public
function
setValue
(
$app
,
$key
,
$value
)
{
public
function
setValue
(
$app
,
$key
,
$value
)
{
// Does the key exist? no: insert, yes: update.
if
(
!
$this
->
hasKey
(
$app
,
$key
))
{
if
(
!
$this
->
hasKey
(
$app
,
$key
))
{
$data
=
array
(
'appid'
=>
$app
,
'configkey'
=>
$key
,
...
...
@@ -155,7 +161,7 @@ class AppConfig {
*
* Deletes a key.
*/
public
function
deleteKey
(
$app
,
$key
)
{
public
function
deleteKey
(
$app
,
$key
)
{
$where
=
array
(
'appid'
=>
$app
,
'configkey'
=>
$key
,
...
...
@@ -170,7 +176,7 @@ class AppConfig {
*
* Removes all keys in appconfig belonging to the app.
*/
public
function
deleteApp
(
$app
)
{
public
function
deleteApp
(
$app
)
{
$where
=
array
(
'appid'
=>
$app
,
);
...
...
@@ -184,19 +190,19 @@ class AppConfig {
* @return array
*/
public
function
getValues
(
$app
,
$key
)
{
if
((
$app
!==
false
)
==
(
$key
!==
false
))
{
if
((
$app
!==
false
)
==
(
$key
!==
false
))
{
return
false
;
}
$fields
=
'`configvalue`'
;
$where
=
'WHERE'
;
$params
=
array
();
if
(
$app
!==
false
)
{
if
(
$app
!==
false
)
{
$fields
.
=
', `configkey`'
;
$where
.
=
' `appid` = ?'
;
$params
[]
=
$app
;
$key
=
'configkey'
;
}
else
{
}
else
{
$fields
.
=
', `appid`'
;
$where
.
=
' `configkey` = ?'
;
$params
[]
=
$key
;
...
...
@@ -206,12 +212,10 @@ class AppConfig {
$result
=
$this
->
conn
->
executeQuery
(
$query
,
$params
);
$values
=
array
();
while
(
$row
=
$result
->
fetch
((
\PDO
::
FETCH_ASSOC
)))
{
while
(
$row
=
$result
->
fetch
((
\PDO
::
FETCH_ASSOC
)))
{
$values
[
$row
[
$key
]]
=
$row
[
'configvalue'
];
}
return
$values
;
}
}
require_once
__DIR__
.
'/legacy/'
.
basename
(
__FILE__
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment