You are here

function ip_backlog_nodes in IP address manager 6

Same name and namespace in other branches
  1. 8.2 ip.module \ip_backlog_nodes()
  2. 7 ip.module \ip_backlog_nodes()

Handle backlog of nodes.

1 call to ip_backlog_nodes()
ip_cron in ./ip.module
Implementation of hook_cron().
2 string references to 'ip_backlog_nodes'
ip_cron in ./ip.module
Implementation of hook_cron().
ip_uninstall in ./ip.install
Implementation of hook_uninstall().

File

./ip.module, line 305
IP address manager module.

Code

function ip_backlog_nodes() {

  // This variable tracks the last wid.
  $ip_backlog_nodes = variable_get('ip_backlog_nodes', PHP_INT_MAX);
  if ($ip_backlog_nodes) {
    $content_message = '@type: added %title.';
    $result = db_query_range("SELECT wid, hostname, link" . " FROM {watchdog}" . " WHERE type = 'content'" . " AND message = '%s'" . " AND wid < " . $ip_backlog_nodes . " ORDER BY wid DESC", array(
      $content_message,
    ), 0, 20);
    $row_count = 0;
    while ($row = db_fetch_object($result)) {
      $nid = str_replace(array(
        '<a href="' . base_path() . 'node/',
        '">view</a>',
      ), array(
        '',
        '',
      ), $row->link);

      // Test the node.
      $node = node_load($nid);
      if (!empty($node)) {
        ip_posts_insert('node', $nid, $row->hostname);
      }
      $row_count++;
      variable_set('ip_backlog_nodes', $row->wid);
    }
    if (!$row_count) {

      // Mark as finished.
      variable_set('ip_backlog_nodes', 0);
    }
  }
}