apps.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Tom Needham <tom@owncloud.com>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\Provisioning_API;
  23. use \OC_OCS_Result;
  24. use \OC_App;
  25. class Apps {
  26. public static function getApps($parameters){
  27. $apps = OC_App::listAllApps();
  28. $list = array();
  29. foreach($apps as $app) {
  30. $list[] = $app['id'];
  31. }
  32. $filter = isset($_GET['filter']) ? $_GET['filter'] : false;
  33. if($filter){
  34. switch($filter){
  35. case 'enabled':
  36. return new OC_OCS_Result(array('apps' => \OC_App::getEnabledApps()));
  37. break;
  38. case 'disabled':
  39. $enabled = OC_App::getEnabledApps();
  40. return new OC_OCS_Result(array('apps' => array_diff($list, $enabled)));
  41. break;
  42. default:
  43. // Invalid filter variable
  44. return new OC_OCS_Result(null, 101);
  45. break;
  46. }
  47. } else {
  48. return new OC_OCS_Result(array('apps' => $list));
  49. }
  50. }
  51. public static function getAppInfo($parameters){
  52. $app = $parameters['appid'];
  53. $info = OC_App::getAppInfo($app);
  54. if(!is_null($info)) {
  55. return new OC_OCS_Result(OC_App::getAppInfo($app));
  56. } else {
  57. return new OC_OCS_Result(null, \OC_API::RESPOND_NOT_FOUND, 'The request app was not found');
  58. }
  59. }
  60. public static function enable($parameters){
  61. $app = $parameters['appid'];
  62. OC_App::enable($app);
  63. return new OC_OCS_Result(null, 100);
  64. }
  65. public static function disable($parameters){
  66. $app = $parameters['appid'];
  67. OC_App::disable($app);
  68. return new OC_OCS_Result(null, 100);
  69. }
  70. }