content.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Elgg Poll post widget view
  4. *
  5. * @package Elggpoll
  6. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  7. * @author John Mellberg
  8. * @copyright John Mellberg 2009
  9. *
  10. * @uses $vars['entity'] Optionally, the poll post to view
  11. */
  12. elgg_load_library('elgg:polls');
  13. $widget = elgg_extract("entity", $vars);
  14. //get the num of polls the user want to display
  15. $limit = (int) $widget->limit;
  16. //if no number has been set, default to 5
  17. if($limit < 1){
  18. $limit = 5;
  19. }
  20. // the page owner
  21. $options = array(
  22. 'type' => 'object',
  23. 'subtype'=>'poll',
  24. 'limit' => $limit,
  25. );
  26. switch($widget->context){
  27. case "groups":
  28. $options["container_guid"] = $widget->getOwnerGUID();
  29. break;
  30. case "index":
  31. if($user_guid = elgg_get_logged_in_user_guid()){
  32. $options["wheres"] = array("(e.owner_guid <> " . $user_guid . ")");
  33. }
  34. break;
  35. default:
  36. $options["wheres"] = array("(e.owner_guid <> " . $widget->getOwnerGUID() . ")");
  37. break;
  38. }
  39. if ($polls = elgg_get_entities($options)){
  40. foreach($polls as $poll) {
  41. echo elgg_view("polls/widget", array('entity' => $poll));
  42. }
  43. } else {
  44. echo "<p>" . elgg_echo("polls:widget:nonefound") . "</p>";
  45. }