diff --git a/account.php b/account.php
index 070eb3fa7a4..42ac229ed57 100644
--- a/account.php
+++ b/account.php
@@ -266,6 +266,13 @@ function account_content_save($edit) {
function account_user($uname) {
global $user, $theme;
+ function module($name, $module, $username) {
+ global $theme;
+ if ($module["user"] && $block = $module["user"]($username, "user", "view")) {
+ if ($block["content"]) $theme->box($block["subject"], $block["content"]);
+ }
+ }
+
if ($user->id && $user->userid == $uname) {
$output .= "
\n";
$output .= "
User ID:
$user->userid
\n";
@@ -300,17 +307,11 @@ function account_user($uname) {
$comments++;
}
- $result = db_query("SELECT d.* FROM diaries d LEFT JOIN users u ON u.id = d.author WHERE u.userid = '$uname' AND d.timestamp > ". (time() - 1209600) ." ORDER BY id DESC LIMIT 2");
- while ($diary = db_fetch_object($result)) {
- $block3 .= "
\n";
- $diaries++;
- }
-
// Display account information:
$theme->header();
if ($block1) $theme->box("User information for $uname", $block1);
if ($block2) $theme->box("$uname has posted ". format_plural($comments, "comment", "comments") ." recently", $block2);
- if ($block3) $theme->box("$uname has posted ". format_plural($diaries, "diary entry", "diary entries") ." recently", $block3);
+ module_iterate("module", $uname);
$theme->footer();
}
else {
diff --git a/database/database.mysql b/database/database.mysql
index cecc968f770..14e8325ba01 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -1,11 +1,3 @@
-CREATE TABLE admin_blocks (
- id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
- subject varchar(64) DEFAULT '' NOT NULL,
- content text,
- info varchar(128) DEFAULT '' NOT NULL,
- link varchar(128) DEFAULT '' NOT NULL,
- PRIMARY KEY (id)
-);
CREATE TABLE affiliates (
id int(11) DEFAULT '0' NOT NULL auto_increment,
@@ -16,6 +8,18 @@ CREATE TABLE affiliates (
PRIMARY KEY (id)
);
+CREATE TABLE boxes (
+ id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
+ subject varchar(64) DEFAULT '' NOT NULL,
+ content text,
+ info varchar(128) DEFAULT '' NOT NULL,
+ link varchar(128) DEFAULT '' NOT NULL,
+ type tinyint(2) DEFAULT '0' NOT NULL,
+ UNIQUE subject (subject),
+ UNIQUE info (info),
+ PRIMARY KEY (id)
+);
+
CREATE TABLE bans (
id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
mask varchar(255) DEFAULT '' NOT NULL,
@@ -76,6 +80,15 @@ CREATE TABLE diaries (
PRIMARY KEY (id)
);
+CREATE TABLE drupals (
+ id int(11) DEFAULT '0' NOT NULL auto_increment,
+ link varchar(255) DEFAULT '' NOT NULL,
+ name varchar(255) DEFAULT '' NOT NULL,
+ contact varchar(255) DEFAULT '' NOT NULL,
+ UNIQUE link (link),
+ PRIMARY KEY (id)
+);
+
CREATE TABLE headlines (
id int(11) DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
diff --git a/includes/module.inc b/includes/module.inc
index 826e415b4ca..e52f612e15e 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -1,9 +1,9 @@
-function module_iterate($function) {
+function module_iterate($function, $argument = "") {
global $repository;
foreach ($repository as $name=>$module) {
- $function($name, $module);
+ $function($name, $module, $argument);
}
}
@@ -25,8 +25,8 @@ function module_rehash_crons($name, $module) {
function module_rehash_blocks($name, $module) {
db_query("DELETE FROM blocks WHERE module = '$name'");
- if ($module["block"]) {
- foreach ($blocks = $module["block"]() as $offset=>$block) {
+ if ($module["block"] && $blocks = $module["block"]()) {
+ foreach ($blocks as $offset=>$block) {
db_query("INSERT INTO blocks (name, module, offset) VALUES ('". check_input($block["info"]) ."', '". check_input($name) ."', '". check_input($offset) ."')");
}
}
diff --git a/modules/admin-block.module b/modules/admin-block.module
deleted file mode 100644
index 7f7f44ffafa..00000000000
--- a/modules/admin-block.module
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-$module = array("help" => "ab_help",
- "block" => "ab_block",
- "admin" => "ab_admin");
-
-function ab_help() {
- ?>
-
The content of the site can be almost entirely altered through blocks. Simply put, admin blocks are small bits of PHP code which will get plugged into the site. Admin blocks are typically used to add custom blocks to the site.
-
If you know how to script in PHP, admin blocks are pretty easy to create. Don't worry if you're no PHP-wizard: simply use the standard admin blocks (i.e. those available by default) as they are just fine or ask an expert 'admin blocker' to help you create custom admin blocks that fit your needs.
-
Each admin block consists of a subject and an associated block of PHP code which can be as long as you want it to be and that will 'render' the content of the block. You can use any piece of PHP code to make up an admin block. An admin block's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.
-
There are however some factors to keep in mind when using and creating admin blocks: admin blocks can be extremly useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or even with the site engine for that matter, avoid experimenting with admin blocks because you can - and you probably will - corrupt your database or even render your site unusable! If you don't plan to do fancy stuff with admin blocks then you're probably safe though.
-
Remember that the code within each admin block must be valid PHP code, including things like terminating statements with a semicolon so the parser won't die. Therefore, it is highly recommended to test your admin blocks seperatly using a simple test script on top of a test database before migrating to your production environment running your real database.
-
Note that you can use global variables such as configuration parameters within the scope of an admin block. Also keep in mind that variables that have been given values in an admin block will retain these values in the engine or module afterwards.
-
You can use the return statement to return the actual content of the block as well.
-
A basic example:
-
Given the admin block with subject "Welcome", used to create a Welcome-block. The content for this admin block could be created by using:
For a more in-depth example, we recommend you check the existing default admin blocks and use them as a start.
-
As mentioned above, you can virtually use any piece of PHP code in an admin block: you can declare and use functions, consult the SQL database, access configuration settings and so on.
The content of the site can be almost entirely altered through boxes. Simply put, boxes are small bits of text, HTML or PHP code which will get plugged into the site just like any other block. Boxes are typically used to add custom blocks to the site.
+
Each box consists of a subject and an associated block of text, HTML or PHP code which can be as long as you want it to be and that will 'render' the content of the box.
+
PHP boxes
+
If you know how to script in PHP, PHP boxes are pretty easy to create. Don't worry if you're no PHP-wizard: simply use ASCII or HTML boxes instead.
+
You can use any piece of PHP code to make up the content of a PHP box: this implies that you can declare and use functions, consult the SQL database, access configuration settings and much more. A PHP box's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.
+
There are however some factors to keep in mind when using and creating PHP boxes: PHP boxes can be extremly useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or even with the site engine for that matter, avoid experimenting with PHP boxes because you can - and you probably will - corrupt your database or even render your site unusable! If you don't plan to do fancy stuff with boxes then you're probably better off with ASCII or HTML boxes.
+
Remember that the code within each PHP box must be valid PHP code, including things like terminating statements with a semicolon so the parser won't die. Therefore, it is highly recommended to test your boxes seperatly using a simple test script on top of a test database before migrating to your production environment running your real database.
+
Note that you can use global variables such as configuration parameters within the scope of a PHP box. Also keep in mind that variables that have been given values in a PHP box will retain these values in the engine or module afterwards.
+
You can use the return statement to return the actual content for your block as well.
+
A basic example:
+
Given the box with subject "Welcome", used to create a "Welcome"-box. The content for this box could be created by using:
1. We assume that you have some working experience with Apache, MySQL and PHP. If you still need to install Apache, MySQL or PHP, please install them now. The installation of these required packages is beyond the scope of this document but make sure your Apache is setup to allow .htaccess files so that drupal can override Apache options from within the drupal directories.
-
2. Unzip the distribution tarball into the directory you want to serve web files from:
+
1. Download the distribution tarball and unzip it into the directory you want to serve web files from:
$ tar -zxvf drupal-x.x.x.tar.gz
+
2. We assume that you have some working experience with Apache, MySQL and PHP. In order to set up your drupal site correctly, you'll first have to get Apache, MySQL and PHP working together. So if you still need to install Apache, MySQL or PHP, please install them now. Otherwise, head on to point 3. The installation of these required packages is beyond the scope of this document but what follows are some brief guidelines to get you started.
+
Installing MySQL shouldn't be too much of a burden, when using a Linux distribution that can handle RPMs. All you have to do is grab the RMPs from the MySQL website. Please do note that you'll also need the MySQL client RPM, not only the MySQL server one. Once MySQL has been installed, download Apache and PHP, and unpack them in the same directory. To install Apache together with PHP and MySQL, follow the "quick install"-instructions in the INSTALL-file located in your PHP directory. When configuring PHP do not forget to replace 'apache_1.3.x' with your version of Apache. This may sound silly but it got me twice.
+
After the compilation process you have to set the DocumentRoot in Apache's httpd.conf to the path of your drupal-directory. Make sure your Apache is setup to allow .htaccess files so drupal can override Apache options from within the drupal directories. Therefore, set AllowOverride to "All" instead of "None". Somewhat down httpd.conf they ask you to set Directory to whatever you set DocumentRoot to. The last thing to do is to add index.php in IfModule mod_dir.c behind DirectoryIndex. Apache will then look for index.php in the DocumentRoot and will display it as its main page.
3. Create a MySQL database for your drupal site (if you haven't already):
-
$ mysqladmin create <database>
+
$ mysqladmin create <database>
Make sure to consult the MySQL documentation on how to setup the correct access rights and permissions in your MySQL grant tables.
4. Once you have a proper database, dump the required tables into your database:
-
$ mysql -h <hostname> -u <username> -p<password> <database> < database/database.mysql
+
$ mysql -h <hostname> -u <username> -p<password> <database> < database/database.mysql
5. Copy the file includes/hostname.conf to match your server's hostname:
6. Edit your configuration file to set the required settings such as the database options and to customize your site to your likings.
@@ -168,6 +170,10 @@ function documentation() {
page
If a module requires its own page it should provide a function named module_page. The page can then be publicly accessed via http://yourdomain.com/module.php?mod=module which will cause the engine to invoke module_page in order to generate the module's page.
+
+
user
+
+
Even though we aim towards modularity, a basic rule is to avoid defined interfaces. We are exceptionally careful when it comes down to adding hooks because once you give a hook to developers they will start coding to it and once somebody's using it, you are stuck with it.
diff --git a/modules/drupal-site.module b/modules/drupal-site.module
new file mode 100644
index 00000000000..8a50cb9526a
--- /dev/null
+++ b/modules/drupal-site.module
@@ -0,0 +1,94 @@
+
+
+$module = array("block" => "drupal_block",
+ "admin" => "drupal_admin");
+
+function drupal_block() {
+ global $site_url;
+
+ $result = db_query("SELECT * FROM drupals ORDER BY name");
+
+ $content .= "\n";
+
+ $content .= "