*** /usr/src/local/drupal/7/Modules/weblinks/weblinks.module	2011-02-25 03:07:04.000000000 +0100
--- weblinks.module	2013-01-06 00:22:25.000000000 +0100
***************
*** 40,55 ****
  }
  
  /**
!  * Implementation of hook_perm().
   */
! function weblinks_perm() {
    return module_invoke_all('weblinks_perm');
  }
  
  /**
!  * Implementation of hook_weblinks_perm().
   */
! function weblinks_weblinks_perm() {
    return array(
      'access web links',
      'create weblinks', 
--- 40,55 ----
  }
  
  /**
!  * Implementation of hook_permssion().
   */
! function weblinks_permission() {
    return module_invoke_all('weblinks_perm');
  }
  
  /**
!  * Implementation of hook_weblinks_permission().
   */
! function weblinks_weblinks_permission() {
    return array(
      'access web links',
      'create weblinks', 
***************
*** 73,79 ****
        'title_label' => t('Link Name'),
        'has_body' => TRUE,
        'body_label' => t('Link Description'),
!       'module' => 'weblinks',
      )
    );
  }
--- 73,79 ----
        'title_label' => t('Link Name'),
        'has_body' => TRUE,
        'body_label' => t('Link Description'),
!       'base' => 'weblinks',
      )
    );
  }
***************
*** 101,107 ****
   * This is a helper function for hook_init and hook_view.
   */
  function _weblinks_get_menu_title() {
!   return t(db_result(db_query("SELECT link_title FROM {menu_links} WHERE link_path = 'weblinks'")));
  }
  
  /**
--- 101,107 ----
   * This is a helper function for hook_init and hook_view.
   */
  function _weblinks_get_menu_title() {
!   return t(db_query("SELECT link_title FROM {menu_links} WHERE link_path = 'weblinks'")->fetchField());
  }
  
  /**
***************
*** 125,131 ****
      $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
      $form['body_field']['body']['#rows'] = 5;
      $form['body_field']['body']['#default_value'] = isset($node->body) ? $node->body : variable_get('weblinks_body_stub', '');
!     $form['body_field']['format'] = filter_form(isset($node->format) ? $node->format : variable_get('weblinks_format', FILTER_FORMAT_DEFAULT));
    }
  
    $form['url'] = array(
--- 125,131 ----
      $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
      $form['body_field']['body']['#rows'] = 5;
      $form['body_field']['body']['#default_value'] = isset($node->body) ? $node->body : variable_get('weblinks_body_stub', '');
!     $form['body_field']['format'] = filter_form(isset($node->format) ? $node->format : variable_get('weblinks_format', filter_fallback_format()));
    }
  
    $form['url'] = array(
***************
*** 189,195 ****
    $vocid = variable_get('weblinks_nav_vocabulary', '');
    if (empty($vocid) && function_exists('taxonomy_vocabulary_load')) {
      // Check to see if a weblinks vocabulary exists
!     $vocid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='weblinks'"));
      if ($vocid) {
        // We found a vocabulary, so make sure it is associated with our content.
        $vocabulary = (array)taxonomy_vocabulary_load($vocid);
--- 189,195 ----
    $vocid = variable_get('weblinks_nav_vocabulary', '');
    if (empty($vocid) && function_exists('taxonomy_vocabulary_load')) {
      // Check to see if a weblinks vocabulary exists
!     $vocid = db_query("SELECT vid FROM {vocabulary} WHERE module='weblinks'")->fetchField();
      if ($vocid) {
        // We found a vocabulary, so make sure it is associated with our content.
        $vocabulary = (array)taxonomy_vocabulary_load($vocid);
***************
*** 309,319 ****
  /**
   * Implementation of hook_load().
   */
! function weblinks_load($node) {
!   $obj = db_fetch_object(db_query('SELECT urlhash, url, last_status, last_checked, click_count, last_click, reciprocal FROM {weblinks} WHERE nid = %d AND vid=%d', $node->nid, $node->vid));
    // This makes formatting easier.
    $obj->none = NULL;
-   return $obj;
  }
  
  /**
--- 309,322 ----
  /**
   * Implementation of hook_load().
   */
! function weblinks_load($nodes) {
!   // note that $nodes is an array of object references, keyed by nid
!   $obj = db_select('weblinks', 'w')
!            ->condition('w.nid', array_keys($nodes), 'IN')
!            ->fields('w', array ('urlhash', 'url', 'last_status', 'last_checked', 'click_count', 'last_click', 'reciprocal'))
!            ->execute();
    // This makes formatting easier.
    $obj->none = NULL;
  }
  
  /**
***************
*** 736,742 ****
      $skip_empty = FALSE;
    }
    $show_desc = variable_get('weblinks_catdesc', TRUE);
!   $format = variable_get('weblinks_format', FILTER_FORMAT_DEFAULT);
    $max_depth = $admin ? 99999999 : variable_get('weblinks_maxfrontdepth', 1);
  
    $tree = array();
--- 739,745 ----
      $skip_empty = FALSE;
    }
    $show_desc = variable_get('weblinks_catdesc', TRUE);
!   $format = variable_get('weblinks_format', filter_fallback_format());
    $max_depth = $admin ? 99999999 : variable_get('weblinks_maxfrontdepth', 1);
  
    $tree = array();
***************
*** 758,764 ****
    }
    else {
      // Top level, so do we have unclassified links?
!     $unclassed_count = db_result(_weblinks_get_query(0, 'count'));
      if ($admin || $unclassed_count > 0) {
        // Add our dummy unclassified term object to the list.
        $tree[] = _weblinks_unclassed();
--- 761,767 ----
    }
    else {
      // Top level, so do we have unclassified links?
!     $unclassed_count = db_query(_weblinks_get_query(0, 'count'))->fetchField();
      if ($admin || $unclassed_count > 0) {
        // Add our dummy unclassified term object to the list.
        $tree[] = _weblinks_unclassed();
***************
*** 767,773 ****
      // Do we want a separate unpublished group?
      if (variable_get('weblinks_unpublished_title', t('Unpublished'))) {
        // Do we have unpublished nodes?
!       $unpub_count = db_result(_weblinks_get_query('unpublished', 'count'));
        if ($admin && $unpub_count > 0) {
          $tree[] = _weblinks_unpublished();
        }
--- 770,776 ----
      // Do we want a separate unpublished group?
      if (variable_get('weblinks_unpublished_title', t('Unpublished'))) {
        // Do we have unpublished nodes?
!       $unpub_count = db_query(_weblinks_get_query('unpublished', 'count'))->fetchField();
        if ($admin && $unpub_count > 0) {
          $tree[] = _weblinks_unpublished();
        }
***************
*** 791,797 ****
          $term->node_count = $unpub_count;
        }
        else {
!         $term->node_count = taxonomy_term_count_nodes($tid, 'weblinks');
        }
      }
      if ($skip_empty && $term->node_count == 0) {
--- 794,800 ----
          $term->node_count = $unpub_count;
        }
        else {
!         $term->node_count =  db_query("SELECT COUNT(ti.nid) FROM {taxonomy_index} as ti INNER JOIN {node} as n on n.nid=ti.nid WHERE ti.tid = :aid and n.type='weblink'", array(':aid' => $tid) )->fetchField();
        }
      }
      if ($skip_empty && $term->node_count == 0) {
***************
*** 963,969 ****
      $uid = $account->uid;
    }
    else {
!     $uid = db_result(db_query("SELECT uid FROM {users} WHERE name='%s'", $name));
    }
    return $uid;
  }
--- 966,972 ----
      $uid = $account->uid;
    }
    else {
!     $uid = db_query("SELECT uid FROM {users} WHERE name='%s'", $name)->fetchField();
    }
    return $uid;
  }
***************
*** 1004,1010 ****
    static $options, $empty_text, $filter_format, $linkdesc;
    if (!isset($empty_text)) {
      $empty_text = variable_get('weblinks_empty_text', NULL);
!     $filter_format = variable_get('weblinks_format', FILTER_FORMAT_DEFAULT);
      $linkdesc = variable_get('weblinks_linkdesc', 'teaser');
  
      $options = array();
--- 1007,1013 ----
    static $options, $empty_text, $filter_format, $linkdesc;
    if (!isset($empty_text)) {
      $empty_text = variable_get('weblinks_empty_text', NULL);
!     $filter_format = variable_get('weblinks_format', filter_fallback_format());
      $linkdesc = variable_get('weblinks_linkdesc', 'teaser');
  
      $options = array();
***************
*** 1169,1176 ****
    }
   
    $where = $wheres ? (' WHERE '. implode(' AND ', $wheres) .' ') : NULL;
!   $query = 'SELECT ' . $cols . ' FROM {node} n ' . $join . $where .' '. $order;
!   $query = db_rewrite_sql($query);
  // $term = taxonomy_get_term($tid);
  // drupal_set_message("$tid ($term->name), $sort: ".$query);
  
--- 1172,1179 ----
    }
   
    $where = $wheres ? (' WHERE '. implode(' AND ', $wheres) .' ') : NULL;
!   $query_wl = 'SELECT ' . $cols . ' FROM {node} n ' . $join . $where .' '. $order;
!   $query = db_query($query_wl, $tid);  // db_rewrite_sql
  // $term = taxonomy_get_term($tid);
  // drupal_set_message("$tid ($term->name), $sort: ".$query);
  
***************
*** 1262,1268 ****
      return NULL;
    }
    else {
!     return '<div class="weblinks-pagedesc">'. check_markup($pagedesc, variable_get('weblinks_format', FILTER_FORMAT_DEFAULT, FALSE)) .'</div>';
    }
  }
  
--- 1265,1271 ----
      return NULL;
    }
    else {
!     return '<div class="weblinks-pagedesc">'. check_markup($pagedesc, variable_get('weblinks_format', filter_fallback_format(), FALSE)) .'</div>';
    }
  }
  
