diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator.module | 52 | ||||
-rw-r--r-- | modules/aggregator/aggregator.module | 52 | ||||
-rw-r--r-- | modules/comment.module | 62 | ||||
-rw-r--r-- | modules/comment/comment.module | 62 | ||||
-rw-r--r-- | modules/import.module | 52 | ||||
-rw-r--r-- | modules/node.module | 14 | ||||
-rw-r--r-- | modules/node/node.module | 14 | ||||
-rw-r--r-- | modules/taxonomy.module | 64 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 64 |
9 files changed, 218 insertions, 218 deletions
diff --git a/modules/aggregator.module b/modules/aggregator.module index 22cb55939..a36ef3215 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -92,7 +92,7 @@ function import_bundle_block($attributes) { } function import_feed_block($feed) { - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { $output .= import_format_item($item); @@ -119,13 +119,13 @@ function import_block($op, $delta) { list($type, $id) = split(":", $delta); switch ($type) { case "feed": - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $id)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id)); $block["subject"] = $feed->title; $block["content"] .= import_feed_block($feed) ."<div align=\"right\">". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."</div>"; break; case "bundle": - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $id)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id)); $block["subject"] = $bundle->title; $block["content"] .= import_bundle_block($bundle->attributes) ."<div align=\"right\">". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."</div>"; break; @@ -168,7 +168,7 @@ function import_get_feeds($attributes = 0) { } function import_remove($feed) { - db_query("DELETE FROM item WHERE fid = '%d'", $feed["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]); return t("removed news items from '%site'.", array("%site" => $feed["title"])); } @@ -270,7 +270,7 @@ function import_refresh($feed) { $channel[$key] = filter(strtr(trim($value), $tt)); } - db_query("UPDATE feed SET timestamp = '%d', link = '%s', description = '%s' WHERE fid = '%d'", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); + db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); /* ** We reverse the array such that we store the first item last, @@ -316,10 +316,10 @@ function import_refresh($feed) { */ if ($link && $link != $feed["link"] && $link != $feed["url"]) { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND link = '%s'", $feed["fid"], $link)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link)); } else { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND title = '%s'", $feed["fid"], $title)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title)); } import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"])); @@ -331,7 +331,7 @@ function import_refresh($feed) { unset($items); - $result = db_query("SELECT iid FROM item WHERE fid = '%d' ORDER BY timestamp", $feed["fid"]); + $result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]); while ($item = db_fetch_object($result)) { $items[] = "iid = '$item->iid'"; @@ -351,10 +351,10 @@ function import_refresh($feed) { function import_save_item($edit) { if ($edit["iid"] && $edit["title"]) { - db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = '%d'", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); + db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); } else if ($edit["iid"]) { - db_query("DELETE FROM item WHERE iid = '%d'", $edit["iid"]); + db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]); } else if ($edit["title"] && $edit["link"]) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time()); @@ -378,15 +378,15 @@ function import_form_bundle($edit = array()) { function import_save_bundle($edit) { if ($edit["bid"] && $edit["title"]) { - db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = '%d'", $edit["title"], $edit["attributes"], $edit["bid"]); + db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]); } else if ($edit["bid"]) { - db_query("DELETE FROM bundle WHERE bid = '%d'", $edit["bid"]); + db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); + $next_id = db_next_id("bundle_bid"); + db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); } } @@ -415,33 +415,33 @@ function import_form_feed($edit = array()) { function import_save_feed($edit) { if ($edit["fid"] && $edit["title"]) { - db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = '%d'", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["fid"]) { - db_query("DELETE FROM feed WHERE fid = '%d'", $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); + $next_id = db_next_id("feed_fid"); + db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); } } function import_save_attributes($edit) { foreach ($edit as $iid => $value) { - db_query("UPDATE item SET attributes = '%s' WHERE iid = '%d'", $value, $iid); + db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid); } return "attributes has been saved"; } function import_get_feed($fid) { - return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); } function import_get_bundle($bid) { - return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); } function import_view() { @@ -594,13 +594,13 @@ function import_page_last() { function import_page_feed($fid) { - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\"><a href=\"$feed->link\">$feed->link</a></div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">$feed->description</div></p>"; $header .= "<p><b>". t("Last update") .":</b><div style=\"margin-left: 20px;\">". format_interval(time() - $feed->timestamp) ." ". t("ago") ." <a href=\"$feed->url\"><img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" alt=\"\" /></a><br /><br /></div></p>\n"; - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">"; while ($item = db_fetch_object($result)) { @@ -630,7 +630,7 @@ function import_page_feed($fid) { function import_page_bundle($bid) { - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\">". l($bundle->title, "import/bundle/$bundle->bid") ."</div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">". t("A composite news feed about") ." $bundle->attributes.</div></p>"; diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 22cb55939..a36ef3215 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -92,7 +92,7 @@ function import_bundle_block($attributes) { } function import_feed_block($feed) { - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { $output .= import_format_item($item); @@ -119,13 +119,13 @@ function import_block($op, $delta) { list($type, $id) = split(":", $delta); switch ($type) { case "feed": - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $id)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id)); $block["subject"] = $feed->title; $block["content"] .= import_feed_block($feed) ."<div align=\"right\">". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."</div>"; break; case "bundle": - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $id)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id)); $block["subject"] = $bundle->title; $block["content"] .= import_bundle_block($bundle->attributes) ."<div align=\"right\">". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."</div>"; break; @@ -168,7 +168,7 @@ function import_get_feeds($attributes = 0) { } function import_remove($feed) { - db_query("DELETE FROM item WHERE fid = '%d'", $feed["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]); return t("removed news items from '%site'.", array("%site" => $feed["title"])); } @@ -270,7 +270,7 @@ function import_refresh($feed) { $channel[$key] = filter(strtr(trim($value), $tt)); } - db_query("UPDATE feed SET timestamp = '%d', link = '%s', description = '%s' WHERE fid = '%d'", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); + db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); /* ** We reverse the array such that we store the first item last, @@ -316,10 +316,10 @@ function import_refresh($feed) { */ if ($link && $link != $feed["link"] && $link != $feed["url"]) { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND link = '%s'", $feed["fid"], $link)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link)); } else { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND title = '%s'", $feed["fid"], $title)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title)); } import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"])); @@ -331,7 +331,7 @@ function import_refresh($feed) { unset($items); - $result = db_query("SELECT iid FROM item WHERE fid = '%d' ORDER BY timestamp", $feed["fid"]); + $result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]); while ($item = db_fetch_object($result)) { $items[] = "iid = '$item->iid'"; @@ -351,10 +351,10 @@ function import_refresh($feed) { function import_save_item($edit) { if ($edit["iid"] && $edit["title"]) { - db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = '%d'", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); + db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); } else if ($edit["iid"]) { - db_query("DELETE FROM item WHERE iid = '%d'", $edit["iid"]); + db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]); } else if ($edit["title"] && $edit["link"]) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time()); @@ -378,15 +378,15 @@ function import_form_bundle($edit = array()) { function import_save_bundle($edit) { if ($edit["bid"] && $edit["title"]) { - db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = '%d'", $edit["title"], $edit["attributes"], $edit["bid"]); + db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]); } else if ($edit["bid"]) { - db_query("DELETE FROM bundle WHERE bid = '%d'", $edit["bid"]); + db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); + $next_id = db_next_id("bundle_bid"); + db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); } } @@ -415,33 +415,33 @@ function import_form_feed($edit = array()) { function import_save_feed($edit) { if ($edit["fid"] && $edit["title"]) { - db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = '%d'", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["fid"]) { - db_query("DELETE FROM feed WHERE fid = '%d'", $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); + $next_id = db_next_id("feed_fid"); + db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); } } function import_save_attributes($edit) { foreach ($edit as $iid => $value) { - db_query("UPDATE item SET attributes = '%s' WHERE iid = '%d'", $value, $iid); + db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid); } return "attributes has been saved"; } function import_get_feed($fid) { - return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); } function import_get_bundle($bid) { - return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); } function import_view() { @@ -594,13 +594,13 @@ function import_page_last() { function import_page_feed($fid) { - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\"><a href=\"$feed->link\">$feed->link</a></div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">$feed->description</div></p>"; $header .= "<p><b>". t("Last update") .":</b><div style=\"margin-left: 20px;\">". format_interval(time() - $feed->timestamp) ." ". t("ago") ." <a href=\"$feed->url\"><img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" alt=\"\" /></a><br /><br /></div></p>\n"; - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">"; while ($item = db_fetch_object($result)) { @@ -630,7 +630,7 @@ function import_page_feed($fid) { function import_page_bundle($bid) { - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\">". l($bundle->title, "import/bundle/$bundle->bid") ."</div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">". t("A composite news feed about") ." $bundle->attributes.</div></p>"; diff --git a/modules/comment.module b/modules/comment.module index 8ada37458..9af8c2a7f 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -113,7 +113,7 @@ function comment_form($edit) { function comment_edit($cid) { global $user; - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $cid)); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $cid)); if (comment_access("edit", $comment)) { comment_preview(object2array($comment)); @@ -130,7 +130,7 @@ function comment_reply($pid, $nid) { */ if ($pid) { - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $pid)); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid)); comment_view($comment); } else { @@ -181,7 +181,7 @@ function comment_preview($edit) { theme("box", t("Reply"), comment_form($edit)); if ($edit["pid"]) { - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $edit["pid"])); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"])); comment_view($comment); } else { @@ -221,7 +221,7 @@ function comment_post($edit) { ** validated/filtered data to perform such check. */ - $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND nid = '%d' AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0); + $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0); if ($duplicate != 0) { watchdog("warning", "comment: duplicate '". $edit["subject"] ."'"); @@ -237,7 +237,7 @@ function comment_post($edit) { ** user. */ - db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = '%d' AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]); + db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = %d AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]); /* ** Fire a hook @@ -268,9 +268,9 @@ function comment_post($edit) { $score = $roles[$user->rid] ? $roles[$user->rid] : 0; $users = serialize(array(0 => $score)); - $edit["cid"] = db_next_id("comments"); + $edit["cid"] = db_next_id("comments_cid"); - db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users); + db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users); /* ** Tell the other modules a new comment has been submitted: @@ -397,7 +397,7 @@ function comment_render($node, $cid = 0) { if (empty($threshold)) { $threshold = $user->uid ? $user->threshold : variable_get("comment_default_threshold", 0); } - $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = '%d'", $threshold)); + $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = %d", $threshold)); if (empty($comment_page)) { $comment_page = 1; @@ -417,7 +417,7 @@ function comment_render($node, $cid = 0) { print "<form method=\"post\" action=\"". url("comment") ."\">\n"; print form_hidden("nid", $nid); - $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid); + $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid); if ($comment = db_fetch_object($result)) { comment_view($comment, comment_links($comment)); @@ -734,7 +734,7 @@ function comment_node_link($node) { ** Edit comments: */ - $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE nid = '%d' AND c.status = 0 ORDER BY c.timestamp", $node->nid); + $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE nid = %d AND c.status = 0 ORDER BY c.timestamp", $node->nid); $header = array(t("title"), t("author"), array("data" => t("operations"), "colspan" => 3)); @@ -754,7 +754,7 @@ function comment_node_link($node) { function comment_admin_edit($id) { - $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $id); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $id); $comment = db_fetch_object($result); // if a comment is "deleted", it's deleted @@ -774,7 +774,7 @@ function comment_admin_edit($id) { function comment_delete($edit) { if ($edit["confirm"]) { - db_query("UPDATE comments SET status = 2 WHERE cid = '%d'", $edit["cid"]); + db_query("UPDATE comments SET status = 2 WHERE cid = %d", $edit["cid"]); watchdog("special", "comment: deleted comment #". $edit["cid"]); $output = "deleted comment."; } @@ -790,7 +790,7 @@ function comment_delete($edit) { } function comment_save($id, $edit) { - db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = '%d'", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id); + db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id); watchdog("special", "comment: modified '". $edit["subject"] ."'"); return "updated comment."; } @@ -889,16 +889,16 @@ function comment_mod_votes($edit) { $mid = arg(3); if ($op == t("Save vote")) { - db_query("UPDATE moderation_votes SET vote = '%s', weight = '%d' WHERE mid = '%d'", $edit["vote"], $edit["weight"], $mid); + db_query("UPDATE moderation_votes SET vote = '%s', weight = %d WHERE mid = %d", $edit["vote"], $edit["weight"], $mid); $mid = 0; } else if ($op == t("Delete vote")) { - db_query("DELETE FROM moderation_votes WHERE mid = '%d'", $mid); - db_query("DELETE FROM moderation_roles WHERE mid = '%d'", $mid); + db_query("DELETE FROM moderation_votes WHERE mid = %d", $mid); + db_query("DELETE FROM moderation_roles WHERE mid = %d", $mid); $mid = 0; } else if ($op == t("Add new vote")) { - db_query("INSERT INTO moderation_votes (mid, vote, weight) VALUES (NULL, '%s', '%d')", $edit["vote"], $edit["weight"]); + db_query("INSERT INTO moderation_votes (mid, vote, weight) VALUES (NULL, '%s', %d)", $edit["vote"], $edit["weight"]); $mid = 0; } @@ -913,7 +913,7 @@ function comment_mod_votes($edit) { $output .= "</table>"; if ($mid) { - $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = '%d'", $mid)); + $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = %d", $mid)); } $output .= "<h3>Add new moderation option</h3>"; @@ -938,15 +938,15 @@ function comment_mod_filters($edit) { $fid = arg(3); if ($op == t("Save threshold")) { - db_query("UPDATE moderation_filters SET filter = '%s', minimum = '%d' WHERE fid = '%d'", $edit["filter"], $edit["minimum"], $fid); + db_query("UPDATE moderation_filters SET filter = '%s', minimum = %d WHERE fid = %d", $edit["filter"], $edit["minimum"], $fid); $fid = 0; } else if ($op == t("Delete threshold")) { - db_query("DELETE FROM moderation_filters WHERE fid = '%d'", $fid); + db_query("DELETE FROM moderation_filters WHERE fid = %d", $fid); $fid = 0; } else if ($op == t("Add new threshold")) { - db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', '%d')", $edit["filter"], $edit["minimum"]); + db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', %d)", $edit["filter"], $edit["minimum"]); $fid = 0; } @@ -962,7 +962,7 @@ function comment_mod_filters($edit) { $output .= "</table>"; if ($fid) { - $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = '%d'", $fid)); + $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = %d", $fid)); } $output .= "<h3>Add new threshold</h3>"; @@ -1138,7 +1138,7 @@ function comment_moderation_form($comment) { // comment hasn't been moderated yet: if (!isset($votes)) { - $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = '%d' ORDER BY weight", $user->rid); + $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = %d ORDER BY weight", $user->rid); $votes = array(); while ($vote = db_fetch_object($result)) { if ($vote->value != 0) { @@ -1257,18 +1257,18 @@ function comment_moderate() { global $moderation, $user; if ($moderation) { - $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = '%d'", $user->rid); + $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = %d", $user->rid); while ($mod = db_fetch_object($result)) { $votes[$mod->mid] = $mod->value; } - $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = '%d'", key($moderation))))); + $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = %d", key($moderation))))); if (user_access("administer comments") || comment_user_can_moderate($node)) { foreach ($moderation as $cid => $vote) { if ($vote) { if (($vote == 'offline') && (user_access("administer comments"))) { - db_query("UPDATE comments SET status = 1 WHERE cid = '%d'", $cid); + db_query("UPDATE comments SET status = 1 WHERE cid = %d", $cid); watchdog("special", "comment: unpublished comment #". $cid); /* @@ -1278,7 +1278,7 @@ function comment_moderate() { module_invoke_all("comment", "unpublish", $cid); } else { - $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '%d'", $cid)); + $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = %d", $cid)); $users = unserialize($comment->users); if ($user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) { $users[$user->uid] = $vote; @@ -1293,7 +1293,7 @@ function comment_moderate() { } } $new_score = round($tot_score / count($users)); - db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = '%d'", serialize($users), $cid); + db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = %d", serialize($users), $cid); /* ** Fire a hook @@ -1320,7 +1320,7 @@ function comment_num_all($nid) { static $cache; if (!isset($cache[$nid])) { - $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND c.status = 0 GROUP BY n.nid", $nid)); + $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND c.status = 0 GROUP BY n.nid", $nid)); $cache[$nid] = $comment->number ? $comment->number : 0; } return $cache[$nid]; @@ -1330,7 +1330,7 @@ function comment_num_replies($id) { static $cache; if (!isset($cache[$nid])) { - $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND status = 0", $id); + $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND status = 0", $id); $cache[$nid] = $result ? db_result($result, 0) : 0; } @@ -1360,7 +1360,7 @@ function comment_num_new($nid, $timestamp = 0) { ** Use the timestamp to retrieve the number of new comments */ - $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND timestamp > '%d' AND c.status = 0", $nid, $timestamp)); + $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = 0", $nid, $timestamp)); return $result; } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8ada37458..9af8c2a7f 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -113,7 +113,7 @@ function comment_form($edit) { function comment_edit($cid) { global $user; - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $cid)); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $cid)); if (comment_access("edit", $comment)) { comment_preview(object2array($comment)); @@ -130,7 +130,7 @@ function comment_reply($pid, $nid) { */ if ($pid) { - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $pid)); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid)); comment_view($comment); } else { @@ -181,7 +181,7 @@ function comment_preview($edit) { theme("box", t("Reply"), comment_form($edit)); if ($edit["pid"]) { - $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $edit["pid"])); + $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"])); comment_view($comment); } else { @@ -221,7 +221,7 @@ function comment_post($edit) { ** validated/filtered data to perform such check. */ - $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND nid = '%d' AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0); + $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0); if ($duplicate != 0) { watchdog("warning", "comment: duplicate '". $edit["subject"] ."'"); @@ -237,7 +237,7 @@ function comment_post($edit) { ** user. */ - db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = '%d' AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]); + db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = %d AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]); /* ** Fire a hook @@ -268,9 +268,9 @@ function comment_post($edit) { $score = $roles[$user->rid] ? $roles[$user->rid] : 0; $users = serialize(array(0 => $score)); - $edit["cid"] = db_next_id("comments"); + $edit["cid"] = db_next_id("comments_cid"); - db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users); + db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users); /* ** Tell the other modules a new comment has been submitted: @@ -397,7 +397,7 @@ function comment_render($node, $cid = 0) { if (empty($threshold)) { $threshold = $user->uid ? $user->threshold : variable_get("comment_default_threshold", 0); } - $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = '%d'", $threshold)); + $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = %d", $threshold)); if (empty($comment_page)) { $comment_page = 1; @@ -417,7 +417,7 @@ function comment_render($node, $cid = 0) { print "<form method=\"post\" action=\"". url("comment") ."\">\n"; print form_hidden("nid", $nid); - $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid); + $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.data, c.score, c.users", $cid); if ($comment = db_fetch_object($result)) { comment_view($comment, comment_links($comment)); @@ -734,7 +734,7 @@ function comment_node_link($node) { ** Edit comments: */ - $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE nid = '%d' AND c.status = 0 ORDER BY c.timestamp", $node->nid); + $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE nid = %d AND c.status = 0 ORDER BY c.timestamp", $node->nid); $header = array(t("title"), t("author"), array("data" => t("operations"), "colspan" => 3)); @@ -754,7 +754,7 @@ function comment_node_link($node) { function comment_admin_edit($id) { - $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $id); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $id); $comment = db_fetch_object($result); // if a comment is "deleted", it's deleted @@ -774,7 +774,7 @@ function comment_admin_edit($id) { function comment_delete($edit) { if ($edit["confirm"]) { - db_query("UPDATE comments SET status = 2 WHERE cid = '%d'", $edit["cid"]); + db_query("UPDATE comments SET status = 2 WHERE cid = %d", $edit["cid"]); watchdog("special", "comment: deleted comment #". $edit["cid"]); $output = "deleted comment."; } @@ -790,7 +790,7 @@ function comment_delete($edit) { } function comment_save($id, $edit) { - db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = '%d'", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id); + db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id); watchdog("special", "comment: modified '". $edit["subject"] ."'"); return "updated comment."; } @@ -889,16 +889,16 @@ function comment_mod_votes($edit) { $mid = arg(3); if ($op == t("Save vote")) { - db_query("UPDATE moderation_votes SET vote = '%s', weight = '%d' WHERE mid = '%d'", $edit["vote"], $edit["weight"], $mid); + db_query("UPDATE moderation_votes SET vote = '%s', weight = %d WHERE mid = %d", $edit["vote"], $edit["weight"], $mid); $mid = 0; } else if ($op == t("Delete vote")) { - db_query("DELETE FROM moderation_votes WHERE mid = '%d'", $mid); - db_query("DELETE FROM moderation_roles WHERE mid = '%d'", $mid); + db_query("DELETE FROM moderation_votes WHERE mid = %d", $mid); + db_query("DELETE FROM moderation_roles WHERE mid = %d", $mid); $mid = 0; } else if ($op == t("Add new vote")) { - db_query("INSERT INTO moderation_votes (mid, vote, weight) VALUES (NULL, '%s', '%d')", $edit["vote"], $edit["weight"]); + db_query("INSERT INTO moderation_votes (mid, vote, weight) VALUES (NULL, '%s', %d)", $edit["vote"], $edit["weight"]); $mid = 0; } @@ -913,7 +913,7 @@ function comment_mod_votes($edit) { $output .= "</table>"; if ($mid) { - $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = '%d'", $mid)); + $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = %d", $mid)); } $output .= "<h3>Add new moderation option</h3>"; @@ -938,15 +938,15 @@ function comment_mod_filters($edit) { $fid = arg(3); if ($op == t("Save threshold")) { - db_query("UPDATE moderation_filters SET filter = '%s', minimum = '%d' WHERE fid = '%d'", $edit["filter"], $edit["minimum"], $fid); + db_query("UPDATE moderation_filters SET filter = '%s', minimum = %d WHERE fid = %d", $edit["filter"], $edit["minimum"], $fid); $fid = 0; } else if ($op == t("Delete threshold")) { - db_query("DELETE FROM moderation_filters WHERE fid = '%d'", $fid); + db_query("DELETE FROM moderation_filters WHERE fid = %d", $fid); $fid = 0; } else if ($op == t("Add new threshold")) { - db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', '%d')", $edit["filter"], $edit["minimum"]); + db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', %d)", $edit["filter"], $edit["minimum"]); $fid = 0; } @@ -962,7 +962,7 @@ function comment_mod_filters($edit) { $output .= "</table>"; if ($fid) { - $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = '%d'", $fid)); + $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = %d", $fid)); } $output .= "<h3>Add new threshold</h3>"; @@ -1138,7 +1138,7 @@ function comment_moderation_form($comment) { // comment hasn't been moderated yet: if (!isset($votes)) { - $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = '%d' ORDER BY weight", $user->rid); + $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = %d ORDER BY weight", $user->rid); $votes = array(); while ($vote = db_fetch_object($result)) { if ($vote->value != 0) { @@ -1257,18 +1257,18 @@ function comment_moderate() { global $moderation, $user; if ($moderation) { - $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = '%d'", $user->rid); + $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = %d", $user->rid); while ($mod = db_fetch_object($result)) { $votes[$mod->mid] = $mod->value; } - $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = '%d'", key($moderation))))); + $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = %d", key($moderation))))); if (user_access("administer comments") || comment_user_can_moderate($node)) { foreach ($moderation as $cid => $vote) { if ($vote) { if (($vote == 'offline') && (user_access("administer comments"))) { - db_query("UPDATE comments SET status = 1 WHERE cid = '%d'", $cid); + db_query("UPDATE comments SET status = 1 WHERE cid = %d", $cid); watchdog("special", "comment: unpublished comment #". $cid); /* @@ -1278,7 +1278,7 @@ function comment_moderate() { module_invoke_all("comment", "unpublish", $cid); } else { - $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '%d'", $cid)); + $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = %d", $cid)); $users = unserialize($comment->users); if ($user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) { $users[$user->uid] = $vote; @@ -1293,7 +1293,7 @@ function comment_moderate() { } } $new_score = round($tot_score / count($users)); - db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = '%d'", serialize($users), $cid); + db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = %d", serialize($users), $cid); /* ** Fire a hook @@ -1320,7 +1320,7 @@ function comment_num_all($nid) { static $cache; if (!isset($cache[$nid])) { - $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND c.status = 0 GROUP BY n.nid", $nid)); + $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND c.status = 0 GROUP BY n.nid", $nid)); $cache[$nid] = $comment->number ? $comment->number : 0; } return $cache[$nid]; @@ -1330,7 +1330,7 @@ function comment_num_replies($id) { static $cache; if (!isset($cache[$nid])) { - $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND status = 0", $id); + $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND status = 0", $id); $cache[$nid] = $result ? db_result($result, 0) : 0; } @@ -1360,7 +1360,7 @@ function comment_num_new($nid, $timestamp = 0) { ** Use the timestamp to retrieve the number of new comments */ - $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND timestamp > '%d' AND c.status = 0", $nid, $timestamp)); + $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = 0", $nid, $timestamp)); return $result; } diff --git a/modules/import.module b/modules/import.module index 22cb55939..a36ef3215 100644 --- a/modules/import.module +++ b/modules/import.module @@ -92,7 +92,7 @@ function import_bundle_block($attributes) { } function import_feed_block($feed) { - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { $output .= import_format_item($item); @@ -119,13 +119,13 @@ function import_block($op, $delta) { list($type, $id) = split(":", $delta); switch ($type) { case "feed": - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $id)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id)); $block["subject"] = $feed->title; $block["content"] .= import_feed_block($feed) ."<div align=\"right\">". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."</div>"; break; case "bundle": - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $id)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id)); $block["subject"] = $bundle->title; $block["content"] .= import_bundle_block($bundle->attributes) ."<div align=\"right\">". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."</div>"; break; @@ -168,7 +168,7 @@ function import_get_feeds($attributes = 0) { } function import_remove($feed) { - db_query("DELETE FROM item WHERE fid = '%d'", $feed["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]); return t("removed news items from '%site'.", array("%site" => $feed["title"])); } @@ -270,7 +270,7 @@ function import_refresh($feed) { $channel[$key] = filter(strtr(trim($value), $tt)); } - db_query("UPDATE feed SET timestamp = '%d', link = '%s', description = '%s' WHERE fid = '%d'", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); + db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); /* ** We reverse the array such that we store the first item last, @@ -316,10 +316,10 @@ function import_refresh($feed) { */ if ($link && $link != $feed["link"] && $link != $feed["url"]) { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND link = '%s'", $feed["fid"], $link)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link)); } else { - $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND title = '%s'", $feed["fid"], $title)); + $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title)); } import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"])); @@ -331,7 +331,7 @@ function import_refresh($feed) { unset($items); - $result = db_query("SELECT iid FROM item WHERE fid = '%d' ORDER BY timestamp", $feed["fid"]); + $result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]); while ($item = db_fetch_object($result)) { $items[] = "iid = '$item->iid'"; @@ -351,10 +351,10 @@ function import_refresh($feed) { function import_save_item($edit) { if ($edit["iid"] && $edit["title"]) { - db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = '%d'", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); + db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); } else if ($edit["iid"]) { - db_query("DELETE FROM item WHERE iid = '%d'", $edit["iid"]); + db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]); } else if ($edit["title"] && $edit["link"]) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time()); @@ -378,15 +378,15 @@ function import_form_bundle($edit = array()) { function import_save_bundle($edit) { if ($edit["bid"] && $edit["title"]) { - db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = '%d'", $edit["title"], $edit["attributes"], $edit["bid"]); + db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]); } else if ($edit["bid"]) { - db_query("DELETE FROM bundle WHERE bid = '%d'", $edit["bid"]); + db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); + $next_id = db_next_id("bundle_bid"); + db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]); } } @@ -415,33 +415,33 @@ function import_form_feed($edit = array()) { function import_save_feed($edit) { if ($edit["fid"] && $edit["title"]) { - db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = '%d'", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["fid"]) { - db_query("DELETE FROM feed WHERE fid = '%d'", $edit["fid"]); - db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]); + db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]); + db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]); } else if ($edit["title"]) { // a single unique id for bundles and feeds, to use in blocks - $next_id = db_next_id("import"); - db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); + $next_id = db_next_id("feed_fid"); + db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]); } } function import_save_attributes($edit) { foreach ($edit as $iid => $value) { - db_query("UPDATE item SET attributes = '%s' WHERE iid = '%d'", $value, $iid); + db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid); } return "attributes has been saved"; } function import_get_feed($fid) { - return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); } function import_get_bundle($bid) { - return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); } function import_view() { @@ -594,13 +594,13 @@ function import_page_last() { function import_page_feed($fid) { - $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid)); + $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\"><a href=\"$feed->link\">$feed->link</a></div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">$feed->description</div></p>"; $header .= "<p><b>". t("Last update") .":</b><div style=\"margin-left: 20px;\">". format_interval(time() - $feed->timestamp) ." ". t("ago") ." <a href=\"$feed->url\"><img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" alt=\"\" /></a><br /><br /></div></p>\n"; - $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); + $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75)); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">"; while ($item = db_fetch_object($result)) { @@ -630,7 +630,7 @@ function import_page_feed($fid) { function import_page_bundle($bid) { - $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid)); + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid)); $header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\">". l($bundle->title, "import/bundle/$bundle->bid") ."</div></p>"; $header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">". t("A composite news feed about") ." $bundle->attributes.</div></p>"; diff --git a/modules/node.module b/modules/node.module index 846b9dfff..66e083846 100644 --- a/modules/node.module +++ b/modules/node.module @@ -44,12 +44,12 @@ function node_tag_new($nid) { if ($user->uid) { $nid = check_query($nid); - $result = db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid); + $result = db_query("SELECT timestamp FROM history WHERE uid = %d AND nid = %d", $user->uid, $nid); if (db_fetch_object($result)) { - db_query("UPDATE history SET timestamp = '%d' WHERE uid = '%d' AND nid = '%d'", time(), $user->uid, $nid); + db_query("UPDATE history SET timestamp = %d WHERE uid = %d AND nid = %d", time(), $user->uid, $nid); } else { - db_query("INSERT INTO history (uid, nid, timestamp) VALUES ('%d', '%d', '%d')", $user->uid, $nid, time()); + db_query("INSERT INTO history (uid, nid, timestamp) VALUES (%d, %d, %d)", $user->uid, $nid, time()); } } } @@ -61,7 +61,7 @@ function node_tag_new($nid) { function node_last_viewed($nid) { global $user; - $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '$user->uid' AND nid = '%d'", $nid)); + $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '$user->uid' AND nid = %d", $nid)); return ($history->timestamp ? $history->timestamp : 0); } @@ -77,7 +77,7 @@ function node_is_new($nid, $timestamp) { if (!isset($cache[$nid])) { if ($user->uid) { - $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid)); + $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = %d AND nid = %d", $user->uid, $nid)); $cache[$nid] = $history->timestamp ? $history->timestamp : 0; } else { @@ -269,7 +269,7 @@ function node_save($node) { $node->created = time(); } $node->changed = time(); - $node->nid = db_next_id("node"); + $node->nid = db_next_id("node_nid"); // Prepare the query: foreach ($node as $key => $value) { @@ -472,7 +472,7 @@ function node_filter_link($text) { function node_comment_mode($nid) { static $comment_mode; if (!isset($comment_mode[$nid])) { - $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = '%d'", $nid)); + $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = %d", $nid)); } return $comment_mode[$nid]; } diff --git a/modules/node/node.module b/modules/node/node.module index 846b9dfff..66e083846 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -44,12 +44,12 @@ function node_tag_new($nid) { if ($user->uid) { $nid = check_query($nid); - $result = db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid); + $result = db_query("SELECT timestamp FROM history WHERE uid = %d AND nid = %d", $user->uid, $nid); if (db_fetch_object($result)) { - db_query("UPDATE history SET timestamp = '%d' WHERE uid = '%d' AND nid = '%d'", time(), $user->uid, $nid); + db_query("UPDATE history SET timestamp = %d WHERE uid = %d AND nid = %d", time(), $user->uid, $nid); } else { - db_query("INSERT INTO history (uid, nid, timestamp) VALUES ('%d', '%d', '%d')", $user->uid, $nid, time()); + db_query("INSERT INTO history (uid, nid, timestamp) VALUES (%d, %d, %d)", $user->uid, $nid, time()); } } } @@ -61,7 +61,7 @@ function node_tag_new($nid) { function node_last_viewed($nid) { global $user; - $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '$user->uid' AND nid = '%d'", $nid)); + $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '$user->uid' AND nid = %d", $nid)); return ($history->timestamp ? $history->timestamp : 0); } @@ -77,7 +77,7 @@ function node_is_new($nid, $timestamp) { if (!isset($cache[$nid])) { if ($user->uid) { - $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = '%d' AND nid = '%d'", $user->uid, $nid)); + $history = db_fetch_object(db_query("SELECT timestamp FROM history WHERE uid = %d AND nid = %d", $user->uid, $nid)); $cache[$nid] = $history->timestamp ? $history->timestamp : 0; } else { @@ -269,7 +269,7 @@ function node_save($node) { $node->created = time(); } $node->changed = time(); - $node->nid = db_next_id("node"); + $node->nid = db_next_id("node_nid"); // Prepare the query: foreach ($node as $key => $value) { @@ -472,7 +472,7 @@ function node_filter_link($text) { function node_comment_mode($nid) { static $comment_mode; if (!isset($comment_mode[$nid])) { - $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = '%d'", $nid)); + $comment_mode[$nid] = db_result(db_query("SELECT comment FROM node WHERE nid = %d", $nid)); } return $comment_mode[$nid]; } diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 256e0364b..fff9cfbaf 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -95,7 +95,7 @@ function taxonomy_form_vocabulary($edit = array()) { function taxonomy_save_vocabulary($edit) { $data = array("name" => $edit["name"], "types" => @implode(",", $edit["types"]), "description" => $edit["description"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]); if ($edit["vid"] && $edit["name"]) { - db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = '%d'", $edit["vid"]); + db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = %d", $edit["vid"]); module_invoke_all("taxonomy", "update", "vocabulary", $edit); $message = t("updated vocabulary '%name'.", array("%name" => $edit["name"])); } @@ -103,7 +103,7 @@ function taxonomy_save_vocabulary($edit) { $message = taxonomy_del_vocabulary($edit["vid"]); } else { - $data["vid"] = $edit["vid"] = db_next_id("vocabulary"); + $data["vid"] = $edit["vid"] = db_next_id("vocabulary_vid"); db_query("INSERT INTO vocabulary ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); module_invoke_all("taxonomy", "insert", "vocabulary", $edit); $message = t("created new vocabulary '%name'.", array("%name" => $edit["name"])); @@ -117,8 +117,8 @@ function taxonomy_save_vocabulary($edit) { function taxonomy_del_vocabulary($vid) { $vocabulary = taxonomy_get_vocabulary($vid); - db_query("DELETE FROM vocabulary WHERE vid = '%d'", $vid); - $result = db_query("SELECT tid FROM term_data WHERE vid = '%d'", $vid); + db_query("DELETE FROM vocabulary WHERE vid = %d", $vid); + $result = db_query("SELECT tid FROM term_data WHERE vid = %d", $vid); while ($term = db_fetch_object($result)) { taxonomy_del_term($term->tid); } @@ -188,7 +188,7 @@ function taxonomy_save_term($edit) { if ($edit["tid"] && $edit["name"]) { $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]); - db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = '%d'", $edit["tid"]); + db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = %d", $edit["tid"]); module_invoke_all("taxonomy", "update", "term", $edit); $message = t("the term '%a' has been updated.", array("%a" => $edit["name"])); } @@ -196,7 +196,7 @@ function taxonomy_save_term($edit) { return taxonomy_del_term($edit["tid"]); } else { - $edit["tid"] = db_next_id("term_data"); + $edit["tid"] = db_next_id("term_data_tid"); $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]); db_query("INSERT INTO term_data ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); module_invoke_all("taxonomy", "insert", "term", $edit); @@ -204,34 +204,34 @@ function taxonomy_save_term($edit) { } // relations (seem very powerful, but I have to understand it completely) - db_query("DELETE FROM term_relation WHERE tid1 = '%d' OR tid2 = '%d'", $edit["tid"], $edit["tid"]); + db_query("DELETE FROM term_relation WHERE tid1 = %d OR tid2 = %d", $edit["tid"], $edit["tid"]); if ($edit["relations"]) { foreach ($edit["relations"] as $related_id) { if ($related_id != 0) { - db_query("INSERT INTO term_relation (tid1, tid2) VALUES ('%d', '%d')", $edit["tid"], $related_id); + db_query("INSERT INTO term_relation (tid1, tid2) VALUES (%d, %d)", $edit["tid"], $related_id); } } } // hierarchy - db_query("DELETE FROM term_hierarchy WHERE tid = '%d'", $edit["tid"]); + db_query("DELETE FROM term_hierarchy WHERE tid = %d", $edit["tid"]); if (!isset($edit["parent"])) { $edit["parent"] = 0; } if (is_array($edit["parent"])) { foreach ($edit["parent"] as $parent) { - db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $parent); + db_query("INSERT INTO term_hierarchy (tid, parent) VALUES (%d, %d)", $edit["tid"], $parent); } } else { - db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $edit["parent"][0]); + db_query("INSERT INTO term_hierarchy (tid, parent) VALUES (%d, %d)", $edit["tid"], $edit["parent"][0]); } - db_query("DELETE FROM term_synonym WHERE tid = '%d'", $edit["tid"]); + db_query("DELETE FROM term_synonym WHERE tid = %d", $edit["tid"]); if ($edit["synonyms"]) { foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) { if ($synonym) { - db_query("INSERT INTO term_synonym (tid, name) VALUES ('%d', '%s')", $edit["tid"], chop($synonym)); + db_query("INSERT INTO term_synonym (tid, name) VALUES (%d, '%s')", $edit["tid"], chop($synonym)); } } } @@ -244,11 +244,11 @@ function taxonomy_save_term($edit) { function taxonomy_del_term($tid) { $term = taxonomy_get_term($tid); - db_query("DELETE FROM term_data WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_hierarchy WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_relation WHERE tid1 = '%d' OR tid2 = '%d'", $tid, $tid); - db_query("DELETE FROM term_synonym WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_node WHERE tid = '%d'", $tid); + db_query("DELETE FROM term_data WHERE tid = %d", $tid); + db_query("DELETE FROM term_hierarchy WHERE tid = %d", $tid); + db_query("DELETE FROM term_relation WHERE tid1 = %d OR tid2 = %d", $tid, $tid); + db_query("DELETE FROM term_synonym WHERE tid = %d", $tid); + db_query("DELETE FROM term_node WHERE tid = %d", $tid); module_invoke_all("taxonomy", "delete", "term", $term); cache_clear_all(); @@ -356,14 +356,14 @@ function taxonomy_node_form($type, $node = '') { // return 1 if node identified by $nid contains a taxonomy term identified by $tid in his body or title function taxonomy_node_has_term($nid, $tid) { - $term_name = db_result(db_query("SELECT name FROM term_data WHERE tid = '%d'", $tid)); + $term_name = db_result(db_query("SELECT name FROM term_data WHERE tid = %d", $tid)); - return db_result(db_query("SELECT COUNT(n.nid) FROM node n WHERE n.nid = '%d' AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name)); + return db_result(db_query("SELECT COUNT(n.nid) FROM node n WHERE n.nid = %d AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name)); } // return array of terms of a node beloging to a particular vocabulary identified by $vid function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") { - $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE t.tid = r.tid AND t.vid = '%d' AND r.nid = '%d' ORDER BY weight", $vid, $nid); + $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $nid); $terms = array(); while ($term = db_fetch_object($result)) { $terms[$term->$key] = $term; @@ -376,7 +376,7 @@ function taxonomy_node_get_terms($nid, $key = "tid") { static $terms; if (!isset($terms[$nid])) { - $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE r.tid = t.tid AND r.nid = '%d' ORDER BY weight, name", $nid); + $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name", $nid); $terms[$nid] = array(); while ($term = db_fetch_object($result)) { $terms[$nid][$term->$key] = $term; @@ -391,20 +391,20 @@ function taxonomy_node_save($nid, $terms) { if ($terms) { foreach ($terms as $term) { - db_query("INSERT INTO term_node (nid, tid) VALUES ('%d', '%d')", $nid, $term); + db_query("INSERT INTO term_node (nid, tid) VALUES (%d, %d)", $nid, $term); } } } // clean up terms function taxonomy_node_delete($nid) { - db_query("DELETE FROM term_node WHERE nid = '%d'", $nid); + db_query("DELETE FROM term_node WHERE nid = %d", $nid); } // relations: return array of related terms function taxonomy_get_related($tid, $key = "tid") { if ($tid) { - $result = db_query("SELECT t.*, tid1, tid2 FROM term_relation, term_data t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = '%d' OR tid2 = '%d') AND t.tid != '%d' ORDER BY weight, name", $tid, $tid, $tid); + $result = db_query("SELECT t.*, tid1, tid2 FROM term_relation, term_data t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name", $tid, $tid, $tid); $related = array(); while ($term = db_fetch_object($result)) { $related[$term->$key] = $term; @@ -419,7 +419,7 @@ function taxonomy_get_related($tid, $key = "tid") { // hierarchy: get parent terms function taxonomy_get_parents($tid, $key = "tid") { if ($tid) { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.parent = t.tid AND h.tid = '%d' ORDER BY weight, name", $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name", $tid); $parents = array(); while ($parent = db_fetch_object($result)) { $parents[$parent->$key] = $parent; @@ -434,10 +434,10 @@ function taxonomy_get_parents($tid, $key = "tid") { // hierarchy: get children function taxonomy_get_children($tid, $vid = 0, $key = "tid") { if ($vid) { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE t.vid = '%d' AND h.tid = t.tid AND h.parent = '%d' ORDER BY weight, name", $vid, $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name", $vid, $tid); } else { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.tid = t.tid AND parent = '%d' ORDER BY weight", $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.tid = t.tid AND parent = %d ORDER BY weight", $tid); } $children = array(); while ($term = db_fetch_object($result)) { @@ -456,7 +456,7 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $key = "tid if (!isset($children[$vocabulary_id])) { $children[$vocabulary_id] = array(); - $result = db_query("SELECT t.*, parent FROM term_data t, term_hierarchy h WHERE t.tid = h.tid AND t.vid = '%d' ORDER BY weight, name", $vocabulary_id); + $result = db_query("SELECT t.*, parent FROM term_data t, term_hierarchy h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name", $vocabulary_id); while ($term = db_fetch_object($result)) { $children[$vocabulary_id][$term->parent][] = $term->tid; $parents[$vocabulary_id][$term->tid][] = $term->parent; @@ -481,7 +481,7 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $key = "tid // synonyms: return array of synonyms function taxonomy_get_synonyms($tid) { if ($tid) { - $result = db_query("SELECT name FROM term_synonym WHERE tid = '%d'", $tid); + $result = db_query("SELECT name FROM term_synonym WHERE tid = %d", $tid); while ($synonym = db_fetch_array($result)) { $synonyms[] = $synonym["name"]; } @@ -573,12 +573,12 @@ function taxonomy_get_term_by_name($name) { function taxonomy_get_vocabulary($vid) { // simple cache using a static var? - return db_fetch_object(db_query("SELECT * FROM vocabulary WHERE vid = '%d'", $vid)); + return db_fetch_object(db_query("SELECT * FROM vocabulary WHERE vid = %d", $vid)); } function taxonomy_get_term($tid) { // simple cache using a static var? - return db_fetch_object(db_query("SELECT * FROM term_data WHERE tid = '%d'", $tid)); + return db_fetch_object(db_query("SELECT * FROM term_data WHERE tid = %d", $tid)); } /* diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 256e0364b..fff9cfbaf 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -95,7 +95,7 @@ function taxonomy_form_vocabulary($edit = array()) { function taxonomy_save_vocabulary($edit) { $data = array("name" => $edit["name"], "types" => @implode(",", $edit["types"]), "description" => $edit["description"], "multiple" => $edit["multiple"], "required" => $edit["required"], "hierarchy" => $edit["hierarchy"], "relations" => $edit["relations"], "weight" => $edit["weight"]); if ($edit["vid"] && $edit["name"]) { - db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = '%d'", $edit["vid"]); + db_query("UPDATE vocabulary SET ". _prepare_update($data) ." WHERE vid = %d", $edit["vid"]); module_invoke_all("taxonomy", "update", "vocabulary", $edit); $message = t("updated vocabulary '%name'.", array("%name" => $edit["name"])); } @@ -103,7 +103,7 @@ function taxonomy_save_vocabulary($edit) { $message = taxonomy_del_vocabulary($edit["vid"]); } else { - $data["vid"] = $edit["vid"] = db_next_id("vocabulary"); + $data["vid"] = $edit["vid"] = db_next_id("vocabulary_vid"); db_query("INSERT INTO vocabulary ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); module_invoke_all("taxonomy", "insert", "vocabulary", $edit); $message = t("created new vocabulary '%name'.", array("%name" => $edit["name"])); @@ -117,8 +117,8 @@ function taxonomy_save_vocabulary($edit) { function taxonomy_del_vocabulary($vid) { $vocabulary = taxonomy_get_vocabulary($vid); - db_query("DELETE FROM vocabulary WHERE vid = '%d'", $vid); - $result = db_query("SELECT tid FROM term_data WHERE vid = '%d'", $vid); + db_query("DELETE FROM vocabulary WHERE vid = %d", $vid); + $result = db_query("SELECT tid FROM term_data WHERE vid = %d", $vid); while ($term = db_fetch_object($result)) { taxonomy_del_term($term->tid); } @@ -188,7 +188,7 @@ function taxonomy_save_term($edit) { if ($edit["tid"] && $edit["name"]) { $data = array("name" => $edit["name"], "description" => $edit["description"], "weight" => $edit["weight"]); - db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = '%d'", $edit["tid"]); + db_query("UPDATE term_data SET ". _prepare_update($data) ." WHERE tid = %d", $edit["tid"]); module_invoke_all("taxonomy", "update", "term", $edit); $message = t("the term '%a' has been updated.", array("%a" => $edit["name"])); } @@ -196,7 +196,7 @@ function taxonomy_save_term($edit) { return taxonomy_del_term($edit["tid"]); } else { - $edit["tid"] = db_next_id("term_data"); + $edit["tid"] = db_next_id("term_data_tid"); $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]); db_query("INSERT INTO term_data ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2)); module_invoke_all("taxonomy", "insert", "term", $edit); @@ -204,34 +204,34 @@ function taxonomy_save_term($edit) { } // relations (seem very powerful, but I have to understand it completely) - db_query("DELETE FROM term_relation WHERE tid1 = '%d' OR tid2 = '%d'", $edit["tid"], $edit["tid"]); + db_query("DELETE FROM term_relation WHERE tid1 = %d OR tid2 = %d", $edit["tid"], $edit["tid"]); if ($edit["relations"]) { foreach ($edit["relations"] as $related_id) { if ($related_id != 0) { - db_query("INSERT INTO term_relation (tid1, tid2) VALUES ('%d', '%d')", $edit["tid"], $related_id); + db_query("INSERT INTO term_relation (tid1, tid2) VALUES (%d, %d)", $edit["tid"], $related_id); } } } // hierarchy - db_query("DELETE FROM term_hierarchy WHERE tid = '%d'", $edit["tid"]); + db_query("DELETE FROM term_hierarchy WHERE tid = %d", $edit["tid"]); if (!isset($edit["parent"])) { $edit["parent"] = 0; } if (is_array($edit["parent"])) { foreach ($edit["parent"] as $parent) { - db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $parent); + db_query("INSERT INTO term_hierarchy (tid, parent) VALUES (%d, %d)", $edit["tid"], $parent); } } else { - db_query("INSERT INTO term_hierarchy (tid, parent) VALUES ('%d', '%d')", $edit["tid"], $edit["parent"][0]); + db_query("INSERT INTO term_hierarchy (tid, parent) VALUES (%d, %d)", $edit["tid"], $edit["parent"][0]); } - db_query("DELETE FROM term_synonym WHERE tid = '%d'", $edit["tid"]); + db_query("DELETE FROM term_synonym WHERE tid = %d", $edit["tid"]); if ($edit["synonyms"]) { foreach (explode ("\n", str_replace("\r", "", $edit["synonyms"])) as $synonym) { if ($synonym) { - db_query("INSERT INTO term_synonym (tid, name) VALUES ('%d', '%s')", $edit["tid"], chop($synonym)); + db_query("INSERT INTO term_synonym (tid, name) VALUES (%d, '%s')", $edit["tid"], chop($synonym)); } } } @@ -244,11 +244,11 @@ function taxonomy_save_term($edit) { function taxonomy_del_term($tid) { $term = taxonomy_get_term($tid); - db_query("DELETE FROM term_data WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_hierarchy WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_relation WHERE tid1 = '%d' OR tid2 = '%d'", $tid, $tid); - db_query("DELETE FROM term_synonym WHERE tid = '%d'", $tid); - db_query("DELETE FROM term_node WHERE tid = '%d'", $tid); + db_query("DELETE FROM term_data WHERE tid = %d", $tid); + db_query("DELETE FROM term_hierarchy WHERE tid = %d", $tid); + db_query("DELETE FROM term_relation WHERE tid1 = %d OR tid2 = %d", $tid, $tid); + db_query("DELETE FROM term_synonym WHERE tid = %d", $tid); + db_query("DELETE FROM term_node WHERE tid = %d", $tid); module_invoke_all("taxonomy", "delete", "term", $term); cache_clear_all(); @@ -356,14 +356,14 @@ function taxonomy_node_form($type, $node = '') { // return 1 if node identified by $nid contains a taxonomy term identified by $tid in his body or title function taxonomy_node_has_term($nid, $tid) { - $term_name = db_result(db_query("SELECT name FROM term_data WHERE tid = '%d'", $tid)); + $term_name = db_result(db_query("SELECT name FROM term_data WHERE tid = %d", $tid)); - return db_result(db_query("SELECT COUNT(n.nid) FROM node n WHERE n.nid = '%d' AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name)); + return db_result(db_query("SELECT COUNT(n.nid) FROM node n WHERE n.nid = %d AND ((n.body LIKE '%%%s%%') OR (n.body LIKE '%%%s%%'))", $nid, $term_name, $term_name)); } // return array of terms of a node beloging to a particular vocabulary identified by $vid function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = "tid") { - $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE t.tid = r.tid AND t.vid = '%d' AND r.nid = '%d' ORDER BY weight", $vid, $nid); + $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $nid); $terms = array(); while ($term = db_fetch_object($result)) { $terms[$term->$key] = $term; @@ -376,7 +376,7 @@ function taxonomy_node_get_terms($nid, $key = "tid") { static $terms; if (!isset($terms[$nid])) { - $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE r.tid = t.tid AND r.nid = '%d' ORDER BY weight, name", $nid); + $result = db_query("SELECT t.* FROM term_data t, term_node r WHERE r.tid = t.tid AND r.nid = %d ORDER BY weight, name", $nid); $terms[$nid] = array(); while ($term = db_fetch_object($result)) { $terms[$nid][$term->$key] = $term; @@ -391,20 +391,20 @@ function taxonomy_node_save($nid, $terms) { if ($terms) { foreach ($terms as $term) { - db_query("INSERT INTO term_node (nid, tid) VALUES ('%d', '%d')", $nid, $term); + db_query("INSERT INTO term_node (nid, tid) VALUES (%d, %d)", $nid, $term); } } } // clean up terms function taxonomy_node_delete($nid) { - db_query("DELETE FROM term_node WHERE nid = '%d'", $nid); + db_query("DELETE FROM term_node WHERE nid = %d", $nid); } // relations: return array of related terms function taxonomy_get_related($tid, $key = "tid") { if ($tid) { - $result = db_query("SELECT t.*, tid1, tid2 FROM term_relation, term_data t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = '%d' OR tid2 = '%d') AND t.tid != '%d' ORDER BY weight, name", $tid, $tid, $tid); + $result = db_query("SELECT t.*, tid1, tid2 FROM term_relation, term_data t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name", $tid, $tid, $tid); $related = array(); while ($term = db_fetch_object($result)) { $related[$term->$key] = $term; @@ -419,7 +419,7 @@ function taxonomy_get_related($tid, $key = "tid") { // hierarchy: get parent terms function taxonomy_get_parents($tid, $key = "tid") { if ($tid) { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.parent = t.tid AND h.tid = '%d' ORDER BY weight, name", $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.parent = t.tid AND h.tid = %d ORDER BY weight, name", $tid); $parents = array(); while ($parent = db_fetch_object($result)) { $parents[$parent->$key] = $parent; @@ -434,10 +434,10 @@ function taxonomy_get_parents($tid, $key = "tid") { // hierarchy: get children function taxonomy_get_children($tid, $vid = 0, $key = "tid") { if ($vid) { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE t.vid = '%d' AND h.tid = t.tid AND h.parent = '%d' ORDER BY weight, name", $vid, $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE t.vid = %d AND h.tid = t.tid AND h.parent = %d ORDER BY weight, name", $vid, $tid); } else { - $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.tid = t.tid AND parent = '%d' ORDER BY weight", $tid); + $result = db_query("SELECT t.* FROM term_hierarchy h, term_data t WHERE h.tid = t.tid AND parent = %d ORDER BY weight", $tid); } $children = array(); while ($term = db_fetch_object($result)) { @@ -456,7 +456,7 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $key = "tid if (!isset($children[$vocabulary_id])) { $children[$vocabulary_id] = array(); - $result = db_query("SELECT t.*, parent FROM term_data t, term_hierarchy h WHERE t.tid = h.tid AND t.vid = '%d' ORDER BY weight, name", $vocabulary_id); + $result = db_query("SELECT t.*, parent FROM term_data t, term_hierarchy h WHERE t.tid = h.tid AND t.vid = %d ORDER BY weight, name", $vocabulary_id); while ($term = db_fetch_object($result)) { $children[$vocabulary_id][$term->parent][] = $term->tid; $parents[$vocabulary_id][$term->tid][] = $term->parent; @@ -481,7 +481,7 @@ function taxonomy_get_tree($vocabulary_id, $parent = 0, $depth = -1, $key = "tid // synonyms: return array of synonyms function taxonomy_get_synonyms($tid) { if ($tid) { - $result = db_query("SELECT name FROM term_synonym WHERE tid = '%d'", $tid); + $result = db_query("SELECT name FROM term_synonym WHERE tid = %d", $tid); while ($synonym = db_fetch_array($result)) { $synonyms[] = $synonym["name"]; } @@ -573,12 +573,12 @@ function taxonomy_get_term_by_name($name) { function taxonomy_get_vocabulary($vid) { // simple cache using a static var? - return db_fetch_object(db_query("SELECT * FROM vocabulary WHERE vid = '%d'", $vid)); + return db_fetch_object(db_query("SELECT * FROM vocabulary WHERE vid = %d", $vid)); } function taxonomy_get_term($tid) { // simple cache using a static var? - return db_fetch_object(db_query("SELECT * FROM term_data WHERE tid = '%d'", $tid)); + return db_fetch_object(db_query("SELECT * FROM term_data WHERE tid = %d", $tid)); } /* |