aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Jardine <kevinjardine@yahoo.com>2012-07-17 08:57:37 -0700
committerKevin Jardine <kevinjardine@yahoo.com>2012-07-17 08:57:37 -0700
commit86d154541f9cf1de74f79cae6c1b05b3214bdca8 (patch)
tree46475df7579e0bf12c7bff62c3e125b16c641247
parent5c7dcf2a382479a4f9cf7eafeaa4eb30faed440d (diff)
parent190a81e721df6efb1d051830c1ee852c1fe7b069 (diff)
downloadelgg-86d154541f9cf1de74f79cae6c1b05b3214bdca8.tar.gz
elgg-86d154541f9cf1de74f79cae6c1b05b3214bdca8.tar.bz2
Merge pull request #33 from beck24/group-widget
Allows calendar widget to be useful in groups context
-rw-r--r--models/model.php4
-rw-r--r--start.php2
-rw-r--r--views/default/widgets/event_calendar/content.php8
-rw-r--r--views/default/widgets/event_calendar/view.php39
4 files changed, 9 insertions, 44 deletions
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/start.php b/start.php
index dd5437944..49312599f 100644
--- a/start.php
+++ b/start.php
@@ -73,7 +73,7 @@ function event_calendar_init() {
}
//add a widget
- elgg_register_widget_type('event_calendar',elgg_echo("event_calendar:widget_title"),elgg_echo('event_calendar:widget:description'));
+ elgg_register_widget_type('event_calendar',elgg_echo("event_calendar:widget_title"),elgg_echo('event_calendar:widget:description'), 'all,groups');
// add the event calendar group tool option
$event_calendar_group_default = elgg_get_plugin_setting('group_default', 'event_calendar');
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 @@
-<?php
-
-/**
- * Elgg event calendar widget
- *
- * @package event_calendar
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Kevin Jardine <kevin@radagast.biz>
- * @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 "<div id=\"widget_calendar\">";
-
- foreach($events as $event) {
- echo elgg_view("object/event_calendar",array('entity' => $event));
- }
-
- echo "</div>";
-
- }
-
-?> \ No newline at end of file