1
0

apps.php 2.1 KB

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