Beispiel #1
0
function polls_replace_choices($poll, $new_choices)
{
    polls_delete_choices($poll);
    polls_add_choices($poll, $new_choices);
}
Beispiel #2
0
    $poll_guid = get_input('poll_guid');
    if ($poll_guid) {
        $poll = get_entity($poll_guid);
        if ($number_of_choices) {
            $count = 0;
            $new_choices = array();
            for ($i = 0; $i < $number_of_choices; $i++) {
                $text = get_input('choice_text_' . $i, '');
                if ($text) {
                    $new_choices[] = $text;
                    $count++;
                }
            }
        }
        // add choices to the poll
        polls_add_choices($poll, $new_choices);
    }
}
// manage vote sub-action
if ($vote_flag) {
    //get the poll entity
    $poll = get_entity($guid);
    if (elgg_instanceof($poll, 'object', 'poll')) {
        // Make sure the response isn't blank
        if (empty($response)) {
            register_error(elgg_echo("polls:novote"));
            forward($poll->getUrl());
            // Otherwise, save the poll vote
        } else {
            $user_guid = elgg_get_logged_in_user_guid();
            // check to see if this user has already voted