Commit 35f8eed1 authored by Gerhard Stegemann's avatar Gerhard Stegemann Committed by Nancy Wichmann
Browse files

Issue #870846 by GStegemann: Iteration #3

parent b6cde97c
Loading
Loading
Loading
Loading
+7 −0
Changes for CHANGELOG.txt: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -18,3 +18,10 @@ March 15, 2013
      weblinks_permission: changed to D7 style.
      All 6.x update hooks removed.
      CHANGELOG.txt file added.

March 18, 2013
--------------
      Web Links Checker: more database calls changed to D7 API syntax.
      - theme_weblinks_status adopted to D7 style.
      - All 6.x update hooks removed.
+4 −4
Changes for contribs/weblinks_checker/weblinks_checker.admin.inc: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ function weblinks_checker_settings() {
    '#default_value' => variable_get('weblinks_checker_limit', 5),
    );

    $count = db_result(db_query("SELECT COUNT(nid) FROM {node} WHERE type='weblinks'"));
    $count = db_query("SELECT COUNT(nid) FROM {node} WHERE type='weblinks'")->fetchField();
    $form['basic']['weblinks_checker_limit']['#description'] .= ' '. t('There are currently !count links defined.', array('!count' => $count));

  $form['basic']['weblinks_checker_show_status'] = array(
@@ -108,7 +108,7 @@ function weblinks_checker_settings() {
  $mins = 60;
  $hour = 3600;
  $day = 86400;
  $interval = array(0, 15 * $min, 30 * $min, 60 * $min, 2 * $hour, 3 * $hour, 4 * $hour, 6 * $hour, 12 * $hour, 1 * $day, 2 * $day, 3 * $day, 7 * $day, 14 * $day, 28 * $day);
  $interval = array(0, 15 * $mins, 30 * $mins, 60 * $mins, 2 * $hour, 3 * $hour, 4 * $hour, 6 * $hour, 12 * $hour, 1 * $day, 2 * $day, 3 * $day, 7 * $day, 14 * $day, 28 * $day);
  $form['basic']['weblinks_checker_interval'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc($interval, 'format_interval'),
@@ -253,8 +253,8 @@ function weblinks_checker_settings() {

  $result = db_query("SELECT uid, name FROM {users}");
  $rescue_users = array();
  while ($row = db_fetch_array($result)) {
    $rescue_users[$row['uid']] = $row['name'];
  foreach ($result as $row) {
    $rescue_users[$row->uid] = $row->name;
  }
  $rescue_users[0] = variable_get('anonymous', t('Anonymous'));

+8 −29
Changes for contribs/weblinks_checker/weblinks_checker.install: 8 added lines, 29 removed lines.
Original line number Diff line number Diff line
@@ -14,35 +14,6 @@ function weblinks_checker_enable() {
  db_query("UPDATE {system} SET weight=-2 WHERE type='module' AND name='weblinks_checker'");
}

/**
 * Implementation of hook_update_N().
 * Change module weight. http://drupal.org/node/530082
 */
function weblinks_checker_update_6000() {
  $ret = array();
  $ret[] = update_sql("UPDATE {system} SET weight=-2 WHERE type='module' AND name='weblinks_checker'");
  return $ret;
}

/**
 * Implementation of hook_update_N().
 * Fix url. http://drupal.org/node/575512
 */
function weblinks_checker_update_6001() {
  $ret = array();

  $result = db_query("SELECT nid, vid, url FROM {weblinks} GROUP BY nid ORDER BY nid ASC, vid DESC");
  while ($row = db_fetch_object($result)) {
    $new = rawurldecode(_weblinks_checker_fix_url($row->url));
    if ($new != $row->url) {
      $urlhash = md5($new);
      $ret[] = update_sql("UPDATE {weblinks} SET url='$new', urlhash='$urlhash' WHERE nid=$row->nid AND vid=$row->vid");
    }
  }

  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
@@ -67,3 +38,11 @@ function weblinks_checker_uninstall() {
  variable_del('weblinks_user_rescue');
  variable_del('weblinks_validate_check');
}

/**
 * Implements hook_update_last_removed().
 */
function weblinks_checker_update_last_removed() {
  return 6001;
}
+6 −6
Changes for contribs/weblinks_checker/weblinks_checker.js: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
(function ($) {

function weblinks_checker_handler(event) {
  if ($("input[@name=weblinks_checker_enabled]:checked").val() == 1) {
  if ($("input[name=weblinks_checker_enabled]:checked").val() == 1) {
    $("div.weblinks_checker_hide").show();
    $("#edit-weblinks-checker-enabled-wrapper label").css({fontWeight:"normal" });
  }
@@ -9,7 +10,7 @@ function weblinks_checker_handler(event) {
    $("#edit-weblinks-checker-enabled-wrapper label").css({fontWeight:"bold" });
  }

  if ($("input[@name=weblinks_checker_unpublish]:checked").val() == 0) {
  if ($("input[name=weblinks_checker_unpublish]:checked").val() == 0) {
    $("div.weblinks_checker_unpublish_hide").hide();
  }
  else {
@@ -18,13 +19,12 @@ function weblinks_checker_handler(event) {
}

// Run the javascript on page load.
if (Drupal.jsEnabled) {
  $(document).ready(function () {
    // On page load, determine the default settings.
    weblinks_checker_handler();

    // Bind the functions to click events.
    $("input[@name=weblinks_checker_enabled]").bind("click", weblinks_checker_handler);
    $("input[@name=weblinks_checker_unpublish]").bind("click", weblinks_checker_handler);
    $("input[name=weblinks_checker_enabled]").bind("click", weblinks_checker_handler);
    $("input[name=weblinks_checker_unpublish]").bind("click", weblinks_checker_handler);
  });
}
 No newline at end of file
})(jQuery);
+10 −9
Changes for contribs/weblinks_checker/weblinks_checker.module: 10 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
/**
 * @file
 * Checks validity of submitted links and handles user deletion.
 * Drupal 6 Version
 * Drupal 7 Version
 */

/**
@@ -41,7 +41,7 @@ function weblinks_checker_menu() {
function weblinks_checker_theme() {
  return array(
    'weblinks_status' => array(
      'arguments' => array('node'),
      'variables' => array('node' => NULL),
      ),
    );
}
@@ -49,12 +49,13 @@ function weblinks_checker_theme() {
/**
 *  Theme the link status.
 *
 *  @param $node
 *  @param $variables['node']
 *    Object containing the node information.
 *  @return
 *    String containing the formatted status or NULL if status is okay.
 */
function theme_weblinks_status($node) {
function theme_weblinks_status($variables) {
  $node = $variables['node'];
  $output = NULL;
  if (!function_exists('weblinks_error_codes')) {
    include(drupal_get_path('module', 'weblinks') .'/weblinks_errors.inc');
@@ -95,7 +96,7 @@ function theme_weblinks_status($node) {
 */
function weblinks_checker_weblinks_preprocess($node) {
  if (variable_get('weblinks_checker_show_status', TRUE)) {
    return array('link_status' => theme('weblinks_status', $node));
    return array('link_status' => theme('weblinks_status', array('node' => $node)));
  }
  else {
    return array();
@@ -134,7 +135,7 @@ function weblinks_checker_user_delete($account) {
 * Implementation of hook_form_alter().
 * Adds validation and submit to the node add/edit form.
 */
function weblinks_checker_form_alter(&$form, $form_state, $form_id) {
function weblinks_checker_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id) {
    if ($form['type']['#value'] == 'weblinks') {
      $form['#validate'][] = 'weblinks_checker_validate';
@@ -160,7 +161,7 @@ function weblinks_checker_validate($form, &$form_state) {
  if ($allow_dupes != 1) {
    // See if this url is already in the database.
    $urlhash = md5($new);
    $url_exists_nid = db_result(db_query("SELECT nid FROM {weblinks} l WHERE l.urlhash='%s' AND l.url='%s'", $urlhash, $new));
    $url_exists_nid = db_query("SELECT nid FROM {weblinks} l WHERE l.urlhash=':urlh' AND l.url=':url'", array(':urlh' => $urlhash, ':url' => $new))->fetchField();
    if ($url_exists_nid) {
      if ($form['#node']->nid != $url_exists_nid) {
        if (!$allow_dupes) {
@@ -175,7 +176,7 @@ function weblinks_checker_validate($form, &$form_state) {

  if (variable_get('weblinks_validate_check', FALSE)) {
    // Verify that the link is working.
    $response = drupal_http_request($new, array(), 'HEAD', NULL, 0);
    $response = drupal_http_request($new, array('max_redirects' => 0));
    $status = $response->code;

    $ignore = variable_get('weblinks_checker_ignore', array());
@@ -320,7 +321,7 @@ function weblinks_checker_cron() {
    $extra = NULL;

    // Hit the site. Don't follow redirects.
    $response = drupal_http_request($url, array(), 'HEAD', NULL, 0);
    $response = drupal_http_request($url, array('max_redirects' => 0));
    $status = $response->code;

    // Log site with errors.
Loading