river.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Add a filter to the river page of a group
  4. *
  5. * @todo remove when Elgg core supports this
  6. */
  7. $guid = (int) get_input("guid");
  8. elgg_entity_gatekeeper($guid, 'group');
  9. elgg_set_page_owner_guid($guid);
  10. elgg_group_gatekeeper();
  11. // remove thewire_tools double extend
  12. elgg_unextend_view("core/river/filter", "thewire_tools/activity_post");
  13. // get inputs
  14. $group = get_entity($guid);
  15. $type = preg_replace('[\W]', '', get_input('type', 'all'));
  16. $subtype = preg_replace('[\W]', '', get_input('subtype', ''));
  17. if ($subtype) {
  18. $selector = "type=$type&subtype=$subtype";
  19. } else {
  20. $selector = "type=$type";
  21. }
  22. // set river options
  23. $db_prefix = elgg_get_config('dbprefix');
  24. $options = array(
  25. 'joins' => array(
  26. "JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid",
  27. "LEFT JOIN {$db_prefix}entities e2 ON e2.guid = rv.target_guid",
  28. ),
  29. 'wheres' => array(
  30. "(e1.container_guid = $group->guid OR e2.container_guid = $group->guid)",
  31. ),
  32. 'no_results' => elgg_echo('groups:activity:none'),
  33. );
  34. if ($type != 'all') {
  35. $options['type'] = $type;
  36. if ($subtype) {
  37. $options['subtype'] = $subtype;
  38. }
  39. }
  40. // build page elements
  41. $title = elgg_echo('groups:activity');
  42. elgg_push_breadcrumb($group->name, $group->getURL());
  43. elgg_push_breadcrumb($title);
  44. $content = elgg_view('core/river/filter', array('selector' => $selector));
  45. $content .= elgg_list_river($options);
  46. $params = array(
  47. 'content' => $content,
  48. 'title' => $title,
  49. 'filter' => '',
  50. 'class' => 'elgg-river-layout',
  51. );
  52. $body = elgg_view_layout('content', $params);
  53. // draw page
  54. echo elgg_view_page($title, $body);