Closed (fixed)
Project:
Voting API
Version:
master
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
6 Mar 2006 at 21:17 UTC
Updated:
19 May 2006 at 07:15 UTC
Jump to comment: Most recent file
The biggest need right now is figuring out a good way to cleanly integrate voting_actions module into the api. It's something that really should be integrated, with a way for other modules (like simplevote) to register a 'default action' without the user needing to do anything.
ie, if 10 people vote it up to 4 stars, promote it to the front page. that's possible now but it's a manually configured process.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | simplevote.module | 3.85 KB | eaton |
Comments
Comment #1
eaton commentedThis is one I've been rolling around for a bit, and there are a couple of key sub-points:
1) The API needs a convenience function to load a piece of content from a type/id pair, returning an object. Why is this necessary? When a piece of content is voted on, we'll need a fully instantiated version of the content object to pass to the action. Nodes and comments are two obvious examples, but aggregator items, users, and other bits would be helpful too. Providing several default loaders and tossing out a votingapi invoke in other circumstances, to allow other modules to handle the task, would probably be best.
2) The API needs to support conditionals based on the voting results AND the current state of the content object. For example, don't bother with 'promotion' actions if the module is already promoted. This will save needless DB thrashing.
3) The API needs to provide hooks (like views.module's hook_views_tables()?) for other modules to expose 'default' actions without user intervention. This would allow a moderation module to set up automatic promotion/demotion actions without the user knowing the details.
4) The API needs to expose a screen not unlike the existing voting_actions administration screen, for users to override default actions exposed by modules, and create their own.
Comment #2
eaton commentedThe latest checkin for votingapi supports 1), 2), and 3). #4 -- a UI for managing the new data structures -- is not yet in place. But all of the backend work is in place. Further updates as events warrant.
I've attached a modified version of SimpleVote that demonstrates how this functionality works. It implements the hook_votingapi_action_sets() hook and returns an array of action sets. Each action set is a collection of filter criteria, and actions to perform if the filter criteria are met.
The $condition objects require the most explanation at this point, as they're basically the name of a function (the handler) and the data to pass into that function (the value). votingapi_vote_result_handler() is a handler that's already been added to votingapi for comparing the results of a given vote.
Comment #3
eaton commentedComment #4
eaton commentedSubsequent checkins have refined the action set format, and examples can now be found in VotingAPI's API.txt file, and the CVS version of SimpleVote.module.
Comment #5
(not verified) commented