2012-08-04 22:25:20 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
OC_JSON::checkAdminUser();
|
2012-08-04 22:26:28 +04:00
|
|
|
|
2012-09-18 17:35:27 +04:00
|
|
|
$l = OC_L10N::get('settings');
|
2012-08-04 22:25:20 +04:00
|
|
|
|
2012-09-04 13:31:28 +04:00
|
|
|
if(OC_Config::getValue('appstoreenabled', true)==false) {
|
2012-08-04 22:25:20 +04:00
|
|
|
OCP\JSON::success(array('type' => 'external', 'data' => array()));
|
|
|
|
}
|
|
|
|
|
|
|
|
$enabledApps=OC_App::getEnabledApps();
|
|
|
|
|
|
|
|
if(is_null($enabledApps)) {
|
|
|
|
OCP\JSON::error(array('data' => array('message' => $l->t('Unable to load list from App Store'))));
|
|
|
|
}
|
|
|
|
|
|
|
|
$apps=array();
|
|
|
|
|
|
|
|
// apps from external repo via OCS
|
2013-02-10 02:37:42 +04:00
|
|
|
$categoryNames=OC_OCSClient::getCategories();
|
|
|
|
if(is_array($categoryNames)) {
|
|
|
|
$categories=array_keys($categoryNames);
|
2012-08-04 22:25:20 +04:00
|
|
|
$page=0;
|
2012-08-31 22:22:03 +04:00
|
|
|
$filter='approved';
|
2012-09-04 13:31:28 +04:00
|
|
|
$externalApps=OC_OCSClient::getApplications($categories, $page, $filter);
|
2012-09-07 17:22:01 +04:00
|
|
|
foreach($externalApps as $app) {
|
2012-08-04 22:25:20 +04:00
|
|
|
// show only external apps that aren't enabled yet
|
|
|
|
$local=false;
|
2012-09-07 17:22:01 +04:00
|
|
|
foreach($enabledApps as $a) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if($a === $app['name']) {
|
2012-08-04 22:25:20 +04:00
|
|
|
$local=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$local) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if($app['preview'] === '') {
|
2012-11-10 04:02:47 +04:00
|
|
|
$pre=OC_Helper::imagePath('settings', 'trans.png');
|
2012-08-04 22:25:20 +04:00
|
|
|
} else {
|
|
|
|
$pre=$app['preview'];
|
|
|
|
}
|
2013-04-17 17:32:03 +04:00
|
|
|
if($app['label'] === 'recommended') {
|
2013-02-09 13:09:37 +04:00
|
|
|
$label='3rd Party';
|
2013-01-30 16:39:53 +04:00
|
|
|
} else {
|
|
|
|
$label='Recommended';
|
|
|
|
}
|
2012-08-04 22:25:20 +04:00
|
|
|
$apps[]=array(
|
|
|
|
'name'=>$app['name'],
|
|
|
|
'id'=>$app['id'],
|
|
|
|
'active'=>false,
|
|
|
|
'description'=>$app['description'],
|
|
|
|
'author'=>$app['personid'],
|
|
|
|
'license'=>$app['license'],
|
|
|
|
'preview'=>$pre,
|
|
|
|
'internal'=>false,
|
2013-01-30 16:39:53 +04:00
|
|
|
'internallabel'=>$label,
|
2013-01-21 23:40:23 +04:00
|
|
|
'update'=>false,
|
2012-08-04 22:25:20 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OCP\JSON::success(array('type' => 'external', 'data' => $apps));
|