You are here

function ip_backlog_nodes in IP address manager 7

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

Handle backlog of nodes.

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

File

./ip.module, line 349
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) {
    $result = db_query_range("SELECT wid, hostname, link" . " FROM {watchdog}" . " WHERE type = 'content'" . " AND message = :msg" . " AND wid < :backlog_nodes" . " ORDER BY wid DESC", 0, 20, array(
      ':msg' => '@type: added %title.',
      ':backlog_nodes' => $ip_backlog_nodes,
    ));
    $row_count = 0;
    foreach ($result as $row) {
      $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);
    }
  }
}