Thanks for modr8 it's gr8!!

We have the notifications module installed with Organic Groups and when there is content that has been put in the moderation queue no notification is sent, nothing wrong with this, perfect!! BUT when content is approved, it should go through the rest of the save process that it interrupted by going into moderation. Notifications being 1 example that I need, there may be others too.

Basically I'm not getting any notifications sent when I approve a node.

Might be as simple as something like...

in modr8_admin.inc function modr8_form_submit()

case 'approve':
 ...
 if (module_exists('notifications')) {
  [build $event array]
  notifications_event($event);
}

I was looking in the notifications_content.module at function notifications_content_nodeapi() to give me a clue what to do.

I'm going to investigate using an Action to do this, rather than delve any further into the code as it may be quicker to sort out, but I thought I'd flag it for the modr8 devs for investigation!

Happy to help out if I can.

Comments

TechnoBuddhist’s picture

quick update.

I think I know what the problem is, modr8_form_submit() manually sets the status of the node to 1(published). However I noticed that when I manually published a node in admin, the notifications event fired and my emails were sent, looking thru code it looks like all we need to do is make modr8_form_submit() do a node_save() and it's all taken care of....

coding and testing, expect a patch hopefully soon.

TechnoBuddhist’s picture

Category: feature » bug
Status: Active » Needs review
StatusFileSize
new815 bytes

That seems to do the job.

the problem was definitely because modr8 was manually setting the node.status field to 1. Core node module does this...

  node_invoke($node, $op);
  node_invoke_nodeapi($node, $op);

after saving node. I think that's the code that allows other modules to do their stuff, including Notifications.

Very simple fix...

function modr8_form_submit($form, &$form
         }
         $publish = '';
         if (user_access('administer nodes')) {
-          $publish = ', status = 1';
+          $node = node_load($nid);
+          $node->status = 1;
+          node_save($node);
         }
-        db_query('UPDATE {node} SET moderate = 0 '. $publish .' WHERE nid = %d', $nid);
+        db_query('UPDATE {node} SET moderate = 0 WHERE nid = %d', $nid);
         drupal_set_message(t('The %type with title %title has been approved.', array('%title' => $values['title'], '%type' => $values['type'])));
         cache_clear_all();
         modr8_log_action('approve', $nid, $values, $message);

I think I've made this mistake in one of my own bits of code so I'm off to check it now.

Obviously, please test this yourself before applying to a live site. Patch is against 6.x-1.1

pwolanin’s picture

StatusFileSize
new1.14 KB

Indeed - that's probably more correct, though a lot of extra code to execute.

However, if we are going this route, we can just take the query out all together and always use node_save().

TechnoBuddhist’s picture

@pwolanin

looks like you can drop the line;

 }
         $publish = '';   <-- drop this line !!?
+        $node = node_load($nid);

$publish doesn't seem to be used anywhere else in the function and it doesn't look like it's a global.

pwolanin’s picture

yes, I think that's dead code.

pwolanin’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
StatusFileSize
new1.1 KB
pwolanin’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Needs review » Patch (to be ported)

committed to 6.x

pwolanin’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.36 KB
pwolanin’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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