dear experts,
i posted a similar question in the rate module issues page, but since this isn't limited to the rate module per-se, i'm posting a general question here...
working on a site i need to add a confirmation window before a vote is cast. the confirmation needs to happen before the event, in the sense that if the user declines, the vote isn't counted, and rules with event "user votes on a node" do not fire.
how can this be achieved? is there a combination of existing modules that would work? or with a custom module?
if so, how?
similar questions have been discussed before, but at least as per my understanding, without working solutions...:
https://www.drupal.org/node/1871002 (Cannot prevent voting being processed at eventBeforeRate event)
here:
http://drupal.stackexchange.com/questions/124121/rules-integration-with-...
and here:
http://drupal.stackexchange.com/questions/73355/rate-module-and-rule-int...
i appreciate any help with this.
(you might have noticed i'm a beginner, please speak slowly ;-) )
thank you,
d
Comments
Given the voting interface is
Given the voting interface is ajax based, I am guessing you are looking for a custom solution that will require some knowledge of how the voting/rating tool works.
hey nevets, thank you for
hey nevets, thank you for your response.
reading other posts (like the ones that i linked to) i gather that it's not only a matter of getting it to work, but also getting it to work without introducing some js security risks. any suggestions?
anybody?!?!
anybody?!?!
hey people, please help.
hey people, please help.
i don't know anymore. am i asking the wrong questions? am i posting them in the wrong place? or is this just something that can't be achieved in drupal?!
kind wishes,
d
I think the reason you are
I think the reason you are not getting specific answers is you are asking about a theoretical problem since you have no code to show.
catch 22
thank you.
so it seems i'm in a bit of a catch-22 situation: i don't know coding, and therefore i can't show any code here for discussion, and therefore no one can advise me on how to progress and so on...
if anyone can post something basic with which to kickstart a process here i'll be very grateful!!
best wishes,
doron
_
in this case, that's going to be problem-- don't know of any way to do this without custom jquery. And to complicate matters even more, based on the first link you provided above, it seems even that doesn't work properly. However, since that issue is almost 2 years old, it might be worth seeing if it would work with the dev version.
Alternatively, maybe the fivestar module can do it.
In any case, you're not likely to get useful answer in the forums because there is no 'try this' type answer that will work. This is one of those instances that requires code. :-(
hi, and thank you for your
hi, and thank you for your input.
do you think my best option is paying someone to solve this problem for me? or perhaps it's better to have someone develop a whole new custom module?
d
_
I don't think I would recommend a custom module-- it definitely seems a feature that belongs in the rate module. If you do hire someone, I would recommend they contact the maintainer of the rate module and offer to submit it as an enhancement patch. More often then not, maintainers are happy to have patches for enhancements.
hi worldfallz. thank you for
hi worldfallz. thank you for your advice. i'm sure it is good advice, but since i'm not receiving ANY response to the messages i'm sending the rate module's maintainers, i'm afraid i won't be able to follow it...
the drupal world is a mystery to me :-(
_
That's not drupal specific... That's just open source. People come and go all the time. The benefit is that when they go, unlike with commercial sw, they can't their code with them.
I would still recommend adding the feature to the module as a patch and posting it to the issue queue. You never who might come along and take over maintainership and add it to the module.
dear experts,
dear experts,
i'm considering a whole new approach to the matter, a work around, and i'd like to run through it here, and hear some experts' opinion.. is it feasible, doable, logical?
the idea is to create a pseudo voting system. instead of a widget, the user clicks on a voting LINK, which directs him to a new (popup?) page, aka the confirmation page. if he declines, the page closes and he's back where he started. if he agrees, he is redirected back to the original page which is refreshed to reflect the new vote. the votes themselves can be nodes, and the node count can be brought in with views...
except for the obvious disadvantage of 2 extra redirects, what other problems do you foresee? are there any hidden security issues?
many thanks,
d
_
Not sure how you would implement this, but it seems a decent solution. Not sure I would direct to a new page though. I would think you could do it with some custom jquery and a standard js confirm alert.
You could just attach a
You could just attach a javascript confirm() event to the submit button's onclick handler.
worldfalls why do you think
worldfalls why do you think this would be difficult to implememt?
what are the advantages of javascript? wouldn't it introduce some security issues as discussed above?
Codeblind is it really so straightforward? could you pleeease go into a bit more detail on how to do it?
(a quick search for "javascript confirm event" shows many people struggling with this and quite a few different solutions)
thanks again
d
_
I never said it was difficult...I said it requires custom js/jquery.
There should be no security
There should be no security issues inherent in using a javascript confirm to block the form submission. All a confirm dialog does is display a message with yes and no type buttons. Clicking yes allows the form request to continue, while clicking no simply stops the http request from being made by the client browser. The processing of submitted data is still managed by the Drupal Form API and so is as secure as the Form API is at any given moment.
Where you can run into trouble is the javascript confirm() will only run if javascript is being supported. A bot or browser with javascript disabled would bypass the confirmation dialog entirely. The form is as secure as it ever was, but confidence in the user actually acknowledging the agreement is decreased.
Another method would be to create a modal window with a message that sets the value of a hidden form field by way of javascript, and make that hidden field required. This will increase your confidence the user wittingly agreed to the terms and leave some evidence by way of an associated value in the database. The downside is javascript support is absolutely required to make a submission.
I have worked with other custom solutions that checked for flags or other such markers on hook_form_validate(), but they tend to prove problematic, difficult to maintain, and easy to circumvent--even by accident.
I prefer to support both JS
I prefer to support both JS and non-JS solutions. So I'd set it up to work without JS first, redirecting to a form built with confirm_form(), that redirects back to the first page after confirmation. Then I'd AJAX the original form, so that it submits the vote through AJAX when the form is clicked.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
regarding the non JS solution
regarding the non JS solution, is this something i can achieve without coding? ie link to a page which has a reference to the original content, and then if the user accepts, create a new "vote node" which is also referenced to that piece of content?
using the link module and the rules module perhaps, or other modules?
(i'm setting up my site using panels)
d
or perhaps one of the modal
or perhaps one of the modal modules?
in my search i came across an interesting module called entity-reference-view-widget. could it be twisted somehow to work here?
or perhaps with the relation module?
any help welcome...
_
we're going round in circles at this point. There doesn't seem to a non-programming method to do this. I have no clue how entityreference_view_widget or relation fit into this at all. But if you see a way, you'll probably have to try it to find out as no one is likely to have used them for this before.
Sorry, I'm more a coder than
Sorry, I'm more a coder than a module user, so I don't know any module-based solutions you can use.
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
hi experts,
hi experts,
a custom module was made for me to solve this problem, and it worked. a window would pop-up every time a user voted.
but since then i made some security updates to drupal, and now it's broken. in fact, nothing happens at all!!!
as far as i can tell, the main differences are
database system version 5.1.66 --> 5.6.23
php 5.3.18 --> 5.4.43
the jQuery-update-module is enabled and shows the same version on
both instances of the site: jQuery 1.7.2 and jQuery UI 1.10.2
perhaps you know how to fix this?
i'm including here the content of the .module file.. let me know what else i should show...
many many thanks for any tips.
d
<?php
// $id:
module_load_include('module', 'rate', 'rate');
if (module_exists('rate') && !function_exists('rate_get_active_widgets')) {
function rate_get_activate_widgets(){
return '';
}
}
/**
* Implements hook_node_view();
*/
function rate_alter_node_view($node, $view_mode, $langcode = ''){
$title = 'item';
if(is_object($node)){
$title = $node->title;
}
if ($view_mode != 'rss') {
$widgets = rate_get_active_widgets('node', $node->type, $view_mode);
if(count($widgets) > 0){
$node->content['rate_alter'] = get_popup($title);
}
}
}
/**
* Implements hook_comment_view_alter();
*/
function rate_alter_comment_view_alter(&$comment){
$node = $comment['#node'];
$widgets = rate_get_active_widgets('comment', $node->type);
if(count($widgets) > 0){
$comment['rate_alter'] = get_popup();
}
}
/**
* Get the popup on the page
**/
function get_popup($title = null){
drupal_add_css(drupal_get_path('module', 'rate_alter') . '/jquery-ui/jquery-ui.min.js',array('group' => CSS_DEFAULT, 'every_page' => TRUE));
drupal_add_js(drupal_get_path('module', 'rate_alter') . '/jquery-ui/jquery-ui.min.js');
drupal_add_css(drupal_get_path('module', 'rate_alter') . '/jquery-ui/jquery-ui.min.css',array('group' => CSS_DEFAULT, 'every_page' => TRUE));
drupal_add_css(drupal_get_path('module', 'rate_alter') . '/rate_alter.css',array('group' => CSS_DEFAULT, 'every_page' => TRUE));
drupal_add_js(drupal_get_path('module', 'rate_alter') . '/rate_alter.js');
$popup_markup = array(
'#weight' => 200,
'#markup' => get_html_popup($title),
'#type' => 'item',
);
return $popup_markup;
}
/**
* get html for popup
*/
function get_html_popup($title = null){
$html = '
$html .= '
are you sure you want to vote on '. $title .'?
';
$html .= '';
$html .= '
';
return $html;
}
Check out https://www.drupal
Check out https://www.drupal.org/sandbox/cmcintosh/2644004 - it's a sandbox project that might do what you need.