? .svn ? vote_up_down-170068.patch ? alternative/.svn ? documentation/.svn ? documentation/voting_actions_examples/.svn ? images/.svn ? tests/.svn ? theme/.svn ? translations/.svn Index: vote_up_down.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/vote_up_down/vote_up_down.module,v retrieving revision 1.24.2.31 diff -u -p -r1.24.2.31 vote_up_down.module --- vote_up_down.module 5 Apr 2009 13:11:00 -0000 1.24.2.31 +++ vote_up_down.module 20 Aug 2009 03:24:00 -0000 @@ -123,6 +123,13 @@ function vote_up_down_admin_advanced_set '#options' => array(0 => t('No'), 1 => t('Yes')), '#description' => t('If yes, a link will be displayed on nodes and comments that will allow users to reset their vote.'), ); + $form['vote_widget_settings_advanced']['vote_up_down_vote_self'] = array( + '#type' => 'radios', + '#title' => t('Allow users to vote on their own content'), + '#default_value' => variable_get('vote_up_down_vote_self', 1), + '#options' => array(0 => t('No'), 1 => t('Yes')), + '#description' => t('If no, the voting widget will not appear on your own content.'), + ); $form['vote_widget_settings_advanced']['vote_up_down_tag'] = array( '#type' => 'textfield', '#title' => t('Voting API tag'), @@ -207,11 +214,12 @@ function vote_up_down_menu() { * Implementation of hook_nodeapi(). */ function vote_up_down_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { + global $user; switch ($op) { case 'view': if (user_access('view up/down votes')) { $node_type = in_array($node->type, variable_get('vote_up_down_node_types', array()), TRUE); - if ($node_type) { + if ($node_type && ($node->uid != $user->uid || variable_get('vote_up_down_vote_self', 1))) { $style = variable_get('vote_up_down_widget_style_node', 0) == 1 ? '_alt' : ''; if ($teaser && variable_get('vote_up_down_widget_node', 0) && variable_get('vote_up_down_widget_node', 0) != 2) { $node->content['vote_up_down'] = array( @@ -250,9 +258,10 @@ function vote_up_down_preprocess_node(&$ * Implementation of hook_comment(). */ function vote_up_down_comment(&$comment, $op) { + global $user; switch ($op) { case 'view': - if (variable_get('vote_up_down_widget_comment', 1)) { + if (variable_get('vote_up_down_widget_comment', 1) && ($comment->uid != $user->uid || variable_get('vote_up_down_vote_self', 1))) { if (user_access('view up/down votes')) { $style = variable_get('vote_up_down_widget_style_comment', 0) == 1 ? '_alt' : ''; $comment->comment = theme("vote_up_down_widget$style", $comment->cid, 'comment') . $comment->comment; @@ -371,39 +380,6 @@ function vote_up_down_block($op = 'list' } /** - * Implementation of hook_userpoints(). - */ -function vote_up_down_userpoints($op, $params = array()) { - switch ($op) { - case 'setting': - $form['vote_updown_points'] = array( - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#title' => t('Vote up/down points'), - ); - - $form['vote_updown_points']['userpoints_vote_up_down'] = array( - '#type' => 'textfield', - '#title' => t('Points for voting on a node (requires the Vote Up/Down module)'), - '#default_value' => variable_get('userpoints_vote_up_down', 0), - '#size' => 5, - '#maxlength' => 5, - ); - $form['vote_updown_points']['userpoints_actions'] = array( - '#type' => 'textfield', - '#title' => t('Points for actions (requires the Actions module)'), - '#default_value' => variable_get('userpoints_actions', 0), - '#size' => 5, - '#maxlength' => 5, - ); - - return $form; - break; - } -} - -/** * Menu callback; Handles voteupdown and subpages. */ function vote_up_down_page() { @@ -538,22 +514,6 @@ function vote_up_down_vote($type, $cid, $tag = $tag ? $tag : variable_get('vote_up_down_tag', 'vote'); $vote['tag'] = $tag; - // Userpoints integration. - if (module_exists('userpoints')) { - global $user; - if ($type == 'node') { - $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.uid FROM {node} n WHERE n.nid = %d'), $cid)); - } - else { - $node = db_fetch_object(db_query(db_rewrite_sql('SELECT c.uid FROM {comments} c WHERE c.cid = %d', 'c', 'cid'), $cid)); - } - $criteria = array('content_type' => $type, 'content_id' => $cid, 'uid' => $user->uid, 'tag' => $tag); - $user_vote = votingapi_select_single_vote_value($criteria); - if ($user->uid && !$user_vote && ($node->uid != $user->uid) && ($vote['value'] != 0)) { - userpoints_userpointsapi('points', variable_get('userpoints_vote_up_down', 0), $user->uid, 'Vote Up/Down points'); - } - } - // Do the voting via Voting API. if ($uid = _vote_up_down_get_uid()) { if ($vote['value'] == 0) {