]> source.dussan.org Git - nextcloud-server.git/commitdiff
Added failsafes for retrieving remote apps on settings->apps page, in case categories...
authorSam Tuke <samtuke@owncloud.com>
Tue, 18 Sep 2012 15:51:55 +0000 (16:51 +0100)
committerSam Tuke <samtuke@owncloud.com>
Tue, 18 Sep 2012 15:55:03 +0000 (16:55 +0100)
lib/app.php
lib/ocsclient.php
settings/apps.php

index 328095a90d290ef212de29d08693cd836deb2d43..38ba4bcdc8812d5ae9d95b50204c2b3c87a65f81 100755 (executable)
@@ -563,7 +563,12 @@ class OC_App{
                
                if ( is_array( $catagoryNames ) ) {
                        
-                       $categories = array_keys( $catagoryNames );
+                       // Check that categories of apps were retrieved correctly
+                       if ( ! $categories = array_keys( $catagoryNames ) ) {
+                       
+                               return false;
+                               
+                       }
                        
                        $page = 0;
                
@@ -589,7 +594,15 @@ class OC_App{
                
                }
                
-               return $app1;
+               if ( empty( $app1 ) ) {
+               
+                       return false;
+                       
+               } else {
+               
+                       return $app1;
+                       
+               }
        }
 
        /**
index 8596ea0b3c7fb0374013d0c58c885165c5c7cf92..6428a88367918db03ebb7c18f341da83f1f52747 100644 (file)
@@ -53,7 +53,7 @@ class OC_OCSClient{
        /**
         * @brief Get all the categories from the OCS server
         * @returns array with category ids
-        *
+        * @note returns NULL if config value appstoreenabled is set to false
         * This function returns a list of all the application categories on the OCS server
         */
        public static function getCategories() {
index 1481f6fc4ada0b9ab27661bd7def7ad4d622d6ee..a1c1bf6aa5303710fb3d308a8111e5414ed23cb4 100644 (file)
@@ -31,10 +31,6 @@ OC_App::setActiveNavigationEntry( "core_apps" );
 
 $installedApps = OC_App::getAllApps();
 
-$remoteApps = OC_App::getAppstoreApps();
-
-//$remoteApps = array();
-
 //TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature?
 
 $blacklist = array('files');//we dont want to show configuration for these
@@ -90,29 +86,39 @@ foreach ( $installedApps as $app ) {
        }
 }
 
-// Remove duplicates
-foreach ( $appList as $app ) {
+$remoteApps = OC_App::getAppstoreApps();
 
-       foreach ( $remoteApps AS $key => $remote ) {
-       
-               if ( 
-               $app['name'] == $remote['name']
-               // To set duplicate detection to use OCS ID instead of string name, 
-               // enable this code, remove the line of code above, 
-               // and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app: 
-               // OR $app['ocs_id'] == $remote['ocs_id']
-               ) {
+if ( $remoteApps ) {
+
+       // Remove duplicates
+       foreach ( $appList as $app ) {
+
+               foreach ( $remoteApps AS $key => $remote ) {
+               
+                       if ( 
+                       $app['name'] == $remote['name']
+                       // To set duplicate detection to use OCS ID instead of string name, 
+                       // enable this code, remove the line of code above, 
+                       // and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app: 
+                       // OR $app['ocs_id'] == $remote['ocs_id']
+                       ) {
+                               
+                               unset( $remoteApps[$key]);
                        
-                       unset( $remoteApps[$key]);
+                       }
                
                }
-       
+               
        }
+
+       $combinedApps = array_merge( $appList, $remoteApps );
+
+} else {
+
+       $combinedApps = $appList;
        
 }
 
-$combinedApps = array_merge( $appList, $remoteApps );
-
 function app_sort( $a, $b ) {
 
        if ($a['active'] != $b['active']) {