Index: faq.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.module,v
retrieving revision 1.1.4.31
diff -u -r1.1.4.31 faq.module
--- faq.module	10 Apr 2007 21:24:42 -0000	1.1.4.31
+++ faq.module	13 Apr 2007 20:24:48 -0000
@@ -192,6 +192,10 @@
   return $form;
 }
 
+function faq_delete(&$node) {
+		db_query('DELETE FROM {faq_weights} WHERE nid = %d', $node->nid); 		
+}
+
 function faq_view($node, $teaser = FALSE, $page = FALSE) {
 
   if ($page) {
@@ -429,19 +433,19 @@
 						$category = 0;
 						if (module_exists("i18n") && variable_get('i18n_node_faq', 0)) {
 								$lang = i18n_get_lang();
-								$result = db_query("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {i18n_node} i ON i.nid = n.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND i.language = '%s' ORDER BY w.weight ASC, n.sticky DESC, n.created DESC", $category, $lang);
+								$result = db_query("SELECT n.nid, n.title, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {i18n_node} i ON i.nid = n.nid LEFT JOIN {faq_weights} w ON n.nid = w.nid AND w.tid = %d WHERE n.type='faq' AND n.status = 1 AND i.language = '%s' ORDER BY weight ASC, n.sticky DESC, n.created DESC", $category, $lang);
 						}
 						else {
-								$result = db_query("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 w.weight ASC, n.sticky DESC, n.created DESC", $category);
+								$result = db_query("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 weight ASC, n.sticky DESC, n.created DESC", $category);
 						}
 				} 
 				else {
 						if (module_exists("i18n") && variable_get('i18n_node_faq', 0)) {
 								$lang = i18n_get_lang();
-								$result = db_query("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 {i18n_node} i ON i.nid = n.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 AND i.language = '%s' ORDER BY w.weight ASC, n.sticky DESC, n.created DESC", $category, $category, $lang);
+								$result = db_query("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 {i18n_node} i ON i.nid = n.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 AND i.language = '%s' ORDER BY weight ASC, n.sticky DESC, n.created DESC", $category, $category, $lang);
 						}
 						else {
-								$result = db_query("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 w.weight ASC, n.sticky DESC, n.created DESC", $category, $category);
+								$result = db_query("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", $category, $category);
 						}
 				}
 
@@ -542,6 +546,7 @@
 }
 
 
+
 /**
  * Function to display the faq page
  */
@@ -600,10 +605,10 @@
   // non-categorized questions and answers
   if (!$use_categories) {
 				if (!empty($display_vars["lang"])) {
-						$result = db_query("SELECT n.title, n.nid, r.body, r.teaser, r.format FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid LEFT JOIN {i18n_node} i ON i.nid = n.nid LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND i.language = '%s' AND w.tid = 0 ORDER BY w.weight, n.sticky DESC, n.created DESC", $display_vars["lang"]);
+						$result = db_query("SELECT n.title, n.nid, 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 {i18n_node} i ON i.nid = n.nid LEFT JOIN {faq_weights} w ON w.nid = n.nid WHERE n.type='faq' AND n.status = 2 AND i.language = '%s' AND (w.tid = 0 OR w.tid IS NULL) ORDER BY weight, n.sticky DESC, n.created DESC", $display_vars["lang"]);
 				}
 				else {
-						$result = db_query("SELECT n.title, n.nid, r.body, r.teaser, r.format 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 ORDER BY w.weight, n.sticky DESC, n.created DESC");
+						$result = db_query("SELECT n.title, n.nid, 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");
 				}
 
     switch ($faq_display) {
@@ -752,10 +757,10 @@
 function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {
 
 		if (!empty($display_vars["lang"])) {
-				$result = db_query("SELECT n.title, n.nid, r.body, r.teaser, r.format 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 LEFT JOIN {i18n_node} i ON i.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' AND i.language = '%s' ORDER BY w.weight, n.sticky DESC, n.created DESC", $term->tid, $display_vars["lang"]);
+				$result = db_query("SELECT n.title, n.nid, 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 LEFT JOIN {i18n_node} i ON i.nid = n.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' AND i.language = '%s' ORDER BY weight, n.sticky DESC, n.created DESC", $term->tid, $display_vars["lang"]);
 		}
 		else {
-				$result = db_query("SELECT n.title, n.nid, r.body, r.teaser, r.format 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 w.weight, n.sticky DESC, n.created DESC", $term->tid);
+				$result = db_query("SELECT n.title, n.nid, 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", $term->tid);
 		}
 
   $display_vars['display_header'] = $display_header;
