? calendar_views_args.patch
Index: calendar.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/calendar/calendar.inc,v
retrieving revision 1.13.2.21
diff -u -p -r1.13.2.21 calendar.inc
--- calendar.inc	23 Apr 2008 08:59:41 -0000	1.13.2.21
+++ calendar.inc	25 Apr 2008 13:32:08 -0000
@@ -17,7 +17,11 @@ function _calendar_views_query_alter(&$q
   if ($view->build_type == 'block') {
     $query->calendar_type = 'month';
     $view->calendar_display = $display_formats['block'];
+<<<<<<< .mine
+//     $view->args = explode('/', str_replace($view->url .'/', '', $_GET['q']));
+=======
     $view->args = explode('/', str_replace($view->url .'/', '', $_GET['q']));
+>>>>>>> .r70
     foreach ($view->argument as $delta => $argument) {
       // Special handling for OG gid argument.
       // Find a default value for the gid when used in a block.
@@ -702,7 +706,7 @@ function calendar_nav($view, $mini = FAL
 
   // make the navigation into a header, with prev and next links
   // use the calendar_nav themes to mimic standard calendar navigation
-  $paths = calendar_get_paths($view);
+  $paths = calendar_get_paths($view, $view->args);
   $prev_path = implode('/', array_reverse($paths[0]));
   $next_path = implode('/', array_reverse($paths[1]));
 
@@ -739,7 +743,7 @@ function calendar_nav($view, $mini = FAL
   return $header;
 }
 
-function calendar_get_paths($view) {
+function calendar_get_paths($view, $args) {
   $path = array();
   $prev_date = drupal_clone($view->min_date);
   date_modify($prev_date, '-1 '. $view->calendar_type);
@@ -748,8 +752,21 @@ function calendar_get_paths($view) {
 
   // build an array of the current path and its parts
   $i = 0;
+  // Make sure the URL for links passes correctly with views args
+  $parts = explode('/', $view->url);
+  $bump = 0;
+  foreach ($parts as $delta => $part) {
+    // If one of the args is buried in the url, add it here and adjust
+    // the delta values we'll compare the calendar arg positions to.
+    $valid_args = calendar_valid_views_args();
+    if (in_array($part, $valid_args)) {
+      $parts[$delta] = array_shift($args);
+      $bump++;
+    }
+  }
+  $correct_path = implode('/', $parts);
   $path[$i]     = array(
-    'path' => $view->url,
+    'path' => $correct_path,
     'type' => 'url',
       );
   foreach ($view->argument as $delta => $arg) {
@@ -762,7 +779,6 @@ function calendar_get_paths($view) {
         );
     }
   }
-
   // if there are other arguments after the view arguments, add them to the
   // navigation links
   while($i < sizeof($view->args)) {
@@ -772,7 +788,6 @@ function calendar_get_paths($view) {
       'type' => '',
     );
   }
-
   // reverse through the path, creating a $nextpath and $prevpath arrays
   $formats = array('day' => 'j', 'month' => 'm', 'year' => 'Y', 'week' => 'W');
   for ($x = $i; $x >= 0; $x--) {
@@ -799,6 +814,9 @@ function calendar_get_paths($view) {
         $prevpath[$x] = 'W'. $prev_week;
       }
     }
+    elseif($path[$x]['type'] == 'gid') {
+      // Do nothing. This stops group IDs being passed to the parser twice.
+    }
     // Non-date path elements just get passed through.
     else {
       $nextpath[$x] = $path[$x]['path'];
Index: calendar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/calendar/calendar.module,v
retrieving revision 1.102.2.5
diff -u -p -r1.102.2.5 calendar.module
--- calendar.module	23 Apr 2008 16:23:47 -0000	1.102.2.5
+++ calendar.module	25 Apr 2008 13:32:08 -0000
@@ -467,6 +467,22 @@ function calendar_args() {
 }
 
 /**
+ * Return an array of all valid views arguments.
+ */ 
+function calendar_valid_views_args() {
+  // Make an array of all valid views args, including $node-class.
+  $node_types = node_get_types('names');
+  foreach($node_types as $name => $type) {
+    $args[] = '$node-'.$name;
+  }
+  $args[] = '$arg';
+  $args[] = '$node';
+  $args[] = '$user';
+  $args[] = '$group';
+  return $args;
+}
+
+/**
  * Figure out what the URL of the calendar view we're currently looking at is.
  */
 function calendar_real_url($view, $args) {
@@ -476,11 +492,13 @@ function calendar_real_url($view, $args)
   foreach ($parts as $delta => $part) {
     // If one of the args is buried in the url, add it here and adjust
     // the delta values we'll compare the calendar arg positions to.
-    if (in_array($part, array('$arg', '$node', '$user', '$group'))) {
+    $valid_args = calendar_valid_views_args();
+    if (in_array($part, $valid_args)) {
       $parts[$delta] = array_shift($args);
       $bump++;
     }
   }
+
   foreach ($args as $delta => $arg) {
     if (!in_array($delta + $bump, calendar_arg_positions($view)) && !empty($arg)) {
       array_push($parts, $arg);
