1
0

applicable.php 935 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. \OC_JSON::checkAppEnabled('files_external');
  8. \OC_JSON::callCheck();
  9. \OC_JSON::checkAdminUser();
  10. $pattern = '';
  11. $limit = null;
  12. $offset = null;
  13. if (isset($_GET['pattern'])) {
  14. $pattern = (string)$_GET['pattern'];
  15. }
  16. if (isset($_GET['limit'])) {
  17. $limit = (int)$_GET['limit'];
  18. }
  19. if (isset($_GET['offset'])) {
  20. $offset = (int)$_GET['offset'];
  21. }
  22. $groups = [];
  23. foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) {
  24. $groups[$group->getGID()] = $group->getDisplayName();
  25. }
  26. $users = [];
  27. foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) {
  28. $users[$user->getUID()] = $user->getDisplayName();
  29. }
  30. $results = ['groups' => $groups, 'users' => $users];
  31. \OC_JSON::success($results);