From 85b55a57d01f92f1f3f84c6e9cd1203fff60a3f0 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Sun, 30 May 2010 21:44:43 -0500 Subject: [PATCH] task #807934 by marvil07: Let choose vud node view behaviour Now, you can choose if you want to use the modal div or to avoid showing the voting links. --- WIDGETAPI.txt | 3 ++- vud.module | 6 ++++++ vud.theme.inc | 30 ++++++++++++++++++++++-------- widgets/alternate/widget.tpl.php | 14 ++++++++------ widgets/plain/widget.tpl.php | 6 +++--- widgets/updown/widget.tpl.php | 2 ++ 6 files changed, 43 insertions(+), 18 deletions(-) diff --git WIDGETAPI.txt WIDGETAPI.txt index 7ce868a..ab49514 100644 --- WIDGETAPI.txt +++ WIDGETAPI.txt @@ -121,7 +121,8 @@ $class : 'negative', 'positive' or 'neutral' depending on number of $vote_label : The pluralized vote label $points : Number of total vote points for the vote object (signed) $unsigned_points : Number of total vote points for the object (unsigned) -$readonly : Boolean that indicates if the actual user can vote on the object +$readonly : Boolean that indicates if the actual user can vote on the object where the widget is displayed +$show_links : Boolean that indicates if the links need to be show(TRUE when the user has permission to vote or message_on_deny option is set to TRUE) Advanced features ================= diff --git vud.module vud.module index 4c40cd8..791e65f 100644 --- vud.module +++ vud.module @@ -29,6 +29,12 @@ function vud_admin_advanced_settings() { '#default_value' => variable_get('vud_tag', 'vote'), '#description' => t('Since Vote Up/Down uses Voting API, all votes will be tagged with this term. (default: vote)
This tag is useful is you have deployed various modules that use Voting API. It should always be a unique value. Usually, there is NO need to change this.'), ); + $form['vud_message_on_deny'] = array( + '#type' => 'checkbox', + '#title' => t('Message on denied permission'), + '#default_value' => variable_get('vud_message_on_deny', FALSE), + '#description' => t('When this flag is active, a modal window will be shown to the end user instead of avoid showing the voting links'), + ); return system_settings_form($form); } diff --git vud.theme.inc vud.theme.inc index 7e2fd8e..608ebc7 100644 --- vud.theme.inc +++ vud.theme.inc @@ -184,21 +184,35 @@ function vud_widget_proxy($content_id, $type, $tag, $widget_theme, $readonly=NUL $variables['vote_label'] = format_plural($vote_result, 'vote', 'votes'); $variables['readonly'] = $readonly; + $link_up = url("vote/$type/$content_id/1/$tag/$widget_theme/$token_up"); + $link_down = url("vote/$type/$content_id/-1/$tag/$widget_theme/$token_down"); + $message_on_deny = variable_get('vud_message_on_deny', FALSE); + $variables['show_links'] = !$readonly || $message_on_deny; if ($readonly) { - ctools_include('modal'); - ctools_modal_add_js(); - $variables['link_class_up'] .= ' denied ctools-use-modal'; - $variables['link_class_down'] .= ' denied ctools-use-modal'; - $variables['link_up'] = url(sprintf('vud/nojs/denied/%d', $widget_message_code)); - $variables['link_down'] = url(sprintf('vud/nojs/denied/%d', $widget_message_code)); + $variables['link_class_up'] .= ' denied'; + $variables['link_class_down'] .= ' denied'; + if ($message_on_deny) { + ctools_include('modal'); + ctools_modal_add_js(); + $variables['link_class_up'] .= ' ctools-use-modal'; + $variables['link_class_down'] .= ' ctools-use-modal'; + $link_up = url(sprintf('vud/nojs/denied/%d', $widget_message_code)); + $link_down = url(sprintf('vud/nojs/denied/%d', $widget_message_code)); + } + else { + // no vote access, so avoid show the link at template + $link_up = '#'; + $link_down = '#'; + } } else { $variables['link_class_up'] .= ' ctools-use-ajax'; $variables['link_class_down'] .= ' ctools-use-ajax'; - $variables['link_up'] = url("vote/$type/$content_id/1/$tag/$widget_theme/$token_up"); - $variables['link_down'] = url("vote/$type/$content_id/-1/$tag/$widget_theme/$token_down"); } + $variables['link_up'] = $link_up; + $variables['link_down'] = $link_down; + $output = $plugin['render function']($template_file, $variables); return $output; } diff --git widgets/alternate/widget.tpl.php widgets/alternate/widget.tpl.php index 0809374..ef71a02 100644 --- widgets/alternate/widget.tpl.php +++ widgets/alternate/widget.tpl.php @@ -8,10 +8,12 @@ */ ?>
- -
- -
-
- + +
+ + +
+
+ +
diff --git widgets/plain/widget.tpl.php widgets/plain/widget.tpl.php index 3846a34..a214a74 100644 --- widgets/plain/widget.tpl.php +++ widgets/plain/widget.tpl.php @@ -7,13 +7,13 @@ * Plain widget theme for Vote Up/Down */ ?> -
- + + -
diff --git widgets/updown/widget.tpl.php widgets/updown/widget.tpl.php index 632bb9a..4d8bc20 100644 --- widgets/updown/widget.tpl.php +++ widgets/updown/widget.tpl.php @@ -13,10 +13,12 @@ +
+
-
+ -- 1.7.1