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.

AttachmentSize
modr8.nodeops.patch2.56 KB

#1

pwolanin - February 3, 2009 - 23:12
Status:needs review» needs work

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

pwolanin - February 3, 2009 - 23:31

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

Roger López - February 3, 2009 - 23:31

I definitely want to refactor, just didn't want to over-scope this issue.

#4

Roger López - February 3, 2009 - 23:37
Status:needs work» postponed

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

pwolanin - February 3, 2009 - 23:39
Status:postponed» needs work

Let's just do it here - the amount of code we are talking about doesn't really warrant multiple issues.

#6

Roger López - February 4, 2009 - 01:45
Status:needs work» needs review

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

pwolanin - February 4, 2009 - 13:17
Status:needs review» active

no patch

#8

Roger López - February 4, 2009 - 15:36
Status:active» needs review

oops.

AttachmentSize
modr8.nodeops.patch 6.08 KB

#9

pwolanin - February 6, 2009 - 04:22

seems like we are building all the values twice, since we still have:

   foreach ($form_state['values'] as $nid => $values) {

#10

jorgemare - February 13, 2009 - 18:50

Subscribe

#11

alex_b - July 1, 2009 - 20:13
Status:needs review» needs work

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

EvanDonovan - August 7, 2009 - 20:17

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

Daniel A. Beilinson - August 8, 2009 - 09:02

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

bit7 - October 10, 2009 - 22:05

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 :)

 
 

Drupal is a registered trademark of Dries Buytaert.