content.php 920 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Individual poll view
  4. *
  5. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  6. *
  7. */
  8. elgg_load_library('elgg:polls');
  9. $widget = elgg_extract("entity", $vars);
  10. $options = array(
  11. 'type' => 'object',
  12. 'subtype'=>'poll',
  13. 'limit' => 1
  14. );
  15. switch($widget->context){
  16. case "index":
  17. if($user_guid = elgg_get_logged_in_user_guid()){
  18. $options["wheres"] = array("(e.owner_guid <> " . $user_guid . ")");
  19. }
  20. break;
  21. case "dashboard":
  22. $options["wheres"] = array("(e.owner_guid <> " . $widget->getOwnerGUID() . ")");
  23. break;
  24. default:
  25. $options["container_guid"] = $widget->getOwnerGUID();
  26. break;
  27. }
  28. if($polls = elgg_get_entities($options)){
  29. $body = elgg_view('polls/poll_widget', array('entity' => $polls[0]));
  30. } else {
  31. $body = elgg_echo('polls:widget:no_polls', array($widget->getOwnerEntity()->name));
  32. }
  33. echo $body;