Welcome, Guest. Please Login or Register.
May 14, 2025, 07:39:00 PM
Home Help Search Log in Register
News: If you are still using YaBB SE, please consider upgrading to SMF as soon as possible.

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  Poll Voting Restricted by # posts « previous next »
Pages: [1] Reply Ignore Print
Author Topic: Poll Voting Restricted by # posts  (Read 1604 times)
MarshallBanana
Noobie
*
Posts: 11


noob

WWW
Poll Voting Restricted by # posts
« on: July 19, 2003, 04:32:28 PM »
Reply with quote

Hey, I'm looking for a mod that will restrict voting in polls either to certain membergroups (50 post group, 150 post group, etc), or just set a minimum number of posts that a user can have to vote.

I don't know if there is anything like that already out there, if there is let me know.

Thanks
Logged
Grudge
Global Moderator
Full Member
*****
Posts: 178


Damn llama's don't like me :(

Re:Poll Voting Restricted by # posts
« Reply #1 on: July 21, 2003, 08:51:20 PM »
Reply with quote

Hey,

I've not done a boardmod/tested this but this would basically work:

Open poll.php and search for:

   if ($username == 'Guest')
      fatal_error($txt['yse28']);

   $request = mysql_query("SELECT votedMemberIDs, votingLocked FROM {$db_prefix}polls WHERE (ID_POLL='$poll' AND FIND_IN_SET('$ID_MEMBER', votedMemberIDs)=0) LIMIT 1;") or database_error(__FILE__, __LINE__);

(it's just after the vote() function!)

Afterwards add:

$request = mysql_query("SELECT posts FROM {$db_prefix}members WHERE memberName='$username' LIMIT 1;") or database_error(__FILE__, __LINE__);
$tmp = mysql_fetch_row($request);
if($tmp[0]<MINPOST && $settings[7] != 'Administrator' && $settings[7] != 'Global Moderator')
fatal_error('You have not reached the required amount of posts to vote in this poll');


Where MINPOST is the amount of posts they must reach (ie replace it with whatever amount you want). I know I haven't made this into a mod etc but there should be enough here to allow you to try it yourself. I BELIEVE I have got the mysql request right - if it doesn't work it may be realName= instead of memberName= :o

I know this isn't exactly a full mod and you would prob want to add the option to adjust it form the admin menu etc but it will hopefully get you on your way ;)
« Last Edit: July 21, 2003, 08:55:03 PM by Grudge » Logged
MarshallBanana
Noobie
*
Posts: 11


noob

WWW
Re:Poll Voting Restricted by # posts
« Reply #2 on: July 24, 2003, 06:23:52 AM »
Reply with quote

Hey, thanks a bunch. I haven't worked much with MySQL yet, so it is nice to be able to look at your MySQL commands and figure out what you're doing in this little bit of code.
Logged
MarshallBanana
Noobie
*
Posts: 11


noob

WWW
Re:Poll Voting Restricted by # posts
« Reply #3 on: July 25, 2003, 07:26:02 AM »
Reply with quote

All right: I tried this out, and it works just fine as far as giving the correct error message to users with less than 50 posts. However, it gives the "either this poll does not exist, voting was locked.... etc." message if you do have enough posts.

The error occurred because of this chunk$request = mysql_query("SELECT votedMemberIDs, votingLocked FROM {$db_prefix}polls WHERE (ID_POLL='$poll' AND FIND_IN_SET('$ID_MEMBER', votedMemberIDs)=0) LIMIT 1;") or database_error(__FILE__, __LINE__);
//startadd
   $request = mysql_query("SELECT posts FROM {$db_prefix}members WHERE memberName='$username' LIMIT 1;") or database_error(__FILE__, __LINE__);
You assigned a new value to $request (probably didn't realize that it was already assigned) therefore when it tried to use $request later in the script it had the wrong value. All I did was change the variable $request to $request2 inside the added script and it worked perfectly.

Again, thanks for the help! I'll study other mods and figure out how to make this a complete mod, with control panel and all.
Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  Poll Voting Restricted by # posts « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.028 seconds with 21 queries.