summaryrefslogtreecommitdiffstats
path: root/lib/app.php
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2012-09-18 14:35:27 +0100
committerSam Tuke <samtuke@owncloud.com>2012-09-18 14:35:27 +0100
commitb765e883f32bf271c77e4bfa4a88249e5b371a1a (patch)
treefa7851e829f31dc4b7092be509e808ff43bb11c0 /lib/app.php
parent9bfdf47cd43139ca5c3fba255fd4486d06b6d72c (diff)
downloadnextcloud-server-b765e883f32bf271c77e4bfa4a88249e5b371a1a.tar.gz
nextcloud-server-b765e883f32bf271c77e4bfa4a88249e5b371a1a.zip
Fixed bug with duplicate entries for installed 3rd party apps in settings->apps
Added method getAppstoreApps to OC_App Added minor documentation
Diffstat (limited to 'lib/app.php')
-rwxr-xr-xlib/app.php72
1 files changed, 64 insertions, 8 deletions
diff --git a/lib/app.php b/lib/app.php
index 28f1f16ebaf..328095a90d2 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -397,10 +397,11 @@ class OC_App{
}
/**
- * @brief Read app metadata from the info.xml file
+ * @brief Read all app metadata from the info.xml file
* @param string $appid id of the app or the path of the info.xml file
* @param boolean path (optional)
* @returns array
+ * @note all data is read from info.xml, not just pre-defined fields
*/
public static function getAppInfo($appid,$path=false) {
if($path) {
@@ -442,6 +443,7 @@ class OC_App{
}
}
self::$appInfo[$appid]=$data;
+
return $data;
}
@@ -521,20 +523,74 @@ class OC_App{
}
/**
- * get a list of all apps in the apps folder
+ * @brief: get a list of all apps in the apps folder
+ * @return array or app names (string IDs)
+ * @todo: change the name of this method to getInstalledApps, which is more accurate
*/
public static function getAllApps() {
+
$apps=array();
- foreach(OC::$APPSROOTS as $apps_dir) {
- $dh=opendir($apps_dir['path']);
- while($file=readdir($dh)) {
- if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
- $apps[]=$file;
+
+ foreach ( OC::$APPSROOTS as $apps_dir ) {
+
+ $dh = opendir( $apps_dir['path'] );
+
+ while( $file = readdir( $dh ) ) {
+
+ if (
+ $file[0] != '.'
+ and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php' )
+ ) {
+
+ $apps[] = $file;
+
}
+
}
+
}
+
return $apps;
}
+
+ /**
+ * @brief: get a list of all apps on apps.owncloud.com
+ * @return multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
+ */
+ public static function getAppstoreApps( $filter = 'approved' ) {
+
+ $catagoryNames = OC_OCSClient::getCategories();
+
+ if ( is_array( $catagoryNames ) ) {
+
+ $categories = array_keys( $catagoryNames );
+
+ $page = 0;
+
+ $remoteApps = OC_OCSClient::getApplications( $categories, $page, $filter );
+
+ $app1 = array();
+
+ $i = 0;
+
+ foreach ( $remoteApps as $app ) {
+
+ $app1[$i] = $app;
+
+ $app1[$i]['author'] = $app['personid'];
+
+ $app1[$i]['ocs_id'] = $app['id'];
+
+ $app1[$i]['internal'] = $app1[$i]['active'] = 0;
+
+ $i++;
+
+ }
+
+ }
+
+ return $app1;
+ }
/**
* check if the app need updating and update when needed
@@ -640,7 +696,7 @@ class OC_App{
}
}else{
OC_Log::write('core', 'Can\'t get app storage, app '.$appid.' not enabled', OC_Log::ERROR);
- false;
+ return false;
}
}
}