-
Dries Buytaert authored
- node.module: + Changed node_form() to use good ol' tables instead of div/CSS-tags. + Revised the "revision API": I think we have both an easy and powerful API now that should make everyone happy. + Improved the usability of the rollback functionality a bit. + Removed the "view node" link from the "node overview" page in the admin section and added a "delete node" link instead. + Added a few missing translations; there might be missing more translations though. - book.module: + Made the book module use the "revision API" instead of having it poke and use the innards and underlying details of the revision system. - queue.module: + Made the queue module use the improved revision number. - module.inc: + Applied Moshe's patch: added more arguments to module_invoke() - mail-to-sql.pl: + Added support for more header fields and for folded fields Notes: - no database updates required
Dries Buytaert authored- node.module: + Changed node_form() to use good ol' tables instead of div/CSS-tags. + Revised the "revision API": I think we have both an easy and powerful API now that should make everyone happy. + Improved the usability of the rollback functionality a bit. + Removed the "view node" link from the "node overview" page in the admin section and added a "delete node" link instead. + Added a few missing translations; there might be missing more translations though. - book.module: + Made the book module use the "revision API" instead of having it poke and use the innards and underlying details of the revision system. - queue.module: + Made the queue module use the improved revision number. - module.inc: + Applied Moshe's patch: added more arguments to module_invoke() - mail-to-sql.pl: + Added support for more header fields and for folded fields Notes: - no database updates required
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
module.inc 2.60 KiB
<?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'");
}
}
?>