i can vote as a logged in user, but not as anonymous. i gave permissions to anonymous users in the access control panel, but to no avail.

http://fucktheregents.com/?q=node/48

drupal 4.6 with the most recent nodevote.

thanks!
-ryan

Comments

kbahey’s picture

Status: Active » Closed (works as designed)

By design, anonymous users cannot vote.

ryanrain’s picture

advice for people who want to allow anonymous users to vote:

1. i just took out a few of the "if" clauses in the "_nodevote_is_votable()" function (line 208). thanks for teh well-commented code!
2. then i used phpmyadmin to remove the keys in the nodevote table.

sloppy but easy.

kbahey’s picture

Well, before giving the details of the solution for those who need it, let me first warn those who want to allow anonymous users to vote that this opens the door to vote rigging. For example, a user can log off and vote on their own node. Moreover, they can vote multiple times!

Also, because this solution relies on removing the keys in the database table, it may be slow on large sites with lots of users, nodes, and votes.

If you still want to do this, then do the following:

The solution consists of two changes.

1. Change the database table from:

CREATE TABLE nodevote (
  uid  int(10) NOT NULL default '0',
  nid  int(10) NOT NULL default '0',
  vote int(2)  NOT NULL default '0',
  PRIMARY KEY (uid, nid),
  KEY node_id (nid),
  KEY user_id (uid)
) TYPE=MyISAM;

To

CREATE TABLE nodevote (
  uid  int(10) NOT NULL default '0',
  nid  int(10) NOT NULL default '0',
  vote int(2)  NOT NULL default '0'
) TYPE=MyISAM;

If you already have data in the nodevote table, then just use PHPmyadmin to remove the keys from the existing table in the database.

2. Change the code to allow anonymous voting:

In the nodevote.module file, locate the following piece of code in the function _nodevote_is_votable()

          // Did the user already vote on this node?
          if (!_nodevote_user_voted($user->uid, $node->nid)) {
            $ret = true;
          }

Change that to be like so:

          // Did the user already vote on this node?
          //if (!_nodevote_user_voted($user->uid, $node->nid)) {
            $ret = true;
          //}

Enjoy...

jasonwhat’s picture

Title: can't vote as an anonymous user » Php sessions?

While it isn't a perfect solution. Doesn't the "voting" module as well polls use php sessions to attempt to prevent rigging. Someone could clear their cookies and get by the system, but generally isn't this a good way to do it? Although, I don't really know the best way possible.

kbahey’s picture

Title: Php sessions? » can't vote as an anonymous user

Changing title back ...

kbahey’s picture

This code was done for 4.6, and needs to be updated for 4.7.

Patches for this are welcome, provided they are parameterized.

Please see http://drupal.org/node/69564