1
0

applicable.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Robin McCorkell <robin@mccorkell.me.uk>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. \OC_JSON::checkAppEnabled('files_external');
  28. \OC_JSON::callCheck();
  29. \OC_JSON::checkAdminUser();
  30. $pattern = '';
  31. $limit = null;
  32. $offset = null;
  33. if (isset($_GET['pattern'])) {
  34. $pattern = (string)$_GET['pattern'];
  35. }
  36. if (isset($_GET['limit'])) {
  37. $limit = (int)$_GET['limit'];
  38. }
  39. if (isset($_GET['offset'])) {
  40. $offset = (int)$_GET['offset'];
  41. }
  42. $groups = [];
  43. foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) {
  44. $groups[$group->getGID()] = $group->getDisplayName();
  45. }
  46. $users = [];
  47. foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) {
  48. $users[$user->getUID()] = $user->getDisplayName();
  49. }
  50. $results = ['groups' => $groups, 'users' => $users];
  51. \OC_JSON::success($results);