diff options
author | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2002-01-09 14:35:40 +0000 |
---|---|---|
committer | Kjartan Mannes <kjartan@2.no-reply.drupal.org> | 2002-01-09 14:35:40 +0000 |
commit | 3b5c38061140bb4569779728d9ff119a5a3ed6cf (patch) | |
tree | f52fe19cec7774f917b516a3910c6fcb216dd5d6 /includes | |
parent | c71e1339584173f47cb7c1869426ef3cf9639ef3 (diff) | |
download | brdo-3b5c38061140bb4569779728d9ff119a5a3ed6cf.tar.gz brdo-3b5c38061140bb4569779728d9ff119a5a3ed6cf.tar.bz2 |
Session
- attempted to fixed crashes with the custom session handler.
External SMTP library
- added functionality to have Drupal not use the default PHP mail()
function. For more info see: http://www.drupal.org/node.php?id=44
Note: for this to work all modules that send mails should use the
Drupal function to send mail:
user_mail($mail, $subject, $message, $header);
Calendar
- added an archive page which users can use to find archives instead of
the good old block.
Miscellaneous
- fixed a "random" offset bug on module.inc that occurred on Windows.
All of this needs more testing, and further suggestions are welcome.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/module.inc | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/includes/module.inc b/includes/module.inc index be1f7fe9f..389593b81 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -1,98 +1,98 @@ -<?php -// $Id$ - -// initialize modules: -function module_init() { - module_list(); -} - -// apply function $function to every known module: -function module_iterate($function, $argument = "") { - foreach (module_list() as $name) $function($name, $argument); -} - -// invoke hook $hook of module $name with optional arguments: -function module_invoke($name, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { - $function = $name ."_". $hook; - if (function_exists($function)) { - return $function($a1, $a2, $a3, $a4); - } -} - -// return array of module names (includes lazy module loading): -function module_list() { - static $list; - - if (!$list) { - if ($handle = @opendir("modules")) { - $list = array(); - while ($file = readdir($handle)) { - if (".module" == substr($file, -7)) { - $filename = substr($file, 0, -7); - include "modules/$filename.module"; - $list[$filename] = $filename; - } - } - closedir($handle); - asort($list); - } - else { - $list = array(); - } - } - - return $list; -} - -// return 1 if module $name exists, 0 otherwise: -function module_exist($name) { - $list = module_list(); - return ($list[$name]) ? 1 : 0; -} - -// return 1 if module $name implements hook $hook, 0 otherwise: -function module_hook($name, $hook) { - return function_exists($name ."_". $hook); -} - -// rehash module-exported blocks: -function module_rehash_blocks($name) { - db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'"); - - if ($blocks = module_invoke($name, "block")) { - foreach ($blocks as $delta => $block) { - foreach ($block as $item => $data) { - $block[$item] = addslashes($data); - } - if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) { - db_query("INSERT INTO blocks (name, module, delta) VALUES ('$block[info]', '$name', '$delta')"); - } - else { - db_query("UPDATE blocks SET delta = '$delta', remove = '0' WHERE module = '$name' AND name = '$block[info]'"); - } - } - } - - db_query("DELETE FROM blocks WHERE module = '$name' AND remove = '1'"); -} - -// rehash a module: -function module_rehash($name) { - if (module_exist($name)) { - $result = db_query("SELECT * FROM modules WHERE name = '$name'"); - - if (!$object = db_fetch_object($result)) { - db_query("INSERT INTO modules (name) VALUES ('$name')"); - } - - // rehash module-exported blocks (if necessary): - module_rehash_blocks($name); - } - else { - // remove all reference to module: - db_query("DELETE FROM modules WHERE name = '$name'"); - db_query("DELETE FROM blocks WHERE module = '$name'"); - } -} - -?> +<?php
+// $Id$
+
+// initialize modules:
+function module_init() {
+ module_list();
+}
+
+// apply function $function to every known module:
+function module_iterate($function, $argument = "") {
+ foreach (module_list() as $name) $function($name, $argument);
+}
+
+// invoke hook $hook of module $name with optional arguments:
+function module_invoke($name, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
+ $function = $name ."_". $hook;
+ if (function_exists($function)) {
+ return $function($a1, $a2, $a3, $a4);
+ }
+}
+
+// return array of module names (includes lazy module loading):
+function module_list() {
+ static $list;
+
+ if (!$list) {
+ if ($handle = @opendir("modules")) {
+ $list = array();
+ while ($file = readdir($handle)) {
+ if (".module" == substr($file, -7)) {
+ $filename = substr($file, 0, -7);
+ $list[$filename] = $filename;
+ include "modules/$filename.module";
+ }
+ }
+ closedir($handle);
+ asort($list);
+ }
+ else {
+ $list = array();
+ }
+ }
+
+ return $list;
+}
+
+// return 1 if module $name exists, 0 otherwise:
+function module_exist($name) {
+ $list = module_list();
+ return ($list[$name]) ? 1 : 0;
+}
+
+// return 1 if module $name implements hook $hook, 0 otherwise:
+function module_hook($name, $hook) {
+ return function_exists($name ."_". $hook);
+}
+
+// rehash module-exported blocks:
+function module_rehash_blocks($name) {
+ db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'");
+
+ if ($blocks = module_invoke($name, "block")) {
+ foreach ($blocks as $delta => $block) {
+ foreach ($block as $item => $data) {
+ $block[$item] = addslashes($data);
+ }
+ if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '$block[info]'"))) {
+ db_query("INSERT INTO blocks (name, module, delta) VALUES ('$block[info]', '$name', '$delta')");
+ }
+ else {
+ db_query("UPDATE blocks SET delta = '$delta', remove = '0' WHERE module = '$name' AND name = '$block[info]'");
+ }
+ }
+ }
+
+ db_query("DELETE FROM blocks WHERE module = '$name' AND remove = '1'");
+}
+
+// rehash a module:
+function module_rehash($name) {
+ if (module_exist($name)) {
+ $result = db_query("SELECT * FROM modules WHERE name = '$name'");
+
+ if (!$object = db_fetch_object($result)) {
+ db_query("INSERT INTO modules (name) VALUES ('$name')");
+ }
+
+ // rehash module-exported blocks (if necessary):
+ module_rehash_blocks($name);
+ }
+ else {
+ // remove all reference to module:
+ db_query("DELETE FROM modules WHERE name = '$name'");
+ db_query("DELETE FROM blocks WHERE module = '$name'");
+ }
+}
+
+?>
|