--- og_calender.module	2008-11-11 22:54:57.000000000 +0100
+++ og_calendar.module	2008-11-12 17:43:53.000000000 +0100
@@ -68,7 +68,7 @@ function og_calendar_menu() { 
  *   display "Could not access any events."
  */
 function og_calendar_page($group = NULL, $year = NULL, $month = NULL, $day = NULL) {  
-  if ($group) {
+  if ($group && og_is_group_type($group->type)) {
   	$gid = $group->nid;
     og_set_group_context($group);
     $bc[] = l(t('Home'), '');
@@ -127,7 +128,17 @@ function og_calendar_page($group = NULL,
     drupal_goto('event');
   }
 }
-
+/**
+ * Implementation of hook_db_rewrite_sql().
+ */
+function og_calendar_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
+  if ($args["event_get_events_event"] && $args["og_nid"]) {
+    $array = array();
+    $array['join'] = "JOIN {og_ancestry} og ON og.nid = n.nid";
+    $array['where'] = "group_nid = " .$args["og_nid"];
+    return $array; 
+  }
+}
 /**
  * Provide a link to the previous or next month for which an event is found.
  * Adapted from _event_nav().

