From c6f78fbe43dbe3f6875b72b34592bde25fc78d0b Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Tue, 27 Sep 2011 22:36:14 +0200
Subject: [PATCH] Add flag in info.xml to control the apps that are installed
 by default

---
 apps/calendar/appinfo/info.xml          | 1 +
 apps/contacts/appinfo/info.xml          | 1 +
 apps/files_imageviewer/appinfo/info.xml | 3 ++-
 apps/files_sharing/appinfo/info.xml     | 3 ++-
 apps/files_textviewer/appinfo/info.xml  | 1 +
 apps/media/appinfo/info.xml             | 3 ++-
 apps/user_openid/appinfo/info.xml       | 3 ++-
 lib/installer.php                       | 8 +++++---
 lib/setup.php                           | 2 +-
 9 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml
index c846fc1eeb..6b1ecd2337 100644
--- a/apps/calendar/appinfo/info.xml
+++ b/apps/calendar/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<author>Georg Ehrke (Userinterface), Jakob Sack</author>
 	<require>2</require>
 	<description>Calendar with CalDAV support</description>
+	<default_enable/>
 </info>
diff --git a/apps/contacts/appinfo/info.xml b/apps/contacts/appinfo/info.xml
index 77c9dc91bf..d18a19c3ae 100644
--- a/apps/contacts/appinfo/info.xml
+++ b/apps/contacts/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<author>Jakob Sack</author>
 	<require>2</require>
 	<description>Address book with CardDAV support.</description>
+	<default_enable/>
 </info>
diff --git a/apps/files_imageviewer/appinfo/info.xml b/apps/files_imageviewer/appinfo/info.xml
index f3b5a67960..00b55c254d 100644
--- a/apps/files_imageviewer/appinfo/info.xml
+++ b/apps/files_imageviewer/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<licence>AGPL</licence>
 	<author>Robin Appelman</author>
 	<require>2</require>
-</info>
\ No newline at end of file
+	<default_enable/>
+</info>
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index 2fbb3300f6..abf847b448 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<licence>AGPL</licence>
 	<author>Michael Gapczynski</author>
 	<require>2</require>
-</info>
\ No newline at end of file
+	<default_enable/>
+</info>
diff --git a/apps/files_textviewer/appinfo/info.xml b/apps/files_textviewer/appinfo/info.xml
index 209b414034..becfd5e35c 100644
--- a/apps/files_textviewer/appinfo/info.xml
+++ b/apps/files_textviewer/appinfo/info.xml
@@ -6,4 +6,5 @@
 	<licence>AGPL</licence>
 	<author>Robin Appelman</author>
 	<require>2</require>
+	<default_enable/>
 </info>
diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml
index 044abade53..795c9a4dd7 100644
--- a/apps/media/appinfo/info.xml
+++ b/apps/media/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<licence>AGPL</licence>
 	<author>Robin Appelman</author>
 	<require>2</require>
-</info>
\ No newline at end of file
+	<default_enable/>
+</info>
diff --git a/apps/user_openid/appinfo/info.xml b/apps/user_openid/appinfo/info.xml
index 32525009d6..332d2199dd 100644
--- a/apps/user_openid/appinfo/info.xml
+++ b/apps/user_openid/appinfo/info.xml
@@ -7,4 +7,5 @@
 	<licence>AGPL</licence>
 	<author>Robin Appelman</author>
 	<require>2</require>
-</info>
\ No newline at end of file
+	<default_enable/>
+</info>
diff --git a/lib/installer.php b/lib/installer.php
index 9416a42c97..0febb2cab4 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -243,13 +243,14 @@ class OC_Installer{
 	 * If $enabled is true, apps are installed as enabled.
 	 * If $enabled is false, apps are installed as disabled.
 	 */
-	public static function installShippedApps( $enabled ){
+	public static function installShippedApps(){
 		$dir = opendir( OC::$SERVERROOT."/apps" );
 		while( false !== ( $filename = readdir( $dir ))){
 			if( substr( $filename, 0, 1 ) != '.' and is_dir(OC::$SERVERROOT."/apps/$filename") ){
 				if( file_exists( OC::$SERVERROOT."/apps/$filename/appinfo/app.php" )){
 					if(!OC_Installer::isInstalled($filename)){
-						OC_Installer::installShippedApp($filename);
+						$info = OC_Installer::installShippedApp($filename);
+						$enabled = isset($info['default_enable']);
 						if( $enabled ){
 							OC_Appconfig::setValue($filename,'enabled','yes');
 						}else{
@@ -265,7 +266,7 @@ class OC_Installer{
 	/**
 	 * install an app already placed in the app folder
 	 * @param string $app id of the app to install
-	 * @return bool
+	 * @returns array see OC_App::getAppInfo
 	 */
 	public static function installShippedApp($app){
 		//install the database
@@ -279,5 +280,6 @@ class OC_Installer{
 		}
 		$info=OC_App::getAppInfo(OC::$SERVERROOT."/apps/$app/appinfo/info.xml");
 		OC_Appconfig::setValue($app,'installed_version',$info['version']);
+		return $info;
 	}
 }
diff --git a/lib/setup.php b/lib/setup.php
index 7b205acd70..8d3079720c 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -206,7 +206,7 @@ class OC_Setup {
 				OC_User::login($username, $password);
 
 				//guess what this does
-				OC_Installer::installShippedApps(true);
+				OC_Installer::installShippedApps();
 
 				//create htaccess files for apache hosts
 				if (strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
-- 
GitLab