Blame view

sources/settings/ajax/apps/ocs.php 1.6 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <?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();
  
  $l = OC_L10N::get('settings');
  
  if(OC_Config::getValue('appstoreenabled', true)==false) {
  	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
  $categoryNames=OC_OCSClient::getCategories();
  if(is_array($categoryNames)) {
  	$categories=array_keys($categoryNames);
  	$page=0;
  	$filter='approved';
  	$externalApps=OC_OCSClient::getApplications($categories, $page, $filter);
  	foreach($externalApps as $app) {
  		// show only external apps that aren't enabled yet
  		$local=false;
  		foreach($enabledApps as $a) {
31b7f2792   Kload   Upgrade to ownclo...
36
  			if($a === $app['name']) {
03e52840d   Kload   Init
37
38
39
40
41
  				$local=true;
  			}
  		}
  
  		if(!$local) {
31b7f2792   Kload   Upgrade to ownclo...
42
  			if($app['preview'] === '') {
03e52840d   Kload   Init
43
44
45
46
  				$pre=OC_Helper::imagePath('settings', 'trans.png');
  			} else {
  				$pre=$app['preview'];
  			}
31b7f2792   Kload   Upgrade to ownclo...
47
  			if($app['label'] === 'recommended') {
03e52840d   Kload   Init
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  				$label='3rd Party';
  			} else {
  				$label='Recommended';
  			}
  			$apps[]=array(
  				'name'=>$app['name'],
  				'id'=>$app['id'],
  				'active'=>false,
  				'description'=>$app['description'],
  				'author'=>$app['personid'],
  				'license'=>$app['license'],
  				'preview'=>$pre,
  				'internal'=>false,
  				'internallabel'=>$label,
  				'update'=>false,
  			);
  		}
  	}
  }
  
  OCP\JSON::success(array('type' => 'external', 'data' => $apps));