You are here

function lc_PushTask in Link checker 5

1 call to lc_PushTask()
linkchecker_cron in ./linkchecker.module
Implementation of hook_cron() Rebuild the table if necessary.

File

./linkchecker.module, line 355
This module periodically check html links referenced by drupal nodes Developed and maintained by Marek Tichy, marek@ecn.cz

Code

function lc_PushTask($task) {
  $res = db_query("SELECT max( taskid ) AS maxid FROM `linkchecker_tasks`");
  $foo = db_fetch_array($res);
  $newid = $foo["maxid"] ? $foo["maxid"] + 1 : 1;

  // Have we seen and processed this node ? If yes, delete it first
  $res = db_query("SELECT * FROM `linkchecker_tasks` where `status` = 999 AND `nodeid` = {$task['nodeid']}");
  $foo = db_fetch_array($res);
  $taskid = $foo["taskid"];
  if ($taskid) {
    lc_RemoveTask(array(
      'taskid' => $taskid,
    ));
    d_("Removing task {$taskid} and it's reports since node {$task['nodeid']} has been updated");
  }

  // Push task into a queue for (re)checking
  db_query("INSERT INTO `linkchecker_tasks` ( `taskid` , `nodeid` , `status` , `update` )\n                VALUES ({$newid}, {$task['nodeid']}, '0', NOW( ));");
}