? vote_up_down--1.patch
Index: hook_vud.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/hook_vud.php,v
retrieving revision 1.1.2.2
diff -r1.1.2.2 hook_vud.php
14a15,42
>  * Allow modules to alter access to the voting operation.
>  *
>  * @param $perm
>  *   A string containing the permission required to modify the vote.
>  * @param $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.
>  * @param $value
>  *   An integer containing the vote value, 1 for an up vote, -1 for a down vote.
>  * @param $tag
>  *   A string containing the voting API tag.
>  * $param $account
>  *   An object containing the user voting on the content, NULL for the current
>  *   user.
>  *
>  * @return
>  *   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) {
>   // Denies access for all users other than user 1.
>   if ($account->uid != 1) {
>     return FALSE;
>   }
> }
> 
> /**
Index: vud.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud.module,v
retrieving revision 1.1.2.29
diff -r1.1.2.29 vud.module
67c67,68
<     'access arguments' => array('use vote up/down'),
---
>     'access callback'  => 'vud_access',
>     'access arguments' => array('use vote up/down', 1, 2, 3, 4),
76c77,78
<     'access arguments' => array('reset vote up/down votes'),
---
>     'access callback'  => 'vud_access',
>     'access arguments' => array('reset vote up/down votes', 1, 2, 3, 4),
99a102,141
>  * Access callback for votes.
>  *
>  * @param $perm
>  *   A string containing the permission required to modify the vote.
>  * @param $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.
>  * @param $value
>  *   An integer containing the vote value, 1 for an up vote, -1 for a down vote.
>  * @param $tag
>  *   A string containing the voting API tag.
>  * $param $account
>  *   An object containing the user voting on the content, NULL for the current
>  *   user.
>  *
>  * @return
>  *   A boolean flagging whether or not the user has access to the vote.
>  */
> function vud_access($perm, $type, $content_id, $value, $tag, $account = NULL) {
>   if (NULL === $user) {
>     global $user;
>     $account = $user;
>   }
> 
>   // Initializes access based on user's permission.
>   $access = user_access($perm, $account);
> 
>   // 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;
>     }
>   }
> 
>   return $access;
> }
> 
> /**
Index: vud_node/vud_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vud_node/vud_node.module,v
retrieving revision 1.1.2.41
diff -r1.1.2.41 vud_node.module
74a75,95
>  * Implementation of hook_vud_access().
>  */
> function vud_node_vud_access($perm, $type, $content_id, $value, $tag, $account) {
>   // If one time voting is enabled, checks if a vote has been registered.
>   if (variable_get('vud_node_vote_once', 0) && $perm != 'reset vote up/down votes') {
>     $criteria = array(
>       'content_type' => $type,
>       'content_id' => $content_id,
>       'tag' => $tag,
>     );
>     $criteria['uid'] = $account->uid;
>     if (!$account->uid) {
>       $criteria['vote_source'] = ip_address();
>     }
>     if ($user_vote = votingapi_select_single_vote_value($criteria)) {
>       return FALSE;
>     }
>   }
> }
> 
> /**
118,119c139,146
< 
< return system_settings_form($form);
---
>   $form['vud_node_vote_once'] = array(
>     '#type'          => 'radios',
>     '#title'         => t('One time voting'),
>     '#description'   => t('Choose if users are allowed to vote only once per node.'),
>     '#default_value' => variable_get('vud_node_vote_once', 0),
>     '#options'       => array(0 => t('No'), 1 => t('Yes')),
>   );
>   return system_settings_form($form);
