Index: D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.module =================================================================== --- D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.module (revision 1671) +++ D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.module (working copy) @@ -421,7 +421,18 @@ db_query("UPDATE {linkchecker_links} SET code = %d, error = '%s', fail_count = fail_count+1, last_checked = %d WHERE lid = %d", $response->code, $response->error, time(), $link->lid); //watchdog('linkchecker', 'Unhandled link error %link has been found.', array('%link' => $link->url), WATCHDOG_ERROR, l(t('Broken links'), 'admin/reports/linkchecker')); } - } + } + + 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)); + module_invoke_all('linkchecker', $trigger_code, $node); + } + } } function linkchecker_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { @@ -1029,3 +1040,13 @@ function _linkchecker_comment_load($cid) { return db_fetch_array(db_query('SELECT * FROM {comments} WHERE cid = %d', $cid)); } + +/** + * Implementation of hook_init(). + */ +function linkchecker_init() { + $path = drupal_get_path('module', 'linkchecker'); + if (module_exists('trigger')) { + include_once $path .'/linkchecker.actions.inc'; + } +} Index: D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.actions.inc =================================================================== --- D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.actions.inc (revision 0) +++ D:/dev/eclipse/assist21/sites/all/modules/linkchecker/linkchecker.actions.inc (revision 0) @@ -0,0 +1,48 @@ + t('Content contains links with HTTP Code %code ', array('%code' => $code))); + } + $pseudohooks['failed'] = array( + 'runs when' => t('Content contains links with HTTP without error code (failed)'), + ); + + // $pseudohooks will not be set if no workflows have been assigned + // to node types. + if (isset($pseudohooks)) { + return array( + 'linkchecker' => array( + 'linkchecker' => $pseudohooks, + ), + ); + } +} + +/** + * Implementation of hook_trigger_name(). + * + */ +function linkchecker_linkchecker($op, $user) { + // 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, + 'user' => $user, + ); + actions_do(array_keys($aids), $user, $context); +}