members.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. $guid = (int) get_input('group_guid');
  3. $members_search = sanitise_string(get_input('members_search'));
  4. elgg_entity_gatekeeper($guid, 'group');
  5. $group = get_entity($guid);
  6. elgg_set_page_owner_guid($guid);
  7. elgg_group_gatekeeper();
  8. $title = elgg_echo('groups:members:title', array($group->name));
  9. elgg_push_breadcrumb($group->name, $group->getURL());
  10. elgg_push_breadcrumb(elgg_echo('groups:members'));
  11. $db_prefix = elgg_get_config('dbprefix');
  12. $options = [
  13. 'relationship' => 'member',
  14. 'relationship_guid' => $group->guid,
  15. 'inverse_relationship' => true,
  16. 'type' => 'user',
  17. 'limit' => (int) get_input('limit', max(20, elgg_get_config('default_limit')), false),
  18. 'joins' => array("JOIN {$db_prefix}users_entity ue ON e.guid = ue.guid"),
  19. 'order_by' => 'ue.name ASC',
  20. 'no_results' => elgg_format_element('div', ['class' => 'elgg-list'], elgg_echo('notfound'))
  21. ];
  22. if (!empty($members_search)) {
  23. $options['base_url'] = "groups/members/{$guid}?members_search={$members_search}";
  24. $options['wheres'][] = "(ue.name LIKE '%{$members_search}%' OR ue.username LIKE '%{$members_search}%')";
  25. }
  26. $user_list = elgg_list_entities_from_relationship($options);
  27. if (elgg_is_xhr()) {
  28. echo $user_list;
  29. return;
  30. }
  31. $content = elgg_view_form('group_tools/members_search', [
  32. 'action' => "groups/members/{$guid}",
  33. 'disable_security' => true,
  34. ]);
  35. $content .= $user_list;
  36. $params = array(
  37. 'content' => $content,
  38. 'title' => $title,
  39. 'filter' => '',
  40. );
  41. $body = elgg_view_layout('content', $params);
  42. echo elgg_view_page($title, $body);