Great work on these voting systems! Any chance for a D7 port?

CommentFileSizeAuthor
#28 rate-935446-27.patch365 bytesmauritsl
#4 rate-935446.patch111.81 KBwillvincent

Comments

bertboerland’s picture

hi,

this is a very valid requst. Note however that we build this module for our own customers. As long as they do not migrate and we do not need this module in d7, we might be slow on picking this up. In due time this will be done however for sure, jut not when d7.0 will be out.

bertboerland’s picture

Status: Active » Postponed

setting to postponed, will be done in due time

sammyman’s picture

Subscribing.

willvincent’s picture

Status: Postponed » Needs review
Issue tags: +#d7ux
StatusFileSize
new111.81 KB

Trying my hand at rolling an initial patch for Drupal 7... this is rolled against cvs head.

It addresses all issues in coder, including formatting issues, aside from two or three false positives.

  • DB functions have been updated to new d7 style
  • .info files have been updated as required by d7
  • minor formatting changes to the code, including adding a few missing comments
  • Updated JS to preserve compatibility of jQuery alongside other libraries

Probably a bunch more items I'm forgetting, and I'm sure there's most likely a good deal more work going to be needed to port this fully, but it's at least installable.. Haven't tested beyond that yet.

mauritsl’s picture

Many thanks on that!

Now busy with carols :) But I will review this soon and commit it to a 7.x branch.

willvincent’s picture

There are still a lot of problems with this patch.. It installs on d7, but that's the extent of it really.. none of the menu hooks are working as they should, and they don't live within the new d7 admin menu properly. Form callback for the widget types is also broken, it's throwing an error, and returning "Array" rather than a rendered form.

Not sure where to go from here though as I'm not familiar enough with the code or the voting api.

ranavaibhav’s picture

Title: Drupal 7 » Rate module - Drupal 7 port

+1
subscribing

rene bakx’s picture

Since i figured out, I would need a module like this on a project I'm building the next weekends off, started on the conversion this afternoon, and I'm pretty much done with the admin part of this module.

Rewrote the storage part of the widgets, instead of storing all the widgets in one gigantic serialized array in the variables added a schema to store a single widget in one row of the database.

Moved some things around, and created a few functions to cope with that new table.

Pushed my work so far onto gitorious repo

Will look at your patch tomorrow tcindie, i'm especially interested in your work at the javascript side :)

bertboerland’s picture

Hi Rene, thanks!

rene bakx’s picture

Don't thank me yet, cause i give up.. the lack of structure in this module is to much for me.

I spend almost an entire morning figuring how i need to set a template and why it can not be in the edit widget way. For me this proves that storing data as serialized arrays is like storing a database inside a database. If it would truly be the CCK of voting, the data model needs to be unserialized and stored in a normal table way. Having a few tables extra in a DB is cheaper then unserialize every widget there is, check if that widget has your current node_type set and then display the voting form.

But that would cost me more time then i have at this moment, and would mean a complete rebuild. Might as well build a new module from scratch then.

If somebody want's to continue with this, feel free to grab my work from the above mentioned gitorious account.

bertboerland’s picture

thanks for this feedback, will discuss this with maurits

thomas1977’s picture

Subscribing. Looking forward to the D7 port being a reality. Thanks, guys!

DomDoze’s picture

Subscribing. Would love to see this ported.

mauritsl’s picture

I got pretty far this evening based on the work of tcindie. The backend works, except for the delete checkboxes not playing well with ahah. The frontend still generates tons of errors coming from the part that integrates with votingapi. I will go on with that part on Wednesday, hoping to get a working D7 version this week. No promises yet - will do my best :)

@ReneB: The variables system is indeed a database in a database. I agree that Rate got too complex to store everything in the variables. But it's more important to have a working D7 version imo. I will leave your work for a next version.

bertboerland’s picture

I have seen a working demo at mau's, so rate will be the first voting module out for d7 it seems ;-)

willvincent’s picture

The entire ahah system has changed in d7.. It's changed to #ajax

Randy Fay posted good info about the changes on his site here: http://randyfay.com/ajax

mauritsl’s picture

Status: Needs review » Needs work

A D7 port has been committed. Dev snapshot will be available within 12 hours.

Known issues:

  • The charts functionality under the "Vote results" tab is missing. Charts are removed since there is not a reliable chart module available voor D7 yet. The only charts module available for D7 at the moment is charts. We are now using chart, which does not have a D7 release. I have not tested charts yet, but the last commit was 27 weeks ago, too much imo.
  • All votes are counted when users vote multiple times on the same node. Will be fixed with VotingAPI, see #1023492: Old votes are not deleted in votingapi_set_votes().
  • Anonymous users can vote multiple times on the same node. This can be a bug in votingapi, needs to be investigated.

I just did some basic testing. Please test for yourself and post your feedback here.

@tcindie:
In the D6 version you can check the delete checkbox and then click the "Add more options" button. The row with the delete box checked is then deleted. The behavior was different in D7, the row was deleted, but the Nth checkbox remains checked (for another option). I did not manage to get the damn checkbox unchecked, but solved the problem by not deleting the row at all.

mauritsl’s picture

Euuhm testing needed.. thus "needs review"

mauritsl’s picture

Status: Needs work » Needs review

Vote rollover issue is already posted in the VotingAPI issue queue: #997092: Anonymous vote rollover not working

Cheek’s picture

Thanks for the port! However, it's not yet working for me. I can install. Create rate systems. But I can't print anything in my theme.

None of the code examples in the readme.txt show anything. Also, print_r($links); or print_r($results); gives no results.

When I try:

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && $node = node_load(arg(1))) {
  node_invoke_nodeapi($node, 'view');
  print $node->rate_NAME['#value'];
}
?>

I get:
Fatal error: Call to undefined function node_invoke_nodeapi() in /sites/all/themes/foa/templates/node.tpl.php on line 104

I'm also getting the following error on every page:

WARNING: PARAMETER 1 TO RATE_NODE_VIEW() EXPECTED TO BE A REFERENCE, VALUE GIVEN IN MODULE_INVOKE_ALL() (LINE 817 OF /INCLUDES/MODULE.INC).

willvincent’s picture

That issue isn't due to the module being non functional, it's due to you calling a function that no longer exists in d7. ;)

From the docs:

The function node_invoke_nodeapi() has been removed. Use module_invoke_all('node_' . $hook, $node); where you used node_invoke_nodeapi($node, $hook);.

So, that code should be changed to this:

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && $node = node_load(arg(1))) {
  module_invoke_all('node_view', $node);
  print $node->rate_NAME['#value'];
}
?>
mauritsl’s picture

That code also doesn't work. The widget is now in $node->rate_NAME['#markup'] instead of '#value'. But the module_invoke_all() triggers errors in the comment module. To overcome these problems I've created a new function called "rate_embed". The code is now:

if (arg(0) == 'node' && is_numeric(arg(1)) && ($node = node_load(arg(1)))) {
  print rate_embed($node, 'NAME');
}

Readme is also updated. Code is committed to CVS.

willvincent’s picture

This is a cleaner way of handling this anyway I think.. there's probably not any reason to have it be in the nodeapi hook if it's not going to load automatically anyway. :)

mauritsl’s picture

I had the same thoughts on that at first, but the reason not to do so is that you will depend your theme on a module. This will generate fatal errors (thus wsod's) if you disable the module.

mauritsl’s picture

There is a bug in the permissions part.

An anonymous user is not getting a message when he does not have the permission to vote, and when the option "Behaviour when user has no permission to vote" is set to "Redirect to login and show message".

The message is set in the vote callback. Then the user is redirected to /user, this is a separate request. In D7, messages are never displayed on another request for anon users. The way to fix this is to create new page, with message and loginbox, and redirect to that page.

I do not have time to fix this issue this week, so I will release a beta now, mentioning this issue in the release notes.

rene bakx’s picture

Hey Maurits...

I still have the code that untangles the code a little, and storing some extra fields in table to make it easier, and more scalable in sites with many rate widgets and many nodes. What i did was, i kept the serialized data structure, but introduced a rid (rate.id) , and created a link table that linked an rid to nid. And created a little helper function that hooked into node_load to load the rate widgets associated to that specific node. Saved some looping trough all the widget to determine the correct widget(s) for a node.

If you want, I could merge that, with the code you made for actually showing the widgets on the front screen.

Cause that's where I got stuck, and ran out of time to port the rate module to 7 (instead I quickly ported the plus1 module, cause that was the widget I was looking for, so technically Bert is not correct on having the first working vote system ;))

Have to commit it back to you via a patch, since I did not get my CVS access on d.o, or possible trough github/gitorious?

kansaj’s picture

I still cannot get rid form the message
Warning: Parameter 1 to rate_node_view() expected to be a reference, value given in module_invoke_all() (line 817 of .../includes/module.inc).
and it prevents from showing the widget.

mauritsl’s picture

StatusFileSize
new365 bytes

@kansaj:
The rate_node_view function indeed expects a reference. This is not a technical requirement, so I think we should remove the ampersand there.

Can you please tell me if the patch attached solves your problem?

kansaj’s picture

With #28 now everything works fine !
Tnx

mauritsl’s picture

Patch is committed to CVS.

mauritsl’s picture

Bug in permissions part (comment #25) is now fixed.

I solved this issue by creating a new menu callback, which sets the message and shows the login page (using user_page()). Advantage is that this also works with aggressive caching, D6 version don't, so maybe I will backport this.

Beta 2 is now released, containing this fix and patch from #28.

Anonymous’s picture

I have just installed the module... added a couple of widget types and enabled them on all node types and comments...

And yet... When I try to add a rating field to my comment forms... there is no 'rate' field type under 'select a field type'... or in fact any field type which will allow me to select the Rate widgets...

I am a beginner... so be kind - but am I missing something blindingly obvious?

D7 latest release

zrice57’s picture

Version: 6.x-1.x-dev » 7.x-1.0-beta2
Component: Code » Miscellaneous
Assigned: Unassigned » zrice57

I installed the drupal 7 beta2 version onto my site. Everyting works but when I try to click on a vote option it doesn't load the vote.

I have to copy and paste the url of the vote button into the address bar for it to work.

i have tried on multiple computers with multiple browsers and they all have the same problem

mauritsl’s picture

Status: Needs review » Fixed

@fineale_uk: The rate widgets can be configured under admin/structure/rate. More info is provided in the readme file.

@zrice57: Thanks for the report. It is also reported as a separate issue: #1042216: Can't click to vote on IE8. Please track that issue for this problem.

I'm setting the status for this ticket to fixed, as the D7 version is available. All issues with this release should have their own ticket.

Status: Fixed » Closed (fixed)
Issue tags: -#d7ux

Automatically closed -- issue fixed for 2 weeks with no activity.

ivnish’s picture

Assigned: zrice57 » Unassigned
Issue summary: View changes
Issue tags: -#d7ux