]> source.dussan.org Git - nextcloud-server.git/commitdiff
finish the application store feature so that users can download and install ownCloud...
authorFrank Karlitschek <karlitschek@kde.org>
Fri, 6 Jan 2012 18:08:35 +0000 (19:08 +0100)
committerFrank Karlitschek <karlitschek@kde.org>
Fri, 6 Jan 2012 18:08:35 +0000 (19:08 +0100)
lib/app.php
lib/ocsclient.php
settings/apps.php

index b1aa8ba354df2580a2ebaf4ff1e3a08c22ced001..1873e1136cd5ac6166eac2dab4ac7ee4e5f9d420 100644 (file)
@@ -94,7 +94,15 @@ class OC_App{
         */
        public static function enable( $app ){
                if(!OC_Installer::isInstalled($app)){
-                       OC_Installer::installShippedApp($app);
+                       // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
+                       if(!is_numeric($app)){
+                               OC_Installer::installShippedApp($app);
+                       }else{
+                                $download=OC_OCSClient::getApplicationDownload($app,1);
+                               if(isset($download['downloadlink']) and $download['downloadlink']<>'') {
+                                       OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink']));
+                               }
+                       }
                }
                OC_Appconfig::setValue( $app, 'enabled', 'yes' );
        }
@@ -107,6 +115,7 @@ class OC_App{
         * This function set an app as disabled in appconfig.
         */
        public static function disable( $app ){
+               // check if app is a shiped app or not. if not delete
                OC_Appconfig::setValue( $app, 'enabled', 'no' );
        }
 
index 072fd236fee18a70d5186a78d08febb4026e244a..9d5932fb720bd54d323c23a55dc3ee084e56281c 100644 (file)
@@ -130,6 +130,33 @@ class OC_OCSClient{
                return $app;
        }
 
+        /**
+         * @brief Get the download url for an application from the OCS server
+         * @returns array with application data
+         *
+         * This function returns an download url for an applications from the OCS server
+         */
+        public static function getApplicationDownload($id,$item){
+                $url='http://api.apps.owncloud.com/v1/content/download/'.urlencode($id).'/'.urlencode($item);
+
+                $xml=@file_get_contents($url);
+                if($xml==FALSE){
+                        OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
+                        return NULL;
+                }
+                $data=simplexml_load_string($xml);
+
+                $tmp=$data->data->content;
+                $app=array();
+                if(isset($tmp->downloadlink)) { 
+                       $app['downloadlink']=$tmp->downloadlink;
+               }else{
+                       $app['downloadlink']='';
+               }
+                return $app;
+        }
+
+
        /**
         * @brief Get all the knowledgebase entries from the OCS server
         * @returns array with q and a data
index 12a7bf772025b2e234325d084fd9596331c83aa4..40b72639cd6dc0fa606061b60b5bd0f17f4fcb2d 100644 (file)
@@ -51,22 +51,22 @@ function app_sort($a, $b){
 }
 usort($apps, 'app_sort');
 
-// dissabled for now
-// $catagoryNames=OC_OCSClient::getCategories();
-// if(is_array($catagoryNames)){
-//     $categories=array_keys($catagoryNames);
-//     $externalApps=OC_OCSClient::getApplications($categories);
-//     foreach($externalApps as $app){
-//             $apps[]=array(
-//                     'name'=>$app['name'],
-//                     'id'=>$app['id'],
-//                     'active'=>false,
-//                     'description'=>$app['description'],
-//                     'author'=>$app['personid'],
-//                     'license'=>$app['license'],
-//             );
-//     }
-// }
+// apps from external repo via OCS
+ $catagoryNames=OC_OCSClient::getCategories();
+ if(is_array($catagoryNames)){
+       $categories=array_keys($catagoryNames);
+       $externalApps=OC_OCSClient::getApplications($categories);
+       foreach($externalApps as $app){
+               $apps[]=array(
+                       'name'=>$app['name'],
+                       'id'=>$app['id'],
+                       'active'=>false,
+                       'description'=>$app['description'],
+                       'author'=>$app['personid'],
+                       'license'=>$app['license'],
+               );
+       }
+ }