When module create a new newsletter edition it could be usufull use $node->simplenews['send'] instead $node->send.

It could be allow others modules interact with the nodeapi simplenews working.

  // Trigger it for sending.
  $node->simplenews['send'] = 1;

Comments

sgabe’s picture

Status: Active » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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

pheudo’s picture

Status: Closed (fixed) » Needs work

It's only a proposal.

Becouse when u save a node with "simplenews['send'] = SIMPLENEWS_COMMAND_SEND_NOW" simplenews nodeapi implementation send automatically during the node_save.

But it sends newsletter multiple times if user that run cron is able to send newsletter... Like matters with Poormanscron...

struesda’s picture

Moving the setting of the send property down to just before the update api call seems to work (that way, the initial send does not pick up the node for sending - only the 2nd update call picks it up.)

   // Prepare the correct status for Simplenews to pickup.
    db_query("UPDATE {simplenews_newsletters} SET s_status=1 WHERE nid=%d", $node->nid);
    // Trigger it for sending.
    $node->simplenews['send'] = SIMPLENEWS_COMMAND_SEND_NOW;
    // We have to call simplenews_nodeapi() directly as we wont have a new node ID before we save.
    simplenews_nodeapi($node, 'update', $teaser = NULL, $page = NULL);
    return $node->nid;

I also went ahead and used the proper constant so it is easier to tell what it is doing.

dgtlmoon’s picture

Status: Needs work » Needs review

Should be resolved in 1.x and 2.x branches

joachim’s picture

Status: Needs review » Fixed

Closing accordingly.

Status: Fixed » Closed (fixed)

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