Poll votes based on user-reputation

Spartak

Well-known member
Member
Joined
9 yrs. 9 mth. 5 days
Messages
587
Reaction score
8,878
Wallet
0$
Poll votes based on user-reputation

When a user votes in a poll, the weight/importance of their vote is based on their reputation:<br />
<br />
In [polls.php] change the following code:<br />
<br />
<pre data-deferred="true" class="block-code line-numbers language-none"><code class="language-php">$votesarray[$voteoption-1]++;
//$votepower = $mybb-&gt;user['reputation'];
//$votesarray[$voteoption-1] = $votesarray[$voteoption-1] + $votepower;

$votesarray[$option-1]++;
//$votepower = $mybb-&gt;user['reputation'];
//$votesarray[$option-1] = $votesarray[$option-1] + $votepower;

--$votesarray[$vote-1];
//$votepower = $mybb-&gt;user['reputation'];
//$votesarray[$vote-1] = $votesarray[$vote-1] - $votepower;

--$votesarray[$voteoption-1];
//$votepower = $mybb-&gt;user['reputation'];
//$votesarray[$voteoption-1] = $votesarray[$voteoption-1] - $votepower;</code></pre><br />
To make the change, find the uncommented part in the file, comment it out, and underneath it add the two lines, and uncomment those<br />
<br />
And to let them undo their votes (so that the second half of the above changes have any effect):<br />
AdminCP -&gt; "Users &amp; Groups" -&gt; "Groups" -&gt; (pick a group) "Options" -&gt; "Edit Group" -&gt; "Forums and Posts" -&gt; "Can undo votes in polls?"<br />
<hr class="mycode_hr" />
I'm going to do something where:<br />
<br />
the top 25% reputation users have &#36;votepower of 5<br />
the middle 50% reputation users have a &#36;votepower of 3<br />
the bottom 25% reputation users have a &#36;votepower of 1<br />
and negative reputation users (not sure if this is a thing?) have a &#36;votepower of 0<br />
<br />
Not sure how I'm going to calculate those percentages yet though<br />
<hr class="mycode_hr" />
When you open a thread, it'll show the wrong # of votes after the above change<br />
<br />
To fix it, go to ~line 608 in [showthread.php], find the comment "// Decide what poll status to show depending on the status of the poll and whether or not the user voted already."<br />
<br />
And insert this code right above that comment:<br />
<br />
<pre data-deferred="true" class="block-code line-numbers language-none"><code class="language-php">$query = $db-&gt;simple_select(&quot;polls&quot;, &quot;numvotes&quot;, &quot;tid='&quot;.$tid.&quot;'&quot;);
$thispollqueryresult = $db-&gt;fetch_array($queryy);
$totalvotes = $thispollqueryresult['numvotes'];</code></pre>


Please, Log in or Register to view URLs content!
 
Top Bottom