Commit 3c2dc18c authored by Dries's avatar Dries

- Fixed bug #1545: incorrect sequence tables on PostgreSQL. Patch by Neil.

  In addition, I have updated update.php so it makes the corresponding
  changes for MySQL users.
parent b85cf719
......@@ -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>";
......
......@@ -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>";
......
This diff is collapsed.
This diff is collapsed.
......@@ -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>";
......
......@@ -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];
}
......
......@@ -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];
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -63,7 +63,8 @@
"2003-01-03" => "update_48",
"2003-01-05" => "update_49",
"2003-01-15" => "update_50",
"2003-04-19" => "update_51"
"2003-04-19" => "update_51",
"2003-04-20" => "update_52"
);
// Update functions
......@@ -684,6 +685,25 @@ function update_51() {
update_sql("ALTER TABLE blocks CHANGE delta delta varchar(32) NOT NULL default '0'");
}
function update_52() {
update_sql("UPDATE sequences SET name = 'comments_cid' WHERE name = 'comments';");
update_sql("UPDATE sequences SET name = 'node_nid' WHERE name = 'node';");
update_sql("DELETE FROM sequences WHERE name = 'import'");
update_sql("DELETE FROM sequences WHERE name = 'bundle_bid'"); // in case we would run this entry twice
update_sql("DELETE FROM sequences WHERE name = 'feed_fid'"); // in case we would run this entry twice
$bundles = db_result(db_query("SELECT MAX(bid) FROM bundle;"));
update_sql("INSERT INTO sequences (name, id) VALUES ('bundle_bid', '$bundles')");
$feeds = db_result(db_query("SELECT MAX(fid) FROM feed;"));
update_sql("INSERT INTO sequences (name, id) VALUES ('feed_fid', '$feeds')");
update_sql("UPDATE sequences SET name = 'vocabulary_vid' WHERE name = 'vocabulary';");
update_sql("UPDATE sequences SET name = 'term_data_tid' WHERE name = 'term_data'");
}
function update_upgrade3() {
update_sql("INSERT INTO system VALUES ('archive.module','archive','module','',1)");
update_sql("INSERT INTO system VALUES ('block.module','block','module','',1)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment