You are here

function views_atom_rules_action_send_tombstone in Views Atom 7

Rule implementation callback for sending a tombstone for a specific node.

Parameters

$data: A wrapped Drupal entity

$views_diplay: A concatenation of views name and display id

1 string reference to 'views_atom_rules_action_send_tombstone'
views_atom_rules_action_info in ./views_atom.rules.inc
Implements hook_rules_action_info().

File

./views_atom.rules.inc, line 76

Code

function views_atom_rules_action_send_tombstone($data, $topic_url, $settings, RulesState $state, RulesPlugin $element) {

  // @todo, ideal this rules_action would go in push_hub or a more generic atom module.
  // That generic module might follow this discussion: http://groups.drupal.org/node/197583
  if (module_exists('push_hub')) {
    $nid = $data
      ->getIdentifier();

    // Note the confusing alias flag. TRUE means "this has already been aliased,
    // which is the way to prevent url from trying to find an alias.
    $topic_url = url($topic_url, array(
      'absolute' => TRUE,
      'alias' => TRUE,
    ));
    $updated = date('c', REQUEST_TIME);
    $items = array(
      array(
        // Note the confusing alias flag. TRUE means "this has already been aliased,
        // which is the way to prevent url from trying to find an alias.
        'guid' => url('node/' . $nid, array(
          'absolute' => TRUE,
          'alias' => TRUE,
        )),
        'when' => $updated,
      ),
    );
    $tombstone_array = array(
      'title' => t('Tombstone'),
      'use_push' => TRUE,
      'hub_url' => url('pubsubhubbub/endpoint', array(
        'absolute' => TRUE,
      )),
      'feed_url' => $topic_url,
      'updated' => $updated,
      'show_updated_comment' => FALSE,
      'items' => $items,
    );
    $tombstone = theme('views_atom_tombstone', $tombstone_array);

    // @todo, make send_mode configurable.
    push_hub_notify($topic_url, $tombstone, PUSH_HUB_IMMEDIATE | PUSH_HUB_CRON);
  }
}