how to restrict a voting module by role??

fight.fire - June 7, 2006 - 22:49

The idea: site content based on regional news. city A have a News only about A, site B, only news about B.., Roles groups users from city A, role A, users from city B, role B.... Content A,B,C... may be visible to all, but only users A role can vote on A news, B on B,....

thanks!

Using Votingapi?

Scott Reynolds - June 8, 2006 - 03:36

You using the votingapi module?

What I would do is modify the SimpleVote module ( or your own vote module).

Within the the _block() (or however you are displaying the vote 'widget')
Add a check using global $user

global $user

if (is_array($user->roles) && in_array($target_role, $user->roles)) {
  // DISPLAY VOTE WIDGET HERE
}

For more info http://drupal.org/node/27690

currently I use Votingapi

fight.fire - June 8, 2006 - 12:19

currently I use Votingapi with mediumvote and nodereview (but use SimpleVote its also ok). I'll try this!

Thanks Thanks!

ok for mediumvote

fight.fire - June 12, 2006 - 19:44

I addes the widget like:

global $user;
if (is_array($user->roles) && in_array('admin*', $user->roles))
    // add positive vote-role depend
    $output .= theme('mediumvote_icon', $type, $cid, 1, false, $tag, $mode, $user_vote);
  global $user;
if (is_array($user->roles) && in_array('admin*', $user->roles))
    // add negative vote-role depend
    $output .= theme('mediumvote_icon', $type, $cid, -1, false, $tag, $mode, $user_vote);

*admin role example

in mediumvote module. If i define news about A like a flexinode type A, how make this nodetype role-dependent???

thanks!

Good Question

Scott Reynolds - June 13, 2006 - 07:57

Edit: Ok I was wrong...

I am not familar enough with flexinode to know how to extract what node you are currently viewing. i.e what city this node belongs to.

You should repost this to get people who are smarter to help ya out

 
 

Drupal is a registered trademark of Dries Buytaert.