Skip to content

Commit

Permalink
make it possible to load apps seperately. needed to fix oc-910 withou…
Browse files Browse the repository at this point in the history
…t breaking oc-863
  • Loading branch information
blizzz committed Jun 4, 2012
1 parent b117a1e commit 773f3cf
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions lib/app.php
Expand Up @@ -27,7 +27,6 @@
* upgrading and removing apps.
*/
class OC_App{
static private $init = false;
static private $apps = array();
static private $activeapp = '';
static private $navigation = array();
Expand All @@ -36,6 +35,7 @@ class OC_App{
static private $personalForms = array();
static private $appInfo = array();
static private $appTypes = array();
static private $loadedApps = array();

/**
* @brief loads all apps
Expand All @@ -49,15 +49,11 @@ class OC_App{
* if $types is set, only apps of those types will be loaded
*/
public static function loadApps($types=null){
// Did we already load everything?
if( self::$init ){
return true;
}

// Our very own core apps are hardcoded
foreach( array( 'settings') as $app ){
if(is_null($types)){
if(is_null($types) && !in_array($app, self::$loadedApps)){
require( $app.'/appinfo/app.php' );
self::$loadedApps[] = $app;
}
}

Expand All @@ -66,14 +62,13 @@ public static function loadApps($types=null){
// prevent app.php from printing output
ob_start();
foreach( $apps as $app ){
if((is_null($types) or self::isType($app,$types))){
if((is_null($types) or self::isType($app,$types)) && !in_array($app, self::$loadedApps)){
self::loadApp($app);
self::$loadedApps[] = $app;
}
}
ob_end_clean();

self::$init = true;

// return
return true;
}
Expand Down Expand Up @@ -129,7 +124,7 @@ private static function getAppTypes($app){
*/
public static function setAppTypes($app){
$appData=self::getAppInfo($app);

if(isset($appData['types'])){
$appTypes=implode(',',$appData['types']);
}else{
Expand Down Expand Up @@ -191,7 +186,7 @@ public static function enable( $app ){
if($app!==false){
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
$version=OC_Util::getVersion();
$version=OC_Util::getVersion();
if(!isset($info['require']) or ($version[0]>$info['require'])){
OC_Log::write('core','App "'.$info['name'].'" can\'t be installed because it is not compatible with this version of ownCloud',OC_Log::ERROR);
return false;
Expand Down Expand Up @@ -525,26 +520,26 @@ public static function updateApps(){
}
}
}

// check if the current enabled apps are compatible with the current ownCloud version. disable them if not.
// this is important if you upgrade ownCloud and have non ported 3rd party apps installed
$apps =OC_App::getEnabledApps();
$version=OC_Util::getVersion();
foreach($apps as $app) {

// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
if(!isset($info['require']) or ($version[0]>$info['require'])){
OC_Log::write('core','App "'.$info['name'].'" can\'t be used because it is not compatible with this version of ownCloud',OC_Log::ERROR);
OC_App::disable( $app );
}



}



}

/**
Expand Down

0 comments on commit 773f3cf

Please sign in to comment.