PageRenderTime 89ms CodeModel.GetById 29ms RepoModel.GetById 11ms app.codeStats 0ms

/settings/ajax/apps/ocs.php

https://github.com/sezuan/core
PHP | 68 lines | 51 code | 9 blank | 8 comment | 10 complexity | 116978500b4a77aea29f0fbb6806daa3 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. OC_JSON::checkAdminUser();
  9. $l = OC_L10N::get('settings');
  10. if(OC_Config::getValue('appstoreenabled', true)==false) {
  11. OCP\JSON::success(array('type' => 'external', 'data' => array()));
  12. }
  13. $enabledApps=OC_App::getEnabledApps();
  14. if(is_null($enabledApps)) {
  15. OCP\JSON::error(array('data' => array('message' => $l->t('Unable to load list from App Store'))));
  16. }
  17. $apps=array();
  18. // apps from external repo via OCS
  19. $categoryNames=OC_OCSClient::getCategories();
  20. if(is_array($categoryNames)) {
  21. $categories=array_keys($categoryNames);
  22. $page=0;
  23. $filter='approved';
  24. $externalApps=OC_OCSClient::getApplications($categories, $page, $filter);
  25. foreach($externalApps as $app) {
  26. // show only external apps that aren't enabled yet
  27. $local=false;
  28. foreach($enabledApps as $a) {
  29. if($a == $app['name']) {
  30. $local=true;
  31. }
  32. }
  33. if(!$local) {
  34. if($app['preview']=='') {
  35. $pre=OC_Helper::imagePath('settings', 'trans.png');
  36. } else {
  37. $pre=$app['preview'];
  38. }
  39. if($app['label']=='recommended') {
  40. $label='3rd Party';
  41. } else {
  42. $label='Recommended';
  43. }
  44. $apps[]=array(
  45. 'name'=>$app['name'],
  46. 'id'=>$app['id'],
  47. 'active'=>false,
  48. 'description'=>$app['description'],
  49. 'author'=>$app['personid'],
  50. 'license'=>$app['license'],
  51. 'preview'=>$pre,
  52. 'internal'=>false,
  53. 'internallabel'=>$label,
  54. 'update'=>false,
  55. );
  56. }
  57. }
  58. }
  59. OCP\JSON::success(array('type' => 'external', 'data' => $apps));