#138481: (fago) Allow 'delete' link to return to view like edit link does.
authorEarl Miles
Sat, 5 May 2007 00:54:53 +0000 (00:54 +0000)
committerEarl Miles
Sat, 5 May 2007 00:54:53 +0000 (00:54 +0000)
CHANGELOG.txt
modules/views_node.inc

index 7a982a9..07cbf4d 100644 (file)
@@ -10,6 +10,7 @@ Views 5.x-dev
     o #117365: Comment: Last Changed Time wasn't ensuring node_comment_statistics is in the query.
     o #136794: Sort by nid via click-sorting was also broken
     o #141205: (by mfrederickson) Add an argument to views_get_filter_values() to let other code use it.
+    o #138481: (fago) Allow 'delete' link to return to view like edit link does.
 
 Views 5.x-beta3
   Bugs fixed:
index 3793438..3ec70c5 100644 (file)
@@ -95,7 +95,10 @@ function node_views_tables() {
       ),
       'delete' => array(
         'name' => t('Node: Delete link'),
-        'handler' => 'views_handler_node_delete',
+        'handler' => array(
+          'views_handler_node_delete_destination'   => t('Return To View'),
+          'views_handler_node_delete' => t('Return To The Frontpage'),
+        ),
         'notafield' => TRUE,
         'addlfields' => array('type', 'uid'),
         'option' => 'string',
@@ -888,6 +891,19 @@ function views_handler_node_delete($fieldinfo, $fielddata, $value, $data) {
 }
 
 /**
+ * display a link to delete a node with a destination return
+ */
+function views_handler_node_delete_destination($fieldinfo, $fielddata, $value, $data) {
+  // try to build a fake node object
+  $data->type = $data->node_type;
+  $data->uid = $data->node_uid;
+  if (node_access('delete', $data)) {
+    $link_text = $fielddata['options'] ? $fielddata['options'] : t('Delete');
+    return l($link_text, "node/$data->nid/delete", NULL, drupal_get_destination());
+  }
+}
+
+/**
  * Display a node's nid, which is a little bit special.
  */
 function views_handler_node_nid($fieldinfo, $fielddata, $value, $data) {