--- C:/Documents and Settings/Dan/Local Settings/Temp/views_bonus_export.module-revBASE.svn001.tmp.module	Thu Nov 22 16:10:22 2007
+++ F:/sw/Apache Group/Apache/htdocs/pride_drupal2/sites/all/modules/views_bonus/views_bonus_export.module	Thu Nov 22 16:10:10 2007
@@ -83,10 +83,52 @@
     $view->pager_limit = 0;
   }
   else if ($op == 'post_view' && $view->build_type != 'block') {
     $args = views_post_view_make_args($view, $arg, $arg);
     $url = views_get_url($view, $args);
+    
+    
+    
+    
+    
+    ////////////// (start patch)
+    
+    // This block of code was added as a patch, but it still needs a bit more work.
+    // 
+    // The idea is that if you are viewing 
+    //        www.yoursite.com/yourview?exposed_filter_param1=foo
+    // we want to get a link to a CSV like this:
+    //        www.yoursite.com/yourview_url/csv?exposed_filter_param1=foo
+    // "$url_filter" will be everything after the question mark, and is basically just the query string.
+    // 
+    // In this context, it works fine.  
+    //
+    // But the trouble is, the same view, when you are editing it and setting it up, 
+    //   the view is also visible via 
+    //        www.yoursite.com/admin/build/views/yourview_name?exposed_filter_param1=foo
+    // The next few lines of code get a bit confused in that context, and the CSV button doesn't work.
+    //   It shouldn't be hard to fix, but I am going to pass the torch to someone else, as I have no more
+    //   time to spend on this.  :-\
+    
+    // This line added as per suggestion at http://drupal.org/node/175116#comment-604317
+    $url_filter = str_replace(base_path() . views_get_url($view, array()), '', $_SERVER[REQUEST_URI]);
+    
+    // Remove leading '?' if there is one.
+    if (substr($url_filter,0,1)=='?') {
+      $url_filter = substr($url_filter,1);  
+    }
+    if (strlen($url_filter)==0) {  
+      unset($url_filter); // otherwise, a '?' gets appended to your URL even if there's nothing after it.
+    }
+    
+    //
+    //
+    ////////////// (end patch)
+    
+    
+    
+    
     $title = views_get_title($view, 'page', $args);
     $links = array();
     
     if (user_access('export views')) {
       if ($arg == 'csv') {
