diff --git a/vud.api.php b/vud.api.php
index b7c5da6..ff7a736 100644
--- a/vud.api.php
+++ b/vud.api.php
@@ -15,7 +15,7 @@ define('VUD_NEWENTITY_WIDGET_MESSAGE_POSTPONED', 2);
*
* @param $perm
* A string containing the permission required to modify the vote.
- * @param $type
+ * @param $content_type
* A string containing the type of content being voted on.
* @param $content_id
* An integer containing the unique ID of the content being voted on.
@@ -31,7 +31,7 @@ define('VUD_NEWENTITY_WIDGET_MESSAGE_POSTPONED', 2);
* A boolean forcing access to the vote, pass NULL if the function should
* not modify the access restriction.
*/
-function hook_vud_access($perm, $type, $content_id, $value, $tag, $account) {
+function hook_vud_access($perm, $content_type, $content_id, $value, $tag, $account) {
// Denies access for all users other than user 1.
if ($account->uid != 1) {
return FALSE;
diff --git a/vud.module b/vud.module
index e744404..8a9758e 100644
--- a/vud.module
+++ b/vud.module
@@ -116,7 +116,7 @@ function vud_menu() {
*
* @param $perm
* A string containing the permission required to modify the vote.
- * @param $type
+ * @param $content_type
* A string containing the type of content being voted on.
* @param $content_id
* An integer containing the unique ID of the content being voted on.
@@ -131,24 +131,28 @@ function vud_menu() {
* @return
* A boolean flagging whether or not the user has access to the vote.
*/
-function vud_access_callback($perm, $type, $content_id, $value, $tag, $account = NULL) {
- if (NULL === $account) {
+function vud_access_callback($perm, $content_type, $content_id, $value, $tag, $account = NULL) {
+ if ($account === NULL) {
global $user;
$account = $user;
}
- // Initializes access based on user's permission.
- $access = user_access($perm, $account);
+ // If user do not pass system permissions, deny soon.
+ if (user_access($perm, $account) !== TRUE) {
+ return FALSE;
+ }
- // Invokes hook_access(), gives modules ability to allow or disallow access.
- $access_array = module_invoke_all('vud_access', $perm, $type, $content_id, $value, $tag, $account);
- foreach ($access_array as $set_access) {
- if (isset($set_access)) {
- $access = $set_access;
+ // Invokes hook_vud_access(), gives modules ability to allow or disallow access.
+ $access_array = module_invoke_all('vud_access', $perm, $content_type, $content_id, $value, $tag, $account);
+ foreach ($access_array as $access_result) {
+ // If one hook implementation want to deny, end there.
+ if ($access_result !== TRUE) {
+ return FALSE;
}
}
- return $access;
+ // If we are here, account should pass.
+ return TRUE;
}
/**
diff --git a/vud_comment/vud_comment.module b/vud_comment/vud_comment.module
index 7e661eb..052cb06 100644
--- a/vud_comment/vud_comment.module
+++ b/vud_comment/vud_comment.module
@@ -115,7 +115,7 @@ function vud_comment_comment(&$comment, $op) {
$tag = variable_get('vud_tag', 'vote');
$read_only = !vud_access_callback('use vote up/down', 'comment', $comment->cid, 0, $tag);
$widget = variable_get('vud_comment_widget', 'plain');
- $comment->vud_comment_widget = theme('vud_widget', $comment->cid, 'comment', $tag, $widget, $read_only);
+ $comment->vud_comment_widget = theme('vud_widget', $comment->cid, 'comment', $tag, $widget, $read_only, VUD_WIDGET_MESSAGE_DENIED);
if (variable_get('vud_comment_widget_display', VUD_COMMENT_DISPLAY_NORMAL) == VUD_COMMENT_DISPLAY_NORMAL) {
$comment->comment = $comment->vud_comment_widget . $comment->comment;
}
diff --git a/vud_term/vud_term.module b/vud_term/vud_term.module
index d966ee3..b14cde5 100644
--- a/vud_term/vud_term.module
+++ b/vud_term/vud_term.module
@@ -119,7 +119,7 @@ function _vud_term_generate_table(&$node) {
$rows[] = array(
$tdetails->name,
$tdetails->description,
- theme('vud_widget', $content_id, "term", $tag, $widget, $read_only),
+ theme('vud_widget', $content_id, "term", $tag, $widget, $read_only, VUD_WIDGET_MESSAGE_DENIED),
"". _vud_term_get_row_votes($content_id, $tag) .'',
l('Reset your vote', "votereset/term/$content_id/$tag/$reset_token"),
);
@@ -134,7 +134,7 @@ function _vud_term_generate_table(&$node) {
$rows[] = array(
$tdetails->name,
$tdetails->description,
- theme('vud_widget', $content_id, "term", $tag, $widget, $read_only),
+ theme('vud_widget', $content_id, "term", $tag, $widget, $read_only, VUD_WIDGET_MESSAGE_DENIED),
"". _vud_term_get_row_votes($content_id, $tag) .'',
);
}