]> source.dussan.org Git - nextcloud-server.git/commitdiff
shipped apps are no longer hardcoded
authorKamil Domanski <kdomanski@kdemail.net>
Sun, 19 Jun 2011 20:42:33 +0000 (22:42 +0200)
committerKamil Domanski <kdomanski@kdemail.net>
Sun, 19 Jun 2011 20:46:05 +0000 (22:46 +0200)
lib/installer.php
lib/setup.php

index 02b71027cd7f3aca23250a83f8434429cd72c362..91b7ea7da6786fbf11bd3c02cd2b5e0867a2829a 100644 (file)
@@ -108,7 +108,7 @@ class OC_INSTALLER{
                $basedir=$SERVERROOT.'/apps/'.$info['id'];
                
                //check if an app with the same id is already installed
-               if(self::isInstalled( $info['id'] ))){
+               if(self::isInstalled( $info['id'] )){
                        error_log("App already installed");
                        OC_HELPER::rmdirr($extractDir);
                        if($data['source']=='http'){
@@ -118,14 +118,14 @@ class OC_INSTALLER{
                }
 
                //check if the destination directory already exists
-+              if(is_dir($basedir)){
-+                      error_log("App's directory already exists");
-+                      OC_HELPER::rmdirr($extractDir);
-+                      if($data['source']=='http'){
-+                              unlink($path);
-+                      }
-+                      return false;
-+              }
+               if(is_dir($basedir)){
+                       error_log("App's directory already exists");
+                       OC_HELPER::rmdirr($extractDir);
+                       if($data['source']=='http'){
+                               unlink($path);
+                       }
+                       return false;
+               }
                
                if(isset($data['pretent']) and $data['pretent']==true){
                        return false;
index 43ead7b96acf49b6845140ac4ab5201a1185612d..0e324b741a221d7c9d79eab6723f596f5b8513af 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+include_once( 'installer.php' );
+
 $hasSQLite = (is_callable('sqlite_open') or class_exists('SQLite3'));
 $hasMySQL = is_callable('mysql_connect');
 $datadir = OC_CONFIG::getValue('datadir', $SERVERROOT.'/data');
@@ -31,7 +33,6 @@ else {
 
 class OC_SETUP {
        public static function install($options) {
-               global $SERVERROOT;
                $error = array();
                $dbtype = $options['dbtype'];
                
@@ -134,21 +135,8 @@ class OC_SETUP {
                                OC_GROUP::createGroup('admin');
                                OC_GROUP::addToGroup($username, 'admin');
 
-                               foreach( array( "files_imageviewer", "files_publiclink" ) as $app ){
-
-                                       if(is_file("$SERVERROOT/apps/$app/appinfo/database.xml")){
-                                               OC_DB::createDbFromStructure("$SERVERROOT/apps/$app/appinfo/database.xml");
-                                       }
-
-                                       //run appinfo/install.php
-                                       if(is_file("$SERVERROOT/apps/$app/appinfo/install.php")){
-                                               include("$SERVERROOT/apps/$app/appinfo/install.php");
-                                       }
-
-                                       $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml");
-                                       OC_APPCONFIG::setValue($app,'installed_version',$info['version']);
-                                       OC_APPCONFIG::setValue($app,'enabled','yes');
-                               }
+                               //guess what this does
+                               self::installShippedApps();
 
                                //create htaccess files for apache hosts
                                self::createHtaccess(); //TODO detect if apache is used
@@ -198,6 +186,32 @@ class OC_SETUP {
                $content = "deny from all";
                file_put_contents(OC_CONFIG::getValue('datadirectory', $SERVERROOT.'/data').'/.htaccess', $content);
        }
+
+       private static function installShippedApps(){
+               global $SERVERROOT;
+               $dir = opendir( "$SERVERROOT/apps" );
+               while( false !== ( $filename = readdir( $dir ))){
+                       if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){
+                               if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){
+                                       if(!OC_INSTALLER::isInstalled($filename)){
+                                               //install the database
+                                               if(is_file("$SERVERROOT/apps/$filename/appinfo/database.xml")){
+                                                       OC_DB::createDbFromStructure("$SERVERROOT/apps/$filename/appinfo/database.xml");
+                                               }
+
+                                               //run appinfo/install.php
+                                               if(is_file("$SERVERROOT/apps/$filename/appinfo/install.php")){
+                                                       include("$SERVERROOT/apps/$filename/appinfo/install.php");
+                                               }
+                                               $info=OC_APP::getAppInfo("$SERVERROOT/apps/$filename/appinfo/info.xml");
+                                               OC_APPCONFIG::setValue($filename,'installed_version',$info['version']);
+                                               OC_APPCONFIG::setValue($filename,'enabled','yes');
+                                       }
+                               }
+                       }
+               }
+               closedir( $dir );
+       }
 }
 
 ?>