vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Miscellaneous Hacks - Poll Write-In & Change Vote Hack (https://vborg.vbsupport.ru/showthread.php?t=142964)

TomasDR 03-23-2007 10:00 PM

Poll Write-In & Change Vote Hack
 
Poll Write-In Vote Hack

This is only for 3.6.x, you can find my 3.7.x version here.

About this hack:
I developed this hack for my board after several polls were made by members that were short on options, especially since the poll creators are sometimes biased with the poll options. I am sure you have seen the same on your boards.

This hack allows the poll creator to allow "Write-In Votes" to a poll (single or multiple). I also added the feature to change your vote if the poll is a "write-in vote" poll, you can also allow vote changes on all polls through an admin option (ver 1.2+). This will allow a user to change their vote if they discover a better poll option written in by another user, or if they want to add one or more write-in votes to a multiple choice poll.

An admin/moderator/etc. who has permission to edit a poll can change a poll to make it a write-in poll or not. (ver 1.3+)

The cancel/change vote feature works with single and multiple choice polls.

This is my first hack but please don't let that scare you away, this is a very basic hack.

Permission Overview:

There are very few permission checks with my hack;
  • If you can create a poll, you can make it a write-in vote poll.
  • If you can vote on the poll, you can add a write-in vote to a write-in poll.
  • If the poll is closed you cannot change your vote or add a write-in vote of course.
  • You cannot add a write-in vote to a non write-in vote poll.
Permission Settings:

Located in vBulletin Options "Poll and Thread Rating Options" section.
  • Allow users to change their votes in ANY poll. (Default NO)
  • Show the username after a write-in vote. (Default Yes)
    * If NO a log entry is written to the moderator log as per a request, see pic below
Install Info:
  • Files edited: 0
  • Templates edited: 3
  • Files to install: 1
  • Time to install: 5 minutes max
Install Procedure:
1. Install the Product (Download the XML file)
2. Edit Template polloptions_table
FIND
Code:

<input type="submit" class="button" value="$vbphrase[vote_now]" />
ADD ABOVE
Code:

<if condition="$pollinfo[writein]"><span style="float:$stylevar[right]"><a href="poll.php?$session[sessionurl]do=addwritein&amp;pollid=$pollinfo[pollid]">$vbphrase[add_writein_vote]</a>&nbsp;&nbsp;</span></if>
3. Edit Template pollresults_table
FIND
Code:

<td class="tfoot" colspan="4" align="center"><span class="smallfont"><if condition="$show['multiple']">$vbphrase[multiple_choice_poll] </if>$vbphrase[voters]: <strong>$pollinfo[numbervotes]</strong>. $pollstatus</span></td>
REPLACE WITH
Code:

<td class="tfoot" colspan="4" align="center"><span class="smallfont"><if condition="$show['multiple']">$vbphrase[multiple_choice_poll] </if>$vbphrase[voters]: <strong>$pollinfo[numbervotes]</strong>. $pollstatus<if condition="$vbulletin->options['allchangevote'] OR $pollinfo[writein]"><if condition="$uservoted AND $pollinfo[active]">&nbsp;&nbsp;<a href="poll.php?$session[sessionurl]do=changevote&amp;pollid=$pollinfo[pollid]">$vbphrase[change_vote]</a></if></if></span></td>
4. Edit Template editpoll
FIND
Code:

<if condition="$show['makeprivate']"> <fieldset class="fieldset"> <legend>$vbphrase[poll_options]</legend> <table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0"> <tr> <td><label for="cb_public"><input type="checkbox" name="public" value="1" id="cb_public" tabindex="1" $pollinfo[public] />$vbphrase[make_votes_public]</label></td> </tr> </table> </fieldset> </if>
REPLACE WITH
Code:

<fieldset class="fieldset"><legend>$vbphrase[poll_options]</legend><table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">$addwritein<if condition="$show['makeprivate']"><tr> <td><label for="cb_public"><input type="checkbox" name="public" value="1" id="cb_public" tabindex="1" $pollinfo[public] />$vbphrase[make_votes_public]</label></td></tr></if></table></fieldset>
5. Enjoy!
Version Info:


Version 1.0:
  • Initial release of the hack
Version 1.1:
  • Added a requested feature (please see screenshot) so now the username is recorded after a write-in vote.
  • Added an error/permission check for max poll options that is set in vBulletin options by the admin so a write-in poll cannot exceed that number.
  • Added two new error messages reflecting the max poll option error & a specialized error message for entering a blank write-in vote.
Version 1.2:
  • Added the feature (suggested by bchertov) to be able to allow your users to change their vote in all polls. This is now a vBulletin Option located in the Setting Group Poll and Thread Rating Options the option is Allow Users to Change Their Votes in ALL Polls as a Yes/No, if set for 'No' they will still be able to change their vote in Write-in polls as before. NOTE: The template edit has changed for the template pollresults_table with this version!
  • Fixed the bug reported by A_V concerning poll max options being set for zero/unlimited.
  • Added the Write-in permission check along with the vB option for allowing users to change votes in the plugin Change write-in poll vote.
Version 1.3:
  • Added the requested feature to allow changing the Write-In option when Editing Polls. Note: There is an additional template (editpoll) to edit with this new version.
Version 1.4:
  • Added the ability to turn off the username added after a write-in vote.
  • Added logging to the moderator log if the username addition is turned off per a request.
Version 1.5:
  • Found a bug if you allow the "Unregistered / Not Logged In" group to vote in polls. If they change their vote they will change all guest's votes. You only need to upgrade if you allow Unregistered users the ability to vote in polls.
Version 3.6.8:
vBulletin 3.6.8 has the ability to filter by product in the moderator log. This is the only difference between the xml files.

Please post your comments or suggestions for this hack. I will read ALL posts.

PLEASE CLICK INSTALL!
(You will get an email when a new version is released.)


Pictures:
  1. Showing the "Write-In" checkbox under Miscellaneous Options when creating a poll.
  2. Showing the poll with the link to add a write-in vote.
  3. Showing the screen to add a write-in vote.
  4. Showing the new poll with the new write-in vote and the link to Change your vote.
  5. Showing the new feature (ver 1.1) where the username is placed after the write-in vote.
  6. Showing the moderator log entry.

TomasDR 03-23-2007 10:54 PM

Post reserved.

bacanze 03-23-2007 11:00 PM

A useful plugin, thanks :)

4x4 Mecca 03-24-2007 12:27 AM

Looks AWESOME! One suggestion. How about a small (vote added by [username]) or something after or under the added vote option. That way people know what the original options were and who added the extra options.

bitdefuser 03-24-2007 12:54 AM

This is risky if your going to have a very important poll, such as voting for a new moderator. No install for me, just warning you folks out there.

4x4 Mecca 03-24-2007 01:24 AM

Its an option, just like allowing multiple votes is

bashy 03-24-2007 09:29 AM

Wow, excellent m8 well done :)
Is there a away to set it so the option is checked by default?

TTG 03-24-2007 09:33 AM

I'm sure my members could find this a useful addition .. thanks TomasDR
Clicked install

MaestroX 03-24-2007 09:52 AM

Nice one, thanks for sharing :)

TomasDR 03-24-2007 10:24 PM

Quote:

Originally Posted by bitdefuser (Post 1210734)
This is risky if your going to have a very important poll, such as voting for a new moderator. No install for me, just warning you folks out there.

As the other person mentioned, Write-In votes is an option, just like Public and/or Multiple voting is an option. Also there is a permission check in the plugin so someone cannot add a Write-in vote to a non write-in poll even if they knew the do=addwritein URL.

I agree with you hence why I added the permission check.

ezurick 03-24-2007 10:26 PM

I couldn't find the two (2) poll templates to edit....

TomasDR 03-24-2007 10:31 PM

Quote:

Originally Posted by ezurick (Post 1211380)
I couldn't find the two (2) poll templates to edit....

They are both under the "category" Poll Templates << in your style manager.

4x4 Mecca 03-24-2007 10:44 PM

What about my suggestion on seeing who added the option. I think it could get out of hand with people adding random crap if they were anonymous. Is is possible? Thanks for the mod, I love it.

TomasDR 03-24-2007 11:00 PM

Quote:

Originally Posted by 4x4 Mecca (Post 1211387)
What about my suggestion on seeing who added the option. I think it could get out of hand with people adding random crap if they were anonymous. Is is possible? Thanks for the mod, I love it.

Currently there is only one SQL change in the hack, to add the field "writein" to the poll table and I wanted to keep it simple.

Let me look into adding something like this, if this would work for you:
  • Coca-Cola
  • Pepsi
  • Mountain Dew (TomasDR)

4x4 Mecca 03-24-2007 11:45 PM

That's exactly what I'm looking for. Thanks :)

bitdefuser 03-25-2007 12:37 AM

Quote:

Originally Posted by TomasDR (Post 1211376)
As the other person mentioned, Write-In votes is an option, just like Public and/or Multiple voting is an option. Also there is a permission check in the plugin so someone cannot add a Write-in vote to a non write-in poll even if they knew the do=addwritein URL.

I agree with you hence why I added the permission check.

Oh, sorry. Looks like I've skipped that part out. Please forgive me. :(

TomasDR 03-25-2007 06:26 AM

Quote:

Originally Posted by 4x4 Mecca (Post 1211387)
What about my suggestion on seeing who added the option. I think it could get out of hand with people adding random crap if they were anonymous. Is is possible? Thanks for the mod, I love it.

Version updated to 1.1 with this option, please see the screenshot.

Thanks

4x4 Mecca 03-25-2007 03:57 PM

Thanks! I'm going to donate today or tomorrow. I appreciate the work.

bchertov 03-25-2007 09:36 PM

Does this hack allow users to change their votes on any poll (if the correct options are selected)? If so that would be fabulous! It would be good if vote-change feature could selected without the write in option.

Strongly considering installing!

TomasDR 03-25-2007 11:20 PM

Quote:

Originally Posted by bchertov (Post 1212175)
Does this hack allow users to change their votes on any poll (if the correct options are selected)? If so that would be fabulous! It would be good if vote-change feature could selected without the write in option.

Strongly considering installing!

It is just for write-in polls only but I just checked my code and forgot the write-in check permission for the Change Vote plugin so realistically you could remove the highlighted blue code from the following instructions.

In the template pollresults_table

Code:

<td class="tfoot" colspan="4" align="center"><span class="smallfont"><if condition="$show['multiple']">$vbphrase[multiple_choice_poll] </if>$vbphrase[voters]: <strong>$pollinfo[numbervotes]</strong>. $pollstatus<if condition="$pollinfo[writein]"><if condition="$uservoted">&nbsp;&nbsp;<a href="poll.php?$session[sessionurl]do=changevote&amp;pollid=$pollinfo[pollid]">$vbphrase[change_vote]</a></if></if></span></td>
I apologize for missing the write- in poll permission check for the change vote plugin, if you want to add the code to prevent anyone from entering the URL http://xxx.yourforum.xxx/poll.php?do...evote&pollid=# you can add the following to the plugin Change write-in poll vote

FIND

Code:

//check if poll is closed
 if (!$pollinfo['active'] OR !$threadinfo['open'] OR ($pollinfo['dateline'] + ($pollinfo['timeout'] * 86400) < TIMENOW AND $pollinfo['timeout'] != 0))
 { //poll closed
  eval(standard_error(fetch_error('pollclosed')));
 }

ADD AFTER
Code:

if (!$pollinfo['writein'])
 {
  print_no_permission();
 }

I will ensure that I include the permission check code in the next version, I apologize for any "smart" users you may have on the board that changes their votes with regular non write-in polls.

The permission check is definitely there for adding write ins so again no one can add a write-in vote to a non-write-in poll.

Finally I may consider making the change vote an option (for write-in's only or for all polls).

TomasDR 03-25-2007 11:24 PM

Quote:

Originally Posted by 4x4 Mecca (Post 1211893)
Thanks! I'm going to donate today or tomorrow. I appreciate the work.

Thank you, I am open to all suggestions and feature requests.

A_V 03-25-2007 11:35 PM

I find a small bug

I have in my settings that max option in poll's is 0 (to desactivate the max)

This mod allways show the error of mutch options in post that permission of administrator.


I can resolve editing the plugin "Write-in vote code"

in line with:

PHP Code:

if ($vbulletin->options['maxpolloptions'] < $pollinfo['numberoptions']) 


i replace with:
PHP Code:

if ($vbulletin->options['maxpolloptions'] < $pollinfo['numberoptions'] && $vbulletin->options['maxpolloptions'] > 0

and no more problems ;-)

TomasDR 03-26-2007 12:14 AM

Quote:

Originally Posted by A_V (Post 1212282)
I find a small bug

I have in my settings that max option in poll's is 0 (to desactivate the max)

Thank you I forgot to consider that some admins may have set their maxpolloptions to unlimited (0).

TomasDR 03-26-2007 01:40 AM

Quote:

Originally Posted by bchertov (Post 1212175)
Does this hack allow users to change their votes on any poll (if the correct options are selected)? If so that would be fabulous! It would be good if vote-change feature could selected without the write in option.

Strongly considering installing!

Now this is an admin option, see Version 1.2 notes.

Also fixed one bug and a permission loophole.

PS. Sorry for the rapid updates.

bchertov 03-26-2007 05:02 AM

If this can in fact be used to allow people to change votes in a poll, that would be an answer to a long standing popular request in these parts! I suggest you either edit the title of your post to reflect that or publish just that feature as a separate hack. :up:

bashy 03-26-2007 05:06 AM

Yes it can :)

bchertov 03-26-2007 04:31 PM

Quote:

Originally Posted by TomasDR (Post 1212352)
Now this is an admin option, see Version 1.2 notes.

Fabulous! I will install this soon!

odie3 03-26-2007 11:42 PM

Very nice!

bada_bing 03-27-2007 07:07 PM

has anyone tried this hack with vbportal installed and if so how does this work on the portal?

bchertov 03-28-2007 04:34 AM

Installed! Worked great!

It would be nice if the Allow write-in votes were offered when editing the poll.

odie3 03-28-2007 11:34 AM

Quote:

Originally Posted by bchertov (Post 1214236)
Installed! Worked great!

It would be nice if the Allow write-in votes were offered when editing the poll.

agreed +1

TomasDR 03-28-2007 10:17 PM

Quote:

Originally Posted by bchertov (Post 1214236)
Installed! Worked great!

It would be nice if the Allow write-in votes were offered when editing the poll.

Quote:

Originally Posted by odie3 (Post 1214393)
agreed +1

Version 1.3 has this option now.

odie3 03-28-2007 11:52 PM

Do you have to reload the product-poll_write_in_vote.xml file for 1.3 or just do Edit #4?

TomasDR 03-29-2007 07:55 PM

Quote:

Originally Posted by odie3 (Post 1214898)
Do you have to reload the product-poll_write_in_vote.xml file for 1.3 or just do Edit #4?

Yes you need to reload the xml file, there is two additional plugins for the Edit Poll feature.

bchertov 03-30-2007 05:22 AM

And one more thing...

Once the poll is closed the "change your vote" option should go away.

Still a Great Hack!

EnIgMa1234 03-30-2007 05:40 PM

great hack, thanks :D

TomasDR 04-11-2007 06:36 PM

Quote:

Originally Posted by bchertov (Post 1215885)
And one more thing...

Once the poll is closed the "change your vote" option should go away.

Still a Great Hack!

There is a permission check within the Plugin for that, I just didn't add the IF Conditional to the template where the link is added, so no one can change their vote after it's closed even though they will see the link.

bchertov 04-12-2007 05:11 AM

Quote:

Originally Posted by TomasDR (Post 1225207)
I just didn't add the IF Conditional to the template where the link is added, so no one can change their vote after it's closed even though they will see the link.

How about adding that "if"?

inciarco 05-12-2007 01:12 PM

Magnific Add-On!! :up:

Works Ok With vBulletin 3.6.6!! :up:

:)

Shana 05-30-2007 06:20 PM

Is it possible to remove the username that added the poll option?


All times are GMT. The time now is 03:56 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01519 seconds
  • Memory Usage 1,855KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (2)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete