From 9ef955b6e02fd9dbaef7d2c2b22b569447b4e913 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 25 Sep 2001 17:10:44 +0000 Subject: - bugfix #1: fixed the line that accidentically got cut off by incorrectly applying a patch. Mea culpa. (reported by Axel) - bugfix #2: incorrect deactivation of the delete link in node_links(). (patch by Axel) - improvement: added confirmation page upon deletion of a node ("Do you really want to delete this node?"), and removed the old and confusing "node has to be blocked first". (patch by Axel) --- modules/node.module | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'modules/node.module') diff --git a/modules/node.module b/modules/node.module index 428f3c4ba..c00522a8f 100644 --- a/modules/node.module +++ b/modules/node.module @@ -6,7 +6,7 @@ class Node { $this->uid = $node[uid] ? $node[uid] : $user->uid; $this->nid = $node[nid]; $this->type = $node[type]; - $this->comment = $node[comment] ? $node[comment] : + $this->comment = $node[comment] ? $node[comment] : variable_get($node[type]."_comment", 0); $this->name = $node[name] ? $node[name] : $user->name; $this->title = $node[title]; $this->attributes = $node[attributes]; @@ -36,6 +36,8 @@ function node_perm() { function node_conf_options() { $output .= form_select("Default number of nodes to display", "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), "The default maximum number of nodes to display on the main page."); + $output .= form_select("Prompt for confirmation when deleting nodes", "default_nodes_confirm_delete", variable_get("default_nodes_confirm_delete", 1), array("Disabled", "Enabled"), "Prompt for confirmation when deleting nodes."); + return $output; } @@ -102,7 +104,7 @@ function node_links($nid, $type) { $link[] = ($op == "option") ? "edit options" : "edit options"; $link[] = ($op == "status") ? "edit status" : "edit status"; $link[] = ($op == "attribute") ? "edit attribute" : "edit attributes"; - $link[] = ($op == "delete") ? "delete node" : "delete node"; + $link[] = "delete node"; return $link; } @@ -184,7 +186,20 @@ function node_save_content($edit, $type) { } function node_delete($id) { - return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node: set node status to 'dumped' first."); + return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node."); +} + + +function node_delete_confirmation($id) { + + $node = node_get_object(array("nid" => $id)); + + $form .= form_item(t("Do you really want to delete this node"), check_output($node->title)); + $form .= form_submit("Delete node"); + $form .= form_submit("Keep node"); + + return form("admin.php?mod=node&id=$node->nid", $form); + } function node_query($type = -1) { @@ -325,8 +340,11 @@ function node_admin() { print node_edit_content(node_get_array(array("nid" => $id)), $type); break; case "default": - print node_setting(); break; + case "confirm delete": + print node_delete_confirmation($id); + break; + case "Delete node": case "delete": print status(node_delete($id)); print node_overview($query); -- cgit v1.2.3