You are here

function simplenews_action_nodeapi in Simplenews 6.2

Implementation of hook_nodeapi().

Deletes actions related to newsletter issue when it is deleted (node deleted).

File

simplenews_action/simplenews_action.module, line 374
Provide actions for simplenews.

Code

function simplenews_action_nodeapi(&$node, $op, $teaser, $page) {

  // Operate only on node types set in 'simplenews_content_types' variable.
  if (!in_array($node->type, variable_get('simplenews_content_types', array(
    'simplenews',
  )))) {
    return;
  }
  switch ($op) {
    case 'delete':
      $result = db_query("SELECT aid, parameters FROM {actions} WHERE callback='simplenews_send_newsletter_action'");
      while ($action = db_fetch_object($result)) {
        $parameters = unserialize($action->parameters);
        if ($parameters['nid'] == $node->nid) {
          actions_delete($action->aid);
        }
      }
      break;
  }
}