From cea13ac10598078a6489650bf69c6efc45231e03 Mon Sep 17 00:00:00 2001
From: Kevin Jardine <kevinjardine@yahoo.com>
Date: Wed, 9 May 2012 19:09:24 +0200
Subject: fixes for group event bugs

---
 views/default/event_calendar/container.php             |  6 +++++-
 views/default/event_calendar/groupprofile_calendar.php |  4 +---
 views/default/forms/event_calendar/edit.php            | 13 ++++++++-----
 3 files changed, 14 insertions(+), 9 deletions(-)

(limited to 'views/default')

diff --git a/views/default/event_calendar/container.php b/views/default/event_calendar/container.php
index fdd7da2c6..cb5c8620c 100644
--- a/views/default/event_calendar/container.php
+++ b/views/default/event_calendar/container.php
@@ -1,8 +1,12 @@
 <?php
 elgg_load_library('elgg:event_calendar');
 $site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
+$group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
 $admin = elgg_is_admin_logged_in();
-$containers = array(0 => elgg_echo('event_calendar:site_calendar'));
+$containers = array();
+if (($site_calendar != 'no') && ($admin || !$site_calendar || ($site_calendar == 'loggedin'))) {
+	$containers[0] = elgg_echo('event_calendar:site_calendar');
+}
 $user = elgg_get_logged_in_user_entity();
 $groups = $user->getGroups('',0,0);
 foreach ($groups as $group) {
diff --git a/views/default/event_calendar/groupprofile_calendar.php b/views/default/event_calendar/groupprofile_calendar.php
index 7ee09104f..c71780be8 100644
--- a/views/default/event_calendar/groupprofile_calendar.php
+++ b/views/default/event_calendar/groupprofile_calendar.php
@@ -26,10 +26,8 @@ if (event_calendar_activated_for_group($page_owner_entity)) {
 	if (is_array($events) && sizeof($events) > 0) {
 
 		foreach($events as $event) {
-			echo elgg_view("object/event_calendar",array('entity' => $event));
+			echo elgg_view("object/event_calendar",array('entity' => $event['event']));
 		}
 			
     }
 }
-	
-?>
\ No newline at end of file
diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php
index d1c7967c3..278fdddce 100644
--- a/views/default/forms/event_calendar/edit.php
+++ b/views/default/forms/event_calendar/edit.php
@@ -140,7 +140,6 @@ $body = '<div class="event-calendar-edit-form">';
 
 $body .= elgg_view('input/hidden',array('name'=>'event_action', 'value'=>$event_action));
 $body .= elgg_view('input/hidden',array('name'=>'event_guid', 'value'=>$event_guid));
-//$body .= elgg_view('input/hidden',array('name'=>'group_guid', 'value'=>$vars['group_guid']));
 
 $body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-top-block">';
 
@@ -164,10 +163,14 @@ $body .= elgg_view("input/tags",array('name' => 'tags','class'=>'event-calendar-
 $body .= '</p>';
 $body .= '<p class="event-calendar-description">'.$prefix['event_tags'].elgg_echo('event_calendar:event_tags_description').'</p>';
 
-$body .= '<p><label>'.elgg_echo("event_calendar:calendar_label").'</label>';
-$body .= elgg_view('event_calendar/container',array('container_guid'=>$vars['group_guid']));
-$body .= '</p>';
-$body .= '<p class="event-calendar-description">'.$prefix['calendar'].elgg_echo('event_calendar:calendar_description').'</p>';
+if ($event || !$vars['group_guid']) {
+	$body .= '<p><label>'.elgg_echo("event_calendar:calendar_label").'</label>';
+	$body .= elgg_view('event_calendar/container',array('container_guid'=>$vars['group_guid']));
+	$body .= '</p>';
+	$body .= '<p class="event-calendar-description">'.$prefix['calendar'].elgg_echo('event_calendar:calendar_description').'</p>';
+} else {
+	$body .= elgg_view('input/hidden',array('name'=>'group_guid', 'value'=>$vars['group_guid']));
+}
 
 if($event_calendar_bbb_server_url) {
 	$body .= '<p>';
-- 
cgit v1.2.3