Index: privatemsg.pages.inc =================================================================== --- privatemsg.pages.inc (revision 637) +++ privatemsg.pages.inc (working copy) @@ -160,11 +160,14 @@ // If this is an AJAX request, update $_GET['q'] so that table sorting and // similar links are using the correct base path. if ($_GET['q'] == 'system/ajax') { - $q = 'messages'; + //Here to get the 'q' dynamically not straightly set, therefore when we use this page + //in a block, it won't jump back to the originally page. + /*$q = 'messages'; if (!empty($argument)) { $q .= '/' . $argument; } - $_GET['q'] = $q; + $_GET['q'] = $q;*/ + $_GET['q'] = $_GET['destination']; } // Load the table columns. @@ -250,11 +253,19 @@ if (!empty($operation['callback'])) { // Hack to fix destination during ajax requests. if (isset($form_state['input']['ajax_page_state'])) { + /* $destination = 'messages'; if (!empty($form['#list_argument'])) { $destination .= '/' . $form['#list_argument']; } $_GET['destination'] = $destination; + */ + $temp_destination = $_SERVER["HTTP_REFERER"]; + global $base_url; + $temp_base_url = $base_url; + $temp_destination = str_replace($temp_base_url,'',$temp_destination); + $temp_destination = substr($temp_destination, 1); + $_GET['destination'] = $temp_destination; } privatemsg_operation_execute($operation, $form_state['values']['list'], $form_state['values']['account']); }