Merge pull request #5146 from guruz/cache_enabled_apps_list
OC_App: Cache list of enabled apps
This commit is contained in:
commit
92d9263e24
|
@ -165,10 +165,14 @@ class OC_App{
|
||||||
/**
|
/**
|
||||||
* get all enabled apps
|
* get all enabled apps
|
||||||
*/
|
*/
|
||||||
|
private static $enabledAppsCache = array();
|
||||||
public static function getEnabledApps() {
|
public static function getEnabledApps() {
|
||||||
if(!OC_Config::getValue('installed', false)) {
|
if(!OC_Config::getValue('installed', false)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
if(!empty(self::$enabledAppsCache)) {
|
||||||
|
return self::$enabledAppsCache;
|
||||||
|
}
|
||||||
$apps=array('files');
|
$apps=array('files');
|
||||||
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
|
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
|
||||||
.' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
|
.' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
|
||||||
|
@ -187,6 +191,7 @@ class OC_App{
|
||||||
$apps[]=$row['appid'];
|
$apps[]=$row['appid'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self::$enabledAppsCache = $apps;
|
||||||
return $apps;
|
return $apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,11 +203,11 @@ class OC_App{
|
||||||
* This function checks whether or not an app is enabled.
|
* This function checks whether or not an app is enabled.
|
||||||
*/
|
*/
|
||||||
public static function isEnabled( $app ) {
|
public static function isEnabled( $app ) {
|
||||||
if( 'files'==$app or ('yes' == OC_Appconfig::getValue( $app, 'enabled' ))) {
|
if('files' == $app) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
$enabledApps = self::getEnabledApps();
|
||||||
return false;
|
return in_array($app, $enabledApps);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,6 +219,7 @@ class OC_App{
|
||||||
* This function set an app as enabled in appconfig.
|
* This function set an app as enabled in appconfig.
|
||||||
*/
|
*/
|
||||||
public static function enable( $app ) {
|
public static function enable( $app ) {
|
||||||
|
self::$enabledAppsCache = array(); // flush
|
||||||
if(!OC_Installer::isInstalled($app)) {
|
if(!OC_Installer::isInstalled($app)) {
|
||||||
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
|
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
|
||||||
if(!is_numeric($app)) {
|
if(!is_numeric($app)) {
|
||||||
|
@ -257,6 +263,7 @@ class OC_App{
|
||||||
* This function set an app as disabled in appconfig.
|
* This function set an app as disabled in appconfig.
|
||||||
*/
|
*/
|
||||||
public static function disable( $app ) {
|
public static function disable( $app ) {
|
||||||
|
self::$enabledAppsCache = array(); // flush
|
||||||
// check if app is a shipped app or not. if not delete
|
// check if app is a shipped app or not. if not delete
|
||||||
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
|
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
|
||||||
OC_Appconfig::setValue( $app, 'enabled', 'no' );
|
OC_Appconfig::setValue( $app, 'enabled', 'no' );
|
||||||
|
|
Loading…
Reference in New Issue