--- og_calendar.module.5.1.orig	2007-03-19 12:05:08.000000000 -0700
+++ og_calendar.module	2007-04-02 13:06:06.000000000 -0700
@@ -29,6 +29,16 @@ function og_calendar_menu() {
       'access' => user_access('access content'),
       'type' => MENU_CALLBACK,
     );
+//
+// Modification - added og_calendar_curr
+//
+    $items[] = array(
+      'path' => 'og_calendar_curr',
+      'title' => t('Group calendar by month'),
+      'callback' => 'og_calendar_page_current',
+      'access' => user_access('access content'),
+      'type' => MENU_CALLBACK,
+    );
   }
   return $items;
 }
@@ -177,3 +187,110 @@ function og_calendar_og_create_links($gr
   return $links;
 }
 
+/**
+ * Modification - limited to current month ONLY.  
+ *
+ * Also allows previous / next month paging.
+ *
+ * views either all group events or a specific group's calendar
+ *
+ * It is called like this: /og_calendar_curr/<gid>
+ */
+function og_calendar_page_current($gid = NULL, $date = NULL) {
+  if ($gid) {
+    $group = node_load($gid);
+    $nodes = array();
+    og_set_group_context($group);
+    $bc[] = l(t('Home'), '');
+    $bc[] = l(t('Groups'), 'og');
+    $bc[] = l($group->title, "node/$gid");
+    drupal_set_breadcrumb($bc);
+
+    // Maintains group theme for og calendar view
+  	og_set_theme($gid);
+
+	// Basically, modified og_calendar_page and added code to get the parameters for the current month:
+
+		if (!empty($date)) {
+			$todays_date = $date;
+		} else {
+			$todays_date = date("Y-m-d", time()); 
+		}
+
+		list($year, $month, $day) = split("-", $todays_date);
+
+		$next_year = $year;
+		$next_month = $month+1;
+		
+		if ($next_month == 13) {
+     		$next_month = 1;
+      		$next_year = $year + 1;
+		}
+
+		$prev_year = $year;
+		$prev_month = $month-1;
+		
+		if ($prev_month == 0) {
+     		$prev_month = 12;
+      		$prev_year = $year - 1;
+		}
+
+		if ($next_month < 10) $next_month = '0' . $next_month;
+		if ($prev_month < 10) $prev_month = '0' . $prev_month;
+
+		$start_date = $year . "-" . $month . "-01";
+		$end_date = $next_year . "-" . $next_month . "-01";
+		$prev_date = $prev_year . "-" . $prev_month . "-01";
+
+  		$parts = explode("-",$start_date);
+	  	$start_date_unix = mktime(12,0,0,$parts[1],$parts[2],$parts[0]);
+  		
+  		$parts = explode("-",$end_date);
+	  	$end_date_unix = mktime(12,0,0,$parts[1],$parts[2],$parts[0]);
+
+    // View only events from this group limited by above timeframe
+    $sql = "SELECT e.nid, e.event_start, e.event_end FROM {event} e INNER JOIN {node} n ON n.nid = e.nid";
+    $sql = db_rewrite_sql($sql, 'n', 'nid', array('og_nid' => $gid));
+    $result = db_query($sql, $gid);
+    while ($nid = db_fetch_object($result)) {
+      $event = node_load($nid->nid);
+	  // We need to get the event start date so we know how to set the timeframe;
+	  $event_start = $nid->event_start;
+	  $event_end = $nid->event_end;
+      // Get only event nodes that fall within the timeframe
+      if ($event_start >= $start_date_unix && $event_start < $end_date_unix) {
+      	if (isset($event->nid)) {
+        	$nodes[$event->nid] = $event;
+	      }
+	  }
+    }
+    if (count($nodes)) {
+      $output = event_get_calendar('month', $nodes, 'og_calendar', t('@name calendar', array('@name' => $group->title)));
+
+	  $output .= "<a href='/og_calendar_curr/" . $gid . "/" . $prev_date . "'>Previous Month</a> | <a href='/og_calendar_curr/" . $gid . "/" . $end_date . "'>Next Month</a>";
+
+	  $output .= "<br>";
+
+      $output .= theme('event_ical_link', 'event/ical/'. $node->filter);
+
+      // Add RSS feed and icon to events page
+      drupal_add_link(array(
+        'rel' => 'alternate',
+        'type' => 'application/rss+xml',
+        'title' => t('RSS'),
+        'href' => url('event/feed', NULL, NULL, TRUE)
+      ));
+      $output .= theme('feed_icon', url('event/feed'));
+
+
+      return $output;
+    }
+    else {
+      return t('No (visible) events for the @name group were found!', array('@name' => $group->title));
+    }
+  }
+  else {
+    // Redirect to the main event page
+    drupal_goto('event');
+  }
+}
