xoops forums

cabdi_uk

Just popping in
Posted on: 2009/6/14 16:10
cabdi_uk
cabdi_uk (Show more)
Just popping in
Posts: 28
Since: 2007/6/12
#1

Xoopspoll 1.2 total voters and votes not match

Hello

I am using XOOPS 2.3.3 and have recently installed xoopspoll 1.2 and it works fine. The only issue I have with it is that some users can vote many times creating more votes than the nu,ber of voters. Is there any way of limiting voters so that each votes once based on IP or Mac address , etc.

Thanks

ghia

Community Support Member
Posted on: 2009/6/14 18:09
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#2

Re: Xoopspoll 1.2 total voters and votes not match

Wasn't there a preference for that?

cabdi_uk

Just popping in
Posted on: 2009/6/15 0:22
cabdi_uk
cabdi_uk (Show more)
Just popping in
Posts: 28
Since: 2007/6/12
#3

Re: Xoopspoll 1.2 total voters and votes not match

Yes there was a preference not helpful. The prefernce with this module has the following:

=> Restrict voting from the same IP* Yes No

=>Restricting voting from the same User* Yes No

I have got both selected Yes but I can vote several times and it shows the number of votes more than teh voters. For example if I voted 3 times and I am the only person who voted, it shows the no. of votes as 3 and voters as just 1. I cant set it to one vote for voter.

ghia

Community Support Member
Posted on: 2009/6/15 7:40
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#4

Re: Xoopspoll 1.2 total voters and votes not match

What is in your xoops_xoopspoll_log table? Do you have different ID's or IP's for the three votes?

I checked the voting function in /class/xoopspolllog.php and have questiions with this function:
function hasVoted($poll_id$ip$user_id=null)
    {
    global 
$xoopsModuleConfig;
    
//
    
$filter '';
    if (
$xoopsModuleConfig['limit_by_uid'] == 1){
      if (
$user_id 0) { //otherwise anons cannot vote at all.
        
$filter .= ' AND user_id ='.intval($user_id);
      }
    }
    if (
$xoopsModuleConfig['limit_by_ip'] == 1)
      
$filter .= ' AND ip ="'.intval($ip).'"';
    
//if both are set to no then have to default to original behavior otherwise it will break.
    
if ($filter == '') {
      if ( !empty(
$user_id) ) {
        
$filter .= " AND user_id=".intval($user_id);
      } else {
        
$filter .= " AND ip='".$ip."'";
      }
    }
    
// 
        
$db =& Database::getInstance();
    
$sql "SELECT COUNT(*) FROM ".$db->prefix("xoopspoll_log")." WHERE poll_id=".intval($poll_id).$filter;
    
//
        
list($count) = $db->fetchRow($db->query($sql));
        if ( 
$count ) {
            return 
true;
        }
        return 
false;
    }

The function makes to many presumptions on the state of the preferences and the case for both checks is now allowing that eg user1 can not vote more than once from ip1 but can vote again from ip2.
I would say when there is already a vote from user1 or from ip1, the new vote should be refused.

Mazarin

Just can't stay away
Posted on: 2009/9/9 8:15
Mazarin
Mazarin (Show more)
Just can't stay away
Posts: 533
Since: 2008/12/10
#5

Re: Xoopspoll 1.2 total voters and votes not match

Shouldn't a more logical behavior be (in the case of both restrictions being enabled):

If anonymous user
ip has voted=can't vote (if anonymous can vote at all)
else if logged in user
user has voted=can't vote
ip has voted but user has NOT voted=CAN vote

Seems fairly simple to fix this. If I do, should I upload it as a hack or an update to the module or what?

sailjapan

Moderator
Posted on: 2009/9/9 13:27
sailjapan
sailjapan (Show more)
Moderator
Posts: 1672
Since: 2005/11/16
#6

Re: Xoopspoll 1.2 total voters and votes not match

seeing how you did it would be informative

Mazarin

Just can't stay away
Posted on: 2009/9/9 20:09
Mazarin
Mazarin (Show more)
Just can't stay away
Posts: 533
Since: 2008/12/10
#7

Re: Xoopspoll 1.2 total voters and votes not match

OK, fixed that (I think). Now I'll just fix some annoying little things with the poll block before I upload things for you people to test

Mamba

Moderator
Posted on: 2009/9/9 21:29
Mamba
Mamba (Show more)
Moderator
Posts: 10962
Since: 2004/4/23
#8

Re: Xoopspoll 1.2 total voters and votes not match

Thank you for doing it!

We need to have a "XOOPS Classic Pack" with the original modules that were included in XOOPS distribution up to XOOPS 2.0.13, and once they are redone/refactored as envisioned in the "Blue Move", we would release the Classic Pack.

Therefore your work is very much appreciated.

Mazarin

Just can't stay away
Posted on: 2009/9/10 7:17
Mazarin
Mazarin (Show more)
Just can't stay away
Posts: 533
Since: 2008/12/10
#9

Re: Xoopspoll 1.2 total voters and votes not match

I just realized that I'm doing my changes in v1.1 and the link to v1.2 in the repository is down. Can anyone provide me with a link to or send me v1.2?

ghia

Community Support Member
Posted on: 2009/9/10 23:40
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#10

Re: Xoopspoll 1.2 total voters and votes not match

Try this one