From 982cde0bb1a9230b793f7341eba5d8117c48ca0b Mon Sep 17 00:00:00 2001
From: Frank Karlitschek <frank@owncloud.org>
Date: Sat, 26 May 2012 20:37:10 +0200
Subject: [PATCH] check during ownCloud upgrade if all the installed apps are
 compatible with the new ownCloud version. Disable them if not

---
 lib/app.php         | 24 ++++++++++++++++++++++--
 settings/js/apps.js |  4 ++--
 2 files changed, 24 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 lib/app.php

diff --git a/lib/app.php b/lib/app.php
old mode 100644
new mode 100755
index c639d2c4a5..78de0fa21b
--- a/lib/app.php
+++ b/lib/app.php
@@ -189,11 +189,11 @@ class OC_App{
 			}
 		}
 		if($app!==false){
-             		// check if the app is compatible with this version of ownCloud
+			// check if the app is compatible with this version of ownCloud
 			$info=OC_App::getAppInfo($app);
 			$version=OC_Util::getVersion();	
 	                if(!isset($info['require']) or ($version[0]>$info['require'])){
-				OC_Log::write('core','App can\'t be installed because it is not compatible with this version of ownCloud',OC_Log::ERROR);
+				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;
 			}else{
 				OC_Appconfig::setValue( $app, 'enabled', 'yes' );
@@ -525,6 +525,26 @@ class OC_App{
 				}
 			}
 		}
+		
+		// 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 );
+			}
+
+	
+			
+		}
+		
+		
+		
 	}
 
 	/**
diff --git a/settings/js/apps.js b/settings/js/apps.js
index 8aa54463b3..f6e08b608b 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -41,7 +41,7 @@ $(document).ready(function(){
 			if(active){
 				$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:app},function(result){
 					if(!result || result.status!='success'){
-						OC.dialogs.alert('Error','Error while disabling app');
+						OC.dialogs.alert('Error while disabling app','Error');
 					}
 					else {
 						element.data('active',false);
@@ -54,7 +54,7 @@ $(document).ready(function(){
 			}else{
 				$.post(OC.filePath('settings','ajax','enableapp.php'),{appid:app},function(result){
 					if(!result || result.status!='success'){
-						OC.dialogs.alert('Error','Error while enabling app');
+						OC.dialogs.alert('Error while enabling app','Error');
 					}
 					else {
 						element.data('active',true);
-- 
GitLab