aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--languages/en.php5
-rw-r--r--models/model.php225
-rw-r--r--start.php1
-rw-r--r--views/default/event_calendar/css.php7
-rw-r--r--views/default/event_calendar/datetime_edit.php12
-rw-r--r--views/default/event_calendar/full_calendar_view.php2
-rw-r--r--views/default/event_calendar/personal_manage_section.php20
-rw-r--r--views/default/event_calendar/reminder_section.php28
-rw-r--r--views/default/event_calendar/schedule_section.php22
-rw-r--r--views/default/event_calendar/share_section.php26
-rw-r--r--views/default/forms/event_calendar/edit.php110
-rw-r--r--views/default/input/datepicker_inline.php3
-rw-r--r--views/default/input/timepicker.php90
-rw-r--r--views/default/js/event_calendar/event_calendar.php24
14 files changed, 345 insertions, 230 deletions
diff --git a/languages/en.php b/languages/en.php
index 5f060748c..782cd7a72 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -290,6 +290,7 @@ You can manage calendar requests for this event here:
'event_calendar:site_calendar' => "Site-wide calendar",
'event_calendar:calendar_label' => "Calendar",
'event_calendar:calendar_description' => "Calendar for this event.",
+ 'event_calendar:are_you_sure' => "Are you sure about this change?",
'event_calendar:schedule:header' => "Schedule",
'event_calendar:permissions:header' => "Permissions",
'event_calendar:read_access' => "Read access",
@@ -298,6 +299,9 @@ You can manage calendar requests for this event here:
'event_calendar:share_ownership:description' => "Allow the following people to edit or delete this event, invite participants, etc.",
'event_calendar:settings:fewer_fields:title' => "Hide fees, contact, organiser and long description fields",
'event_calendar:settings:restricted_times:title' => "Restricted time to between 6am and 9pm (6:00 and 21:00)",
+ 'event_calendar:add_event' => "Add event",
+ 'event_calendar:schedule_event' => "Schedule event",
+ 'event_calendar:list_polls' => "List event polls",
'event_calendar:edit_form:error:missing_title' => "Error: please supply the missing title.",
'event_calendar:repeated_event:week_interval' => "every %s weeks.",
'event_calendar:repeated_event:week_single' => "every week.",
@@ -305,6 +309,7 @@ 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:reminder:body' => "The event
%s
diff --git a/models/model.php b/models/model.php
index 042d21736..7de514802 100644
--- a/models/model.php
+++ b/models/model.php
@@ -22,6 +22,22 @@ function event_calendar_get_event_for_edit($event_id) {
}
}
+// converts to time in minutes since midnight
+function event_calendar_convert_to_time($hour,$minute,$meridian) {
+ if ($meridian) {
+ if ($meridian == 'am') {
+ if ($hour == 12) {
+ $hour = 0;
+ }
+ } else {
+ if ($hour < 12) {
+ $hour += 12;
+ }
+ }
+ }
+ return 60*$hour+$minute;
+}
+
// returns the event or FALSE
function event_calendar_set_event_from_form($event_guid,$group_guid) {
@@ -33,6 +49,7 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
$event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar');
$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
$event_calendar_repeating_events = elgg_get_plugin_setting('repeating_events', 'event_calendar');
+ $schedule_type = get_input('schedule_type');
if ($event_calendar_more_required == 'yes') {
$required_fields = array('title','venue','start_date',
@@ -80,41 +97,47 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
$event->description = get_input('description');
$event->venue = get_input('venue');
- $start_date = get_input('start_date');
- $event->original_start_date = get_input('start_date');
- //$end_date = trim(get_input('end_date',''));
- // convert start date from current server time to GMT
- $start_date_text = gmdate("Y-m-d",$start_date);
- //$event->munged_start_date_string = $start_date_text." ".date_default_timezone_get();
-
- $event->start_date = strtotime($start_date_text." ".date_default_timezone_get());
- $end_date = trim(get_input('end_date',''));
- $event->original_end_date = get_input('end_date');
- if ($end_date) {
- $end_date_text = gmdate("Y-m-d",$end_date);
- $event->end_date = strtotime($end_date_text." ".date_default_timezone_get());
- //$event->munged_end_date_string = $end_date_text." ".date_default_timezone_get();
- } else {
- $event->end_date = '';
- }
-
- if ($event_calendar_times != 'no') {
- $st = get_input('start_time','');
- if (is_numeric($st)) {
- $event->start_time = $st;
- } else {
- $event->start_time = '';
- }
- $et = get_input('end_time','');
- if (is_numeric($et)) {
- $event->end_time = $et;
+ if ($schedule_type != 'poll') {
+ $start_date_text = trim(get_input('start_date'));
+ /*$event->original_start_date = get_input('start_date');
+ //$end_date = trim(get_input('end_date',''));
+ // convert start date from current server time to GMT
+ $start_date_text = gmdate("Y-m-d",$start_date);
+ //$event->munged_start_date_string = $start_date_text." ".date_default_timezone_get();*/
+
+ // TODO: is the timezone bit necessary?
+ $event->start_date = strtotime($start_date_text." ".date_default_timezone_get());
+ $end_date_text = trim(get_input('end_date',''));
+ //$event->original_end_date = get_input('end_date');
+ if ($end_date_text) {
+ $event->end_date = strtotime($end_date_text." ".date_default_timezone_get());
+ //$event->munged_end_date_string = $end_date_text." ".date_default_timezone_get();
} else {
- $event->end_time = '';
+ $event->end_date = '';
}
- if (is_numeric($event->start_time)) {
- // Set start date to the Unix start time, if set.
- // This allows sorting by date *and* time.
- $event->start_date += $event->start_time*60;
+
+ if ($event_calendar_times != 'no') {
+ $hour = get_input('start_time_hour','');
+ $minute = get_input('start_time_minute','');
+ $meridian = get_input('start_time_meridian','');
+ if (is_numeric($hour) && is_numeric($minute)) {
+ $event->start_time = event_calendar_convert_to_time($hour,$minute,$meridian);
+ } else {
+ $event->start_time = '';
+ }
+ $hour = get_input('end_time_hour','');
+ $minute = get_input('end_time_minute','');
+ $meridian = get_input('end_time_meridian','');
+ if (is_numeric($hour) && is_numeric($minute)) {
+ $event->end_time = event_calendar_convert_to_time($hour,$minute,$meridian);
+ } else {
+ $event->end_time = '';
+ }
+ if (is_numeric($event->start_date) && is_numeric($event->start_time)) {
+ // Set start date to the Unix start time, if set.
+ // This allows sorting by date *and* time.
+ $event->start_date += $event->start_time*60;
+ }
}
}
if ($event_calendar_spots_display == 'yes') {
@@ -147,8 +170,7 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
$event->organiser = get_input('organiser');
$event->tags = string_to_tag_array(get_input('tags'));
$event->long_description = get_input('long_description');
- $event->all_day = get_input('all_day');
- $event->schedule_type = get_input('schedule_type');
+ $event->schedule_type = $schedule_type;
$event->send_reminder = get_input('send_reminder');
$event->reminder_number = get_input('reminder_number');
$event->reminder_interval = get_input('reminder_interval');
@@ -193,7 +215,8 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) {
return $event;
}
-function event_calendar_get_events_between($start_date,$end_date,$is_count=FALSE,$limit=10,$offset=0,$container_guid=0,$region='-') {
+function event_calendar_get_events_between($start_date,$end_date,$is_count=FALSE,$limit=10,$offset=0,$container_guid=0,$region='-') {
+ $polls_supported = elgg_is_active_plugin('event_poll');
if ($is_count) {
$count = event_calendar_get_entities_from_metadata_between2('start_date','end_date',
$start_date, $end_date, "object", "event_calendar", 0, $container_guid, $limit,$offset,"",0,false,true,$region);
@@ -203,6 +226,11 @@ function event_calendar_get_events_between($start_date,$end_date,$is_count=FALSE
$start_date, $end_date, "object", "event_calendar", 0, $container_guid, $limit,$offset,"",0,false,false,$region);
$repeating_events = event_calendar_get_repeating_events_between($start_date,$end_date,$container_guid,$region);
$all_events = event_calendar_merge_repeating_events($events, $repeating_events);
+ if ($polls_supported) {
+ elgg_load_library('elgg:event_poll');
+ $all_events = event_poll_merge_poll_events($all_events,$start_date,$end_date);
+ }
+
return $all_events;
}
}
@@ -1204,10 +1232,12 @@ function event_calendar_get_formatted_full_items($event) {
$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_items = array();
- $item = new stdClass();
- $item->title = elgg_echo('event_calendar:when_label');
- $item->value = $time_bit;
- $event_items[] = $item;
+ if ($time_bit) {
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:when_label');
+ $item->value = $time_bit;
+ $event_items[] = $item;
+ }
$item = new stdClass();
$item->title = elgg_echo('event_calendar:venue_label');
$item->value = htmlspecialchars($event->venue);
@@ -1244,6 +1274,9 @@ function event_calendar_get_formatted_full_items($event) {
}
function event_calendar_get_formatted_time($event) {
+ if (!$event->start_date) {
+ return '';
+ }
$date_format = 'j M Y';
$event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar') != 'no';
@@ -1448,18 +1481,9 @@ function event_calendar_get_page_content_list($page_type,$container_guid,$start_
elgg_push_context('groups');
elgg_set_page_owner_guid($container_guid);
$user_guid = elgg_get_logged_in_user_guid();
- $group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
- if (!$group_calendar || $group_calendar == 'members') {
- if (elgg_get_page_owner_entity()->canWriteToContainer($user_guid)){
- elgg_register_menu_item('title', array(
- 'name' => 'add',
- 'href' => "event_calendar/add/".$container_guid,
- 'text' => elgg_echo('event_calendar:add'),
- 'class' => 'elgg-button elgg-button-action',
- ));
- }
- } else if ($group_calendar == 'admin') {
- if (elgg_is_admin_logged_in() || ($group->owner_guid == $user_guid)) {
+ // TODO - ideally avoid the check on the event_poll plugin, perhaps by having event_poll remove the menu item
+ if(event_calendar_can_add($container_guid)) {
+ if (!elgg_plugin_exists('event_poll')) {
elgg_register_menu_item('title', array(
'name' => 'add',
'href' => "event_calendar/add/".$container_guid,
@@ -1470,20 +1494,9 @@ function event_calendar_get_page_content_list($page_type,$container_guid,$start_
}
} else {
elgg_push_breadcrumb(elgg_echo('item:object:event_calendar'));
- $site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
- if (!$site_calendar || $site_calendar == 'admin') {
- // only admins can post directly to the site-wide calendar
- if (elgg_is_admin_logged_in()) {
- elgg_register_menu_item('title', array(
- 'name' => 'add',
- 'href' => "event_calendar/add",
- 'text' => elgg_echo('event_calendar:add'),
- 'class' => 'elgg-button elgg-button-action',
- ));
- }
- } else if ($site_calendar == 'loggedin') {
- // any logged-in user can post to the site calendar
- if (elgg_is_logged_in()) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ if(event_calendar_can_add($container_guid)) {
+ if (!elgg_plugin_exists('event_poll')) {
elgg_register_menu_item('title', array(
'name' => 'add',
'href' => "event_calendar/add",
@@ -1535,7 +1548,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
$event = get_entity((int)$guid);
if (elgg_instanceof($event, 'object', 'event_calendar') && $event->canEdit()) {
$body_vars['event'] = $event;
- $body_vars['form_data'] = event_calendar_prepare_edit_form_vars($event);
+ $body_vars['form_data'] = event_calendar_prepare_edit_form_vars($event,$page_type);
$event_container = get_entity($event->container_guid);
if (elgg_instanceof($event_container, 'group')) {
@@ -1554,6 +1567,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
}
} else {
$title = elgg_echo('event_calendar:add_event_title');
+
if ($guid) {
// add to group
$group = get_entity($guid);
@@ -1561,7 +1575,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
$body_vars['group_guid'] = $guid;
elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$guid);
elgg_push_breadcrumb(elgg_echo('event_calendar:add_event_title'));
- $body_vars['form_data'] = event_calendar_prepare_edit_form_vars();
+ $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type);
$content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
} else {
$content = elgg_echo('event_calendar:no_group');
@@ -1571,7 +1585,7 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
elgg_push_breadcrumb(elgg_echo('event_calendar:add_event_title'));
- $body_vars['form_data'] = event_calendar_prepare_edit_form_vars();
+ $body_vars['form_data'] = event_calendar_prepare_edit_form_vars(NULL,$page_type);
$content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
}
@@ -1590,17 +1604,22 @@ function event_calendar_get_page_content_edit($page_type,$guid) {
* @param ElggObject $event
* @return array
*/
-function event_calendar_prepare_edit_form_vars($event = NULL) {
+function event_calendar_prepare_edit_form_vars($event = NULL, $page_type = '') {
// input names => defaults
+ $now = time();
+ $iso_date = date('Y-m-d',$now);
+ $now_midnight = strtotime($iso_date);
+ $start_time = floor(($now-$now_midnight)/60) + 60;
+ $start_time = floor($start_time/5)*5;
$values = array(
'title' => NULL,
'description' => NULL,
'venue' => NULL,
- 'start_date' => NULL,
- 'end_date' => NULL,
- 'start_time' => NULL,
- 'end_time' => NULL,
+ 'start_date' => $now+60*60,
+ 'end_date' => $now+2*60*60,
+ 'start_time' => $start_time,
+ 'end_time' => $start_time + 60,
'spots' => NULL,
'region' => '-',
'event_type' => '-',
@@ -1608,11 +1627,9 @@ function event_calendar_prepare_edit_form_vars($event = NULL) {
'contact' => NULL,
'organiser' => NULL,
'tags' => NULL,
- 'all_day' => 0,
'send_reminder' => NULL,
'reminder_number' => 1,
'reminder_interval' => 60,
- 'schedule_type' => 'fixed',
'repeats' => NULL,
'repeat_interval' => 1,
'event-calendar-repeating-monday-value' => 0,
@@ -1628,6 +1645,12 @@ function event_calendar_prepare_edit_form_vars($event = NULL) {
'access_id' => ACCESS_DEFAULT,
'group_guid' => NULL,
);
+
+ if ($page_type == 'schedule') {
+ $values['schedule_type'] = 'poll';
+ } else {
+ $values['schedule_type'] = 'fixed';
+ }
if ($event) {
foreach (array_keys($values) as $field) {
@@ -2102,6 +2125,7 @@ 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');
foreach($events as $e) {
$event = $e['event'];
$event_data = $e['data'];
@@ -2115,11 +2139,16 @@ function event_calendar_get_page_content_fullcalendar_events($start_date,$end_da
'start' => date('c',$ed['start_time']),
'end' => date('c',$ed['end_time']),
);
- if (!$times_supported || $event->all_day) {
+ if (!$times_supported || ($event->schedule_type == 'all_day')) {
$event_item['allDay'] = TRUE;
} else {
$event_item['allDay'] = FALSE;
}
+
+ if ($polls_supported && isset($e['is_event_poll']) && $e['is_event_poll']) {
+ $event_item['className'] = 'event-poll-class';
+ $event_item['title'] .= ' '.elgg_echo('event_calendar:poll_suffix');
+ }
$event_array[] = $event_item;
}
@@ -2298,3 +2327,45 @@ function event_calendar_get_join_bbb_url($event) {
return $url;
}
+// returns TRUE if the given user can add an event to the given calendar
+// if group_guid is 0, this is assumed to be the site calendar
+function event_calendar_can_add($group_guid=0,$user_guid=0) {
+ if (!$user_guid) {
+ if (elgg_is_logged_in()) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ } else {
+ return FALSE;
+ }
+ }
+ if ($group_guid) {
+ if (!event_calendar_activated_for_group($group_guid)) {
+ return FALSE;
+ }
+ $group = get_entity($group_guid);
+ if (elgg_instanceof($group,'group')) {
+ $group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
+ if (!$group_calendar || $group_calendar == 'members') {
+ return $group->canWriteToContainer($user_guid);
+ } else if ($group_calendar == 'admin') {
+ if ($group->canEdit($user_guid)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+ } else {
+ return FALSE;
+ }
+ } else {
+ $site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
+ if (!$site_calendar || $site_calendar == 'admin') {
+ // only admins can post directly to the site-wide calendar
+ return elgg_is_admin_user($user_guid);
+ } else if ($site_calendar == 'loggedin') {
+ // any logged-in user can post to the site calendar
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/start.php b/start.php
index 4c17c719b..c9f95c8d6 100644
--- a/start.php
+++ b/start.php
@@ -190,6 +190,7 @@ function event_calendar_page_handler($page) {
case 'manage_users':
echo event_calendar_get_page_content_manage_users($page[1]);
break;
+ case 'schedule':
case 'add':
if (isset($page[1])) {
group_gatekeeper();
diff --git a/views/default/event_calendar/css.php b/views/default/event_calendar/css.php
index 4d68f500f..9461a7fe9 100644
--- a/views/default/event_calendar/css.php
+++ b/views/default/event_calendar/css.php
@@ -269,4 +269,9 @@ li.event-calendar-filter-menu-show-only {
.event-calendar-description {
display: none;
-} \ No newline at end of file
+}
+
+.event-calendar-edit-bottom {
+ clear: both;
+ margin-bottom: 5px;
+}
diff --git a/views/default/event_calendar/datetime_edit.php b/views/default/event_calendar/datetime_edit.php
index aa3a8f2de..ceceeb20e 100644
--- a/views/default/event_calendar/datetime_edit.php
+++ b/views/default/event_calendar/datetime_edit.php
@@ -9,16 +9,16 @@ if ($event_calendar_times != 'no') {
$body .= '<p><label>'.elgg_echo('event_calendar:from_label').'</label>';
}
$body .= elgg_view("event_calendar/input/date_local",array(
- 'timestamp'=>TRUE,
+ //'timestamp'=>TRUE,
'autocomplete'=>'off',
'class'=>'event-calendar-compressed-date',
'name' => 'start_date',
'value'=>$vars['start_date']));
$body .= elgg_view("input/timepicker",array('name' => 'start_time','value'=>$vars['start_time']));
if ($event_calendar_hide_end != 'yes') {
- $body .= '</p><p><label>'.elgg_echo('event_calendar:to_label').'</label>';
+ $body .= '</p><p id="event-calendar-to-time-wrapper"><label>'.elgg_echo('event_calendar:to_label').'</label>';
$body .= elgg_view("event_calendar/input/date_local",array(
- 'timestamp'=>TRUE,
+ //'timestamp'=>TRUE,
'autocomplete'=>'off',
'class'=>'event-calendar-compressed-date',
'name' => 'end_date',
@@ -26,7 +26,7 @@ if ($event_calendar_times != 'no') {
));
$body .= elgg_view("input/timepicker",array('name' => 'end_time','value'=>$vars['end_time']));
}
- $body .= '</p>';
+ $body .= '</p></span>';
} else {
$body .= '<p><label>'.elgg_echo("event_calendar:start_date_label").'<br />';
@@ -35,10 +35,10 @@ if ($event_calendar_times != 'no') {
$body .= '<p class="description">'.$prefix['start_date'].elgg_echo('event_calendar:start_date_description').'</p>';
if ($event_calendar_hide_end != 'yes') {
- $body .= '<p><label>'.elgg_echo("event_calendar:end_date_label").'<br />';
+ $body .= '<p id="event-calendar-to-time-wrapper"><label>'.elgg_echo("event_calendar:end_date_label").'<br />';
$body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE,'autocomplete'=>'off','name' => 'end_date','value'=>$vars['end_date']));
$body .= '</label></p>';
- $body .= '<p class="description">'.$prefix['end_date'].elgg_echo('event_calendar:end_date_description').'</p>';
+ //$body .= '<p class="description">'.$prefix['end_date'].elgg_echo('event_calendar:end_date_description').'</p>';
}
}
diff --git a/views/default/event_calendar/full_calendar_view.php b/views/default/event_calendar/full_calendar_view.php
index 6c21c42c8..5fffff624 100644
--- a/views/default/event_calendar/full_calendar_view.php
+++ b/views/default/event_calendar/full_calendar_view.php
@@ -14,7 +14,7 @@ handleEventClick = function(event) {
handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) {
- if (!confirm("Are you sure about this change?")) {
+ if (!confirm("<?php echo elgg_echo('event_calendar:are_you_sure'); ?>")) {
revertFunc();
} else {
elgg.action('event_calendar/modify_full_calendar',
diff --git a/views/default/event_calendar/personal_manage_section.php b/views/default/event_calendar/personal_manage_section.php
new file mode 100644
index 000000000..9e03db0ab
--- /dev/null
+++ b/views/default/event_calendar/personal_manage_section.php
@@ -0,0 +1,20 @@
+<?php
+$fd = $vars['form_data'];
+$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
+$body = '';
+
+if ($event_calendar_personal_manage == 'by_event') {
+ $personal_manage_options = array(
+ elgg_echo('event_calendar:personal_manage:by_event:open') => 'open',
+ elgg_echo('event_calendar:personal_manage:by_event:closed') => 'closed',
+ elgg_echo('event_calendar:personal_manage:by_event:private') => 'private',
+ );
+ $body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-membership-block">';
+ $body .= '<h2>'.elgg_echo('event_calendar:personal_manage:label').'</h2>';
+ $body .= elgg_view("input/radio",array('name' => 'personal_manage','value'=>$fd['personal_manage'],'options'=>$personal_manage_options));
+ //$body .= '<p class="event-calendar-description">'.$prefix['personal_manage'].elgg_echo('event_calendar:personal_manage:description').'</p>';
+ $body .= '<br clear="both" />';
+ $body .= '</div>';
+}
+
+echo $body;
diff --git a/views/default/event_calendar/reminder_section.php b/views/default/event_calendar/reminder_section.php
new file mode 100644
index 000000000..fffa6d065
--- /dev/null
+++ b/views/default/event_calendar/reminder_section.php
@@ -0,0 +1,28 @@
+<?php
+$fd = $vars['form_data'];
+$event_calendar_reminders = elgg_get_plugin_setting('reminders', 'event_calendar');
+$body = '';
+if ($event_calendar_reminders == 'yes') {
+ $body .= '<div class="event-calendar-edit-reminder-wrapper">';
+ if ($fd['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'=>$fd['reminder_number']));
+ $body .= elgg_view('input/dropdown',array('name'=>'reminder_interval','options_values'=>$intervals,'value'=>$fd['reminder_interval']));
+ $body .= elgg_echo('elgg_calendar:send_reminder_before');
+ $body .= '</div>';
+}
+echo $body;
diff --git a/views/default/event_calendar/schedule_section.php b/views/default/event_calendar/schedule_section.php
new file mode 100644
index 000000000..3a74dc789
--- /dev/null
+++ b/views/default/event_calendar/schedule_section.php
@@ -0,0 +1,22 @@
+<?php
+$event = $vars['event'];
+$fd = $vars['form_data'];
+$event_calendar_repeated_events = elgg_get_plugin_setting('repeated_events', 'event_calendar');
+
+$body = '<div class="event-calendar-edit-date-wrapper">';
+$body .= elgg_view('event_calendar/datetime_edit',
+ array(
+ 'start_date' => $fd['start_date'],
+ 'end_date' => $fd['end_date'],
+ 'start_time' => $fd['start_time'],
+ 'end_time' => $fd['end_time'],
+ 'prefix' => $vars['prefix'],
+));
+if ($event_calendar_repeated_events == 'yes') {
+ $body .= elgg_view('event_calendar/repeat_form_element',$vars);
+}
+
+$body .= elgg_view('event_calendar/reminder_section',$vars);
+$body .= '</div>';
+
+echo $body;
diff --git a/views/default/event_calendar/share_section.php b/views/default/event_calendar/share_section.php
new file mode 100644
index 000000000..134f07656
--- /dev/null
+++ b/views/default/event_calendar/share_section.php
@@ -0,0 +1,26 @@
+<?php
+$fd = $vars['form_data'];
+$event_calendar_hide_access = elgg_get_plugin_setting('hide_access', 'event_calendar');
+$body = '<div class="event-calendar-edit-form-block event-calendar-edit-form-share-block">';
+$body .= '<h2>'.elgg_echo('event_calendar:permissions:header').'</h2>';
+if($event_calendar_hide_access == 'yes') {
+ $event_calendar_default_access = elgg_get_plugin_setting('default_access', 'event_calendar');
+ if($event_calendar_default_access) {
+ $body .= elgg_view("input/hidden",array('name' => 'access_id','value'=>$event_calendar_default_access));
+ } else {
+ $body .= elgg_view("input/hidden",array('name' => 'access_id','value'=>ACCESS_DEFAULT));
+ }
+} else {
+ $body .= '<p><label>'.elgg_echo('event_calendar:read_access').'</label>';
+ $body .= elgg_view("input/access",array('name' => 'access_id','value'=>$fd['access_id']));
+ $body .= '</p>';
+}
+if (elgg_plugin_exists('entity_admins')) {
+ $body .= elgg_echo('event_calendar:share_ownership:label');
+ $body .= '<br />';
+ $body .= elgg_echo('event_calendar:share_ownership:description');
+ $body .= elgg_view('input/entity_admins_dropdown',array('entity'=>$vars['event']));
+}
+$body .= '</div>';
+
+echo $body;
diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php
index 278fdddce..6ea06a6b4 100644
--- a/views/default/forms/event_calendar/edit.php
+++ b/views/default/forms/event_calendar/edit.php
@@ -2,17 +2,15 @@
$event = $vars['event'];
$fd = $vars['form_data'];
-$personal_manage_options = array(
- elgg_echo('event_calendar:personal_manage:by_event:open') => 'open',
- elgg_echo('event_calendar:personal_manage:by_event:closed') => 'closed',
- elgg_echo('event_calendar:personal_manage:by_event:private') => 'private',
-);
-
$schedule_options = array(
- elgg_echo('event_calendar:schedule_type:poll')=>'poll',
+ elgg_echo('event_calendar:all_day_label') => 'all_day',
elgg_echo('event_calendar:schedule_type:fixed')=>'fixed',
);
+if (elgg_plugin_exists('event_poll')) {
+ $schedule_options = array_merge(array(elgg_echo('event_calendar:schedule_type:poll')=>'poll'),$schedule_options);
+}
+
$event_calendar_fewer_fields = elgg_get_plugin_setting('fewer_fields', 'event_calendar');
$event_calendar_repeating_events = elgg_get_plugin_setting('repeating_events', 'event_calendar');
@@ -20,12 +18,8 @@ $event_calendar_region_display = elgg_get_plugin_setting('region_display', 'even
$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_hide_access = elgg_get_plugin_setting('hide_access', 'event_calendar');
$event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar');
-$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
-$event_calendar_repeated_events = elgg_get_plugin_setting('repeated_events', 'event_calendar');
-$event_calendar_reminders = elgg_get_plugin_setting('reminders', 'event_calendar');
$event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar');
if ($event_calendar_more_required == 'yes') {
@@ -49,53 +43,6 @@ foreach ($all_fields as $fn) {
}
if ($event) {
- /*$title = $event->title;
- $brief_description = $event->description;
- $venue = $event->venue;
- // this is a form redisplay, so take the values as submitted
- $start_date = $event->start_date;
- $end_date = $event->end_date;
-
- if ($event_calendar_region_display) {
- $region = $event->region;
- if (!$region) {
- $region = '-';
- }
- }
-
- if ($event_calendar_spots_display) {
- $spots = trim($event->spots);
- }
- if ($event_calendar_type_display) {
- $event_type = $event->event_type;
- if (!$event_type) {
- $event_type = '-';
- }
- }
- $fees = $event->fees;
- $contact = $event->contact;
- $organiser = $event->organiser;
- if ($event->tags) {
- $event_tags = $event->tags;
- } else {
- // old way
- $event_tags = $event->event_tags;
- }
- $reminder_number = $event->reminder_number;
- $reminder_interval = $event->reminder_interval;
-
- $long_description = $event->long_description;
- $access = $event->access_id;
- if ($event_calendar_times != 'no') {
- $start_time = $event->start_time;
- $end_time = $event->end_time;
- }
- if ($event_calendar_personal_manage == 'by_event') {
- $personal_manage = $event->personal_manage;
- if (!$personal_manage) {
- $personal_manage = 'open';
- }
- }*/
$event_action = 'manage_event';
$event_guid = $event->guid;
} else {
@@ -106,8 +53,7 @@ if ($event) {
$title = $fd['title'];
$brief_description = $fd['description'];
$venue = $fd['venue'];
-$start_date = $fd['start_date'];
-$end_date = $fd['end_date'];
+
$fees = $fd['fees'];
if ($event_calendar_spots_display) {
$spots = $fd['spots'];
@@ -122,19 +68,16 @@ $contact = $fd['contact'];
$organiser = $fd['organiser'];
$event_tags = $fd['tags'];
$all_day = $fd['all_day'];
-$send_reminder = $fd['send_reminder'];
-$reminder_number = $fd['reminder_number'];
-$reminder_interval = $fd['reminder_interval'];
$schedule_type = $fd['schedule_type'];
$long_description = $fd['long_description'];
-$access = $fd['access_id'];
-if ($event_calendar_times != 'no') {
+
+/*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 = '<div class="event-calendar-edit-form">';
@@ -187,15 +130,11 @@ $body .= '</div>';
$body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-schedule-block">';
$body .= '<h2>'.elgg_echo('event_calendar:schedule:header').'</h2>';
-if ($all_day) {
- $body .= elgg_view('input/checkbox',array('name'=>'all_day','value'=>1,'checked'=>'checked'));
-} else {
- $body .= elgg_view('input/checkbox',array('name'=>'all_day','value'=>1));
-}
-$body .= elgg_echo('event_calendar:all_day_label');
-if(elgg_plugin_exists('event_poll')) {
- $body .= elgg_view('input/radio',array('name'=>'schedule_type','value'=>$schedule_type,'options'=>$schedule_options));
-}
+$body .= elgg_view('input/radio',array('id'=>'event-calendar-edit-schedule-type','name'=>'schedule_type','value'=>$schedule_type,'options'=>$schedule_options));
+
+$vars['prefix'] = $prefix;
+
+/*
$body .= '<div class="event-calendar-edit-date-wrapper">';
$body .= elgg_view('event_calendar/datetime_edit',
array(
@@ -230,7 +169,9 @@ if ($event_calendar_reminders == 'yes') {
$body .= elgg_view('input/dropdown',array('name'=>'reminder_interval','options_values'=>$intervals,'value'=>$reminder_interval));
$body .= elgg_echo('elgg_calendar:send_reminder_before');
$body .= '</div>';
-}
+}*/
+
+$body .= elgg_view('event_calendar/schedule_section',$vars);
if ($event_calendar_spots_display == 'yes') {
$body .= '<p><label>'.elgg_echo("event_calendar:spots_label").'<br />';
@@ -238,7 +179,8 @@ if ($event_calendar_spots_display == 'yes') {
$body .= '</label></p>';
$body .= '<p class="event-calendar-description">'.$prefix['spots'].elgg_echo('event_calendar:spots_description').'</p>';
}
-$body .= '</div>';
+
+$body .= '<div class="event-calendar-edit-bottom"></div>';
$body .= '</div>';
// the following feature has been superceded by the manage subscribers feature
@@ -250,23 +192,27 @@ $body .= '</div>';
$body .= '<p class="description">'.elgg_echo('event_calendar:add_user_description').'</p>';
}*/
-if ($event_calendar_personal_manage == 'by_event') {
+$body .= elgg_view('event_calendar/personal_manage_section',$vars);
+
+/*if ($event_calendar_personal_manage == 'by_event') {
$body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-membership-block">';
$body .= '<h2>'.elgg_echo('event_calendar:personal_manage:label').'</h2>';
$body .= elgg_view("input/radio",array('name' => 'personal_manage','value'=>$personal_manage,'options'=>$personal_manage_options));
//$body .= '<p class="event-calendar-description">'.$prefix['personal_manage'].elgg_echo('event_calendar:personal_manage:description').'</p>';
$body .= '<br clear="both" />';
$body .= '</div>';
-}
+}*/
-$body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-share-block">';
+$body .= elgg_view('event_calendar/share_section',$vars);
+
+/*$body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-share-block">';
$body .= '<h2>'.elgg_echo('event_calendar:permissions:header').'</h2>';
if($event_calendar_hide_access == 'yes') {
$event_calendar_default_access = elgg_get_plugin_setting('default_access', 'event_calendar');
if($event_calendar_default_access) {
$body .= elgg_view("input/hidden",array('name' => 'access_id','value'=>$event_calendar_default_access));
} else {
- $body .= elgg_view("input/hidden",array('name' => 'access_id','value'=>ACCESS_PRIVATE));
+ $body .= elgg_view("input/hidden",array('name' => 'access_id','value'=>ACCESS_DEFAULT));
}
} else {
$body .= '<p><label>'.elgg_echo('event_calendar:read_access').'</label>';
@@ -279,7 +225,7 @@ if (elgg_plugin_exists('entity_admins')) {
$body .= elgg_echo('event_calendar:share_ownership:description');
$body .= elgg_view('input/entity_admins_dropdown',array('entity'=>$event));
}
-$body .= '</div>';
+$body .= '</div>';*/
if ($event_calendar_region_display == 'yes' || $event_calendar_type_display == 'yes' || $event_calendar_fewer_fields != 'yes') {
$body .= '<div class="event-calendar-edit-form-block event-calendar-edit-form-other-block">';
diff --git a/views/default/input/datepicker_inline.php b/views/default/input/datepicker_inline.php
index 1d0a0689d..3fd9c37af 100644
--- a/views/default/input/datepicker_inline.php
+++ b/views/default/input/datepicker_inline.php
@@ -65,7 +65,6 @@ $("#<?php echo $vars['name']; ?>").datepicker({
document.location.href = "<?php echo $link_bit; ?>".replace('%s', date.substring(0,10));
},
dateFormat: "yy-mm-dd",
- <?php echo $vars['range_bit']; ?>
defaultDate: "<?php echo $vars['start_date'] .' - '.$vars['end_date']; ?>",
beforeShowDay: highlightWeek
});
@@ -76,7 +75,7 @@ if ("<?php echo $vars['mode'] ?>" == "month") {
end_date += 1;
}
$("#<?php echo $vars['name']; ?>").datepicker("setDate", start_date, end_date);
-var done_loading = true;
+done_loading = true;
});
</script>
diff --git a/views/default/input/timepicker.php b/views/default/input/timepicker.php
index ccbb88778..2cc95ced7 100644
--- a/views/default/input/timepicker.php
+++ b/views/default/input/timepicker.php
@@ -1,5 +1,4 @@
<?php
-$event_calendar_restricted_times = elgg_get_plugin_setting('restricted_times', 'event_calendar');
$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar');
if (!$time_format) {
$time_format = '24';
@@ -9,75 +8,44 @@ $value = $vars['value'];
if (is_numeric($value)) {
$hour = floor($value/60);
$minute = ($value -60*$hour);
- $time = $hour*60+$minute;
} else {
- $time = '-';
+ $hour = 0;
+ $minute = 0;
}
-$dates = array();
-$dates['-'] = '-';
+$hours = array();
+$minutes = array();
if ($time_format == '12') {
- if ($event_calendar_restricted_times == 'yes') {
- $h1 = 6;
- $h2 = 9;
+ $meridians = array('am'=>'am','pm'=>'pm');
+ if ($hour == 0) {
+ $hour = 12;
+ $meridian = 'am';
+ } else if ($hour == 12) {
+ $meridian = 'pm';
+ } else if ($hour < 12) {
+ $meridian = 'am';
} else {
- $h1 = 0;
- $h2 = 11;
+ $hour -= 12;
+ $meridian = 'pm';
}
- for($h=$h1;$h<=12;$h++) {
- $ht = sprintf("%02d",$h);
- for($m=0;$m<60;$m=$m+15) {
- $mt = sprintf("%02d",$m);
- $t = $h*60+$m;
- if ($h < 12) {
- $dates[$t] = "$ht:$mt am";
- } else {
- $dates[$t] = "$ht:$mt pm";
- }
- }
- }
- for($h=1;$h<$h2;$h++) {
- $ht = sprintf("%02d",$h);
- for($m=0;$m<60;$m=$m+15) {
- $mt = sprintf("%02d",$m);
- $t = 12*60+$h*60+$m;
- $dates[$t] = "$ht:$mt pm";
- }
- }
- if ($event_calendar_restricted_times == 'yes') {
- $m = 0;
- $h = 9;
- $ht = sprintf("%02d",$h);
- $mt = sprintf("%02d",$m);
- $t = 12*60+$h*60+$m;
- $dates[$t] = "$ht:$mt pm";
+ for($h=1;$h<=12;$h++) {
+ $hours[$h] = $h;
}
} else {
- if ($event_calendar_restricted_times == 'yes') {
- $h1 = 6;
- $h2 = 21;
- } else {
- $h1 = 0;
- $h2 = 24;
- }
- for($h=$h1;$h<$h2;$h++) {
- $ht = sprintf("%02d",$h);
- for($m=0;$m<60;$m=$m+15) {
- $mt = sprintf("%02d",$m);
- $t = $h*60+$m;
- $dates[$t] = "$ht:$mt";
- }
- }
- if ($event_calendar_restricted_times == 'yes') {
- $m = 0;
- $h = 21;
- $ht = sprintf("%02d",$h);
- $mt = sprintf("%02d",$m);
- $t = 12*60+$h*60+$m;
- $dates[$t] = "$ht:$mt pm";
+ for($h=0;$h<=23;$h++) {
+ $hours[$h] = $h;
}
-}
+}
-echo elgg_view('input/dropdown',array('name'=>$vars['name'],'value'=>$time,'options_values'=>$dates));
+for($m=0;$m<60;$m=$m+5) {
+ $mt = sprintf("%02d",$m);
+ $minutes[$m] = $mt;
+}
+echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_hour','value'=>$hour,'options_values'=>$hours));
+echo " <b>:</b> ";
+echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_minute','value'=>$minute,'options_values'=>$minutes));
+if ($time_format == '12') {
+ echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_meridian','value'=>$meridian,'options_values'=>$meridians));
+}
diff --git a/views/default/js/event_calendar/event_calendar.php b/views/default/js/event_calendar/event_calendar.php
index b3ca2cc7b..244846f96 100644
--- a/views/default/js/event_calendar/event_calendar.php
+++ b/views/default/js/event_calendar/event_calendar.php
@@ -10,6 +10,8 @@ elgg.event_calendar.init = function () {
$('.event-calendar-repeating-unselected').live('click',elgg.event_calendar.handleRepeatingSelect);
$('.event-calendar-repeating-selected').live('click',elgg.event_calendar.handleRepeatingUnselect);
$('#event-calendar-edit').submit(elgg.event_calendar.handleEditFormSubmit);
+ $('#event-calendar-edit-schedule-type').click(elgg.event_calendar.handleScheduleType);
+ elgg.event_calendar.handleScheduleType();
var all_day_field = $('[name="all_day"][type="checkbox"]');
if (all_day_field.is(':checked')) {
@@ -21,6 +23,28 @@ elgg.event_calendar.init = function () {
all_day_field.change(elgg.event_calendar.handleAllDayField);
}
+elgg.event_calendar.handleScheduleType = function(e) {
+ var st = $('#event-calendar-edit-schedule-type:checked').val();
+ if (st == 'poll') {
+ $(".event-calendar-edit-date-wrapper").hide();
+ $(".event-calendar-edit-reminder-wrapper").hide();
+ $(".event-calendar-edit-form-membership-block").hide();
+ $(".event-calendar-edit-form-share-block").hide();
+ } else {
+ $(".event-calendar-edit-date-wrapper").show();
+ $(".event-calendar-edit-reminder-wrapper").show();
+ $(".event-calendar-edit-form-membership-block").show();
+ $(".event-calendar-edit-form-share-block").show();
+ if (st == 'all_day') {
+ $("[name='start_time']").hide();
+ $("#event-calendar-to-time-wrapper").hide();
+ } else {
+ $("[name='start_time']").show();
+ $("#event-calendar-to-time-wrapper").show();
+ }
+ }
+}
+
elgg.event_calendar.handleAllDayField = function(e) {
var field = $('[name="start_time"]');
if (field.attr('disabled') == 'disabled') {