aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/event_calendar/modify_full_calendar.php13
-rw-r--r--languages/en.php5
-rw-r--r--models/model.php48
-rw-r--r--start.php4
-rw-r--r--views/default/event_calendar/full_calendar_view.php51
5 files changed, 76 insertions, 45 deletions
diff --git a/actions/event_calendar/modify_full_calendar.php b/actions/event_calendar/modify_full_calendar.php
index 595bdbe4b..9288eb0e0 100644
--- a/actions/event_calendar/modify_full_calendar.php
+++ b/actions/event_calendar/modify_full_calendar.php
@@ -3,9 +3,18 @@ elgg_load_library('elgg:event_calendar');
$event_guid = get_input('event_guid',0);
$day_delta = get_input('dayDelta');
$minute_delta = get_input('minuteDelta','');
-
-if (event_calendar_modify_full_calendar($event_guid,$day_delta,$minute_delta)) {
+$start_time = get_input('startTime','');
+$resend = get_input('resend','');
+$minutes = get_input('minutes');
+$iso_date = get_input('iso_date');
+$result = event_calendar_modify_full_calendar($event_guid,$day_delta,$minute_delta,$start_time,$resend,$minutes,$iso_date);
+if ($result) {
$response = array('success'=>TRUE);
+ // specially handling for event polls
+ if (is_array($result)) {
+ $response['minutes'] = $result['minutes'];
+ $response['iso_date'] = $result['iso_date'];
+ }
} else {
$response = array('success'=>FALSE, 'message' =>elgg_echo('event_calendar:modify_full_calendar:error'));
}
diff --git a/languages/en.php b/languages/en.php
index 3d8c94e3f..3fd9cf7cb 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -309,8 +309,6 @@ You can manage calendar requests for this event here:
'event_calendar:settings:repeated_events:title' => "Allow repeated events (currently only works properly in full calendar mode)",
'event_calendar:settings:reminders:title' => "Allow sending reminders",
'event_calendar:reminder:subject' => "Reminder for event: %s",
- 'event_calendar:poll_suffix' => "(poll)",
- 'event_calendar:cannot_drag_polls' => "Cannot change event polls.",
'event_calendar:reminder:body' => "The event
%s
@@ -332,6 +330,9 @@ You can visit the event page here:
'event_calendar:bbb_create_error' => "Error: unable to create BBB conference, message was: %s",
'event_calendar:bbb_settings_error' => "Error: must set conference URL and salt in plugin settings",
'event_calendar:join_conf_button' => "Join conference",
+
+ 'event_calendar:poll_suffix' => "(poll)",
+ 'event_calendar:resend_poll_invitation' => "Do you want to alert poll invitees that the options have changed?",
/**
* Event calendar river
diff --git a/models/model.php b/models/model.php
index aea6bca2f..2752626bc 100644
--- a/models/model.php
+++ b/models/model.php
@@ -2091,28 +2091,34 @@ function getLastDayOfMonth($month,$year) {
return idate('d', mktime(0, 0, 0, ($month + 1), 0, $year));
}
-// TODO - this is not quite right across daylight savings time divides
-// Possible solution: convert stored date to server date, do inc and then convert back to GMT
-
-function event_calendar_modify_full_calendar($event_guid,$day_delta,$minute_delta) {
+function event_calendar_modify_full_calendar($event_guid,$day_delta,$minute_delta,$start_time,$resend,$minutes,$iso_date) {
$event = get_entity($event_guid);
if (elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
- $event->start_date = strtotime("$day_delta days",$event->start_date)+60*$minute_delta;
- if ($event->end_date) {
- $event->end_date = strtotime("$day_delta days",$event->end_date);
- }
- $times = elgg_get_plugin_setting('times','event_calendar');
- //$inc = 24*60*60*$day_delta+60*$minute_delta;
-
- //$event->real_end_time += $inc;
- $event->real_end_time = strtotime("$day_delta days",$event->real_end_time)+60*$minute_delta;
- if ($times != 'no') {
- $event->start_time += $minute_delta;
- if ($event->end_time) {
- $event->end_time += $minute_delta;
+ if ($event->is_event_poll) {
+ if (elgg_is_active_plugin('event_poll')) {
+ elgg_load_library('elgg:event_poll');
+ return event_poll_change($event_guid,$day_delta,$minute_delta,$start_time,$resend,$minutes,$iso_date);
+ } else {
+ return FALSE;
+ }
+ } else {
+ $event->start_date = strtotime("$day_delta days",$event->start_date)+60*$minute_delta;
+ if ($event->end_date) {
+ $event->end_date = strtotime("$day_delta days",$event->end_date);
}
+ $times = elgg_get_plugin_setting('times','event_calendar');
+ //$inc = 24*60*60*$day_delta+60*$minute_delta;
+
+ //$event->real_end_time += $inc;
+ $event->real_end_time = strtotime("$day_delta days",$event->real_end_time)+60*$minute_delta;
+ if ($times != 'no') {
+ $event->start_time += $minute_delta;
+ if ($event->end_time) {
+ $event->end_time += $minute_delta;
+ }
+ }
+ return TRUE;
}
- return TRUE;
}
return FALSE;
}
@@ -2134,14 +2140,13 @@ function event_calendar_get_page_content_fullcalendar_events($start_date,$end_da
}
$event_array = array();
$times_supported = elgg_get_plugin_setting('times','event_calendar') != 'no';
- $polls_supported = elgg_plugin_exists('event_poll');
+ $polls_supported = elgg_is_active_plugin('event_poll');
foreach($events as $e) {
$event = $e['event'];
$event_data = $e['data'];
$c = count($event_data);
foreach($event_data as $ed) {
$event_item = array(
- 'id' => $event->guid,
'guid' => $event->guid,
'title' => $event->title,
'start' => date('c',$ed['start_time']),
@@ -2158,7 +2163,10 @@ function event_calendar_get_page_content_fullcalendar_events($start_date,$end_da
$event_item['title'] .= ' '.elgg_echo('event_calendar:poll_suffix');
$event_item['is_event_poll'] = TRUE;
$event_item['url'] = elgg_get_site_url().'event_poll/vote/'.$event->guid;
+ $event_item['minutes'] = $ed['minutes'];
+ $event_item['iso_date'] = $ed['iso_date'];
} else {
+ $event_item['id'] = $event->guid;
$event_item['is_event_poll'] = FALSE;
$event_item['url'] = elgg_get_site_url().'event_calendar/view_light_box/'.$event->guid;
}
diff --git a/start.php b/start.php
index ebd88d541..dd5437944 100644
--- a/start.php
+++ b/start.php
@@ -66,7 +66,7 @@ function event_calendar_init() {
elgg_extend_view('css/elgg', 'event_calendar/css');
$event_calendar_listing_format = elgg_get_plugin_setting('listing_format', 'event_calendar');
- if (elgg_plugin_exists('event_poll') || ($event_calendar_listing_format == 'full')) {
+ if (elgg_is_active_plugin('event_poll') || ($event_calendar_listing_format == 'full')) {
elgg_extend_view('css/elgg', 'fullcalendar/css');
$plugin_js = elgg_get_simplecache_url('js', 'event_calendar/fullcalendar');
elgg_register_js('elgg.full_calendar', $plugin_js);
@@ -293,7 +293,7 @@ function event_calendar_entity_menu_setup($hook, $type, $return, $params) {
if ($handler != 'event_calendar') {
return $return;
}
- if (elgg_plugin_exists('event_poll') && $entity->canEdit() && $entity->schedule_type == 'poll') {
+ if (elgg_is_active_plugin('event_poll') && $entity->canEdit() && $entity->schedule_type == 'poll') {
$options = array(
'name' => 'schedule',
'text' => elgg_echo('event_poll:schedule_button'),
diff --git a/views/default/event_calendar/full_calendar_view.php b/views/default/event_calendar/full_calendar_view.php
index 6ba8fe892..4316b5359 100644
--- a/views/default/event_calendar/full_calendar_view.php
+++ b/views/default/event_calendar/full_calendar_view.php
@@ -54,21 +54,32 @@ handleDayClick = function(date,allDay,jsEvent,view) {
}
handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) {
- if (event.is_event_poll) {
- alert("<?php echo elgg_echo('event_calendar:cannot_drag_polls'); ?>");
- revertFunc();
- } else if (!confirm("<?php echo elgg_echo('event_calendar:are_you_sure'); ?>")) {
+
+ if (!event.is_event_poll && !confirm("<?php echo elgg_echo('event_calendar:are_you_sure'); ?>")) {
revertFunc();
} else {
+ if (event.is_event_poll) {
+ if (confirm("<?php echo elgg_echo('event_calendar:resend_poll_invitation'); ?>")) {
+ var resend = 1;
+ } else {
+ resend = 0;
+ }
+ var data = {event_guid: event.guid, startTime: event.start.toISOString(), dayDelta: dayDelta, minuteDelta: minuteDelta, resend: resend, minutes: event.minutes, iso_date: event.iso_date};
+ } else {
+ data = {event_guid: event.guid, startTime: event.start.toISOString(), dayDelta: dayDelta, minuteDelta: minuteDelta};
+ }
elgg.action('event_calendar/modify_full_calendar',
{
- data: {event_guid: event.guid,dayDelta: dayDelta, minuteDelta: minuteDelta},
+ data: data,
success: function (res) {
var success = res.success;
var msg = res.message;
if (!success) {
elgg.register_error(msg,2000);
revertFunc()
+ } else {
+ event.minutes = res.minutes;
+ event.iso_date = res.iso_date;
}
}
}
@@ -86,9 +97,9 @@ getISODate = function(d) {
}
handleEventRender = function(event, element, view) {
- if (event.is_event_poll) {
+ /*if (event.is_event_poll) {
element.draggable = false;
- }
+ }*/
}
handleGetEvents = function(start, end, callback) {
@@ -103,19 +114,21 @@ handleGetEvents = function(start, end, callback) {
// reset date links and classes
//$('.fc-widget-content').removeClass('event-calendar-date-selected');
var link = $('.elgg-menu-item-event-calendar-0add').find('a').attr('href');
- var ss = link.split('/');
- var last_ss = ss[ss.length-1];
- var group_guid;
- if (last_ss == 'add') {
- group_guid = 0;
- } else if (last_ss.split('-').length == 3) {
- group_guid = ss[ss.length-2];
- } else {
- group_guid = last_ss;
+ if (link != undefined) {
+ var ss = link.split('/');
+ var last_ss = ss[ss.length-1];
+ var group_guid;
+ if (last_ss == 'add') {
+ group_guid = 0;
+ } else if (last_ss.split('-').length == 3) {
+ group_guid = ss[ss.length-2];
+ } else {
+ group_guid = last_ss;
+ }
+ var url = elgg.get_site_url();
+ $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid);
+ $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid);
}
- var url = elgg.get_site_url();
- $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid);
- $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid);
}
handleViewDisplay = function(view) {