Commit b85cf719 authored by Dries's avatar Dries

- Applied modified version of Al's "block delta" patch. I left out the

  blogroll feature as I think it would get very confusing.  I don't mind
  to add it but it need some thought and documentation as it somewhat
  conflicts with the existing cloud module.

  These changes require you to run update.php.
parent 6bc00ed3
......@@ -25,7 +25,7 @@ GO
CREATE TABLE [dbo].[blocks] (
[module] [varchar] (64) NOT NULL ,
[delta] [smallint] NOT NULL ,
[delta] [varchar] (32) NOT NULL ,
[status] [smallint] NOT NULL ,
[weight] [smallint] NOT NULL ,
[region] [smallint] NOT NULL ,
......
......@@ -47,7 +47,7 @@ CREATE TABLE authmap (
CREATE TABLE blocks (
module varchar(64) DEFAULT '' NOT NULL,
delta tinyint(2) DEFAULT '0' NOT NULL,
delta varchar(32) NOT NULL default '0',
status tinyint(2) DEFAULT '0' NOT NULL,
weight tinyint(1) DEFAULT '0' NOT NULL,
region tinyint(1) DEFAULT '0' NOT NULL,
......
......@@ -45,7 +45,7 @@ CREATE TABLE authmap (
CREATE TABLE blocks (
module varchar(64) NOT NULL default '',
delta smallint NOT NULL default '0',
delta varchar(32) NOT NULL default '0',
status smallint NOT NULL default '0',
weight smallint NOT NULL default '0',
region smallint NOT NULL default '0',
......
......@@ -105,27 +105,30 @@ function import_block($op, $delta) {
if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
}
else {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $delta));
if ($feed) {
$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>";
}
else {
// it was a bundle. this is NOT elegant
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $delta));
$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>";
list($type, $id) = split(":", $delta);
switch ($type) {
case "feed":
$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));
$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;
}
return $block;
......@@ -138,9 +141,11 @@ function import_get_bundles($attributes = 0) {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["subject"] = $bundle->title;
$block[$bundle->bid]["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>";
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["subject"] = $bundle->title;
$block["bundle:$bundle->bid"]["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>";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
return $block;
......@@ -152,9 +157,11 @@ function import_get_feeds($attributes = 0) {
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["subject"] = $feed->title;
$block[$feed->fid]["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>";
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["subject"] = $feed->title;
$block["feed:$feed->fid"]["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>";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
......
......@@ -105,27 +105,30 @@ function import_block($op, $delta) {
if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
}
else {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $delta));
if ($feed) {
$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>";
}
else {
// it was a bundle. this is NOT elegant
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $delta));
$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>";
list($type, $id) = split(":", $delta);
switch ($type) {
case "feed":
$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));
$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;
}
return $block;
......@@ -138,9 +141,11 @@ function import_get_bundles($attributes = 0) {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["subject"] = $bundle->title;
$block[$bundle->bid]["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>";
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["subject"] = $bundle->title;
$block["bundle:$bundle->bid"]["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>";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
return $block;
......@@ -152,9 +157,11 @@ function import_get_feeds($attributes = 0) {
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["subject"] = $feed->title;
$block[$feed->fid]["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>";
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["subject"] = $feed->title;
$block["feed:$feed->fid"]["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>";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
......
......@@ -77,7 +77,8 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%d'", $block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -118,7 +119,8 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%d', '%d', '%d', '%d', '%s', '%d')", $block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', '%d', '%d', '%d', '%s', '%d')",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......
......@@ -77,7 +77,8 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%d'", $block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -118,7 +119,8 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%d', '%d', '%d', '%d', '%s', '%d')", $block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', '%d', '%d', '%d', '%s', '%d')",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......
......@@ -105,27 +105,30 @@ function import_block($op, $delta) {
if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
}
else {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $delta));
if ($feed) {
$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>";
}
else {
// it was a bundle. this is NOT elegant
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $delta));
$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>";
list($type, $id) = split(":", $delta);
switch ($type) {
case "feed":
$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));
$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;
}
return $block;
......@@ -138,9 +141,11 @@ function import_get_bundles($attributes = 0) {
$result = db_query("SELECT * FROM bundle ORDER BY title");
while ($bundle = db_fetch_object($result)) {
$block[$bundle->bid]["subject"] = $bundle->title;
$block[$bundle->bid]["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>";
$block[$bundle->bid]["info"] = "$bundle->title bundle";
$block["bundle:$bundle->bid"]["subject"] = $bundle->title;
$block["bundle:$bundle->bid"]["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>";
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}
return $block;
......@@ -152,9 +157,11 @@ function import_get_feeds($attributes = 0) {
$result = db_query("SELECT * FROM feed ORDER BY fid");
while ($feed = db_fetch_object($result)) {
$block[$feed->fid]["subject"] = $feed->title;
$block[$feed->fid]["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>";
$block[$feed->fid]["info"] = "$feed->title feed";
$block["feed:$feed->fid"]["subject"] = $feed->title;
$block["feed:$feed->fid"]["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>";
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
return $block;
......
......@@ -62,7 +62,8 @@
"2002-12-29" => "update_47",
"2003-01-03" => "update_48",
"2003-01-05" => "update_49",
"2003-01-15" => "update_50"
"2003-01-15" => "update_50",
"2003-04-19" => "update_51"
);
// Update functions
......@@ -679,6 +680,10 @@ function update_50() {
update_sql("ALTER TABLE forum ADD INDEX (tid)");
}
function update_51() {
update_sql("ALTER TABLE blocks CHANGE delta delta varchar(32) NOT NULL default '0'");
}
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