diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-11-05 22:59:11 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-11-05 22:59:11 +0000 |
commit | db47bac35ec035388cfdab0a9fb27e97f8099742 (patch) | |
tree | f1ae2de16fdaa0ab39199d61828076e9eeb9af45 /modules | |
parent | f88cfaa2dd205846843068175931e68c582bb037 (diff) | |
download | brdo-db47bac35ec035388cfdab0a9fb27e97f8099742.tar.gz brdo-db47bac35ec035388cfdab0a9fb27e97f8099742.tar.bz2 |
- 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
Diffstat (limited to 'modules')
-rw-r--r-- | modules/book.module | 10 | ||||
-rw-r--r-- | modules/book/book.module | 10 | ||||
-rw-r--r-- | modules/node.module | 65 | ||||
-rw-r--r-- | modules/node/node.module | 65 | ||||
-rw-r--r-- | modules/queue.module | 14 |
5 files changed, 106 insertions, 58 deletions
diff --git a/modules/book.module b/modules/book.module index 320f1f88f..129857251 100644 --- a/modules/book.module +++ b/modules/book.module @@ -142,7 +142,7 @@ function book_view($node, $main = 0) { */ if ($node->moderate && $mod != "queue") { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } /* @@ -233,7 +233,7 @@ function book_tree($parent = "", $depth = 0) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -260,7 +260,7 @@ function book_render() { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -300,7 +300,7 @@ function book_export_html($id = "", $depth = 1) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -325,7 +325,7 @@ function book_export_html_recursive($parent = "", $depth = 1) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: diff --git a/modules/book/book.module b/modules/book/book.module index 320f1f88f..129857251 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -142,7 +142,7 @@ function book_view($node, $main = 0) { */ if ($node->moderate && $mod != "queue") { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } /* @@ -233,7 +233,7 @@ function book_tree($parent = "", $depth = 0) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -260,7 +260,7 @@ function book_render() { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -300,7 +300,7 @@ function book_export_html($id = "", $depth = 1) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: @@ -325,7 +325,7 @@ function book_export_html_recursive($parent = "", $depth = 1) { // take the most recent approved revision: if ($node->moderate) { - $node = $node->revisions[sizeof($node->revisions) - 1]["node"]; + $node = node_revision_load($node, end(node_revision_list($node))); } // output the content: diff --git a/modules/node.module b/modules/node.module index 26d40dc08..2c1b6d3b1 100644 --- a/modules/node.module +++ b/modules/node.module @@ -234,6 +234,18 @@ function node_admin_nodes() { return $output; } +/* +** Return the revision with the specified revision number. +*/ + +function node_revision_load($node, $revision) { + return $node->revisions[$revision]["node"]; +} + +/* +** Create and return a new revision of the given node. +*/ + function node_revision_create($node) { global $user; @@ -252,14 +264,12 @@ function node_revision_create($node) { return $node; } -function node_revision_rollback($nid, $revision) { - global $user; +/* +** Roll-back to the revision with the specified revision number. +*/ - /* - ** Load the original/current node: - */ - - $node = node_load(array("nid" => $nid)); +function node_revision_rollback($node, $revision) { + global $user; /* ** Extract the specified revision: @@ -298,8 +308,11 @@ function node_revision_rollback($nid, $revision) { watchdog("special", "node: rollbacked to revision #$revision of '$node->title'"); } -function node_revision_delete($nid, $revision) { - $node = node_load(array("nid" => $nid)); +/* +** Delete the revision with specified revision number. +*/ + +function node_revision_delete($node, $revision) { unset($node->revisions[$revision]); @@ -308,8 +321,17 @@ function node_revision_delete($nid, $revision) { watchdog("special", "node: removed revision #$revision of '$node->title'"); } -function node_revision_previous($node) { - return end(array_keys($node->revisions)); +/* +** Return a list of all the existing revision numbers. +*/ + +function node_revision_list($node) { + if (is_array($node->revisions)) { + return array_keys($node->revisions); + } + else { + return array(); + } } function node_admin() { @@ -344,10 +366,12 @@ function node_admin() { print node_admin_edit($id); break; case "rollback revision": - print node_revision_rollback($id, $revision); + print node_revision_rollback(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case "delete revision": - print node_revision_delete($id, $revision); + print node_revision_delete(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case t("Preview"): print node_preview($edit); @@ -492,7 +516,6 @@ function node_form($edit) { $form .= $function(&$edit, &$help, &$error); } - $output .= "<div style=\"margin-right: 40px; float: left;\">"; /* ** Add the help text: @@ -502,6 +525,10 @@ function node_form($edit) { $output .= "<p>$help</p>"; } + $output .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">"; + $output .= " <tr>"; + $output .= " <td valign=\"top\">"; + /* ** Add the default fields: */ @@ -554,14 +581,13 @@ function node_form($edit) { $output .= form_submit(t("Delete")); } - $output .= "</div>"; - /* ** Add the admin specific parts: */ if (user_access("administer nodes")) { - $output .= "<div style=\"float: right;\">"; + $output .= "</td><td valign=\"top\">"; + $output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 25, $error["name"]); $output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]); $output .= "<br />"; @@ -569,9 +595,12 @@ function node_form($edit) { $output .= form_select(t("Allow users comments"), "comment", $edit->comment, array("Disabled", "Enabled")); $output .= form_select(t("Promote to front page"), "promote", $edit->promote, array("Disabled", "Enabled")); $output .= form_select(t("Create new revision"), "revision", $edit->revision, array("Disabled", "Enabled")); - $output .= "</div>"; } + $output .= " </td>"; + $output .= " </tr>"; + $output .= "</table>"; + return form($output); } diff --git a/modules/node/node.module b/modules/node/node.module index 26d40dc08..2c1b6d3b1 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -234,6 +234,18 @@ function node_admin_nodes() { return $output; } +/* +** Return the revision with the specified revision number. +*/ + +function node_revision_load($node, $revision) { + return $node->revisions[$revision]["node"]; +} + +/* +** Create and return a new revision of the given node. +*/ + function node_revision_create($node) { global $user; @@ -252,14 +264,12 @@ function node_revision_create($node) { return $node; } -function node_revision_rollback($nid, $revision) { - global $user; +/* +** Roll-back to the revision with the specified revision number. +*/ - /* - ** Load the original/current node: - */ - - $node = node_load(array("nid" => $nid)); +function node_revision_rollback($node, $revision) { + global $user; /* ** Extract the specified revision: @@ -298,8 +308,11 @@ function node_revision_rollback($nid, $revision) { watchdog("special", "node: rollbacked to revision #$revision of '$node->title'"); } -function node_revision_delete($nid, $revision) { - $node = node_load(array("nid" => $nid)); +/* +** Delete the revision with specified revision number. +*/ + +function node_revision_delete($node, $revision) { unset($node->revisions[$revision]); @@ -308,8 +321,17 @@ function node_revision_delete($nid, $revision) { watchdog("special", "node: removed revision #$revision of '$node->title'"); } -function node_revision_previous($node) { - return end(array_keys($node->revisions)); +/* +** Return a list of all the existing revision numbers. +*/ + +function node_revision_list($node) { + if (is_array($node->revisions)) { + return array_keys($node->revisions); + } + else { + return array(); + } } function node_admin() { @@ -344,10 +366,12 @@ function node_admin() { print node_admin_edit($id); break; case "rollback revision": - print node_revision_rollback($id, $revision); + print node_revision_rollback(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case "delete revision": - print node_revision_delete($id, $revision); + print node_revision_delete(node_load(array("nid" => $id)), $revision); + print node_admin_edit($id); break; case t("Preview"): print node_preview($edit); @@ -492,7 +516,6 @@ function node_form($edit) { $form .= $function(&$edit, &$help, &$error); } - $output .= "<div style=\"margin-right: 40px; float: left;\">"; /* ** Add the help text: @@ -502,6 +525,10 @@ function node_form($edit) { $output .= "<p>$help</p>"; } + $output .= "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">"; + $output .= " <tr>"; + $output .= " <td valign=\"top\">"; + /* ** Add the default fields: */ @@ -554,14 +581,13 @@ function node_form($edit) { $output .= form_submit(t("Delete")); } - $output .= "</div>"; - /* ** Add the admin specific parts: */ if (user_access("administer nodes")) { - $output .= "<div style=\"float: right;\">"; + $output .= "</td><td valign=\"top\">"; + $output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 25, $error["name"]); $output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]); $output .= "<br />"; @@ -569,9 +595,12 @@ function node_form($edit) { $output .= form_select(t("Allow users comments"), "comment", $edit->comment, array("Disabled", "Enabled")); $output .= form_select(t("Promote to front page"), "promote", $edit->promote, array("Disabled", "Enabled")); $output .= form_select(t("Create new revision"), "revision", $edit->revision, array("Disabled", "Enabled")); - $output .= "</div>"; } + $output .= " </td>"; + $output .= " </tr>"; + $output .= "</table>"; + return form($output); } diff --git a/modules/queue.module b/modules/queue.module index ea1ba0b11..aa70ef656 100644 --- a/modules/queue.module +++ b/modules/queue.module @@ -51,7 +51,7 @@ function queue_vote($id, $vote) { } else if (variable_get($node->type ."_dump", -2) >= $node->score) { if ($node->revisions) { - node_revision_rollback($node->nid, node_revision_previous($node)); + node_revision_rollback($node, end(node_revision_list($node))); watchdog("special", "moderation: dumped '$node->title' (rollback)"); } else { @@ -61,7 +61,7 @@ function queue_vote($id, $vote) { } else if (variable_get($node->type ."_expire", 6) <= $node->votes) { if ($node->revisions) { - node_revision_rollback($node->nid, node_revision_previous($node)); + node_revision_rollback($node, end(node_revision_list($node))); watchdog("special", "moderation: expired '$node->title' (rollback)"); } else { @@ -108,16 +108,6 @@ function queue_view($id) { */ $queue_votes = array("neutral (+0)" => "+ 0", "post it (+1)" => "+ 1", "dump it (-1)" => "- 1"); - // TODO: this is where the upcoming versioning system should come in - if ($n = node_load(array("nid" => $node->pid))) { - $output .= " ". t("The above node is a proposed update of an existing node:") ." \"<a href=\"node.php?id=$n->nid\">". check_output($n->title) ."</a>\"."; - } - - // TODO: this is where the upcoming versioning system should come in - if ($node->log) { - $output .= " ". t("The log message to accompany this submission is given below:") ."<p><i>". check_output($node->log, 1) ."</i></p>"; - } - // moderation form: $output .= "<form action=\"module.php?mod=queue\" method=\"post\">"; foreach ($queue_votes as $key=>$value) $options .= " <option value=\"$value\">$key</option>"; |