From 8b4c95b259089c54331e9a6d014495c1ec807cea Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 13 Jan 2001 16:33:19 +0000 Subject: [PATCH] - rewrote the block placement stuff and updated the themes. IMPORTANT: you have to drop 2 tables "blocks" and "layout" and you have to recreate them again with those in database/database.mysql - integrated the documentation written by UnConeD --- account.php | 19 +++----- database/database.mysql | 20 ++++---- includes/theme.inc | 19 ++------ modules/account.module | 16 ++++++- modules/affiliate-site.module | 14 +++++- modules/ban.module | 30 +++++++++++- modules/block.module | 86 ++++++++++++++++++++++++++++++++--- modules/block/block.module | 86 ++++++++++++++++++++++++++++++++--- modules/cron.module | 2 +- modules/documentation.module | 3 -- themes/marvin/marvin.theme | 7 +-- themes/unconed/unconed.theme | 7 +-- 12 files changed, 241 insertions(+), 68 deletions(-) diff --git a/account.php b/account.php index a9cd9850e2d..08af23bee4a 100644 --- a/account.php +++ b/account.php @@ -222,23 +222,16 @@ function account_content_edit() { if ($user->id) { $output .= "
\n"; - $output .= "Blocks:
\n"; + $output .= "Blocks in side bars:
\n"; $result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module"); while ($block = db_fetch_object($result)) { $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '$block->name' AND user = '$user->id'")); - - $options = ""; - for ($weight = 0; $weight < 10; $weight++) { - $options .= "\n"; - } - - $output .= ""; - $output .= "$block->name
"; + $output .= "name]\"". ($entry->user ? " CHECKED" : "") ."> $block->name
\n"; } - $output .= "You can more or less position your blocks by assigning them weights. The heavy blocks will sink down whereas the light blocks will be positioned at the top of the page.

\n"; - $output .= "
\n"; + $output .= "

Enable the blocks you would like to see displayed in the side bars.

\n"; + $output .= "

\n"; $output .= "
\n"; $theme->header(); @@ -257,8 +250,8 @@ function account_content_save($edit) { global $user; if ($user->id) { db_query("DELETE FROM layout WHERE user = $user->id"); - foreach ($edit as $block=>$weight) { - db_query("INSERT INTO layout (user, block, weight) VALUES ('". check_input($user->id) ."', '". check_input($block) ."', '". check_input($weight) ."')"); + foreach (($edit ? $edit : array()) as $block=>$weight) { + db_query("INSERT INTO layout (user, block) VALUES ('". check_input($user->id) ."', '". check_input($block) ."')"); } } } diff --git a/database/database.mysql b/database/database.mysql index ab3685850a1..699407a45a3 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -8,6 +8,16 @@ CREATE TABLE affiliates ( PRIMARY KEY (id) ); +CREATE TABLE blocks ( + name varchar(64) DEFAULT '' NOT NULL, + module varchar(64) DEFAULT '' NOT NULL, + offset tinyint(2) DEFAULT '0' NOT NULL, + status tinyint(2) DEFAULT '0' NOT NULL, + weight tinyint(1) DEFAULT '0' NOT NULL, + region tinyint(1) DEFAULT '0' NOT NULL, + PRIMARY KEY (name) +); + CREATE TABLE boxes ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, subject varchar(64) DEFAULT '' NOT NULL, @@ -30,13 +40,6 @@ CREATE TABLE bans ( PRIMARY KEY (id) ); -CREATE TABLE blocks ( - name varchar(64) DEFAULT '' NOT NULL, - module varchar(64) DEFAULT '' NOT NULL, - offset tinyint(2) DEFAULT '0' NOT NULL, - status tinyint(2) DEFAULT '0' NOT NULL, - PRIMARY KEY (name) -); CREATE TABLE channel ( id int(11) DEFAULT '0' NOT NULL auto_increment, @@ -100,8 +103,7 @@ CREATE TABLE headlines ( CREATE TABLE layout ( user int(11) DEFAULT '0' NOT NULL, - block varchar(64) DEFAULT '' NOT NULL, - weight int(11) DEFAULT '0' NOT NULL + block varchar(64) DEFAULT '' NOT NULL ); CREATE TABLE modules ( diff --git a/includes/theme.inc b/includes/theme.inc index d6a4dd3e459..4a39bc107c9 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -58,7 +58,7 @@ function theme_account($theme) { } -function theme_main_blocks($theme) { +function theme_blocks($region, $theme) { global $id, $PHP_SELF, $user; switch (strtok($PHP_SELF, ".")) { @@ -68,26 +68,13 @@ function theme_main_blocks($theme) { else theme_new_headlines($theme); break; case "/index": - theme_account($theme); - $result = db_query("SELECT * FROM blocks WHERE status = 2"); + if ($user->id) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status AND l.user = '$user->id'))". (($region == "left" || $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight"); + else $result = db_query("SELECT * FROM blocks WHERE status = 2 ORDER BY weight"); while ($block = db_fetch_object($result)) { $blocks = module_execute($block->module, "block"); $theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]); } break; - default: - theme_account($theme); - } -} - -function theme_user_blocks($theme) { - global $PHP_SELF, $repository, $user; - if ($user->id && strstr($PHP_SELF, "index.php")) { - $result = db_query("SELECT * FROM layout l LEFT JOIN blocks b ON l.block = b.name WHERE l.user = '$user->id' AND l.weight > 0 AND b.status = '1' ORDER BY weight"); - while ($block = db_fetch_object($result)) { - $blocks = module_execute($block->module, "block"); - $theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]); - } } } diff --git a/modules/account.module b/modules/account.module index efcbc9ac181..4d382ccf49c 100644 --- a/modules/account.module +++ b/modules/account.module @@ -1,8 +1,17 @@ "account_cron", +$module = array("help" => "account_help", + "cron" => "account_cron", "admin" => "account_admin"); +function account_help() { + ?> +

The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access rights, password retrieval, user settings and much more.

+

The required administration can be accomplished through the "account" interface of the administration section. From here administrators can get a quick overview of all registered users and view/edit specific accounts using the links provided. Some useful operations include blocking specific accounts (e.g. a troublesome user) and giving/taking administration permissions. Note that you should only give these permissions to people you trust!

+

Check the documentation page for detailed information about user management.

+ overview | help
\n"; + switch ($op) { case "edit": account_edit($name); break; + case "help": + account_help(); + break; case "view": account_view($name); break; diff --git a/modules/affiliate-site.module b/modules/affiliate-site.module index dcb850070b0..42c95c6167d 100644 --- a/modules/affiliate-site.module +++ b/modules/affiliate-site.module @@ -1,8 +1,15 @@ "affiliate_block", +$module = array("help" => "affiliate_help", + "block" => "affiliate_block", "admin" => "affiliate_admin"); +function affiliate_help() { + ?> +

This is a small module to manage related and/or affiliate sites. The module exports 2 different blocks with links to the affiliate sites.

+ overview | help
\n"; + switch($op) { case "Add affiliate": affiliate_admin_add($name, $link, $contact); @@ -86,6 +95,9 @@ function affiliate_admin() { affiliate_admin_del($id); affiliate_admin_display(); break; + case "help": + affiliate_help(); + break; default: affiliate_admin_display(); } diff --git a/modules/ban.module b/modules/ban.module index 05f3efcdd46..f602c177f72 100644 --- a/modules/ban.module +++ b/modules/ban.module @@ -1,10 +1,33 @@ "ban_admin"); +$module = array("help" => "ban_help", + "admin" => "ban_admin"); include "includes/ban.inc"; +function ban_help() { + ?> +

The ban module keeps a list of bans in four categories:

+ +

The ban system allows you to use a flexible wild-card ban system. This means you can block all email addresses from a certain domain name, block every username starting with "guest", etc. To do this, you can use the following wild-card characters:

+ +

Examples:

+ + add ban | check ban | overview
\n"; + print "add ban | check ban | overview | help
\n"; switch ($op) { case "Add ban": @@ -110,6 +133,9 @@ function ban_admin() { case "add": ban_admin_add(); break; + case "help": + ban_help(); + break; case "check": ban_admin_check(); break; diff --git a/modules/block.module b/modules/block.module index 3b1068a9991..ce994d704c3 100644 --- a/modules/block.module +++ b/modules/block.module @@ -1,8 +1,18 @@ "block_page", + "help" => "block_help", "admin" => "block_admin"); +function block_help() { + ?> +

Blocks are the boxes visible in the side bars on the left and the right-hand side of the website. They are either exported by the engine or by any of the available modules. To really get your teeth in a drupal website, you are going to have to deal with blocks and administrating blocks in a fairly sophisticated fashion. This means you are going to have to be sensitive to the way the block placement strategy works.

+

The placement of blocks is delegated to the administrator but for most blocks, i.e. those called "custom blocks", the sole force behind enabling and disabling them is the user itself.

+

An administrator can lay out and arrange the available blocks to fit in two regions: "left" and "right". Regions simply contain blocks. In addition, an administrator can assign each block (within a region) a weight to sort them vertically. The heavy blocks will sink down whereas the light blocks will be positioned at the top.

+

As mentioned above, blocks can be arranged to fit in two regions: left and right. For theme builders, each region is identified by a corresponding constant: "left" and "right".

+ $value) { - db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'"); + db_query("UPDATE blocks SET region = '$value[region]', status = '$value[status]', weight = '$value[weight]' WHERE name = '$key'"); } } @@ -37,20 +47,33 @@ function block_admin_display() { // Generate output: $output .= "
\n"; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($block = db_fetch_object($result)) { $module = ($repository[$block->module]["admin"]) ? "module\">$block->module" : $block->module; - $status .= "name][status]\">\n"; $status .= " \n"; $status .= " \n"; $status .= " \n"; $status .= "\n"; - $output .= " \n"; + $weight .= "\n"; + + $region .= "\n"; + + $output .= " \n"; unset($status); + unset($weight); + unset($region); } $output .= "
blockmodulestatus
blockmodulestatusweightregion
". $block->name ."$module$status
". $block->name ."$module$status$weight$region
\n"; @@ -60,16 +83,67 @@ function block_admin_display() { print $output; } +function block_admin_overview() { + global $site_name; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight"); + $lblocks .= "\n"; + while ($block = db_fetch_object($result)) $lblocks .= " \n"; + $lblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight"); + $rblocks .= "\n"; + while ($block = db_fetch_object($result)) $rblocks .= " \n"; + $rblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $output .= "

layout 1:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
\n". ($lblocks ? $lblocks : " ") ." \n". ($rblocks ? $rblocks : " ") ."
$site_name footer
\n"; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight"); + $blocks .= "\n"; + while ($block = db_fetch_object($result)) $blocks .= " \n"; + $blocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $output .= "

layout 2:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
 \n". ($blocks ? $blocks : " ") ."
$site_name footer
\n"; + + $output .= "

layout 3:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
\n". ($blocks ? $blocks : " ") ." 
$site_name footer
\n"; + + print $output; +} + function block_admin() { global $op, $edit; + + print "configure | overview | help
\n"; switch ($op) { + case "help": + block_help(); + break; + case "overview": + block_admin_overview(); + break; case "Save blocks": block_admin_save($edit); - break; + // fall through + default: + block_admin_display(); } - block_admin_display(); } ?> diff --git a/modules/block/block.module b/modules/block/block.module index 3b1068a9991..ce994d704c3 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -1,8 +1,18 @@ "block_page", + "help" => "block_help", "admin" => "block_admin"); +function block_help() { + ?> +

Blocks are the boxes visible in the side bars on the left and the right-hand side of the website. They are either exported by the engine or by any of the available modules. To really get your teeth in a drupal website, you are going to have to deal with blocks and administrating blocks in a fairly sophisticated fashion. This means you are going to have to be sensitive to the way the block placement strategy works.

+

The placement of blocks is delegated to the administrator but for most blocks, i.e. those called "custom blocks", the sole force behind enabling and disabling them is the user itself.

+

An administrator can lay out and arrange the available blocks to fit in two regions: "left" and "right". Regions simply contain blocks. In addition, an administrator can assign each block (within a region) a weight to sort them vertically. The heavy blocks will sink down whereas the light blocks will be positioned at the top.

+

As mentioned above, blocks can be arranged to fit in two regions: left and right. For theme builders, each region is identified by a corresponding constant: "left" and "right".

+ $value) { - db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'"); + db_query("UPDATE blocks SET region = '$value[region]', status = '$value[status]', weight = '$value[weight]' WHERE name = '$key'"); } } @@ -37,20 +47,33 @@ function block_admin_display() { // Generate output: $output .= "\n"; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($block = db_fetch_object($result)) { $module = ($repository[$block->module]["admin"]) ? "module\">$block->module" : $block->module; - $status .= "name][status]\">\n"; $status .= " \n"; $status .= " \n"; $status .= " \n"; $status .= "\n"; - $output .= " \n"; + $weight .= "\n"; + + $region .= "\n"; + + $output .= " \n"; unset($status); + unset($weight); + unset($region); } $output .= "
blockmodulestatus
blockmodulestatusweightregion
". $block->name ."$module$status
". $block->name ."$module$status$weight$region
\n"; @@ -60,16 +83,67 @@ function block_admin_display() { print $output; } +function block_admin_overview() { + global $site_name; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight"); + $lblocks .= "\n"; + while ($block = db_fetch_object($result)) $lblocks .= " \n"; + $lblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 1 ORDER BY weight"); + $rblocks .= "\n"; + while ($block = db_fetch_object($result)) $rblocks .= " \n"; + $rblocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $output .= "

layout 1:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
\n". ($lblocks ? $lblocks : " ") ." \n". ($rblocks ? $rblocks : " ") ."
$site_name footer
\n"; + + $result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight"); + $blocks .= "\n"; + while ($block = db_fetch_object($result)) $blocks .= " \n"; + $blocks .= "
". ($block->status == 2 ? "$block->name" : $block->name) ."$block->weight
\n"; + + $output .= "

layout 2:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
 \n". ($blocks ? $blocks : " ") ."
$site_name footer
\n"; + + $output .= "

layout 3:

\n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
$site_name header
\n". ($blocks ? $blocks : " ") ." 
$site_name footer
\n"; + + print $output; +} + function block_admin() { global $op, $edit; + + print "configure | overview | help
\n"; switch ($op) { + case "help": + block_help(); + break; + case "overview": + block_admin_overview(); + break; case "Save blocks": block_admin_save($edit); - break; + // fall through + default: + block_admin_display(); } - block_admin_display(); } ?> diff --git a/modules/cron.module b/modules/cron.module index dab94675036..67a147a7c0f 100644 --- a/modules/cron.module +++ b/modules/cron.module @@ -7,7 +7,7 @@ function cron_help() { ?>

Cron (which stands for chronograph) is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of n seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.

Note that cron does not guarantee that the commands will be executed at the specified interval. However, the engine will make sure that the commands are run at the specified intervals as closely as possible.

-

Check the documentation for more information about cron and how to setup it correctly.

+

Check the documentation page for more information about cron and how to setup it correctly.

While we in no way consider the design and implementation of the drupal engine to be finished, we feel that our own accompanying intensive experience has given us a fairly stable and well-proven design. The following provides a brief over-view of the different aspects of drupal's core engine and features.

-

Blocks

-

Blocks are the side-boxes of the site that provide the main interface to the engine. They can be fully customized by an administrator to suit his or her needs. (Full documentation still under construction)

-

Cron

Cron (which stands for chronograph) is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of n seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.

diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index ba7c1c64ee6..858752d0a38 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -221,11 +221,8 @@ diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme index f91db81c3ad..758d5193bcb 100644 --- a/themes/unconed/unconed.theme +++ b/themes/unconed/unconed.theme @@ -282,11 +282,8 @@