Index: contributions/modules/hidden/hidden.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/hidden/hidden.module,v
retrieving revision 1.2.2.1
diff -u -p -r1.2.2.1 hidden.module
--- contributions/modules/hidden/hidden.module	18 Oct 2007 12:17:15 -0000	1.2.2.1
+++ contributions/modules/hidden/hidden.module	30 Dec 2007 19:26:22 -0000
@@ -692,30 +692,53 @@ function hidden_link($type, $item = NULL
   if ($hidden == false) {
     // not hidden
     if (user_access('mark as hidden')) {
-      $links['hidden-hide'] = array('title' => t('hide'), 'href' => "hidden/$type/$target/hide", );
+      $links['hidden-hide'] = array(
+        'title' => t('hide'), 
+        'href' => "hidden/$type/$target/hide", 
+        'query' => drupal_get_destination(), 
+      );
     }
     // not hidden and is published
     if (user_access('report for hiding') && (
          ($type == 'comment' && $item->status != COMMENT_NOT_PUBLISHED) || 
          ($type == 'node' && $item->status)
        )) {
-       $links['hidden-report'] = array('title' => t('report'), 'href' => "hidden/$type/$target/report", );
+       $links['hidden-report'] = array(
+         'title' => t('report'), 
+         'href' => "hidden/$type/$target/report",
+         'query' => drupal_get_destination(),
+       );
     }
   }
   elseif ($hidden->delay!=0) {
     // marked to be hidden by a cron job
     if (user_access('mark as hidden')) {
-      $links['hidden-hide'] = array('title' => t('hide now'), 'href' => "hidden/$type/$target/hide", );
-      $links['hidden-unhide'] = array( 'title' => t("don't hide"), 'href' => "hidden/$type/$target/unhide", );
+      $links['hidden-hide'] = array(
+        'title' => t('hide now'), 
+        'href' => "hidden/$type/$target/hide",
+        'query' => drupal_get_destination(),
+      );
+      $links['hidden-unhide'] = array( 
+        'title' => t("don't hide"), 
+        'href' => "hidden/$type/$target/unhide", 
+        'query' => drupal_get_destination(),
+      );
     }
     if (user_access('report for hiding')) {
-      $links['hidden-report'] = array('title' => t('report'), 'href' => "hidden/$type/$target/report", );
+      $links['hidden-report'] = array(
+        'title' => t('report'), 
+        'href' => "hidden/$type/$target/report",
+        'query' => drupal_get_destination(),
+      );
     }
   }
   else {
     // hidden
     if (user_access('mark as hidden')) {
-      $links['hidden-unhide'] = array( 'title' => t('unhide'), 'href' => "hidden/$type/$target/unhide", );
+      $links['hidden-unhide'] = array( 
+        'title' => t('unhide'), 
+        'href' => "hidden/$type/$target/unhide", 
+      );
     }
   }
 
@@ -1681,7 +1704,7 @@ function hidden_hide($op, $type, $id) {
   }
   if (!$result) {
     drupal_set_message(t('Database error occurred when retrieving item\'s title.'), 'error');
-    drupal_goto($type, $id);
+    drupal_goto();
   }
 
   if ($op=='hide') {
@@ -1829,6 +1852,7 @@ function hidden_hide_submit($form_id, $f
       _hidden_log(HIDDEN_LOG_ERROR, $msg, $type, $id, $rid, $public, $private);
       drupal_set_message($msg, 'error');
     }
+    _hidden_goto_hidden($type, $nid, $cid);
   }
   else {
     if (_hidden_reported_hide($type, $nid, $cid, $uid, $rid, $public, $private)) {
@@ -1841,9 +1865,8 @@ function hidden_hide_submit($form_id, $f
       _hidden_log(HIDDEN_LOG_ERROR, $msg, $type, $id, $rid, $public, $private);
       drupal_set_message($msg, 'error');
     }
+    drupal_goto();
   }
-
-  _hidden_goto_hidden($type, $nid, $cid);
 }
 
 /**
@@ -3160,40 +3183,39 @@ function _hidden_mail($subject, $content
  *   cid (optional)
  */
 function _hidden_goto_hidden($type, $id, $cid=null) {
-  if ($cid!==null) {
-    $nid = $id;
-    if ($cid!=0) {
-      $id = $cid;
-    }
-  }
-  elseif ($type == 'node') {
-    $nid = $id;
-    $cid = 0;
+  if ($type == 'node') {
+    $access = user_access('administer nodes');          // it's a node can the user see unpublished nodes?
   }
   else {
-    $query = 'SELECT nid FROM {comments} WHERE cid=%d';
-    $nid = db_result(db_query($query, $id));
-    $cid = $id;
+    $access = user_access('administer comments');       // it's a comment can the user see unpublished comments
   }
 
-  if ($cid == 0) {
-    $access = user_access('administer nodes');
-  }
+  if ($access == TRUE) { // if the user can see it return there
+    drupal_goto();
+  } 
   else {
-    $access = user_access('administer comments');
+    unset($_REQUEST['destination']);
   }
 
-  if ($access) {
-    $url = 'node/'. $nid;
-    if ($cid != 0) {
-      $fragment = 'comment-'. $cid;
+  if ($cid!==null) { // there is a comment id
+    $nid = $id;      // so $id must be a node id
+    if ($cid!=0) {
+      $id = $cid;    // it is a reference to a comment not a node
     }
   }
-  else {
-    $url = "hidden/$type/$id";
+  elseif ($type == 'node') { // the type is node
+    $nid = $id;              // make the id the nid
+    $cid = 0;                // make the cid 0
+  }
+  else {                     // the type is comment
+    $query = 'SELECT nid FROM {comments} WHERE cid=%d'; // find out the node it is attached to
+    $nid = db_result(db_query($query, $id));            // set nid
+    $cid = $id;                                         // and so the id was cid
   }
 
-  drupal_goto($url, null, $fragment);
+  $url = "hidden/$type/$id";
+
+  drupal_goto($url);
 }
 
 /**
