From 58126731fe957c604c1989d59d41534f8fbcf04b Mon Sep 17 00:00:00 2001 From: Kevin Jardine Date: Fri, 13 Apr 2012 17:20:49 +0200 Subject: added support for event polls (needs the event_poll plugin) --- actions/event_calendar/edit.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actions') diff --git a/actions/event_calendar/edit.php b/actions/event_calendar/edit.php index 0cc956d73..aef1a59cc 100644 --- a/actions/event_calendar/edit.php +++ b/actions/event_calendar/edit.php @@ -34,6 +34,10 @@ if ($event) { add_to_river('river/object/event_calendar/create','create',$user_guid,$event->guid); system_message(elgg_echo('event_calendar:add_event_response')); } + + if ($event->schedule_type == 'poll') { + forward('event_poll/add/'.$event->guid); + } forward($event->getURL()); } else { -- cgit v1.2.3 From 0e264d23ae1b4c4a186cb855ed984bb082908fbb Mon Sep 17 00:00:00 2001 From: Kevin Jardine Date: Tue, 26 Jun 2012 21:41:58 +0200 Subject: more changes to support event polls --- actions/event_calendar/modify_full_calendar.php | 13 +++++- languages/en.php | 5 ++- models/model.php | 48 +++++++++++--------- start.php | 4 +- .../default/event_calendar/full_calendar_view.php | 51 ++++++++++++++-------- 5 files changed, 76 insertions(+), 45 deletions(-) (limited to 'actions') 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(""); - revertFunc(); - } else if (!confirm("")) { + + if (!event.is_event_poll && !confirm("")) { revertFunc(); } else { + if (event.is_event_poll) { + if (confirm("")) { + 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) { -- cgit v1.2.3 From 2d605dc207541121f02fda9893509acb8e605212 Mon Sep 17 00:00:00 2001 From: Kevin Jardine Date: Wed, 27 Jun 2012 11:05:16 +0200 Subject: changed CSS to avoid form flash of irrelevant content for event polls, and deleted some commented out code --- actions/event_calendar/modify_full_calendar.php | 2 +- views/default/event_calendar/css.php | 6 ++ views/default/forms/event_calendar/edit.php | 86 ------------------------- 3 files changed, 7 insertions(+), 87 deletions(-) (limited to 'actions') diff --git a/actions/event_calendar/modify_full_calendar.php b/actions/event_calendar/modify_full_calendar.php index 9288eb0e0..1e0bd3a01 100644 --- a/actions/event_calendar/modify_full_calendar.php +++ b/actions/event_calendar/modify_full_calendar.php @@ -10,7 +10,7 @@ $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 + // special handling for event polls if (is_array($result)) { $response['minutes'] = $result['minutes']; $response['iso_date'] = $result['iso_date']; diff --git a/views/default/event_calendar/css.php b/views/default/event_calendar/css.php index b1e17e4df..c1dbf4633 100644 --- a/views/default/event_calendar/css.php +++ b/views/default/event_calendar/css.php @@ -261,10 +261,16 @@ li.event-calendar-filter-menu-show-only { .event-calendar-edit-date-wrapper { clear: both; margin-left: 20px; + display: none; } .event-calendar-edit-reminder-wrapper { margin-top: 10px; + display: none; +} + +.event-calendar-edit-form-membership-block, .event-calendar-edit-form-share-block { + display: none; } .event-calendar-description { diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php index 6ea06a6b4..2ba744fc4 100644 --- a/views/default/forms/event_calendar/edit.php +++ b/views/default/forms/event_calendar/edit.php @@ -17,7 +17,6 @@ $event_calendar_repeating_events = elgg_get_plugin_setting('repeating_events', ' $event_calendar_region_display = elgg_get_plugin_setting('region_display', 'event_calendar'); $event_calendar_type_display = elgg_get_plugin_setting('type_display', 'event_calendar'); $event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar'); -//$event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar'); $event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar'); $event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar'); @@ -71,14 +70,6 @@ $all_day = $fd['all_day']; $schedule_type = $fd['schedule_type']; $long_description = $fd['long_description']; -/*if ($event_calendar_times != 'no') { - $start_time = $fd['start_time']; - $end_time = $fd['end_time']; -} -if ($event_calendar_personal_manage == 'by_event') { - $personal_manage = $fd['personal_manage']; -}*/ - $body = '
'; $body .= elgg_view('input/hidden',array('name'=>'event_action', 'value'=>$event_action)); @@ -134,43 +125,6 @@ $body .= elgg_view('input/radio',array('id'=>'event-calendar-edit-schedule-type' $vars['prefix'] = $prefix; -/* -$body .= '
'; -$body .= elgg_view('event_calendar/datetime_edit', - array( - 'start_date' => $start_date, - 'end_date' => $end_date, - 'start_time' => $start_time, - 'end_time' => $end_time, - 'prefix' => $prefix, -)); -if ($event_calendar_repeated_events == 'yes') { - $body .= elgg_view('event_calendar/repeat_form_element',$vars); -} -if ($event_calendar_reminders == 'yes') { - $body .= '
'; - if ($send_reminder) { - $body .= elgg_view('input/checkbox',array('name'=>'send_reminder','checked' => 'checked','value'=>1)); - } else { - $body .= elgg_view('input/checkbox',array('name'=>'send_reminder','value'=>1)); - } - $body .= elgg_echo('elgg_calendar:send_reminder_label'). ' '; - $numbers = array(); - for ($i=1;$i<60;$i++) { - $numbers[$i] = $i; - } - $intervals = array( - 1 => elgg_echo('event_calendar:interval:minute'), - 60 => elgg_echo('event_calendar:interval:hour'), - 60*24 => elgg_echo('event_calendar:interval:day'), - ); - - $body .= elgg_view('input/dropdown',array('name'=>'reminder_number','options_values'=>$numbers,'value'=>$reminder_number)); - $body .= elgg_view('input/dropdown',array('name'=>'reminder_interval','options_values'=>$intervals,'value'=>$reminder_interval)); - $body .= elgg_echo('elgg_calendar:send_reminder_before'); - $body .= '
'; -}*/ - $body .= elgg_view('event_calendar/schedule_section',$vars); if ($event_calendar_spots_display == 'yes') { @@ -183,50 +137,10 @@ if ($event_calendar_spots_display == 'yes') { $body .= '
'; $body .= '
'; -// the following feature has been superceded by the manage subscribers feature - -/*if ($event_calendar_add_users == 'yes') { - $body .= '



'; - $body .= '

'.elgg_echo('event_calendar:add_user_description').'

'; -}*/ - $body .= elgg_view('event_calendar/personal_manage_section',$vars); -/*if ($event_calendar_personal_manage == 'by_event') { - $body .= '
'; - $body .= '

'.elgg_echo('event_calendar:personal_manage:label').'

'; - $body .= elgg_view("input/radio",array('name' => 'personal_manage','value'=>$personal_manage,'options'=>$personal_manage_options)); - //$body .= '

'.$prefix['personal_manage'].elgg_echo('event_calendar:personal_manage:description').'

'; - $body .= '
'; - $body .= '
'; -}*/ - $body .= elgg_view('event_calendar/share_section',$vars); -/*$body .= '';*/ - if ($event_calendar_region_display == 'yes' || $event_calendar_type_display == 'yes' || $event_calendar_fewer_fields != 'yes') { $body .= '
'; -- cgit v1.2.3