From 9df403f051354b24da61b12f6446d10d899f05f7 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Tue, 18 Sep 2012 16:51:55 +0100 Subject: [PATCH] Added failsafes for retrieving remote apps on settings->apps page, in case categories or app data are not found --- lib/app.php | 17 +++++++++++++++-- lib/ocsclient.php | 2 +- settings/apps.php | 44 +++++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lib/app.php b/lib/app.php index 328095a90d..38ba4bcdc8 100755 --- a/lib/app.php +++ b/lib/app.php @@ -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; + + } } /** diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 8596ea0b3c..6428a88367 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -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() { diff --git a/settings/apps.php b/settings/apps.php index 1481f6fc4a..a1c1bf6aa5 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -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 [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 [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']) {