summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2003-02-16 14:57:35 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2003-02-16 14:57:35 +0000
commitdd329e1d95dcc0e02841482b660091945f433d13 (patch)
tree4ab177a5825704acd68741389f8659718646e2b0 /modules/node/node.module
parentb29f1bff7fa95270644d4d4db42bbe3d92cbb0d6 (diff)
downloadbrdo-dd329e1d95dcc0e02841482b660091945f433d13.tar.gz
brdo-dd329e1d95dcc0e02841482b660091945f433d13.tar.bz2
- Added function node_invoke_all($hook, &$node, $op, $arg = 0).
- Added a _nodeapi hook that in time will replace the _node hook. Trying to make as few changes to existing code as possible until the new api is stabilized. - Modified node_form() to add administration options from other modules using the _nodeapi hook. - Modified node_save() to fetch which fields should be saved to the node table from the _nodeapi hook. - Moved comment and queue options from node_form() and node_save() to the modules _nodeapi hooks.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module31
1 files changed, 24 insertions, 7 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 2262a0e82..bc96f8950 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -131,6 +131,20 @@ function node_invoke($node, $name, $arg = 0) {
}
}
+function node_invoke_all($hook, &$node, $op, $arg = 0) {
+ $return = array();
+ foreach (module_list() as $name) {
+ if (module_hook($name, $hook)) {
+ $function = $name ."_". $hook;
+ $result = $function($node, $op, $arg);
+ if (isset($result)) {
+ $return = array_merge($return, $result);
+ }
+ }
+ }
+ return $return;
+}
+
function node_load($conditions) {
/*
@@ -171,7 +185,7 @@ function node_load($conditions) {
function node_save($node, $filter) {
- $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "static", "moderate", "created", "changed", "users", "votes");
+ $fields = node_invoke_all("nodeapi", $node, "fields");
foreach ($filter as $key => $value) {
/*
@@ -900,13 +914,9 @@ function node_form($edit, $error = NULL) {
$output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
$output .= "<br />";
$output .= form_select(t("Set public/published"), "status", $edit->status, array(t("Disabled"), t("Enabled")));
- $output .= form_select(t("Moderation status"), "moderate", $edit->moderate, array(t("Approved"), t("Awaiting approval")));
$output .= form_select(t("Promote to front page"), "promote", $edit->promote, array(t("Disabled"), t("Enabled")));
$output .= form_select(t("Static on front page"), "static", $edit->static, array(t("Disabled"), t("Enabled")));
- // TODO: move this to the comment.module
- if (module_exist("comment")) {
- $output .= form_select(t("Allow user comments"), "comment", $edit->comment, array(t("Disabled"), t("Read only"), t("Read-write")));
- }
+ $output .= implode("", node_invoke_all("nodeapi", $edit, "form", "admin"));
$output .= form_select(t("Create new revision"), "revision", $edit->revision, array(t("Disabled"), t("Enabled")));
}
@@ -1299,4 +1309,11 @@ function node_update_index() {
"select" => "SELECT n.nid as lno, n.title as text1, n.body as text2 FROM node n WHERE n.status = 1 AND moderate = 0 and (created > " . variable_get("node_cron_last", 1) . " or changed > " . variable_get("node_cron_last", 1) . ")");
}
-?>
+function node_nodeapi(&$node, $op, $arg = 0) {
+ switch ($op) {
+ case "fields":
+ return array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "promote", "static", "created", "changed", "users", "votes");
+ }
+}
+
+?> \ No newline at end of file