summaryrefslogtreecommitdiffstats
path: root/lib/ocsclient.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ocsclient.php')
-rw-r--r--lib/ocsclient.php71
1 files changed, 35 insertions, 36 deletions
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index d0d27263bac..ae35470cff6 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -4,7 +4,7 @@
*
* @author Frank Karlitschek
* @author Jakob Sack
- * @copyright 2010 Frank Karlitschek karlitschek@kde.org
+ * @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -35,12 +35,7 @@ class OC_OCSClient{
* This function returns the url of the OCS AppStore server. It´s possible to set it in the config file or it will fallback to the default
*/
private static function getAppStoreURL(){
- $configurl=OC_Config::getValue('appstoreurl', '');
- if($configurl<>'') {
- $url=$configurl;
- }else{
- $url='http://api.apps.owncloud.com/v1';
- }
+ $url = OC_Config::getValue('appstoreurl', 'http://api.apps.owncloud.com/v1');
return($url);
}
@@ -50,12 +45,7 @@ class OC_OCSClient{
* This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default
*/
private static function getKBURL(){
- $configurl=OC_Config::getValue('knowledgebaseurl', '');
- if($configurl<>'') {
- $url=$configurl;
- }else{
- $url='http://api.apps.owncloud.com/v1';
- }
+ $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1');
return($url);
}
@@ -67,6 +57,9 @@ class OC_OCSClient{
* This function returns a list of all the application categories on the OCS server
*/
public static function getCategories(){
+ if(OC_Config::getValue('appstoreenabled', true)==false){
+ return NULL;
+ }
$url=OC_OCSClient::getAppStoreURL().'/content/categories';
$xml=@file_get_contents($url);
@@ -78,7 +71,7 @@ class OC_OCSClient{
$tmp=$data->data;
$cats=array();
- foreach($tmp->category as $key=>$value) {
+ foreach($tmp->category as $value) {
$id= (int) $value->id;
$name= (string) $value->name;
@@ -140,6 +133,9 @@ class OC_OCSClient{
* This function returns an applications from the OCS server
*/
public static function getApplication($id){
+ if(OC_Config::getValue('appstoreenabled', true)==false){
+ return NULL;
+ }
$url=OC_OCSClient::getAppStoreURL().'/content/data/'.urlencode($id);
$xml=@file_get_contents($url);
@@ -167,31 +163,34 @@ 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=OC_OCSClient::getAppStoreURL().'/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;
+ /**
+ * @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){
+ if(OC_Config::getValue('appstoreenabled', true)==false){
+ return NULL;
+ }
+ $url=OC_OCSClient::getAppStoreURL().'/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;
- }
+ return $app;
+ }
/**