summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/comment.module14
-rw-r--r--modules/comment/comment.module14
-rw-r--r--modules/node.module31
-rw-r--r--modules/node/node.module31
-rw-r--r--modules/queue.module13
5 files changed, 86 insertions, 17 deletions
diff --git a/modules/comment.module b/modules/comment.module
index effac37d1..e9fde950c 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -1490,4 +1490,16 @@ function comment_update_index() {
return array("last_update" => "comment_cron_last", "node_type" => "comment", "select" => "SELECT c.cid as lno, c.subject as text1, c.comment as text2 FROM comments c WHERE c.status = 0 AND timestamp > ". variable_get("comment_cron_last", 1));
}
-?>
+function comment_nodeapi(&$node, $op, $arg = 0) {
+ switch ($op) {
+ case "form":
+ if ($arg == "admin" && user_access("administer comments")) {
+ return form_select(t("Allow user comments"), "comment", $node->comment, array(t("Disabled"), t("Read only"), t("Read-write")));
+ }
+ break;
+ case "fields":
+ return array("comment");
+ }
+}
+
+?> \ No newline at end of file
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index effac37d1..e9fde950c 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1490,4 +1490,16 @@ function comment_update_index() {
return array("last_update" => "comment_cron_last", "node_type" => "comment", "select" => "SELECT c.cid as lno, c.subject as text1, c.comment as text2 FROM comments c WHERE c.status = 0 AND timestamp > ". variable_get("comment_cron_last", 1));
}
-?>
+function comment_nodeapi(&$node, $op, $arg = 0) {
+ switch ($op) {
+ case "form":
+ if ($arg == "admin" && user_access("administer comments")) {
+ return form_select(t("Allow user comments"), "comment", $node->comment, array(t("Disabled"), t("Read only"), t("Read-write")));
+ }
+ break;
+ case "fields":
+ return array("comment");
+ }
+}
+
+?> \ No newline at end of file
diff --git a/modules/node.module b/modules/node.module
index 2262a0e82..bc96f8950 100644
--- a/modules/node.module
+++ b/modules/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
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
diff --git a/modules/queue.module b/modules/queue.module
index fbeca356a..825650462 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -210,4 +210,15 @@ function queue_block($op = "list", $delta = 0) {
}
}
-?>
+function queue_nodeapi(&$node, $op, $arg = 0) {
+ switch ($op) {
+ case "form":
+ if ($arg == "admin" && user_access("administer moderation")) {
+ return form_select(t("Moderation status"), "moderate", $node->moderate, array(t("Approved"), t("Awaiting approval")));
+ }
+ break;
+ case "fields":
+ return array("moderate");
+ }
+}
+?> \ No newline at end of file