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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

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.

pwolanin’s picture

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.

zroger’s picture

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

zroger’s picture

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

pwolanin’s picture

Status: Postponed » Needs work

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

zroger’s picture

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.

pwolanin’s picture

Status: Needs review » Active

no patch

zroger’s picture

Status: Active » Needs review
FileSize
6.08 KB

oops.

pwolanin’s picture

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

   foreach ($form_state['values'] as $nid => $values) {
ilfelice’s picture

Subscribe

alex_b’s picture

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.

EvanDonovan’s picture

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.

/**
 * 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;
} 
Daniel A. Beilinson’s picture

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.

k3vin’s picture

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

drewish’s picture

Status: Needs work » Needs review
FileSize
5.8 KB

re-rolled zroger's patch against the current version. fixed the issue that alex_b reported in #11.

some direction from the maintainer on this vs EvanDonovan's approach would be helpful.

EvanDonovan’s picture

@drewish: Your way is definitely more robust. I think it is the way that should be committed to the module; I just don't actually use modr8 anymore, only the {node}.moderate value.

pwolanin’s picture

Why is the patch doing a node load in cases where the operation to be performed only requires the NID?

CobraMP’s picture

looking at the latest patch I am gathering the the following php code will set the node into moderation

db_query('UPDATE {node} SET moderate = %d WHERE nid = %d', 1, $node->nid);

I am trying to make a rule where the action "execute custom php code" will set the node into moderation

*edit
I can verify that indeed that worked perfectly

mathankumarc’s picture

Version: 6.x-1.0 » 7.x-1.x-dev

New features are going into 7.x

mathankumarc’s picture

Committed public API functions to 7.x.

As pwolanin stated in #2 , node operations will try to perform moderate actions on the contents which are not in moderation queue.

Is there any better way to achieve this? We can alter the node filter form, but query cannot be altered.