- Tidied up the usage of module_invoke() and module_invoke_all(). Patch by

Jonathan Chaffer.
4.3.x
Dries Buytaert 2003-09-14 18:33:16 +00:00
parent df3afcbc44
commit 9fbab016f9
8 changed files with 32 additions and 118 deletions

View File

@ -15,9 +15,7 @@ if (!get_cfg_var("safe_mode")) {
** Iterate through the modules calling their cron handlers (if any):
*/
foreach (module_list() as $module) {
module_invoke($module, "cron");
}
module_invoke_all("cron");
watchdog("message", "cron run completed");
?>

View File

@ -219,7 +219,7 @@ function node_teaser($body) {
return substr($body, 0, $size);
}
function node_invoke(&$node, $hook, $arg = 0) {
function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
if (is_array($node)) {
$function = $node["type"] ."_$hook";
}
@ -231,7 +231,7 @@ function node_invoke(&$node, $hook, $arg = 0) {
}
if (function_exists($function)) {
return ($arg ? $function($node, $arg) : $function($node));
return ($function($node, $a2, $a3, $a4));
}
}
@ -264,7 +264,7 @@ function node_load($conditions, $revision = -1) {
** results to the node or overwrite some values:
*/
if ($extra = module_invoke($node->type, "load", $node)) {
if ($extra = node_invoke($node, "load")) {
foreach ($extra as $key => $value) {
$node->$key = $value;
}
@ -445,14 +445,9 @@ function node_access($op, $node = 0) {
$type = $node;
}
$function = $type ."_access";
if (function_exists($function)) {
return $function($op, $node);
}
else {
return 0;
}
// Ideally this would be a node_invoke, but the access hook takes
// the $op parameter before the $node parameter so we can't do that.
return module_invoke ($type, "access", $op, $node);
}
function node_perm() {
@ -597,10 +592,7 @@ function node_admin_edit($node) {
/*
** Display the node form extensions:
*/
foreach (module_list() as $name) {
$output .= module_invoke($name, "node_link", $node);
}
$output .= implode("\n", module_invoke_all("node_link", $node));
return $output;
@ -1179,14 +1171,8 @@ function node_form($edit, $error = NULL) {
// Prepend extra node form:
$form = implode("", module_invoke_all("nodeapi", $edit, "form pre", $error));
/*
** Get the node specific bits:
*/
$function = $edit->type ."_form";
if (function_exists($function)) {
$form .= $function($edit, $help, $error, $param);
}
// Get the node specific bits:
$form .= node_invoke($edit, "form", $help, $error, $param);
// Append extra node form:
$form .= implode("", module_invoke_all("nodeapi", $edit, "form post", $error));

View File

@ -219,7 +219,7 @@ function node_teaser($body) {
return substr($body, 0, $size);
}
function node_invoke(&$node, $hook, $arg = 0) {
function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
if (is_array($node)) {
$function = $node["type"] ."_$hook";
}
@ -231,7 +231,7 @@ function node_invoke(&$node, $hook, $arg = 0) {
}
if (function_exists($function)) {
return ($arg ? $function($node, $arg) : $function($node));
return ($function($node, $a2, $a3, $a4));
}
}
@ -264,7 +264,7 @@ function node_load($conditions, $revision = -1) {
** results to the node or overwrite some values:
*/
if ($extra = module_invoke($node->type, "load", $node)) {
if ($extra = node_invoke($node, "load")) {
foreach ($extra as $key => $value) {
$node->$key = $value;
}
@ -445,14 +445,9 @@ function node_access($op, $node = 0) {
$type = $node;
}
$function = $type ."_access";
if (function_exists($function)) {
return $function($op, $node);
}
else {
return 0;
}
// Ideally this would be a node_invoke, but the access hook takes
// the $op parameter before the $node parameter so we can't do that.
return module_invoke ($type, "access", $op, $node);
}
function node_perm() {
@ -597,10 +592,7 @@ function node_admin_edit($node) {
/*
** Display the node form extensions:
*/
foreach (module_list() as $name) {
$output .= module_invoke($name, "node_link", $node);
}
$output .= implode("\n", module_invoke_all("node_link", $node));
return $output;
@ -1179,14 +1171,8 @@ function node_form($edit, $error = NULL) {
// Prepend extra node form:
$form = implode("", module_invoke_all("nodeapi", $edit, "form pre", $error));
/*
** Get the node specific bits:
*/
$function = $edit->type ."_form";
if (function_exists($function)) {
$form .= $function($edit, $help, $error, $param);
}
// Get the node specific bits:
$form .= node_invoke($edit, "form", $help, $error, $param);
// Append extra node form:
$form .= implode("", module_invoke_all("nodeapi", $edit, "form post", $error));

View File

@ -173,12 +173,7 @@ function system_view_theme($name) {
}
function system_view_filters() {
foreach (module_list() as $name) {
if (module_hook($name, "conf_filters")) {
$output .= module_invoke($name, "conf_filters");
}
}
return $output;
return implode("\n", module_invoke_all("conf_filters"));
}
function system_save_settings($edit = array()) {

View File

@ -173,12 +173,7 @@ function system_view_theme($name) {
}
function system_view_filters() {
foreach (module_list() as $name) {
if (module_hook($name, "conf_filters")) {
$output .= module_invoke($name, "conf_filters");
}
}
return $output;
return implode("\n", module_invoke_all("conf_filters"));
}
function system_save_settings($edit = array()) {

View File

@ -1052,11 +1052,7 @@ function user_edit($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "edit_form", $edit, $user);
}
}
$output .= implode("\n", module_invoke_all ("user", "edit_form", $edit, $user));
$options = "<option value=\"\"". (("" == $key) ? " selected=\"selected\"" : "") .">". t("Default theme") ."</option>\n";
foreach (theme_list() as $key => $value) {
@ -1101,11 +1097,7 @@ function user_view($uid = 0) {
$output = form_item(t("Name"), "$user->name ($user->init)");
$output .= form_item(t("E-mail address"), $user->mail, t("Please note that only you can see your own e-mail address - it is not publicly visible."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "view_private", "", $user);
}
}
$output .= implode("\n", module_invoke_all("user", "view_private", "", $user));
theme("header", $user->name);
theme("box", t("User account"), user_menu());
@ -1115,11 +1107,7 @@ function user_view($uid = 0) {
else if ($uid && $account = user_load(array("uid" => $uid, "status" => 1))) {
$output = form_item(t("Name"), $account->name);
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "view_public", "", $account);
}
}
$output .= implode("\n", module_invoke_all("user", "view_public", "", $account));
if (user_access("administer users")) {
$output .= form_item(t("Administration"), l(t("edit account"), "admin/user/edit/$account->uid"));
@ -1399,11 +1387,7 @@ function user_admin_perm($edit = array()) {
** Compile permission array:
*/
foreach (module_list() as $name) {
if (module_hook($name, "perm")) {
$perms = array_merge($perms, module_invoke($name, "perm"));
}
}
$perms = module_invoke_all("perm");
asort($perms);
/*
@ -1577,11 +1561,7 @@ function user_admin_edit($edit = array()) {
$output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "edit_form", $edit, $account);
}
}
$output .= implode("\n", module_invoke_all("user", "edit_form", $edit, $account));
$options = "<option value=\"\"". (("" == $key) ? " selected=\"selected\"" : "") .">". t("Default theme") ."</option>\n";
foreach (theme_list() as $key => $value) {

View File

@ -1052,11 +1052,7 @@ function user_edit($edit = array()) {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "edit_form", $edit, $user);
}
}
$output .= implode("\n", module_invoke_all ("user", "edit_form", $edit, $user));
$options = "<option value=\"\"". (("" == $key) ? " selected=\"selected\"" : "") .">". t("Default theme") ."</option>\n";
foreach (theme_list() as $key => $value) {
@ -1101,11 +1097,7 @@ function user_view($uid = 0) {
$output = form_item(t("Name"), "$user->name ($user->init)");
$output .= form_item(t("E-mail address"), $user->mail, t("Please note that only you can see your own e-mail address - it is not publicly visible."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "view_private", "", $user);
}
}
$output .= implode("\n", module_invoke_all("user", "view_private", "", $user));
theme("header", $user->name);
theme("box", t("User account"), user_menu());
@ -1115,11 +1107,7 @@ function user_view($uid = 0) {
else if ($uid && $account = user_load(array("uid" => $uid, "status" => 1))) {
$output = form_item(t("Name"), $account->name);
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "view_public", "", $account);
}
}
$output .= implode("\n", module_invoke_all("user", "view_public", "", $account));
if (user_access("administer users")) {
$output .= form_item(t("Administration"), l(t("edit account"), "admin/user/edit/$account->uid"));
@ -1399,11 +1387,7 @@ function user_admin_perm($edit = array()) {
** Compile permission array:
*/
foreach (module_list() as $name) {
if (module_hook($name, "perm")) {
$perms = array_merge($perms, module_invoke($name, "perm"));
}
}
$perms = module_invoke_all("perm");
asort($perms);
/*
@ -1577,11 +1561,7 @@ function user_admin_edit($edit = array()) {
$output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
foreach (module_list() as $module) {
if (module_hook($module, "user")) {
$output .= module_invoke($module, "user", "edit_form", $edit, $account);
}
}
$output .= implode("\n", module_invoke_all("user", "edit_form", $edit, $account));
$options = "<option value=\"\"". (("" == $key) ? " selected=\"selected\"" : "") .">". t("Default theme") ."</option>\n";
foreach (theme_list() as $key => $value) {

View File

@ -4,13 +4,7 @@
include_once "includes/xmlrpcs.inc";
include_once "includes/common.inc";
$functions = array();
foreach (module_list() as $name) {
if (module_hook($name, "xmlrpc")) {
$functions = array_merge($functions, module_invoke($name, "xmlrpc"));
}
}
$functions = module_invoke_all("xmlrpc");
$server = new xmlrpc_server($functions);