You are here

function linkchecker_user_report_page in Link checker 6.2

Same name and namespace in other branches
  1. 7 linkchecker.pages.inc \linkchecker_user_report_page()

Menu callback for author specific reporting.

1 string reference to 'linkchecker_user_report_page'
linkchecker_menu in ./linkchecker.module
Implementation of hook_menu().

File

includes/linkchecker.pages.inc, line 39
User page callbacks for the linkchecker module.

Code

function linkchecker_user_report_page($account) {
  drupal_set_title(check_plain($account->name));
  $ignore_response_codes = preg_split('/(\\r\\n?|\\n)/', variable_get('linkchecker_ignore_response_codes', "200\n206\n302\n304\n401\n403"));

  // Search for broken links in nodes and comments of the current user.
  if (module_exists('comment') && variable_get('linkchecker_scan_comments', 0)) {
    $links_report_sql = "SELECT ll.*\n      FROM {linkchecker_links} ll\n      INNER JOIN (\n        SELECT lid FROM (\n          SELECT DISTINCT ll.lid\n          FROM {node} n\n          INNER JOIN {node_revisions} r ON r.vid = n.vid\n          INNER JOIN {linkchecker_nodes} ln ON ln.nid = n.nid\n          INNER JOIN {linkchecker_links} ll ON ll.lid = ln.lid AND ll.last_checked <> %d AND ll.status = %d AND ll.code NOT IN (" . db_placeholders($ignore_response_codes, 'int') . ")\n          WHERE n.uid = %d OR r.uid = %d\n          UNION\n          SELECT DISTINCT ll.lid\n          FROM {comments} c\n          INNER JOIN {linkchecker_comments} lc ON lc.cid = c.cid\n          INNER JOIN {linkchecker_links} ll ON ll.lid = lc.lid AND ll.last_checked <> %d AND ll.status = %d AND ll.code NOT IN (" . db_placeholders($ignore_response_codes, 'int') . ")\n          WHERE c.uid = %d\n        ) q1\n      ) q2 ON q2.lid = ll.lid";

    // Build the array variable with all parameters for the pager_query with comment module enabled.
    $links_report_parameters = array_merge(array(
      0,
      1,
    ), $ignore_response_codes, array(
      $account->uid,
      $account->uid,
      0,
      1,
    ), $ignore_response_codes, array(
      $account->uid,
    ));
  }
  else {

    // Search for broken links in nodes of the current user.
    $links_report_sql = "SELECT ll.*\n      FROM {linkchecker_links} ll\n      INNER JOIN (\n        SELECT lid FROM (\n          SELECT DISTINCT ll.lid\n          FROM {node} n\n          INNER JOIN {node_revisions} r ON r.vid = n.vid\n          INNER JOIN {linkchecker_nodes} ln ON ln.nid = n.nid\n          INNER JOIN {linkchecker_links} ll ON ll.lid = ln.lid AND ll.last_checked <> %d AND ll.status = %d AND ll.code NOT IN (" . db_placeholders($ignore_response_codes, 'int') . ")\n          WHERE n.uid = %d OR r.uid = %d\n        ) q1\n      ) q2 ON q2.lid = ll.lid";

    // Build the array variable with all parameters for the pager_query with comment module disabled.
    $links_report_parameters = array_merge(array(
      0,
      1,
    ), $ignore_response_codes, array(
      $account->uid,
      $account->uid,
    ));
  }
  return _linkchecker_report_page($links_report_sql, $links_report_parameters, $account);
}