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
dec13971
Commit
dec13971
authored
12 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
cache app types in the db
parent
5608867e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/app.php
+28
-5
28 additions, 5 deletions
lib/app.php
lib/appconfig.php
+34
-0
34 additions, 0 deletions
lib/appconfig.php
with
62 additions
and
5 deletions
lib/app.php
+
28
−
5
View file @
dec13971
...
...
@@ -35,6 +35,7 @@ class OC_App{
static
private
$adminForms
=
array
();
static
private
$personalForms
=
array
();
static
private
$appInfo
=
array
();
static
private
$appTypes
=
array
();
/**
* @brief loads all apps
...
...
@@ -85,11 +86,7 @@ class OC_App{
if
(
is_string
(
$types
)){
$types
=
array
(
$types
);
}
$appData
=
self
::
getAppInfo
(
$app
);
if
(
!
isset
(
$appData
[
'types'
])){
return
false
;
}
$appTypes
=
$appData
[
'types'
];
$appTypes
=
self
::
getAppTypes
(
$app
);
foreach
(
$types
as
$type
){
if
(
array_search
(
$type
,
$appTypes
)
!==
false
){
return
true
;
...
...
@@ -97,6 +94,32 @@ class OC_App{
}
return
false
;
}
/**
* get the types of an app
* @param string $app
* @return array
*/
private
static
function
getAppTypes
(
$app
){
//load the cache
if
(
count
(
self
::
$appTypes
)
==
0
){
self
::
$appTypes
=
OC_Appconfig
::
getValues
(
false
,
'types'
);
}
//get it from info.xml if we haven't cached it
if
(
!
isset
(
self
::
$appTypes
[
$app
])){
$appData
=
self
::
getAppInfo
(
$app
);
if
(
isset
(
$appData
[
'types'
])){
self
::
$appTypes
[
$app
]
=
$appData
[
'types'
];
}
else
{
self
::
$appTypes
[
$app
]
=
array
();
}
OC_Appconfig
::
setValue
(
$app
,
'types'
,
implode
(
','
,
self
::
$appTypes
[
$app
]));
}
return
explode
(
','
,
self
::
$appTypes
[
$app
]);
}
/**
* get all enabled apps
...
...
This diff is collapsed.
Click to expand it.
lib/appconfig.php
+
34
−
0
View file @
dec13971
...
...
@@ -163,4 +163,38 @@ class OC_Appconfig{
return
true
;
}
/**
* get multiply values, either the app or key can be used as wildcard by setting it to false
* @param app
* @param key
* @return array
*/
public
static
function
getValues
(
$app
,
$key
){
if
(
$app
!==
false
and
$key
!==
false
){
return
false
;
}
$where
=
'WHERE'
;
$fields
=
'configvalue'
;
$params
=
array
();
if
(
$app
!==
false
){
$where
.
=
' appid = ?'
;
$fields
.
=
', configkey'
;
$params
[]
=
$app
;
$key
=
'configkey'
;
}
else
{
$fields
.
=
', appid'
;
$where
.
=
' configkey = ?'
;
$params
[]
=
$key
;
$key
=
'appid'
;
}
$queryString
=
'SELECT '
.
$fields
.
' FROM *PREFIX*appconfig '
.
$where
;
$query
=
OC_DB
::
prepare
(
$queryString
);
$result
=
$query
->
execute
(
$params
);
$values
=
array
();
while
(
$row
=
$result
->
fetchRow
()){
$values
[
$row
[
$key
]]
=
$row
[
'configvalue'
];
}
return
$values
;
}
}
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