Index: vud.module =================================================================== --- vud.module (revision 954) +++ vud.module (revision 1041) @@ -58,7 +58,7 @@ 'title' => 'Vote', 'page callback' => 'vud_vote', 'page arguments' => array(1, 2, 3, 4, 5, 6), - 'access arguments' => array('use vote up/down'), + 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, 'file' => 'vud.theme.inc', ); Index: vud_node/vud_node.module =================================================================== --- vud_node/vud_node.module (revision 954) +++ vud_node/vud_node.module (revision 1041) @@ -10,7 +10,7 @@ * Implementation of hook_perm(). */ function vud_node_perm() { - return array('use vote up/down on nodes', 'administer vote up/down on nodes', 'see vote up/down node stats'); + return array('view vote up/down on nodes', 'use vote up/down on nodes', 'administer vote up/down on nodes', 'see vote up/down node stats'); } /** @@ -87,7 +87,7 @@ function vud_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'view': - if (user_access('use vote up/down on nodes')) { + if (user_access('view vote up/down on nodes')) { $node_type = in_array($node->type, variable_get('vud_node_types', array()), TRUE); $widget_showmode = variable_get('vud_node_widget_show', 2); $tag = variable_get('vud_tag', 'vote'); @@ -186,7 +186,7 @@ case 0: break; case 1: - if (($teaser == 1) && $node_type && user_access('use vote up/down on nodes')) { + if (($teaser == 1) && $node_type && user_access('view vote up/down on nodes')) { $links['vud_node_votes_count'] = array( 'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme), 'html' => TRUE, @@ -194,7 +194,7 @@ } break; case 2: - if (($teaser == 0) && $node_type && user_access('use vote up/down on nodes')) { + if (($teaser == 0) && $node_type && user_access('view vote up/down on nodes')) { $links['vud_node_votes_count'] = array( 'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme), 'html' => TRUE, @@ -202,7 +202,7 @@ } break; case 3: - if ($node_type && user_access('use vote up/down on nodes')) { + if ($node_type && user_access('view vote up/down on nodes')) { $links['vud_node_votes_count'] = array( 'title' => theme('vud_votes', $node->nid, $type, $tag, $widget_theme), 'html' => TRUE, Index: vud.theme.inc =================================================================== --- vud.theme.inc (revision 954) +++ vud.theme.inc (revision 1041) @@ -230,28 +230,31 @@ */ function vud_vote($type, $cid, $value, $tag, $widget, $token) { if (is_numeric($value) && drupal_valid_token($token, "vote/$type/$cid/$value/$tag/$widget")) { - $vote = array(); - // Sanity-check the incoming values. - if ($value > 0) { - $vote['value'] = 1; - } - else if ($value < 0) { - $vote['value'] = -1; - } - else { - $vote['value'] = 0; - } + // 2010-01-05 Allow support for some users to VIEW a node but not use it + if (user_access('use vote up/down')) { + $vote = array(); + // Sanity-check the incoming values. + if ($value > 0) { + $vote['value'] = 1; + } + else if ($value < 0) { + $vote['value'] = -1; + } + else { + $vote['value'] = 0; + } - $vote['value_type'] = 'points'; - $tag = $tag ? $tag : variable_get('vud_tag', 'vote'); - $vote['tag'] = $tag; + $vote['value_type'] = 'points'; + $tag = $tag ? $tag : variable_get('vud_tag', 'vote'); + $vote['tag'] = $tag; - $vote['content_id'] = $cid; - $vote['content_type'] = $type; - $vote['tag'] = $tag; - $votes = array(0 => $vote); - drupal_alter('vud_votes', $votes); - votingapi_set_votes($votes); + $vote['content_id'] = $cid; + $vote['content_type'] = $type; + $vote['tag'] = $tag; + $votes = array(0 => $vote); + drupal_alter('vud_votes', $votes); + votingapi_set_votes($votes); + } } else { watchdog("vud", "Could not vote on $type $cid, with value $value, tag $tag and token $token"); @@ -262,17 +265,26 @@ ctools_include('ajax'); $plugin = vud_widget_get($widget); - if ($function = ctools_plugin_get_function($plugin, 'ajax render')) { - $commands = $function($type, $cid, $value, $tag, $token, $widget); - } - else { + // 2010-01-05 Check if the user has access, if not, send back alert box asking to log in + if (!user_access('use vote up/down')) { + //$commands[] = ctools_ajax_command_error('Only logged in users are allowed to vote.'); + drupal_set_message('Only logged in users are allowed to vote.'); $commands = array(); - if (!empty($plugin['widget template'])) { - $commands[] = ctools_ajax_command_replace("#widget-$type-$cid", theme('vud_widget', $cid, $type, $tag, $widget)); + $commands[] = ctools_ajax_command_redirect('user/login'); + } else { + + if ($function = ctools_plugin_get_function($plugin, 'ajax render')) { + $commands = $function($type, $cid, $value, $tag, $token, $widget); } + else { + $commands = array(); + if (!empty($plugin['widget template'])) { + $commands[] = ctools_ajax_command_replace("#widget-$type-$cid", theme('vud_widget', $cid, $type, $tag, $widget)); + } - if (!empty($plugin['votes template'])) { - $commands[] = ctools_ajax_command_replace("#votes-$type-$cid", theme('vud_votes', $cid, $type, $tag, $widget)); + if (!empty($plugin['votes template'])) { + $commands[] = ctools_ajax_command_replace("#votes-$type-$cid", theme('vud_votes', $cid, $type, $tag, $widget)); + } } }