<?php /** * Poll result view */ $poll = elgg_extract('entity', $vars); // Get array of possible responses $choices = poll_get_choice_array($poll); $total = $poll->getResponseCount(); $allow_open_poll = elgg_get_plugin_setting('allow_open_poll', 'poll'); if ($allow_open_poll == 'yes') { $open_poll = $poll->open_poll == 1; } else { $open_poll = false; } $vote_id = 0; foreach ($choices as $choice) { $response_count = $poll->getResponseCountForChoice((string) $choice); $response_label = elgg_echo('poll:result:label', array($choice, $response_count)); $voted_users = ''; // Show members if this poll is an open poll or if an admin is logged in // (in the latter case open polls must be enabled in plugin settings) if ($open_poll || $allow_open_poll == 'yes' && elgg_is_admin_logged_in()) { $vote_id++; // TODO Would it be possible to use elgg_list_annotations() with // custom view that displays only annotation owner icons? $response_annotations = elgg_get_annotations(array('guid' => $poll->guid, 'annotation_name' => 'vote', 'annotation_value' => $choice)); $user_guids = array(); foreach ($response_annotations as $ur) { $user_guids[] = $ur->owner_guid; }
<?php /** * Poll voting form */ $poll = $vars['entity']; $response_input = elgg_view('input/radio', array('name' => 'response', 'options' => poll_get_choice_array($poll))); $submit_input = elgg_view('input/submit', array('name' => 'submit_vote', 'value' => elgg_echo('poll:vote'), 'class' => 'elgg-button-submit poll-vote-button', 'rel' => $poll->guid)); $guid_input = elgg_view('input/hidden', array('name' => 'guid', 'value' => $poll->guid)); $callback_input = elgg_view('input/hidden', array('name' => 'callback', 'value' => $vars['callback'])); echo <<<HTML \t<div> \t\t{$response_input} \t</div> \t<div> \t\t{$guid_input} \t\t{$submit_input} \t\t{$callback_input} \t</div> HTML ;
<?php if (isset($vars['entity'])) { $poll = $vars['entity']; //set up our variables $question = $poll->question; $description = $poll->description; $tags = $poll->tags; $access_id = $poll->access_id; } else { register_error(elgg_echo("poll:blank")); forward('poll/all'); } //convert $responses to radio inputs for form display $responses = poll_get_choice_array($poll); $response_inputs = elgg_view('input/radio', array('name' => 'response', 'options' => $responses)); $submit_input = '<br>' . elgg_view('input/submit', array('rel' => $poll->guid, 'class' => 'elgg-button-submit poll-vote-button', 'name' => 'submit_vote', 'value' => elgg_echo('poll:vote'))); if (isset($vars['entity'])) { $entity_hidden = elgg_view('input/hidden', array('name' => 'guid', 'value' => $poll->guid)); $entity_hidden .= elgg_view('input/hidden', array('name' => 'callback', 'value' => $vars['callback'])); } else { $entity_hidden = ''; } $form_body = "<p>" . $response_inputs . "</p>"; $form_body .= "<p>" . $submit_input . $entity_hidden . "</p>"; if ($vars['form_display']) { echo '<div id="poll-vote-form-container-' . $poll->guid . '" style="display:' . $vars['form_display'] . '">'; } else { echo '<div class="poll-vote-form-container-' . $poll->guid . '">'; } echo $form_body;
<?php /** * Poll voting form */ $poll = $vars['entity']; $multiple_hint = ""; if ($poll->max_votes > 1) { $input_type = 'input/checkboxes'; $multiple_hint = elgg_echo('poll:max_votes:info', array($poll->max_votes)); } else { $input_type = 'input/radio'; } $response_input = elgg_view($input_type, array('name' => 'response', 'options' => poll_get_choice_array($poll))); $submit_input = elgg_view('input/submit', array('name' => 'submit_vote', 'value' => elgg_echo('poll:vote'), 'class' => 'elgg-button-submit poll-vote-button', 'rel' => $poll->guid)); $guid_input = elgg_view('input/hidden', array('name' => 'guid', 'value' => $poll->guid)); $callback_input = elgg_view('input/hidden', array('name' => 'callback', 'value' => $vars['callback'])); echo <<<HTML \t<div> \t\t{$response_input} \t</div> \t<div> \t\t{$multiple_hint} \t</div> \t<div> \t\t{$guid_input} \t\t{$submit_input} \t\t{$callback_input} \t</div> HTML ;
/** * Elgg Poll plugin * @package Elggpoll * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @Original author John Mellberg * website http://www.syslogicinc.com * @Modified By Team Webgalli to work with ElggV1.5 * www.webgalli.com or www.m4medicine.com */ if (isset($vars['entity'])) { //set img src $img_src = elgg_get_site_url() . "mod/poll/graphics/poll.gif"; $question = $vars['entity']->question; //get the array of possible responses $responses = poll_get_choice_array($vars['entity']); //get the array of user responses to the poll $user_responses = $vars['entity']->getAnnotations('vote', false, 0, 'desc'); //get the count of responses $user_responses_count = $vars['entity']->countAnnotations('vote'); $allow_open_poll = elgg_get_plugin_setting('allow_open_poll', 'poll'); if ($allow_open_poll) { $open_poll = $vars['entity']->open_poll == 1; } else { $open_poll = false; } //populate array $vote_id = 0; foreach ($responses as $response) { //get count per response $response_count = poll_get_response_count($response, $user_responses);