Index: sites/all/modules/slot_machine/slot_machine.module =================================================================== --- sites/all/modules/slot_machine/slot_machine.module +++ sites/all/modules/slot_machine/slot_machine.module @@ -282,7 +282,7 @@ * @return int - the nid of the slotted node; returns NULL if slot is empty */ function slot_machine_get_slot_nid($topic, $feature_name) { - $nid = db_result(db_query("SELECT sm.nid FROM {slot_machine} sm JOIN {slot_machine_slots} s ON sm.feature_type = s.feature_type WHERE sm.priority = s.priority AND sm.topic = %d AND s.name = '%s'", $topic, $feature_name)); + $nid = db_result(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n INNER JOIN {slot_machine} sm on sm.nid = n.nid JOIN {slot_machine_slots} s ON sm.feature_type = s.feature_type WHERE sm.priority = s.priority AND sm.topic = %d AND s.name = '%s'"), $topic, $feature_name)); return $nid; } @@ -335,7 +335,7 @@ $vocab = variable_get('slot_machine_topics', 'none'); if (is_numeric($vocab)) { $slotted_topics = array(); - $slots = db_query("SELECT topic FROM {slot_machine} WHERE nid = %d", $node->nid); + $slots = db_query("SELECT topic FROM {slot_machine} WHERE nid = %d", $node->nid); while ($slot = db_fetch_object($slots)) { $slotted_topics[] = $slot->topic; } @@ -454,7 +454,7 @@ ORDER BY sf.topic, s.priority", time(), mktime(0, 0, 0), time(), mktime(0, 0, 0)); while ($obj = db_fetch_object($results)) { - $num_queue = db_result(db_query("SELECT COUNT(nid) FROM {slot_machine} WHERE topic = %d AND feature_type = '%s' AND priority > %d", $obj->topic, $obj->feature_type, $max_priorities[$obj->feature_type])); + $num_queue = db_result(db_query("SELECT COUNT(nid) FROM {slot_machine} WHERE topic = %d AND feature_type = '%s' AND priority > %d", $obj->topic, $obj->feature_type, $max_priorities[$obj->feature_type])); if ($num_queue && !$rotating[$obj->topic][$obj->feature_type]) { // Remove the item, and update the others db_query("DELETE FROM {slot_machine} WHERE nid = %d AND topic = %d", $obj->nid, $obj->topic); @@ -500,7 +500,7 @@ * Get the feature type for this node */ function slot_machine_get_feature_type($nid) { - $type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $nid)); + $type = db_result(db_query(db_rewrite_sql("SELECT type FROM {node} WHERE nid = %d"), $nid)); return $type; } @@ -557,9 +557,9 @@ function _sm_get_vocabulary_terms($vid) { $topics = array(); if (variable_get('slot_machine_include_child_terms', 0) == 1) { - $results = db_query('SELECT td.name, td.tid FROM {term_data} td JOIN {vocabulary} v ON td.vid = v.vid WHERE v.vid = %d ORDER BY td.tid ASC', $vid); + $results = db_query(db_rewrite_sql('SELECT td.name, td.tid FROM {term_data} td JOIN {vocabulary} v ON td.vid = v.vid WHERE v.vid = %d ORDER BY td.tid ASC'), $vid); } else { - $results = db_query('SELECT td.name, td.tid FROM {term_data} td LEFT JOIN {vocabulary} v ON td.vid = v.vid LEFT JOIN {term_hierarchy} th ON td.tid = th.tid WHERE v.vid = %d AND th.parent = 0 ORDER BY td.name ASC', $vid); + $results = db_query(db_rewrite_sql('SELECT td.name, td.tid FROM {term_data} td LEFT JOIN {vocabulary} v ON td.vid = v.vid LEFT JOIN {term_hierarchy} th ON td.tid = th.tid WHERE v.vid = %d AND th.parent = 0 ORDER BY td.name ASC'), $vid); } while ($term = db_fetch_object($results)) { $topics[$term->tid] = $term->name; @@ -571,9 +571,9 @@ $node_topics = array(); if ($nid) { if (module_exists('node_comments')) { - $comment_nid = db_result(db_query("SELECT nid FROM {node_comments} WHERE cid = %d", $nid)); + $comment_nid = db_result(db_query(db_rewrite_sql("SELECT nid FROM {node_comments} WHERE cid = %d"), $nid)); } - $terms = db_query("SELECT td.name FROM {node} n JOIN {term_node} tn ON n.nid = tn.nid JOIN {term_data} td ON tn.tid = td.tid JOIN {vocabulary} v ON td.vid = v.vid WHERE v.name = 'Topics' AND n.nid = %d", ($comment_nid ? $comment_nid : $nid)); + $terms = db_query(db_rewrite_sql("SELECT td.name FROM {node} n JOIN {term_node} tn ON n.nid = tn.nid JOIN {term_data} td ON tn.tid = td.tid JOIN {vocabulary} v ON td.vid = v.vid WHERE v.name = 'Topics' AND n.nid = %d"), ($comment_nid ? $comment_nid : $nid)); while ($term = db_fetch_object($terms)) { $node_topics[] = $term->name; } Index: sites/all/modules/slot_machine/slot_machine.utils.inc =================================================================== --- sites/all/modules/slot_machine/slot_machine.utils.inc +++ sites/all/modules/slot_machine/slot_machine.utils.inc @@ -9,9 +9,9 @@ if (is_numeric($vocab)) { if (!$topic && !variable_get('slot_machine_home_topic', 1)) { $topic_nids = array(); - $result = db_query('SELECT tid, name FROM {term_data} WHERE vid = %d', $vocab); + $result = db_query(db_rewrite_sql('SELECT tid, name FROM {term_data} WHERE vid = %d', '{term_data}', 'tid'), $vocab); while ($row = db_fetch_object($result)) { - $topic_nid = db_result(db_query_range('SELECT sm.nid FROM {slot_machine} sm INNER JOIN {slot_machine_slots} s ON s.feature_type = sm.feature_type WHERE topic = %d ORDER BY s.weight ASC', $row->tid, 0, 1)); + $topic_nid = db_result(db_query_range(db_rewrite_sql('SELECT node.nid FROM {node} node INNER JOIN {slot_machine} sm on sm.nid = node.nid INNER JOIN {slot_machine_slots} s ON s.feature_type = sm.feature_type WHERE topic = %d ORDER BY s.weight ASC','node','nid'), $row->tid, 0, 1)); if ($topic_nid) { $topic_nids[$row->name] = $topic_nid; } @@ -21,7 +21,7 @@ } } else { - $tid = db_result(db_query('SELECT tid FROM {term_data} WHERE name = "%s" AND vid = %d', $topic, $vocab)); + $tid = db_result(db_query(db_rewrite_sql('SELECT tid FROM {term_data} WHERE name = "%s" AND vid = %d', '{term_data}', 'tid'), $topic, $vocab)); $feature_types = db_query('SELECT name FROM {slot_machine_slots} ORDER BY weight ASC'); $nids = array(); while ($row = db_fetch_object($feature_types)) {