]> source.dussan.org Git - nextcloud-server.git/commitdiff
update apps when their version number increases
authorRobin Appelman <icewind1991@gmail.com>
Sun, 11 Dec 2011 21:08:01 +0000 (22:08 +0100)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 8 Jan 2012 00:57:53 +0000 (01:57 +0100)
lib/app.php
lib/base.php

index 1873e1136cd5ac6166eac2dab4ac7ee4e5f9d420..6b35cdffec9cbb87e0031754964884c2628626b1 100644 (file)
@@ -371,4 +371,33 @@ class OC_App{
                }
                return $apps;
        }
+       
+       /**
+        * check if any apps need updating and update those
+        */
+       public static function updateApps(){
+               // The rest comes here
+               $apps = OC_Appconfig::getApps();
+               foreach( $apps as $app ){
+                       $installedVersion=OC_Appconfig::getValue($app,'installed_version');
+                       $appInfo=OC_App::getAppInfo($app);
+                       $currentVersion=$appInfo['version'];
+                       if (version_compare($currentVersion, $installedVersion, '>')) {
+                               OC_App::updateApp($app);
+                       }
+               }
+       }
+       
+       /**
+        * update the database for the app and call the update script
+        * @param string appid
+        */
+       public static function updateApp($appid){
+               if(file_exists(OC::$SERVERROOT.'/apps/'.$file.'/appinfo/database.xml')){
+                       OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/apps/'.$file.'/appinfo/database.xml');
+               }
+               if(file_exists(OC::$SERVERROOT.'/apps/'.$file.'/appinfo/update.php')){
+                       include OC::$SERVERROOT.'/apps/'.$file.'/appinfo/update.php';
+               }
+       }
 }
index 7b42d56f522d3dd712019368924bb9eb1afa8679..c3965c9cd39683e7a6fc2a12dfc2f458bb2dc20e 100644 (file)
@@ -159,6 +159,8 @@ class OC{
                        OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
                }
 
+               OC_App::updateApps();
+
                ini_set('session.cookie_httponly','1;');
                session_start();