--- weblinks.module.orig	Wed Mar 28 16:39:47 2007
+++ weblinks.module	Wed Mar 28 17:10:37 2007
@@ -365,9 +365,6 @@
   	'#required' => FALSE);
   $form['body_filter']['format'] = filter_form($node->format);
 	
-	$ref=$_REQUEST['ref'];
-  $form['ref'] = array('#type' => 'hidden', '#value' => $ref);
-
   return $form;
 }
 
@@ -435,7 +432,7 @@
  * Returns a form for adding a weblink
  */
 function weblinks_form_weblink() {
-	drupal_goto("node/add/weblinks", $query = "ref=admin");
+	drupal_goto("node/add/weblinks", $query = "destination=admin/content/weblinks");
 }
 
 /**
@@ -619,7 +616,6 @@
 	foreach($node->taxonomy[$vid] as $tid) {
   	db_query('INSERT INTO {weblinks} (nid, tid, vid, url, weight) VALUES (%d, %d, %d, "%s", %d)', $node->nid, $tid,  $node->vid, $node->url, $node->weight);
   }
-  if ($node->ref == 'admin') {drupal_goto('admin/content/weblinks');}
 }
 
 /**
@@ -633,7 +629,6 @@
 	foreach($node->taxonomy[$vid] as $tid) {
 		db_query('INSERT INTO {weblinks} (nid, tid, vid, url, weight) VALUES (%d, %d, %d, "%s", %d)', $node->nid, $tid, $node->vid, $node->url, $node->weight);
 	}
-  if ($node->ref == 'admin') {drupal_goto('admin/content/weblinks');}
 }
 
 /**
@@ -641,7 +636,6 @@
  */
 function weblinks_delete(&$node) {
   db_query('DELETE FROM {weblinks} WHERE nid = %d', $node->nid);
-  if ($node->ref == 'admin') {drupal_goto('admin/content/weblinks');}
 }
 
 /**
@@ -704,10 +698,10 @@
 			$menu .= '<div class="weblinkCat"><fieldset class=" collapsible collapsed"><legend>'.$term->name.'</legend>'.
 						'<div class="form-item">';
 			$menu .= "<h3>".$term->name;
-			if (user_access('administer weblinks')) {$menu .= " ::: ".l(t('edit category'), "admin/content/weblinks/edit/container/$term->tid");}
+			if (user_access('administer weblinks')) {$menu .= " ::: ".l(t('edit category'), "admin/content/weblinks/edit/container/$term->tid", NULL, 'destination='.$_GET['q']);}
 			elseif (user_access('edit group categories')) {
 				$include = _weblinks_get_access();
-				if (in_array($term->tid, $include)) {$menu .= " ::: ".l(t('edit category'), "admin/content/weblinks/edit/container/$term->tid");}
+				if (in_array($term->tid, $include)) {$menu .= " ::: ".l(t('edit category'), "admin/content/weblinks/edit/container/$term->tid", NULL, 'destination='.$_GET['q']);}
 			}
 			$menu .= "</h3>";
 			$menu .= _weblinks_recurse_admin($term->tid);
@@ -1100,9 +1094,9 @@
 		$title = stripslashes($title);
 		if ($admin) {
 			$page_content .= "<li class=\"adminBasicweblinks\">";			
-			if (user_access('administer weblinks')) {$page_content .= l(t('edit weblink'), "node/{$row['nid']}/edit", $attributes = array(), $query="ref=admin")." - ";}
+			if (user_access('administer weblinks')) {$page_content .= l(t('edit weblink'), "node/{$row['nid']}/edit", $attributes = array(), $query="destination=".$_GET['q'])." - ";}
 			elseif (user_access('edit group weblinks')) {				
-				if (in_array($tid, $include)) {$page_content .= l(t('edit weblink'), "node/{$row['nid']}/edit", $attributes = array(), $query="ref=admin")." - ";}
+				if (in_array($tid, $include)) {$page_content .= l(t('edit weblink'), "node/{$row['nid']}/edit", $attributes = array(), $query="destination=".$_GET['q'])." - ";}
 			}
 			if (variable_get('weblinks_urlnode', 'url') == 'node') {
 				$page_content .= l(t($row['title']), 'node/'.$row['nid'])."</li>";
