From bd6840a34cd9d3b3afabf3f6c977f8cea5a32662 Mon Sep 17 00:00:00 2001 From: Matt Beckett Date: Tue, 3 Jul 2012 12:54:06 -0600 Subject: removed old widget file Allows calendar widget to be useful in groups context --- models/model.php | 4 +-- views/default/widgets/event_calendar/content.php | 8 +++-- views/default/widgets/event_calendar/view.php | 39 ------------------------ 3 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 views/default/widgets/event_calendar/view.php diff --git a/models/model.php b/models/model.php index 2752626bc..ba1393a8c 100644 --- a/models/model.php +++ b/models/model.php @@ -1150,12 +1150,12 @@ function event_calendar_security_fields() { return "__elgg_token=$token&__elgg_ts=$ts"; } -function event_calendar_get_events_for_group($group_guid) { +function event_calendar_get_events_for_group($group_guid, $limit = 0) { $options = array( 'type' => 'object', 'subtype' => 'event_calendar', 'container_guid' => $group_guid, - 'limit' => 0, + 'limit' => $limit, ); return elgg_get_entities($options); } diff --git a/views/default/widgets/event_calendar/content.php b/views/default/widgets/event_calendar/content.php index 329046cb0..eaedb76bd 100644 --- a/views/default/widgets/event_calendar/content.php +++ b/views/default/widgets/event_calendar/content.php @@ -20,8 +20,12 @@ $num = 5; // Get the events - - $events = event_calendar_get_personal_events_for_user(elgg_get_page_owner_guid(),$num); + $owner = elgg_get_page_owner_entity(); + if(elgg_instanceof($owner, 'group')) { + $events = event_calendar_get_events_for_group(elgg_get_page_owner_guid(),$num); + } else { + $events = event_calendar_get_personal_events_for_user(elgg_get_page_owner_guid(),$num); + } // If there are any events to view, view them if (is_array($events) && sizeof($events) > 0) { diff --git a/views/default/widgets/event_calendar/view.php b/views/default/widgets/event_calendar/view.php deleted file mode 100644 index 329046cb0..000000000 --- a/views/default/widgets/event_calendar/view.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Radagast Solutions 2008 - * @link http://radagast.biz/ - * - */ - - // Load event calendar model - elgg_load_library('elgg:event_calendar'); - - //the number of events to display - $num = (int) $vars['entity']->num_display; - if (!$num) - $num = 5; - - // Get the events - - $events = event_calendar_get_personal_events_for_user(elgg_get_page_owner_guid(),$num); - - // If there are any events to view, view them - if (is_array($events) && sizeof($events) > 0) { - - echo "
"; - - foreach($events as $event) { - echo elgg_view("object/event_calendar",array('entity' => $event)); - } - - echo "
"; - - } - -?> \ No newline at end of file -- cgit v1.2.3