Login  Register

Re: Managing vote permission

Posted by Pedro on Apr 24, 2013; 7:11pm
URL: https://support.nabble.com/Managing-vote-permission-tp7584064p7584172.html

Go to poll_js macro and replace this line " if (!<n.poll_visitor_can_vote/>)  " with this "  if (!<n.visitor.can_create_poll_in.page_node/> )  ".  In this way, only those who can create polls will be able to vote.
The beginning of your macro will be like this:
 <override_macro name="poll_js" requires="servlet">
    <n.comment.>
        This is the javascript code that will update the poll controls and make them available to the users.
    </n.comment.>
    <n.param_loop. param="poll_node_id">
        <n.get_node_from_id. node_id="[n.current_parameter_value/]">
            <n.set_local_node.this_node />
            <n.if.visitor.is_registered>
                <then>
                    <n.poll_option_list.loop.>
                        var input = '<n.local_node.poll_vote_input_field field_id="option[n.option_id/]" index="[n.current_index/]"/>';
                        $('#poll-option-input<n.option_id/>').html(input);
                    </n.poll_option_list.loop.>
 
                    <n.if.poll_has_ended>
                        <then>
                            var input = '<t>This poll is closed.</t>';
                        </then>
                        <else>
                            var txt_vote = "<t>Vote</t>";
                            var input = '<input type="submit" value="' + txt_vote + '"/>';
                            if (!<n.visitor.can_create_poll_in.page_node/> )
                                input = '<input type="submit" value="' + txt_vote + '" disabled="true"/>';
 
                        </else> 
/(...)
My test forum.