Skip to content
Snippets Groups Projects
Commit 9ef955b6 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- 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)
parent 97922068
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -6,7 +6,7 @@ function Node($node) { ...@@ -6,7 +6,7 @@ function Node($node) {
$this->uid = $node[uid] ? $node[uid] : $user->uid; $this->uid = $node[uid] ? $node[uid] : $user->uid;
$this->nid = $node[nid]; $this->nid = $node[nid];
$this->type = $node[type]; $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->name = $node[name] ? $node[name] : $user->name;
$this->title = $node[title]; $this->title = $node[title];
$this->attributes = $node[attributes]; $this->attributes = $node[attributes];
...@@ -36,6 +36,8 @@ function node_perm() { ...@@ -36,6 +36,8 @@ function node_perm() {
function node_conf_options() { 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("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; return $output;
} }
...@@ -102,7 +104,7 @@ function node_links($nid, $type) { ...@@ -102,7 +104,7 @@ function node_links($nid, $type) {
$link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>"; $link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>";
$link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>"; $link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>";
$link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>"; $link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>";
$link[] = ($op == "delete") ? "delete node" : "<A HREF=\"admin.php?mod=node&op=delete&id=$nid\">delete node</A>"; $link[] = "<a href=\"admin.php?mod=node&op=". (variable_get("default_nodes_confirm_delete", 1) ? "confirm+" : "") ."delete&id=$nid\">delete node</a>";
return $link; return $link;
} }
...@@ -184,7 +186,20 @@ function node_save_content($edit, $type) { ...@@ -184,7 +186,20 @@ function node_save_content($edit, $type) {
} }
function node_delete($id) { 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) { function node_query($type = -1) {
...@@ -325,8 +340,11 @@ function node_admin() { ...@@ -325,8 +340,11 @@ function node_admin() {
print node_edit_content(node_get_array(array("nid" => $id)), $type); print node_edit_content(node_get_array(array("nid" => $id)), $type);
break; break;
case "default": case "default":
print node_setting();
break; break;
case "confirm delete":
print node_delete_confirmation($id);
break;
case "Delete node":
case "delete": case "delete":
print status(node_delete($id)); print status(node_delete($id));
print node_overview($query); print node_overview($query);
......
...@@ -6,7 +6,7 @@ function Node($node) { ...@@ -6,7 +6,7 @@ function Node($node) {
$this->uid = $node[uid] ? $node[uid] : $user->uid; $this->uid = $node[uid] ? $node[uid] : $user->uid;
$this->nid = $node[nid]; $this->nid = $node[nid];
$this->type = $node[type]; $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->name = $node[name] ? $node[name] : $user->name;
$this->title = $node[title]; $this->title = $node[title];
$this->attributes = $node[attributes]; $this->attributes = $node[attributes];
...@@ -36,6 +36,8 @@ function node_perm() { ...@@ -36,6 +36,8 @@ function node_perm() {
function node_conf_options() { 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("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; return $output;
} }
...@@ -102,7 +104,7 @@ function node_links($nid, $type) { ...@@ -102,7 +104,7 @@ function node_links($nid, $type) {
$link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>"; $link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>";
$link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>"; $link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>";
$link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>"; $link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>";
$link[] = ($op == "delete") ? "delete node" : "<A HREF=\"admin.php?mod=node&op=delete&id=$nid\">delete node</A>"; $link[] = "<a href=\"admin.php?mod=node&op=". (variable_get("default_nodes_confirm_delete", 1) ? "confirm+" : "") ."delete&id=$nid\">delete node</a>";
return $link; return $link;
} }
...@@ -184,7 +186,20 @@ function node_save_content($edit, $type) { ...@@ -184,7 +186,20 @@ function node_save_content($edit, $type) {
} }
function node_delete($id) { 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) { function node_query($type = -1) {
...@@ -325,8 +340,11 @@ function node_admin() { ...@@ -325,8 +340,11 @@ function node_admin() {
print node_edit_content(node_get_array(array("nid" => $id)), $type); print node_edit_content(node_get_array(array("nid" => $id)), $type);
break; break;
case "default": case "default":
print node_setting();
break; break;
case "confirm delete":
print node_delete_confirmation($id);
break;
case "Delete node":
case "delete": case "delete":
print status(node_delete($id)); print status(node_delete($id));
print node_overview($query); print node_overview($query);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment