Node operations
Roger López - February 2, 2009 - 20:17
| Project: | modr8 |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
This patch adds a hook_node_operations() function for modr8 and provides 3 operations:
- Mark for moderation
- Approve moderated nodes
- Delete moderated nodes
Pretty simple but immensely useful. Use with views bulk operations to create custom moderation views.
| Attachment | Size |
|---|---|
| modr8.nodeops.patch | 2.56 KB |

#1
Looks useful indeed - however, it seems like at least for the approve/deny functions we ought to be able to re-use existing code? If not, we should refactor it.
#2
More problems - the operations, such as "approve" may be applied to nodes that are not in moderation. Also, casting $node to an array does not fully recapitulate the expected values array.
#3
I definitely want to refactor, just didn't want to over-scope this issue.
#4
created an issue to refactor into reusable api functions. will re-roll this after that gets in.
marking postponed, waiting on #368782: Refactor: modr8 api functions
#5
Let's just do it here - the amount of code we are talking about doesn't really warrant multiple issues.
#6
new patch that creates new public API functions:
- modr8_moderate_node($node) - place a node into moderation
- modr8_approve_node($node) - approve and publish a node
- modr8_delete_node($node) - delete a node and notify user
These functions are now used by modr8_form_submit() and the hook_node_operations() callbacks.
#7
no patch
#8
oops.
#9
seems like we are building all the values twice, since we still have:
foreach ($form_state['values'] as $nid => $values) {#10
Subscribe
#11
I see undefined $nid in query:
+function modr8_moderate_node($node) {+ db_query('UPDATE {node} SET moderate = %d WHERE nid = %d', 1, $nid);
+ return db_affected_rows();
+}
Further I would argue that there shouldn't be an 'approve moderated nodes' or a 'delete moderated nodes' because these steps can be implemented by exposing a filter on moderation plus bulk operations for moving into moderation queue and approving:
'select all nodes in moderation' + approve or delete.
#12
I just did this today, without seeing there was already an issue. I simply added the following, where node_mass_update() is the function in the node module that publish/unpublish, etc. uses.
Of course, doing it my way doesn't write to the moderation log. But in my case that isn't necessary, since we don't actually use the log messages.
<?php/**
* Implementation of hook_node_operations(). (added ead 8/7/09)
*/
function modr8_node_operations() {
$operations = array(
'moderate' => array(
'label' => t('Add to moderation queue'),
'callback' => 'node_mass_update',
'callback arguments' => array('updates' => array('moderate' => 1)),
),
'unmoderate' => array(
'label' => t('Remove from moderation'),
'callback' => 'node_mass_update',
'callback arguments' => array('updates' => array('moderate' => 0)),
),
);
return $operations;
}
?>
#13
There is no happen after i'm trying to do bulk opertions: aprove or remove from moderation queue.
Nodes staying there in moderation and have moderated status: No.
#14
I put EvanDonovan modr8_node_operations() function in the file /modules/node/node.admin.inc and the operations works for me in drupal 6.14.
Better the function would be implemented in the modr8 module. For me the feature is very important and very flexible to handle a lot of nodes.
Thanks btw for the snippet EvanDonovan :)