Index: linkchecker.module
===================================================================
--- linkchecker.module	(revision 2511)
+++ linkchecker.module	(working copy)
@@ -48,6 +48,17 @@
  */
 define('LINKCHECKER_DEFAULT_FILTER_BLACKLIST', 'filter/1|insert_node/0|insert_view/0|smileys/0|links_weblink/0|weblinks_embed/0|weblinks_filter/0');
 
+
+/**
+ * Implementation of hook_init().
+ */
+function linkchecker_init() {
+  $path = drupal_get_path('module', 'linkchecker');
+  if (module_exists('trigger')) {
+    include_once $path . '/includes/linkchecker.trigger.inc';
+  }
+}
+
 /**
  * Implementation of hook_perm().
  */
@@ -60,6 +71,10 @@
  */
 function linkchecker_help($path, $arg) {
   switch ($path) {
+    case 'admin/build/trigger/linkchecker':
+      $output = '<p>'. t('Triggers are system events, such as when new content is added or when a user logs in. Trigger module combines these triggers with actions (functional tasks), such as unpublishing content or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure additional actions.', array('@url' => url('admin/settings/actions'))) .'</p>';
+      $output .= '<p>'. t('Below you can assign actions to run when certain link checker-related triggers happen. For example, you could unpublish a node or put it in moderation queue if a link check failed.') .'</p>';
+      return $output;
     case 'admin/help#linkchecker':
       return '<p>' . t('This module provides an aid to finding broken links on your site. It periodically checks contents of all public nodes, tries to find any html links and check for their validity. It reports broken links through the admin interface. For more information about status codes see <a href="@rfc">Status Code Definitions</a>.', array('@rfc' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html')) . '</p>';
   }
@@ -335,6 +350,20 @@
         //watchdog('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker'));
       }
   }
+  
+  //Provide triggers on various HTTP status codes
+  if (module_exists('trigger')) {
+    //Fire Trigger on all nodes, that contain the link.
+    $res = db_query("SELECT * FROM {linkchecker_nodes} WHERE lid = %d", $link->lid);
+    $trigger_code = ($response->code >= 200 && $response->code < 600) ? $response->code : 'failed';
+    $nid = array();
+    while ($row = db_fetch_object($res)) {
+      $node = node_load(array('nid' => $row->nid));
+      //calls hook_linkchecker proving the link and node object
+      module_invoke_all('linkchecker', $trigger_code, $link, $node);
+    }
+  }
+
 }
 
 function linkchecker_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
Index: includes/linkchecker.trigger.inc
===================================================================
--- includes/linkchecker.trigger.inc	(revision 0)
+++ includes/linkchecker.trigger.inc	(revision 0)
@@ -0,0 +1,87 @@
+<?php
+// $Id: $
+
+/**
+ * @file
+ * Hooks for linkchecker actions and triggers.
+ */
+
+/**
+ * Implementation of hook_action_info(). Info hook for all linkchecker actions.
+ */
+function linkchecker_action_info() {
+  return array(
+    'linkchecker_change_to_http_get' => array(
+      'type' => 'linkchecker',
+      'description' => t('Process HTTP GET method if HEAD request fails.'),
+      'configurable' => FALSE,
+      'hooks' => array(
+        'linkchecker' => array(300, 301, 302, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 500, 501, 502),
+      ),
+    ),
+  );
+}
+
+/**
+ * Processes a HTTP GET request if the HEAD request fails. This action is used for websites
+ * which do not correctly answer to HEAD requests.
+ * @param $link
+ *   link object
+ * @param $context
+ *   array of context data
+ */
+function linkchecker_change_to_http_get($link, $context = array()) {
+  //only request URLs which have been HEAD requests before, avoids recursion
+  if ($link->method != 'GET') {
+  	$link->method = 'GET'; //change to GET request
+    $useragent = variable_get('linkchecker_check_useragent', 'Drupal (+http://drupal.org/)');  
+    //conduct request
+    $response = drupal_http_request($link->url, array('User-Agent' => 'User-Agent: ' . $useragent), $link->method, NULL, 1);
+    //run status handling once more
+    _linkchecker_status_handling($link, $response);
+    if ($response->code == 200) { //update link method in db table if response was successfull
+      db_query("UPDATE {linkchecker_links} SET method = '%s' WHERE lid = %d", $link->method, $link->lid);
+    }
+  }
+}
+
+/**
+ * Implementation of hook_hook_info(). 
+ */
+function linkchecker_hook_info() {
+  foreach (array(300, 301, 302, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 500, 501, 502) as $code) {
+    $triggers[$code] = array(
+      'runs when' => t('Content contains links with HTTP status code @code', array('@code' => $code))
+    );
+  }
+  $triggers['failed'] = array(
+    'runs when' => t('Content contains links without HTTP status codes (failed)'),
+  );
+
+  // $triggers will not be set if no workflows have been assigned to node types.
+  if (isset($triggers)) {
+    return array(
+      'linkchecker' => array(
+        'linkchecker' => $triggers,
+      ),
+    );
+  }
+}
+
+/**
+ * Implementation of hook_trigger_name(). HTTP status code trigger hooks.
+ */
+function linkchecker_linkchecker($op, $link, $node) {
+  // We support a subset of operations.
+  if (!($op == 'failed' || ($op >= 300 && $op < 600) )) {
+    return;
+  }
+  $aids = _trigger_get_hook_aids('linkchecker', $op);
+  $context = array(
+    'hook' => 'linkchecker',
+    'op' => $op,
+    'node' => $node,
+  );
+  //run action manually
+  actions_do(array_keys($aids), $link, $context);
+}
