Index: faq.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/Attic/faq.install,v
retrieving revision 1.1.4.17.2.1
diff -u -r1.1.4.17.2.1 faq.install
--- faq.install 28 Jan 2008 10:47:12 -0000 1.1.4.17.2.1
+++ faq.install 29 Jan 2008 12:22:17 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: faq.install,v 1.1.4.17.2.1 2008/01/28 10:47:12 snpower Exp $
+// $Id: faq.install,v 1.1.4.17 2007/09/24 12:46:16 snpower Exp $

 /**
  * Implementation of hook_install()
@@ -9,25 +9,37 @@
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-      $created = db_query("CREATE TABLE IF NOT EXISTS {faq_weights} (
+      $created1 = db_query("CREATE TABLE IF NOT EXISTS {faq_weights} (
         tid INT(10) UNSIGNED NOT NULL DEFAULT '0',
-        nid INT(10) NOT NULL DEFAULT '0',
+        nid INT(10) UNSIGNED NOT NULL DEFAULT '0',
         weight TINYINT(4) NOT NULL DEFAULT '0',
         PRIMARY KEY (tid, nid)
       ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+      $created2 = db_query("CREATE TABLE IF NOT EXISTS {faq_questions} (
+        nid INT(10) UNSIGNED NOT NULL DEFAULT '0',
+        vid INT(10) UNSIGNED NOT NULL DEFAULT '0',
+        question text NOT NULL,
+        PRIMARY KEY (nid, vid)
+      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
       break;

     case 'pgsql':
-      $created = db_query('CREATE TABLE {faq_weights} (
+      $created1 = db_query('CREATE TABLE {faq_weights} (
         tid integer NOT NULL DEFAULT 0,
         nid integer NOT NULL DEFAULT 0,
         weight smallint NOT NULL DEFAULT 0,
         PRIMARY KEY (tid, nid)
       );');
+      $created2 = db_query('CREATE TABLE {faq_questions} (
+        nid integer NOT NULL DEFAULT 0,
+        vid integer NOT NULL DEFAULT 0,
+        question text NOT NULL,
+        PRIMARY KEY (nid, vid)
+      );');
       break;
   }

-  if (!$created) {
+  if (!$created1 || !$created2) {
     drupal_set_message(t('Table installation for the FAQ module was unsuccessful.'), 'error');
   }
 }
@@ -66,10 +78,12 @@
     case 'mysql':
     case 'mysqli':
       $deleted = db_query("DROP TABLE IF EXISTS {faq_weights}");
+      $deleted = db_query("DROP TABLE IF EXISTS {faq_questions}");
       break;

     case 'pgsql':
       $deleted = db_query('DROP TABLE {faq_weights}');
+      $deleted = db_query('DROP TABLE {faq_questions}');
       break;
   }

@@ -90,7 +104,7 @@
     case 'mysqli':
       $ret[] = update_sql("CREATE TABLE IF NOT EXISTS {faq_weights} (
         tid INT(10) UNSIGNED NOT NULL DEFAULT '0',
-        nid INT(10) NOT NULL DEFAULT '0',
+        nid INT(10) UNSIGNED NOT NULL DEFAULT '0',
         weight TINYINT(4) NOT NULL DEFAULT '0',
         PRIMARY KEY (tid, nid)
       ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
@@ -109,4 +123,31 @@
   return $ret;
 }

+function faq_update_2() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("CREATE TABLE IF NOT EXISTS {faq_questions} (
+        nid INT(10) UNSIGNED NOT NULL DEFAULT '0',
+        vid INT(10) UNSIGNED NOT NULL DEFAULT '0',
+        question text NOT NULL,
+        PRIMARY KEY (nid, vid)
+      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+      break;
+
+    case 'pgsql':
+      $ret[] = update_sql('CREATE TABLE {faq_questions} (
+        nid integer NOT NULL DEFAULT 0,
+        vid integer NOT NULL DEFAULT 0,
+        question text NOT NULL,
+        PRIMARY KEY (nid, vid)
+      );');
+      break;
+  }
+
+  $result = db_query("INSERT INTO {faq_questions} (nid, vid, question) SELECT r.nid, r.vid, r.title FROM {node_revisions} r, {node} n WHERE n.nid = r.nid AND n.type = 'faq'");
+
+  return $ret;
+}
+

Index: faq.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.module,v
retrieving revision 1.1.4.63.2.10
diff -u -r1.1.4.63.2.10 faq.module
--- faq.module 28 Jan 2008 16:33:43 -0000 1.1.4.63.2.10
+++ faq.module 29 Jan 2008 12:22:17 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: faq.module,v 1.1.4.63.2.10 2008/01/28 16:33:43 snpower Exp $
+// $Id: faq.module,v 1.1.4.63.2.8 2007/12/17 14:05:51 snpower Exp $

 /**
  * Display help and module information
@@ -165,14 +165,16 @@
 }

 function faq_form(&$node) {
+  $type = node_get_types('type', $node);

   // question
   $form['title'] = array(
-    '#type' => 'textfield',
+    '#type' => 'textarea',
     '#title' => t('Question'),
-    '#default_value' => $node->title,
+    '#default_value' => empty($node->question) ? $node->title : $node->question,
     '#required' => TRUE,
-    '#weight' => 0,
+    '#weight' => -1,
+    '#rows' => 3,
     '#description' => t('Question to be answered'),
   );

@@ -182,6 +184,7 @@
     '#title' => t('Answer'),
     '#default_value' => $node->body,
     '#rows' => 20,
+    '#weight' => 0,
     '#required' => TRUE,
     '#description' => t('This is that answer to the question.  It will be filtered according to the input format.'),
   );
@@ -190,8 +193,36 @@
   return $form;
 }

+function faq_insert($node) {
+  $ret = db_query("INSERT INTO {faq_questions} (nid, vid, question) VALUES(%d, %d, '%s')", $node->nid, $node->vid, $node->title);
+}
+
+function faq_update($node) {
+  if ($node->revision) {
+    faq_insert($node);
+  }
+  else {
+    db_query("UPDATE {faq_questions} SET question = '%s' WHERE nid = %d AND vid = %d", $node->title, $node->nid, $node->vid);
+  }
+}
+
 function faq_delete(&$node) {
   db_query('DELETE FROM {faq_weights} WHERE nid = %d', $node->nid);
+  db_query('DELETE FROM {faq_questions} WHERE nid = %d', $node->nid);
+}
+
+function faq_load($node) {
+  $result = db_fetch_object(db_query('SELECT question FROM {faq_questions} WHERE nid = %d', $node->nid));
+  $node->question = $result->question;
+  $node->title = $node->question;
+}
+
+function faq_nodeapi(&$node, $op, $teaser, $page) {
+  switch ($op) {
+    case 'delete revision':
+      db_query('DELETE FROM {faq_questions} WHERE nid = %d AND vid = %d', $node->nid, $node->vid);
+      break;
+  }
 }

 function faq_view($node, $teaser = FALSE, $page = FALSE) {
@@ -356,7 +387,7 @@
   drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');

   // set up a hidden variable
-  $form['faq_display'] = array('#type' => 'value',
+  $form['faq_display'] = array('#type' => 'hidden',
     '#value' => variable_get('faq_display', 'questions_top'),
   );

@@ -487,13 +518,14 @@
       $date_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", "n", "nid"), $category);
     }
     else {
-      $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND tn.tid = %d ORDER BY weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $category, $category);
-      $date_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND tn.tid = %d ORDER BY n.sticky DESC, n.created DESC", "n", "nid"), $category, $category);
+      $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND tn.tid = %d ORDER BY weight ASC, n.sticky DESC, n.created DESC", "n", "nid"), $category, $category);
+      $date_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND tn.tid = %d ORDER BY n.sticky DESC, n.created DESC", "n", "nid"), $category, $category);
     }


     while ($node = db_fetch_object($result)) {
-      $options[$node->nid] = $node->title;
+      $title = (strlen($node->title) <= 64) ? $node->title : substr_replace($node->title, "...", 63);
+      $options[$node->nid] = $title;
       $order .= "$node->nid,";
     }
     $order = rtrim($order, ",");
@@ -629,7 +661,7 @@

   // non-categorized questions and answers
   if (!$use_categories) {
-    $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"));
+    $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"));

     switch ($faq_display) {
       case 'questions_top':
@@ -654,7 +686,7 @@

   // categorize questions
   else {
-    $category_display=variable_get('faq_category_display', 'categories_inline');
+    $category_display = variable_get('faq_category_display', 'categories_inline');
     $hide_sub_categories = variable_get('faq_hide_sub_categories', FALSE);
     $output .= "<br />";

@@ -739,7 +771,7 @@

 function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {

-  $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $term->tid);
+  $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $term->tid);

   $display_vars['display_header'] = $display_header;
   $display_vars['faq_display'] = $faq_display;
@@ -820,14 +852,14 @@

   // loop through results
   $questions = array();
-  while ($node = db_fetch_object($result)) {
-    $node_obj = node_load($node->nid);
-    if (node_access("view", $node_obj)) {
+  while ($row = db_fetch_object($result)) {
+    $node = node_load($row->nid);
+    if (node_access("view", $node)) {
       $anchor = "n". $node->nid;

-      $questions[] = l($node->title, 'faq', NULL, NULL, $anchor);
+      $questions[] = l($node->question, 'faq', NULL, NULL, $anchor);

-      $answers .= '<div class="faq_question">'. l($node->title,
+      $answers .= '<div class="faq_question">'. l($node->question,
       "node/$node->nid", array("name" => "$anchor")) ."</div>\n";

       // should we display teaser or full text
@@ -982,7 +1014,7 @@

     foreach ($list as $tid => $sub_term) {
       if (taxonomy_term_count_nodes($sub_term->tid, 'faq')) {
-        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
+        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
         $display_vars['display_header'] = 1;
         $sub_cats .= '<div class="faq_category_indent">';
         $sub_cat_data = theme('category_questions_top', $sub_result, $display_vars, $sub_term, $class);
@@ -997,14 +1029,14 @@

   if (db_num_rows($result)) {
     $questions = array();
-    while ($node = db_fetch_object($result)) {
-      $node = node_load($node->nid);
+    while ($row = db_fetch_object($result)) {
+      $node = node_load($row->nid);
       if (node_access("view", $node)) {
         $anchor = $term->tid ."n". $node->nid;

-        $questions[] = l($node->title, $this_page, NULL, NULL, $anchor);
+        $questions[] = l($node->question, $this_page, NULL, NULL, $anchor);

-        $answers .= '<div class="faq_question">'. l($node->title, "node/$node->nid", array("name" => "$anchor")) ."</div>\n";
+        $answers .= '<div class="faq_question">'. l($node->question, "node/$node->nid", array("name" => "$anchor")) ."</div>\n";

         // should we display teaser or full text
         if ($display_vars['use_teaser']) {
@@ -1102,11 +1134,11 @@
   drupal_add_js(drupal_get_path('module', 'faq') .'/faq.js', 'module');

   $output = "<div>\n";
-  while ($node = db_fetch_object($result)) {
-    $node_obj = node_load($node->nid);
-    if (node_access("view", $node_obj)) {
+  while ($row = db_fetch_object($result)) {
+    $node = node_load($row->nid);
+    if (node_access("view", $node)) {
       $output .= '<div class="faq_question faq_dt_hide_answer">';
-      $output .= l($node->title, "node/$node->nid") ."</div>\n";
+      $output .= l($node->question, "node/$node->nid") ."</div>\n";

       // should we display teaser or full text
       if ($display_vars['use_teaser']) {
@@ -1243,7 +1275,7 @@

     foreach ($list as $tid => $sub_term) {
       if (taxonomy_term_count_nodes($sub_term->tid, 'faq')) {
-        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
+        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
         $display_vars['display_header'] = 1;
         $sub_cats .= '<div class="faq_category_indent">';
         $sub_cats .= theme('category_hide_answer', $sub_result, $display_vars, $sub_term, $class);
@@ -1257,11 +1289,11 @@
   if (db_num_rows($result)) {
     $output .= '<div class="faq_dl_hide_answer">'."\n";

-    while ($node = db_fetch_object($result)) {
-      $node = node_load($node->nid);
+    while ($row = db_fetch_object($result)) {
+      $node = node_load($row->nid);
       if (node_access("view", $node)) {
         $output .= '<div class="faq_question faq_dt_hide_answer">';
-        $output .= l($node->title, "node/$node->nid") ."</div>\n";
+        $output .= l($node->question, "node/$node->nid") ."</div>\n";
         // should we display teaser or full text
         if ($display_vars['use_teaser']) {
           $more_link = '';
@@ -1310,11 +1342,11 @@
   }

   $output = "<div>\n";
-  while ($node = db_fetch_object($result)) {
-    $node_obj = node_load($node->nid);
-    if (node_access("view", $node_obj)) {
+  while ($row = db_fetch_object($result)) {
+    $node = node_load($row->nid);
+    if (node_access("view", $node)) {
       $output .= '<div class="faq_question">';
-      $output .= l($que_label . $node->title, "node/$node->nid") ."</div>\n";
+      $output .= l($que_label . $node->question, "node/$node->nid") ."</div>\n";

       // should we display teaser or full text
       if ($display_vars['use_teaser']) {
@@ -1466,7 +1498,7 @@

     foreach ($list as $tid => $sub_term) {
       if (taxonomy_term_count_nodes($sub_term->tid, 'faq')) {
-        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
+        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
         $display_vars['display_header'] = 1;
         $sub_cats .= '<div class="faq_category_indent">';
         $sub_cats .= theme('category_questions_inline', $sub_result, $display_vars, $sub_term, $class);
@@ -1480,11 +1512,11 @@
   if (db_num_rows($result)) {
     $output .= "<div>\n";

-    while ($node = db_fetch_object($result)) {
-      $node = node_load($node->nid);
+    while ($row = db_fetch_object($result)) {
+      $node = node_load($row->nid);
       if (node_access("view", $node)) {
         $output .= '<div class="faq_question">';
-        $output .= l($que_label . $node->title, "node/$node->nid") ."</div>\n";
+        $output .= l($que_label . $node->question, "node/$node->nid") ."</div>\n";

         // should we display teaser or full text
         if ($display_vars['use_teaser']) {
@@ -1519,10 +1551,10 @@

 function theme_new_page($result) {
   $items = array();
-  while ($node = db_fetch_object($result)) {
-    $node_obj = node_load($node->nid);
-    if (node_access("view", $node_obj)) {
-      $items[] = l($node->title, "node/$node->nid");
+  while ($row = db_fetch_object($result)) {
+    $node = node_load($row->nid);
+    if (node_access("view", $node)) {
+      $items[] = l($node->question, "node/$node->nid");
     }
   }
   $list_style = variable_get('faq_question_listing', 'ul');
@@ -1638,7 +1670,7 @@

     foreach ($list as $tid => $sub_term) {
       if (taxonomy_term_count_nodes($sub_term->tid, 'faq')) {
-        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
+        $sub_result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $sub_term->tid);
         $display_vars['display_header'] = 1;
         $sub_cats .= '<div class="faq_category_indent">';
         $sub_cats .= theme('category_new_page', $sub_result, $display_vars, $sub_term, $class);
@@ -1651,10 +1683,10 @@

   if (db_num_rows($result)) {
     $items = array();
-    while ($node = db_fetch_object($result)) {
-      $node = node_load($node->nid);
+    while ($row = db_fetch_object($result)) {
+      $node = node_load($row->nid);
       if (node_access("view", $node)) {
-        $items[] = l($node->title, "node/$node->nid");
+        $items[] = l($node->question, "node/$node->nid");
       }
       else {
         $count--;
@@ -1771,14 +1803,14 @@

 function theme_faq_highlights($num = 5) {

-  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid WHERE n.type='faq' AND n.status = 1 ORDER BY n.created DESC", "n", "nid"), 0, $num);
+  $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY n.created DESC", "n", "nid"), 0, $num);

   $items = array();
-  while ($node = db_fetch_object($result)) {
-    $node = node_load(array('nid' => $node->nid));
+  while ($row = db_fetch_object($result)) {
+    $node = node_load(array('nid' => $row->nid));
     $node = node_prepare($node);
     if (node_access("view", $node)) {
-      $items[] = l($node->title, 'node/'. $node->nid);
+      $items[] = l($node->question, 'node/'. $node->nid);
     }
   }
   $list_style = variable_get('faq_question_listing', 'ul');
@@ -1790,14 +1822,14 @@

 function theme_faq_random_highlights($num = 5) {

-  $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num);
+  $result = db_query_range(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.type='faq' AND n.status = 1 ORDER BY RAND()", "n", "nid"), 0, $num);

   $items = array();
-  while ($node = db_fetch_object($result)) {
-    $node = node_load(array('nid' => $node->nid));
+  while ($row = db_fetch_object($result)) {
+    $node = node_load(array('nid' => $row->nid));
     $node = node_prepare($node);
     if (node_access("view", $node)) {
-      $items[] = l($node->title, 'node/'. $node->nid);
+      $items[] = l($node->question, 'node/'. $node->nid);
     }
   }
   $list_style = variable_get('faq_question_listing', 'ul');
@@ -1885,11 +1917,11 @@

   // otherwise return list of weighted FAQ nodes
   $items = array();
-  $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"));
-  while ($node = db_fetch_object($result)) {
-    $node_obj = node_load($node->nid);
-    if (node_access("view", $node_obj)) {
-      $items[] = l($node->title, "node/$node->nid");
+  $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"));
+  while ($row = db_fetch_object($result)) {
+    $node = node_load($row->nid);
+    if (node_access("view", $node)) {
+      $items[] = l($node->question, "node/$node->nid");
     }
   }
