content.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * content of the discussions widget
  4. */
  5. $widget = $vars["entity"];
  6. $discussion_count = sanitise_int($widget->discussion_count, false);
  7. if (empty($discussion_count)) {
  8. $discussion_count = 5;
  9. }
  10. $options = array(
  11. "type" => "object",
  12. "subtype" => "groupforumtopic",
  13. "limit" => $discussion_count,
  14. "order_by" => "e.last_action desc",
  15. "pagination" => false,
  16. "full_view" => false
  17. );
  18. if ($widget->group_only == "yes") {
  19. $owner = $widget->getOwnerEntity();
  20. $groups = $owner->getGroups("", false);
  21. if (!empty($groups)) {
  22. $group_guids = array();
  23. foreach ($groups as $group) {
  24. $group_guids[] = $group->getGUID();
  25. }
  26. $options["container_guids"] = $group_guids;
  27. }
  28. }
  29. $content = elgg_list_entities($options);
  30. if (empty($content)) {
  31. $content = elgg_echo("grouptopic:notcreated");
  32. } else {
  33. $content .= "<div class='elgg-widget-more'>";
  34. $content .= elgg_view("output/url", array("text" => elgg_echo("widgets:discussion:more"), "href" => "discussion/all"));
  35. $content .= "</div>";
  36. }
  37. // prepend a quick start form
  38. $params = $vars;
  39. $params["embed"] = true;
  40. echo elgg_view("widgets/start_discussion/content", $params);
  41. // view listing of discussions
  42. echo $content;