aboutsummaryrefslogtreecommitdiff
path: root/mod/event_calendar
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:24:39 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:24:39 +0100
commita9ac4c861335e60373c1e99b61372e6e0d6ac9f4 (patch)
tree84e660ad22367aab1697a1f910125f520243b882 /mod/event_calendar
parent1f40407cb2d2f0edfc4cc5346f332f5c6adab022 (diff)
parentb011a80767e1062a394b7bbbc3be3d2959a5f773 (diff)
downloadelgg-a9ac4c861335e60373c1e99b61372e6e0d6ac9f4.tar.gz
elgg-a9ac4c861335e60373c1e99b61372e6e0d6ac9f4.tar.bz2
Add 'mod/event_calendar/' from commit 'b011a80767e1062a394b7bbbc3be3d2959a5f773'
git-subtree-dir: mod/event_calendar git-subtree-mainline: 1f40407cb2d2f0edfc4cc5346f332f5c6adab022 git-subtree-split: b011a80767e1062a394b7bbbc3be3d2959a5f773
Diffstat (limited to 'mod/event_calendar')
-rw-r--r--mod/event_calendar/CHANGES.txt154
-rw-r--r--mod/event_calendar/CONTRIBUTIONS.txt7
-rw-r--r--mod/event_calendar/README.txt89
-rw-r--r--mod/event_calendar/actions/event_calendar/add_personal.php17
-rw-r--r--mod/event_calendar/actions/event_calendar/add_to_group.php10
-rw-r--r--mod/event_calendar/actions/event_calendar/add_to_group_members.php15
-rw-r--r--mod/event_calendar/actions/event_calendar/addtocalendar.php33
-rw-r--r--mod/event_calendar/actions/event_calendar/delete.php21
-rw-r--r--mod/event_calendar/actions/event_calendar/edit.php55
-rw-r--r--mod/event_calendar/actions/event_calendar/join_conference.php20
-rw-r--r--mod/event_calendar/actions/event_calendar/killrequest.php23
-rw-r--r--mod/event_calendar/actions/event_calendar/manage_subscribers.php26
-rw-r--r--mod/event_calendar/actions/event_calendar/modify_full_calendar.php24
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_from_group.php8
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_from_group_members.php15
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_personal.php12
-rw-r--r--mod/event_calendar/actions/event_calendar/request_personal_calendar.php16
-rw-r--r--mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php40
-rw-r--r--mod/event_calendar/activate.php4
-rw-r--r--mod/event_calendar/images/calendar.gifbin0 -> 269 bytes
-rw-r--r--mod/event_calendar/images/event_icon.gifbin0 -> 1254 bytes
-rw-r--r--mod/event_calendar/images/event_icon_old.gifbin0 -> 1531 bytes
-rw-r--r--mod/event_calendar/images/ics.pngbin0 -> 344 bytes
-rw-r--r--mod/event_calendar/images/river_icon_event.gifbin0 -> 586 bytes
-rw-r--r--mod/event_calendar/languages/ca.php143
-rw-r--r--mod/event_calendar/languages/en.php360
-rw-r--r--mod/event_calendar/languages/es.php215
-rw-r--r--mod/event_calendar/languages/fr.php124
-rw-r--r--mod/event_calendar/languages/ru.php365
-rw-r--r--mod/event_calendar/manifest.xml16
-rw-r--r--mod/event_calendar/models/model.php2518
-rw-r--r--mod/event_calendar/start.php414
-rw-r--r--mod/event_calendar/views/default/css/elements/forms/datepicker_multi.php39
-rw-r--r--mod/event_calendar/views/default/event_calendar/agenda_footer.php5
-rw-r--r--mod/event_calendar/views/default/event_calendar/agenda_header.php12
-rw-r--r--mod/event_calendar/views/default/event_calendar/agenda_item_view.php26
-rw-r--r--mod/event_calendar/views/default/event_calendar/agenda_view.php34
-rw-r--r--mod/event_calendar/views/default/event_calendar/calendar.php70
-rw-r--r--mod/event_calendar/views/default/event_calendar/calendar_toggle.php18
-rw-r--r--mod/event_calendar/views/default/event_calendar/conference_button.php33
-rw-r--r--mod/event_calendar/views/default/event_calendar/container.php28
-rw-r--r--mod/event_calendar/views/default/event_calendar/css.php264
-rw-r--r--mod/event_calendar/views/default/event_calendar/datetime_edit.php46
-rw-r--r--mod/event_calendar/views/default/event_calendar/entities/entity_list.php66
-rw-r--r--mod/event_calendar/views/default/event_calendar/entities/gallery.php44
-rw-r--r--mod/event_calendar/views/default/event_calendar/entities/gallery_item.php63
-rw-r--r--mod/event_calendar/views/default/event_calendar/filter_menu.php78
-rw-r--r--mod/event_calendar/views/default/event_calendar/forms/add_to_group.php74
-rw-r--r--mod/event_calendar/views/default/event_calendar/full_calendar_view.php200
-rw-r--r--mod/event_calendar/views/default/event_calendar/group_module.php37
-rw-r--r--mod/event_calendar/views/default/event_calendar/groupprofile_calendar.php33
-rw-r--r--mod/event_calendar/views/default/event_calendar/groupprofile_calendar_deprecated.php44
-rw-r--r--mod/event_calendar/views/default/event_calendar/input/date_local.php55
-rw-r--r--mod/event_calendar/views/default/event_calendar/metatags.php2
-rw-r--r--mod/event_calendar/views/default/event_calendar/nav.php38
-rw-r--r--mod/event_calendar/views/default/event_calendar/paged_footer.php4
-rw-r--r--mod/event_calendar/views/default/event_calendar/paged_header.php15
-rw-r--r--mod/event_calendar/views/default/event_calendar/paged_item_view.php27
-rw-r--r--mod/event_calendar/views/default/event_calendar/paged_view.php36
-rw-r--r--mod/event_calendar/views/default/event_calendar/personal_manage_section.php20
-rw-r--r--mod/event_calendar/views/default/event_calendar/personal_toggle_js.php20
-rw-r--r--mod/event_calendar/views/default/event_calendar/region_select.php21
-rw-r--r--mod/event_calendar/views/default/event_calendar/reminder_section.php28
-rw-r--r--mod/event_calendar/views/default/event_calendar/repeat_form_element.php32
-rw-r--r--mod/event_calendar/views/default/event_calendar/review_requests.php30
-rw-r--r--mod/event_calendar/views/default/event_calendar/schedule_section.php22
-rw-r--r--mod/event_calendar/views/default/event_calendar/share_section.php26
-rw-r--r--mod/event_calendar/views/default/event_calendar/show_events.php64
-rw-r--r--mod/event_calendar/views/default/event_calendar/strapline.php18
-rw-r--r--mod/event_calendar/views/default/forms/event_calendar/edit.php233
-rw-r--r--mod/event_calendar/views/default/forms/event_calendar/manage_subscribers.php14
-rw-r--r--mod/event_calendar/views/default/fullcalendar/css.php618
-rw-r--r--mod/event_calendar/views/default/fullcalendar/fullcalendar.print.css61
-rw-r--r--mod/event_calendar/views/default/icon/object/event_calendar/small.php3
-rw-r--r--mod/event_calendar/views/default/input/datepicker_inline.php83
-rw-r--r--mod/event_calendar/views/default/input/timepicker.php51
-rw-r--r--mod/event_calendar/views/default/input/timepicker_old.php38
-rw-r--r--mod/event_calendar/views/default/js/event_calendar/event_calendar.php171
-rw-r--r--mod/event_calendar/views/default/js/event_calendar/fullcalendar.min.js114
-rw-r--r--mod/event_calendar/views/default/js/event_calendar/fullcalendar.php5227
-rw-r--r--mod/event_calendar/views/default/js/event_calendar/gcal.js112
-rw-r--r--mod/event_calendar/views/default/object/event_calendar.php115
-rw-r--r--mod/event_calendar/views/default/plugins/event_calendar/settings.php474
-rw-r--r--mod/event_calendar/views/default/river/object/event_calendar/create.php13
-rw-r--r--mod/event_calendar/views/default/river/object/event_calendar/update.php13
-rw-r--r--mod/event_calendar/views/default/widgets/event_calendar/content.php43
-rw-r--r--mod/event_calendar/views/default/widgets/event_calendar/edit.php35
-rw-r--r--mod/event_calendar/views/ical/event_calendar/show_events.php7
-rw-r--r--mod/event_calendar/views/ical/object/event_calendar.php44
-rw-r--r--mod/event_calendar/views/ical/page/default.php17
-rw-r--r--mod/event_calendar/views/ical/page/layouts/default.php2
-rw-r--r--mod/event_calendar/views/rss/event_calendar/show_events.php24
-rw-r--r--mod/event_calendar/views/rss/object/event_calendar.php61
93 files changed, 13989 insertions, 0 deletions
diff --git a/mod/event_calendar/CHANGES.txt b/mod/event_calendar/CHANGES.txt
new file mode 100644
index 000000000..269ede4ae
--- /dev/null
+++ b/mod/event_calendar/CHANGES.txt
@@ -0,0 +1,154 @@
+CHANGE LOG
+0.85
+
+First version for Elgg 1.8
+
+0.84
+
+Fixed tag search so it works for Elgg 1.7.x.
+
+Added French and Spanish language files provided by UNESCO. These are not
+quite complete and additions are welcome.
+
+There is now an option to allow group admins to add any existing event to a
+group calendar
+
+Fixed a bug which incorrectly removed the ability to change the date and year.
+
+Renamed a date picker view to avoid a conflict with the Profile Manager.
+
+Added unpacked js for ease in customisation and localisation.
+
+Restored the vanished RSS feed link.
+
+Fixed a bug in the region dropdown behaviour on listing pages.
+
+Fixed a case where the page was not properly displayed when clicking on a
+pagination link.
+
+Added a sanity check for date formats.
+
+Changed the listing limit from 4 events to a more reasonable 15 events.
+
+Added real_end_time as an internal metadata value to compute collisions.
+
+Added three features that are turned off by default but can be enabled
+through plugin settings:
+
+The spots feature allows you to specify how many users can add an event to
+their personal calendars. This also adds an "open" filter to the show events page
+so that you can see how many events are not full.
+
+The no collisions feature prevents someone from adding an event
+if they already have another event on their personal calendar within
+the same time period. (This will only work with new events or events that
+you have resaved after updating this plugin as it needs the new real_end_time
+field.)
+
+The add users feature provides a magic JavaScript field that
+allows an event creator to add the event to the personal calendars of other users.
+This appears on the event edit form. (Requires the separate autocomplete plugin.)
+
+There is a separate option (turned off by default) to send notifications to
+users who have events added to their calendars through the add users feature.
+
+0.83
+
+Fixed a bug that prevented region filtering with embedded blanks from
+working properly (thanks Patrick!).
+
+Added a new paged view for events (not month specific) that allows adding/removing events
+to a calendar with one click.
+
+Fixed some issues with the personal event calendar widget.
+
+0.82
+
+Fixed a bug in displaying dates when the start and end date were the same.
+
+Fixed the form redisplay bug described here:
+http://community.elgg.org/mod/groups/topicposts.php?topic=423853&group_guid=263011
+
+Removed an error_log message that was accidentally left in.
+
+Added RSS feeds.
+
+Added the ability to filter events by regions if the region option is turned on.
+
+Added security tokens for Elgg 1.7
+
+0.81
+
+Fixed a problem with the group "widget" not displaying when it should.
+
+Hid the "Today" link as it was not behaving as most people expected.
+
+Forced the display into Month mode after Prev and Next is clicked.
+
+0.8
+
+Removed a debugging message left in the event delete action.
+
+Sorted events properly by date/time rather than time created.
+
+Fixed an error in the parameters passed to elgg_view_entity_list that caused
+problems with Elgg 1.6.1.
+
+Added an admin toggle to allow event times as well as dates.
+
+Added an admin toggle to show the venue in event listings.
+
+Added an admin toggle for an agenda view which should be useful for conferences
+with multiple events on one day.
+
+Added the ability to "lock" the show_events page so that the calendar only
+allows navigation between a first date and a last date.
+
+Added an admin toggle for an autogroup function that automatically adds all
+group events to a user's calendar for all groups that the user is a member of.
+Group events are also automatically removed if the user leaves the group.
+
+Added an admin toggle to add a region drop down to the event form and a field to
+enter the allowable regions.
+
+0.7
+
+Reworked design for Elgg 1.5
+
+Fixed several bugs, including in the list of people who added an event to
+their personal calendar (now shows the proper group navigation if this is
+a group event).
+
+Added the ability to view all/friends/mine events for logged-in users.
+
+Added numerous configuration options (accessible via event_calendar settings
+on the admin tools configuration page). This allows, for example, any logged-in
+user to add events to the site calendar, to remove group calendars, etc.
+
+People who create an event now have the event automatically added to their
+personal event calendar. This behaviour can be configured via the admin event
+calendar settings.
+
+0.6
+
+Fixed a bug that prevented more than one person adding a given event to
+his/her personal calendar.
+
+Fixed a bug that made the page owner the person who created the event. This
+is now the group for group events, otherwise the currently logged in user.
+
+Added river support.
+
+0.51
+
+Fixed event overlap detection
+
+0.5
+
+Initial release
+
+
+
+
+
+
diff --git a/mod/event_calendar/CONTRIBUTIONS.txt b/mod/event_calendar/CONTRIBUTIONS.txt
new file mode 100644
index 000000000..edadc2407
--- /dev/null
+++ b/mod/event_calendar/CONTRIBUTIONS.txt
@@ -0,0 +1,7 @@
+Pete Harris from Curverider contributed the icons. Thanks Pete!
+
+Igor Nuk from UNESCO sent me Spanish and French language files as well
+as a version tweaked to make it easier to customise.
+
+Many clients too numerous to mention have funded enhancements since the
+original version was funded by the Royal Institute of British Architects. \ No newline at end of file
diff --git a/mod/event_calendar/README.txt b/mod/event_calendar/README.txt
new file mode 100644
index 000000000..fbfd172b0
--- /dev/null
+++ b/mod/event_calendar/README.txt
@@ -0,0 +1,89 @@
+THIS VERSION IS DEPRECATED. USE THE VERSION IN
+
+https://github.com/kevinjardine/Elgg-Event-Calendar/tree/full
+
+/**
+ * Manage and display events
+ *
+ * @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-2011
+ * @link http://radagast.biz/
+ *
+ */
+
+ Note: this README.txt file is a bit outdated because it does not describe numerous
+ recently added features. For more information, check the CHANGES.txt file
+ or look at the event calendar settings available through Tools Administration.
+
+Version: 0.85
+
+Requires: Elgg 1.8 or higher
+
+Should be installed in mod/event_calendar
+
+*Description*
+
+The event_calendar plugin adds a site-wide event calendar as well as
+an event calendar to each group. Various options related to the site and group
+calendars can be set using the event calendar settings on the tool
+administration page.
+
+Group members can view events by month, week and day using a jQuery date
+picker widget, and submit event descriptions including the venue, start date,
+end date, tags, description, organiser, contact person, event access level,
+and fees if any.
+
+Group events are aggregated into the site wide event calendar accessible from
+the Tools menu drop down.
+
+Site admins (or optionally any user) can also add non-group-specific events to
+the site-wide calendar.
+
+Users can add group or site-wide events to a personal calendar to showcase
+events that they plan to attend or are interested in. They can optionally
+display these events by dragging an Event calendar widget onto their profile
+or dashboard.
+
+The number of users who have added an event to their personal gallery is listed
+on each event page along with a link to a page that displays these users in a
+gallery format. It is thus easy to find other people interested in the same
+event.
+
+*Admin settings*
+
+Numerous options for the event calendar can be set in the event_calendar settings
+area under Tool Administration.
+
+These include:
+
+Add starting and ending times as well as dates to events (default: no)
+
+Automatically add events a user creates to his/her personal calendar (default: yes)
+
+Automatically add group events for all members to their personal calendars (default: no)
+
+(If activated, the autogroup function automatically adds all group events to a
+user's calendar for all groups that the user is a member of. Group events are
+also automatically removed if the user leaves the group.)
+
+Use Agenda view (default: no)
+
+Useful for conferences with multiple events on the same day.
+
+Display venue in event listings (default: no)
+
+Add region dropdown (default: no), plus a way to specify the allowable regions
+
+First date displayable on show events pages (default: no first date)
+
+Last date displayable on show events pages (default: no last date)
+
+As well, there are numerous options for configuring the site wide and group calendars.
+
+*Acknowledgment*
+
+The initial development of the event calendar plugin was funded by the Research
+& Development department at the Royal Institute of British Architects
+(RIBA). Several other clients have funded enhancements. \ No newline at end of file
diff --git a/mod/event_calendar/actions/event_calendar/add_personal.php b/mod/event_calendar/actions/event_calendar/add_personal.php
new file mode 100644
index 000000000..ed4eb3092
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/add_personal.php
@@ -0,0 +1,17 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ if (!event_calendar_has_personal_event($event_guid,$user_guid)) {
+ if (event_calendar_add_personal_event($event_guid,$user_guid)) {
+ system_message(elgg_echo('event_calendar:add_to_my_calendar_response'));
+ } else {
+ register_error(elgg_echo('event_calendar:add_to_my_calendar_error'));
+ }
+ }
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/add_to_group.php b/mod/event_calendar/actions/event_calendar/add_to_group.php
new file mode 100644
index 000000000..b5eae4693
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/add_to_group.php
@@ -0,0 +1,10 @@
+<?php
+$event_id = get_input("event_id",0);
+$group_id = get_input("group_id",0);
+$event = get_entity($event_id);
+$group = get_entity($group_id);
+if ($group && $group->canEdit()) {
+ add_entity_relationship($event_id, "display_on_group", $group_id );
+ system_message(elgg_echo('event_calendar:add_to_group:success'));
+}
+forward($event->getUrl());
diff --git a/mod/event_calendar/actions/event_calendar/add_to_group_members.php b/mod/event_calendar/actions/event_calendar/add_to_group_members.php
new file mode 100644
index 000000000..d0d555b12
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/add_to_group_members.php
@@ -0,0 +1,15 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input("event_guid",0);
+$event = get_entity($event_guid);
+$group = get_entity($event->container_guid);
+if (elgg_instanceof($group,'group') && elgg_instanceof($event,'object','event_calendar') && $group->canEdit()) {
+ $members = $group->getMembers(0,0);
+ foreach($members as $member) {
+ event_calendar_add_personal_event($event->guid,$member->guid);
+ }
+ system_message(elgg_echo('event_calendar:add_to_group_members:success'));
+} else {
+ register_error(elgg_echo('event_calendar:add_to_group_members:error'));
+}
+forward("event_calendar/manage_users/$event_guid");
diff --git a/mod/event_calendar/actions/event_calendar/addtocalendar.php b/mod/event_calendar/actions/event_calendar/addtocalendar.php
new file mode 100644
index 000000000..0144dfba1
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/addtocalendar.php
@@ -0,0 +1,33 @@
+<?php
+// this action allows an admin or event owner to approve a calendar request
+
+elgg_load_library('elgg:event_calendar');
+
+$user_guid = get_input('user_guid', elgg_get_logged_in_user_guid());
+$event_guid = get_input('event_guid');
+
+$user = get_entity($user_guid);
+$event = get_entity($event_guid);
+
+if (elgg_instanceof($event, 'object', 'event_calendar')
+ && elgg_instanceof($user, 'user')
+ && $event->canEdit()
+ && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) {
+
+ if (event_calendar_add_personal_event($event_guid,$user_guid)) {
+ remove_entity_relationship($user_guid, 'event_calendar_request', $event_guid);
+ notify_user($user_guid, $CONFIG->site->guid, elgg_echo('event_calendar:add_users_notify:subject'),
+ sprintf(
+ elgg_echo('event_calendar:add_users_notify:body'),
+ $user->name,
+ $event->title,
+ $event->getURL()
+ )
+ );
+ system_message(elgg_echo('event_calendar:request_approved'));
+ }
+} else {
+ register_error(elgg_echo('event_calendar:review_requests:error:approve'));
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/delete.php b/mod/event_calendar/actions/event_calendar/delete.php
new file mode 100644
index 000000000..dd8a7ef22
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/delete.php
@@ -0,0 +1,21 @@
+<?php
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
+ if (get_input('cancel','')) {
+ system_message(elgg_echo('event_calendar:delete_cancel_response'));
+ } else {
+ $container = get_entity($event->container_guid);
+ $event->delete();
+ system_message(elgg_echo('event_calendar:delete_response'));
+ if (elgg_instanceof($container,'group')) {
+ forward('event_calendar/group/'.$container->guid);
+ } else {
+ forward('event_calendar/list');
+ }
+ }
+} else {
+ register_error(elgg_echo('event_calendar:error_delete'));
+}
+
+forward(REFERER); \ No newline at end of file
diff --git a/mod/event_calendar/actions/event_calendar/edit.php b/mod/event_calendar/actions/event_calendar/edit.php
new file mode 100644
index 000000000..aef1a59cc
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/edit.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * Edit action
+ *
+ * @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/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+// start a new sticky form session in case of failure
+elgg_make_sticky_form('event_calendar');
+
+$event_guid = get_input('event_guid',0);
+$group_guid = get_input('group_guid',0);
+$event = event_calendar_set_event_from_form($event_guid,$group_guid);
+if ($event) {
+ // remove sticky form entries
+ elgg_clear_sticky_form('event_calendar');
+ $user_guid = elgg_get_logged_in_user_guid();
+ if ($event_guid) {
+ add_to_river('river/object/event_calendar/update','update',$user_guid,$event_guid);
+ system_message(elgg_echo('event_calendar:manage_event_response'));
+ } else {
+ $event_calendar_autopersonal = elgg_get_plugin_setting('autopersonal', 'event_calendar');
+ if (!$event_calendar_autopersonal || ($event_calendar_autopersonal == 'yes')) {
+ event_calendar_add_personal_event($event->guid,$user_guid);
+ }
+ 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 {
+ // redisplay form with error message
+ register_error(elgg_echo('event_calendar:manage_event_error'));
+ if ($event_guid) {
+ forward('event_calendar/edit/'.$event_guid);
+ } else {
+ if ($group_guid) {
+ forward('event_calendar/add/'.$group_guid);
+ } else {
+ forward('event_calendar/add/');
+ }
+ }
+}
diff --git a/mod/event_calendar/actions/event_calendar/join_conference.php b/mod/event_calendar/actions/event_calendar/join_conference.php
new file mode 100644
index 000000000..9eb8f0da9
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/join_conference.php
@@ -0,0 +1,20 @@
+<?php
+// extended logic for BBB
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('event_guid');
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ // make sure that the conference still exists, and if not, try recreating it
+ if (event_calendar_conference_exists($event)) {
+ event_calendar_join_conference($event);
+ } else if (event_calendar_create_bbb_conf($event)) {
+ event_calendar_join_conference($event);
+ } else {
+ register_error(elgg_echo('event_calendar:couldnotjoin'));
+ forward($event->getURL());
+ }
+} else {
+ register_error(elgg_echo('event_calendar:error_nosuchevent'));
+ forward('event_calendar/list');
+}
diff --git a/mod/event_calendar/actions/event_calendar/killrequest.php b/mod/event_calendar/actions/event_calendar/killrequest.php
new file mode 100644
index 000000000..f4f3c3135
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/killrequest.php
@@ -0,0 +1,23 @@
+<?php
+// this action allows an admin or event owner to reject a calendar request
+
+elgg_load_library('elgg:event_calendar');
+
+$user_guid = get_input('user_guid', elgg_get_logged_in_user_guid());
+$event_guid = get_input('event_guid');
+
+$user = get_entity($user_guid);
+$event = get_entity($event_guid);
+
+if (elgg_instanceof($event, 'object', 'event_calendar')
+ && elgg_instanceof($user, 'user')
+ && $event->canEdit()
+ && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) {
+
+ remove_entity_relationship($user->guid, 'event_calendar_request', $event_guid);
+ system_message(elgg_echo('event_calendar:requestkilled'));
+} else {
+ register_error(elgg_echo('event_calendar:review_requests:error:reject'));
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/manage_subscribers.php b/mod/event_calendar/actions/event_calendar/manage_subscribers.php
new file mode 100644
index 000000000..079c3628f
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/manage_subscribers.php
@@ -0,0 +1,26 @@
+<?php
+$event_guid = get_input('event_guid');
+$event = get_entity($event_guid);
+$event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+if (($event_calendar_add_users == 'yes') && elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
+ $members = get_input('members');
+ // clear the event from all personal calendars
+ remove_entity_relationships($event_guid, 'personal_event', TRUE);
+ // add event to personal calendars
+ $event_calendar_add_users_notify = elgg_get_plugin_setting('add_users_notify', 'event_calendar');
+ $site_guid = elgg_get_site_entity()->guid;
+ foreach ($members as $user_guid) {
+ add_entity_relationship($user_guid,'personal_event',$event_guid);
+ if ($event_calendar_add_users_notify == 'yes') {
+ $subject = elgg_echo('event_calendar:add_users_notify:subject');
+ $user = get_user($user_guid);
+ $message = elgg_echo('event_calendar:add_users_notify:body',array($user->name,$event->title,$event->getURL()));
+ notify_user($user_guid, $site_guid, $subject, $message, NULL, 'email');
+ }
+ }
+ system_message(elgg_echo('event_calendar:manage_subscribers:success'));
+ forward($event->getURL());
+} else {
+ register_error(elgg_echo('event_calendar:manage_subscribers:error'));
+ forward();
+}
diff --git a/mod/event_calendar/actions/event_calendar/modify_full_calendar.php b/mod/event_calendar/actions/event_calendar/modify_full_calendar.php
new file mode 100644
index 000000000..1e0bd3a01
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/modify_full_calendar.php
@@ -0,0 +1,24 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input('event_guid',0);
+$day_delta = get_input('dayDelta');
+$minute_delta = get_input('minuteDelta','');
+$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);
+ // special 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'));
+}
+
+echo json_encode($response);
+
+exit;
diff --git a/mod/event_calendar/actions/event_calendar/remove_from_group.php b/mod/event_calendar/actions/event_calendar/remove_from_group.php
new file mode 100644
index 000000000..4a7185245
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/remove_from_group.php
@@ -0,0 +1,8 @@
+<?php
+$event_id = get_input("event_id",0);
+$group_id = get_input("group_id",0);
+$event = get_entity($event_id);
+remove_entity_relationship($event_id, "display_on_group", $group_id );
+system_message(elgg_echo('event_calendar:remove_from_group:success'));
+forward($event->getUrl());
+?> \ No newline at end of file
diff --git a/mod/event_calendar/actions/event_calendar/remove_from_group_members.php b/mod/event_calendar/actions/event_calendar/remove_from_group_members.php
new file mode 100644
index 000000000..a15b66c97
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/remove_from_group_members.php
@@ -0,0 +1,15 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input("event_guid",0);
+$event = get_entity($event_guid);
+$group = get_entity($event->container_guid);
+if (elgg_instanceof($group,'group') && elgg_instanceof($event,'object','event_calendar') && $group->canEdit()) {
+ $members = $group->getMembers(0,0);
+ foreach($members as $member) {
+ event_calendar_remove_personal_event($event->guid,$member->guid);
+ }
+ system_message(elgg_echo('event_calendar:remove_from_group_members:success'));
+} else {
+ register_error(elgg_echo('event_calendar:remove_from_group_members:error'));
+}
+forward("event_calendar/manage_users/$event_guid");
diff --git a/mod/event_calendar/actions/event_calendar/remove_personal.php b/mod/event_calendar/actions/event_calendar/remove_personal.php
new file mode 100644
index 000000000..1308b17e9
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/remove_personal.php
@@ -0,0 +1,12 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ event_calendar_remove_personal_event($event_guid,$user_guid);
+ system_message(elgg_echo('event_calendar:remove_from_my_calendar_response'));
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/request_personal_calendar.php b/mod/event_calendar/actions/event_calendar/request_personal_calendar.php
new file mode 100644
index 000000000..68c96e364
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/request_personal_calendar.php
@@ -0,0 +1,16 @@
+<?php
+// asks the event owner to add you to the event
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$user_guid = elgg_get_logged_in_user_guid();
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ if (event_calendar_send_event_request($event,$user_guid)) {
+ system_message(elgg_echo('event_calendar:request_event_response'));
+ } else {
+ register_error(elgg_echo('event_calendar:request_event_error'));
+ }
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php b/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php
new file mode 100644
index 000000000..8eb20e6b9
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php
@@ -0,0 +1,40 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input('event_guid',0);
+$user_guid = get_input('user_guid',elgg_get_logged_in_user_guid());
+$other = get_input('other','');
+if ($other) {
+ $remove_response = elgg_echo('event_calendar:added_to_the_calendar');
+ $add_response = elgg_echo('event_calendar:removed_from_the_calendar');
+ $add_error = elgg_echo('event_calendar:add_to_the_calendar_error');
+} else {
+ $remove_response = elgg_echo('event_calendar:remove_from_my_calendar_response');
+ $add_response = elgg_echo('event_calendar:add_to_my_calendar_response');
+ $add_error = elgg_echo('event_calendar:add_to_my_calendar_error');
+}
+
+if (event_calendar_has_personal_event($event_guid,$user_guid)) {
+ $button_text = elgg_echo('event_calendar:add_to_the_calendar');
+ event_calendar_remove_personal_event($event_guid,$user_guid);
+ $response = array('success'=>TRUE, 'message' => $remove_response, 'button_text'=>$button_text);
+} else {
+ if (event_calendar_add_personal_event($event_guid,$user_guid)) {
+ $event_calendar_add_users_notify = elgg_get_plugin_setting('add_users_notify', 'event_calendar');
+ if ($event_calendar_add_users_notify == 'yes') {
+ $subject = elgg_echo('event_calendar:add_users_notify:subject');
+ $user = get_user($user_guid);
+ $event = get_entity($event_guid);
+ $site_guid = elgg_get_site_entity()->guid;
+ $message = elgg_echo('event_calendar:add_users_notify:body',array($user->name,$event->title,$event->getURL()));
+ notify_user($user_guid, $site_guid, $subject, $message, NULL, 'email');
+ }
+ $button_text = elgg_echo('event_calendar:remove_from_the_calendar_button');
+ $response = array('success'=>TRUE, 'message' => $add_response, 'button_text'=>$button_text);
+ } else {
+ $response = array('success'=>FALSE, 'message' =>$add_error);
+ }
+}
+
+echo json_encode($response);
+
+exit;
diff --git a/mod/event_calendar/activate.php b/mod/event_calendar/activate.php
new file mode 100644
index 000000000..3be14d287
--- /dev/null
+++ b/mod/event_calendar/activate.php
@@ -0,0 +1,4 @@
+<?php
+
+elgg_set_plugin_setting('listing_format', 'full', 'event_calendar');
+elgg_set_plugin_setting('fewer_fields', 'yes', 'event_calendar'); \ No newline at end of file
diff --git a/mod/event_calendar/images/calendar.gif b/mod/event_calendar/images/calendar.gif
new file mode 100644
index 000000000..d0abaa7c0
--- /dev/null
+++ b/mod/event_calendar/images/calendar.gif
Binary files differ
diff --git a/mod/event_calendar/images/event_icon.gif b/mod/event_calendar/images/event_icon.gif
new file mode 100644
index 000000000..a0ac7da52
--- /dev/null
+++ b/mod/event_calendar/images/event_icon.gif
Binary files differ
diff --git a/mod/event_calendar/images/event_icon_old.gif b/mod/event_calendar/images/event_icon_old.gif
new file mode 100644
index 000000000..154d5af09
--- /dev/null
+++ b/mod/event_calendar/images/event_icon_old.gif
Binary files differ
diff --git a/mod/event_calendar/images/ics.png b/mod/event_calendar/images/ics.png
new file mode 100644
index 000000000..311ffa221
--- /dev/null
+++ b/mod/event_calendar/images/ics.png
Binary files differ
diff --git a/mod/event_calendar/images/river_icon_event.gif b/mod/event_calendar/images/river_icon_event.gif
new file mode 100644
index 000000000..d02e5395a
--- /dev/null
+++ b/mod/event_calendar/images/river_icon_event.gif
Binary files differ
diff --git a/mod/event_calendar/languages/ca.php b/mod/event_calendar/languages/ca.php
new file mode 100644
index 000000000..4881d7458
--- /dev/null
+++ b/mod/event_calendar/languages/ca.php
@@ -0,0 +1,143 @@
+<?php
+$language = array (
+ 'item:object:event_calendar' => 'Calendari',
+ 'tag_names:event_tags' => 'Etiquetes',
+ 'event_calendar:optional' => 'Opcional.',
+ 'event_calendar:required' => 'Requerit.',
+ 'event_calendar:new_event' => 'Nou esdeveniment',
+ 'event_calendar:no_such_event_edit_error' => 'Error: no hi ha cap esdeveniment o no tens permissos per editar-lo.',
+ 'event_calendar:add_event_title' => 'Afegeix esdeveniment',
+ 'event_calendar:manage_event_title' => 'Edita esdeveniment',
+ 'event_calendar:manage_event_description' => 'Introdueix detalls del teu esdeveniment a sota. El títol, lloc on serà i data d\'inici són requerits. Pots fer clic a les icones del calendari per indicar les dates d\'inici i final.',
+ 'event_calendar:title_label' => 'Títol',
+ 'event_calendar:title_description' => 'D\'una a quatre paraules',
+ 'event_calendar:brief_description_label' => 'Descripció',
+ 'event_calendar:brief_description_description' => 'Una frase curta.',
+ 'event_calendar:venue_label' => 'On',
+ 'event_calendar:venue_description' => 'On serà aquest esdeveniment?',
+ 'event_calendar:start_date_label' => 'Data d\'inici',
+ 'event_calendar:start_date_description' => 'Quan començarà?',
+ 'event_calendar:end_date_label' => 'Data de finalització',
+ 'event_calendar:end_date_description' => 'Quan finalitzarà aquest esdeveniment? La data d\'inici serà utilitzada com a data de finalització si no en poses cap.',
+ 'event_calendar:start_time_label' => 'Hora d\'inici',
+ 'event_calendar:start_time_description' => 'A quina hora començarà aquest esdeveniment?',
+ 'event_calendar:end_time_label' => 'Hora de finalització',
+ 'event_calendar:end_time_description' => 'A quina hora finalitzarà aquest esdeveniment?',
+ 'event_calendar:fees_label' => 'Costos',
+ 'event_calendar:fees_description' => 'El cost d\'aquest esdeveniment, si és que en té.',
+ 'event_calendar:contact_label' => 'Contacte',
+ 'event_calendar:contact_description' => 'La persona de contacte per a més informació, preferiblement amb un número de telèfon o una adreça d\'email',
+ 'event_calendar:organiser_label' => 'Organitzadora',
+ 'event_calendar:organiser_description' => 'La persona o organització responsable d\'aquest esdeveniment.',
+ 'event_calendar:event_tags_label' => 'Etiquetes',
+ 'event_calendar:event_tags_description' => 'Una llista separada amb comes de les etiquetes més destacables per a aquest esdeveniment.',
+ 'event_calendar:long_description_label' => 'Descripció llarga',
+ 'event_calendar:long_description_description' => 'Pot ser un paràgraf o més com a requerit.',
+ 'event_calendar:manage_event_response' => 'El teu esdeveniment s\'ha desat correctament.',
+ 'event_calendar:add_event_response' => 'El teu esdeveniment s\'ha afegit correctament.',
+ 'event_calendar:show_events_title' => 'Calendari',
+ 'event_calendar:day_label' => 'Dia',
+ 'event_calendar:week_label' => 'Setmana',
+ 'event_calendar:month_label' => 'Mes',
+ 'event_calendar:group' => 'Calendari del grup',
+ 'event_calendar:new' => 'Afegir esdeveniment',
+ 'event_calendar:submit' => 'Desa i continua',
+ 'event_calendar:cancel' => 'Cancel·la',
+ 'event_calendar:widget_title' => 'Calendari',
+ 'event_calendar:widget:description' => 'Mostra els teus esdeveniments.',
+ 'event_calendar:num_display' => 'Número d\'esdeveniments per mostrar',
+ 'event_calendar:groupprofile' => 'Propers esdeveniments',
+ 'event_calendar:view_calendar' => 'vista del calendari',
+ 'event_calendar:when_label' => 'Quan',
+ 'event_calendar:site_wide_link' => 'Veure tots els esdeveniments',
+ 'event_calendar:view_link' => 'Veure aquest esdeveniment',
+ 'event_calendar:edit_link' => 'Edita aquest esdeveniment',
+ 'event_calendar:delete_link' => 'Esborra aquest esdeveniment',
+ 'event_calendar:delete_response' => 'Aquest esdeveniment ha estat esborrat.',
+ 'event_calendar:error_delete' => 'Aquest esdeveniment no existeix o no tens permisos per esborrar-lo.',
+ 'event_calendar:delete_cancel_response' => 'Esborrat de l\'esdeveniment cancel·lat.',
+ 'event_calendar:add_to_my_calendar' => 'Afegeix al meu calendari',
+ 'event_calendar:remove_from_my_calendar' => 'Treure del meu calendari',
+ 'event_calendar:add_to_my_calendar_response' => 'Aquest esdeveniment ha estat afegit al teu calendari personal',
+ 'event_calendar:add_to_the_calendar' => 'Afegeix al calendari',
+ 'event_calendar:remove_from_the_calendar' => 'Elimina',
+ 'event_calendar:add_to_the_calendar_menu_text' => 'Afegir al meu',
+ 'event_calendar:remove_from_the_calendar_menu_text' => 'Elimina del meu',
+ 'event_calendar:remove_from_the_calendar_button' => 'Elimina del calendari',
+ 'event_calendar:added_to_the_calendar' => 'Afegit al calendari',
+ 'event_calendar:removed_from_the_calendar' => 'Calendari eliminat',
+ 'event_calendar:personal_event_calendars_link' => 'A %s calendaris',
+ 'event_calendar:personal_event_calendars_link_one' => 'A un calendari',
+ 'event_calendar:users_for_event_breadcrumb' => 'Calendaris personals',
+ 'event_calendar:settings:group_profile_display_option:left' => 'columna esquerra',
+ 'event_calendar:settings:group_profile_display_option:right' => 'columna dreta',
+ 'event_calendar:settings:group_profile_display_option:none' => 'cap',
+ 'event_calendar:settings:agenda_view:title' => 'Utilitza la vista d\'agenda',
+ 'event_calendar:settings:yes' => 'sí',
+ 'event_calendar:settings:no' => 'no',
+ 'event_calendar:region_label' => 'Regió',
+ 'event_calendar:type_label' => 'Tipus',
+ 'event_calendar:all' => 'Tots',
+ 'event_calendar:no_events_found' => 'No s\'han trobat esdeveniments.',
+ 'event_calendar:mine' => 'Meus',
+ 'event_calendar:agenda:column:time' => 'Temps',
+ 'event_calendar:agenda:column:session' => 'Sessió',
+ 'event_calendar:agenda:column:venue' => 'Localització',
+ 'event_calendar:settings:agenda' => 'agenda',
+ 'event_calendar:settings:month' => 'per mes',
+ 'event_calendar:settings:full' => 'vista completa',
+ 'event_calendar:paged:column:date' => 'Data',
+ 'event_calendar:paged:column:time' => 'Hora',
+ 'event_calendar:paged:column:event' => 'Esdeveniment',
+ 'event_calendar:paged:column:venue' => 'Localització',
+ 'event_calendar:paged:column:calendar' => 'Calendari',
+ 'event_calendar:open' => 'Obrir',
+ 'event_calendar:add_user_label' => 'Afegir habitants',
+ 'event_calendar:show_all' => 'Tots',
+ 'event_calendar:show_mine' => 'El meu calendari',
+ 'event_calendar:show_friends' => 'Calendari de les amigues',
+ 'event_calendar:listing_title:all' => 'Tots',
+ 'event_calendar:listing_title:mine' => 'El meu calendari',
+ 'event_calendar:listing_title:friends' => 'Calendari de les amigues',
+ 'event_calendar:personal_manage:open' => 'obert',
+ 'event_calendar:personal_manage:closed' => 'tancat',
+ 'event_calendar:personal_manage:private' => 'privat',
+ 'event_calendar:from_label' => 'De:',
+ 'event_calendar:to_label' => 'A:',
+ 'event_calendar:settings:timeformat:title' => 'Format d\'hora',
+ 'event_calendar:time_format:12hour' => '12 hores (am/pm)',
+ 'event_calendar:time_format:24hour' => '24 hores',
+ 'event_calendar:all_day_label' => 'Event de tot el dia',
+ 'event_calendar:repeat_interval_label' => 'Repeteix cada',
+ 'event_calendar:repeat_weeks' => 'setmana(es)',
+ 'event_calendar:on_these_days' => 'en aquests dies',
+ 'event_calendar:day_abbrev:monday' => 'DL',
+ 'event_calendar:day_abbrev:tuesday' => 'DM',
+ 'event_calendar:day_abbrev:wednesday' => 'DC',
+ 'event_calendar:day_abbrev:thursday' => 'DJ',
+ 'event_calendar:day_abbrev:friday' => 'DV',
+ 'event_calendar:day_abbrev:saturday' => 'DS',
+ 'event_calendar:day_abbrev:sunday' => 'DG',
+ 'event_calendar:dow:full:monday' => 'Dilluns',
+ 'event_calendar:dow:full:tuesday' => 'Dimarts',
+ 'event_calendar:dow:full:wednesday' => 'Dimecres',
+ 'event_calendar:dow:full:thursday' => 'Dijous',
+ 'event_calendar:dow:full:friday' => 'Divendres',
+ 'event_calendar:dow:full:saturday' => 'Dissabte',
+ 'event_calendar:dow:full:sunday' => 'Diumenge',
+ 'event_calendar:schedule_type:fixed' => 'Posa data i hora',
+ 'event_calendar:interval:minute' => 'minut(s)',
+ 'event_calendar:interval:hour' => 'hora(es)',
+ 'event_calendar:interval:day' => 'dia(es)',
+ 'event_calendar:site_calendar' => 'Calendari del lloc',
+ 'event_calendar:calendar_label' => 'Calendari',
+ 'event_calendar:calendar_description' => 'Calendari per aquest esdeveniment.',
+ 'event_calendar:basic:header' => 'Informació bàsica',
+ 'event_calendar:schedule:header' => 'Horari',
+ 'event_calendar:permissions:header' => 'Permisos',
+ 'event_calendar:read_access' => 'Accés de lectura',
+ 'event_calendar:add_event' => 'Afegeix event',
+ 'event_calendar:poll_suffix' => '(enquesta)',
+ 'event_calendar:add' => 'Afegeix',
+);
+add_translation("ca", $language);
diff --git a/mod/event_calendar/languages/en.php b/mod/event_calendar/languages/en.php
new file mode 100644
index 000000000..b8fb918cc
--- /dev/null
+++ b/mod/event_calendar/languages/en.php
@@ -0,0 +1,360 @@
+<?php
+
+ $english = array(
+
+ 'item:object:event_calendar' => "Calendar",
+ 'tag_names:event_tags' => "Tags",
+ 'event_calendar:optional' => "Optional.",
+ 'event_calendar:required' => "Required.",
+ 'event_calendar:new_event' => "New event",
+ 'event_calendar:no_such_event_edit_error' => "Error: There is no such event or you do not have permission to edit it.",
+ 'event_calendar:add_event_title' => "Add event",
+ 'event_calendar:manage_event_title' => "Edit event",
+ 'event_calendar:manage_event_description' => "Enter the details of your event below. "
+ ."The title, venue, and start date are required. "
+ ."You can click on the calendar icons to set the start and end dates.",
+ 'event_calendar:title_label' => "Title",
+ 'event_calendar:title_description' => "One to four words",
+ 'event_calendar:brief_description_label' => "Description",
+ 'event_calendar:brief_description_description' => "A short phrase.",
+ 'event_calendar:venue_label' => "Where",
+ 'event_calendar:venue_description' => "Where will this event be held?",
+ 'event_calendar:start_date_label' => "Start date",
+ 'event_calendar:start_date_description' => "When will this event start?",
+ 'event_calendar:end_date_label' => "End date",
+ 'event_calendar:end_date_description' => "When will this event end? The start date will be "
+ ."used as the end date if this is not supplied.",
+ 'event_calendar:start_time_label' => "Start time",
+ 'event_calendar:start_time_description' => "What time will this event start?",
+ 'event_calendar:end_time_label' => "End time",
+ 'event_calendar:end_time_description' => "What time will this event end?",
+ 'event_calendar:fees_label' => "Fees",
+ 'event_calendar:fees_description' => "The cost of this event, if any.",
+ 'event_calendar:contact_label' => "Contact",
+ 'event_calendar:contact_description' => "The person to contact for more information, "
+ ."preferably with a telephone number or email address.",
+ 'event_calendar:organiser_label' => "Organiser",
+ 'event_calendar:organiser_description' => "The individual or organisation responsible for this event.",
+ 'event_calendar:event_tags_label' => "Tags",
+ 'event_calendar:event_tags_description' => "A comma-separated list of tags relevant to this event.",
+ 'event_calendar:long_description_label' => "Long description",
+ 'event_calendar:long_description_description' => "Can be a paragraph or more as required.",
+ 'event_calendar:manage_event_response' => "Your event has been saved.",
+ 'event_calendar:add_event_response' => "Your event has been added.",
+ 'event_calendar:manage_event_error' => "Error: There was an error in saving your event. "
+ ."Please make sure that you have provided the required fields.",
+ 'event_calendar:error_nosuchevent' => "Error: there is no such event.",
+ 'event_calendar:show_events_title' => "Calendar",
+ 'event_calendar:day_label' => "Day",
+ 'event_calendar:week_label' => "Week",
+ 'event_calendar:month_label' => "Month",
+ 'event_calendar:group' => "Group calendar",
+ 'event_calendar:new' => "Add event",
+ 'event_calendar:submit' => "Save and Continue",
+ 'event_calendar:cancel' => "Cancel",
+ 'event_calendar:widget_title' => "Calendar",
+ 'event_calendar:widget:description' => "Displays your events.",
+ 'event_calendar:num_display' => "Number of events to display",
+ 'event_calendar:groupprofile' => "Upcoming events",
+ 'event_calendar:view_calendar' => "view calendar",
+ 'event_calendar:when_label' => "When",
+ 'event_calendar:site_wide_link' => "View all events",
+ 'event_calendar:view_link' => "View this event",
+ 'event_calendar:edit_link' => "Edit this event",
+ 'event_calendar:delete_link' => "Delete this event",
+ 'event_calendar:delete_response' => "This event has been deleted.",
+ 'event_calendar:error_delete' => "This event does not exist or you do not have the right to delete it.",
+ 'event_calendar:delete_cancel_response' => "Event delete cancelled.",
+ 'event_calendar:add_to_my_calendar' => "Add to my calendar",
+ 'event_calendar:remove_from_my_calendar' => "Remove from my calendar",
+ 'event_calendar:add_to_my_calendar_response' => "This event has been added to your personal calendar.",
+ 'event_calendar:add_to_my_calendar_error' => "This event could not added to your personal calendar. "
+ ."(Perhaps the event is full or is scheduled at the same time as another event in your personal calendar?)",
+ 'event_calendar:remove_from_my_calendar_response' => "This event has been removed from your personal calendar.",
+ 'event_calendar:add_to_the_calendar' => "Add to calendar",
+ 'event_calendar:remove_from_the_calendar' => "Remove",
+ 'event_calendar:add_to_the_calendar_menu_text' => "Add to mine",
+ 'event_calendar:remove_from_the_calendar_menu_text' => "Remove from mine",
+ 'event_calendar:remove_from_the_calendar_button' => "Remove from calendar",
+ 'event_calendar:added_to_the_calendar' => "Added to calendar",
+ 'event_calendar:removed_from_the_calendar' => "Removed calendar",
+ 'event_calendar:add_to_the_calendar_response' => "Event added to this person's calendar.",
+ 'event_calendar:add_to_the_calendar_error' => "This event could not added to this person's calendar. "
+ ."(Perhaps the event is full or is scheduled at the same time as another event in this person's calendar?)",
+ 'event_calendar:remove_from_the_calendar_response' => "Event removed from this person's calendar.",
+
+ 'event_calendar:users_for_event_menu_title' => "People listing this event on their personal calendars",
+ 'event_calendar:users_for_event_title' => "Personal calendars for \"%s'\"",
+ 'event_calendar:personal_event_calendars_link' => "On %s calendars",
+ 'event_calendar:personal_event_calendars_link_one' => "On 1 calendar",
+ 'event_calendar:users_for_event_breadcrumb' => "Personal calendars",
+ 'event_calendar:settings:group_profile_display:title' => "Group calendar profile display (if group calendars are enabled)",
+ 'event_calendar:settings:group_profile_display_option:left' => "left column",
+ 'event_calendar:settings:group_profile_display_option:right' => "right column",
+ 'event_calendar:settings:group_profile_display_option:none' => "none",
+ 'event_calendar:settings:times:title' => "Add time as well as date to events",
+ 'event_calendar:settings:autopersonal:title' => "Automatically add events a user creates to his/her personal calendar.",
+ 'event_calendar:settings:autogroup:title' => "Automatically add group events for all members to their personal calendars.",
+ 'event_calendar:settings:agenda_view:title' => "Use Agenda view",
+ 'event_calendar:settings:venue_view:title' => "Display venue in summary view (event listings)",
+ 'event_calendar:settings:yes' => "yes",
+ 'event_calendar:settings:no' => "no",
+ 'event_calendar:settings:site_calendar:title' => "Site calendar",
+ 'event_calendar:settings:site_calendar:admin' => "yes, only admins can post events",
+ 'event_calendar:settings:site_calendar:loggedin' => "yes, any logged-in user can post an event",
+ 'event_calendar:settings:group_calendar:title' => "Group calendars",
+ 'event_calendar:settings:group_calendar:admin' => "yes, only admins and group owners can post events",
+ 'event_calendar:settings:group_calendar:members' => "yes, any group member can post an event",
+ 'event_calendar:settings:group_default:title' => "New groups should by default have a group calendar (if group calendars are enabled)",
+ 'event_calendar:settings:group_default:no' => "no (but admins or group owners can turn a group calendar on if desired)",
+ 'event_calendar:settings:group_default:yes' => "yes (but admins or group owners can turn a group calendar off if desired)",
+ 'event_calendar:settings:group_always_display:title' => "If group calendar is enabled, always display it (even if empty)",
+ 'event_calendar:settings:region_display:title' => "Add region field to events",
+ 'event_calendar:settings:region_list:title' => "List of regions (one per line)",
+ 'event_calendar:region_label' => "Region",
+ 'event_calendar:region_description' => "Select the region that this event will be held in.",
+ 'event_calendar:settings:type_display:title' => "Add event type to events",
+ 'event_calendar:settings:type_list:title' => "List of event types (one per line)",
+ 'event_calendar:type_label' => "Type",
+ 'event_calendar:type_description' => "Select the type of event.",
+ 'event_calendar:all' => "All",
+ 'event_calendar:region_filter_by_label' => "Filter by region: ",
+ 'event_calendar:settings:first_date:title' => "First allowable date (in YYYY-MM-DD format)",
+ 'event_calendar:settings:last_date:title' => "Last allowable date (in YYYY-MM-DD format)",
+ 'event_calendar:enable_event_calendar' => "Enable group calendar",
+ 'event_calendar:no_events_found' => "No events found.",
+ 'event_calendar:mine' => "Mine",
+ 'event_calendar:feature' => "Feature",
+ 'event_calendar:unfeature' => "Unfeature",
+ 'event_calendar:agenda:column:time' => "Time",
+ 'event_calendar:agenda:column:session' => "Session",
+ 'event_calendar:agenda:column:venue' => "Location",
+ 'event_calendar:upcoming_events_title' => "Upcoming events",
+ 'event_calendar:settings:paged' => "paged",
+ 'event_calendar:settings:agenda' => "agenda",
+ 'event_calendar:settings:month' => "by month",
+ 'event_calendar:settings:full' => "full view",
+ 'event_calendar:settings:listing_format:title' => "Event listing format",
+ 'event_calendar:paged:column:date' => "Date",
+ 'event_calendar:paged:column:time' => "Time",
+ 'event_calendar:paged:column:event' => "Event",
+ 'event_calendar:paged:column:venue' => "Location",
+ 'event_calendar:paged:column:calendar' => "Calendar",
+ 'event_calendar:settings:spots_display:title' => "Add a spots field for each "
+ ."event to allow you to limit the number of people who can add the event to their calendar",
+ 'event_calendar:settings:no_collisions:title' => "Collision detection: prevent people from adding two events at the same time to their personal calendar",
+ 'event_calendar:settings:collision_length:title' => "How long (in seconds) should an event be assumed to last if no end date or time is specified "
+ ."(used for collision detection). Defaults to 3600 seconds = 1 hour.",
+ 'event_calendar:spots_label' => "Spots",
+ 'event_calendar:spots_description' => "How many people are allowed to add this event to their personal calendars?",
+ 'event_calendar:open' => "Open",
+ 'event_calendar:settings:add_users:title' => "Allow event creators and site admins to add their event to other personal calendars.",
+ 'event_calendar:add_user_label' => "Add users",
+ 'event_calendar:add_user_description' => "Add this event to personal calendars by typing two or more characters in the above text autocomplete field to select a user. "
+ ."You can add multiple users by clicking the \"+\" link. (You must submit this form to actually add the event to the calendars.)",
+ 'event_calendar:settings:add_users_notify:title' => "Email users who have had an event added to their personal calendar by an admin or event creator.",
+ 'event_calendar:add_users_notify:subject' => "A new event has been added to your personal calendar",
+ 'event_calendar:add_users_notify:body' => "%s,\n\nThe \"%s\" event has been added to your calendar.\n\nYou can view it here: \n\n%s\n",
+
+ 'event_calendar:settings:region_list_handles:title' => "The region strings above are string handles. Use the Elgg translation system to resolve them.",
+ 'event_calendar:settings:type_list_handles:title' => "The type strings above are string handles. Use the Elgg translation system to resolve them.",
+
+ 'event_calendar:settings:personal_manage:title' => "Calendar permissions",
+ 'event_calendar:settings:personal_manage:description' => "Determines whether people can add events to their personal calendars (open), "
+ ."need to request the event creator to do so (closed), have no option at all (private), or allow event creators to determine this for each event (by event). "
+ ."Note if you set this to private you should probably activate the option above to allow event creators and site admins to "
+ ."add their events to other personal calendars.",
+ 'event_calendar:strapline' => "Posted %s by %s",
+
+ 'event_calendar:request_event_response' => "Your request to be added to this event has been sent.",
+ 'event_calendar:request_event_error' => "Error: Could not send your request to be added to this event.",
+ 'event_calendar:request_subject' => "You have received an event request",
+ 'event_calendar:request_message' => "%s has asked to have the event \"%s\", here:
+
+%s
+
+added to his/her personal calendar.
+
+You can manage calendar requests for this event here:
+
+%s
+",
+
+ 'event_calendar:review_requests_error' => "This event either does not exist or you do not have the authority to approve requests for it.",
+ 'event_calendar:review_requests_request_none' => "There are no requests to review for this event.",
+ 'event_calendar:request:remove:check' => 'Are you sure you want to reject this request?',
+ 'event_calendar:requestkilled' => 'This request has been rejected.',
+ 'event_calendar:request_approved' => "This request has been approved.",
+ 'event_calendar:review_requests_title' => "Review requests for \"%s\"",
+ 'event_calendar:review_requests_menu_title' => "Review requests",
+ 'event_calendar:make_request_title' => 'Request this event',
+ 'event_calendar:review_requests:reject' => "Reject",
+ 'event_calendar:review_requests:reject:title' => "Reject this request",
+ 'event_calendar:review_requests:accept' => "Accept",
+ 'event_calendar:review_requests:accept:title' => "Accept this request",
+ 'event_calendar:review_requests:error:approve' => "Error: could not approve this request.",
+ 'event_calendar:review_requests:error:reject' => "Error: could not reject this request.",
+
+ 'event_calendar:settings:hide_access:title' => "Hide event access drop down",
+ 'event_calendar:settings:default_access:title' => "If the event access is hidden, what should it default to?",
+ 'event_calendar:settings:hide_end:title' => "Hide end time and date fields",
+ 'event_calendar:settings:more_required:title' => "Make all visible fields except long description required.",
+
+ 'event_calendar:add_to_group:remove_group_title' => "Remove this event from group",
+ 'event_calendar:add_to_group:remove_group_button' => "Remove from group",
+ 'event_calendar:remove_from_group:success' => "Event removed from group calendar",
+ 'event_calendar:add_to_group:add_group_title' => "Add this event to group",
+ 'event_calendar:add_to_group:add_group_button' => "Add to group",
+ 'event_calendar:add_to_group:success' => "Event added to group calendar",
+ 'event_calendar:settings:add_to_group_calendar:title' => "Allow group admins to add any existing event to a group calendar",
+
+ 'event_calendar:group_breadcrumb' => "Group calendar",
+ 'event_calendar:no_group' => "There is no such group.",
+ 'event_calendar:generic_error_title' => "Error",
+ 'event_calendar:error_event_edit' => "Error: there is no such event or you do not have permission to edit it.",
+ 'event_calendar:add' => "Add",
+
+ 'feed:ical' => "iCal feed for this page",
+ 'event_calendar:ical_popup_message' => "You can use the following URL to get an iCalendar feed of the public events from this listing page: ",
+ 'event_calendar:ical_auth_file_name:title' => "Location of iCal authentication file on local file system (experimental - not needed for public feeds)",
+
+ 'event_calendar:owner:permissions_error' => "You do not have permission to view that page.",
+ 'event_calendar:feature_not_activated' => "This feature is not activated",
+
+ 'event_calendar:show_all' => "Show all",
+ 'event_calendar:show_open' => "Show open",
+ 'event_calendar:show_mine' => "My calendar",
+ 'event_calendar:show_friends' => "My friends' calendars",
+ 'event_calendar:show_only' => "Show only those on:",
+
+ 'event_calendar:listing_title:all' => "All events",
+ 'event_calendar:listing_title:open' => "Open events",
+ 'event_calendar:listing_title:mine' => "My calendar",
+ 'event_calendar:listing_title:friends' => "Friends' calendars",
+ 'event_calendar:manage_users:title' => "Manage subscribers for \"%s\"",
+ 'event_calendar:manage_users:breadcrumb' => "Manage subscribers",
+ 'event_calendar:manage_users:description' => "Add or remove events from personal calendars.",
+ 'event_calendar:manage_users:unauthorized' => "Error: you are not authorised to manage personal calendars for this event.",
+ 'event_calendar:add_to_group_members:success' => "This event has been added to the personal calendars of all group members.",
+ 'event_calendar:add_to_group_members:error' => "Error: could not add this event to the personal calendars of group members.",
+ 'event_calendar:remove_from_group_members:success' => "This event has been removed from the personal calendars of all group members.",
+ 'event_calendar:remove_from_group_members:error' => "Error: could not remove this event from the personal calendars of group members.",
+ 'event_calendar:add_to_group_members:button' => "Add to all",
+ 'event_calendar:remove_from_group_members:button' => "Remove from all",
+
+ 'event_calendar:manage_subscribers:success' => "Personal calendars updated.",
+ 'event_calendar:manage_subscribers:error' => "Error: could not update personal calendars.",
+ 'event_calendar:personal_manage:open' => "open",
+ 'event_calendar:personal_manage:closed' => "closed",
+ 'event_calendar:personal_manage:private' => "private",
+ 'event_calendar:personal_manage:by_event' => "by event",
+ 'event_calendar:personal_manage:label' => "Personal calendars",
+ 'event_calendar:personal_manage:description' => "Determines whether people can add this event to their calendars (open), "
+ ."need to apply to do so (closed) or have no option at all (private - so only you or a site admin can add the event to calendars).",
+ 'event_calendar:personal_manage:by_event:open' => "Open. People can freely add this event to their personal calendars.",
+ 'event_calendar:personal_manage:by_event:closed' => "Closed. People can request to add this event to their personal calendars. You can review and approve requests.",
+ 'event_calendar:personal_manage:by_event:private' => "Private. You or another event administrator must add this event to personal calendars. There is no way for other users to add or request this event.",
+
+ 'event_calendar:settings:full_calendar:title' => "Support full calendar",
+ 'event_calendar:modify_full_calendar:error' => "Error: could not modify full calendar",
+ 'event_calendar:from_label' => "From:",
+ 'event_calendar:to_label' => "To:",
+ 'event_calendar:settings:timeformat:title' => "Time format",
+ 'event_calendar:time_format:12hour' => "12 hour (am/pm)",
+ 'event_calendar:time_format:24hour' => "24 hour",
+ 'event_calendar:all_day_label' => "All-day event",
+ 'event_calendar:repeat_interval_label' => "Repeat every",
+ 'event_calendar:repeat_weeks' => "week(s)",
+ 'event_calendar:on_these_days' => "on these days:",
+ 'event_calendar:day_abbrev:monday' => "M",
+ 'event_calendar:day_abbrev:tuesday' => "T",
+ 'event_calendar:day_abbrev:wednesday' => "W",
+ 'event_calendar:day_abbrev:thursday' => "T",
+ 'event_calendar:day_abbrev:friday' => "F",
+ 'event_calendar:day_abbrev:saturday' => "S",
+ 'event_calendar:day_abbrev:sunday' => "S",
+ 'event_calendar:dow:full:monday' => "Monday",
+ 'event_calendar:dow:full:tuesday' => "Tuesday",
+ 'event_calendar:dow:full:wednesday' => "Wednesday",
+ 'event_calendar:dow:full:thursday' => "Thursday",
+ 'event_calendar:dow:full:friday' => "Friday",
+ 'event_calendar:dow:full:saturday' => "Saturday",
+ 'event_calendar:dow:full:sunday' => "Sunday",
+ 'event_calendar:schedule_type:poll' => "Create poll asking invitees about day/time",
+ 'event_calendar:schedule_type:fixed' => "Set day/time",
+ 'elgg_calendar:send_reminder_label' => "Send reminder",
+ 'elgg_calendar:send_reminder_before' => "before",
+ 'event_calendar:interval:minute' => "minute(s)",
+ 'event_calendar:interval:hour' => "hour(s)",
+ 'event_calendar:interval:day' => "day(s)",
+ '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:basic:header' => "Basic info",
+ 'event_calendar:schedule:header' => "Schedule",
+ 'event_calendar:permissions:header' => "Permissions",
+ 'event_calendar:read_access' => "Read access",
+ 'event_calendar:web_conference_label' => "Include a web conference for this event.",
+ 'event_calendar:share_ownership:label' => "Share ownership of this event",
+ '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.",
+ 'event_calendar:repeated_event:format' => "Starting on %s and repeated on %s",
+ '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:reminder:body' => "The event
+
+%s
+
+takes place at
+
+%s.
+
+You can visit the event page here:
+%s
+ ",
+
+ /**
+ * BBB support
+ */
+
+ 'event_calendar:bbb_server_url' => "Big Blue Button server URL (must end with slash)",
+ 'event_calendar:bbb_security_salt' => "Big Blue Button security salt",
+ 'event_calendar:bbb_create_error' => "Error: unable to create BBB conference, message was: %s",
+ 'event_calendar:conference_create_error' => "Error: unable to create web conference.",
+ 'event_calendar:bbb_settings_error' => "Error: must set conference URL and salt in plugin settings",
+ 'event_calendar:couldnotjoin' => "Error: unable to join conference.",
+ '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
+ **/
+
+ //generic terms to use
+
+ 'river:update:object:event_calendar' => "%s updated the event %s",
+ 'river:create:object:event_calendar' => "%s added the event %s",
+ 'river:comment:object:event_calendar' => '%s commented on the event %s',
+ 'event_calendar:river:created' => "%s added",
+ 'event_calendar:river:updated' => "%s updated",
+ 'event_calendar:river:annotated1' => "%s added",
+ 'event_calendar:river:annotated2' => "to his/her personal calendar.",
+
+ //these get inserted into the river links to take the user to the entity
+ 'event_calendar:river:create' => "a new event titled",
+ 'event_calendar:river:the_event' => "an event titled",
+
+ );
+
+ add_translation("en",$english);
diff --git a/mod/event_calendar/languages/es.php b/mod/event_calendar/languages/es.php
new file mode 100644
index 000000000..2282591d3
--- /dev/null
+++ b/mod/event_calendar/languages/es.php
@@ -0,0 +1,215 @@
+<?php
+$language = array (
+ 'tag_names:event_tags' => 'Etiqueta',
+ 'event_calendar:optional' => 'Opcional.',
+ 'event_calendar:required' => 'Requerido.',
+ 'event_calendar:add_to_my_calendar_error' => 'No se puede añadir ese evento a tu calendario personal. (Quizás tu calendario ya esté lleno o ¿intentas agendar dos eventos a la vez en tu calendario personal?)',
+ 'event_calendar:add_to_the_calendar' => 'Añadir al calendario',
+ 'event_calendar:remove_from_the_calendar' => 'Remover',
+ 'event_calendar:add_to_the_calendar_menu_text' => 'Añadir a mi calendario',
+ 'event_calendar:remove_from_the_calendar_menu_text' => 'Remover de mi calendario',
+ 'event_calendar:remove_from_the_calendar_button' => 'Remover del calendario',
+ 'event_calendar:added_to_the_calendar' => 'Añadir al calendario',
+ 'event_calendar:removed_from_the_calendar' => 'Remover calendario',
+ 'event_calendar:add_to_the_calendar_response' => 'Evento añadido al calendario personal',
+ 'event_calendar:add_to_the_calendar_error' => 'No se puede añadir ese evento a tu calendario personal. (Quizás tu calendario ya esté lleno o ¿intentas agendar dos eventos a la vez en tu calendario personal?)',
+ 'event_calendar:remove_from_the_calendar_response' => 'Evento borrado del calendario.',
+ 'event_calendar:users_for_event_menu_title' => 'Habitantes que apuntan ese evento en su calendario personal',
+ 'event_calendar:personal_event_calendars_link_one' => 'En 1 calendario',
+ 'event_calendar:users_for_event_breadcrumb' => 'Calendario personal',
+ 'event_calendar:settings:agenda' => 'Agenda',
+ 'event_calendar:settings:full' => 'Vista completa',
+ 'event_calendar:settings:spots_display:title' => 'Añade un campo para cada evento para que puedas limitar el numero de personas que pueden añadir el evento a su propio calendario',
+ 'event_calendar:settings:no_collisions:title' => 'Colisión detectada: evita que se añadan dos eventos a la vez en el calendario',
+ 'event_calendar:settings:collision_length:title' => 'Cuanto tiempo (en segundos) un evento puede ser considerado como activo si no se establece una fecha o hora para su fin (usado para la detección de colisiones). Por defecto: 3600 segundos = 1 hora.',
+ 'event_calendar:spots_description' => '¿A cuantas habitantes se aceptarán que añadan ese evento a sus calendarios personales?',
+ 'event_calendar:open' => 'Abierto',
+ 'event_calendar:add_user_label' => 'Añadir habitantes',
+ 'event_calendar:add_users_notify:subject' => 'Un nuevo evento se ha añadido a tu calendario personal',
+ 'event_calendar:add_users_notify:body' => '%s,
+
+Se ha añadido un evento de "%s" a tu calendario personal.',
+ 'event_calendar:settings:personal_manage:title' => 'Permisos del calendario',
+ 'event_calendar:request_event_response' => 'Tu petición para añadir ese evento ha sido enviada,',
+ 'event_calendar:request_event_error' => 'Error: Tu petición para añadir el evento al calendario no se ha enviado.',
+ 'event_calendar:request_subject' => 'Haz recebido una invitación de calendario',
+ 'event_calendar:review_requests_request_none' => 'No hay peticiones a revisar para ese evento.',
+ 'event_calendar:request:remove:check' => '¿Estas seguro que quieres rechazar esa petición?',
+ 'event_calendar:requestkilled' => 'La petición ha sido rechazada.',
+ 'event_calendar:request_approved' => 'La petición ha sido aceptada.',
+ 'event_calendar:make_request_title' => 'Enviar petición a ese evento',
+ 'event_calendar:review_requests:reject' => 'Rechazar',
+ 'event_calendar:review_requests:reject:title' => 'Rechazar la petición',
+ 'event_calendar:review_requests:accept' => 'Aceptar',
+ 'event_calendar:review_requests:accept:title' => 'Aceptar la petición',
+ 'event_calendar:review_requests:error:approve' => 'Error: la petición no se ha aprobado.',
+ 'event_calendar:review_requests:error:reject' => 'Error: No se ha podido rechazar la petición.',
+ 'event_calendar:settings:hide_access:title' => 'Ocultar acceso al calendario',
+ 'event_calendar:settings:hide_end:title' => 'Ocultar campos de fecha y hora',
+ 'event_calendar:settings:more_required:title' => 'Hacer visible todos los campos excepto si se requiere una larga descripción.',
+ 'event_calendar:add_to_group:remove_group_title' => 'Remover ese evento del grupo',
+ 'event_calendar:add_to_group:remove_group_button' => 'Remover del grupo',
+ 'event_calendar:remove_from_group:success' => 'Evento removido del calendario del grupo',
+ 'event_calendar:add_to_group:add_group_title' => 'Añadir ese evento al grupo',
+ 'event_calendar:add_to_group:add_group_button' => 'Adicionar al grupo',
+ 'event_calendar:add_to_group:success' => 'Evento añadido al calendario del grupo',
+ 'event_calendar:settings:add_to_group_calendar:title' => 'Aceptar que el grupo de operadores añadan cualquier evento existente al calendario del grupo',
+ 'event_calendar:group_breadcrumb' => 'Calendario del grupo',
+ 'event_calendar:generic_error_title' => 'Error',
+ 'event_calendar:add' => 'Añadir',
+ 'event_calendar:owner:permissions_error' => 'No ienes permisos para visualizar esa pagina.',
+ 'event_calendar:feature_not_activated' => 'Esa funcionalidad no esta activada',
+ 'event_calendar:show_all' => 'Muestra todo',
+ 'event_calendar:show_mine' => 'Mi calendario',
+ 'event_calendar:show_friends' => 'Calendario de mis amigas',
+ 'event_calendar:from_label' => 'Desde:',
+ 'event_calendar:to_label' => 'Hasta:',
+ 'event_calendar:time_format:12hour' => '12 horas (am/pm)',
+ 'event_calendar:time_format:24hour' => '24 horas',
+ 'event_calendar:all_day_label' => 'El evento dura todo el día',
+ 'event_calendar:repeat_interval_label' => 'Repite cada',
+ 'event_calendar:day_abbrev:monday' => 'L',
+ 'event_calendar:day_abbrev:tuesday' => 'M',
+ 'event_calendar:day_abbrev:wednesday' => 'M',
+ 'event_calendar:day_abbrev:thursday' => 'J',
+ 'event_calendar:day_abbrev:friday' => 'V',
+ 'event_calendar:day_abbrev:saturday' => 'S',
+ 'event_calendar:day_abbrev:sunday' => 'D',
+ 'event_calendar:dow:full:monday' => 'Lunes',
+ 'event_calendar:dow:full:tuesday' => 'Martes',
+ 'event_calendar:dow:full:wednesday' => 'Miércoles',
+ 'event_calendar:dow:full:thursday' => 'Jueves',
+ 'event_calendar:dow:full:friday' => 'Viernes',
+ 'event_calendar:dow:full:saturday' => 'Sabado',
+ 'event_calendar:dow:full:sunday' => 'Domingo',
+ 'event_calendar:schedule_type:fixed' => 'Selecciona dia/hora',
+ 'event_calendar:interval:minute' => 'minuto(s)',
+ 'event_calendar:interval:hour' => 'hora(s)',
+ 'event_calendar:interval:day' => 'día(s)',
+ 'event_calendar:site_calendar' => 'Calendario del sitio',
+ 'event_calendar:calendar_label' => 'Calendario',
+ 'event_calendar:basic:header' => 'Información básica',
+ 'event_calendar:schedule:header' => 'Fecha',
+ 'event_calendar:permissions:header' => 'Permisos',
+ 'event_calendar:read_access' => 'Acceso de lectura',
+ 'event_calendar:add_event' => 'Añadir evento',
+ 'event_calendar:schedule_event' => 'Evento agendado',
+ 'item:object:event_calendar' => 'Calendario',
+ 'event_calendar:new_event' => 'Nuevo evento',
+ 'event_calendar:no_such_event_edit_error' => 'Error: No existe tal evento o usted no tiene autorización para editarlo.',
+ 'event_calendar:add_event_title' => 'Agregar evento',
+ 'event_calendar:manage_event_title' => 'Editar evento',
+ 'event_calendar:manage_event_description' => 'Introduzca los detalles de su evento a continuación. El título, lugar y fecha de inicio se requieren. Puede hacer clic en los íconos del calendario para establecer las fechas de inicio y fin.',
+ 'event_calendar:title_label' => 'Título',
+ 'event_calendar:title_description' => 'Una a cuatro palabras',
+ 'event_calendar:brief_description_label' => 'Descripción breve',
+ 'event_calendar:brief_description_description' => 'Una frase corta.',
+ 'event_calendar:venue_label' => 'Lugar',
+ 'event_calendar:venue_description' => '¿Dónde se llevará a cabo este evento?',
+ 'event_calendar:start_date_label' => 'Fecha de inicio',
+ 'event_calendar:start_date_description' => '¿Cuándo comenzará este evento?',
+ 'event_calendar:end_date_label' => 'Fecha final',
+ 'event_calendar:end_date_description' => '¿Cuándo terminará este evento? La fecha de inicio será usada como la fecha de finalización si no se suministra esta información.',
+ 'event_calendar:start_time_label' => 'Hora de inicio',
+ 'event_calendar:start_time_description' => '¿A qué hora comenzará este evento?',
+ 'event_calendar:end_time_label' => 'Hora de finalización',
+ 'event_calendar:end_time_description' => '¿A qué hora terminará este evento?',
+ 'event_calendar:fees_label' => 'Tarifas',
+ 'event_calendar:fees_description' => 'El costo de este evento, si hay caso.',
+ 'event_calendar:contact_label' => 'Contacto',
+ 'event_calendar:contact_description' => 'Persona que será el contacto para brindar mayor información, preferiblemente con número de teléfono o dirección de correo electrónico.',
+ 'event_calendar:organiser_label' => 'Origanizador',
+ 'event_calendar:organiser_description' => 'La persona u organización responsable por este evento.',
+ 'event_calendar:event_tags_label' => 'Etiquetas',
+ 'event_calendar:event_tags_description' => 'Lista de etiquetas relativas al eventos, separadas por una coma.',
+ 'event_calendar:long_description_label' => 'Descripción larga',
+ 'event_calendar:long_description_description' => 'Puede ser un parágrafo o más, según lo requerido.',
+ 'event_calendar:manage_event_response' => 'Su evento ha sido guardado.',
+ 'event_calendar:add_event_response' => 'Su evento ha sido agregado.',
+ 'event_calendar:manage_event_error' => 'Error: Hubo un error al guardar su evento. Por favor asegúrese que todos los campos requeridos hayan sido proporcionados.',
+ 'event_calendar:error_nosuchevent' => 'Error: no existe tal evento.',
+ 'event_calendar:show_events_title' => 'Calendario',
+ 'event_calendar:day_label' => 'Día',
+ 'event_calendar:week_label' => 'Semana',
+ 'event_calendar:month_label' => 'Mes',
+ 'event_calendar:group' => 'Calendario de grupo',
+ 'event_calendar:new' => 'Agregar evento',
+ 'event_calendar:submit' => 'Enviar',
+ 'event_calendar:cancel' => 'Cancelar',
+ 'event_calendar:widget_title' => 'Calendario',
+ 'event_calendar:widget:description' => 'Exponer sus eventos.',
+ 'event_calendar:num_display' => 'Número de eventos expuestos',
+ 'event_calendar:groupprofile' => 'Eventos venideros',
+ 'event_calendar:view_calendar' => 'ver calendario',
+ 'event_calendar:when_label' => 'Cuando',
+ 'event_calendar:site_wide_link' => 'Ver todos los eventos',
+ 'event_calendar:view_link' => 'Ver este evento',
+ 'event_calendar:edit_link' => 'Editar este evento',
+ 'event_calendar:delete_link' => 'Eliminar este evento',
+ 'event_calendar:delete_response' => 'Este evento ha sido eliminado.',
+ 'event_calendar:error_delete' => 'Este evento no existe o usted no tiene el derecho de eliminarlo.',
+ 'event_calendar:delete_cancel_response' => 'Eliminación del evento cancelada.',
+ 'event_calendar:add_to_my_calendar' => 'Agregar a mi calendario',
+ 'event_calendar:remove_from_my_calendar' => 'Retirar de mi calendario',
+ 'event_calendar:add_to_my_calendar_response' => 'Este evento ha sido agregado a su calendario personal.',
+ 'event_calendar:remove_from_my_calendar_response' => 'Este evento ha sido retirado de su calendario personal.',
+ 'event_calendar:users_for_event_title' => 'Personas interesadas en el evento "%s"',
+ 'event_calendar:personal_event_calendars_link' => 'Eventos personales del calendario (%s)',
+ 'event_calendar:settings:group_profile_display:title' => 'Perfil de visualización del calendario de grupo (si están habilitados los calendarios de grupo)',
+ 'event_calendar:settings:group_profile_display_option:left' => 'Columna de la izquierda',
+ 'event_calendar:settings:group_profile_display_option:right' => 'Columna de la derecha',
+ 'event_calendar:settings:group_profile_display_option:none' => 'Ninguno',
+ 'event_calendar:settings:times:title' => 'Agregar hora y fecha a los eventos',
+ 'event_calendar:settings:autopersonal:title' => 'Agregar automáticamente a su calendario personal eventos que un usuario cree.',
+ 'event_calendar:settings:autogroup:title' => 'Agregar automáticamente los eventos de grupo al calendario personal de sus miembros.',
+ 'event_calendar:settings:agenda_view:title' => 'Usar Vista previa de Agenda',
+ 'event_calendar:settings:venue_view:title' => 'Mostrar sede en vista rápida (listados de eventos)',
+ 'event_calendar:settings:yes' => 'sí',
+ 'event_calendar:settings:no' => 'no',
+ 'event_calendar:settings:site_calendar:title' => 'Calendario del sitio',
+ 'event_calendar:settings:site_calendar:admin' => 'sí, solamente si administradores pueden anunciar eventos',
+ 'event_calendar:settings:site_calendar:loggedin' => 'sí, cualquier usuario registrado puede anunciar un evento',
+ 'event_calendar:settings:group_calendar:title' => 'Calendarios de grupo',
+ 'event_calendar:settings:group_calendar:admin' => 'sí, solamente administradores y propietarios de grupos pueden anunciar eventos',
+ 'event_calendar:settings:group_calendar:members' => 'sí, cualquier miembro de un grupo puede anunciar un evento',
+ 'event_calendar:settings:group_default:title' => 'Grupos nuevos deben tener un calendario de grupo por defecto (si los calendarios de grupo están activados)',
+ 'event_calendar:settings:group_default:no' => 'no (sin embargo administradores y propietarios de grupos pueden desactivar un calendario de grupo si lo desean)',
+ 'event_calendar:settings:group_default:yes' => 'sí (sin embargo administradores y propietarios de grupos pueden desactivar un calendario de grupo si lo desean)',
+ 'event_calendar:settings:group_always_display:title' => 'Si un calendario de grupo está activo, siempre exponerlo (aun si está vacío)',
+ 'event_calendar:settings:region_display:title' => 'Agregar campo región a eventos',
+ 'event_calendar:settings:region_list:title' => 'Lista de regiones (una por línea)',
+ 'event_calendar:region_label' => 'Región',
+ 'event_calendar:region_description' => 'Selecciona la región en la cual el evento se llevará a cabo',
+ 'event_calendar:settings:type_display:title' => 'Agregar tipo de eventos a eventos',
+ 'event_calendar:settings:type_list:title' => 'Lista de tipos de eventos (uno por línea)',
+ 'event_calendar:type_label' => 'Tipo de eventos',
+ 'event_calendar:type_description' => 'Seleccione un tipo de evento.',
+ 'event_calendar:all' => 'Todos',
+ 'event_calendar:region_filter_by_label' => 'Filtro por región:',
+ 'event_calendar:settings:first_date:title' => 'Primera fecha permitida (en el formato AAAA - MM- DD)',
+ 'event_calendar:settings:last_date:title' => 'Última fecha permitida (en el formato AAAA - MM- DD)',
+ 'event_calendar:enable_event_calendar' => 'Permitir clanedario de eventos de grupo',
+ 'event_calendar:no_events_found' => 'No se encontraron eventos.',
+ 'event_calendar:mine' => 'Mío',
+ 'event_calendar:feature' => 'Presentar',
+ 'event_calendar:unfeature' => 'No presentar',
+ 'event_calendar:agenda:column:time' => 'Hora',
+ 'event_calendar:agenda:column:session' => 'Sesión',
+ 'event_calendar:agenda:column:venue' => 'Lugar',
+ 'event_calendar:upcoming_events_title' => 'Eventor venideros',
+ 'event_calendar:settings:paged' => 'Paginado',
+ 'event_calendar:settings:month' => 'Por mes',
+ 'event_calendar:settings:listing_format:title' => 'Formato del listado de eventos',
+ 'event_calendar:paged:column:date' => 'Fecha',
+ 'event_calendar:paged:column:time' => 'Hora',
+ 'event_calendar:paged:column:event' => 'Evento',
+ 'event_calendar:paged:column:venue' => 'Lugar',
+ 'event_calendar:paged:column:calendar' => 'Calendario',
+ 'event_calendar:river:created' => '%s agregado',
+ 'event_calendar:river:updated' => '%s actualizado',
+ 'event_calendar:river:annotated1' => '%s agregado',
+ 'event_calendar:river:annotated2' => 'a su calendario personal.',
+ 'event_calendar:river:create' => 'un nuevo evento titulado',
+ 'event_calendar:river:the_event' => 'un evento titulado',
+);
+add_translation("es", $language);
diff --git a/mod/event_calendar/languages/fr.php b/mod/event_calendar/languages/fr.php
new file mode 100644
index 000000000..6e2624691
--- /dev/null
+++ b/mod/event_calendar/languages/fr.php
@@ -0,0 +1,124 @@
+<?php
+$language = array (
+ 'event_calendar:manage_event_description' => 'Entrez les détails de votre événement ci-dessous. Le titre, le lieu et la date de début sont obligatoires. Vous pouvez cliquer sur les icônes du calendrier pour indiquer les dates de début et de fin.',
+ 'event_calendar:start_time_label' => 'Horaire de départ',
+ 'event_calendar:start_time_description' => 'À quelle heure cet événement commence?',
+ 'event_calendar:end_time_label' => 'Horaire de fin',
+ 'event_calendar:end_time_description' => 'À quelle heure se termine cet événement?',
+ 'event_calendar:event_tags_label' => 'Balises',
+ 'event_calendar:event_tags_description' => 'Optionnel. Une liste de balises séparées par des virgules.',
+ 'event_calendar:error_nosuchevent' => 'Erreur: il n\'y a pas de tel événement.',
+ 'event_calendar:settings:times:title' => 'Ajouter du temps et la date aux événements',
+ 'event_calendar:settings:autogroup:title' => 'Ajouter automatiquement des événements de groupe à tous les membres dans leurs agendas personnels.',
+ 'event_calendar:settings:agenda_view:title' => 'Utilisez la vue Agenda',
+ 'event_calendar:settings:venue_view:title' => 'Afficher le lieu en vue sommaire (listings des événements)',
+ 'event_calendar:settings:group_always_display:title' => 'Si un calendrier de groupe est activé, toujours l\'afficher (même vides)',
+ 'event_calendar:settings:region_display:title' => 'Ajouter un champ région aux événements',
+ 'event_calendar:settings:region_list:title' => 'Liste des rListe des régions (un par ligne)
+ (une seule par ligne)',
+ 'event_calendar:region_label' => 'Régions',
+ 'event_calendar:region_description' => 'Sélectionnez la région dans laquelle cet événement aura lieu',
+ 'event_calendar:settings:type_display:title' => 'Ajouter le type d\'événement aux événements',
+ 'event_calendar:settings:type_list:title' => 'Liste des types d\'événement (un seul par ligne)',
+ 'event_calendar:type_label' => 'Type d\'événement',
+ 'event_calendar:type_description' => 'Sélectionnez le type d\'événement.',
+ 'event_calendar:all' => 'Tous',
+ 'event_calendar:region_filter_by_label' => 'Filtrer par région:',
+ 'event_calendar:settings:first_date:title' => 'Première date d\'entrée admissible (au format AAAA-MM-JJ)',
+ 'event_calendar:settings:last_date:title' => 'Dernière date admissible (au format AAAA-MM-JJ)',
+ 'event_calendar:mine' => 'Le mien',
+ 'event_calendar:feature' => 'Mise en vedette',
+ 'event_calendar:unfeature' => 'Enlever la mise en vedette',
+ 'event_calendar:agenda:column:time' => 'Heure',
+ 'event_calendar:agenda:column:session' => 'Session',
+ 'event_calendar:agenda:column:venue' => 'Lieu',
+ 'event_calendar:upcoming_events_title' => 'Événements à venir',
+ 'event_calendar:settings:paged' => 'Pagé',
+ 'event_calendar:settings:month' => 'par mois',
+ 'event_calendar:settings:listing_format:title' => 'Format des listes d\'événements',
+ 'event_calendar:paged:column:date' => 'Date',
+ 'event_calendar:paged:column:time' => 'Heure',
+ 'event_calendar:paged:column:event' => 'Evénement',
+ 'event_calendar:paged:column:venue' => 'Lieu',
+ 'event_calendar:paged:column:calendar' => 'Calendrier',
+ 'item:object:event_calendar' => 'Agenda',
+ 'event_calendar:new_event' => 'Nouvel événement',
+ 'event_calendar:no_such_event_edit_error' => 'Erreur: Il n\'y a pas de tel événement, ou vous n\'avez pas la permission de le modifier.',
+ 'event_calendar:add_event_title' => 'Ajouter un événement',
+ 'event_calendar:manage_event_title' => 'Modifier un événement',
+ 'event_calendar:title_label' => 'Titre',
+ 'event_calendar:title_description' => 'Obligatoire. Un à quatre mots',
+ 'event_calendar:brief_description_label' => 'Courte description',
+ 'event_calendar:brief_description_description' => 'Optionnel. Une phrase courte.',
+ 'event_calendar:venue_label' => 'Lieu',
+ 'event_calendar:venue_description' => 'Obligatoire. Où se tiendra l\'événement?',
+ 'event_calendar:start_date_label' => 'Date de départ',
+ 'event_calendar:start_date_description' => 'Obligatoire. A quelle date cet événement démarera?',
+ 'event_calendar:end_date_label' => 'Date de fin de l\'événement',
+ 'event_calendar:end_date_description' => 'Optionnel. Quand c\'est événement s\'achèvera-t-il? La date de départ sera utilisée comme date de fin si ce champ n\'est pas rempli.',
+ 'event_calendar:fees_label' => 'Prix d\'entrée',
+ 'event_calendar:fees_description' => 'Optionnel. Le côut de l\'événement.',
+ 'event_calendar:contact_label' => 'Contact',
+ 'event_calendar:contact_description' => 'Optionnel. La personne à contacter pour avoir plus de renseignements, préférablement avec un numéro de téléphone ou une adresse emailpreferably with a telephone number or email address.',
+ 'event_calendar:organiser_label' => 'Organisateur',
+ 'event_calendar:organiser_description' => 'Optionnel. La personne ou l\'organisation responsable de l\'événement.',
+ 'event_calendar:long_description_label' => 'Description longue',
+ 'event_calendar:long_description_description' => 'Optionnel. Peut être un paragraphe ou plus si nécessaire.',
+ 'event_calendar:manage_event_response' => 'Votre événement a été sauvegardé.',
+ 'event_calendar:add_event_response' => 'Votre événement a été ajouté.',
+ 'event_calendar:manage_event_error' => 'Erreur: Une erreur s\'est produite lors de l\'enregistrement de votre événement. Assurez-vous que les champs spécifiés ont bien été remplis.',
+ 'event_calendar:show_events_title' => 'Agenda des événements',
+ 'event_calendar:day_label' => 'Jour',
+ 'event_calendar:week_label' => 'Semaine',
+ 'event_calendar:month_label' => 'Mois',
+ 'event_calendar:group' => 'Agenda de groupe',
+ 'event_calendar:new' => 'Ajouter un événement',
+ 'event_calendar:submit' => 'Ok',
+ 'event_calendar:cancel' => 'Annuler',
+ 'event_calendar:widget_title' => 'Agenda des événements',
+ 'event_calendar:widget:description' => 'Afficher vos événements.',
+ 'event_calendar:num_display' => 'Nombre d\'événement à afficher',
+ 'event_calendar:groupprofile' => 'Les prochains événements',
+ 'event_calendar:view_calendar' => 'Voir l\'agenda',
+ 'event_calendar:when_label' => 'Quand',
+ 'event_calendar:site_wide_link' => 'Voir tous les événements',
+ 'event_calendar:view_link' => 'Voir cet événement',
+ 'event_calendar:edit_link' => 'Modifier cet événement',
+ 'event_calendar:delete_link' => 'Supprimer cet événement',
+ 'event_calendar:delete_confirm_title' => 'Confirmer la suppression de l\'événement',
+ 'event_calendar:delete_confirm_description' => 'Etes-vous sur de vouloir supprimer cet événement ("%s")? Cette action est irréversible.',
+ 'event_calendar:delete_response' => 'Cet événement a été supprimé.',
+ 'event_calendar:error_delete' => 'Cet événement n\'existe pas ou vous n\'avez pas le droit de le supprimer.',
+ 'event_calendar:delete_cancel_response' => 'Suppression de l\'événement annulé.',
+ 'event_calendar:add_to_my_calendar' => 'Ajouter à mon agenda',
+ 'event_calendar:remove_from_my_calendar' => 'Supprimer de mon agenda',
+ 'event_calendar:add_to_my_calendar_response' => 'Cet événement a été ajouté à votre agenda personnel.',
+ 'event_calendar:remove_from_my_calendar_response' => 'Cet événement a été supprimé de votre agenda personnel.',
+ 'event_calendar:users_for_event_title' => 'Membre du site intéressé par l\'événement "%s"\'',
+ 'event_calendar:personal_event_calendars_link' => 'Agenda des événements personnels de (%s)',
+ 'event_calendar:settings:group_profile_display:title' => 'Afficher le profil de l\'agenda du groupe (Si les agendas de groupe ont été permis)',
+ 'event_calendar:settings:group_profile_display_option:left' => 'Colonne de gauche',
+ 'event_calendar:settings:group_profile_display_option:right' => 'Colonne de droite',
+ 'event_calendar:settings:group_profile_display_option:none' => 'aucun',
+ 'event_calendar:settings:autopersonal:title' => 'Ajouter automatiquement les événements d\'un utilisateur à son agenda personnelA.',
+ 'event_calendar:settings:yes' => 'oui',
+ 'event_calendar:settings:no' => 'non',
+ 'event_calendar:settings:site_calendar:title' => 'Side de l\'agenda',
+ 'event_calendar:settings:site_calendar:admin' => 'oui, seuls les administrateurs peuvent proposer des événements',
+ 'event_calendar:settings:site_calendar:loggedin' => 'oui, seuls les utilisateurs identifiés peuvent publier un événement',
+ 'event_calendar:settings:group_calendar:title' => 'Les agendas du groupe',
+ 'event_calendar:settings:group_calendar:admin' => 'oui seuls les administrateurs et les créateurs du groupe peuvent publier un événement',
+ 'event_calendar:settings:group_calendar:members' => 'oui, les membres du groupe peuvent publier un événement',
+ 'event_calendar:settings:group_default:title' => 'Les nouveaux groupes par défaut peuvent avoir leur propre agenda (Si les agendas de groupe sont permis)',
+ 'event_calendar:settings:group_default:no' => 'non (mais les administrateurs du groupe peuvement ajouter la fonction agenda si désiré)',
+ 'event_calendar:settings:group_default:yes' => 'oui (mais les administrateurs ou les créateurs du groupe peuvent supprimer la fonction agenda si désiré)',
+ 'event_calendar:enable_event_calendar' => 'Ajouter la fonction agenda au groupe',
+ 'event_calendar:no_events_found' => 'Aucun événement trouvé.',
+ 'event_calendar:river:created' => '%s ajouté',
+ 'event_calendar:river:updated' => '%s mis à jour',
+ 'event_calendar:river:annotated1' => '%s ajouté',
+ 'event_calendar:river:annotated2' => 'à son agenda personnel.',
+ 'event_calendar:river:create' => 'un nouvel événement intitulé',
+ 'event_calendar:river:the_event' => 'un événement intitulé',
+);
+add_translation("fr", $language);
diff --git a/mod/event_calendar/languages/ru.php b/mod/event_calendar/languages/ru.php
new file mode 100644
index 000000000..980c014f3
--- /dev/null
+++ b/mod/event_calendar/languages/ru.php
@@ -0,0 +1,365 @@
+<?php
+
+ $russian = array(
+
+ 'item:object:event_calendar' => "Календарь",
+ 'tag_names:event_tags' => "Теги",
+ 'event_calendar:optional' => "Опционально.",
+ 'event_calendar:required' => "Обязательно.",
+ 'event_calendar:new_event' => "Новое событие",
+ 'event_calendar:no_such_event_edit_error' => "Ошибка: Нет такого события или у вас нет прав на его редактирование.",
+ 'event_calendar:add_event_title' => "Добавить событие",
+ 'event_calendar:manage_event_title' => "Изменить событие",
+ 'event_calendar:manage_event_description' => "Введите детали вашего события. "
+ ."Название, место и дата начала обязательны. "
+ ."Вы можете нажать на иконки календаря, чтобы установить начальную и конечную даты.",
+ 'event_calendar:title_label' => "Название",
+ 'event_calendar:title_description' => "От одного до четырех слов",
+ 'event_calendar:brief_description_label' => "Краткое описание",
+ 'event_calendar:brief_description_description' => "Короткая фраза.",
+ 'event_calendar:venue_label' => "Место",
+ 'event_calendar:venue_description' => "Где это событие будет проходить?",
+ 'event_calendar:start_date_label' => "Дата начала",
+ 'event_calendar:start_date_description' => "Когда это событие начнется?",
+ 'event_calendar:end_date_label' => "Дата окончания",
+ 'event_calendar:end_date_description' => "Когда событие закончится? Будет использована дата начала "
+ ."если не будет указано явно.",
+ 'event_calendar:start_time_label' => "Время начала",
+ 'event_calendar:start_time_description' => "В какое время событие начинается?",
+ 'event_calendar:end_time_label' => "Время окончания",
+ 'event_calendar:end_time_description' => "В какое время событие закончится?",
+ 'event_calendar:fees_label' => "Стоимость",
+ 'event_calendar:fees_description' => "Стоимость мероприятия, если есть.",
+ 'event_calendar:contact_label' => "Контакт",
+ 'event_calendar:contact_description' => "Лицо с которым можно связаться для уточнения информации, "
+ ."желательно с номером телефона или email адресом.",
+ 'event_calendar:organiser_label' => "Организатор",
+ 'event_calendar:organiser_description' => "Лицо или организация, отвечающая за событие.",
+ 'event_calendar:event_tags_label' => "Теги",
+ 'event_calendar:event_tags_description' => "Список тегов, относящихся к этому событию, разделенный запятыми.",
+ 'event_calendar:long_description_label' => "Детальное описание",
+ 'event_calendar:long_description_description' => "Может быть параграф или больше, сколько потребуется.",
+ 'event_calendar:manage_event_response' => "Ваше событие сохранено.",
+ 'event_calendar:add_event_response' => "Ваше событие добавлено.",
+ 'event_calendar:manage_event_error' => "Ошибка: При сохранении возникла ошибка. "
+ ."Пожалуйста, удостоверьтесь, что вы указали все обязательные поля.",
+ 'event_calendar:error_nosuchevent' => "Ошибка: нет такого события.",
+ 'event_calendar:show_events_title' => "Календарь",
+ 'event_calendar:day_label' => "День",
+ 'event_calendar:week_label' => "Неделя",
+ 'event_calendar:month_label' => "Месяц",
+ 'event_calendar:group' => "Календарь группы",
+ 'event_calendar:new' => "Добавить событие",
+ 'event_calendar:submit' => "Отправить",
+ 'event_calendar:cancel' => "Отменить",
+ 'event_calendar:widget_title' => "Календарь",
+ 'event_calendar:widget:description' => "Отображает ваши события.",
+ 'event_calendar:num_display' => "Количество событий",
+ 'event_calendar:events_type' => "Показывать",
+ 'event_calendar:personal_events' => "Персональные",
+ 'event_calendar:all_events' => "Все активные",
+ 'event_calendar:groupprofile' => "Предстоящие события",
+ 'event_calendar:view_calendar' => "просмотр календаря",
+ 'event_calendar:when_label' => "Когда",
+ 'event_calendar:site_wide_link' => "Просмотреть все события",
+ 'event_calendar:view_link' => "Просмотреть событие",
+ 'event_calendar:edit_link' => "Изменить событие",
+ 'event_calendar:delete_link' => "Удалить событие",
+ 'event_calendar:delete_response' => "Событие было удалено.",
+ 'event_calendar:error_delete' => "Такого события не существует или у вас нет прав на его удаление.",
+ 'event_calendar:delete_cancel_response' => "Удаление события отменено.",
+ 'event_calendar:add_to_my_calendar' => "Добавить в мой календарь",
+ 'event_calendar:remove_from_my_calendar' => "Убрать мз моего календаря",
+ 'event_calendar:add_to_my_calendar_response' => "Событие было добавлено в Ваш личный календарь.",
+ 'event_calendar:add_to_my_calendar_error' => "Событие не может быть добавлено в Ваш персональный каледарь. "
+ ."(Возможно событие уже заполнено или совпадает по времени с другим событием в Вашем персональном календаре?)",
+ 'event_calendar:remove_from_my_calendar_response' => "Событие было удалено из Вашего персонального календаря.",
+ 'event_calendar:add_to_the_calendar' => "Добавить в календарь",
+ 'event_calendar:remove_from_the_calendar' => "Убрать",
+ 'event_calendar:add_to_the_calendar_menu_text' => "Добавить в мой",
+ 'event_calendar:remove_from_the_calendar_menu_text' => "Убрать из моего",
+ 'event_calendar:remove_from_the_calendar_button' => "Убрать из календаря",
+ 'event_calendar:added_to_the_calendar' => "Добавлено в календарь",
+ 'event_calendar:removed_from_the_calendar' => "Удалено из календаря",
+ 'event_calendar:add_to_the_calendar_response' => "Событие добавлено в календарь.",
+ 'event_calendar:add_to_the_calendar_error' => "Это событие не может быть добавлено в календарь этой персоны. "
+ ."(Возможно, событие уже заполнено или запланировано на время, совпадающее со временем другого события в календаре этой персоны)",
+ 'event_calendar:remove_from_the_calendar_response' => "Событие удалено из календаря этой персоны.",
+
+ 'event_calendar:users_for_event_menu_title' => "Люди, регистрирующие это событие в своих календарях",
+ 'event_calendar:users_for_event_title' => "Персональные календари \"%s'\"",
+ 'event_calendar:personal_event_calendars_link' => "В %s календарях",
+ 'event_calendar:personal_event_calendars_link_one' => "В 1 календаре",
+ 'event_calendar:users_for_event_breadcrumb' => "Персональные календари",
+ 'event_calendar:settings:group_profile_display:title' => "Окно профиля календарей группы (если календари группы разрешены)",
+ 'event_calendar:settings:group_profile_display_option:left' => "левая колонка",
+ 'event_calendar:settings:group_profile_display_option:right' => "правая колонка",
+ 'event_calendar:settings:group_profile_display_option:none' => "никакая",
+ 'event_calendar:settings:times:title' => "Добавить время и дату к событиям",
+ 'event_calendar:settings:autopersonal:title' => "Автоматически добавлять события, которые пользователь создает в своем календаре.",
+ 'event_calendar:settings:autogroup:title' => "Автоматически добавлять групповые события в персональные календари всех членов группы.",
+ 'event_calendar:settings:agenda_view:title' => "Использовать вид План",
+ 'event_calendar:settings:venue_view:title' => "Показывать место проведения в итоговом виде (списки событий)",
+ 'event_calendar:settings:yes' => "да",
+ 'event_calendar:settings:no' => "нет",
+ 'event_calendar:settings:site_calendar:title' => "Календарь сайта",
+ 'event_calendar:settings:site_calendar:admin' => "да, только администраторы могут отправлять события",
+ 'event_calendar:settings:site_calendar:loggedin' => "да, только вошедшие пользователи могут отправлять события",
+ 'event_calendar:settings:group_calendar:title' => "Календари группы",
+ 'event_calendar:settings:group_calendar:admin' => "да, только администраторы и владельцы групп могут отправлять события",
+ 'event_calendar:settings:group_calendar:members' => "да, только члены групп могут отправлять события",
+ 'event_calendar:settings:group_default:title' => "По умолчанию новые группы должны иметь календарь группы (если календари группы разрешены)",
+ 'event_calendar:settings:group_default:no' => "нет (но администраторы или владельцы групп могут разрешить календари группы)",
+ 'event_calendar:settings:group_default:yes' => "да (но администраторы или владельцы групп могут запретить календари группы)",
+ 'event_calendar:settings:group_always_display:title' => "Всегда показывать календарь группы, если календари группы разрешены (даже если он пустой)",
+ 'event_calendar:settings:region_display:title' => "Добавить поле Регион в события",
+ 'event_calendar:settings:region_list:title' => "Список регионов (один на строку)",
+ 'event_calendar:region_label' => "Регион",
+ 'event_calendar:region_description' => "Выбрать регион, где будет проводиться событие.",
+ 'event_calendar:settings:type_display:title' => "Добавить тип события",
+ 'event_calendar:settings:type_list:title' => "Список типов событий (один на строку)",
+ 'event_calendar:type_label' => "Тип события",
+ 'event_calendar:type_description' => "Выбрать тип события.",
+ 'event_calendar:all' => "Все",
+ 'event_calendar:region_filter_by_label' => "Фильтровать по региону: ",
+ 'event_calendar:settings:first_date:title' => "Первая разрешенная дата (в формате ГГГГ-ММ-ДД)",
+ 'event_calendar:settings:last_date:title' => "Последняя разрешенная дата (в формате ГГГГ-ММ-ДД)",
+ 'event_calendar:enable_event_calendar' => "Включить календарь группы",
+ 'event_calendar:no_events_found' => "Не найдено ни одного события.",
+ 'event_calendar:mine' => "Мои",
+ 'event_calendar:feature' => "Свойства",
+ 'event_calendar:unfeature' => "Unfeature",
+ 'event_calendar:agenda:column:time' => "Время",
+ 'event_calendar:agenda:column:session' => "Сессия",
+ 'event_calendar:agenda:column:venue' => "Место",
+ 'event_calendar:upcoming_events_title' => "Предстоящие события",
+ 'event_calendar:settings:paged' => "постранично",
+ 'event_calendar:settings:agenda' => "план",
+ 'event_calendar:settings:month' => "по месяцам",
+ 'event_calendar:settings:full' => "полный вид",
+ 'event_calendar:settings:listing_format:title' => "Формат списка событий",
+ 'event_calendar:paged:column:date' => "Дата",
+ 'event_calendar:paged:column:time' => "Время",
+ 'event_calendar:paged:column:event' => "Событие",
+ 'event_calendar:paged:column:venue' => "Место",
+ 'event_calendar:paged:column:calendar' => "Календарь",
+ 'event_calendar:settings:spots_display:title' => "Добавить поле Количество к каждому "
+ ."чтобы ограничить количество людей, которые могут добавить событие к себе в календари",
+ 'event_calendar:settings:no_collisions:title' => "Определение конфликтов: запретить людям добавлять в календари два события с пересекающимися временами",
+ 'event_calendar:settings:collision_length:title' => "Какую длительность (в секундах) выставлять событию, если не установлена его конечная дата или время "
+ ."(используется для определения конфликтов). По умолчанию 3600 секунд = 1 час.",
+ 'event_calendar:spots_label' => "Количество",
+ 'event_calendar:spots_description' => "Скольким людям разрешено добавить это событие в свои персональные календари?",
+ 'event_calendar:open' => "Открыт",
+ 'event_calendar:settings:add_users:title' => "Разрешить создателям события и администраторам сайта добавлять свои события в другие персональные календари.",
+ 'event_calendar:add_user_label' => "Добавить пользователей",
+ 'event_calendar:add_user_description' => "Добавить это событие в персональные календари, выбирая пользователя в поле с автозаполнением выше. "
+ ."Вы можете добавить нескольких пользователей, нажимая на ссылку \"+\". (Вы должны отправить эту форму, чтобы добавить событие в календари.)",
+ 'event_calendar:settings:add_users_notify:title' => "Уведомить по электронной почте тех пользователей, которым администраторы сайта или создатель события добавили событие в персональный календарь.",
+ 'event_calendar:add_users_notify:subject' => "В ваш персональный календарь добавлено новое событие",
+ 'event_calendar:add_users_notify:body' => "%s,\n\nСобытие \"%s\" было добавлено в ваш календарь.\n\nВы можете посмотреть его здесь: \n\n%s\n",
+
+ 'event_calendar:settings:region_list_handles:title' => "Строки регионов выше - это строковые десктипторы. Используйте систему переводов Elgg для их разрешения.",
+ 'event_calendar:settings:type_list_handles:title' => "Строки типов выше - это строковые десктипторы. Используйте систему переводов Elgg для их разрешения.",
+
+ 'event_calendar:settings:personal_manage:title' => "Допуски календаря",
+ 'event_calendar:settings:personal_manage:description' => "Определяет, могут ли пользователи добавлять события в свои персональные календари (открытое), "
+ ."необходим запрос создателю события, чтобы сделать это (закрытое), невозможно вообще (частное), или позволить создателю события определять это для каждого события (по событию). "
+ ."Примечание. Если вы устанавливаете это в Частное, то, возможно, следует активировать опцию, позволяющую создателю события или администраторам сайта "
+ ."добавлять свои события в персональные календари других пользователей.",
+ 'event_calendar:strapline' => "Опубликовал(а) %s %s",
+
+ 'event_calendar:request_event_response' => "Ваш запрос на добавление к этому событию был отправлен.",
+ 'event_calendar:request_event_error' => "Ошибка: ваш запрос на добавление к этому событию не может быть отправлен.",
+ 'event_calendar:request_subject' => "Вы получили запрос по событию",
+ 'event_calendar:request_message' => "%s просит разрешить добавить событие \"%s\", здесь:
+
+%s
+
+в свой персональный календарь.
+
+Вы можете управлять календарными запросами на это событие тут:
+
+%s
+",
+
+ 'event_calendar:review_requests_error' => "Либо это событие не существует, либо у вас нет полномочий подтверждать запрос на него.",
+ 'event_calendar:review_requests_request_none' => "Для этого события нет запросов на обзор.",
+ 'event_calendar:request:remove:check' => 'Вы уверены, что хотите отклонить этот запрос?',
+ 'event_calendar:requestkilled' => 'Этот запрос был отклонен.',
+ 'event_calendar:request_approved' => "Этот запрос был подтвержден.",
+ 'event_calendar:review_requests_title' => "Обзор запросов на \"%s\"",
+ 'event_calendar:review_requests_menu_title' => "Обзор запросов",
+ 'event_calendar:make_request_title' => 'Запросить это событие',
+ 'event_calendar:review_requests:reject' => "Отклонить",
+ 'event_calendar:review_requests:reject:title' => "Отклонить этот запрос",
+ 'event_calendar:review_requests:accept' => "Принять",
+ 'event_calendar:review_requests:accept:title' => "Принять этот запрос",
+ 'event_calendar:review_requests:error:approve' => "Ошибка: не могу подтвердить этот запрос.",
+ 'event_calendar:review_requests:error:reject' => "Ошибка: не могу отклонить этот запрос.",
+
+ 'event_calendar:settings:hide_access:title' => "Скрыть выпадающий элемент с доступом к событию",
+ 'event_calendar:settings:default_access:title' => "Какое должно быть значение по умолчанию, если доступ к событию скрыт?",
+ 'event_calendar:settings:hide_end:title' => "Скрыть поля даты и времени окончания",
+ 'event_calendar:settings:more_required:title' => "Сделать обязательными все видимые поля, кроме долгих описаний.",
+
+ 'event_calendar:add_to_group:remove_group_title' => "Удалить это событие из группы",
+ 'event_calendar:add_to_group:remove_group_button' => "Удалить из группы",
+ 'event_calendar:remove_from_group:success' => "Событие удалено из календаря группы",
+ 'event_calendar:add_to_group:add_group_title' => "Добавить это событие в группу",
+ 'event_calendar:add_to_group:add_group_button' => "Добавить в группу",
+ 'event_calendar:add_to_group:success' => "Событие добавлено в календарь группы",
+ 'event_calendar:settings:add_to_group_calendar:title' => "Разрешить администраторам группы добавлять любое существующее событие в календарь группы",
+
+ 'event_calendar:group_breadcrumb' => "Календарь группы",
+ 'event_calendar:no_group' => "Такой группы не существует.",
+ 'event_calendar:generic_error_title' => "Ошибка",
+ 'event_calendar:error_event_edit' => "Ошибка: либо такого события не существует, либо у вас нет разрешения ее редактировать.",
+ 'event_calendar:add' => "Добавить",
+
+ 'feed:ical' => "Лента iCal для этой страницы",
+ 'event_calendar:ical_popup_message' => "Вы можете использовать следующую ссылку, чтобы получить ленту iCalendar на все общие события из следующего списка: ",
+ 'event_calendar:ical_auth_file_name:title' => "Путь к файлу идентификации iCal в локальной файловой системе (экспериментально - не нужна для общих лент)",
+
+ 'event_calendar:owner:permissions_error' => "У вас нет разрешения для просмотра этой страницы.",
+ 'event_calendar:feature_not_activated' => "Эта возможность не активирована",
+
+ 'event_calendar:show_all' => "Показать все",
+ 'event_calendar:show_open' => "Показать открытые",
+ 'event_calendar:show_mine' => "Мой календарь",
+ 'event_calendar:show_friends' => "Календарь друзей",
+ 'event_calendar:show_only' => "Показывать только:",
+
+ 'event_calendar:listing_title:all' => "Все события",
+ 'event_calendar:listing_title:open' => "Открытые события",
+ 'event_calendar:listing_title:mine' => "Мой календарь",
+ 'event_calendar:listing_title:friends' => "Календари друзей",
+ 'event_calendar:manage_users:title' => "Управлять подписчиками на \"%s\"",
+ 'event_calendar:manage_users:breadcrumb' => "Управлять подписчиками",
+ 'event_calendar:manage_users:description' => "Добавить или удалить события из персональных календарей.",
+ 'event_calendar:manage_users:unauthorized' => "Ошибка: вы не уполномочены управлять персональными календарями для этого события.",
+ 'event_calendar:add_to_group_members:success' => "Это событие было добавлено в персональные календари всех членов группы.",
+ 'event_calendar:add_to_group_members:error' => "Ошибка: не могу добавить это событие в персональные календари членов группы.",
+ 'event_calendar:remove_from_group_members:success' => "Это событие было удалено из персональных календарей всех членов группы.",
+ 'event_calendar:remove_from_group_members:error' => "Ошибка: не могу удалить это событие из персональных календарей членов группы.",
+ 'event_calendar:add_to_group_members:button' => "Добавить всем",
+ 'event_calendar:remove_from_group_members:button' => "Удалить из всех",
+
+ 'event_calendar:manage_subscribers:success' => "Персональный календарь обновлен.",
+ 'event_calendar:manage_subscribers:error' => "Ошибка: не могу обновить персональный календарь.",
+ 'event_calendar:personal_manage:open' => "открытый",
+ 'event_calendar:personal_manage:closed' => "закрытый",
+ 'event_calendar:personal_manage:private' => "приватный",
+ 'event_calendar:personal_manage:by_event' => "по событию",
+ 'event_calendar:personal_manage:label' => "Доступ к календарю",
+ 'event_calendar:personal_manage:description' => "Определяет, может ли пользователь добавить это событие в свой календарях (открытый),"
+ ."требуется разрешние (закрытый) или не имеет возможности добавить вообще (приватное - такм образом только вы или сайт-админ могут добавять событие в календари).",
+ 'event_calendar:personal_manage:by_event:open' => "Открытое. Пользователи могут свободно добавлять это событие в свои персональные календари.",
+ 'event_calendar:personal_manage:by_event:closed' => "Закрытое. Пользователи могут отправлять запрос, чтобы добавить это событие в свои персональные календари. Вы можете просматривать и подтверждать эти запросы.",
+ 'event_calendar:personal_manage:by_event:private' => "Частное. Вы или другой администратор события должны добавить это событие в персональные календари. У других пользователей нет возможности послать запрос на это событие.",
+
+ 'event_calendar:settings:full_calendar:title' => "Поддержка полного календаря",
+ 'event_calendar:modify_full_calendar:error' => "Ошибка: не могу изменить весь календарь",
+ 'event_calendar:from_label' => "С: ",
+ 'event_calendar:to_label' => "По: ",
+ 'event_calendar:settings:timeformat:title' => "Формат времени",
+ 'event_calendar:time_format:12hour' => "12 часовой (am/pm)",
+ 'event_calendar:time_format:24hour' => "24 часовой",
+ 'event_calendar:all_day_label' => "Весь день",
+ 'event_calendar:repeat_interval_label' => "Повторять каждые",
+ 'event_calendar:repeat_weeks' => "неделю(и)",
+ 'event_calendar:on_these_days' => "в эти дни:",
+ 'event_calendar:day_abbrev:monday' => "П",
+ 'event_calendar:day_abbrev:tuesday' => "В",
+ 'event_calendar:day_abbrev:wednesday' => "С",
+ 'event_calendar:day_abbrev:thursday' => "Ч",
+ 'event_calendar:day_abbrev:friday' => "П",
+ 'event_calendar:day_abbrev:saturday' => "С",
+ 'event_calendar:day_abbrev:sunday' => "В",
+ 'event_calendar:dow:full:monday' => "Понедельник",
+ 'event_calendar:dow:full:tuesday' => "Вторник",
+ 'event_calendar:dow:full:wednesday' => "Среда",
+ 'event_calendar:dow:full:thursday' => "Четверг",
+ 'event_calendar:dow:full:friday' => "Пятница",
+ 'event_calendar:dow:full:saturday' => "Суббота",
+ 'event_calendar:dow:full:sunday' => "Воскресенье",
+ 'event_calendar:schedule_type:poll' => "Сделать опрос приглашенных про день/время",
+ 'event_calendar:schedule_type:fixed' => "Установить день/время",
+ 'elgg_calendar:send_reminder_label' => "Отправить напоминание",
+ 'elgg_calendar:send_reminder_before' => "перед",
+ 'event_calendar:interval:minute' => "менут",
+ 'event_calendar:interval:hour' => "часов",
+ 'event_calendar:interval:day' => "дней",
+ 'event_calendar:site_calendar' => "Календарь сайта",
+ 'event_calendar:calendar_label' => "Календарь",
+ 'event_calendar:calendar_description' => "Календарь для этого события.",
+ 'event_calendar:are_you_sure' => "Вы уверены в этом изменении?",
+ 'event_calendar:basic:header' => "Общая информация",
+ 'event_calendar:schedule:header' => "Расписание",
+ 'event_calendar:permissions:header' => "Разрешения",
+ 'event_calendar:read_access' => "Доступ на чтение ",
+ 'event_calendar:web_conference_label' => "Подключить веб-конференцию для этого события",
+ 'event_calendar:share_ownership:label' => "Добавить еще владельцев этого события",
+ 'event_calendar:share_ownership:description' => "Разрешить следующим людям редактировать или удалять это событие, приглашать участников",
+ 'event_calendar:settings:fewer_fields:title' => "Скрыть платежную информацию, контакты, органайзер и длинные описательные поля",
+ 'event_calendar:settings:restricted_times:title' => "Ограниченное время между 6:00 and 21:00",
+ 'event_calendar:add_event' => "Добавить событие",
+ 'event_calendar:schedule_event' => "Расписание события",
+ 'event_calendar:list_polls' => "Показать голосования",
+ 'event_calendar:edit_form:error:missing_title' => "Ошибка: укажите название",
+ 'event_calendar:repeated_event:week_interval' => "каждые %s недели.",
+ 'event_calendar:repeated_event:week_single' => "каждую неделю.",
+ 'event_calendar:repeated_event:format' => "Начинать с %s и продолжать по %s",
+ 'event_calendar:settings:repeated_events:title' => "Разрешить повторяющиеся события (сейчас работает нормально только в режиме полного календаря)",
+ 'event_calendar:settings:reminders:title' => "Разрешить отправку напоминаний",
+ 'event_calendar:reminder:subject' => "Напоминане о событии: %s",
+ 'event_calendar:reminder:body' => "Событие
+
+%s
+
+будет проходть в
+
+%s.
+
+Вы можете просмотреть страницу события тут:
+%s
+ ",
+
+ /**
+ * BBB support
+ */
+
+ 'event_calendar:bbb_server_url' => "Адрес сервера Big Blue Button (должен заканчиваться косой чертой)",
+ 'event_calendar:bbb_security_salt' => "Случайное число безопасности Big Blue Button",
+ 'event_calendar:bbb_create_error' => "Ошибка: невозможно создать конференцию BBB, сообщение: %s",
+ 'event_calendar:conference_create_error' => "Ошибка: невозможно создать веб-конференцию.",
+ 'event_calendar:bbb_settings_error' => "Ошибка: необходимо установить адрес конференции и случайное число в настройках плагина",
+ 'event_calendar:couldnotjoin' => "Ошибка: невозможно присоединиться к конференции.",
+ 'event_calendar:join_conf_button' => "Присоединиться к конференции",
+
+ 'event_calendar:poll_suffix' => "(опрос)",
+ 'event_calendar:resend_poll_invitation' => "Вы хотите предупредить приглашенных пользователей, что эти опции изменились?",
+
+ /**
+ * Event calendar river
+ **/
+
+ //generic terms to use
+
+ 'river:update:object:event_calendar' => "%s обновил событие %s",
+ 'river:create:object:event_calendar' => "%s добавил событие %s",
+ 'river:comment:object:event_calendar' => '%s оставил комментарий на событие %s',
+ 'event_calendar:river:created' => "%s добавлено",
+ 'event_calendar:river:updated' => "%s обновлено",
+ 'event_calendar:river:annotated1' => "%s добавил",
+ 'event_calendar:river:annotated2' => "в его/ее календарь.",
+
+ //these get inserted into the river links to take the user to the entity
+ 'event_calendar:river:create' => "новое событие",
+ 'event_calendar:river:the_event' => "событие",
+
+ );
+
+ add_translation("ru",$russian);
+
+?>
diff --git a/mod/event_calendar/manifest.xml b/mod/event_calendar/manifest.xml
new file mode 100644
index 000000000..ab565f233
--- /dev/null
+++ b/mod/event_calendar/manifest.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
+ <name>Event Calendar</name>
+ <author>Kevin Jardine and Lorea Developers</author>
+ <version>1.8.0</version>
+ <category>content</category>
+ <category>widget</category>
+ <description>Adds configurable group and/or site-wide event calendars.</description>
+ <website>https://lorea.org</website>
+ <copyright>(C) Radagast Solutions 2009-2011, Lorea Developers 2011-2013</copyright>
+ <license>GNU Public License version 2</license>
+ <requires>
+ <type>elgg_release</type>
+ <version>1.8</version>
+ </requires>
+</plugin_manifest>
diff --git a/mod/event_calendar/models/model.php b/mod/event_calendar/models/model.php
new file mode 100644
index 000000000..7b4698f98
--- /dev/null
+++ b/mod/event_calendar/models/model.php
@@ -0,0 +1,2518 @@
+<?php
+/**
+ * Elgg event model
+ *
+ * @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-2011
+ * @link http://radagast.biz/
+ *
+ */
+
+function event_calendar_get_event_for_edit($event_id) {
+ if ($event_id && $event = get_entity($event_id)) {
+ if ($event->canEdit()) {
+ return $event;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+}
+
+// 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) {
+
+ $event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar');
+ $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_hide_end = elgg_get_plugin_setting('hide_end', '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_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',
+ 'brief_description','fees','contact','organiser',
+ 'tags');
+
+ if ($event_calendar_times != 'no') {
+ $required_fields[] = 'start_time';
+ if ($event_calendar_hide_end != 'yes') {
+ $required_fields[] = 'end_time';
+ }
+ }
+ if ($event_calendar_region_display == 'yes') {
+ $required_fields[] = 'region';
+ }
+ if ($event_calendar_type_display == 'yes') {
+ $required_fields[] = 'event_type';
+ }
+ if ($event_calendar_spots_display == 'yes') {
+ $required_fields[] = 'spots';
+ }
+ } else {
+ $required_fields = array('title');
+ }
+
+ if ($event_guid) {
+ $event = get_entity($event_guid);
+ if (!elgg_instanceof($event, 'object', 'event_calendar')) {
+ // do nothing because this is a bad event guid
+ return FALSE;
+ }
+ } else {
+ $user_guid = elgg_get_logged_in_user_guid();
+ $event = new ElggObject();
+ $event->subtype = 'event_calendar';
+ $event->owner_guid = $user_guid;
+ if ($group_guid) {
+ $event->container_guid = $group_guid;
+ } else {
+ $event->container_guid = $event->owner_guid;
+ }
+ }
+ $event->access_id = get_input('access_id');
+ $event->title = get_input('title');
+ $event->description = get_input('description');
+ $event->venue = get_input('venue');
+
+ 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." GMT");
+ $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." GMT");
+ //$event->munged_end_date_string = $end_date_text." ".date_default_timezone_get();
+ } else {
+ $event->end_date = '';
+ }
+
+ 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') {
+ $event->spots = trim(get_input('spots'));
+ }
+ if ($event_calendar_region_display == 'yes') {
+ $event->region = get_input('region');
+ }
+ if ($event_calendar_type_display == 'yes') {
+ $event->event_type = get_input('event_type');
+ }
+ if ($event_calendar_personal_manage == 'by_event') {
+ $event->personal_manage = get_input('personal_manage');
+ }
+
+ if ($event_calendar_repeating_events != 'no') {
+ $repeats = get_input('repeats');
+ $event->repeats = $repeats;
+ if ($repeats == 'yes') {
+ $event->repeat_interval = get_input('repeat_interval');
+ $dow = array('monday','tuesday','wednesday','thursday','friday','saturday','sunday');
+ foreach ($dow as $w) {
+ $v = 'event-calendar-repeating-'.$w.'-value';
+ $event->$v = get_input($v);
+ }
+ }
+ }
+ $event->fees = get_input('fees');
+ $event->contact = get_input('contact');
+ $event->organiser = get_input('organiser');
+ $event->tags = string_to_tag_array(get_input('tags'));
+ $event->long_description = get_input('long_description');
+ $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');
+ $event->web_conference = get_input('web_conference');
+ $event->real_end_time = event_calendar_get_end_time($event);
+ foreach ($required_fields as $fn) {
+ if (!trim($event->$fn)) {
+ return FALSE;
+ break;
+ }
+ }
+ if ($event->save()) {
+ if (!$event_guid && $event->web_conference) {
+ if (!event_calendar_create_bbb_conf($event)) {
+ register_error(elgg_echo('event_calendar:conference_create_error'));
+ }
+ }
+ if ($group_guid && (elgg_get_plugin_setting('autogroup', 'event_calendar') == 'yes')) {
+ event_calendar_add_personal_events_from_group($event->guid,$group_guid);
+ }
+ if (elgg_get_plugin_setting('add_users', 'event_calendar') == 'yes') {
+ if (function_exists('autocomplete_member_to_user')) {
+ $addusers = get_input('adduser',array());
+ foreach($addusers as $adduser) {
+ if ($adduser) {
+ $user = autocomplete_member_to_user($adduser);
+ $user_id = $user->guid;
+ event_calendar_add_personal_event($event->guid,$user_id);
+ if (elgg_get_plugin_setting('add_users_notify', 'event_calendar') == 'yes') {
+ notify_user($user_id, $CONFIG->site->guid, elgg_echo('event_calendar:add_users_notify:subject'),
+ sprintf(
+ elgg_echo('event_calendar:add_users_notify:body'),
+ $user->name,
+ $event->title,
+ $event->getURL()
+ )
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+ return $event;
+}
+
+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);
+ return $count;
+ } else {
+ $events = 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,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;
+ }
+}
+
+function event_calendar_merge_repeating_events($events, $repeating_events) {
+ $non_repeating_events = array();
+ foreach($events as $e) {
+ if ($e->repeats != 'yes') {
+ $non_repeating_events[] = array('event' => $e,'data' => array(array('start_time' => $e->start_date, 'end_time' => $e->real_end_time)));
+ }
+ }
+
+ return array_merge($non_repeating_events, $repeating_events);
+}
+
+function event_calendar_get_repeating_events_between($start_date,$end_date,$container_guid,$region) {
+ // game plan: get all repeating events with start date <= $end_date and then generate all possible events
+ // sanity check
+ if ($start_date <= $end_date) {
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'limit' => 0,
+ 'metadata_name_value_pairs' => array(
+ array(
+ 'name' => 'start_date',
+ 'value' => $end_date,
+ 'operand' => '<='
+ ),
+ array(
+ 'name' => 'repeats',
+ 'value' => 'yes'
+ ),
+ )
+ );
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ if ($region && $region != '-') {
+ $options['metadata_name_value_pairs'][] = array(
+ 'name' => 'region',
+ 'value' => $region
+ );
+ }
+
+ $events = elgg_get_entities_from_metadata($options);
+ }
+ return event_calendar_get_repeating_event_structure($events, $start_date, $end_date);
+}
+
+
+function event_calendar_get_repeating_event_structure($events, $start_date, $end_date) {
+ $dow = array('monday','tuesday','wednesday','thursday','friday','saturday','sunday');
+ $repeating_events = array();
+ if ($events) {
+ foreach($events as $e) {
+ $incs = array();
+ $repeat_data = array();
+ $day_num = date('N',$e->start_date)-1;
+ for($d=0;$d<7;$d++) {
+ $fn = 'event-calendar-repeating-'.$dow[$d].'-value';
+ if ($e->$fn) {
+ $increment = $d - $day_num;
+ $incs[] = $increment;
+ }
+ }
+ if ($incs) {
+ sort($incs);
+
+ $repeat_interval = $e->repeat_interval;
+ $event_start_time = $e->start_date;
+ $event_end_time = $e->real_end_time;
+ $week = 0;
+ if ($event_start_time <= $event_end_time) {
+ $more_to_do = TRUE;
+ $cur_start_time = $event_start_time;
+ $cur_end_time = $event_end_time;
+ // keep generating events until after $end_date
+ // repeat_times is a sanity check to prevent infinite loops in case of bad data
+ $repeat_times = 0;
+ do {
+ foreach($incs as $inc) {
+ //$seconds = $inc*60*60*24;
+ if ($inc >=0) {
+ $tinc = "+ " . $inc;
+ } else {
+ $tinc = $inc;
+ }
+ $this_start_time = strtotime($tinc . " day", $cur_start_time);
+ $this_end_time = strtotime($tinc . " day", $cur_end_time);
+ if ($this_start_time > $end_date) {
+ $more_to_do = FALSE;
+ break;
+ }
+ if ($this_start_time >= $event_start_time) {
+ $repeat_data[] = array (
+ 'start_time' => $this_start_time,
+ 'end_time' => $this_end_time,
+ );
+ }
+ }
+ // repeat_interval weeks later
+ $week += $repeat_interval;
+ $cur_start_time = strtotime("+" . $week . " week", $event_start_time);
+ $cur_end_time = strtotime("+" . $week ." week", $event_end_time);
+ $repeat_times += 1;
+ } while ($repeat_times < 1000 && $more_to_do);
+ }
+ }
+ $repeating_events[] = array('event'=>$e,'data'=>$repeat_data);
+ }
+ }
+ return $repeating_events;
+}
+
+function event_calendar_get_open_events_between($start_date,$end_date,
+$is_count,$limit=10,$offset=0,$container_guid=0,$region='-', $meta_max = 'spots', $annotation_name = 'personal_event') {
+ 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,$meta_max,$annotation_name);
+ return $count;
+ } else {
+ $events = 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,false,$region,$meta_max,$annotation_name);
+ //return event_calendar_vsort($events,'start_date');
+ $repeating_events = event_calendar_get_open_repeating_events_between($start_date,$end_date,$container_guid,$region);
+ $all_events = event_calendar_merge_repeating_events($events, $repeating_events);
+ return $all_events;
+ }
+}
+
+function event_calendar_get_open_repeating_events_between($start_date,$end_date,$container_guid,$region) {
+ $db_prefix = elgg_get_config('dbprefix');
+ $meta_max = 'spots';
+ $annotation_name = 'personal_event';
+ $joins = array();
+ $wheres = array();
+ $meta_max_n = get_metastring_id($meta_max);
+ $ann_n = get_metastring_id($annotation_name);
+ if (!$meta_max_n || !$ann_n) {
+ if ($count) {
+ return 0;
+ } else {
+ return false;
+ }
+ }
+
+ $joins[] = "LEFT JOIN {$dbprefix}metadata m4 ON (e.guid = m4.entity_guid AND m4.name_id=$meta_max_n) ";
+ $joins[] = "LEFT JOIN {$dbprefix}metastrings ms4 ON (m4.value_id = ms4.id) ";
+ $wheres[] = "((ms4.string is null) OR (ms4.string = \"\") OR (CONVERT(ms4.string,SIGNED) > (SELECT count(id) FROM {$dbprefix}annotations ann WHERE ann.entity_guid = e.guid AND name_id = $ann_n GROUP BY entity_guid)))";
+
+ // sanity check
+ if ($start_date <= $end_date) {
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'limit' => 0,
+ 'metadata_name_value_pairs' => array(
+ array(
+ 'name' => 'start_date',
+ 'value' => $end_date,
+ 'operand' => '<='
+ ),
+ array(
+ 'name' => 'repeats',
+ 'value' => 'yes'
+ ),
+ ),
+ 'joins' => $joins,
+ 'wheres' => $wheres,
+
+ );
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ if ($region && $region != '-') {
+ $options['metadata_name_value_pairs'][] = array(
+ 'name' => 'region',
+ 'value' => $region
+ );
+ }
+
+ $events = elgg_get_entities_from_metadata($options);
+ }
+ return event_calendar_get_repeating_event_structure($events, $start_date, $end_date);
+}
+
+function event_calendar_get_events_for_user_between($start_date,$end_date,$is_count,$limit=10,$offset=0,$user_guid,$container_guid=0,$region='-') {
+ if ($is_count) {
+ // old way
+ $count = event_calendar_get_entities_from_metadata_between('start_date','end_date',
+ $start_date, $end_date, "object", "event_calendar", $user_guid, $container_guid, $limit,$offset,"",0,true,true,$region);
+
+ return $count;
+ } else {
+ $events = event_calendar_get_entities_from_metadata_between('start_date','end_date',
+ $start_date, $end_date, "object", "event_calendar", $user_guid, $container_guid, $limit,$offset,"",0,true,false,$region);
+ //return event_calendar_vsort($events,'start_date');
+ return $events;
+ }
+}
+
+function event_calendar_get_events_for_user_between2($start_date,$end_date,$is_count,$limit=10,$offset=0,$user_guid,$container_guid=0,$region='-') {
+ $options_new_way = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'relationship' => 'personal_event',
+ 'relationship_guid' => $user_guid,
+ 'metadata_name_value_pairs' => array( array( 'name' => 'start_date',
+ 'value' => $start_date,
+ 'operand' => '>='),
+ array( 'name' => 'real_end_time',
+ 'value' => $end_date,
+ 'operand' => '<=')
+ ),
+ );
+
+ if ($container_guid) {
+ $options_new_way['container_guid'] = $container_guid;
+ }
+ if ($region && $region != '-') {
+ $options_new_way['metadata_name_value_pairs'][] = array('name'=>'region','value'=>sanitize_string($region));
+ }
+ if ($is_count) {
+ // old way
+ $count_old_way = event_calendar_get_entities_from_metadata_between('start_date','real_end_time',
+ $start_date, $end_date, "object", "event_calendar", $user_guid, $container_guid, $limit,$offset,"",0,true,true,$region);
+ // new way
+ $options_new_way['count'] = TRUE;
+ $count_new_way = elgg_get_entities_from_relationship($options_new_way);
+ return $count_old_way+$count_new_way;
+ } else {
+ $events_old_way = event_calendar_get_entities_from_metadata_between('start_date','real_end_time',
+ $start_date, $end_date, "object", "event_calendar", $user_guid, $container_guid, $limit,$offset,"",0,true,false,$region);
+ $options_new_way['limit'] = $limit;
+ $options_new_way['offset'] = $offset;
+ $options_new_way['order_by_metadata'] = array(array('name'=>'start_date','direction'=>'ASC','as'=>'integer'));
+ //print_r($options_new_way);
+ $events_new_way = elgg_get_entities_from_relationship($options_new_way);
+ //return event_calendar_vsort($events,'start_date');
+ $repeating_events = event_calendar_get_repeating_events_for_user_between($user_guid,$start_date,$end_date,$container_guid,$region);
+ $all_events = event_calendar_merge_repeating_events(array_merge($events_old_way,$events_new_way), $repeating_events);
+ return $all_events;
+ }
+}
+
+function event_calendar_get_repeating_events_for_user_between($user_guid,$start_date,$end_date,$container_guid,$region) {
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'relationship' => 'personal_event',
+ 'relationship_guid' => $user_guid,
+ 'metadata_name_value_pairs' => array(
+ array(
+ 'name' => 'start_date',
+ 'value' => $end_date,
+ 'operand' => '<='
+ ),
+ array(
+ 'name' => 'repeats',
+ 'value' => 'yes'
+ ),
+ )
+ );
+
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ if ($region && $region != '-') {
+ $options['metadata_name_value_pairs'][] = array(
+ 'name' => 'region',
+ 'value' => $region
+ );
+ }
+
+ $events = elgg_get_entities_from_relationship($options);
+ return event_calendar_get_repeating_event_structure($events, $start_date, $end_date);
+}
+
+function event_calendar_get_repeating_events_for_friends_between($user_guid,$friend_list,$start_date,$end_date,$container_guid=0,$region='-') {
+
+ $db_prefix = elgg_get_config('dbprefix');
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'metadata_name_value_pairs' => array(
+ array( 'name' => 'start_date',
+ 'value' => $end_date,
+ 'operand' => '<='
+ ),
+ array( 'name' => 'repeats',
+ 'value' => 'yes'
+ )
+ ),
+ 'joins' => array("JOIN {$db_prefix}entity_relationships r ON (r.guid_two = e.guid)"),
+ 'wheres' => array("r.relationship = 'personal_event'","r.guid_one IN ($friend_list)"),
+ );
+
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+ if ($region && $region != '-') {
+ $options['metadata_name_value_pairs'][] = array('name'=>'region','value'=>sanitize_string($region));
+ }
+
+ $events = elgg_get_entities_from_relationship($options);
+ return event_calendar_get_repeating_event_structure($events, $start_date, $end_date);
+}
+
+function event_calendar_get_events_for_friends_between($start_date,$end_date,$is_count,$limit=10,$offset=0,$user_guid,$container_guid=0,$region='-') {
+ if ($user_guid) {
+ $friends = get_user_friends($user_guid,"",5000);
+ if ($friends) {
+ $friend_guids = array();
+ foreach($friends as $friend) {
+ $friend_guids[] = $friend->getGUID();
+ }
+ $friend_list = implode(",",$friend_guids);
+ // elgg_get_entities_from_relationship does not take multiple relationship guids, so need some custom joins and wheres
+ $db_prefix = elgg_get_config('dbprefix');
+ $options_new_way = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'metadata_name_value_pairs' => array(array( 'name' => 'start_date',
+ 'value' => $start_date,
+ 'operand' => '>='),
+ array( 'name' => 'real_end_time',
+ 'value' => $end_date,
+ 'operand' => '<=')
+ ),
+ 'joins' => array("JOIN {$db_prefix}entity_relationships r ON (r.guid_two = e.guid)"),
+ 'wheres' => array("r.relationship = 'personal_event'","r.guid_one IN ($friend_list)"),
+ );
+
+ if ($container_guid) {
+ $options_new_way['container_guid'] = $container_guid;
+ }
+ if ($region && $region != '-') {
+ $options_new_way['metadata_name_value_pairs'][] = array('name'=>'region','value'=>sanitize_string($region));
+ }
+ if ($is_count) {
+ $count_old_way = event_calendar_get_entities_from_metadata_between('start_date','end_date',
+ $start_date, $end_date, "object", "event_calendar", $friend_guids, $container_guid, $limit,$offset,"",0,true,true,$region);
+ $options_new_way['count'] = TRUE;
+ $count_new_way = elgg_get_entities_from_metadata($options_new_way);
+ return $count_old_way + $count_new_way;
+ } else {
+ $events_old_way = event_calendar_get_entities_from_metadata_between('start_date','end_date',
+ $start_date, $end_date, "object", "event_calendar", $friend_guids, $container_guid, $limit,$offset,"",0,true,false,$region);
+ //return event_calendar_vsort($events,'start_date');
+ $options_new_way['limit'] = $limit;
+ $options_new_way['offset'] = $offset;
+ $options_new_way['order_by_metadata'] = array(array('name'=>'start_date','direction'=>'ASC','as'=>'integer'));
+ //print_r($options_new_way);
+ $events_new_way = elgg_get_entities_from_metadata($options_new_way);
+ $repeating_events = event_calendar_get_repeating_events_for_friends_between($user_guid,$friend_list,$start_date,$end_date,$container_guid,$region);
+ $all_events = event_calendar_merge_repeating_events(array_merge($events_old_way,$events_new_way), $repeating_events);
+ return $all_events;
+ }
+ }
+ }
+ return array();
+}
+
+function event_calendar_vsort($original,$field, $descending = false) {
+ if (!$original) {
+ return $original;
+ }
+ $sortArr = array();
+
+ foreach ( $original as $key => $item ) {
+ $sortArr[ $key ] = $item->$field;
+ }
+
+ if ( $descending ) {
+ arsort( $sortArr );
+ } else {
+ asort( $sortArr );
+ }
+
+ $resultArr = array();
+ foreach ( $sortArr as $key => $value ) {
+ $resultArr[ $key ] = $original[ $key ];
+ }
+
+ return $resultArr;
+}
+
+// TODO - replace with Elgg API if possible
+
+/**
+ * Return a list of entities based on the given search criteria.
+ * In this case, returns entities with the given metadata between two values inclusive
+ *
+ * @param mixed $meta_start_name
+ * @param mixed $meta_end_name
+ * @param mixed $meta_start_value - start of metadata range, must be numerical value
+ * @param mixed $meta_end_value - end of metadata range, must be numerical value
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param mixed $owner_guid Either one integer user guid or an array of user guids
+ * @param int $container_guid If supplied, the result is restricted to events associated with a specific container
+ * @param int $limit
+ * @param int $offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+ * @param boolean $filter Filter by events in personal calendar if true
+ * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+ *
+ * @return int|array A list of entities, or a count if $count is set to true
+ */
+function event_calendar_get_entities_from_metadata_between($meta_start_name, $meta_end_name, $meta_start_value, $meta_end_value, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $filter = false, $count = false, $region='-')
+{
+ global $CONFIG;
+
+ // This should not be possible, but a sanity check just in case
+ if (!is_numeric($meta_start_value) || !is_numeric($meta_end_value)) {
+ return FALSE;
+ }
+
+ $meta_start_n = get_metastring_id($meta_start_name);
+ $meta_end_n = get_metastring_id($meta_end_name);
+ if ($region && $region != '-') {
+ $region_n = get_metastring_id('region');
+ $region_value_n = get_metastring_id($region);
+ if (!$region_n || !$region_value_n) {
+ if ($count) {
+ return 0;
+ } else {
+ return FALSE;
+ }
+ }
+ }
+
+ $entity_type = sanitise_string($entity_type);
+ $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ //if ($order_by == "") $order_by = "e.time_created desc";
+ if ($order_by == "") $order_by = "v.string asc";
+ $order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ((is_array($owner_guid) && (count($owner_guid)))) {
+ foreach($owner_guid as $key => $guid) {
+ $owner_guid[$key] = (int) $guid;
+ }
+ } else {
+ $owner_guid = (int) $owner_guid;
+ }
+
+ if ((is_array($container_guid) && (count($container_guid)))) {
+ foreach($container_guid as $key => $guid) {
+ $container_guid[$key] = (int) $guid;
+ }
+ } else {
+ $container_guid = (int) $container_guid;
+ }
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
+
+ //$access = get_access_list();
+
+ $where = array();
+
+ if ($entity_type!="")
+ $where[] = "e.type='$entity_type'";
+ if ($entity_subtype)
+ $where[] = "e.subtype=$entity_subtype";
+ $where[] = "m.name_id='$meta_start_n'";
+ $where[] = "m2.name_id='$meta_end_n'";
+ $where[] = "((v.string >= $meta_start_value AND v.string <= $meta_end_value) OR ( v2.string >= $meta_start_value AND v2.string <= $meta_end_value) OR (v.string <= $meta_start_value AND v2.string >= $meta_start_value) OR ( v2.string <= $meta_end_value AND v2.string >= $meta_end_value))";
+ if ($region && $region != '-') {
+ $where[] = "m3.name_id='$region_n'";
+ $where[] = "m3.value_id='$region_value_n'";
+ }
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
+ if ($filter) {
+ if (is_array($owner_guid)) {
+ $where[] = "ms2.string in (".implode(",",$owner_guid).")";
+ } else if ($owner_guid > 0) {
+ $where[] = "ms2.string = {$owner_guid}";
+ }
+
+ $where[] = "ms.string = 'personal_event'";
+ } else {
+ if (is_array($owner_guid)) {
+ $where[] = "e.owner_guid in (".implode(",",$owner_guid).")";
+ } else if ($owner_guid > 0) {
+ $where[] = "e.owner_guid = {$owner_guid}";
+ }
+ }
+
+ if (is_array($container_guid)) {
+ $where[] = "e.container_guid in (".implode(",",$container_guid).")";
+ } else if ($container_guid > 0)
+ $where[] = "e.container_guid = {$container_guid}";
+
+ if (!$count) {
+ $query = "SELECT distinct e.* ";
+ } else {
+ $query = "SELECT count(distinct e.guid) as total ";
+ }
+
+ $query .= "from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metadata m2 on e.guid = m2.entity_guid ";
+ if ($filter) {
+ $query .= "JOIN {$CONFIG->dbprefix}annotations a ON (a.entity_guid = e.guid) ";
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings ms ON (a.name_id = ms.id) ";
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings ms2 ON (a.value_id = ms2.id) ";
+ }
+ if ($region && $region != '-') {
+ $query .= "JOIN {$CONFIG->dbprefix}metadata m3 ON (e.guid = m3.entity_guid) ";
+ }
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings v on v.id = m.value_id JOIN {$CONFIG->dbprefix}metastrings v2 on v2.id = m2.value_id where";
+ foreach ($where as $w)
+ $query .= " $w and ";
+ $query .= get_access_sql_suffix("e"); // Add access controls
+ $query .= ' and ' . get_access_sql_suffix("m"); // Add access controls
+ $query .= ' and ' . get_access_sql_suffix("m2"); // Add access controls
+
+ if (!$count) {
+ $query .= " order by $order_by";
+ if ($limit) {
+ $query .= " limit $offset, $limit"; // Add order and limit
+ }
+ $entities = get_data($query, "entity_row_to_elggstar");
+ if (elgg_get_plugin_setting('add_to_group_calendar', 'event_calendar') == 'yes') {
+ if (get_entity($container_guid) instanceOf ElggGroup) {
+ $entities = event_calendar_get_entities_from_metadata_between_related($meta_start_name, $meta_end_name,
+ $meta_start_value, $meta_end_value, $entity_type,
+ $entity_subtype, $owner_guid, $container_guid,
+ 0, 0, "", 0,
+ false, false, '-',$entities);
+ }
+ }
+ return $entities;
+ } else {
+ if ($row = get_data_row($query))
+ return $row->total;
+ }
+ return false;
+}
+
+// adds any related events (has the display_on_group relation)
+// that meet the appropriate criteria
+
+function event_calendar_get_entities_from_metadata_between_related($meta_start_name, $meta_end_name,
+$meta_start_value, $meta_end_value, $entity_type = "",
+$entity_subtype = "", $owner_guid = 0, $container_guid = 0,
+$limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
+$filter = false, $count = false, $region='-',$main_events) {
+
+ $main_list = array();
+ if ($main_events) {
+ foreach ($main_events as $event) {
+ $main_list[$event->guid] = $event;
+ }
+ }
+ $related_list = array();
+ $related_events = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'display_on_group',
+ 'relationship_guid' => $container_guid,
+ 'inverse_relationship' => TRUE,
+ ));
+ if ($related_events) {
+ foreach ($related_events as $event) {
+ $related_list[$event->guid] = $event;
+ }
+ }
+ // get all the events (across all containers) that meet the criteria
+ $all_events = event_calendar_get_entities_from_metadata_between($meta_start_name, $meta_end_name,
+ $meta_start_value, $meta_end_value, $entity_type, $entity_subtype, $owner_guid,
+ 0, $limit, $offset, $order_by, $site_guid, $filter, $count, $region);
+
+ if ($all_events) {
+ foreach($all_events as $event) {
+ if (array_key_exists($event->guid,$related_list)
+ && !array_key_exists($event->guid,$main_list)) {
+ // add to main events
+ $main_events[] = $event;
+ }
+ }
+ }
+ return event_calendar_vsort($main_events,$meta_start_name);
+}
+
+// TODO: try to replace this with new Elgg 1.7 API
+/**
+ * Return a list of entities based on the given search criteria.
+ * In this case, returns entities with the given metadata between two values inclusive
+ *
+ * @param mixed $meta_start_name
+ * @param mixed $meta_end_name
+ * @param mixed $meta_start_value - start of metadata range, must be numerical value
+ * @param mixed $meta_end_value - end of metadata range, must be numerical value
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param mixed $owner_guid Either one integer user guid or an array of user guids
+ * @param int $container_guid If supplied, the result is restricted to events associated with a specific container
+ * @param int $limit
+ * @param int $offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+ * @param boolean $filter Filter by events in personal calendar if true
+ * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+ * @param string $meta_max metadata name containing maximum annotation count
+ * @param string $annotation_name annotation name to count
+ *
+ * @return int|array A list of entities, or a count if $count is set to true
+ *
+ * TODO: see if the new API is robust enough to avoid this custom query
+ */
+function event_calendar_get_entities_from_metadata_between2
+($meta_start_name, $meta_end_name, $meta_start_value, $meta_end_value,
+$entity_type = "", $entity_subtype = "", $owner_guid = 0, $container_guid = 0,
+$limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $filter = false,
+$count = false, $region='-', $meta_max = '', $annotation_name = '')
+{
+ global $CONFIG;
+
+ // This should not be possible, but a sanity check just in case
+ if (!is_numeric($meta_start_value) || !is_numeric($meta_end_value)) {
+ return FALSE;
+ }
+
+ $meta_start_n = get_metastring_id($meta_start_name);
+ $meta_end_n = get_metastring_id($meta_end_name);
+ if ($region && $region != '-') {
+ $region_n = get_metastring_id('region');
+ $region_value_n = get_metastring_id($region);
+ if (!$region_n || !$region_value_n) {
+ if ($count) {
+ return 0;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ $entity_type = sanitise_string($entity_type);
+ $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ //if ($order_by == "") $order_by = "e.time_created desc";
+ if ($order_by == "") $order_by = "v.string asc";
+ $order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ((is_array($owner_guid) && (count($owner_guid)))) {
+ foreach($owner_guid as $key => $guid) {
+ $owner_guid[$key] = (int) $guid;
+ }
+ } else {
+ $owner_guid = (int) $owner_guid;
+ }
+
+ if ((is_array($container_guid) && (count($container_guid)))) {
+ foreach($container_guid as $key => $guid) {
+ $container_guid[$key] = (int) $guid;
+ }
+ } else {
+ $container_guid = (int) $container_guid;
+ }
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
+
+ //$access = get_access_list();
+
+ $where = array();
+
+ if ($entity_type!="")
+ $where[] = "e.type='$entity_type'";
+ if ($entity_subtype)
+ $where[] = "e.subtype=$entity_subtype";
+ $where[] = "m.name_id='$meta_start_n'";
+ $where[] = "m2.name_id='$meta_end_n'";
+ $where[] = "((v.string >= $meta_start_value AND v.string <= $meta_end_value) OR ( v2.string >= $meta_start_value AND v2.string <= $meta_end_value) OR (v.string <= $meta_start_value AND v2.string >= $meta_start_value) OR ( v2.string <= $meta_end_value AND v2.string >= $meta_end_value))";
+ if ($region && $region != '-') {
+ $where[] = "m3.name_id='$region_n'";
+ $where[] = "m3.value_id='$region_value_n'";
+ }
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
+ if ($filter) {
+ if (is_array($owner_guid)) {
+ $where[] = "ms2.string in (".implode(",",$owner_guid).")";
+ } else if ($owner_guid > 0) {
+ $where[] = "ms2.string = {$owner_guid}";
+ }
+
+ $where[] = "ms.string = 'personal_event'";
+ } else {
+ if (is_array($owner_guid)) {
+ $where[] = "e.owner_guid in (".implode(",",$owner_guid).")";
+ } else if ($owner_guid > 0) {
+ $where[] = "e.owner_guid = {$owner_guid}";
+ }
+ }
+
+ if (is_array($container_guid)) {
+ $where[] = "e.container_guid in (".implode(",",$container_guid).")";
+ } else if ($container_guid > 0)
+ $where[] = "e.container_guid = {$container_guid}";
+
+ if (!$count) {
+ $query = "SELECT distinct e.* ";
+ } else {
+ $query = "SELECT count(distinct e.guid) as total ";
+ }
+
+ $query .= "FROM {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metadata m2 on e.guid = m2.entity_guid ";
+ if ($filter) {
+ $query .= "JOIN {$CONFIG->dbprefix}annotations a ON (a.entity_guid = e.guid) ";
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings ms ON (a.name_id = ms.id) ";
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings ms2 ON (a.value_id = ms2.id) ";
+ }
+ if ($region && $region != '-') {
+ $query .= "JOIN {$CONFIG->dbprefix}metadata m3 ON (e.guid = m3.entity_guid) ";
+ }
+ if ($meta_max && $annotation_name) {
+ // This groups events for which the meta max name is defined
+ // perhaps this should be a left join and accept null values?
+ // so it would return groups with no spots defined as well
+ $meta_max_n = get_metastring_id($meta_max);
+ $ann_n = get_metastring_id($annotation_name);
+ if (!$meta_max_n || !$ann_n) {
+ if ($count) {
+ return 0;
+ } else {
+ return false;
+ }
+ }
+
+ $query .= " LEFT JOIN {$CONFIG->dbprefix}metadata m4 ON (e.guid = m4.entity_guid AND m4.name_id=$meta_max_n) ";
+ $query .= " LEFT JOIN {$CONFIG->dbprefix}metastrings ms4 ON (m4.value_id = ms4.id) ";
+ $where[] = "((ms4.string is null) OR (ms4.string = \"\") OR (CONVERT(ms4.string,SIGNED) > (SELECT count(id) FROM {$CONFIG->dbprefix}annotations ann WHERE ann.entity_guid = e.guid AND name_id = $ann_n GROUP BY entity_guid)))";
+ }
+ $query .= "JOIN {$CONFIG->dbprefix}metastrings v on v.id = m.value_id JOIN {$CONFIG->dbprefix}metastrings v2 on v2.id = m2.value_id where";
+ foreach ($where as $w)
+ $query .= " $w AND ";
+ $query .= get_access_sql_suffix("e"); // Add access controls
+ $query .= ' AND ' . get_access_sql_suffix("m"); // Add access controls
+ $query .= ' AND ' . get_access_sql_suffix("m2"); // Add access controls
+
+ if (!$count) {
+ $query .= " order by $order_by";
+ if ($limit) {
+ $query .= " limit $offset, $limit"; // Add order and limit
+ }
+ $entities = get_data($query, "entity_row_to_elggstar");
+ if (elgg_get_plugin_setting('add_to_group_calendar', 'event_calendar') == 'yes') {
+ if (get_entity($container_guid) instanceOf ElggGroup) {
+ $entities = event_calendar_get_entities_from_metadata_between_related($meta_start_name, $meta_end_name,
+ $meta_start_value, $meta_end_value, $entity_type,
+ $entity_subtype, $owner_guid, $container_guid,
+ 0, 0, "", 0,
+ false, false, '-',$entities);
+ }
+ }
+ return $entities;
+ } else {
+ if ($row = get_data_row($query))
+ return $row->total;
+ }
+ return false;
+}
+
+function event_calendar_has_personal_event($event_guid,$user_guid) {
+ // check legacy implementation and new one
+ if (check_entity_relationship($user_guid,'personal_event',$event_guid)) {
+ return TRUE;
+ } else {
+ // use old method for now
+ $options = array('guid'=>$event_guid,'annotation_name' => 'personal_event', 'annotation_value' => $user_guid,'count'=>TRUE);
+ //$annotations = get_annotations($event_guid, "object", "event_calendar", "personal_event", (int) $user_guid, $user_guid);
+ if (elgg_get_annotations($options)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+}
+
+function event_calendar_add_personal_event($event_guid,$user_guid) {
+ if ($event_guid && $user_guid) {
+ if (!event_calendar_has_personal_event($event_guid,$user_guid)
+ && !event_calendar_has_collision($event_guid,$user_guid)) {
+ if (!event_calendar_is_full($event_guid)) {
+ add_entity_relationship($user_guid,'personal_event',$event_guid);
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+function event_calendar_add_personal_events_from_group($event_guid,$group_guid) {
+ $members = get_group_members($group_guid, 100000);
+ foreach($members as $member) {
+ $member_id = $member->getGUID();
+ event_calendar_add_personal_event($event_guid,$member_id);
+ }
+}
+
+function event_calendar_remove_personal_event($event_guid,$user_guid) {
+ remove_entity_relationship($user_guid,'personal_event',$event_guid);
+ // also use old method for now
+ $annotations = get_annotations($event_guid, "object", "event_calendar", "personal_event", (int) $user_guid, $user_guid);
+ if ($annotations) {
+ foreach ($annotations as $annotation) {
+ $annotation->delete();
+ }
+ }
+}
+
+function event_calendar_get_personal_events_for_user($user_guid,$limit) {
+ $events_old_way = elgg_get_entities_from_annotations(array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'annotation_names' => 'personal_event',
+ 'annotation_value' => $user_guid,
+ 'limit' => 0,
+ ));
+
+ $events_new_way = elgg_get_entities_from_relationship(array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'relationship' => 'personal_event',
+ 'relationship_guid' => $user_guid,
+ 'limit' => 0,
+ ));
+
+ $events = array_merge($events_old_way,$events_new_way);
+
+ $final_events = array();
+ if ($events) {
+ $now = time();
+ $one_day = 60*60*24;
+ // don't show events that have been over for more than a day
+ foreach($events as $event) {
+ if (($event->start_date > $now-$one_day) || ($event->end_date && ($event->end_date > $now-$one_day))) {
+ $final_events[] = $event;
+ }
+ }
+ }
+ $sorted = event_calendar_vsort($final_events,'start_date');
+ return array_slice($sorted,0,$limit);
+}
+
+// the old way used annotations, and the new Elgg 1.8 way uses relationships
+// for now this version attempts to bridge the gap by using both methods for older sites
+
+function event_calendar_get_users_for_event($event_guid,$limit,$offset=0,$is_count=FALSE) {
+ $options = array(
+ 'type' => 'user',
+ 'relationship' => 'personal_event',
+ 'relationship_guid' => $event_guid,
+ 'inverse_relationship' => TRUE,
+ 'limit' => 0,
+ );
+ if ($is_count) {
+ //$count_old_way = count_annotations($event_guid, "object", "event_calendar", "personal_event");
+ $count_old_way = elgg_get_annotations(array(
+ 'guid'=>$event_guid,
+ 'type'=>"object",
+ 'subtype'=>"event_calendar",
+ 'annotation_name' => "personal_event",
+ 'count'=>TRUE)
+ );
+ $options ['count'] = TRUE;
+ $count_new_way = elgg_get_entities_from_relationship($options);
+ return $count_old_way + $count_new_way;
+ } else {
+ $users_old_way = array();
+ //$annotations = get_annotations($event_id, "object", "event_calendar", "personal_event", "", 0, $limit, $offset);
+ $annotations = elgg_get_annotations(array(
+ 'guid'=>$event_guid,
+ 'type'=>"object",
+ 'subtype'=>"event_calendar",
+ 'annotation_name' => "personal_event",
+ 'limit' => $limit,
+ 'offset' => $offset)
+ );
+ if ($annotations) {
+ foreach($annotations as $annotation) {
+ if (($user = get_entity($annotation->value)) && ($user instanceOf ElggUser)) {
+ $users_old_way[] = $user;
+ }
+ }
+ }
+ $users_new_way = elgg_get_entities_from_relationship($options);
+ return array_merge($users_old_way,$users_new_way);
+ }
+}
+
+function event_calendar_security_fields() {
+ $ts = time();
+ $token = generate_action_token($ts);
+ return "__elgg_token=$token&__elgg_ts=$ts";
+}
+
+function event_calendar_get_events_for_group($group_guid, $limit = 0) {
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'container_guid' => $group_guid,
+ 'limit' => $limit,
+ );
+ return elgg_get_entities($options);
+}
+
+function event_calendar_convert_time($time) {
+ $event_calendar_time_format = elgg_get_plugin_setting('timeformat','event_calendar');
+ if ($event_calendar_time_format == '12') {
+ $hour = floor($time/60);
+ $minute = sprintf("%02d",$time-60*$hour);
+ if ($hour < 12) {
+ return "$hour:$minute am";
+ } else {
+ $hour -= 12;
+ return "$hour:$minute pm";
+ }
+ } else {
+ $hour = floor($time/60);
+ $minute = sprintf("%02d",$time-60*$hour);
+ return "$hour:$minute";
+ }
+}
+
+function event_calendar_format_time($date,$time1,$time2='') {
+ if (is_numeric($time1)) {
+ $t = event_calendar_convert_time($time1);
+ if (is_numeric($time2)) {
+ $t .= " - ".event_calendar_convert_time($time2);
+ }
+ return "$t, $date";
+ } else {
+ return $date;
+ }
+}
+
+function event_calender_get_gmt_from_server_time($server_time) {
+ $gmtime = $server_time - (int)substr(date('O'),0,3)*60*60;
+}
+
+function event_calendar_activated_for_group($group) {
+ $group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
+ $group_default = elgg_get_plugin_setting('group_default', 'event_calendar');
+ if ($group && ($group_calendar != 'no')) {
+ if ( ($group->event_calendar_enable == 'yes') || ((!$group->event_calendar_enable && (!$group_default || $group_default == 'yes')))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function event_calendar_get_region($event) {
+ $event_calendar_region_list_handles = elgg_get_plugin_setting('region_list_handles', 'event_calendar');
+ $region = trim($event->region);
+ if ($event_calendar_region_list_handles == 'yes') {
+ $region = elgg_echo('event_calendar:region:'.$region);
+ }
+ return htmlspecialchars($region);
+}
+
+function event_calendar_get_type($event) {
+ $event_calendar_type_list_handles = elgg_get_plugin_setting('type_list_handles', 'event_calendar');
+ $type = trim($event->event_type);
+ if ($type) {
+ if ($event_calendar_type_list_handles == 'yes') {
+ $type = elgg_echo('event_calendar:type:'.$type);
+ }
+ return htmlspecialchars($type);
+ } else {
+ return $type;
+ }
+}
+
+function event_calendar_get_formatted_full_items($event) {
+ $time_bit = event_calendar_get_formatted_time($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();
+ 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);
+ $event_items[] = $item;
+ if ($event_calendar_region_display == 'yes') {
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:region_label');
+ $item->value = event_calendar_get_region($event);
+ $event_items[] = $item;
+ }
+ if ($event_calendar_type_display == 'yes') {
+ $event_type = event_calendar_get_type($event);
+ if ($event_type) {
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:type_label');
+ $item->value = event_calendar_get_type($event);
+ $event_items[] = $item;
+ }
+ }
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:fees_label');
+ $item->value = htmlspecialchars($event->fees);
+ $event_items[] = $item;
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:organiser_label');
+ $item->value = htmlspecialchars($event->organiser);
+ $event_items[] = $item;
+ $item = new stdClass();
+ $item->title = elgg_echo('event_calendar:contact_label');
+ $item->value = htmlspecialchars($event->contact);
+ $event_items[] = $item;
+
+ return $event_items;
+}
+
+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';
+
+ $start_date = date($date_format,$event->start_date);
+ if ($event->end_date) {
+ $end_date = date($date_format,$event->end_date);
+ }
+ if ((!$event->end_date) || ($end_date == $start_date)) {
+ if (!$event->all_day && $event_calendar_times) {
+ $start_date = event_calendar_format_time($start_date,$event->start_time,$event->end_time);
+ }
+ $time_bit = $start_date;
+ } else {
+ if (!$event->all_day && $event_calendar_times) {
+ $start_date = event_calendar_format_time($start_date,$event->start_time);
+ $end_date = event_calendar_format_time($end_date,$event->end_time);
+ }
+ $time_bit = "$start_date - $end_date";
+ }
+
+ if ($event->repeats == 'yes') {
+ $dow = array('monday','tuesday','wednesday','thursday','friday','saturday','sunday');
+ $r = array();
+ foreach ($dow as $w) {
+ $fn = 'event-calendar-repeating-'.$w.'-value';
+ if ($event->$fn) {
+ $r[] = elgg_echo('event_calendar:dow:full:'.$w);
+ }
+ }
+ $week_bit = implode(", ",$r);
+ if ($event->repeat_interval > 1) {
+ $week_bit .= ' '.elgg_echo('event_calendar:repeated_event:week_interval',array($event->repeat_interval));
+ } else {
+ $week_bit .= ' '.elgg_echo('event_calendar:repeated_event:week_single');
+ }
+ $time_bit = elgg_echo('event_calendar:repeated_event:format',array($time_bit, $week_bit));
+ }
+
+ return $time_bit;
+}
+
+function event_calendar_get_formatted_date($ts) {
+ // TODO: make the date format configurable
+ return date('j/n/Y',$ts);
+}
+
+function event_calendar_is_full($event_id) {
+ $event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar');
+ if ($event_calendar_spots_display == 'yes') {
+ $count = event_calendar_get_users_for_event($event_id,0,0,TRUE);
+ $event = get_entity($event_id);
+ if ($event) {
+ $spots = $event->spots;
+ if (is_numeric($spots)) {
+ if ($count >= $spots) {
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+function event_calendar_has_collision($event_id, $user_id) {
+ $no_collisions = elgg_get_plugin_setting('no_collisions', 'event_calendar');
+ if ($no_collisions == 'yes') {
+ $event = get_entity($event_id);
+ if ($event) {
+ $start_time = $event->start_date;
+ $end_time = event_calendar_get_end_time($event);
+ // look to see if the user already has events within this period
+ $count = event_calendar_get_events_for_user_between2($start_time,$end_time,TRUE,10,0,$user_id);
+ if ($count > 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+// this complicated bit of code determines the event end time
+function event_calendar_get_end_time($event) {
+ $default_length = elgg_get_plugin_setting('collision_length', 'event_calendar');
+ $start_time = $event->start_date;
+ $end_time = $event->end_time;
+ $end_date = $event->end_date;
+ if($end_date) {
+ if ($end_time) {
+ $end_time = $end_date+$end_time*60;
+ } else if ($start_time == $end_date) {
+ if (is_numeric($default_length)) {
+ $end_time = $end_date + $default_length;
+ } else {
+ // default to an hour length
+ $end_time = $start_time + 3600;
+ }
+ } else {
+ $end_time = $end_date;
+ }
+ } else {
+ if ($end_time) {
+ if ($event->start_time) {
+ $end_time = $start_time + ($end_time*60 - $event->start_time*60);
+ } else {
+ $end_time = $start_time + $end_time*60;
+ }
+ } else {
+ if (is_numeric($default_length)) {
+ $end_time = $start_time + $default_length;
+ } else {
+ // default to an hour length
+ $end_time = $start_time + 3600;
+ }
+ }
+ }
+
+ return $end_time;
+}
+
+// a version to allow for some customised options
+function event_calendar_view_entity_list($entities, $count, $offset, $limit, $fullview = true, $viewtypetoggle = true, $pagination = true) {
+ $count = (int) $count;
+ $limit = (int) $limit;
+
+ // do not require views to explicitly pass in the offset
+ if (!$offset = (int) $offset) {
+ $offset = sanitise_int(get_input('offset', 0));
+ }
+
+ $context = elgg_get_context();
+
+ $html = elgg_view('event_calendar/entities/entity_list',array(
+ 'entities' => $entities,
+ 'count' => $count,
+ 'offset' => $offset,
+ 'limit' => $limit,
+ 'baseurl' => $_SERVER['REQUEST_URI'],
+ 'fullview' => $fullview,
+ 'context' => $context,
+ 'viewtypetoggle' => $viewtypetoggle,
+ 'viewtype' => get_input('search_viewtype','list'),
+ 'pagination' => $pagination
+ ));
+
+ return $html;
+}
+
+// returns open, closed or private for the given event and user
+function event_calendar_personal_can_manage($event,$user_id) {
+ $status = 'private';
+ $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
+ if (!$event_calendar_personal_manage
+ || $event_calendar_personal_manage == 'open'
+ || $event_calendar_personal_manage == 'yes'
+ || (($event_calendar_personal_manage == 'by_event' && (!$event->personal_manage || ($event->personal_manage == 'open'))))) {
+ $status = 'open';
+ } else {
+ // in this case only admins or event owners can manage events on their personal calendars
+ if(elgg_is_admin_logged_in()) {
+ $status = 'open';
+ } else if ($event && ($event->owner_guid == $user_id)) {
+ $status = 'open';
+ } else if (($event_calendar_personal_manage == 'closed')
+ || ($event_calendar_personal_manage == 'no')
+ || (($event_calendar_personal_manage == 'by_event') && ($event->personal_manage == 'closed'))) {
+ $status = 'closed';
+ }
+ }
+
+ return $status;
+}
+
+function event_calendar_send_event_request($event,$user_guid) {
+ $result = FALSE;
+ if(add_entity_relationship($user_guid, 'event_calendar_request', $event->guid)) {
+ $subject = elgg_echo('event_calendar:request_subject');
+ $name = get_entity($user_guid)->name;
+ $title = $event->title;
+ $url = $event->getUrl();
+ $link = elgg_get_site_url().'event_calendar/review_requests/'.$event->guid;
+ $message = sprintf(elgg_echo('event_calendar:request_message'),$name,$title,$url,$link);
+ notify_user($event->owner_guid,elgg_get_site_entity()->guid,$subject,$message);
+ $result = TRUE;
+ }
+ return $result;
+}
+
+// pages
+
+function event_calendar_get_page_content_list($page_type,$container_guid,$start_date,$display_mode,$filter,$region='-') {
+ elgg_load_js('elgg.event_calendar');
+ global $autofeed;
+ $autofeed = true;
+ if ($page_type == 'group') {
+ if (!event_calendar_activated_for_group($container_guid)) {
+ forward();
+ }
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'));
+ elgg_push_context('groups');
+ elgg_set_page_owner_guid($container_guid);
+ $user_guid = elgg_get_logged_in_user_guid();
+ if(event_calendar_can_add($container_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 event-calendar-button-add',
+ ));
+ }
+ } else {
+ elgg_push_breadcrumb(elgg_echo('item:object:event_calendar'));
+ $user_guid = elgg_get_logged_in_user_guid();
+ if(event_calendar_can_add($container_guid)) {
+ elgg_register_menu_item('title', array(
+ 'name' => 'add',
+ 'href' => "event_calendar/add",
+ 'text' => elgg_echo('event_calendar:add'),
+ 'class' => 'elgg-button elgg-button-action event-calendar-button-add',
+ ));
+ }
+ }
+
+ $params = event_calendar_generate_listing_params($page_type,$container_guid,$start_date,$display_mode,$filter,$region);
+
+ $url = current_page_url();
+ if (substr_count($url, '?')) {
+ $url .= "&view=ical";
+ } else {
+ $url .= "?view=ical";
+ }
+
+ $url = elgg_format_url($url);
+ $menu_options = array(
+ 'name' => 'ical',
+ 'id' => 'event-calendar-ical-link',
+ 'text' => elgg_view_icon('calendar'),
+ 'href' => $url,
+ 'title' => elgg_echo('feed:ical'),
+ 'priority' => 800,
+ 'rel' => 'popup',
+ );
+ $menu_item = ElggMenuItem::factory($menu_options);
+ elgg_register_menu_item('extras', $menu_item);
+
+ $body = elgg_view_layout("content", $params);
+ $body .= elgg_view_module('popup', elgg_echo('feed:ical'), elgg_echo('event_calendar:ical_popup_message') . elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo('export'),
+ 'class' => 'elgg-button elgg-button-action',
+ )), array(
+ 'id' => 'event-calendar-ical',
+ 'class' => 'event-calendar-ical hidden',
+ ));
+
+ return elgg_view_page($title, $body);
+}
+
+function event_calendar_get_page_content_edit($page_type,$guid,$start_date='') {
+ elgg_load_js('elgg.event_calendar');
+ $vars = array();
+ $vars['id'] = 'event-calendar-edit';
+ // just in case a feature adds an image upload
+ $vars['enctype'] = 'multipart/form-data';
+
+ $body_vars = array();
+
+ if ($page_type == 'edit') {
+ $title = elgg_echo('event_calendar:manage_event_title');
+ $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,$page_type);
+
+ $event_container = get_entity($event->container_guid);
+ if (elgg_instanceof($event_container, 'group')) {
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
+ $body_vars['group_guid'] = $event_container->guid;
+ } else {
+ elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
+ $body_vars['group_guid'] = 0;
+ }
+ elgg_push_breadcrumb($event->title,$event->getURL());
+ elgg_push_breadcrumb(elgg_echo('event_calendar:manage_event_title'));
+
+ $content = elgg_view_form('event_calendar/edit', $vars,$body_vars);
+ } else {
+ $content = elgg_echo('event_calendar:error_event_edit');
+ }
+ } else {
+ $title = elgg_echo('event_calendar:add_event_title');
+
+ if ($guid) {
+ // add to group
+ $group = get_entity($guid);
+ if (elgg_instanceof($group, 'group')) {
+ $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(NULL,$page_type,$start_date);
+ $content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
+ } else {
+ $content = elgg_echo('event_calendar:no_group');
+ }
+ } else {
+ $body_vars['group_guid'] = 0;
+ 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(NULL,$page_type,$start_date);
+
+ $content = elgg_view_form('event_calendar/edit', $vars, $body_vars);
+ }
+ }
+
+ $params = array('title' => $title, 'content' => $content,'filter' => '');
+
+ $body = elgg_view_layout("content", $params);
+
+ return elgg_view_page($title,$body);
+}
+
+/**
+ * Pull together variables for the edit form
+ *
+ * @param ElggObject $event
+ * @return array
+ */
+function event_calendar_prepare_edit_form_vars($event = NULL, $page_type = '', $start_date = '') {
+
+ // input names => defaults
+ $now = time();
+ $iso_date = date('Y-m-d',$now);
+ $now_midnight = strtotime($iso_date);
+ if ($start_date) {
+ $start_date = strtotime($start_date);
+ } else {
+ $start_date = $now+60*60;
+ }
+ $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' => $start_date,
+ 'end_date' => $start_date+60*60,
+ 'start_time' => $start_time,
+ 'end_time' => $start_time + 60,
+ 'spots' => NULL,
+ 'region' => '-',
+ 'event_type' => '-',
+ 'fees' => NULL,
+ 'contact' => NULL,
+ 'organiser' => NULL,
+ 'tags' => NULL,
+ 'send_reminder' => NULL,
+ 'reminder_number' => 1,
+ 'reminder_interval' => 60,
+ 'repeats' => NULL,
+ 'repeat_interval' => 1,
+ 'event-calendar-repeating-monday-value' => 0,
+ 'event-calendar-repeating-tuesday-value' => 0,
+ 'event-calendar-repeating-wednesday-value' => 0,
+ 'event-calendar-repeating-thursday-value' => 0,
+ 'event-calendar-repeating-friday-value' => 0,
+ 'event-calendar-repeating-saturday-value' => 0,
+ 'event-calendar-repeating-sunday-value' => 0,
+ 'personal_manage' => 'open',
+ 'web_conference' => NULL,
+ 'long_description' => NULL,
+ 'access_id' => ACCESS_DEFAULT,
+ 'group_guid' => NULL,
+ );
+
+ if ($page_type == 'schedule') {
+ $values['schedule_type'] = 'poll';
+ } else {
+ $values['schedule_type'] = 'all_day';
+ }
+
+ if ($event) {
+ foreach (array_keys($values) as $field) {
+ if (isset($event->$field)) {
+ $values[$field] = $event->$field;
+ }
+ }
+ }
+
+ if (elgg_is_sticky_form('event_calendar')) {
+ $sticky_values = elgg_get_sticky_values('event_calendar');
+ foreach ($sticky_values as $key => $value) {
+ $values[$key] = $value;
+ }
+ }
+
+ elgg_clear_sticky_form('event_calendar');
+
+ return $values;
+}
+
+function event_calendar_generate_listing_params($page_type,$container_guid,$original_start_date,$display_mode,$filter,$region='-') {
+ $event_calendar_listing_format = elgg_get_plugin_setting('listing_format', 'event_calendar');
+ $event_calendar_spots_display = trim(elgg_get_plugin_setting('spots_display', 'event_calendar'));
+ $event_calendar_first_date = trim(elgg_get_plugin_setting('first_date', 'event_calendar'));
+ $event_calendar_last_date = trim(elgg_get_plugin_setting('last_date', 'event_calendar'));
+
+ if (!$original_start_date) {
+ $original_start_date = date('Y-m-d');
+ }
+ if ( $event_calendar_first_date && ($original_start_date < $event_calendar_first_date) ) {
+ $original_start_date = $event_calendar_first_date;
+ }
+ if ( $event_calendar_last_date && ($original_start_date > $event_calendar_last_date) ) {
+ $original_start_date = $event_calendar_first_date;
+ }
+
+ if ($event_calendar_listing_format == 'paged') {
+ $start_ts = strtotime($original_start_date);
+ $start_date = $original_start_date;
+ if ($event_calendar_last_date) {
+ $end_ts = strtotime($event_calendar_last_date);
+ } else {
+ // set to a large number
+ $end_ts = 2000000000;
+ }
+ $mode = 'paged';
+ } else {
+
+ // the default interval is one month
+ $day = 60*60*24;
+ $week = 7*$day;
+ $month = 31*$day;
+
+ $mode = trim($display_mode);
+ if (!$mode) {
+ $mode = 'month';
+ }
+
+ if ($mode == "day") {
+ $start_date = $original_start_date;
+ $end_date = $start_date;
+ $start_ts = strtotime($start_date);
+ $end_ts = strtotime($end_date)+$day-1;
+ } else if ($mode == "week") {
+ // need to adjust start_date to be the beginning of the week
+ $start_ts = strtotime($original_start_date);
+ $start_ts -= date("w",$start_ts)*$day;
+ $end_ts = $start_ts + 6*$day;
+
+ $start_date = date('Y-m-d',$start_ts);
+ $end_date = date('Y-m-d',$end_ts);
+ } else {
+ $start_ts = strtotime($original_start_date);
+ $month = date('m',$start_ts);
+ $year = date('Y',$start_ts);
+ $start_date = $year.'-'.$month.'-1';
+ $end_date = $year.'-'.$month.'-'.getLastDayOfMonth($month,$year);
+ }
+
+ if ($event_calendar_first_date && ($start_date < $event_calendar_first_date)) {
+ $start_date = $event_calendar_first_date;
+ }
+
+ if ($event_calendar_last_date && ($end_date > $event_calendar_last_date)) {
+ $end_date = $event_calendar_last_date;
+ }
+
+ $start_ts = strtotime($start_date);
+
+ if ($mode == "day") {
+ $end_ts = strtotime($end_date)+$day-1;
+ $subtitle = elgg_echo('event_calendar:day_label').': '.date('j F Y',strtotime($start_date));
+ } else if ($mode == "week") {
+ // KJ - fix for end date bug
+ //$end_ts = $start_ts + 6*$day;
+ $end_ts = $start_ts + 7*$day;
+ $subtitle = elgg_echo('event_calendar:week_label').': '.date('j F',$start_ts) . ' - '.date('j F Y',$end_ts);
+ } else {
+ // KJ - fix for end date bug
+ //$end_ts = strtotime($end_date);
+ $end_ts = strtotime($end_date)+24*60*60-1;
+ $subtitle = date('F Y',$start_ts);
+ }
+ }
+
+ $current_user_guid = elgg_get_logged_in_user_guid();
+
+ $access_status = elgg_get_ignore_access();
+
+ if ($page_type == 'owner') {
+ $container = get_entity($container_guid);
+ if (elgg_instanceof($container, 'user')) {
+ $auth_token = get_input('auth_token');
+ if ($auth_token) {
+ $secret_key = event_calendar_get_secret_key();
+ if ($secret_key && ($auth_token === sha1($container->username . $secret_key))) {
+ elgg_set_ignore_access(TRUE);
+ }
+ }
+ if ($container->canEdit()) {
+ $user_guid = $container_guid;
+ $group_guid = 0;
+ } else {
+ register_error('event_calendar:owner:permissions_error');
+ forward();
+ exit;
+ }
+ } else {
+ register_error('event_calendar:owner:permissions_error');
+ forward();
+ exit;
+ }
+ } else {
+ $user_guid = $current_user_guid;
+ $group_guid = $container_guid;
+ }
+
+ $offset = get_input('offset');
+ $limit = get_input('limit',15);
+
+ if ($event_calendar_spots_display == 'yes') {
+ if (!$filter) {
+ $filter = 'open';
+ }
+ } else {
+ if (!$filter) {
+ $filter = 'all';
+ }
+ }
+
+ if ($filter == 'all') {
+ $count = event_calendar_get_events_between($start_ts,$end_ts,true,$limit,$offset,$container_guid,$region);
+ $events = event_calendar_get_events_between($start_ts,$end_ts,false,$limit,$offset,$container_guid,$region);
+ } else if ($filter == 'open') {
+ $count = event_calendar_get_open_events_between($start_ts,$end_ts,true,$limit,$offset,$container_guid,$region);
+ $events = event_calendar_get_open_events_between($start_ts,$end_ts,false,$limit,$offset,$container_guid,$region);
+ } else if ($filter == 'friends') {
+ $count = event_calendar_get_events_for_friends_between($start_ts,$end_ts,true,$limit,$offset,$user_guid,$container_guid,$region);
+ $events = event_calendar_get_events_for_friends_between($start_ts,$end_ts,false,$limit,$offset,$user_guid,$container_guid,$region);
+ } else if ($filter == 'mine') {
+ $count = event_calendar_get_events_for_user_between2($start_ts,$end_ts,true,$limit,$offset,$user_guid,$container_guid,$region);
+ $events = event_calendar_get_events_for_user_between2($start_ts,$end_ts,false,$limit,$offset,$user_guid,$container_guid,$region);
+ }
+
+ $vars = array(
+ 'original_start_date' => $original_start_date,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date,
+ 'first_date' => $event_calendar_first_date,
+ 'last_date' => $event_calendar_last_date,
+ 'mode' => $mode,
+ 'events' => $events,
+ 'count' => $count,
+ 'offset' => $offset,
+ 'limit' => $limit,
+ 'group_guid' => $group_guid,
+ 'filter' => $filter,
+ 'region' => $region,
+ 'listing_format' => $event_calendar_listing_format,
+ );
+
+ $content = elgg_view('event_calendar/show_events', $vars);
+ if ($page_type == 'group') {
+ $filter_override = '';
+ } else {
+ $filter_override = elgg_view('event_calendar/filter_menu',$vars);
+ }
+
+ if ($event_calendar_listing_format == 'paged') {
+ $title = elgg_echo('event_calendar:upcoming_events_title');
+ } else if ($event_calendar_listing_format == 'full') {
+ $title = elgg_echo('event_calendar:show_events_title');
+ } else if ($page_type == 'group') {
+ $title = elgg_echo('event_calendar:group'). ' ('.$subtitle.')';
+ } else {
+ $title = elgg_echo('event_calendar:listing_title:'.$filter). ' ('.$subtitle.')';
+ }
+
+ $params = array('title' => $title, 'content' => $content, 'filter_override'=>$filter_override);
+ elgg_set_ignore_access($access_status);
+ return $params;
+}
+
+function event_calendar_get_page_content_view($event_guid,$light_box = FALSE) {
+ // add personal calendar button and links
+ elgg_push_context('event_calendar:view');
+ $event = get_entity($event_guid);
+
+ if (!elgg_instanceof($event, 'object', 'event_calendar')) {
+ $content = elgg_echo('event_calendar:error_nosuchevent');
+ $title = elgg_echo('event_calendar:generic_error_title');
+ } else {
+ $title = htmlspecialchars($event->title);
+ $event_container = get_entity($event->container_guid);
+ if (elgg_instanceof($event_container, 'group')) {
+ if ($event_container->canEdit()) {
+ event_calendar_handle_menu($event_guid);
+ }
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
+ } else {
+ if ($event->canEdit()) {
+ event_calendar_handle_menu($event_guid);
+ }
+ elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
+ }
+
+ elgg_push_breadcrumb($event->title);
+ $content = elgg_view_entity($event, array('full_view' => true,'light_box'=>$light_box));
+ //check to see if comment are on - TODO - add this feature to all events
+ if ($event->comments_on != 'Off') {
+ $content .= elgg_view_comments($event);
+ }
+ }
+
+ if ($light_box) {
+ return '<div class="event-calendar-lightbox">'.elgg_view_title($title).$content.'</div>';
+ } else {
+ $params = array('title' => $title, 'content' => $content,'filter' => '');
+
+ $body = elgg_view_layout("content", $params);
+
+ return elgg_view_page($title,$body);
+ }
+}
+
+function event_calendar_get_page_content_display_users($event_guid) {
+ elgg_load_js('elgg.event_calendar');
+ $event = get_entity($event_guid);
+
+ if (!elgg_instanceof($event, 'object', 'event_calendar')) {
+ $content = elgg_echo('event_calendar:error_nosuchevent');
+ $title = elgg_echo('event_calendar:generic_error_title');
+ } else {
+ event_calendar_handle_menu($event_guid);
+ $title = elgg_echo('event_calendar:users_for_event_title',array(htmlspecialchars($event->title)));
+ $event_container = get_entity($event->container_guid);
+ if (elgg_instanceof($event_container, 'group')) {
+ elgg_push_context('groups');
+ elgg_set_page_owner_guid($event->container_guid);
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
+ } else {
+ elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
+ }
+ elgg_push_breadcrumb($event->title,$event->getURL());
+ elgg_push_breadcrumb(elgg_echo('event_calendar:users_for_event_breadcrumb'));
+ $limit = 12;
+ $offset = get_input('offset', 0);
+ $users = event_calendar_get_users_for_event($event_guid,$limit,$offset,false);
+ $options = array(
+ 'full_view' => FALSE,
+ 'list_type_toggle' => FALSE,
+ 'limit'=>$limit,
+ 'event_calendar_event'=>$event,
+ );
+ elgg_extend_view('user/default','event_calendar/calendar_toggle');
+ $content = elgg_view_entity_list($users,$options);
+ }
+ $params = array('title' => $title, 'content' => $content,'filter' => '');
+
+ $body = elgg_view_layout("content", $params);
+
+ return elgg_view_page($title,$body);
+}
+
+// display a list of all the members of the container of $event_guid and allowing
+// adding or removing them
+
+function event_calendar_get_page_content_manage_users($event_guid) {
+ // TODO: make this an optional feature, toggled off
+ elgg_load_js('elgg.event_calendar');
+ $event = get_entity($event_guid);
+ $limit = 10;
+ $offset = get_input('offset', 0);
+
+ $event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+ if ($event_calendar_add_users != 'yes') {
+ register_error(elgg_echo('event_calendar:feature_not_activated'));
+ forward();
+ exit;
+ }
+
+ if (!elgg_instanceof($event, 'object', 'event_calendar')) {
+ $content = elgg_echo('event_calendar:error_nosuchevent');
+ $title = elgg_echo('event_calendar:generic_error_title');
+ } else {
+ event_calendar_handle_menu($event_guid);
+ $title = elgg_echo('event_calendar:manage_users:title',array($event->title));
+ $event_container = get_entity($event->container_guid);
+ if ($event_container->canEdit()) {
+ if (elgg_instanceof($event_container, 'group')) {
+ elgg_push_context('groups');
+ elgg_set_page_owner_guid($event->container_guid);
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
+ elgg_register_menu_item('title', array(
+ 'name' => 'remove_from_group_members',
+ 'href' => elgg_add_action_tokens_to_url('action/event_calendar/remove_from_group_members?event_guid='.$event_guid),
+ 'text' => elgg_echo('event_calendar:remove_from_group_members:button'),
+ 'class' => 'elgg-button elgg-button-action',
+ ));
+ elgg_register_menu_item('title', array(
+ 'name' => 'add_to_group_members',
+ 'href' => elgg_add_action_tokens_to_url('action/event_calendar/add_to_group_members?event_guid='.$event_guid),
+ 'text' => elgg_echo('event_calendar:add_to_group_members:button'),
+ 'class' => 'elgg-button elgg-button-action',
+ ));
+ $users = $event_container->getMembers($limit,$offset);
+ $count = $event_container->getMembers($limit,$offset,TRUE);
+ elgg_extend_view('user/default','event_calendar/calendar_toggle');
+ $options = array(
+ 'full_view' => FALSE,
+ 'list_type_toggle' => FALSE,
+ 'limit'=>$limit,
+ 'event_calendar_event'=>$event,
+ 'pagination' => TRUE,
+ 'count'=>$count,
+ );
+ $content .= elgg_view_entity_list($users,$options,$offset,$limit);
+ } else {
+ elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
+ $content = '<p>'.elgg_echo('event_calendar:manage_users:description').'</p>';
+ $content .= elgg_view_form('event_calendar/manage_subscribers',array(),array('event'=>$event));
+ }
+ elgg_push_breadcrumb($event->title,$event->getURL());
+ elgg_push_breadcrumb(elgg_echo('event_calendar:manage_users:breadcrumb'));
+
+ } else {
+ $content = elgg_echo('event_calendar:manage_users:unauthorized');
+ }
+ }
+ $params = array('title' => $title, 'content' => $content,'filter' => '');
+
+ $body = elgg_view_layout("content", $params);
+
+ return elgg_view_page($title,$body);
+}
+
+function event_calendar_get_page_content_review_requests($event_guid) {
+ $event = get_entity($event_guid);
+
+ if (!elgg_instanceof($event, 'object', 'event_calendar')) {
+ $content = elgg_echo('event_calendar:error_nosuchevent');
+ $title = elgg_echo('event_calendar:generic_error_title');
+ } else {
+ event_calendar_handle_menu($event_guid);
+ $title = elgg_echo('event_calendar:review_requests_title',array(htmlspecialchars($event->title)));
+ $event_container = get_entity($event->container_guid);
+ if (elgg_instanceof($event_container, 'group')) {
+ elgg_push_context('groups');
+ elgg_set_page_owner_guid($event->container_guid);
+ elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
+ } else {
+ elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
+ }
+ elgg_push_breadcrumb($event->title,$event->getURL());
+ elgg_push_breadcrumb(elgg_echo('event_calendar:review_requests_menu_title'));
+
+ if ($event->canEdit()) {
+ $requests = elgg_get_entities_from_relationship(
+ array(
+ 'relationship' => 'event_calendar_request',
+ 'relationship_guid' => $event_guid,
+ 'inverse_relationship' => TRUE,
+ 'limit' => 0)
+ );
+ if ($requests) {
+ $content = elgg_view('event_calendar/review_requests',array('requests' => $requests, 'entity' => $event));
+ } else {
+ $content = elgg_echo('event_calendar:review_requests_request_none');
+ }
+ } else {
+ $content = elgg_echo('event_calendar:review_requests_error');
+ }
+ }
+ $params = array('title' => $title, 'content' => $content,'filter' => '');
+
+ $body = elgg_view_layout("content", $params);
+
+ return elgg_view_page($title,$body);
+}
+
+function event_calendar_handle_menu($event_guid) {
+ $event = get_entity($event_guid);
+ $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
+ if ((($event_calendar_personal_manage == 'by_event') && ($event->personal_manage == 'closed'))
+ || (($event_calendar_personal_manage == 'closed') || ($event_calendar_personal_manage == 'no'))) {
+ $url = "event_calendar/review_requests/$event_guid";
+ $item = new ElggMenuItem('event-calendar-0review_requests', elgg_echo('event_calendar:review_requests_menu_title'), $url);
+ $item->setSection('event_calendar');
+ elgg_register_menu_item('page', $item);
+ //elgg_register_menu_item(elgg_echo('event_calendar:review_requests_title'), $CONFIG->wwwroot . "pg/event_calendar/review_requests/".$event_id, '0eventcalendaradmin');
+ }
+ $event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+ if ($event_calendar_add_users == 'yes') {
+ $url = "event_calendar/manage_users/$event_guid";
+ $item = new ElggMenuItem('event-calendar-1manage_users', elgg_echo('event_calendar:manage_users:breadcrumb'), $url);
+ $item->setSection('event_calendar');
+ elgg_register_menu_item('page', $item);
+ }
+}
+function event_calendar_get_secret_key() {
+ $key_file_name = elgg_get_plugin_setting('ical_auth_file_name','event_calendar');
+ if ($key_file_name && file_exists($key_file_name)) {
+ $key = (require($key_file_name));
+
+ return $key['tokenSecretKey'];
+ } else {
+ return FALSE;
+ }
+}
+
+function getLastDayOfMonth($month,$year) {
+ return idate('d', mktime(0, 0, 0, ($month + 1), 0, $year));
+}
+
+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()) {
+ 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;
+ }
+ }
+ $dow = array('monday','tuesday','wednesday','thursday','friday','saturday','sunday');
+ $week_repeats = array();
+ $weekday_delta = (($day_delta % 7) + 7) % 7; // Imagine delta is -12: ((-12 % 7) + 7 % 7) = +2 (thursdays are saturdays)
+ foreach ($dow as $i => $w) {
+ $v = 'event-calendar-repeating-'.$w.'-value';
+ $new_day = $dow[($i+$weekday_delta)%7];
+ $week_repeats[$new_day] = $event->$v;
+ }
+ foreach ($week_repeats as $w => $value) {
+ $v = 'event-calendar-repeating-'.$w.'-value';
+ $event->$v = $value;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+function event_calendar_get_page_content_fullcalendar_events($start_date,$end_date,$filter='all',$container_guid=0,$region='-') {
+ //print "$start_date - $end_date";
+ $start_ts = strtotime($start_date);
+ $end_ts = strtotime($end_date);
+ if ($filter == 'all') {
+ $events = event_calendar_get_events_between($start_ts,$end_ts,false,0,0,$container_guid,$region);
+ } else if ($filter == 'open') {
+ $events = event_calendar_get_open_events_between($start_ts,$end_ts,false,0,0,$container_guid,$region);
+ } else if ($filter == 'friends') {
+ $user_guid = elgg_get_logged_in_user_guid();
+ $events = event_calendar_get_events_for_friends_between($start_ts,$end_ts,false,0,0,$user_guid,$container_guid,$region);
+ } else if ($filter == 'mine') {
+ $user_guid = elgg_get_logged_in_user_guid();
+ $events = event_calendar_get_events_for_user_between2($start_ts,$end_ts,false,0,0,$user_guid,$container_guid,$region);
+ }
+ $event_array = array();
+ $times_supported = elgg_get_plugin_setting('times','event_calendar') != 'no';
+ $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(
+ 'guid' => $event->guid,
+ 'title' => $event->title,
+ 'start' => date('c',$ed['start_time']),
+ 'end' => date('c',$ed['end_time']),
+ );
+ 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_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/'.$event->guid;
+ }
+
+ $event_array[] = $event_item;
+ }
+ }
+
+ $json_events_string = json_encode($event_array);
+ return $json_events_string;
+}
+
+// right now this does not return repeated events in sorted order, so repeated events only really work properly for the full calendar
+// TODO: find another solution for displaying repeated events
+
+function event_calendar_flatten_event_structure($events) {
+ $flattened = array();
+ $guids = array();
+ foreach($events as $e) {
+ $this_event = $e['event'];
+ $guid = $this_event->guid;
+ if (!in_array($guid,$guids)) {
+ $guids[] = $guid;
+ $flattened[] = $this_event;
+ }
+ }
+ return $flattened;
+}
+
+function event_calendar_queue_reminders() {
+ // game plan - get all events up to 60 days ahead
+ // with no reminder sent
+ // compute reminder period
+ // if <= current time, set reminder_queued flag and queue the
+ // notification message using the message_queue plugin
+ if (elgg_plugin_exists('message_queue')) {
+ $now = time();
+ // oops - this does not work for repeated events
+ // need extra stuff for that
+ /*$options = array(
+ 'type' => 'object',
+ 'subtype' => 'event_calendar',
+ 'metadata_name_value_pairs' => array(
+ array('name' => 'reminder_queued', 'value' => 'no'),
+ array('name' => 'send_reminder', 'value' => 1),
+ array('name' => 'start_date', 'value' => $now + 60*24*60*60, 'operand' => '>='),
+ ),
+ 'limit' => 0,
+ );
+ $events = elgg_get_entities_from_metadata($options);
+ */
+ $event_list = event_calendar_get_events_between($now,$now + 60*24*60*60,FALSE,0);
+
+ foreach($event_list as $es) {
+ $e = $es['event'];
+ if ($e->send_reminder) {
+ $reminder_period = 60*$e->reminder_interval*$e->reminder_number;
+ if ($e->repeats) {
+ // repeated events require more complex handing
+ foreach($es['data'] as $d) {
+ // if event falls in the reminder period
+ if ($d->start_time - $reminder_period >= $now) {
+ // and the reminder has not already been queued
+ if (!event_calendar_repeat_reminder_logged($e,$d->start_time)) {
+ // set the reminder queued flag
+ event_calendar_repeat_reminder_log($e,$d->start_time);
+ // queue the reminder for sending
+ event_calendar_queue_reminder($e);
+ }
+ break;
+ }
+ }
+ } else {
+ // if this is just a normal non-repeated event, then we just need to set a flag and queue the reminder
+ if (($e->reminder_queued != 'yes') && ($e->start_date - $now <= $reminder_period)) {
+ $e->reminder_queued = 'yes';
+ event_calendar_queue_reminder($e);
+ }
+ }
+ }
+ }
+ }
+}
+
+function event_calendar_repeat_reminder_log($e,$start) {
+ // this simple log just uses annotations on the event
+ // TODO - remove log entries for past events
+ create_annotation($e->guid, 'repeat_reminder_log_item', $start, '',0,ACCESS_PUBLIC);
+}
+
+function event_calendar_repeat_reminder_logged($e,$start) {
+ $options = array(
+ 'guid' => $e->guid,
+ 'annotation_name' => 'repeat_reminder_log_item',
+ 'annotation_value' => $start,
+ 'limit' => 1
+ );
+
+ if (elgg_get_annotations($options)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+function event_calendar_queue_reminder($e) {
+ elgg_load_library('elgg:message_queue');
+ $subject = elgg_echo('event_calendar:reminder:subject',array($e->title));
+ $time_string = event_calendar_get_formatted_time($e);
+ $body = elgg_echo('event_calendar:reminder:body',array($e->title,$time_string,$e->getURL()));
+ $m = message_queue_create_message($subject,$body);
+ if ($m) {
+ $users = event_calendar_get_users_for_event($e->guid,0);
+ foreach($users as $u) {
+ message_queue_add($m->guid,$u->guid);
+ }
+ message_queue_set_for_sending($m->guid);
+ }
+}
+
+/*function event_calendar_create_bbb_conf($event) {
+ $bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt','event_calendar');
+ $bbb_server_url = rtrim(elgg_get_plugin_setting('bbb_server_url','event_calendar'), '/') . '/';
+ if ($bbb_security_salt) {
+ $day_in_minutes = 60*24;
+ $now = time();
+ // fix duration bug
+ # $duration = (int)(($event->real_end_time-$event->start_date)/60)+$day_in_minutes;
+ $duration = (int)(($event->real_end_time-$now)/60)+$day_in_minutes;
+ $title = urlencode($event->title);
+ $params = "name=$title&meetingID={$event->guid}&duration=$duration";
+ $checksum = sha1('create'.$params.$bbb_security_salt);
+ $params .= "&checksum=$checksum";
+
+ // create curl resource
+ $ch = curl_init();
+
+ // set url
+ curl_setopt($ch, CURLOPT_URL, $bbb_server_url.'api/create?'.$params);
+
+ //return the transfer as a string
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ // $output contains the output string
+ $output = curl_exec($ch);
+
+ // close curl resource to free up system resources
+ curl_close($ch);
+
+ #error_log("BBB create request:");
+ #error_log($bbb_server_url.'api/create?'.$params);
+
+ #error_log("BBB create response:");
+ #error_log($output);
+
+ $xml = new SimpleXMLElement($output);
+ if ($xml->returncode == 'SUCCESS') {
+ $event->bbb_attendee_password = (string) $xml->attendeePW;
+ $event->bbb_moderator_password = (string) $xml->moderatorPW;
+ } else {
+ register_error(elgg_echo('event_calendar:bbb_create_error',array($xml->message)));
+ }
+ } else {
+ register_error(elgg_echo('event_calendar:bbb_settings_error'));
+ }
+}*/
+
+// utility function for BBB api calls
+function event_calendar_bbb_api($api_function,$params=NULL) {
+
+ $bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt','event_calendar');
+ $bbb_server_url = rtrim(elgg_get_plugin_setting('bbb_server_url','event_calendar'), '/') . '/';
+ if ($bbb_security_salt) {
+ if (isset($params) && is_array($params) && count($params) > 0) {
+ $query = array();
+ foreach($params as $k => $v) {
+ $query[] = $k.'='.rawurlencode($v);
+ }
+ $qs = implode('&',$query);
+ } else {
+ $qs = '';
+ }
+ $checksum = sha1($api_function.$qs.$bbb_security_salt);
+ if ($qs) {
+ $qs .= "&checksum=$checksum";
+ }
+
+ // create curl resource
+ $ch = curl_init();
+
+ // set url
+ curl_setopt($ch, CURLOPT_URL, $bbb_server_url.'api/'.$api_function.'?'.$qs);
+
+ //return the transfer as a string
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+ // $output contains the output string
+ $output = curl_exec($ch);
+
+ // close curl resource to free up system resources
+ curl_close($ch);
+
+ error_log("BBB api call: ".$api_function);
+ error_log(print_r($params,TRUE));
+ error_log("BBB response: \n".$output);
+ return $output;
+ } else {
+ return FALSE;
+ }
+}
+
+function event_calendar_create_bbb_conf($event) {
+ $day_in_minutes = 60*24;
+ $now = time();
+ // fix duration bug
+ # $duration = (int)(($event->real_end_time-$event->start_date)/60)+$day_in_minutes;
+ $duration = (int)(($event->real_end_time-$now)/60)+$day_in_minutes;
+ if ($duration > 0) {
+ $title = urlencode($event->title);
+ $output = event_calendar_bbb_api('create',array('meetingID'=>$event->guid,'name'=>$title,'duration'=>$duration));
+ if ($output) {
+ $xml = new SimpleXMLElement($output);
+ if ($xml->returncode == 'SUCCESS') {
+ $event->bbb_attendee_password = (string) $xml->attendeePW;
+ $event->bbb_moderator_password = (string) $xml->moderatorPW;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
+// checks to see if a BBB conference is actually running
+function event_calendar_is_conference_running($event) {
+ $output = event_calendar_bbb_api('isMeetingRunning',array('meetingID'=>$event->guid));
+ if (!$output) {
+ return FALSE;
+ } else {
+ $xml = new SimpleXMLElement($output);
+ if ($xml->returncode == 'SUCCESS' && $xml->running == 'true') {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+}
+
+// checks to see if a BBB conference exists
+function event_calendar_conference_exists($event) {
+ $output = event_calendar_bbb_api('getMeetingInfo',array('meetingID'=>$event->guid,'password'=>$event->bbb_moderator_password));
+ if (!$output) {
+ return FALSE;
+ } else {
+ $xml = new SimpleXMLElement($output);
+ if ($xml->returncode == 'SUCCESS' && $xml->meetingID == $event->guid) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+}
+
+// forwards to the join link
+// this function assumes that the conference is running
+function event_calendar_join_conference($event) {
+ forward(event_calendar_get_join_bbb_url($event));
+}
+
+function event_calendar_get_join_bbb_url($event) {
+ $bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt','event_calendar');
+ $bbb_server_url = rtrim(elgg_get_plugin_setting('bbb_server_url','event_calendar'), '/') . '/';
+ $user = elgg_get_logged_in_user_entity();
+ $full_name = urlencode($user->name);
+ if ($event->canEdit()) {
+ $password = urlencode($event->bbb_moderator_password);
+ } else {
+ $password = urlencode($event->bbb_attendee_password);
+ }
+ $params = "fullName=$full_name&meetingID={$event->guid}&userID={$user->username}&password=$password";
+ $checksum = sha1('join'.$params.$bbb_security_salt);
+ $params .= "&checksum=$checksum";
+ $url = $bbb_server_url.'api/join?'.$params;
+ 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/mod/event_calendar/start.php b/mod/event_calendar/start.php
new file mode 100644
index 000000000..954c3400a
--- /dev/null
+++ b/mod/event_calendar/start.php
@@ -0,0 +1,414 @@
+<?php
+
+/**
+ * Event calendar plugin
+ *
+ * @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-2011
+ * @link http://radagast.biz/
+ */
+
+
+elgg_register_event_handler('init','system','event_calendar_init');
+
+function event_calendar_init() {
+
+ elgg_register_library('elgg:event_calendar', elgg_get_plugins_path() . 'event_calendar/models/model.php');
+
+ elgg_register_plugin_hook_handler('cron', 'fiveminute', 'event_calendar_handle_reminders_cron',400);
+
+ // Register a page handler, so we can have nice URLs
+ elgg_register_page_handler('event_calendar','event_calendar_page_handler');
+
+ // Register URL handler
+ elgg_register_entity_url_handler('object', 'event_calendar','event_calendar_url');
+
+ // Register granular notification for this type
+ register_notification_object('object', 'event_calendar', elgg_echo('event_calendar:new_event'));
+
+ elgg_extend_view('css/elements/forms', 'css/elements/forms/datepicker_multi');
+
+ // Set up site menu
+ $site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
+ if (!$site_calendar || $site_calendar != 'no') {
+ // add a site navigation item
+ $item = new ElggMenuItem('event_calendar', elgg_echo('item:object:event_calendar'), 'event_calendar/list/');
+ elgg_register_menu_item('site', $item);
+ }
+ // make event calendar title and description searchable
+ elgg_register_entity_type('object','event_calendar');
+
+ // make legacy tags searchable
+ if (function_exists('elgg_register_tag_metadata_name')) {
+ elgg_register_tag_metadata_name('event_tags');
+ }
+
+ // register the plugin's JavaScript
+ $plugin_js = elgg_get_simplecache_url('js', 'event_calendar/event_calendar');
+ elgg_register_js('elgg.event_calendar', $plugin_js);
+
+ //add to group profile page
+ // TODO - are the left and right values still relevant for Elgg 1.8?
+ $group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
+ if (!$group_calendar || $group_calendar != 'no') {
+ elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'event_calendar_owner_block_menu');
+ $group_profile_display = elgg_get_plugin_setting('group_profile_display', 'event_calendar');
+ if (!$group_profile_display || $group_profile_display == 'right') {
+ //elgg_extend_view('groups/right_column', 'event_calendar/groupprofile_calendar');
+ elgg_extend_view('groups/tool_latest', 'event_calendar/group_module');
+ } else if ($group_profile_display == 'left') {
+ elgg_extend_view('groups/tool_latest', 'event_calendar/group_module');
+ //elgg_extend_view('groups/left_column', 'event_calendar/groupprofile_calendar');
+ }
+ }
+
+ //add to the css
+ elgg_extend_view('css/elgg', 'event_calendar/css');
+
+ $event_calendar_listing_format = elgg_get_plugin_setting('listing_format', 'event_calendar');
+ 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);
+ }
+
+ //add a widget
+ elgg_register_widget_type('event_calendar',elgg_echo("event_calendar:widget_title"),elgg_echo('event_calendar:widget:description'),array('all','dashboard'));
+
+ // add the event calendar group tool option
+ $event_calendar_group_default = elgg_get_plugin_setting('group_default', 'event_calendar');
+ if (!$event_calendar_group_default || ($event_calendar_group_default == 'yes')) {
+ add_group_tool_option('event_calendar',elgg_echo('event_calendar:enable_event_calendar'),true);
+ } else {
+ add_group_tool_option('event_calendar',elgg_echo('event_calendar:enable_event_calendar'),false);
+ }
+
+ // if autogroup is set, listen and respond to join/leave events
+ if (elgg_get_plugin_setting('autogroup', 'event_calendar') == 'yes') {
+ elgg_register_event_handler('join', 'group', 'event_calendar_handle_join');
+ elgg_register_event_handler('leave', 'group', 'event_calendar_handle_leave');
+ }
+
+ // entity menu
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'event_calendar_entity_menu_setup');
+ elgg_register_plugin_hook_handler('prepare', 'menu:entity', 'event_calendar_entity_menu_prepare');
+
+ // register actions
+ $action_path = elgg_get_plugins_path() . 'event_calendar/actions/event_calendar';
+
+ elgg_register_action("event_calendar/edit","$action_path/edit.php");
+ elgg_register_action("event_calendar/delete","$action_path/delete.php");
+ elgg_register_action("event_calendar/add_personal","$action_path/add_personal.php");
+ elgg_register_action("event_calendar/remove_personal","$action_path/remove_personal.php");
+ elgg_register_action("event_calendar/request_personal_calendar","$action_path/request_personal_calendar.php");
+ elgg_register_action("event_calendar/toggle_personal_calendar","$action_path/toggle_personal_calendar.php");
+ elgg_register_action("event_calendar/killrequest","$action_path/killrequest.php");
+ elgg_register_action("event_calendar/addtocalendar","$action_path/addtocalendar.php");
+ elgg_register_action("event_calendar/add_to_group","$action_path/add_to_group.php");
+ elgg_register_action("event_calendar/remove_from_group","$action_path/remove_from_group.php");
+ elgg_register_action("event_calendar/add_to_group_members","$action_path/add_to_group_members.php");
+ elgg_register_action("event_calendar/remove_from_group_members","$action_path/remove_from_group_members.php");
+ elgg_register_action("event_calendar/manage_subscribers","$action_path/manage_subscribers.php");
+ elgg_register_action("event_calendar/modify_full_calendar","$action_path/modify_full_calendar.php");
+ elgg_register_action("event_calendar/join_conference","$action_path/join_conference.php");
+}
+
+/**
+ * Add a menu item to an ownerblock
+ */
+function event_calendar_owner_block_menu($hook, $type, $return, $params) {
+ elgg_load_library('elgg:event_calendar');
+ if (elgg_instanceof($params['entity'], 'group')) {
+ if (event_calendar_activated_for_group($params['entity'])) {
+ $url = "event_calendar/group/{$params['entity']->guid}";
+ $item = new ElggMenuItem('event_calendar', elgg_echo('event_calendar:group'), $url);
+ $return[] = $item;
+ }
+ }
+
+ return $return;
+}
+
+function event_calendar_url($entity) {
+ $friendly_title = elgg_get_friendly_title($entity->title);
+ return "event_calendar/view/{$entity->guid}/$friendly_title";
+}
+
+/**
+ * Dispatches event calendar pages.
+ *
+ * URLs take the form of
+ * Site event calendar: event_calendar/list/<start_date>/<display_mode>/<filter_context>/<region>
+ * Single event: event_calendar/view/<event_guid>/<title>
+ * New event: event_calendar/add
+ * Edit event: event_calendar/edit/<event_guid>
+ * Group event calendar: event_calendar/group/<group_guid>/<start_date>/<display_mode>/<filter_context>/<region>
+ * Add group event: event_calendar/add/<group_guid>
+ * Review requests: event_calendar/review_requests/<event_guid>
+ * Display event subscribers: event_calendar/display_users/<event_guid>
+ * Events for a user's calendar: event_calendar/owner/<username>/<start_date>/<display_mode>/<filter_context>/<region>
+ *
+ * Title is ignored
+ *
+ * @param array $page
+ * @return NULL
+ */
+function event_calendar_page_handler($page) {
+
+ elgg_load_library('elgg:event_calendar');
+ $page_type = $page[0];
+ switch ($page_type) {
+ case 'list':
+ if (isset($page[1])) {
+ $start_date = $page[1];
+ if (isset($page[2])) {
+ $display_mode = $page[2];
+ if (isset($page[3])) {
+ $filter_mode = $page[3];
+ if (isset($page[4])) {
+ $region = $page[4];
+ } else {
+ $region = '';
+ }
+ } else {
+ $filter_mode = '';
+ }
+ } else {
+ $display_mode = '';
+ }
+ } else {
+ $start_date = 0;
+ }
+ echo event_calendar_get_page_content_list($page_type,0,$start_date,$display_mode,$filter_mode,$region);
+ break;
+ case 'view':
+ echo event_calendar_get_page_content_view($page[1]);
+ break;
+ case 'display_users':
+ echo event_calendar_get_page_content_display_users($page[1]);
+ break;
+ case 'manage_users':
+ echo event_calendar_get_page_content_manage_users($page[1]);
+ break;
+ case 'schedule':
+ case 'add':
+ if (isset($page[1])) {
+ group_gatekeeper();
+ $group_guid = $page[1];
+ } else {
+ gatekeeper();
+ $group_guid = 0;
+ }
+ echo event_calendar_get_page_content_edit($page_type,$group_guid,$page[2]);
+ break;
+ case 'edit':
+ gatekeeper();
+ echo event_calendar_get_page_content_edit($page_type, $page[1]);
+ break;
+ case 'group':
+ group_gatekeeper();
+ if (isset($page[1])) {
+ $group_guid = $page[1];
+ if (isset($page[2])) {
+ $start_date = $page[2];
+ if (isset($page[3])) {
+ $display_mode = $page[3];
+ if (isset($page[4])) {
+ $filter_mode = $page[4];
+ if (isset($page[5])) {
+ $region = $page[5];
+ } else {
+ $region = '';
+ }
+ } else {
+ $filter_mode = '';
+ }
+ } else {
+ $display_mode = '';
+ }
+ } else {
+ $start_date = '';
+ }
+ } else {
+ $group_guid = 0;
+ }
+ echo event_calendar_get_page_content_list($page_type,$group_guid,$start_date,$display_mode,$filter_mode,$region);
+ break;
+ case 'owner':
+ if (isset($page[1])) {
+ $username = $page[1];
+ $user = get_user_by_username($username);
+ $user_guid = $user->guid;
+ if (isset($page[2])) {
+ $start_date = $page[2];
+ if (isset($page[3])) {
+ $display_mode = $page[3];
+ if (isset($page[4])) {
+ $filter_mode = $page[4];
+ if (isset($page[5])) {
+ $region = $page[5];
+ } else {
+ $region = '';
+ }
+ } else {
+ $filter_mode = '';
+ }
+ } else {
+ $display_mode = '';
+ }
+ } else {
+ $start_date = '';
+ }
+ } else {
+ $group_guid = 0;
+ }
+ echo event_calendar_get_page_content_list($page_type,$user_guid,$start_date,$display_mode,$filter_mode,$region);
+ break;
+ case 'review_requests':
+ gatekeeper();
+ echo event_calendar_get_page_content_review_requests($page[1]);
+ break;
+ case 'get_fullcalendar_events':
+ echo event_calendar_get_page_content_fullcalendar_events($page[1],$page[2],$page[3],$page[4]);
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * Add particular event calendar links/info to entity menu
+ */
+function event_calendar_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'event_calendar') {
+ return $return;
+ }
+ if (elgg_is_active_plugin('event_poll') && $entity->canEdit() && $entity->schedule_type == 'poll') {
+ $options = array(
+ 'name' => 'schedule',
+ 'text' => elgg_echo('event_poll:schedule_button'),
+ 'title' => elgg_echo('event_poll:schedule_button'),
+ 'href' => 'event_poll/vote/'.$entity->guid,
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+ $user_guid = elgg_get_logged_in_user_guid();
+ if ($user_guid) {
+ $calendar_status = event_calendar_personal_can_manage($entity,$user_guid);
+ if ($calendar_status == 'open') {
+ if (event_calendar_has_personal_event($entity->guid,$user_guid)) {
+ $options = array(
+ 'name' => 'personal_calendar',
+ 'text' => elgg_echo('event_calendar:remove_from_the_calendar_menu_text'),
+ 'title' => elgg_echo('event_calendar:remove_from_my_calendar'),
+ 'href' => elgg_add_action_tokens_to_url("action/event_calendar/remove_personal?guid={$entity->guid}"),
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ } else {
+ if (!event_calendar_is_full($entity->guid) && !event_calendar_has_collision($entity->guid,$user_guid)) {
+ $options = array(
+ 'name' => 'personal_calendar',
+ 'text' => elgg_echo('event_calendar:add_to_the_calendar_menu_text'),
+ 'title' => elgg_echo('event_calendar:add_to_my_calendar'),
+ 'href' => elgg_add_action_tokens_to_url("action/event_calendar/add_personal?guid={$entity->guid}"),
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options); }
+ }
+ } else if ($calendar_status == 'closed') {
+ if (!event_calendar_has_personal_event($entity->guid,$user_guid) && !check_entity_relationship($user_guid, 'event_calendar_request', $entity->guid)) {
+ $options = array(
+ 'name' => 'personal_calendar',
+ 'text' => elgg_echo('event_calendar:make_request_title'),
+ 'title' => elgg_echo('event_calendar:make_request_title'),
+ 'href' => elgg_add_action_tokens_to_url("action/event_calendar/request_personal_calendar?guid={$entity->guid}"),
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+ }
+ }
+
+ $count = event_calendar_get_users_for_event($entity->guid,0,0,true);
+ if ($count == 1) {
+ $calendar_text = elgg_echo('event_calendar:personal_event_calendars_link_one');
+ } else {
+ $calendar_text = elgg_echo('event_calendar:personal_event_calendars_link',array($count));
+ }
+
+ $options = array(
+ 'name' => 'calendar_listing',
+ 'text' => $calendar_text,
+ 'title' => elgg_echo('event_calendar:users_for_event_menu_title'),
+ 'href' => "event_calendar/display_users/{$entity->guid}",
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ /*if (elgg_is_admin_logged_in() && (elgg_get_plugin_setting('allow_featured', 'event_calendar') == 'yes')) {
+ if ($event->featured) {
+ elgg_register_menu_item(elgg_echo('event_calendar:unfeature'), $CONFIG->url . "action/event_calendar/unfeature?event_id=".$event_id.'&'.event_calendar_security_fields(), 'eventcalendaractions');
+ } else {
+ elgg_register_menu_item(elgg_echo('event_calendar:feature'), $CONFIG->url . "action/event_calendar/feature?event_id=".$event_id.'&'.event_calendar_security_fields(), 'eventcalendaractions');
+ }
+ }*/
+
+ return $return;
+}
+
+function event_calendar_entity_menu_prepare($hook, $type, $return, $params) {
+ // remove access level from listings
+ if (elgg_in_context('event_calendar') && !elgg_in_context('event_calendar:view')) {
+ $new_return = array();
+ if (isset($return['default']) && is_array($return['default'])) {
+ foreach($return['default'] AS $item) {
+ if ($item->getName() != 'access') {
+ $new_return[] = $item;
+ }
+ }
+ }
+ $return['default'] = $new_return;
+ }
+
+ return $return;
+}
+
+function event_calendar_handle_join($event, $object_type, $object) {
+ elgg_load_library('elgg:event_calendar');
+ $group = $object['group'];
+ $user = $object['user'];
+ $user_guid = $user->getGUID();
+ $events = event_calendar_get_events_for_group($group->getGUID());
+ foreach ($events as $event) {
+ $event_id = $event->getGUID();
+ event_calendar_add_personal_event($event_id,$user_guid);
+ }
+}
+
+function event_calendar_handle_leave($event, $object_type, $object) {
+ elgg_load_library('elgg:event_calendar');
+ $group = $object['group'];
+ $user = $object['user'];
+ $user_guid = $user->getGUID();
+ $events = event_calendar_get_events_for_group($group->getGUID());
+ foreach ($events as $event) {
+ $event_id = $event->getGUID();
+ event_calendar_remove_personal_event($event_id,$user_guid);
+ }
+}
+
+function event_calendar_handle_reminders_cron() {
+ elgg_load_library('elgg:event_calendar');
+ event_calendar_queue_reminders();
+}
diff --git a/mod/event_calendar/views/default/css/elements/forms/datepicker_multi.php b/mod/event_calendar/views/default/css/elements/forms/datepicker_multi.php
new file mode 100644
index 000000000..4a18bdad1
--- /dev/null
+++ b/mod/event_calendar/views/default/css/elements/forms/datepicker_multi.php
@@ -0,0 +1,39 @@
+<?php
+
+?>
+
+.ui-datepicker.ui-datepicker-multi {
+ width: auto;
+}
+.ui-datepicker-multi .ui-datepicker-group {
+ float: left;
+}
+.ui-datepicker-multi .ui-datepicker-group table {
+ margin-bottom: 0.4em;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 0;
+ width: 95%;
+}
+.ui-datepicker-multi-2 .ui-datepicker-group {
+ width: 50%;
+}
+.ui-datepicker-multi-3 .ui-datepicker-group {
+ width: 33.3%;
+}
+.ui-datepicker-multi-4 .ui-datepicker-group {
+ width: 25%;
+}
+.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header {
+ border-left-width-ltr-source: physical;
+ border-left-width-rtl-source: physical;
+ border-left-width-value: 0;
+}
+.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header {
+ border-left-width-ltr-source: physical;
+ border-left-width-rtl-source: physical;
+ border-left-width-value: 0;
+}
+.ui-datepicker-multi .ui-datepicker-buttonpane {
+ clear: left;
+}
diff --git a/mod/event_calendar/views/default/event_calendar/agenda_footer.php b/mod/event_calendar/views/default/event_calendar/agenda_footer.php
new file mode 100644
index 000000000..8749ebe08
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/agenda_footer.php
@@ -0,0 +1,5 @@
+<?php
+
+echo '</tbody></table></div>';
+
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/agenda_header.php b/mod/event_calendar/views/default/event_calendar/agenda_header.php
new file mode 100644
index 000000000..712dbed8d
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/agenda_header.php
@@ -0,0 +1,12 @@
+<?php
+
+$header .= '<div class="event_calendar_agenda_date_section">';
+$header .= '<div class="event_calendar_agenda_date">'.$vars['date'].'</div>';
+$header .= '<table><thead><tr>';
+$header .= '<th class="agenda_header">'.elgg_echo('event_calendar:agenda:column:time').'</th>';
+$header .= '<th class="agenda_header">'.elgg_echo('event_calendar:agenda:column:session').'</th>';
+$header .= '<th class="agenda_header">'.elgg_echo('event_calendar:agenda:column:venue').'</th>';
+$header .= '</td></thead><tbody>';
+
+echo $header;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/agenda_item_view.php b/mod/event_calendar/views/default/event_calendar/agenda_item_view.php
new file mode 100644
index 000000000..807982665
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/agenda_item_view.php
@@ -0,0 +1,26 @@
+<?php
+$event = $vars['event'];
+$times = $vars['times'];
+$time_bit = '';
+if ($times != 'no') {
+ if (is_numeric($event->start_time)) {
+ $time_bit = event_calendar_convert_time($event->start_time);
+ }
+ if (is_numeric($event->end_time)) {
+ $time_bit .= " - ".event_calendar_convert_time($event->end_time);
+ }
+ $time_bit .= ' ';
+}
+$info = '<tr>';
+$info .= '<td class="event_calendar_agenda_time">'.$time_bit.'</td>';
+$info .= '<td class="event_calendar_agenda_title"><a href="'.$event->getUrl().'">'.$event->title.'</a></td>';
+$info .= '<td class="event_calendar_agenda_venue">'.$event->venue.'</td>';
+$info .= '</tr>';
+if (trim($event->description)) {
+ $info .= '<tr class="event_calendar_agenda_description">';
+ $info .= '<td class="event_calendar_agenda_time">&nbsp;</td>';
+ $info .= '<td colspan="2">'.$event->description.'</td></tr>';
+}
+
+echo $info;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/agenda_view.php b/mod/event_calendar/views/default/event_calendar/agenda_view.php
new file mode 100644
index 000000000..05cdb6461
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/agenda_view.php
@@ -0,0 +1,34 @@
+<?php
+$nav = elgg_view('navigation/pagination',array(
+
+// 'baseurl' => $_SERVER['REQUEST_URI'],
+ 'baseurl' => $_SERVER['SCRIPT_NAME'].'/?'.$_SERVER['QUERY_STRING'],
+ 'offset' => $vars['offset'],
+ 'count' => $vars['count'],
+ 'limit' => $vars['limit'],
+
+ ));
+$event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar');
+$events = $vars['events'];
+$html = '';
+$date_format = 'j M Y';
+$current_date = '';
+if ($events) {
+ foreach($events as $event) {
+ $date = date($date_format,$event->start_date);
+ if ($date != $current_date) {
+ if ($html) {
+ $html .= elgg_view('event_calendar/agenda_footer');
+ }
+ $html .= elgg_view('event_calendar/agenda_header',array('date'=>$date));
+
+ $current_date = $date;
+ }
+ $html .= elgg_view('event_calendar/agenda_item_view',array('event'=>$event,'times'=>$event_calendar_times));
+ }
+ $html .= elgg_view('event_calendar/agenda_footer');
+}
+$html = $nav.'<div class="event_calendar_agenda">'.$html.'</div>'.$nav;
+
+echo $html;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/calendar.php b/mod/event_calendar/views/default/event_calendar/calendar.php
new file mode 100644
index 000000000..ea12ff603
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/calendar.php
@@ -0,0 +1,70 @@
+<?php
+if ($vars['mode']) {
+ $mode = $vars['mode'];
+} else {
+ $mode = 'month';
+}
+
+# event_calendar/list/<start_date>/<display_mode>/<filter_context>/<region>
+if ($vars['group_guid']) {
+ $link_bit = $vars['url']."event_calendar/group/{$vars['group_guid']}/{$vars['original_start_date']}/%s";
+} else {
+ $link_bit = $vars['url']."event_calendar/list/{$vars['original_start_date']}/%s/{$vars['filter']}";
+}
+
+#$link_bit = "event_calendar/show_events.php?start_date='.$vars['original_start_date'].'&group_guid='.$vars['group_guid'].'&filter='.$vars['filter'].'&mode=';
+
+$range_bit = '';
+$first_date = $vars['first_date'];
+if ($first_date) {
+ $range_bit .= 'minDate: $.datepicker.parseDate("yy-mm-dd", "'.$first_date.'"),'."\n";
+}
+$last_date = $vars['last_date'];
+if ($last_date) {
+ $range_bit .= 'maxDate: $.datepicker.parseDate("yy-mm-dd", "'.$last_date.'"),'."\n";
+}
+if ($first_date || $last_date) {
+ if (substr($first_date,0,7) == substr($last_date,0,7)) {
+ $range_bit .= "changeMonth: false,\n";
+ }
+
+ if (substr($first_date,0,4) == substr($last_date,0,4)) {
+ $range_bit .= "changeYear: false,\n";
+ }
+}
+
+$body .= elgg_view("input/datepicker_inline",
+ array(
+ 'name' => 'my_datepicker',
+ 'mode' => $vars['mode']?$vars['mode']:'month',
+ 'start_date' => $vars['start_date'],
+ 'end_date' => $vars['end_date'],
+ 'group_guid' => $vars['group_guid'],
+ 'range_bit' => $range_bit,
+ )
+);
+
+$body .= '<div id="calendarmenucontainer">';
+$body .= '<ul id="calendarmenu">';
+if ($mode == 'day') {
+ $link_class = ' class="sys_selected"';
+} else {
+ $link_class = '';
+}
+$body .= '<li'.$link_class.'><a href="'.sprintf($link_bit,'day').'">'.elgg_echo('event_calendar:day_label').'</a></li>';
+if ($mode == 'week') {
+ $link_class = ' class="sys_selected"';
+} else {
+ $link_class = '';
+}
+$body .= '<li'.$link_class.'><a href="'.sprintf($link_bit,'week').'">'.elgg_echo('event_calendar:week_label').'</a></li>';
+if ($mode == 'month') {
+ $link_class = ' class="sys_selected sys_calmenu_last"';
+} else {
+ $link_class = ' class="sys_calmenu_last"';
+}
+$body .= '<li'.$link_class.'><a href="'.sprintf($link_bit,'month').'">'.elgg_echo('event_calendar:month_label').'</a></li>';
+$body .= '</ul>';
+$body .= '</div>';
+echo $body;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/calendar_toggle.php b/mod/event_calendar/views/default/event_calendar/calendar_toggle.php
new file mode 100644
index 000000000..30de15cf2
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/calendar_toggle.php
@@ -0,0 +1,18 @@
+<?php
+$event = $vars['event_calendar_event'];
+$user = $vars['entity'];
+$container = get_entity($event->container_guid);
+if (event_calendar_has_personal_event($event->guid, $user->guid)) {
+ $label = elgg_echo('event_calendar:remove_from_the_calendar_button');
+} else {
+ $label = elgg_echo('event_calendar:add_to_the_calendar');
+}
+
+if ($container->canEdit()) {
+ $button = elgg_view('input/button',array(
+ 'id'=>'event_calendar_user_data_'.$event->guid.'_'.$user->guid,
+ 'class' => "event-calendar-personal-calendar-toggle",
+ 'value' => $label,
+ ));
+ echo '<div class="event-calendar-personal-calendar-toggle-wrapper">'.$button.'<div>';
+}
diff --git a/mod/event_calendar/views/default/event_calendar/conference_button.php b/mod/event_calendar/views/default/event_calendar/conference_button.php
new file mode 100644
index 000000000..79fa9c5a2
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/conference_button.php
@@ -0,0 +1,33 @@
+<?php
+// A non-admin / non-event-creator only sees the button if they have the event on his/her personal calendar
+// and it is at most 15 minutes before the conference starts.
+
+// The button is removed for everyone (even admins) one day after the event end time.
+
+$event = $vars['event'];
+
+if ($event) {
+ elgg_load_library('elgg:event_calendar');
+ $user_guid = elgg_get_logged_in_user_guid();
+ $termination_time = strtotime("1 day",$event->real_end_time);
+ if ($termination_time < time()) {
+ $in_time_window = FALSE;
+ } else if ($event->canEdit()) {
+ $in_time_window = TRUE;
+ } else if (event_calendar_has_personal_event($event->guid, $user_guid) && (strtotime('-15 minutes',$event->start_date) <= time())) {
+ $in_time_window = TRUE;
+ } else {
+ $in_time_window = FALSE;
+ }
+ if ( $in_time_window ) {
+ $button = elgg_view('output/url', array(
+ 'href' => 'action/event_calendar/join_conference?event_guid='.$event->guid,
+ 'text' => elgg_echo('event_calendar:join_conf_button'),
+ 'class' => 'elgg-button elgg-button-action',
+ 'target' => '_blank',
+ 'is_action' => TRUE,
+ ));
+
+ echo '<div class="event-calendar-conf-join-button">'.$button.'</div>';
+ }
+}
diff --git a/mod/event_calendar/views/default/event_calendar/container.php b/mod/event_calendar/views/default/event_calendar/container.php
new file mode 100644
index 000000000..cb5c8620c
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/container.php
@@ -0,0 +1,28 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
+$group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
+$admin = elgg_is_admin_logged_in();
+$containers = array();
+if (($site_calendar != 'no') && ($admin || !$site_calendar || ($site_calendar == 'loggedin'))) {
+ $containers[0] = elgg_echo('event_calendar:site_calendar');
+}
+$user = elgg_get_logged_in_user_entity();
+$groups = $user->getGroups('',0,0);
+foreach ($groups as $group) {
+ if (event_calendar_activated_for_group($group)) {
+ if ($admin || !$group_calendar || $group_calendar == 'members') {
+ if ($group->canWriteToContainer($user->guid)) {
+ $containers[$group->guid] = $group->name;
+ }
+ } else if ($group->canEdit()) {
+ $containers[$group->guid] = $group->name;
+ }
+ }
+}
+if ($vars['container_guid']) {
+ $value = $vars['container_guid'];
+} else {
+ $value = 0;
+}
+echo elgg_view('input/dropdown',array('name'=>'group_guid', 'value'=>$vars['container_guid'],'options_values'=>$containers));
diff --git a/mod/event_calendar/views/default/event_calendar/css.php b/mod/event_calendar/views/default/event_calendar/css.php
new file mode 100644
index 000000000..00cfd6cbb
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/css.php
@@ -0,0 +1,264 @@
+<?php
+//$background_colour = '#EBF1EB';
+//$highlight_colour = '#478787';
+
+$background_colour = '#F5F5F5';
+$highlight_colour = '#3874B7';
+?>
+
+#calendarmenucontainer {
+ position:relative;
+ left: 25px;
+}
+
+ul#calendarmenu li {
+ float: left;
+ border-top: 1px solid #969696;
+ border-left: 1px solid #969696;
+ border-bottom: 1px solid #969696;
+ background-color: <?php echo $background_colour; ?>;
+}
+
+
+ul#calendarmenu li.sys_calmenu_last {
+ border-right: 1px solid #969696;
+}
+
+ul#calendarmenu li a {
+ text-decoration: none;
+ padding: 4px 12px;
+ float: left;
+}
+
+ul#calendarmenu li a:hover, ul#calendarmenu li.sys_selected a{
+ text-decoration: none;
+ padding: 4px 12px;
+ float: left;
+ color: #FFFFFF;
+ background: <?php echo $highlight_colour; ?>;
+}
+
+.event-calendar-ical {
+ width: 200px;
+}
+
+td.ui-datepicker-unselectable {
+ background-color: #FFFFFF !important;
+ color: #888888 !important;
+}
+
+#my_datepicker .week-highlight a {
+ text-decoration: none;
+ color: #FFFFFF;
+ background: <?php echo $highlight_colour; ?>;
+}
+
+.river_object_event_calendar_create {
+ background: url(<?php echo $vars['url']; ?>mod/event_calendar/images/river_icon_event.gif) no-repeat left -1px;
+}
+.river_object_event_calendar_update {
+ background: url(<?php echo $vars['url']; ?>mod/event_calendar/images/river_icon_event.gif) no-repeat left -1px;
+}
+#event_list {
+ width:510px;
+ margin:0;
+ float:left;
+ padding:5px 0 0 0;
+}
+#event_list .search_listing {
+ border:2px solid #cccccc;
+ margin:0 0 5px 0;
+}
+
+.events {
+ min-height: 300px;
+}
+
+div.event_calendar_agenda_date_section {
+ margin-bottom: 10px;
+}
+
+.event_calendar_agenda_date {
+ font-size: 1.3em;
+ font-weight: bold;
+ margin-bottom: 3px;
+}
+
+th.agenda_header {
+ font-weight: bold;
+}
+
+td.event_calendar_agenda_time {
+ width: 120px;
+}
+
+.event_calendar_agenda_title a {
+ font-weight: bold;
+}
+
+td.event_calendar_agenda_title {
+ width: 180px;
+}
+
+.event_calendar_agenda_venue {
+ margin-bottom: 5px;
+}
+
+.event_calendar_paged_month {
+ font-size: 1.3em;
+ font-weight: bold;
+ margin-bottom: 5px;
+ text-transform:uppercase;
+}
+
+td.event_calendar_paged_date {
+ width: 80px;
+}
+td.event_calendar_paged_time {
+ width: 60px;
+}
+td.event_calendar_paged_title {
+ width: 280px;
+}
+
+td.event_calendar_paged_calendar {
+ padding-left: 30px;
+}
+
+table.event_calendar_paged_table {
+ width:100%;
+ border-collapse:collapse;
+ border-bottom-width:1px;
+ border-bottom-style:solid;
+ border-bottom-color:#bfbfbf;
+ margin-bottom: 5px;
+}
+
+table.event_calendar_paged_table td {
+ border-width:1px 0 0 0;
+ border-style:solid;
+ border-color:#bfbfbf;
+}
+
+table.event_calendar_paged_table th {
+ font-family:verdana, helvetica, arial, sans-serif;
+ font-size:9pt;
+ color:#183e76;
+ background-color:#ececec;
+ font-weight:bold;
+ text-transform:none;
+ padding:3px 3px 3px 3px;
+}
+
+.event_calendar_strapline {
+ font-size: 85%;
+}
+
+.event-calendar-personal-calendar-toggle-wrapper {
+ width: 100%;
+ margin-bottom: 30px;
+}
+
+.event-calendar-personal-calendar-toggle {
+ float: right;
+}
+
+li.event-calendar-filter-menu-show-only {
+ border:0;
+ padding-top:.4em;
+ background:#fff;
+ margin:0 -.3em 0 1.5em;
+}
+
+.event-calendar-compressed-date {
+ width: 150px !important;
+ margin-right: 10px;
+}
+
+fieldset > legend {
+ font-weight: bold;
+ font-size: 1.2em;
+ line-height: 1.1em;
+ padding-bottom: 5px;
+}
+.event-calendar-repeating-wrapper {
+ padding: 0;
+ margin-top: 5px;
+}
+.event-calendar-repeating-unselected {
+ font-size: 16px;
+ font-weight: bold;
+ color: #DDDDDD;
+ background-color: #AAAAAA;
+ border: 1px solid #444444;
+ padding: 5px;
+ width: 25px;
+ text-align: center;
+ display: inline-block;
+ margin: 0;
+}
+
+.event-calendar-repeating-unselected:hover {
+ text-decoration: none;
+}
+
+.event-calendar-repeating-selected {
+ font-size: 16px;
+ font-weight: bold;
+ color: #000000;
+ background-color: #FFFFFF;
+ border: 1px solid #000000;
+ padding: 5px;
+ width: 25px;
+ text-align: center;
+ display: inline-block;
+ margin: 0;
+}
+
+.event-calendar-repeating-selected:hover {
+ text-decoration: none;
+ color: #CCCCCC;
+}
+
+.event-calendar-edit-form-schedule-block ul.elgg-vertical li {
+ display: block !important;
+ clear: both;
+}
+
+.event-calendar-edit-form-block ul.elgg-vertical li label {
+ font-weight: normal;
+ width: 500px;
+}
+
+.event-calendar-edit-form-block h2 {
+ font-size: 18px;
+ color: #000000;
+}
+
+.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 {
+ display: none;
+}
+
+.event-calendar-edit-bottom {
+ clear: both;
+ margin-bottom: 5px;
+}
+
+.event-calendar-date-selected {
+ background-color: #DDDDFF;
+}
diff --git a/mod/event_calendar/views/default/event_calendar/datetime_edit.php b/mod/event_calendar/views/default/event_calendar/datetime_edit.php
new file mode 100644
index 000000000..2e0830167
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/datetime_edit.php
@@ -0,0 +1,46 @@
+<?php
+$event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar');
+$event_calendar_hide_end = elgg_get_plugin_setting('hide_end', 'event_calendar');
+$prefix = $vars['prefix'];
+$body = '';
+
+if ($event_calendar_times != 'no') {
+ if ($event_calendar_hide_end != 'yes') {
+ $body .= '<p><label>'.elgg_echo('event_calendar:from_label').'</label>';
+ }
+ $body .= elgg_view("input/date", array(
+ 'class'=>'event-calendar-compressed-date',
+ 'name' => 'start_date',
+ 'value'=>$vars['start_date'],
+ ));
+ $body .= '<span id="event-calendar-start-time-wrapper">';
+ $body .= elgg_view("input/timepicker",array('name' => 'start_time','value'=>$vars['start_time']));
+ $body .= '</span>';
+ if ($event_calendar_hide_end != 'yes') {
+ $body .= '</p><p id="event-calendar-to-time-wrapper"><label>'.elgg_echo('event_calendar:to_label').'</label>';
+ $body .= elgg_view("input/date", array(
+ 'class'=>'event-calendar-compressed-date',
+ 'name' => 'end_date',
+ 'value'=>$vars['end_date'],
+ ));
+ $body .= '<span id="event-calendar-end-time-wrapper">';
+ $body .= elgg_view("input/timepicker",array('name' => 'end_time','value'=>$vars['end_time']));
+ $body .= '</span>';
+ }
+ $body .= '</p>';
+} else {
+
+ $body .= '<p><label>'.elgg_echo("event_calendar:start_date_label").'<br />';
+ $body .= elgg_view("event_calendar/input/date_local",array('timestamp'=>TRUE, 'autocomplete'=>'off','name' => 'start_date','value'=>$vars['start_date']));
+ $body .= '</label></p>';
+ $body .= '<p class="description">'.$prefix['start_date'].elgg_echo('event_calendar:start_date_description').'</p>';
+
+ if ($event_calendar_hide_end != 'yes') {
+ $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>';
+ }
+}
+
+echo $body; \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/entities/entity_list.php b/mod/event_calendar/views/default/event_calendar/entities/entity_list.php
new file mode 100644
index 000000000..84c2c0b7d
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/entities/entity_list.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * View a list of entities
+ *
+ * @package Elgg
+ * @author Curverider Ltd <info@elgg.com>
+ * @link http://elgg.com/
+ *
+ */
+
+$context = $vars['context'];
+$offset = $vars['offset'];
+$entities = $vars['entities'];
+$limit = $vars['limit'];
+$count = $vars['count'];
+$baseurl = $vars['baseurl'];
+$context = $vars['context'];
+$viewtype = $vars['viewtype'];
+$pagination = $vars['pagination'];
+$fullview = $vars['fullview'];
+
+$html = "";
+$nav = "";
+
+if (isset($vars['viewtypetoggle'])) {
+ $viewtypetoggle = $vars['viewtypetoggle'];
+} else {
+ $viewtypetoggle = true;
+}
+
+if ($context == "search" && $count > 0 && $viewtypetoggle) {
+ $nav .= elgg_view('navigation/viewtype', array(
+ 'baseurl' => $baseurl,
+ 'offset' => $offset,
+ 'count' => $count,
+ 'viewtype' => $viewtype,
+ ));
+}
+
+if ($pagination) {
+ $nav .= elgg_view('navigation/pagination',array(
+ 'baseurl' => $baseurl,
+ 'offset' => $offset,
+ 'count' => $count,
+ 'limit' => $limit,
+ ));
+}
+
+$html .= $nav;
+if ($viewtype == 'list') {
+ if (is_array($entities) && sizeof($entities) > 0) {
+ foreach($entities as $entity) {
+ $html .= elgg_view_entity($entity, $fullview);
+ }
+ }
+} else {
+ if (is_array($entities) && sizeof($entities) > 0) {
+ $html .= elgg_view('event_calendar/entities/gallery', array('entities' => $entities));
+ }
+}
+
+if ($count) {
+ $html .= $nav;
+}
+
+echo $html; \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/entities/gallery.php b/mod/event_calendar/views/default/event_calendar/entities/gallery.php
new file mode 100644
index 000000000..a12dfa84a
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/entities/gallery.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Elgg gallery view
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+
+$entities = $vars['entities'];
+if (is_array($entities) && sizeof($entities) > 0) {
+
+?>
+
+<table class="entity_gallery">
+
+<?php
+
+ $col = 0;
+ foreach($entities as $entity) {
+ if ($col == 0) {
+
+ echo "<tr>";
+
+ }
+ echo "<td class=\"entity_gallery_item\">";
+ echo elgg_view('event_calendar/entities/gallery_item',array('entity'=>$entity));
+ echo "</td>";
+ $col++;
+ if ($col > 3) {
+ echo "</tr>";
+ $col = 0;
+ }
+ }
+ if ($col > 0) echo "</tr>";
+
+?>
+
+</table>
+
+<?php
+
+} \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/entities/gallery_item.php b/mod/event_calendar/views/default/event_calendar/entities/gallery_item.php
new file mode 100644
index 000000000..9fc1edeca
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/entities/gallery_item.php
@@ -0,0 +1,63 @@
+<?php
+
+ /**
+ * Elgg user display (gallery)
+ *
+ * @package ElggProfile
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010
+ * @link http://elgg.com/
+ *
+ * @uses $vars['entity'] The user entity
+ */
+
+$icon = elgg_view(
+ "profile/icon", array(
+ 'entity' => $vars['entity'],
+ 'size' => 'medium',
+ )
+ );
+
+$banned = $vars['entity']->isBanned();
+
+$rel = "";
+if (elgg_get_page_owner_guid() == $vars['entity']->guid)
+ $rel = 'me';
+else if (check_entity_relationship(elgg_get_page_owner_guid(), 'friend', $vars['entity']->guid))
+ $rel = 'friend';
+
+if (!$banned)
+ $info .= "<p><b><a href=\"" . $vars['entity']->getUrl() . "\" rel=\"$rel\">" . $vars['entity']->name . "</a></b></p>";
+else
+ $info .= "<p><b><strike>" . $vars['entity']->name . "</b></strike><br />".elgg_echo('profile:banned')."</p>";
+
+// TODO: look into a way to pass $authorised and $event_id in $vars
+$authorised = FALSE;
+$event_id = get_input('event_id', 0);
+if ($event_id) {
+ if(isadminloggedin()) {
+ $authorised = TRUE;
+ } else {
+ // load the event from the database
+ $event = get_entity($event_id);
+ $user_id = elgg_get_logged_in_user_guid();
+ if ($event && ($event->owner_guid == $user_id)) {
+ $authorised = TRUE;
+ }
+ }
+}
+
+if ($authorised) {
+ $link = '<p><a href="#" ';
+ $link .= 'onclick="javascript:event_calendar_personal_toggle('.$event_id.','.$vars['entity']->guid.'); return false;" ';
+ $link .= ' >';
+ $link .= '<span id="event_calendar_user_data_'.$vars['entity']->guid.'">'.elgg_echo('event_calendar:remove_from_the_calendar').'</span>';
+ $link .= '</a></p>';
+ $info .= $link;
+}
+
+// echo elgg_view_image_block($icon, $info);
+echo elgg_view('search/gallery_listing',array('icon' => $icon, 'info' => $info));
+
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/filter_menu.php b/mod/event_calendar/views/default/event_calendar/filter_menu.php
new file mode 100644
index 000000000..1364902a8
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/filter_menu.php
@@ -0,0 +1,78 @@
+<?php
+// generate a list of filter tabs
+$group_guid = $vars['group_guid'];
+$filter_context = $vars['filter'];
+if ($group_guid) {
+ $url_start = "event_calendar/group/{$group_guid}/{$vars['start_date']}/{$vars['mode']}";
+} else {
+ $url_start = "event_calendar/list/{$vars['start_date']}/{$vars['mode']}";
+}
+
+$tabs = array(
+ 'all' => array(
+ 'text' => elgg_echo('event_calendar:show_all'),
+ 'href' => "$url_start/all",
+ 'selected' => ($filter_context == 'all'),
+ 'priority' => 200,
+ ),
+);
+
+if (elgg_is_logged_in()) {
+ $tabs ['mine'] = array(
+ 'text' => elgg_echo('event_calendar:show_mine'),
+ 'href' => "$url_start/mine",
+ 'selected' => ($filter_context == 'mine'),
+ 'priority' => 300,
+ );
+ $tabs['friend'] = array(
+ 'text' => elgg_echo('event_calendar:show_friends'),
+ 'href' => "$url_start/friends",
+ 'selected' => ($filter_context == 'friends'),
+ 'priority' => 400,
+ );
+}
+
+$tab_rendered = array();
+
+$event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar');
+if ($event_calendar_spots_display == "yes") {
+ $tabs['open'] = array(
+ 'text' => elgg_echo('event_calendar:show_open'),
+ 'href' => "$url_start/open",
+ 'selected' => ($filter_context == 'open'),
+ 'priority' => 100,
+ );
+} else {
+ $tab_rendered['open'] = '';
+}
+
+foreach ($tabs as $name => $tab) {
+ if ($tab['selected']) {
+ $state_selected = ' class="elgg-state-selected"';
+ } else {
+ $state_selected = '';
+ }
+ $tab_rendered[$name] = '<li'.$state_selected.'><a href="'.elgg_normalize_url($tab['href']).'">'.$tab['text'].'</a></li>';
+
+ //elgg_register_menu_item('filter', $tab);
+}
+
+//echo elgg_view_menu('filter', array('sort_by' => 'priority', 'class' => 'elgg-menu-hz'));
+
+$menu = <<<__MENU
+<ul class="elgg-menu elgg-menu-filter elgg-menu-hz elgg-menu-filter-default">
+ {$tab_rendered['open']}
+ {$tab_rendered['all']}
+ {$tab_rendered['mine']}
+ {$tab_rendered['friend']}
+</ul>
+__MENU;
+
+echo $menu;
+
+$event_calendar_region_display = elgg_get_plugin_setting('region_display', 'event_calendar');
+if ($event_calendar_region_display == 'yes') {
+ elgg_load_js("elgg.event_calendar");
+ $url_start .= "/$filter_context";
+ echo elgg_view('event_calendar/region_select',array('url_start'=>$url_start,'region'=>$vars['region']));
+} \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/forms/add_to_group.php b/mod/event_calendar/views/default/event_calendar/forms/add_to_group.php
new file mode 100644
index 000000000..2c8fdec53
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/forms/add_to_group.php
@@ -0,0 +1,74 @@
+<?php
+// Game plan - display two drop downs: one with a list of groups
+// without this event, one with - can add using one and remove using
+// the other
+// the user must have the authority to edit the groups
+
+$event_id = $vars['event']->guid;
+$event_container = $vars['event']->container_guid;
+
+// get the list of all groups:
+
+if (elgg_is_admin_logged_in()) {
+ $groups = elgg_get_entities(array(
+ 'type' => 'group',
+ 'limit' => 5000,
+ ));
+} else {
+ $groups = elgg_get_entities(array(
+ 'type' => 'group',
+ 'owner_guid' => elgg_get_logged_in_user_guid(),
+ 'limit' => 5000,
+ ));
+}
+
+// split the group list into two lists
+
+$add_options = array();
+$remove_options = array();
+$remove_group = elgg_get_entities_from_relationship(array(
+ 'relationship' => 'display_on_group',
+ 'relationship_guid' => $event_id,
+ 'inverse_relationship' => FALSE,
+ 'limit' => 5000,
+));
+$remove_group_ids = array();
+foreach ($remove_group as $group) {
+ $remove_group_ids[] = $group->guid;
+ if ($group->guid != $event_container && $group->canEdit()) {
+ $remove_options[$group->guid] = $group->name;
+ }
+}
+
+if ($remove_group) {
+ foreach($groups as $group) {
+ if (($group->guid != $event_container) && !in_array($group->guid,$remove_group_ids)) {
+ $add_options[$group->guid] = $group->name;
+ }
+ }
+} else {
+ foreach($groups as $group) {
+ if ($group->guid != $event_container && $group->canEdit()) {
+ $add_options[$group->guid] = $group->name;
+ }
+ }
+}
+
+if ($add_options || $remove_options) {
+ echo '<div class="contentWrapper" >';
+ $event_bit = elgg_view('input/hidden', array("name" => "event_id","value" => $event_id));
+ if ($add_options) {
+ echo "<h4>".elgg_echo('event_calendar:add_to_group:add_group_title')."</h4>";
+ $add_pulldown = elgg_view("input/dropdown",array("name" => "group_id","options_values" => $add_options));
+ $submit_button = "<p>".elgg_view("input/submit",array("value"=>elgg_echo('event_calendar:add_to_group:add_group_button')))."</p>";
+ echo elgg_view ('input/form',array("body" => $event_bit.$add_pulldown.$submit_button,"action" => $vars['url']."action/event_calendar/add_to_group"));
+ }
+
+ if ($remove_options) {
+ echo "<h4>".elgg_echo('event_calendar:add_to_group:remove_group_title')."</h4>";
+ $remove_pulldown = elgg_view("input/dropdown",array("name" => "group_id","options_values" => $remove_options));
+ $submit_button = "<p>".elgg_view("input/submit",array("value"=>elgg_echo('event_calendar:add_to_group:remove_group_button')))."</p>";
+ echo elgg_view ('input/form',array("body" => $event_bit.$remove_pulldown.$submit_button,"action" => $vars['url']."action/event_calendar/remove_from_group"));
+ }
+ echo '</div>';
+}
diff --git a/mod/event_calendar/views/default/event_calendar/full_calendar_view.php b/mod/event_calendar/views/default/event_calendar/full_calendar_view.php
new file mode 100644
index 000000000..1a58321b5
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/full_calendar_view.php
@@ -0,0 +1,200 @@
+<?php
+elgg_load_js('elgg.full_calendar');
+
+$timeformat = elgg_get_plugin_setting('timeformat', 'event_calendar') == 24 ? 'H(:mm)' : 'h(:mm)t';
+
+// TODO: is there an easy way to avoid embedding JS?
+?>
+<script>
+
+var goToDateFlag = 0;
+
+handleEventClick = function(event) {
+ if (event.url) {
+ window.location.href = event.url;
+ event.preventDefault();
+ }
+};
+
+handleDayClick = function(date,allDay,jsEvent,view) {
+ var iso = getISODate(date);
+ var link = $('.elgg-menu-item-event-calendar-0add').find('a').attr('href');
+ var ss = link.split('/');
+ 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;
+ }
+ var url = elgg.get_site_url();
+ $('.fc-widget-content').removeClass('event-calendar-date-selected');
+ var current_iso = $('#event-calendar-selected-date').val();
+ if (current_iso == iso) {
+ // deselect
+ $('#event-calendar-selected-date').val("");
+ $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid);
+ $('.event-calendar-button-add').attr('href',url+'event_calendar/add/'+group_guid);
+ $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid);
+ } else {
+ $('#event-calendar-selected-date').val(iso);
+ $('.elgg-menu-item-event-calendar-0add').find('a').attr('href',url+'event_calendar/add/'+group_guid+'/'+iso);
+ $('.event-calendar-button-add').attr('href',url+'event_calendar/add/'+group_guid+'/'+iso);
+ $('.elgg-menu-item-event-calendar-1schedule').find('a').attr('href',url+'event_calendar/schedule/'+group_guid+'/'+iso);
+
+ $(this).addClass('event-calendar-date-selected');
+ }
+}
+
+handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) {
+
+ 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: 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;
+ }
+ }
+ }
+ );
+ }
+};
+
+getISODate = function(d) {
+ var year = d.getFullYear();
+ var month = d.getMonth()+1;
+ month = month < 10 ? '0' + month : month;
+ var day = d.getDate();
+ day = day < 10 ? '0' + day : day;
+ return year +"-"+month+"-"+day;
+}
+
+handleEventRender = function(event, element, view) {
+ /*if (event.is_event_poll) {
+ element.draggable = false;
+ }*/
+}
+
+handleGetEvents = function(start, end, callback) {
+ var start_date = getISODate(start);
+ var end_date = getISODate(end);
+ var url = "event_calendar/get_fullcalendar_events/"+start_date+"/"+end_date+"/<?php echo $vars['filter']; ?>/<?php echo $vars['group_guid']; ?>";
+ elgg.getJSON(url, {success:
+ function(events) {
+ callback(events);
+ }
+ });
+ // 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');
+ 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);
+ }
+}
+
+handleViewDisplay = function(view) {
+ // TODO: finish this, need to highlight selected date if any
+ var current_iso = $('#event-calendar-selected-date').val();
+ if (view == 'month') {
+ goToDateFlag = 0;
+ } else if (goToDateFlag == 0 && current_iso != "") {
+ goToDateFlag = 1;
+ var a = current_iso.split("-");
+ $('#calendar').fullCalendar('gotoDate',parseInt(a[0],10),parseInt(a[1],10)-1,parseInt(a[2],10));
+ //$('.fc-widget-content').removeClass('event-calendar-date-selected');
+ //$(".fc-widget-content[data-date='"+ciso+"']").addClass('event-calendar-date-selected');
+ }
+
+ //$(".fc-widget-content[data-date='20120105']")
+}
+
+fullcalendarInit = function() {
+
+ var loadFullCalendar = function() {
+ var locale = $.datepicker.regional[elgg.get_language()];
+ if (!locale) {
+ locale = $.datepicker.regional[''];
+ }
+ $('#calendar').fullCalendar({
+ header: {
+ left: 'prev,next today',
+ center: 'title',
+ right: 'month,agendaWeek,agendaDay'
+ },
+ month: <?php echo date('n',strtotime($vars['start_date']))-1; ?>,
+ ignoreTimezone: true,
+ editable: true,
+ slotMinutes: 15,
+ eventRender: handleEventRender,
+ eventDrop: handleEventDrop,
+ eventClick: handleEventClick,
+ dayClick: handleDayClick,
+ events: handleGetEvents,
+ viewDisplay: handleViewDisplay,
+
+ isRTL: locale.isRTL,
+ firstDay: locale.firstDay,
+ monthNames: locale.monthNames,
+ monthNamesShort: locale.monthNamesShort,
+ dayNames: locale.dayNames,
+ dayNamesShort: locale.dayNamesShort,
+ buttonText: {
+ today: locale.currentText,
+ month: elgg.echo('event_calendar:month_label'),
+ week: elgg.echo('event_calendar:week_label'),
+ day: elgg.echo('event_calendar:day_label')
+ },
+ timeFormat: "<?php echo $timeformat; ?>",
+ });
+ }
+
+ elgg.get({
+ url: elgg.config.wwwroot + 'vendors/jquery/i18n/jquery.ui.datepicker-'+ elgg.get_language() +'.js',
+ dataType: "script",
+ cache: true,
+ success: loadFullCalendar,
+ error: loadFullCalendar, // english language is already loaded.
+ });
+}
+
+elgg.register_hook_handler('init', 'system', fullcalendarInit);
+
+</script>
+<div id='calendar'></div>
+<input type="hidden" id="event-calendar-selected-date" />
diff --git a/mod/event_calendar/views/default/event_calendar/group_module.php b/mod/event_calendar/views/default/event_calendar/group_module.php
new file mode 100644
index 000000000..b1c1567e7
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/group_module.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Group event calendar module
+ */
+
+$group = elgg_get_page_owner_entity();
+
+if ($group->event_calendar_enable == "no") {
+ return true;
+}
+
+elgg_push_context('widgets');
+$content = elgg_view('event_calendar/groupprofile_calendar');
+elgg_pop_context();
+
+if (!$content) {
+ if (elgg_get_plugin_setting('group_always_display', 'event_calendar') == 'yes') {
+ $content = elgg_echo('event_calendar:no_events_found');
+ }
+}
+
+if ($content) {
+ $all_link = elgg_view('output/url', array(
+ 'href' => "event_calendar/group/$group->guid",
+ 'text' => elgg_echo('link:view:all'),
+ ));
+ $new_link = elgg_view('output/url', array(
+ 'href' => "event_calendar/add/$group->guid",
+ 'text' => elgg_echo('event_calendar:new'),
+ ));
+ echo elgg_view('groups/profile/module', array(
+ 'title' => elgg_echo('event_calendar:group'),
+ 'content' => $content,
+ 'all_link' => $all_link,
+ 'add_link' => $new_link,
+ ));
+}
diff --git a/mod/event_calendar/views/default/event_calendar/groupprofile_calendar.php b/mod/event_calendar/views/default/event_calendar/groupprofile_calendar.php
new file mode 100644
index 000000000..c71780be8
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/groupprofile_calendar.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Elgg event_calendar group profile content
+ *
+ * @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/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$page_owner_entity = elgg_get_page_owner_entity();
+
+if (event_calendar_activated_for_group($page_owner_entity)) {
+ $num = 5;
+ // Get the upcoming events
+ $start_date = time(); // now
+ $end_date = $start_date + 60*60*24*365*2; // maximum is two years from now
+ $events = event_calendar_get_events_between($start_date,$end_date,false,$num,0,elgg_get_page_owner_guid());
+
+ // If there are any events to view, view them
+ if (is_array($events) && sizeof($events) > 0) {
+
+ foreach($events as $event) {
+ echo elgg_view("object/event_calendar",array('entity' => $event['event']));
+ }
+
+ }
+}
diff --git a/mod/event_calendar/views/default/event_calendar/groupprofile_calendar_deprecated.php b/mod/event_calendar/views/default/event_calendar/groupprofile_calendar_deprecated.php
new file mode 100644
index 000000000..0d7d5101f
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/groupprofile_calendar_deprecated.php
@@ -0,0 +1,44 @@
+<?php
+
+/**
+ * Elgg event_calendar group profile content
+ *
+ * @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/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$page_owner_entity = elgg_get_page_owner_entity();
+
+if (event_calendar_activated_for_group($page_owner_entity)) {
+ $num = 5;
+ // Get the upcoming events
+ $start_date = time(); // now
+ $end_date = $start_date + 60*60*24*365*2; // maximum is two years from now
+ $events = event_calendar_get_events_between($start_date,$end_date,false,$num,0,elgg_get_page_owner_guid());
+
+ // If there are any events to view, view them
+ if (is_array($events) && sizeof($events) > 0) {
+
+ echo '<div id="group_pages_widget">';
+ echo '<h2>'.elgg_echo("event_calendar:groupprofile").'</h2>';
+ foreach($events as $event) {
+ echo elgg_view("object/event_calendar",array('entity' => $event));
+ }
+ echo '<div class="forum_latest"><a href="'.$vars['url'].'pg/event_calendar/group/'.elgg_get_page_owner_guid().'">'.elgg_echo('event_calendar:view_calendar').'</a></div>';
+ echo "</div>";
+
+ } else if (elgg_get_plugin_setting('group_always_display', 'event_calendar') == 'yes') {
+ echo '<div id="group_pages_widget">';
+ echo '<h2>'.elgg_echo("event_calendar:groupprofile").'</h2>';
+ echo '<div class="forum_latest">'.elgg_echo('event_calendar:no_events_found').'</div>';
+ echo "</div>";
+ }
+}
+
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/input/date_local.php b/mod/event_calendar/views/default/event_calendar/input/date_local.php
new file mode 100644
index 000000000..a0ce7f4d3
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/input/date_local.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Elgg date input
+ * Displays a text field with a popup date picker.
+ *
+ * The elgg.ui JavaScript library initializes the jQueryUI datepicker based
+ * on the CSS class .elgg-input-date. It uses the ISO 8601 standard for date
+ * representation: yyyy-mm-dd.
+ *
+ * Unix timestamps are supported by setting the 'timestamp' parameter to true.
+ * The date is still displayed to the user in a text format but is submitted as
+ * a unix timestamp in seconds.
+ *
+ * @uses $vars['value'] The current value, if any (as a unix timestamp)
+ * @uses $vars['class'] Additional CSS class
+ * @uses $vars['timestamp'] Store as a Unix timestamp in seconds. Default = false
+ * Note: you cannot use an id with the timestamp option.
+ */
+
+//@todo popup_calendar deprecated in 1.8. Remove in 2.0
+if (isset($vars['class'])) {
+ $vars['class'] = "elgg-input-date popup_calendar {$vars['class']}";
+} else {
+ $vars['class'] = "elgg-input-date popup_calendar";
+}
+
+$defaults = array(
+ 'value' => '',
+ 'disabled' => false,
+ 'timestamp' => false,
+);
+
+$vars = array_merge($defaults, $vars);
+
+$timestamp = $vars['timestamp'];
+unset($vars['timestamp']);
+
+if ($timestamp) {
+ echo elgg_view('input/hidden', array(
+ 'name' => $vars['name'],
+ 'value' => $vars['value'],
+ ));
+
+ $vars['class'] = "{$vars['class']} elgg-input-timestamp";
+ $vars['id'] = $vars['name'];
+ unset($vars['name']);
+}
+
+// convert timestamps to text for display
+if (is_numeric($vars['value'])) {
+ $vars['value'] = date('Y-m-d', $vars['value']);
+}
+
+$attributes = elgg_format_attributes($vars);
+echo "<input type=\"text\" $attributes />";
diff --git a/mod/event_calendar/views/default/event_calendar/metatags.php b/mod/event_calendar/views/default/event_calendar/metatags.php
new file mode 100644
index 000000000..8375ef118
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/metatags.php
@@ -0,0 +1,2 @@
+<link rel="stylesheet" href="<?php echo $vars['url']; ?>mod/event_calendar/datepicker.css" type="text/css" media="screen" title="Flora (Default)">
+<script type="text/javascript" src="<?php echo $vars['url']; ?>mod/event_calendar/ui.datepicker.js"></script>
diff --git a/mod/event_calendar/views/default/event_calendar/nav.php b/mod/event_calendar/views/default/event_calendar/nav.php
new file mode 100644
index 000000000..746a46151
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/nav.php
@@ -0,0 +1,38 @@
+<?php
+$allselect = ''; $friendsselect = ''; $mineselect = '';
+switch($vars['filter']) {
+ case 'all': $allselect = 'class="selected"';
+ break;
+ case 'friends': $friendsselect = 'class="selected"';
+ break;
+ case 'mine': $mineselect = 'class="selected"';
+ break;
+ case 'open': $openselect = 'class="selected"';
+ break;
+}
+
+$url_start = $vars['url'].'mod/event_calendar/show_events.php?group_guid='.$vars['group_guid'].'&amp;mode='.$vars['mod'].'&amp;start_date='.$vars['start_date'];
+
+?>
+<div id="elgg_horizontal_tabbed_nav">
+ <ul>
+<?php
+$event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar');
+if ($event_calendar_spots_display == "yes") {
+?>
+ <li <?php echo $openselect; ?> ><a onclick="javascript:$('#event_list').load('<?php echo $url_start; ?>&amp;filter=open&amp;callback=true'); return false;" href="<?php echo $url_start; ?>&amp;filter=open&amp;callback=true"><?php echo elgg_echo('event_calendar:open'); ?></a></li>
+<?php
+}
+?>
+ <li <?php echo $allselect; ?> ><a onclick="javascript:$('#event_list').load('<?php echo $url_start; ?>&amp;filter=all&amp;callback=true'); return false;" href="<?php echo $url_start; ?>&amp;filter=all&amp;callback=true"><?php echo elgg_echo('all'); ?></a></li>
+ <li <?php echo $friendsselect; ?> ><a onclick="javascript:$('#event_list').load('<?php echo $url_start; ?>&amp;filter=friends&amp;callback=true'); return false;" href="<?php echo $url_start; ?>&amp;filter=friends&amp;callback=true"><?php echo elgg_echo('friends'); ?></a></li>
+ <li <?php echo $mineselect; ?> ><a onclick="javascript:$('#event_list').load('<?php echo $url_start; ?>&amp;filter=mine&amp;callback=true'); return false;" href="<?php echo $url_start; ?>&amp;filter=mine&amp;callback=true"><?php echo elgg_echo('event_calendar:mine'); ?></a></li>
+ </ul>
+</div>
+<?php
+$event_calendar_region_display = elgg_get_plugin_setting('region_display', 'event_calendar');
+if ($event_calendar_region_display == 'yes') {
+ $url_start .= '&amp;filter='.$vars['filter'];
+ echo elgg_view('event_calendar/region_select',array('url_start'=>$url_start,'region'=>$vars['region']));
+}
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/paged_footer.php b/mod/event_calendar/views/default/event_calendar/paged_footer.php
new file mode 100644
index 000000000..954769104
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/paged_footer.php
@@ -0,0 +1,4 @@
+<?php
+echo '</tbody></table></div>';
+?>
+
diff --git a/mod/event_calendar/views/default/event_calendar/paged_header.php b/mod/event_calendar/views/default/event_calendar/paged_header.php
new file mode 100644
index 000000000..5f4b8e59c
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/paged_header.php
@@ -0,0 +1,15 @@
+<?php
+$header .= '<div class="event_calendar_paged_header_section">';
+$header .= '<div class="event_calendar_paged_month">'.$vars['date'].'</div>';
+$header .= '<table class="event_calendar_paged_table"><thead><tr>';
+$header .= '<th class="paged_header">'.elgg_echo('event_calendar:paged:column:date').'</th>';
+$header .= '<th class="paged_header">'.elgg_echo('event_calendar:paged:column:time').'</th>';
+$header .= '<th class="paged_header">'.elgg_echo('event_calendar:paged:column:event').'</th>';
+$header .= '<th class="paged_header">'.elgg_echo('event_calendar:paged:column:venue').'</th>';
+if ($vars['personal_manage'] != 'no') {
+ $header .= '<th class="paged_header">'.elgg_echo('event_calendar:paged:column:calendar').'</th>';
+}
+$header .= '</td></thead><tbody>';
+
+echo $header;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/paged_item_view.php b/mod/event_calendar/views/default/event_calendar/paged_item_view.php
new file mode 100644
index 000000000..f2092bafc
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/paged_item_view.php
@@ -0,0 +1,27 @@
+<?php
+$event = $vars['event'];
+$time_bit = '';
+if (is_numeric($event->start_time)) {
+ $time_bit = event_calendar_convert_time($event->start_time);
+}
+
+$date_bit = event_calendar_get_formatted_date($event->start_date);
+
+if (event_calendar_has_personal_event($event->guid,elgg_get_logged_in_user_guid())) {
+ $calendar_bit = 'checked = "checked"';
+} else {
+ $calendar_bit = '';
+}
+
+$info = '<tr>';
+$info .= '<td class="event_calendar_paged_date">'.$date_bit.'</td>';
+$info .= '<td class="event_calendar_paged_time">'.$time_bit.'</td>';
+$info .= '<td class="event_calendar_paged_title"><a href="'.$event->getUrl().'">'.$event->title.'</a></td>';
+$info .= '<td class="event_calendar_paged_venue">'.$event->venue.'</td>';
+if ($vars['personal_manage'] != 'no') {
+ $info .= '<td class="event_calendar_paged_calendar"><input class="event_calendar_paged_checkbox" id="event_calendar_paged_checkbox_'.$event->guid.'" '.$calendar_bit.' type="checkbox" /></td>';
+}
+$info .= '</tr>';
+
+echo $info;
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/paged_view.php b/mod/event_calendar/views/default/event_calendar/paged_view.php
new file mode 100644
index 000000000..f8257792f
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/paged_view.php
@@ -0,0 +1,36 @@
+<?php
+elgg_load_js('elgg.event_calendar');
+$nav = elgg_view('navigation/pagination',array(
+
+// 'baseurl' => $_SERVER['REQUEST_URI'],
+ 'baseurl' => $_SERVER['SCRIPT_NAME'].'/?'.$_SERVER['QUERY_STRING'],
+ 'offset' => $vars['offset'],
+ 'count' => $vars['count'],
+ 'limit' => $vars['limit'],
+
+ ));
+$event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar');
+$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
+$events = $vars['events'];
+$html = '';
+$date_format = 'F Y';
+$current_month = '';
+if ($events) {
+ foreach($events as $event) {
+ $month = date($date_format,$event->start_date);
+ if ($month != $current_month) {
+ if ($html) {
+ $html .= elgg_view('event_calendar/paged_footer');
+ }
+ $html .= elgg_view('event_calendar/paged_header',array('date'=>$month,'personal_manage'=>$event_calendar_personal_manage));
+
+ $current_month = $month;
+ }
+ $html .= elgg_view('event_calendar/paged_item_view',array('event'=>$event,'times'=>$event_calendar_times,'personal_manage'=>$event_calendar_personal_manage));
+ }
+ $html .= elgg_view('event_calendar/paged_footer');
+}
+$msgs = '<div id="event_calendar_paged_messages"></div>';
+$html = $msgs.$nav.'<div class="event_calendar_paged">'.$html.'</div>'.$nav;
+
+echo $html;
diff --git a/mod/event_calendar/views/default/event_calendar/personal_manage_section.php b/mod/event_calendar/views/default/event_calendar/personal_manage_section.php
new file mode 100644
index 000000000..9e03db0ab
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/views/default/event_calendar/personal_toggle_js.php b/mod/event_calendar/views/default/event_calendar/personal_toggle_js.php
new file mode 100644
index 000000000..c0611e45c
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/personal_toggle_js.php
@@ -0,0 +1,20 @@
+<?php
+// TODO: put the rest into a JS function
+
+$elgg_ts = time();
+$elgg_token = generate_action_token($elgg_ts);
+$tokens = "&__elgg_ts=$elgg_ts&__elgg_token=$elgg_token";
+?>
+<script type="text/javascript">
+function event_calendar_personal_toggle(event_id,user_id) {
+
+ var link = "<?php echo $vars['url']; ?>action/event_calendar/toggle_personal_calendar?";
+ link += "user_id="+user_id+"&event_id="+event_id+"&other=true";
+ link += "<?php echo $tokens; ?>";
+ $.get(link,
+ function (res) {
+ $('#event_calendar_user_data_'+user_id).html(res);
+ }
+ );
+}
+</script> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/region_select.php b/mod/event_calendar/views/default/event_calendar/region_select.php
new file mode 100644
index 000000000..a987171a2
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/region_select.php
@@ -0,0 +1,21 @@
+<?php
+
+$region_list = trim(elgg_get_plugin_setting('region_list', 'event_calendar'));
+// make sure that we are using Unix line endings
+$region_list = str_replace("\r\n","\n",$region_list);
+$region_list = str_replace("\r","\n",$region_list);
+if ($region_list) {
+ $body = '';
+ $options_values = array('-' =>elgg_echo('event_calendar:all'));
+ foreach(explode("\n",$region_list) as $region_item) {
+ $region_item = trim($region_item);
+ $options_values[$region_item] = $region_item;
+ }
+
+ $body .= elgg_echo('event_calendar:region_filter_by_label');
+ $body .= elgg_view('input/hidden',array('id'=>'event-calendar-region-url-start','value'=>$vars['url_start']));
+ $body .= elgg_view("input/dropdown",array('id' => 'event-calendar-region','value'=>$vars['region'],'options_values'=>$options_values));
+ $body .= '<br />';
+}
+
+echo $body;
diff --git a/mod/event_calendar/views/default/event_calendar/reminder_section.php b/mod/event_calendar/views/default/event_calendar/reminder_section.php
new file mode 100644
index 000000000..fffa6d065
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/views/default/event_calendar/repeat_form_element.php b/mod/event_calendar/views/default/event_calendar/repeat_form_element.php
new file mode 100644
index 000000000..5de858caf
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/repeat_form_element.php
@@ -0,0 +1,32 @@
+<?php
+$event = $vars['event'];
+$fd = $vars['form_data'];
+$days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
+
+if ($fd['repeats'] == 'yes') {
+ echo elgg_view('input/checkbox',array('name'=>'repeats','value'=>'yes','checked'=>'checked'));
+} else {
+ echo elgg_view('input/checkbox',array('name'=>'repeats','value'=>'yes'));
+}
+echo elgg_echo('event_calendar:repeat_interval_label').' ';
+echo elgg_view('input/dropdown',array('name'=>'repeat_interval','value'=>$fd['repeat_interval'],'options_values'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8')));
+echo ' '.elgg_echo('event_calendar:repeat_weeks');
+echo ' '.elgg_echo('event_calendar:on_these_days');
+
+echo '<div class="event-calendar-repeating-wrapper">';
+
+foreach($days as $day) {
+ $label = elgg_echo("event_calendar:day_abbrev:$day");
+ echo <<<HTML
+<a id="event-calendar-repeating-$day" href="javascript:void(0);" class="event-calendar-repeating-unselected">
+ $label
+</a>
+HTML;
+
+}
+
+echo '</div>';
+
+foreach($days as $day) {
+ echo elgg_view('input/hidden', array('name' => "event-calendar-repeating-$day-value", 'value' => $fd["event-calendar-repeating-$day-value"]));
+} \ No newline at end of file
diff --git a/mod/event_calendar/views/default/event_calendar/review_requests.php b/mod/event_calendar/views/default/event_calendar/review_requests.php
new file mode 100644
index 000000000..11916b4e3
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/review_requests.php
@@ -0,0 +1,30 @@
+<?php
+
+foreach($vars['requests'] as $request) {
+ if ($request instanceof ElggUser) {
+ $icon = elgg_view("profile/icon", array(
+ 'entity' => $request,
+ 'size' => 'small'
+ ));
+ $info = '<a href="' . $request->getURL() . '" >'.$request->name.'</a>';
+ $info .= '<div style="margin-top: 5px;" ></div>';
+ $info .= elgg_view('output/confirmlink',
+ array(
+ 'class' => "elgg-button elgg-button-delete",
+ 'href' => 'action/event_calendar/killrequest?user_guid='.$request->guid.'&event_guid=' . $vars['entity']->guid,
+ 'confirm' => elgg_echo('event_calendar:request:remove:check'),
+ 'text' => elgg_echo('event_calendar:review_requests:reject'),
+ 'title' => elgg_echo('event_calendar:review_requests:reject:title'),
+ ));
+ $info .= '&nbsp;&nbsp;';
+ $info .= elgg_view('output/url', array(
+ 'text' => elgg_echo('event_calendar:review_requests:accept'),
+ 'title' => elgg_echo('event_calendar:review_requests:accept:title'),
+ 'href' => "action/event_calendar/addtocalendar?user_guid={$request->guid}&event_guid={$vars['entity']->guid}",
+ 'class' => "elgg-button elgg-button-submit",
+ 'is_action' => TRUE,
+ ));
+ //$url = elgg_add_action_tokens_to_url("{$vars['url']}action/event_calendar/addtocalendar?user_guid={$request->guid}&event_guid={$vars['entity']->guid}");
+ echo elgg_view_image_block($icon,$info);
+ }
+}
diff --git a/mod/event_calendar/views/default/event_calendar/schedule_section.php b/mod/event_calendar/views/default/event_calendar/schedule_section.php
new file mode 100644
index 000000000..3a74dc789
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/views/default/event_calendar/share_section.php b/mod/event_calendar/views/default/event_calendar/share_section.php
new file mode 100644
index 000000000..c4f6cf45f
--- /dev/null
+++ b/mod/event_calendar/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 = '<fieldset>';
+$body .= '<legend>'.elgg_echo('event_calendar:permissions:header').'</legend>';
+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 .= '</fieldset>';
+
+echo $body;
diff --git a/mod/event_calendar/views/default/event_calendar/show_events.php b/mod/event_calendar/views/default/event_calendar/show_events.php
new file mode 100644
index 000000000..3a484e756
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/show_events.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Elgg show events view
+ *
+ * @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-12
+ * @link http://radagast.biz/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$listing_format = $vars['listing_format'];
+
+if ($vars['events']) {
+ if ($listing_format == 'agenda') {
+ $vars['events'] = event_calendar_flatten_event_structure($vars['events']);
+ $event_list = elgg_view('event_calendar/agenda_view',$vars);
+ } else if ($listing_format == 'paged') {
+ $vars['events'] = event_calendar_flatten_event_structure($vars['events']);
+ $event_list = elgg_view('event_calendar/paged_view',$vars);
+ } else if ($listing_format == 'full') {
+ $event_list = elgg_view('event_calendar/full_calendar_view',$vars);
+ } else {
+ $vars['events'] = event_calendar_flatten_event_structure($vars['events']);
+ $options = array(
+ 'list_class' => 'elgg-list-entity',
+ 'full_view' => FALSE,
+ 'pagination' => TRUE,
+ 'list_type' => 'listing',
+ 'list_type_toggle' => FALSE,
+ 'offset' => $vars['offset'],
+ 'limit' => $vars['limit'],
+ );
+ $event_list = elgg_view_entity_list($vars['events'], $options);
+ }
+} else {
+ if ($listing_format == 'full') {
+ // show the empty calendar
+ $event_list = elgg_view('event_calendar/full_calendar_view',$vars);
+ } else {
+ $event_list = '<p>'.elgg_echo('event_calendar:no_events_found').'</p>';
+ }
+}
+if ($listing_format == 'paged' || $listing_format == 'full') {
+ echo $event_list;
+} else {
+?>
+<div style="width:100%">
+<div id="event_list" style="float:left;">
+<?php
+echo $event_list;
+?>
+</div>
+<div style="float:right;">
+<?php
+echo elgg_view('event_calendar/calendar',$vars);
+?>
+</div>
+</div>
+<?php
+}
diff --git a/mod/event_calendar/views/default/event_calendar/strapline.php b/mod/event_calendar/views/default/event_calendar/strapline.php
new file mode 100644
index 000000000..edc60aa3e
--- /dev/null
+++ b/mod/event_calendar/views/default/event_calendar/strapline.php
@@ -0,0 +1,18 @@
+<div class="contentWrapper">
+<span class="event_calendar_strapline">
+<?php
+
+ $event = $vars['entity'];
+
+ $time_updated = $event->time_created;
+ $owner_guid = $event->owner_guid;
+ $owner = get_entity($owner_guid);
+
+ echo sprintf(elgg_echo('event_calendar:strapline'),
+ elgg_view_friendly_time($time_updated),
+ "<a href=\"" . $owner->getURL() . "\">" . $owner->name ."</a>"
+ );
+
+?>
+</span>
+</div> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/forms/event_calendar/edit.php b/mod/event_calendar/views/default/forms/event_calendar/edit.php
new file mode 100644
index 000000000..747dae0f0
--- /dev/null
+++ b/mod/event_calendar/views/default/forms/event_calendar/edit.php
@@ -0,0 +1,233 @@
+<?php
+$event = $vars['event'];
+$fd = $vars['form_data'];
+
+$schedule_options = array(
+ elgg_echo('event_calendar:all_day_label') => 'all_day',
+ elgg_echo('event_calendar:schedule_type:fixed')=>'fixed',
+);
+
+if (elgg_is_active_plugin('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');
+
+$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_more_required = elgg_get_plugin_setting('more_required', 'event_calendar');
+$event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar');
+
+if ($event_calendar_more_required == 'yes') {
+ $required_fields = array('title','venue','start_date','start_time',
+ 'brief_description','region','event_type','fees','contact','organiser',
+ 'event_tags','spots');
+} else {
+ $required_fields = array('title','venue','start_date');
+}
+$all_fields = array('title','venue','start_time','start_date','end_time','end_date',
+ 'brief_description','region','event_type','fees','contact','organiser','event_tags',
+ 'long_description','spots','personal_manage');
+
+$prefix = array();
+foreach ($all_fields as $fn) {
+ if (in_array($fn,$required_fields)) {
+ $prefix[$fn] = elgg_echo('event_calendar:required').' ';
+ } else {
+ $prefix[$fn] = elgg_echo('event_calendar:optional').' ';
+ }
+}
+
+if ($event) {
+ $event_action = 'manage_event';
+ $event_guid = $event->guid;
+} else {
+ $event_action = 'add_event';
+ $event_guid = 0;
+}
+
+$title = $fd['title'];
+$brief_description = $fd['description'];
+$venue = $fd['venue'];
+
+$fees = $fd['fees'];
+if ($event_calendar_spots_display) {
+ $spots = $fd['spots'];
+}
+if ($event_calendar_region_display) {
+ $region = $fd['region'];
+}
+if ($event_calendar_type_display) {
+ $event_type = $fd['event_type'];
+}
+$contact = $fd['contact'];
+$organiser = $fd['organiser'];
+$event_tags = $fd['tags'];
+$all_day = $fd['all_day'];
+$schedule_type = $fd['schedule_type'];
+$long_description = $fd['long_description'];
+
+$body = '<div>';
+
+$body .= elgg_view('input/hidden',array('name'=>'event_action', 'value'=>$event_action));
+$body .= elgg_view('input/hidden',array('name'=>'event_guid', 'value'=>$event_guid));
+
+$body .= '<fieldset>';
+$body .= '<legend>' . elgg_echo('event_calendar:basic:header') . '</legend>';
+
+$body .= '<p><label>'.elgg_echo("event_calendar:title_label").'</label>';
+$body .= elgg_view("input/text",array('name' => 'title', 'value' => $title));
+$body .= '</p>';
+$body .= '<p class="event-calendar-description">'.$prefix['title'].elgg_echo('event_calendar:title_description').'</p>';
+
+$body .= '<p><label>'.elgg_echo("event_calendar:venue_label").'</label>';
+$body .= elgg_view("input/text",array('name' => 'venue', 'value' => $venue));
+$body .= '</p>';
+$body .= '<p class="event-calendar-description">'.$prefix['venue'].elgg_echo('event_calendar:venue_description').'</p>';
+
+if ($event_calendar_fewer_fields != 'yes') {
+ $body .= '<p><label>'.elgg_echo("event_calendar:brief_description_label").'</label>';
+ $body .= elgg_view("input/text",array('name' => 'description', 'value' => $brief_description));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['brief_description'].elgg_echo('event_calendar:brief_description_description').'</p>';
+
+} else {
+ $body .= '<label>'.elgg_echo("event_calendar:long_description_label").'</label>';
+ $body .= elgg_view("input/longtext",array('name' => 'long_description', 'value' => $long_description));
+ $body .= '<p class="event-calendar-description">'.$prefix['long_description'].elgg_echo('event_calendar:long_description_description').'</p>';
+}
+
+$body .= '<p><label>'.elgg_echo("event_calendar:event_tags_label").'</label>';
+$body .= elgg_view("input/tags",array('name' => 'tags', 'value' => $event_tags));
+$body .= '</p>';
+$body .= '<p class="event-calendar-description">'.$prefix['event_tags'].elgg_echo('event_calendar:event_tags_description').'</p>';
+
+if ($event || !$vars['group_guid']) {
+ $body .= '<p><label>'.elgg_echo("event_calendar:calendar_label").'</label>';
+ $body .= elgg_view('event_calendar/container',array('container_guid'=>$vars['group_guid']));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['calendar'].elgg_echo('event_calendar:calendar_description').'</p>';
+} else {
+ $body .= elgg_view('input/hidden',array('name'=>'group_guid', 'value'=>$vars['group_guid']));
+}
+
+if($event_calendar_bbb_server_url) {
+ $body .= '<p>';
+ if ($fd['web_conference']) {
+ $body .= elgg_view('input/checkbox',array('name'=>'web_conference','value'=>1,'checked'=>'checked'));
+ } else {
+ $body .= elgg_view('input/checkbox',array('name'=>'web_conference','value'=>1));
+ }
+ $body .= elgg_echo('event_calendar:web_conference_label');
+ $body .= '</p>';
+}
+
+$body .= '</fieldset>';
+
+$body .= '<fieldset>';
+$body .= '<legend>'.elgg_echo('event_calendar:schedule:header').'</legend>';
+$body .= elgg_view('input/radio',array('name'=>'schedule_type','value'=>$schedule_type,'options'=>$schedule_options));
+
+$vars['prefix'] = $prefix;
+
+$body .= elgg_view('event_calendar/schedule_section',$vars);
+
+if ($event_calendar_spots_display == 'yes') {
+ $body .= '<p><label>'.elgg_echo("event_calendar:spots_label").'<br />';
+ $body .= elgg_view("input/text",array('name' => 'spots', 'value' => $spots));
+ $body .= '</label></p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['spots'].elgg_echo('event_calendar:spots_description').'</p>';
+}
+
+$body .= '<div class="event-calendar-edit-bottom"></div>';
+$body .= '</fieldset>';
+
+$body .= elgg_view('event_calendar/personal_manage_section',$vars);
+
+$body .= elgg_view('event_calendar/share_section',$vars);
+
+if ($event_calendar_region_display == 'yes' || $event_calendar_type_display == 'yes' || $event_calendar_fewer_fields != 'yes') {
+ $body .= '<fieldset>';
+
+ if ($event_calendar_region_display == 'yes') {
+ $region_list = trim(elgg_get_plugin_setting('region_list', 'event_calendar'));
+ $region_list_handles = elgg_get_plugin_setting('region_list_handles', 'event_calendar');
+ // make sure that we are using Unix line endings
+ $region_list = str_replace("\r\n","\n",$region_list);
+ $region_list = str_replace("\r","\n",$region_list);
+ if ($region_list) {
+ $options = array();
+ $options[] = '-';
+ foreach(explode("\n",$region_list) as $region_item) {
+ $region_item = trim($region_item);
+ if ($region_list_handles == 'yes') {
+ $options[$region_item] = elgg_echo('event_calendar:region:'.$region_item);
+ } else {
+ $options[$region_item] = $region_item;
+ }
+ }
+ $body .= '<p><label>'.elgg_echo("event_calendar:region_label").'</label>';
+ $body .= elgg_view("input/dropdown",array('name' => 'region','value'=>$region,'options_values'=>$options));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['region'].elgg_echo('event_calendar:region_description').'</p>';
+ }
+ }
+
+ if ($event_calendar_type_display == 'yes') {
+ $type_list = trim(elgg_get_plugin_setting('type_list', 'event_calendar'));
+ $type_list_handles = elgg_get_plugin_setting('type_list_handles', 'event_calendar');
+ // make sure that we are using Unix line endings
+ $type_list = str_replace("\r\n","\n",$type_list);
+ $type_list = str_replace("\r","\n",$type_list);
+ if ($type_list) {
+ $options = array();
+ $options[] = '-';
+ foreach(explode("\n",$type_list) as $type_item) {
+ $type_item = trim($type_item);
+ if ($type_list_handles == 'yes') {
+ $options[$type_item] = elgg_echo('event_calendar:type:'.$type_item);
+ } else {
+ $options[$type_item] = $type_item;
+ }
+ }
+ $body .= '<p><label>'.elgg_echo("event_calendar:type_label").'</label>';
+ $body .= elgg_view("input/dropdown",array('name' => 'event_type','value'=>$event_type,'options_values'=>$options));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['event_type'].elgg_echo('event_calendar:type_description').'</p>';
+ }
+ }
+
+ if ($event_calendar_fewer_fields != 'yes') {
+
+ $body .= '<p><label>'.elgg_echo("event_calendar:fees_label").'</label>';
+ $body .= elgg_view("input/text",array('name' => 'fees', 'value' => $fees));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['fees'].elgg_echo('event_calendar:fees_description').'</p>';
+
+ $body .= '<p><label>'.elgg_echo("event_calendar:contact_label").'</label>';
+ $body .= elgg_view("input/text",array('name' => 'contact', 'value' => $contact));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['contact'].elgg_echo('event_calendar:contact_description').'</p>';
+
+ $body .= '<p><label>'.elgg_echo("event_calendar:organiser_label").'</label>';
+ $body .= elgg_view("input/text",array('name' => 'organiser', 'value' => $organiser));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['organiser'].elgg_echo('event_calendar:organiser_description').'</p>';
+
+ $body .= '<p><label>'.elgg_echo("event_calendar:long_description_label").'</label>';
+ $body .= elgg_view("input/longtext",array('name' => 'long_description', 'value' => $long_description));
+ $body .= '</p>';
+ $body .= '<p class="event-calendar-description">'.$prefix['long_description'].elgg_echo('event_calendar:long_description_description').'</p>';
+ }
+
+ $body .= '</fieldset>';
+}
+
+$body .= elgg_view('input/submit', array('name'=>'submit','value'=>elgg_echo('event_calendar:submit')));
+
+$body .= '</div>';
+
+echo $body;
diff --git a/mod/event_calendar/views/default/forms/event_calendar/manage_subscribers.php b/mod/event_calendar/views/default/forms/event_calendar/manage_subscribers.php
new file mode 100644
index 000000000..8039c5015
--- /dev/null
+++ b/mod/event_calendar/views/default/forms/event_calendar/manage_subscribers.php
@@ -0,0 +1,14 @@
+<?php
+$event = $vars['event'];
+$users = event_calendar_get_users_for_event($event->guid,0);
+$guids = array();
+foreach($users as $user) {
+ $guids[] = $user->guid;
+}
+// TODO: if the event container is a group need to restrict user picker to the members of the group?
+$content = elgg_view('input/userpicker_plus',array('value'=> $guids));
+$content .= '<br /><br />';
+$content .= elgg_view('input/hidden',array('name'=>'event_guid','value'=>$event->guid));
+$content .= elgg_view('input/submit',array('value'=>elgg_echo('submit'),'name'=>'submit_manage_subscribers','id'=>'submit-manage-subscribers'));
+
+echo $content;
diff --git a/mod/event_calendar/views/default/fullcalendar/css.php b/mod/event_calendar/views/default/fullcalendar/css.php
new file mode 100644
index 000000000..04f118493
--- /dev/null
+++ b/mod/event_calendar/views/default/fullcalendar/css.php
@@ -0,0 +1,618 @@
+/*
+ * FullCalendar v1.5.3 Stylesheet
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Mon Feb 6 22:40:40 2012 -0800
+ *
+ */
+
+
+.fc {
+ direction: ltr;
+ text-align: left;
+ }
+
+.fc table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+
+html .fc,
+.fc table {
+ font-size: 1em;
+ }
+
+.fc td,
+.fc th {
+ padding: 0;
+ vertical-align: top;
+ }
+
+
+
+/* Header
+------------------------------------------------------------------------*/
+
+.fc-header td {
+ white-space: nowrap;
+ }
+
+.fc-header-left {
+ width: 25%;
+ text-align: left;
+ }
+
+.fc-header-center {
+ text-align: center;
+ }
+
+.fc-header-right {
+ width: 25%;
+ text-align: right;
+ }
+
+.fc-header-title {
+ display: inline-block;
+ vertical-align: top;
+ }
+
+.fc-header-title h2 {
+ margin-top: 0;
+ white-space: nowrap;
+ }
+
+.fc .fc-header-space {
+ padding-left: 10px;
+ }
+
+.fc-header .fc-button {
+ margin-bottom: 1em;
+ vertical-align: top;
+ }
+
+/* buttons edges butting together */
+
+.fc-header .fc-button {
+ margin-right: -1px;
+ }
+
+.fc-header .fc-corner-right {
+ margin-right: 1px; /* back to normal */
+ }
+
+.fc-header .ui-corner-right {
+ margin-right: 0; /* back to normal */
+ }
+
+/* button layering (for border precedence) */
+
+.fc-header .fc-state-hover,
+.fc-header .ui-state-hover {
+ z-index: 2;
+ }
+
+.fc-header .fc-state-down {
+ z-index: 3;
+ }
+
+.fc-header .fc-state-active,
+.fc-header .ui-state-active {
+ z-index: 4;
+ }
+
+
+
+/* Content
+------------------------------------------------------------------------*/
+
+.fc-content {
+ clear: both;
+ }
+
+.fc-view {
+ width: 100%; /* needed for view switching (when view is absolute) */
+ overflow: hidden;
+ }
+
+
+
+/* Cell Styles
+------------------------------------------------------------------------*/
+
+.fc-widget-header, /* <th>, usually */
+.fc-widget-content { /* <td>, usually */
+ border: 1px solid #ccc;
+ }
+
+.fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
+ background: #ffc;
+ }
+
+.fc-cell-overlay { /* semi-transparent rectangle while dragging */
+ background: #9cf;
+ opacity: .2;
+ filter: alpha(opacity=20); /* for IE */
+ }
+
+
+
+/* Buttons
+------------------------------------------------------------------------*/
+
+.fc-button {
+ position: relative;
+ display: inline-block;
+ cursor: pointer;
+ }
+
+.fc-state-default { /* non-theme */
+ border-style: solid;
+ border-width: 1px 0;
+ }
+
+.fc-button-inner {
+ position: relative;
+ float: left;
+ overflow: hidden;
+ }
+
+.fc-state-default .fc-button-inner { /* non-theme */
+ border-style: solid;
+ border-width: 0 1px;
+ }
+
+.fc-button-content {
+ position: relative;
+ float: left;
+ height: 1.9em;
+ line-height: 1.9em;
+ padding: 0 .6em;
+ white-space: nowrap;
+ }
+
+/* icon (for jquery ui) */
+
+.fc-button-content .fc-icon-wrap {
+ position: relative;
+ float: left;
+ top: 50%;
+ }
+
+.fc-button-content .ui-icon {
+ position: relative;
+ float: left;
+ margin-top: -50%;
+ *margin-top: 0;
+ *top: -50%;
+ }
+
+/* gloss effect */
+
+.fc-state-default .fc-button-effect {
+ position: absolute;
+ top: 50%;
+ left: 0;
+ }
+
+.fc-state-default .fc-button-effect span {
+ position: absolute;
+ top: -100px;
+ left: 0;
+ width: 500px;
+ height: 100px;
+ border-width: 100px 0 0 1px;
+ border-style: solid;
+ border-color: #fff;
+ background: #444;
+ opacity: .09;
+ filter: alpha(opacity=9);
+ }
+
+/* button states (determines colors) */
+
+.fc-state-default,
+.fc-state-default .fc-button-inner {
+ border-style: solid;
+ border-color: #ccc #bbb #aaa;
+ background: #F3F3F3;
+ color: #000;
+ }
+
+.fc-state-hover,
+.fc-state-hover .fc-button-inner {
+ border-color: #999;
+ }
+
+.fc-state-down,
+.fc-state-down .fc-button-inner {
+ border-color: #555;
+ background: #777;
+ }
+
+.fc-state-active,
+.fc-state-active .fc-button-inner {
+ border-color: #555;
+ background: #777;
+ color: #fff;
+ }
+
+.fc-state-disabled,
+.fc-state-disabled .fc-button-inner {
+ color: #999;
+ border-color: #ddd;
+ }
+
+.fc-state-disabled {
+ cursor: default;
+ }
+
+.fc-state-disabled .fc-button-effect {
+ display: none;
+ }
+
+
+
+/* Global Event Styles
+------------------------------------------------------------------------*/
+
+.fc-event {
+ border-style: solid;
+ border-width: 0;
+ font-size: .85em;
+ cursor: default;
+ }
+
+a.fc-event,
+.fc-event-draggable {
+ cursor: pointer;
+ }
+
+a.fc-event {
+ text-decoration: none;
+ }
+
+.fc-rtl .fc-event {
+ text-align: right;
+ }
+
+.fc-event-skin {
+ border-color: #36c; /* default BORDER color */
+ background-color: #36c; /* default BACKGROUND color */
+ color: #fff; /* default TEXT color */
+ }
+
+.fc-event-inner {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ border-style: solid;
+ border-width: 0;
+ overflow: hidden;
+ }
+
+.fc-event-time,
+.fc-event-title {
+ padding: 0 1px;
+ }
+
+.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/
+ display: block;
+ position: absolute;
+ z-index: 99999;
+ overflow: hidden; /* hacky spaces (IE6/7) */
+ font-size: 300%; /* */
+ line-height: 50%; /* */
+ }
+
+
+
+/* Horizontal Events
+------------------------------------------------------------------------*/
+
+.fc-event-hori {
+ border-width: 1px 0;
+ margin-bottom: 1px;
+ }
+
+/* resizable */
+
+.fc-event-hori .ui-resizable-e {
+ top: 0 !important; /* importants override pre jquery ui 1.7 styles */
+ right: -3px !important;
+ width: 7px !important;
+ height: 100% !important;
+ cursor: e-resize;
+ }
+
+.fc-event-hori .ui-resizable-w {
+ top: 0 !important;
+ left: -3px !important;
+ width: 7px !important;
+ height: 100% !important;
+ cursor: w-resize;
+ }
+
+.fc-event-hori .ui-resizable-handle {
+ _padding-bottom: 14px; /* IE6 had 0 height */
+ }
+
+
+
+/* Fake Rounded Corners (for buttons and events)
+------------------------------------------------------------*/
+
+.fc-corner-left {
+ margin-left: 1px;
+ }
+
+.fc-corner-left .fc-button-inner,
+.fc-corner-left .fc-event-inner {
+ margin-left: -1px;
+ }
+
+.fc-corner-right {
+ margin-right: 1px;
+ }
+
+.fc-corner-right .fc-button-inner,
+.fc-corner-right .fc-event-inner {
+ margin-right: -1px;
+ }
+
+.fc-corner-top {
+ margin-top: 1px;
+ }
+
+.fc-corner-top .fc-event-inner {
+ margin-top: -1px;
+ }
+
+.fc-corner-bottom {
+ margin-bottom: 1px;
+ }
+
+.fc-corner-bottom .fc-event-inner {
+ margin-bottom: -1px;
+ }
+
+
+
+/* Fake Rounded Corners SPECIFICALLY FOR EVENTS
+-----------------------------------------------------------------*/
+
+.fc-corner-left .fc-event-inner {
+ border-left-width: 1px;
+ }
+
+.fc-corner-right .fc-event-inner {
+ border-right-width: 1px;
+ }
+
+.fc-corner-top .fc-event-inner {
+ border-top-width: 1px;
+ }
+
+.fc-corner-bottom .fc-event-inner {
+ border-bottom-width: 1px;
+ }
+
+
+
+/* Reusable Separate-border Table
+------------------------------------------------------------*/
+
+table.fc-border-separate {
+ border-collapse: separate;
+ }
+
+.fc-border-separate th,
+.fc-border-separate td {
+ border-width: 1px 0 0 1px;
+ }
+
+.fc-border-separate th.fc-last,
+.fc-border-separate td.fc-last {
+ border-right-width: 1px;
+ }
+
+.fc-border-separate tr.fc-last th,
+.fc-border-separate tr.fc-last td {
+ border-bottom-width: 1px;
+ }
+
+.fc-border-separate tbody tr.fc-first td,
+.fc-border-separate tbody tr.fc-first th {
+ border-top-width: 0;
+ }
+
+
+
+/* Month View, Basic Week View, Basic Day View
+------------------------------------------------------------------------*/
+
+.fc-grid th {
+ text-align: center;
+ }
+
+.fc-grid .fc-day-number {
+ float: right;
+ padding: 0 2px;
+ }
+
+.fc-grid .fc-other-month .fc-day-number {
+ opacity: 0.3;
+ filter: alpha(opacity=30); /* for IE */
+ /* opacity with small font can sometimes look too faded
+ might want to set the 'color' property instead
+ making day-numbers bold also fixes the problem */
+ }
+
+.fc-grid .fc-day-content {
+ clear: both;
+ padding: 2px 2px 1px; /* distance between events and day edges */
+ }
+
+/* event styles */
+
+.fc-grid .fc-event-time {
+ font-weight: bold;
+ }
+
+/* right-to-left */
+
+.fc-rtl .fc-grid .fc-day-number {
+ float: left;
+ }
+
+.fc-rtl .fc-grid .fc-event-time {
+ float: right;
+ }
+
+
+
+/* Agenda Week View, Agenda Day View
+------------------------------------------------------------------------*/
+
+.fc-agenda table {
+ border-collapse: separate;
+ }
+
+.fc-agenda-days th {
+ text-align: center;
+ }
+
+.fc-agenda .fc-agenda-axis {
+ width: 50px;
+ padding: 0 4px;
+ vertical-align: middle;
+ text-align: right;
+ white-space: nowrap;
+ font-weight: normal;
+ }
+
+.fc-agenda .fc-day-content {
+ padding: 2px 2px 1px;
+ }
+
+/* make axis border take precedence */
+
+.fc-agenda-days .fc-agenda-axis {
+ border-right-width: 1px;
+ }
+
+.fc-agenda-days .fc-col0 {
+ border-left-width: 0;
+ }
+
+/* all-day area */
+
+.fc-agenda-allday th {
+ border-width: 0 1px;
+ }
+
+.fc-agenda-allday .fc-day-content {
+ min-height: 34px; /* TODO: doesnt work well in quirksmode */
+ _height: 34px;
+ }
+
+/* divider (between all-day and slots) */
+
+.fc-agenda-divider-inner {
+ height: 2px;
+ overflow: hidden;
+ }
+
+.fc-widget-header .fc-agenda-divider-inner {
+ background: #eee;
+ }
+
+/* slot rows */
+
+.fc-agenda-slots th {
+ border-width: 1px 1px 0;
+ }
+
+.fc-agenda-slots td {
+ border-width: 1px 0 0;
+ background: none;
+ }
+
+.fc-agenda-slots td div {
+ height: 20px;
+ }
+
+.fc-agenda-slots tr.fc-slot0 th,
+.fc-agenda-slots tr.fc-slot0 td {
+ border-top-width: 0;
+ }
+
+.fc-agenda-slots tr.fc-minor th,
+.fc-agenda-slots tr.fc-minor td {
+ border-top-style: dotted;
+ }
+
+.fc-agenda-slots tr.fc-minor th.ui-widget-header {
+ *border-top-style: solid; /* doesn't work with background in IE6/7 */
+ }
+
+
+
+/* Vertical Events
+------------------------------------------------------------------------*/
+
+.fc-event-vert {
+ border-width: 0 1px;
+ }
+
+.fc-event-vert .fc-event-head,
+.fc-event-vert .fc-event-content {
+ position: relative;
+ z-index: 2;
+ width: 100%;
+ overflow: hidden;
+ }
+
+.fc-event-vert .fc-event-time {
+ white-space: nowrap;
+ font-size: 10px;
+ }
+
+.fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */
+ position: absolute;
+ z-index: 1;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: #fff;
+ opacity: .3;
+ filter: alpha(opacity=30);
+ }
+
+.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
+.fc-select-helper .fc-event-bg {
+ display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */
+ }
+
+/* resizable */
+
+.fc-event-vert .ui-resizable-s {
+ bottom: 0 !important; /* importants override pre jquery ui 1.7 styles */
+ width: 100% !important;
+ height: 8px !important;
+ overflow: hidden !important;
+ line-height: 8px !important;
+ font-size: 11px !important;
+ font-family: monospace;
+ text-align: center;
+ cursor: s-resize;
+ }
+
+.fc-agenda .ui-resizable-resizing { /* TODO: better selector */
+ _overflow: hidden;
+ }
+
+
diff --git a/mod/event_calendar/views/default/fullcalendar/fullcalendar.print.css b/mod/event_calendar/views/default/fullcalendar/fullcalendar.print.css
new file mode 100644
index 000000000..e11c18163
--- /dev/null
+++ b/mod/event_calendar/views/default/fullcalendar/fullcalendar.print.css
@@ -0,0 +1,61 @@
+/*
+ * FullCalendar v1.5.3 Print Stylesheet
+ *
+ * Include this stylesheet on your page to get a more printer-friendly calendar.
+ * When including this stylesheet, use the media='print' attribute of the <link> tag.
+ * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Mon Feb 6 22:40:40 2012 -0800
+ *
+ */
+
+
+ /* Events
+-----------------------------------------------------*/
+
+.fc-event-skin {
+ background: none !important;
+ color: #000 !important;
+ }
+
+/* horizontal events */
+
+.fc-event-hori {
+ border-width: 0 0 1px 0 !important;
+ border-bottom-style: dotted !important;
+ border-bottom-color: #000 !important;
+ padding: 1px 0 0 0 !important;
+ }
+
+.fc-event-hori .fc-event-inner {
+ border-width: 0 !important;
+ padding: 0 1px !important;
+ }
+
+/* vertical events */
+
+.fc-event-vert {
+ border-width: 0 0 0 1px !important;
+ border-left-style: dotted !important;
+ border-left-color: #000 !important;
+ padding: 0 1px 0 0 !important;
+ }
+
+.fc-event-vert .fc-event-inner {
+ border-width: 0 !important;
+ padding: 1px 0 !important;
+ }
+
+.fc-event-bg {
+ display: none !important;
+ }
+
+.fc-event .ui-resizable-handle {
+ display: none !important;
+ }
+
+
diff --git a/mod/event_calendar/views/default/icon/object/event_calendar/small.php b/mod/event_calendar/views/default/icon/object/event_calendar/small.php
new file mode 100644
index 000000000..d30d14453
--- /dev/null
+++ b/mod/event_calendar/views/default/icon/object/event_calendar/small.php
@@ -0,0 +1,3 @@
+<?php
+ echo $vars['url'] . "mod/event_calendar/images/event_icon.gif";
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/input/datepicker_inline.php b/mod/event_calendar/views/default/input/datepicker_inline.php
new file mode 100644
index 000000000..3fd9c37af
--- /dev/null
+++ b/mod/event_calendar/views/default/input/datepicker_inline.php
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ * JQuery data picker(inline version)
+ *
+ * @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 -2011
+ * @link http://radagast.biz/
+ *
+ */
+if ($vars['group_guid']) {
+ $link_bit = $vars['url']."event_calendar/group/{$vars['group_guid']}/%s/{$vars['mode']}";
+} else {
+ $link_bit = $vars['url']."event_calendar/list/%s/{$vars['mode']}/{$vars['filter']}";
+}
+
+if ($vars['mode'] == 'week') {
+ $selected_week = date('W',strtotime($vars['start_date'].' UTC'))+1;
+} else {
+ $selected_week = '';
+}
+
+if ($vars['mode']) {
+ $wrapper_class = "event-calendar-filter-period-".$vars['mode'];
+} else {
+ $wrapper_class = "event-calendar-filter-period-month";
+}
+// TODO - figure out how to move this JavaScript
+?>
+
+<script language="javascript">
+var selectedWeek = "<?php echo $selected_week; ?>";
+highlightWeek = function(d) {
+ if (!selectedWeek) { return [true,''];}
+ //var date = $(this).datepicker('getDate');
+ var dayOfWeek = d.getUTCDay();
+ var weekNumber = $.datepicker.iso8601Week(d);
+ if (dayOfWeek == 6) {
+ weekNumber += 1;
+ }
+
+ if (selectedWeek == weekNumber) {
+ return [true,'week-highlight'];
+ }
+ return [true,''];
+}
+$(document).ready(function(){
+var done_loading = false;
+$("#<?php echo $vars['name']; ?>").datepicker({
+ onChangeMonthYear: function(year, month, inst) {
+ if(inst.onChangeToday){
+ day=inst.selectedDay;
+ }else{
+ day=1;
+ }
+ if (done_loading) {
+ // in this case the mode is forced to month
+ document.location.href = "<?php echo $link_bit; ?>".replace('%s', year+'-'+month+'-1');
+ }
+ },
+ onSelect: function(date) {
+ // jump to the new page
+ document.location.href = "<?php echo $link_bit; ?>".replace('%s', date.substring(0,10));
+ },
+ dateFormat: "yy-mm-dd",
+ defaultDate: "<?php echo $vars['start_date'] .' - '.$vars['end_date']; ?>",
+ beforeShowDay: highlightWeek
+});
+var start_date = $.datepicker.parseDate("yy-mm-dd", "<?php echo $vars['start_date']; ?>");
+var end_date = $.datepicker.parseDate("yy-mm-dd", "<?php echo $vars['end_date']; ?>");
+// not sure why this is necessary, but it seems to be
+if ("<?php echo $vars['mode'] ?>" == "month") {
+ end_date += 1;
+}
+$("#<?php echo $vars['name']; ?>").datepicker("setDate", start_date, end_date);
+done_loading = true;
+});
+
+</script>
+<div style="position:relative;" id="<?php echo $vars['name']; ?>" class="<?php echo $wrapper_class; ?>" ></div>
+<p style="clear: both;"><!-- See day-by-day example for highlighting days code --></p> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/input/timepicker.php b/mod/event_calendar/views/default/input/timepicker.php
new file mode 100644
index 000000000..2cc95ced7
--- /dev/null
+++ b/mod/event_calendar/views/default/input/timepicker.php
@@ -0,0 +1,51 @@
+<?php
+$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar');
+if (!$time_format) {
+ $time_format = '24';
+}
+
+$value = $vars['value'];
+if (is_numeric($value)) {
+ $hour = floor($value/60);
+ $minute = ($value -60*$hour);
+} else {
+ $hour = 0;
+ $minute = 0;
+}
+
+$hours = array();
+$minutes = array();
+
+if ($time_format == '12') {
+ $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 {
+ $hour -= 12;
+ $meridian = 'pm';
+ }
+ for($h=1;$h<=12;$h++) {
+ $hours[$h] = $h;
+ }
+} else {
+ for($h=0;$h<=23;$h++) {
+ $hours[$h] = $h;
+ }
+}
+
+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/mod/event_calendar/views/default/input/timepicker_old.php b/mod/event_calendar/views/default/input/timepicker_old.php
new file mode 100644
index 000000000..1d2156cda
--- /dev/null
+++ b/mod/event_calendar/views/default/input/timepicker_old.php
@@ -0,0 +1,38 @@
+<?php
+
+$time_format = elgg_get_plugin_setting('timeformat', 'event_calendar');
+if (!$time_format) {
+ $time_format = 24;
+}
+
+$value = $vars['value'];
+if (is_numeric($value)) {
+ $hour = floor($value/60);
+ $minute = ($value -60*$hour);
+
+ // add 1 to avoid pulldown 0 bug
+ $hour++;
+ $minute++;
+} else {
+ $hour = '-';
+ $minute = '-';
+}
+
+$hours = array();
+$hours['-'] = '-';
+
+for($i=0;$i<$time_format;$i++) {
+ $hours[$i+1] = $i;
+}
+
+$minutes = array();
+$minutes['-'] = '-';
+
+for($i=0;$i<60;$i=$i+15) {
+ $minutes[$i+1] = sprintf("%02d",$i);
+}
+
+echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_h','value'=>$hour,'options_values'=>$hours));
+echo elgg_view('input/dropdown',array('name'=>$vars['name'].'_m','value'=>$minute,'options_values'=>$minutes));
+
+?> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/js/event_calendar/event_calendar.php b/mod/event_calendar/views/default/js/event_calendar/event_calendar.php
new file mode 100644
index 000000000..efa1dc1dd
--- /dev/null
+++ b/mod/event_calendar/views/default/js/event_calendar/event_calendar.php
@@ -0,0 +1,171 @@
+//<script type="text/javascript">
+elgg.provide('elgg.event_calendar');
+
+elgg.event_calendar.init = function () {
+ $('.event_calendar_paged_checkbox').click(elgg.event_calendar.handlePagedPersonalCalendarToggle);
+ $('.event-calendar-personal-calendar-toggle').click(elgg.event_calendar.handleDisplayPagePersonalCalendarToggle);
+ $('#event-calendar-region').change(elgg.event_calendar.handleRegionChange);
+ $('#event-calendar-ical-link').click(elgg.event_calendar.handleIcalPopup);
+ $('.event-calendar-repeating-unselected').each(elgg.event_calendar.setRepeatingClass);
+ $('.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);
+ $('input.elgg-input-radio[name="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')) {
+ //$('[name="start_time"]').val(0);
+ $('#event-calendar-start-time-wrapper').attr('disabled','disabled');
+ //$('[name="end_time"]').val(0);
+ $('#event-calendar-end-time-wrapper').attr('disabled','disabled');
+ }
+ all_day_field.change(elgg.event_calendar.handleAllDayField);
+
+ $('.elgg-input-date[name="start_date"], .elgg-input-date[name="end_date"]').datepicker({
+ dateFormat: 'yy-mm-dd',
+ numberOfMonths: 3,
+ onSelect: elgg.event_calendar.handleDateRangeSelect,
+ });
+}
+
+elgg.event_calendar.handleScheduleType = function(e) {
+ var st = $('input.elgg-input-radio[name="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') {
+ $("#event-calendar-start-time-wrapper").hide();
+ $("#event-calendar-end-time-wrapper").hide();
+ } else {
+ $("#event-calendar-start-time-wrapper").show();
+ $("#event-calendar-end-time-wrapper").show();
+ }
+ }
+}
+
+elgg.event_calendar.handleAllDayField = function(e) {
+ var field = $('[name="start_time"]');
+ if (field.attr('disabled') == 'disabled') {
+ field.removeAttr('disabled');
+ } else {
+ field.attr('disabled','disabled');
+ }
+
+ field = $('[name="end_time"]');
+ if (field.attr('disabled') == 'disabled') {
+ field.removeAttr('disabled');
+ } else {
+ field.attr('disabled','disabled');
+ }
+}
+
+elgg.event_calendar.handleDateRangeSelect = function(selectedDate) {
+ if (this.name == 'start_date') {
+ $('.elgg-input-date[name="end_date"]').datepicker("option", "minDate", selectedDate);
+ } else {
+ $('.elgg-input-date[name="start_date"]').datepicker("option", "maxDate", selectedDate);
+ }
+}
+
+elgg.event_calendar.handleEditFormSubmit = function(e) {
+ if ($.trim($('[name="title"]').val()) == '') {
+ alert(elgg.echo('event_calendar:edit_form:error:missing_title'));
+ e.preventDefault();
+ }
+}
+
+elgg.event_calendar.setRepeatingClass = function(e) {
+ var id = $(this).attr('id');
+ if ($("[name='"+id+"-value']").val() == 1) {
+ $(this).removeClass('event-calendar-repeating-unselected');
+ $(this).addClass('event-calendar-repeating-selected');
+ }
+}
+
+elgg.event_calendar.handleRepeatingSelect = function(e) {
+ $(this).removeClass('event-calendar-repeating-unselected');
+ $(this).addClass('event-calendar-repeating-selected');
+ var id = $(this).attr('id');
+ $("[name='"+id+"-value']").val(1);
+}
+
+elgg.event_calendar.handleRepeatingUnselect = function(e) {
+ $(this).removeClass('event-calendar-repeating-selected');
+ $(this).addClass('event-calendar-repeating-unselected');
+ var id = $(this).attr('id');
+ $("[name='"+id+"-value']").val(0);
+}
+
+elgg.event_calendar.handleRegionChange = function(e) {
+ url = $('#event-calendar-region-url-start').val()+"/"+escape($('#event-calendar-region').val());
+ elgg.forward(url);
+}
+
+elgg.event_calendar.handleIcalPopup = function(e) {
+ this.href = '#event-calendar-ical';
+ e.preventDefault();
+}
+
+elgg.event_calendar.handlePagedPersonalCalendarToggle = function() {
+ guid = parseInt($(this).attr('id').substring('event_calendar_paged_checkbox_'.length));
+ elgg.event_calendar.togglePagedPersonalCalendar(guid);
+}
+elgg.event_calendar.togglePagedPersonalCalendar = function(guid) {
+ elgg.action('event_calendar/toggle_personal_calendar',
+ {
+ data: {event_guid: guid},
+ success: function (res) {
+ var success = res.success;
+ var msg = res.message;
+ if (success) {
+ elgg.system_message(msg,2000);
+ } else {
+ elgg.register_error(msg,2000);
+ }
+ //$('#event_calendar_paged_messages').html(msg);
+ if (!success) {
+ // action failed so toggle checkbox
+ $("#event_calendar_paged_checkbox_"+guid).attr('checked',!$("#event_calendar_paged_checkbox_"+guid).attr('checked'));
+ }
+ }
+ }
+ );
+}
+
+elgg.event_calendar.handleDisplayPagePersonalCalendarToggle = function() {
+ var guidBit = $(this).attr('id').substring('event_calendar_user_data_'.length);
+ var guids = guidBit.split('_');
+ var event_guid = parseInt(guids[0]);
+ var user_guid = parseInt(guids[1]);
+ elgg.event_calendar.toggleDisplayPagePersonalCalendar(event_guid,user_guid);
+}
+
+elgg.event_calendar.toggleDisplayPagePersonalCalendar = function(event_guid,user_guid) {
+ elgg.action('event_calendar/toggle_personal_calendar',
+ {
+ data: {event_guid: event_guid,user_guid: user_guid, other: 'yes'},
+ success: function (res) {
+ var success = res.success;
+ var msg = res.message;
+ if (success) {
+ var button_text = res.button_text;
+ $('#event_calendar_user_data_'+event_guid+'_'+user_guid).val(button_text);
+ //elgg.system_message(msg,2000);
+ } else {
+ elgg.register_error(msg,2000);
+ }
+ }
+ }
+ );
+}
+
+elgg.register_hook_handler('init', 'system', elgg.event_calendar.init);
+//</script> \ No newline at end of file
diff --git a/mod/event_calendar/views/default/js/event_calendar/fullcalendar.min.js b/mod/event_calendar/views/default/js/event_calendar/fullcalendar.min.js
new file mode 100644
index 000000000..df37bdfd8
--- /dev/null
+++ b/mod/event_calendar/views/default/js/event_calendar/fullcalendar.min.js
@@ -0,0 +1,114 @@
+/*
+
+ FullCalendar v1.5.3
+ http://arshaw.com/fullcalendar/
+
+ Use fullcalendar.css for basic styling.
+ For event drag & drop, requires jQuery UI draggable.
+ For event resizing, requires jQuery UI resizable.
+
+ Copyright (c) 2011 Adam Shaw
+ Dual licensed under the MIT and GPL licenses, located in
+ MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+
+ Date: Mon Feb 6 22:40:40 2012 -0800
+
+*/
+(function(m,ma){function wb(a){m.extend(true,Ya,a)}function Yb(a,b,e){function d(k){if(E){u();q();na();S(k)}else f()}function f(){B=b.theme?"ui":"fc";a.addClass("fc");b.isRTL&&a.addClass("fc-rtl");b.theme&&a.addClass("ui-widget");E=m("<div class='fc-content' style='position:relative'/>").prependTo(a);C=new Zb(X,b);(P=C.render())&&a.prepend(P);y(b.defaultView);m(window).resize(oa);t()||g()}function g(){setTimeout(function(){!n.start&&t()&&S()},0)}function l(){m(window).unbind("resize",oa);C.destroy();
+E.remove();a.removeClass("fc fc-rtl ui-widget")}function j(){return i.offsetWidth!==0}function t(){return m("body")[0].offsetWidth!==0}function y(k){if(!n||k!=n.name){F++;pa();var D=n,Z;if(D){(D.beforeHide||xb)();Za(E,E.height());D.element.hide()}else Za(E,1);E.css("overflow","hidden");if(n=Y[k])n.element.show();else n=Y[k]=new Ja[k](Z=s=m("<div class='fc-view fc-view-"+k+"' style='position:absolute'/>").appendTo(E),X);D&&C.deactivateButton(D.name);C.activateButton(k);S();E.css("overflow","");D&&
+Za(E,1);Z||(n.afterShow||xb)();F--}}function S(k){if(j()){F++;pa();o===ma&&u();var D=false;if(!n.start||k||r<n.start||r>=n.end){n.render(r,k||0);fa(true);D=true}else if(n.sizeDirty){n.clearEvents();fa();D=true}else if(n.eventsDirty){n.clearEvents();D=true}n.sizeDirty=false;n.eventsDirty=false;ga(D);W=a.outerWidth();C.updateTitle(n.title);k=new Date;k>=n.start&&k<n.end?C.disableButton("today"):C.enableButton("today");F--;n.trigger("viewDisplay",i)}}function Q(){q();if(j()){u();fa();pa();n.clearEvents();
+n.renderEvents(J);n.sizeDirty=false}}function q(){m.each(Y,function(k,D){D.sizeDirty=true})}function u(){o=b.contentHeight?b.contentHeight:b.height?b.height-(P?P.height():0)-Sa(E):Math.round(E.width()/Math.max(b.aspectRatio,0.5))}function fa(k){F++;n.setHeight(o,k);if(s){s.css("position","relative");s=null}n.setWidth(E.width(),k);F--}function oa(){if(!F)if(n.start){var k=++v;setTimeout(function(){if(k==v&&!F&&j())if(W!=(W=a.outerWidth())){F++;Q();n.trigger("windowResize",i);F--}},200)}else g()}function ga(k){if(!b.lazyFetching||
+ya(n.visStart,n.visEnd))ra();else k&&da()}function ra(){K(n.visStart,n.visEnd)}function sa(k){J=k;da()}function ha(k){da(k)}function da(k){na();if(j()){n.clearEvents();n.renderEvents(J,k);n.eventsDirty=false}}function na(){m.each(Y,function(k,D){D.eventsDirty=true})}function ua(k,D,Z){n.select(k,D,Z===ma?true:Z)}function pa(){n&&n.unselect()}function U(){S(-1)}function ca(){S(1)}function ka(){gb(r,-1);S()}function qa(){gb(r,1);S()}function G(){r=new Date;S()}function p(k,D,Z){if(k instanceof Date)r=
+N(k);else yb(r,k,D,Z);S()}function L(k,D,Z){k!==ma&&gb(r,k);D!==ma&&hb(r,D);Z!==ma&&ba(r,Z);S()}function c(){return N(r)}function z(){return n}function H(k,D){if(D===ma)return b[k];if(k=="height"||k=="contentHeight"||k=="aspectRatio"){b[k]=D;Q()}}function T(k,D){if(b[k])return b[k].apply(D||i,Array.prototype.slice.call(arguments,2))}var X=this;X.options=b;X.render=d;X.destroy=l;X.refetchEvents=ra;X.reportEvents=sa;X.reportEventChange=ha;X.rerenderEvents=da;X.changeView=y;X.select=ua;X.unselect=pa;
+X.prev=U;X.next=ca;X.prevYear=ka;X.nextYear=qa;X.today=G;X.gotoDate=p;X.incrementDate=L;X.formatDate=function(k,D){return Oa(k,D,b)};X.formatDates=function(k,D,Z){return ib(k,D,Z,b)};X.getDate=c;X.getView=z;X.option=H;X.trigger=T;$b.call(X,b,e);var ya=X.isFetchNeeded,K=X.fetchEvents,i=a[0],C,P,E,B,n,Y={},W,o,s,v=0,F=0,r=new Date,J=[],M;yb(r,b.year,b.month,b.date);b.droppable&&m(document).bind("dragstart",function(k,D){var Z=k.target,ja=m(Z);if(!ja.parents(".fc").length){var ia=b.dropAccept;if(m.isFunction(ia)?
+ia.call(Z,ja):ja.is(ia)){M=Z;n.dragStart(M,k,D)}}}).bind("dragstop",function(k,D){if(M){n.dragStop(M,k,D);M=null}})}function Zb(a,b){function e(){q=b.theme?"ui":"fc";if(b.header)return Q=m("<table class='fc-header' style='width:100%'/>").append(m("<tr/>").append(f("left")).append(f("center")).append(f("right")))}function d(){Q.remove()}function f(u){var fa=m("<td class='fc-header-"+u+"'/>");(u=b.header[u])&&m.each(u.split(" "),function(oa){oa>0&&fa.append("<span class='fc-header-space'/>");var ga;
+m.each(this.split(","),function(ra,sa){if(sa=="title"){fa.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");ga&&ga.addClass(q+"-corner-right");ga=null}else{var ha;if(a[sa])ha=a[sa];else if(Ja[sa])ha=function(){na.removeClass(q+"-state-hover");a.changeView(sa)};if(ha){ra=b.theme?jb(b.buttonIcons,sa):null;var da=jb(b.buttonText,sa),na=m("<span class='fc-button fc-button-"+sa+" "+q+"-state-default'><span class='fc-button-inner'><span class='fc-button-content'>"+(ra?"<span class='fc-icon-wrap'><span class='ui-icon ui-icon-"+
+ra+"'/></span>":da)+"</span><span class='fc-button-effect'><span></span></span></span></span>");if(na){na.click(function(){na.hasClass(q+"-state-disabled")||ha()}).mousedown(function(){na.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-down")}).mouseup(function(){na.removeClass(q+"-state-down")}).hover(function(){na.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-hover")},function(){na.removeClass(q+"-state-hover").removeClass(q+"-state-down")}).appendTo(fa);
+ga||na.addClass(q+"-corner-left");ga=na}}}});ga&&ga.addClass(q+"-corner-right")});return fa}function g(u){Q.find("h2").html(u)}function l(u){Q.find("span.fc-button-"+u).addClass(q+"-state-active")}function j(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-active")}function t(u){Q.find("span.fc-button-"+u).addClass(q+"-state-disabled")}function y(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-disabled")}var S=this;S.render=e;S.destroy=d;S.updateTitle=g;S.activateButton=l;S.deactivateButton=
+j;S.disableButton=t;S.enableButton=y;var Q=m([]),q}function $b(a,b){function e(c,z){return!ca||c<ca||z>ka}function d(c,z){ca=c;ka=z;L=[];c=++qa;G=z=U.length;for(var H=0;H<z;H++)f(U[H],c)}function f(c,z){g(c,function(H){if(z==qa){if(H){for(var T=0;T<H.length;T++){H[T].source=c;oa(H[T])}L=L.concat(H)}G--;G||ua(L)}})}function g(c,z){var H,T=Aa.sourceFetchers,X;for(H=0;H<T.length;H++){X=T[H](c,ca,ka,z);if(X===true)return;else if(typeof X=="object"){g(X,z);return}}if(H=c.events)if(m.isFunction(H)){u();
+H(N(ca),N(ka),function(C){z(C);fa()})}else m.isArray(H)?z(H):z();else if(c.url){var ya=c.success,K=c.error,i=c.complete;H=m.extend({},c.data||{});T=Ta(c.startParam,a.startParam);X=Ta(c.endParam,a.endParam);if(T)H[T]=Math.round(+ca/1E3);if(X)H[X]=Math.round(+ka/1E3);u();m.ajax(m.extend({},ac,c,{data:H,success:function(C){C=C||[];var P=$a(ya,this,arguments);if(m.isArray(P))C=P;z(C)},error:function(){$a(K,this,arguments);z()},complete:function(){$a(i,this,arguments);fa()}}))}else z()}function l(c){if(c=
+j(c)){G++;f(c,qa)}}function j(c){if(m.isFunction(c)||m.isArray(c))c={events:c};else if(typeof c=="string")c={url:c};if(typeof c=="object"){ga(c);U.push(c);return c}}function t(c){U=m.grep(U,function(z){return!ra(z,c)});L=m.grep(L,function(z){return!ra(z.source,c)});ua(L)}function y(c){var z,H=L.length,T,X=na().defaultEventEnd,ya=c.start-c._start,K=c.end?c.end-(c._end||X(c)):0;for(z=0;z<H;z++){T=L[z];if(T._id==c._id&&T!=c){T.start=new Date(+T.start+ya);T.end=c.end?T.end?new Date(+T.end+K):new Date(+X(T)+
+K):null;T.title=c.title;T.url=c.url;T.allDay=c.allDay;T.className=c.className;T.editable=c.editable;T.color=c.color;T.backgroudColor=c.backgroudColor;T.borderColor=c.borderColor;T.textColor=c.textColor;oa(T)}}oa(c);ua(L)}function S(c,z){oa(c);if(!c.source){if(z){pa.events.push(c);c.source=pa}L.push(c)}ua(L)}function Q(c){if(c){if(!m.isFunction(c)){var z=c+"";c=function(T){return T._id==z}}L=m.grep(L,c,true);for(H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=m.grep(U[H].events,c,true)}else{L=
+[];for(var H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=[]}ua(L)}function q(c){if(m.isFunction(c))return m.grep(L,c);else if(c){c+="";return m.grep(L,function(z){return z._id==c})}return L}function u(){p++||da("loading",null,true)}function fa(){--p||da("loading",null,false)}function oa(c){var z=c.source||{},H=Ta(z.ignoreTimezone,a.ignoreTimezone);c._id=c._id||(c.id===ma?"_fc"+bc++:c.id+"");if(c.date){if(!c.start)c.start=c.date;delete c.date}c._start=N(c.start=kb(c.start,H));c.end=kb(c.end,
+H);if(c.end&&c.end<=c.start)c.end=null;c._end=c.end?N(c.end):null;if(c.allDay===ma)c.allDay=Ta(z.allDayDefault,a.allDayDefault);if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[]}function ga(c){if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[];for(var z=Aa.sourceNormalizers,H=0;H<z.length;H++)z[H](c)}function ra(c,z){return c&&z&&sa(c)==sa(z)}function sa(c){return(typeof c=="object"?c.events||
+c.url:"")||c}var ha=this;ha.isFetchNeeded=e;ha.fetchEvents=d;ha.addEventSource=l;ha.removeEventSource=t;ha.updateEvent=y;ha.renderEvent=S;ha.removeEvents=Q;ha.clientEvents=q;ha.normalizeEvent=oa;var da=ha.trigger,na=ha.getView,ua=ha.reportEvents,pa={events:[]},U=[pa],ca,ka,qa=0,G=0,p=0,L=[];for(ha=0;ha<b.length;ha++)j(b[ha])}function gb(a,b,e){a.setFullYear(a.getFullYear()+b);e||Ka(a);return a}function hb(a,b,e){if(+a){b=a.getMonth()+b;var d=N(a);d.setDate(1);d.setMonth(b);a.setMonth(b);for(e||Ka(a);a.getMonth()!=
+d.getMonth();)a.setDate(a.getDate()+(a<d?1:-1))}return a}function ba(a,b,e){if(+a){b=a.getDate()+b;var d=N(a);d.setHours(9);d.setDate(b);a.setDate(b);e||Ka(a);lb(a,d)}return a}function lb(a,b){if(+a)for(;a.getDate()!=b.getDate();)a.setTime(+a+(a<b?1:-1)*cc)}function xa(a,b){a.setMinutes(a.getMinutes()+b);return a}function Ka(a){a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0);return a}function N(a,b){if(b)return Ka(new Date(+a));return new Date(+a)}function zb(){var a=0,b;do b=new Date(1970,
+a++,1);while(b.getHours());return b}function Fa(a,b,e){for(b=b||1;!a.getDay()||e&&a.getDay()==1||!e&&a.getDay()==6;)ba(a,b);return a}function Ca(a,b){return Math.round((N(a,true)-N(b,true))/Ab)}function yb(a,b,e,d){if(b!==ma&&b!=a.getFullYear()){a.setDate(1);a.setMonth(0);a.setFullYear(b)}if(e!==ma&&e!=a.getMonth()){a.setDate(1);a.setMonth(e)}d!==ma&&a.setDate(d)}function kb(a,b){if(typeof a=="object")return a;if(typeof a=="number")return new Date(a*1E3);if(typeof a=="string"){if(a.match(/^\d+(\.\d+)?$/))return new Date(parseFloat(a)*
+1E3);if(b===ma)b=true;return Bb(a,b)||(a?new Date(a):null)}return null}function Bb(a,b){a=a.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);if(!a)return null;var e=new Date(a[1],0,1);if(b||!a[13]){b=new Date(a[1],0,1,9,0);if(a[3]){e.setMonth(a[3]-1);b.setMonth(a[3]-1)}if(a[5]){e.setDate(a[5]);b.setDate(a[5])}lb(e,b);a[7]&&e.setHours(a[7]);a[8]&&e.setMinutes(a[8]);a[10]&&e.setSeconds(a[10]);a[12]&&e.setMilliseconds(Number("0."+
+a[12])*1E3);lb(e,b)}else{e.setUTCFullYear(a[1],a[3]?a[3]-1:0,a[5]||1);e.setUTCHours(a[7]||0,a[8]||0,a[10]||0,a[12]?Number("0."+a[12])*1E3:0);if(a[14]){b=Number(a[16])*60+(a[18]?Number(a[18]):0);b*=a[15]=="-"?1:-1;e=new Date(+e+b*60*1E3)}}return e}function mb(a){if(typeof a=="number")return a*60;if(typeof a=="object")return a.getHours()*60+a.getMinutes();if(a=a.match(/(\d+)(?::(\d+))?\s*(\w+)?/)){var b=parseInt(a[1],10);if(a[3]){b%=12;if(a[3].toLowerCase().charAt(0)=="p")b+=12}return b*60+(a[2]?parseInt(a[2],
+10):0)}}function Oa(a,b,e){return ib(a,null,b,e)}function ib(a,b,e,d){d=d||Ya;var f=a,g=b,l,j=e.length,t,y,S,Q="";for(l=0;l<j;l++){t=e.charAt(l);if(t=="'")for(y=l+1;y<j;y++){if(e.charAt(y)=="'"){if(f){Q+=y==l+1?"'":e.substring(l+1,y);l=y}break}}else if(t=="(")for(y=l+1;y<j;y++){if(e.charAt(y)==")"){l=Oa(f,e.substring(l+1,y),d);if(parseInt(l.replace(/\D/,""),10))Q+=l;l=y;break}}else if(t=="[")for(y=l+1;y<j;y++){if(e.charAt(y)=="]"){t=e.substring(l+1,y);l=Oa(f,t,d);if(l!=Oa(g,t,d))Q+=l;l=y;break}}else if(t==
+"{"){f=b;g=a}else if(t=="}"){f=a;g=b}else{for(y=j;y>l;y--)if(S=dc[e.substring(l,y)]){if(f)Q+=S(f,d);l=y-1;break}if(y==l)if(f)Q+=t}}return Q}function Ua(a){return a.end?ec(a.end,a.allDay):ba(N(a.start),1)}function ec(a,b){a=N(a);return b||a.getHours()||a.getMinutes()?ba(a,1):Ka(a)}function fc(a,b){return(b.msLength-a.msLength)*100+(a.event.start-b.event.start)}function Cb(a,b){return a.end>b.start&&a.start<b.end}function nb(a,b,e,d){var f=[],g,l=a.length,j,t,y,S,Q;for(g=0;g<l;g++){j=a[g];t=j.start;
+y=b[g];if(y>e&&t<d){if(t<e){t=N(e);S=false}else{t=t;S=true}if(y>d){y=N(d);Q=false}else{y=y;Q=true}f.push({event:j,start:t,end:y,isStart:S,isEnd:Q,msLength:y-t})}}return f.sort(fc)}function ob(a){var b=[],e,d=a.length,f,g,l,j;for(e=0;e<d;e++){f=a[e];for(g=0;;){l=false;if(b[g])for(j=0;j<b[g].length;j++)if(Cb(b[g][j],f)){l=true;break}if(l)g++;else break}if(b[g])b[g].push(f);else b[g]=[f]}return b}function Db(a,b,e){a.unbind("mouseover").mouseover(function(d){for(var f=d.target,g;f!=this;){g=f;f=f.parentNode}if((f=
+g._fci)!==ma){g._fci=ma;g=b[f];e(g.event,g.element,g);m(d.target).trigger(d)}d.stopPropagation()})}function Va(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.width(Math.max(0,b-pb(f,e)))}}function Eb(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.height(Math.max(0,b-Sa(f,e)))}}function pb(a,b){return gc(a)+hc(a)+(b?ic(a):0)}function gc(a){return(parseFloat(m.curCSS(a[0],"paddingLeft",true))||0)+(parseFloat(m.curCSS(a[0],"paddingRight",true))||0)}function ic(a){return(parseFloat(m.curCSS(a[0],
+"marginLeft",true))||0)+(parseFloat(m.curCSS(a[0],"marginRight",true))||0)}function hc(a){return(parseFloat(m.curCSS(a[0],"borderLeftWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderRightWidth",true))||0)}function Sa(a,b){return jc(a)+kc(a)+(b?Fb(a):0)}function jc(a){return(parseFloat(m.curCSS(a[0],"paddingTop",true))||0)+(parseFloat(m.curCSS(a[0],"paddingBottom",true))||0)}function Fb(a){return(parseFloat(m.curCSS(a[0],"marginTop",true))||0)+(parseFloat(m.curCSS(a[0],"marginBottom",true))||0)}
+function kc(a){return(parseFloat(m.curCSS(a[0],"borderTopWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderBottomWidth",true))||0)}function Za(a,b){b=typeof b=="number"?b+"px":b;a.each(function(e,d){d.style.cssText+=";min-height:"+b+";_height:"+b})}function xb(){}function Gb(a,b){return a-b}function Hb(a){return Math.max.apply(Math,a)}function Pa(a){return(a<10?"0":"")+a}function jb(a,b){if(a[b]!==ma)return a[b];b=b.split(/(?=[A-Z])/);for(var e=b.length-1,d;e>=0;e--){d=a[b[e].toLowerCase()];if(d!==
+ma)return d}return a[""]}function Qa(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;").replace(/\n/g,"<br />")}function Ib(a){return a.id+"/"+a.className+"/"+a.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig,"")}function qb(a){a.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}function ab(a){a.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}
+function rb(a,b){a.each(function(e,d){d.className=d.className.replace(/^fc-\w*/,"fc-"+lc[b.getDay()])})}function Jb(a,b){var e=a.source||{},d=a.color,f=e.color,g=b("eventColor"),l=a.backgroundColor||d||e.backgroundColor||f||b("eventBackgroundColor")||g;d=a.borderColor||d||e.borderColor||f||b("eventBorderColor")||g;a=a.textColor||e.textColor||b("eventTextColor");b=[];l&&b.push("background-color:"+l);d&&b.push("border-color:"+d);a&&b.push("color:"+a);return b.join(";")}function $a(a,b,e){if(m.isFunction(a))a=
+[a];if(a){var d,f;for(d=0;d<a.length;d++)f=a[d].apply(b,e)||f;return f}}function Ta(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==ma)return arguments[a]}function mc(a,b){function e(j,t){if(t){hb(j,t);j.setDate(1)}j=N(j,true);j.setDate(1);t=hb(N(j),1);var y=N(j),S=N(t),Q=f("firstDay"),q=f("weekends")?0:1;if(q){Fa(y);Fa(S,-1,true)}ba(y,-((y.getDay()-Math.max(Q,q)+7)%7));ba(S,(7-S.getDay()+Math.max(Q,q))%7);Q=Math.round((S-y)/(Ab*7));if(f("weekMode")=="fixed"){ba(S,(6-Q)*7);Q=6}d.title=l(j,
+f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(6,Q,q?5:7,true)}var d=this;d.render=e;sb.call(d,a,b,"month");var f=d.opt,g=d.renderBasic,l=b.formatDate}function nc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(1,1,Q?7:5,false)}var d=this;d.render=e;sb.call(d,a,b,"basicWeek");var f=d.opt,g=d.renderBasic,
+l=b.formatDates}function oc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}d.title=l(j,f("titleFormat"));d.start=d.visStart=N(j,true);d.end=d.visEnd=ba(N(d.start),1);g(1,1,1,false)}var d=this;d.render=e;sb.call(d,a,b,"basicDay");var f=d.opt,g=d.renderBasic,l=b.formatDate}function sb(a,b,e){function d(w,I,R,V){v=I;F=R;f();(I=!C)?g(w,V):z();l(I)}function f(){if(k=L("isRTL")){D=-1;Z=F-1}else{D=1;Z=0}ja=L("firstDay");ia=L("weekends")?0:1;la=L("theme")?"ui":"fc";$=L("columnFormat")}function g(w,
+I){var R,V=la+"-widget-header",ea=la+"-widget-content",aa;R="<table class='fc-border-separate' style='width:100%' cellspacing='0'><thead><tr>";for(aa=0;aa<F;aa++)R+="<th class='fc- "+V+"'/>";R+="</tr></thead><tbody>";for(aa=0;aa<w;aa++){R+="<tr class='fc-week"+aa+"'>";for(V=0;V<F;V++)R+="<td class='fc- "+ea+" fc-day"+(aa*F+V)+"'><div>"+(I?"<div class='fc-day-number'/>":"")+"<div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";R+="</tr>"}R+="</tbody></table>";w=
+m(R).appendTo(a);K=w.find("thead");i=K.find("th");C=w.find("tbody");P=C.find("tr");E=C.find("td");B=E.filter(":first-child");n=P.eq(0).find("div.fc-day-content div");ab(K.add(K.find("tr")));ab(P);P.eq(0).addClass("fc-first");y(E);Y=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(a)}function l(w){var I=w||v==1,R=p.start.getMonth(),V=Ka(new Date),ea,aa,va;I&&i.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);ea.html(ya(aa,$));rb(ea,aa)});E.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);aa.getMonth()==
+R?ea.removeClass("fc-other-month"):ea.addClass("fc-other-month");+aa==+V?ea.addClass(la+"-state-highlight fc-today"):ea.removeClass(la+"-state-highlight fc-today");ea.find("div.fc-day-number").text(aa.getDate());I&&rb(ea,aa)});P.each(function(wa,Ga){va=m(Ga);if(wa<v){va.show();wa==v-1?va.addClass("fc-last"):va.removeClass("fc-last")}else va.hide()})}function j(w){o=w;w=o-K.height();var I,R,V;if(L("weekMode")=="variable")I=R=Math.floor(w/(v==1?2:6));else{I=Math.floor(w/v);R=w-I*(v-1)}B.each(function(ea,
+aa){if(ea<v){V=m(aa);Za(V.find("> div"),(ea==v-1?R:I)-Sa(V))}})}function t(w){W=w;M.clear();s=Math.floor(W/F);Va(i.slice(0,-1),s)}function y(w){w.click(S).mousedown(X)}function S(w){if(!L("selectable")){var I=parseInt(this.className.match(/fc\-day(\d+)/)[1]);I=ca(I);c("dayClick",this,I,true,w)}}function Q(w,I,R){R&&r.build();R=N(p.visStart);for(var V=ba(N(R),F),ea=0;ea<v;ea++){var aa=new Date(Math.max(R,w)),va=new Date(Math.min(V,I));if(aa<va){var wa;if(k){wa=Ca(va,R)*D+Z+1;aa=Ca(aa,R)*D+Z+1}else{wa=
+Ca(aa,R);aa=Ca(va,R)}y(q(ea,wa,ea,aa-1))}ba(R,7);ba(V,7)}}function q(w,I,R,V){w=r.rect(w,I,R,V,a);return H(w,a)}function u(w){return N(w)}function fa(w,I){Q(w,ba(N(I),1),true)}function oa(){T()}function ga(w,I,R){var V=ua(w);c("dayClick",E[V.row*F+V.col],w,I,R)}function ra(w,I){J.start(function(R){T();R&&q(R.row,R.col,R.row,R.col)},I)}function sa(w,I,R){var V=J.stop();T();if(V){V=pa(V);c("drop",w,V,true,I,R)}}function ha(w){return N(w.start)}function da(w){return M.left(w)}function na(w){return M.right(w)}
+function ua(w){return{row:Math.floor(Ca(w,p.visStart)/7),col:ka(w.getDay())}}function pa(w){return U(w.row,w.col)}function U(w,I){return ba(N(p.visStart),w*7+I*D+Z)}function ca(w){return U(Math.floor(w/F),w%F)}function ka(w){return(w-Math.max(ja,ia)+F)%F*D+Z}function qa(w){return P.eq(w)}function G(){return{left:0,right:W}}var p=this;p.renderBasic=d;p.setHeight=j;p.setWidth=t;p.renderDayOverlay=Q;p.defaultSelectionEnd=u;p.renderSelection=fa;p.clearSelection=oa;p.reportDayClick=ga;p.dragStart=ra;p.dragStop=
+sa;p.defaultEventEnd=ha;p.getHoverListener=function(){return J};p.colContentLeft=da;p.colContentRight=na;p.dayOfWeekCol=ka;p.dateCell=ua;p.cellDate=pa;p.cellIsAllDay=function(){return true};p.allDayRow=qa;p.allDayBounds=G;p.getRowCnt=function(){return v};p.getColCnt=function(){return F};p.getColWidth=function(){return s};p.getDaySegmentContainer=function(){return Y};Kb.call(p,a,b,e);Lb.call(p);Mb.call(p);pc.call(p);var L=p.opt,c=p.trigger,z=p.clearEvents,H=p.renderOverlay,T=p.clearOverlays,X=p.daySelectionMousedown,
+ya=b.formatDate,K,i,C,P,E,B,n,Y,W,o,s,v,F,r,J,M,k,D,Z,ja,ia,la,$;qb(a.addClass("fc-grid"));r=new Nb(function(w,I){var R,V,ea;i.each(function(aa,va){R=m(va);V=R.offset().left;if(aa)ea[1]=V;ea=[V];I[aa]=ea});ea[1]=V+R.outerWidth();P.each(function(aa,va){if(aa<v){R=m(va);V=R.offset().top;if(aa)ea[1]=V;ea=[V];w[aa]=ea}});ea[1]=V+R.outerHeight()});J=new Ob(r);M=new Pb(function(w){return n.eq(w)})}function pc(){function a(U,ca){S(U);ua(e(U),ca)}function b(){Q();ga().empty()}function e(U){var ca=da(),ka=
+na(),qa=N(g.visStart);ka=ba(N(qa),ka);var G=m.map(U,Ua),p,L,c,z,H,T,X=[];for(p=0;p<ca;p++){L=ob(nb(U,G,qa,ka));for(c=0;c<L.length;c++){z=L[c];for(H=0;H<z.length;H++){T=z[H];T.row=p;T.level=c;X.push(T)}}ba(qa,7);ba(ka,7)}return X}function d(U,ca,ka){t(U)&&f(U,ca);ka.isEnd&&y(U)&&pa(U,ca,ka);q(U,ca)}function f(U,ca){var ka=ra(),qa;ca.draggable({zIndex:9,delay:50,opacity:l("dragOpacity"),revertDuration:l("dragRevertDuration"),start:function(G,p){j("eventDragStart",ca,U,G,p);fa(U,ca);ka.start(function(L,
+c,z,H){ca.draggable("option","revert",!L||!z&&!H);ha();if(L){qa=z*7+H*(l("isRTL")?-1:1);sa(ba(N(U.start),qa),ba(Ua(U),qa))}else qa=0},G,"drag")},stop:function(G,p){ka.stop();ha();j("eventDragStop",ca,U,G,p);if(qa)oa(this,U,qa,0,U.allDay,G,p);else{ca.css("filter","");u(U,ca)}}})}var g=this;g.renderEvents=a;g.compileDaySegs=e;g.clearEvents=b;g.bindDaySeg=d;Qb.call(g);var l=g.opt,j=g.trigger,t=g.isEventDraggable,y=g.isEventResizable,S=g.reportEvents,Q=g.reportEventClear,q=g.eventElementHandlers,u=g.showEvents,
+fa=g.hideEvents,oa=g.eventDrop,ga=g.getDaySegmentContainer,ra=g.getHoverListener,sa=g.renderDayOverlay,ha=g.clearOverlays,da=g.getRowCnt,na=g.getColCnt,ua=g.renderDaySegs,pa=g.resizableDayEvent}function qc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(Q?7:5)}var d=this;d.render=e;Rb.call(d,a,b,"agendaWeek");
+var f=d.opt,g=d.renderAgenda,l=b.formatDates}function rc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}t=N(j,true);var y=ba(N(t),1);d.title=l(j,f("titleFormat"));d.start=d.visStart=t;d.end=d.visEnd=y;g(1)}var d=this;d.render=e;Rb.call(d,a,b,"agendaDay");var f=d.opt,g=d.renderAgenda,l=b.formatDate}function Rb(a,b,e){function d(h){Ba=h;f();v?P():g();l()}function f(){Wa=i("theme")?"ui":"fc";Sb=i("weekends")?0:1;Tb=i("firstDay");if(Ub=i("isRTL")){Ha=-1;Ia=Ba-1}else{Ha=1;Ia=0}La=mb(i("minTime"));
+bb=mb(i("maxTime"));Vb=i("columnFormat")}function g(){var h=Wa+"-widget-header",O=Wa+"-widget-content",x,A,ta,za,Da,Ea=i("slotMinutes")%15==0;x="<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'><thead><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<th class='fc- fc-col"+A+" "+h+"'/>";x+="<th class='fc-agenda-gutter "+h+"'>&nbsp;</th></tr></thead><tbody><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<td class='fc- fc-col"+
+A+" "+O+"'><div><div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";x+="<td class='fc-agenda-gutter "+O+"'>&nbsp;</td></tr></tbody></table>";v=m(x).appendTo(a);F=v.find("thead");r=F.find("th").slice(1,-1);J=v.find("tbody");M=J.find("td").slice(0,-1);k=M.find("div.fc-day-content div");D=M.eq(0);Z=D.find("> div");ab(F.add(F.find("tr")));ab(J.add(J.find("tr")));aa=F.find("th:first");va=v.find(".fc-agenda-gutter");ja=m("<div style='position:absolute;z-index:2;left:0;width:100%'/>").appendTo(a);
+if(i("allDaySlot")){ia=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(ja);x="<table style='width:100%' class='fc-agenda-allday' cellspacing='0'><tr><th class='"+h+" fc-agenda-axis'>"+i("allDayText")+"</th><td><div class='fc-day-content'><div style='position:relative'/></div></td><th class='"+h+" fc-agenda-gutter'>&nbsp;</th></tr></table>";la=m(x).appendTo(ja);$=la.find("tr");q($.find("td"));aa=aa.add(la.find("th:first"));va=va.add(la.find("th.fc-agenda-gutter"));ja.append("<div class='fc-agenda-divider "+
+h+"'><div class='fc-agenda-divider-inner'/></div>")}else ia=m([]);w=m("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>").appendTo(ja);I=m("<div style='position:relative;width:100%;overflow:hidden'/>").appendTo(w);R=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(I);x="<table class='fc-agenda-slots' style='width:100%' cellspacing='0'><tbody>";ta=zb();za=xa(N(ta),bb);xa(ta,La);for(A=tb=0;ta<za;A++){Da=ta.getMinutes();x+="<tr class='fc-slot"+A+" "+
+(!Da?"":"fc-minor")+"'><th class='fc-agenda-axis "+h+"'>"+(!Ea||!Da?s(ta,i("axisFormat")):"&nbsp;")+"</th><td class='"+O+"'><div style='position:relative'>&nbsp;</div></td></tr>";xa(ta,i("slotMinutes"));tb++}x+="</tbody></table>";V=m(x).appendTo(I);ea=V.find("div:first");u(V.find("td"));aa=aa.add(V.find("th:first"))}function l(){var h,O,x,A,ta=Ka(new Date);for(h=0;h<Ba;h++){A=ua(h);O=r.eq(h);O.html(s(A,Vb));x=M.eq(h);+A==+ta?x.addClass(Wa+"-state-highlight fc-today"):x.removeClass(Wa+"-state-highlight fc-today");
+rb(O.add(x),A)}}function j(h,O){if(h===ma)h=Wb;Wb=h;ub={};var x=J.position().top,A=w.position().top;h=Math.min(h-x,V.height()+A+1);Z.height(h-Sa(D));ja.css("top",x);w.height(h-A-1);Xa=ea.height()+1;O&&y()}function t(h){Ga=h;cb.clear();Ma=0;Va(aa.width("").each(function(O,x){Ma=Math.max(Ma,m(x).outerWidth())}),Ma);h=w[0].clientWidth;if(vb=w.width()-h){Va(va,vb);va.show().prev().removeClass("fc-last")}else va.hide().prev().addClass("fc-last");db=Math.floor((h-Ma)/Ba);Va(r.slice(0,-1),db)}function y(){function h(){w.scrollTop(A)}
+var O=zb(),x=N(O);x.setHours(i("firstHour"));var A=ca(O,x)+1;h();setTimeout(h,0)}function S(){Xb=w.scrollTop()}function Q(){w.scrollTop(Xb)}function q(h){h.click(fa).mousedown(W)}function u(h){h.click(fa).mousedown(H)}function fa(h){if(!i("selectable")){var O=Math.min(Ba-1,Math.floor((h.pageX-v.offset().left-Ma)/db)),x=ua(O),A=this.parentNode.className.match(/fc-slot(\d+)/);if(A){A=parseInt(A[1])*i("slotMinutes");var ta=Math.floor(A/60);x.setHours(ta);x.setMinutes(A%60+La);C("dayClick",M[O],x,false,
+h)}else C("dayClick",M[O],x,true,h)}}function oa(h,O,x){x&&Na.build();var A=N(K.visStart);if(Ub){x=Ca(O,A)*Ha+Ia+1;h=Ca(h,A)*Ha+Ia+1}else{x=Ca(h,A);h=Ca(O,A)}x=Math.max(0,x);h=Math.min(Ba,h);x<h&&q(ga(0,x,0,h-1))}function ga(h,O,x,A){h=Na.rect(h,O,x,A,ja);return E(h,ja)}function ra(h,O){for(var x=N(K.visStart),A=ba(N(x),1),ta=0;ta<Ba;ta++){var za=new Date(Math.max(x,h)),Da=new Date(Math.min(A,O));if(za<Da){var Ea=ta*Ha+Ia;Ea=Na.rect(0,Ea,0,Ea,I);za=ca(x,za);Da=ca(x,Da);Ea.top=za;Ea.height=Da-za;u(E(Ea,
+I))}ba(x,1);ba(A,1)}}function sa(h){return cb.left(h)}function ha(h){return cb.right(h)}function da(h){return{row:Math.floor(Ca(h,K.visStart)/7),col:U(h.getDay())}}function na(h){var O=ua(h.col);h=h.row;i("allDaySlot")&&h--;h>=0&&xa(O,La+h*i("slotMinutes"));return O}function ua(h){return ba(N(K.visStart),h*Ha+Ia)}function pa(h){return i("allDaySlot")&&!h.row}function U(h){return(h-Math.max(Tb,Sb)+Ba)%Ba*Ha+Ia}function ca(h,O){h=N(h,true);if(O<xa(N(h),La))return 0;if(O>=xa(N(h),bb))return V.height();
+h=i("slotMinutes");O=O.getHours()*60+O.getMinutes()-La;var x=Math.floor(O/h),A=ub[x];if(A===ma)A=ub[x]=V.find("tr:eq("+x+") td div")[0].offsetTop;return Math.max(0,Math.round(A-1+Xa*(O%h/h)))}function ka(){return{left:Ma,right:Ga-vb}}function qa(){return $}function G(h){var O=N(h.start);if(h.allDay)return O;return xa(O,i("defaultEventMinutes"))}function p(h,O){if(O)return N(h);return xa(N(h),i("slotMinutes"))}function L(h,O,x){if(x)i("allDaySlot")&&oa(h,ba(N(O),1),true);else c(h,O)}function c(h,O){var x=
+i("selectHelper");Na.build();if(x){var A=Ca(h,K.visStart)*Ha+Ia;if(A>=0&&A<Ba){A=Na.rect(0,A,0,A,I);var ta=ca(h,h),za=ca(h,O);if(za>ta){A.top=ta;A.height=za-ta;A.left+=2;A.width-=5;if(m.isFunction(x)){if(h=x(h,O)){A.position="absolute";A.zIndex=8;wa=m(h).css(A).appendTo(I)}}else{A.isStart=true;A.isEnd=true;wa=m(o({title:"",start:h,end:O,className:["fc-select-helper"],editable:false},A));wa.css("opacity",i("dragOpacity"))}if(wa){u(wa);I.append(wa);Va(wa,A.width,true);Eb(wa,A.height,true)}}}}else ra(h,
+O)}function z(){B();if(wa){wa.remove();wa=null}}function H(h){if(h.which==1&&i("selectable")){Y(h);var O;Ra.start(function(x,A){z();if(x&&x.col==A.col&&!pa(x)){A=na(A);x=na(x);O=[A,xa(N(A),i("slotMinutes")),x,xa(N(x),i("slotMinutes"))].sort(Gb);c(O[0],O[3])}else O=null},h);m(document).one("mouseup",function(x){Ra.stop();if(O){+O[0]==+O[1]&&T(O[0],false,x);n(O[0],O[3],false,x)}})}}function T(h,O,x){C("dayClick",M[U(h.getDay())],h,O,x)}function X(h,O){Ra.start(function(x){B();if(x)if(pa(x))ga(x.row,
+x.col,x.row,x.col);else{x=na(x);var A=xa(N(x),i("defaultEventMinutes"));ra(x,A)}},O)}function ya(h,O,x){var A=Ra.stop();B();A&&C("drop",h,na(A),pa(A),O,x)}var K=this;K.renderAgenda=d;K.setWidth=t;K.setHeight=j;K.beforeHide=S;K.afterShow=Q;K.defaultEventEnd=G;K.timePosition=ca;K.dayOfWeekCol=U;K.dateCell=da;K.cellDate=na;K.cellIsAllDay=pa;K.allDayRow=qa;K.allDayBounds=ka;K.getHoverListener=function(){return Ra};K.colContentLeft=sa;K.colContentRight=ha;K.getDaySegmentContainer=function(){return ia};
+K.getSlotSegmentContainer=function(){return R};K.getMinMinute=function(){return La};K.getMaxMinute=function(){return bb};K.getBodyContent=function(){return I};K.getRowCnt=function(){return 1};K.getColCnt=function(){return Ba};K.getColWidth=function(){return db};K.getSlotHeight=function(){return Xa};K.defaultSelectionEnd=p;K.renderDayOverlay=oa;K.renderSelection=L;K.clearSelection=z;K.reportDayClick=T;K.dragStart=X;K.dragStop=ya;Kb.call(K,a,b,e);Lb.call(K);Mb.call(K);sc.call(K);var i=K.opt,C=K.trigger,
+P=K.clearEvents,E=K.renderOverlay,B=K.clearOverlays,n=K.reportSelection,Y=K.unselect,W=K.daySelectionMousedown,o=K.slotSegHtml,s=b.formatDate,v,F,r,J,M,k,D,Z,ja,ia,la,$,w,I,R,V,ea,aa,va,wa,Ga,Wb,Ma,db,vb,Xa,Xb,Ba,tb,Na,Ra,cb,ub={},Wa,Tb,Sb,Ub,Ha,Ia,La,bb,Vb;qb(a.addClass("fc-agenda"));Na=new Nb(function(h,O){function x(eb){return Math.max(Ea,Math.min(tc,eb))}var A,ta,za;r.each(function(eb,uc){A=m(uc);ta=A.offset().left;if(eb)za[1]=ta;za=[ta];O[eb]=za});za[1]=ta+A.outerWidth();if(i("allDaySlot")){A=
+$;ta=A.offset().top;h[0]=[ta,ta+A.outerHeight()]}for(var Da=I.offset().top,Ea=w.offset().top,tc=Ea+w.outerHeight(),fb=0;fb<tb;fb++)h.push([x(Da+Xa*fb),x(Da+Xa*(fb+1))])});Ra=new Ob(Na);cb=new Pb(function(h){return k.eq(h)})}function sc(){function a(o,s){sa(o);var v,F=o.length,r=[],J=[];for(v=0;v<F;v++)o[v].allDay?r.push(o[v]):J.push(o[v]);if(u("allDaySlot")){L(e(r),s);na()}g(d(J),s)}function b(){ha();ua().empty();pa().empty()}function e(o){o=ob(nb(o,m.map(o,Ua),q.visStart,q.visEnd));var s,v=o.length,
+F,r,J,M=[];for(s=0;s<v;s++){F=o[s];for(r=0;r<F.length;r++){J=F[r];J.row=0;J.level=s;M.push(J)}}return M}function d(o){var s=z(),v=ka(),F=ca(),r=xa(N(q.visStart),v),J=m.map(o,f),M,k,D,Z,ja,ia,la=[];for(M=0;M<s;M++){k=ob(nb(o,J,r,xa(N(r),F-v)));vc(k);for(D=0;D<k.length;D++){Z=k[D];for(ja=0;ja<Z.length;ja++){ia=Z[ja];ia.col=M;ia.level=D;la.push(ia)}}ba(r,1,true)}return la}function f(o){return o.end?N(o.end):xa(N(o.start),u("defaultEventMinutes"))}function g(o,s){var v,F=o.length,r,J,M,k,D,Z,ja,ia,la,
+$="",w,I,R={},V={},ea=pa(),aa;v=z();if(w=u("isRTL")){I=-1;aa=v-1}else{I=1;aa=0}for(v=0;v<F;v++){r=o[v];J=r.event;M=qa(r.start,r.start);k=qa(r.start,r.end);D=r.col;Z=r.level;ja=r.forward||0;ia=G(D*I+aa);la=p(D*I+aa)-ia;la=Math.min(la-6,la*0.95);D=Z?la/(Z+ja+1):ja?(la/(ja+1)-6)*2:la;Z=ia+la/(Z+ja+1)*Z*I+(w?la-D:0);r.top=M;r.left=Z;r.outerWidth=D;r.outerHeight=k-M;$+=l(J,r)}ea[0].innerHTML=$;w=ea.children();for(v=0;v<F;v++){r=o[v];J=r.event;$=m(w[v]);I=fa("eventRender",J,J,$);if(I===false)$.remove();
+else{if(I&&I!==true){$.remove();$=m(I).css({position:"absolute",top:r.top,left:r.left}).appendTo(ea)}r.element=$;if(J._id===s)t(J,$,r);else $[0]._fci=v;ya(J,$)}}Db(ea,o,t);for(v=0;v<F;v++){r=o[v];if($=r.element){J=R[s=r.key=Ib($[0])];r.vsides=J===ma?(R[s]=Sa($,true)):J;J=V[s];r.hsides=J===ma?(V[s]=pb($,true)):J;s=$.find("div.fc-event-content");if(s.length)r.contentTop=s[0].offsetTop}}for(v=0;v<F;v++){r=o[v];if($=r.element){$[0].style.width=Math.max(0,r.outerWidth-r.hsides)+"px";R=Math.max(0,r.outerHeight-
+r.vsides);$[0].style.height=R+"px";J=r.event;if(r.contentTop!==ma&&R-r.contentTop<10){$.find("div.fc-event-time").text(Y(J.start,u("timeFormat"))+" - "+J.title);$.find("div.fc-event-title").remove()}fa("eventAfterRender",J,J,$)}}}function l(o,s){var v="<",F=o.url,r=Jb(o,u),J=r?" style='"+r+"'":"",M=["fc-event","fc-event-skin","fc-event-vert"];oa(o)&&M.push("fc-event-draggable");s.isStart&&M.push("fc-corner-top");s.isEnd&&M.push("fc-corner-bottom");M=M.concat(o.className);if(o.source)M=M.concat(o.source.className||
+[]);v+=F?"a href='"+Qa(o.url)+"'":"div";v+=" class='"+M.join(" ")+"' style='position:absolute;z-index:8;top:"+s.top+"px;left:"+s.left+"px;"+r+"'><div class='fc-event-inner fc-event-skin'"+J+"><div class='fc-event-head fc-event-skin'"+J+"><div class='fc-event-time'>"+Qa(W(o.start,o.end,u("timeFormat")))+"</div></div><div class='fc-event-content'><div class='fc-event-title'>"+Qa(o.title)+"</div></div><div class='fc-event-bg'></div></div>";if(s.isEnd&&ga(o))v+="<div class='ui-resizable-handle ui-resizable-s'>=</div>";
+v+="</"+(F?"a":"div")+">";return v}function j(o,s,v){oa(o)&&y(o,s,v.isStart);v.isEnd&&ga(o)&&c(o,s,v);da(o,s)}function t(o,s,v){var F=s.find("div.fc-event-time");oa(o)&&S(o,s,F);v.isEnd&&ga(o)&&Q(o,s,F);da(o,s)}function y(o,s,v){function F(){if(!M){s.width(r).height("").draggable("option","grid",null);M=true}}var r,J,M=true,k,D=u("isRTL")?-1:1,Z=U(),ja=H(),ia=T(),la=ka();s.draggable({zIndex:9,opacity:u("dragOpacity","month"),revertDuration:u("dragRevertDuration"),start:function($,w){fa("eventDragStart",
+s,o,$,w);i(o,s);r=s.width();Z.start(function(I,R,V,ea){B();if(I){J=false;k=ea*D;if(I.row)if(v){if(M){s.width(ja-10);Eb(s,ia*Math.round((o.end?(o.end-o.start)/wc:u("defaultEventMinutes"))/u("slotMinutes")));s.draggable("option","grid",[ja,1]);M=false}}else J=true;else{E(ba(N(o.start),k),ba(Ua(o),k));F()}J=J||M&&!k}else{F();J=true}s.draggable("option","revert",J)},$,"drag")},stop:function($,w){Z.stop();B();fa("eventDragStop",s,o,$,w);if(J){F();s.css("filter","");K(o,s)}else{var I=0;M||(I=Math.round((s.offset().top-
+X().offset().top)/ia)*u("slotMinutes")+la-(o.start.getHours()*60+o.start.getMinutes()));C(this,o,k,I,M,$,w)}}})}function S(o,s,v){function F(I){var R=xa(N(o.start),I),V;if(o.end)V=xa(N(o.end),I);v.text(W(R,V,u("timeFormat")))}function r(){if(M){v.css("display","");s.draggable("option","grid",[$,w]);M=false}}var J,M=false,k,D,Z,ja=u("isRTL")?-1:1,ia=U(),la=z(),$=H(),w=T();s.draggable({zIndex:9,scroll:false,grid:[$,w],axis:la==1?"y":false,opacity:u("dragOpacity"),revertDuration:u("dragRevertDuration"),
+start:function(I,R){fa("eventDragStart",s,o,I,R);i(o,s);J=s.position();D=Z=0;ia.start(function(V,ea,aa,va){s.draggable("option","revert",!V);B();if(V){k=va*ja;if(u("allDaySlot")&&!V.row){if(!M){M=true;v.hide();s.draggable("option","grid",null)}E(ba(N(o.start),k),ba(Ua(o),k))}else r()}},I,"drag")},drag:function(I,R){D=Math.round((R.position.top-J.top)/w)*u("slotMinutes");if(D!=Z){M||F(D);Z=D}},stop:function(I,R){var V=ia.stop();B();fa("eventDragStop",s,o,I,R);if(V&&(k||D||M))C(this,o,k,M?0:D,M,I,R);
+else{r();s.css("filter","");s.css(J);F(0);K(o,s)}}})}function Q(o,s,v){var F,r,J=T();s.resizable({handles:{s:"div.ui-resizable-s"},grid:J,start:function(M,k){F=r=0;i(o,s);s.css("z-index",9);fa("eventResizeStart",this,o,M,k)},resize:function(M,k){F=Math.round((Math.max(J,s.height())-k.originalSize.height)/J);if(F!=r){v.text(W(o.start,!F&&!o.end?null:xa(ra(o),u("slotMinutes")*F),u("timeFormat")));r=F}},stop:function(M,k){fa("eventResizeStop",this,o,M,k);if(F)P(this,o,0,u("slotMinutes")*F,M,k);else{s.css("z-index",
+8);K(o,s)}}})}var q=this;q.renderEvents=a;q.compileDaySegs=e;q.clearEvents=b;q.slotSegHtml=l;q.bindDaySeg=j;Qb.call(q);var u=q.opt,fa=q.trigger,oa=q.isEventDraggable,ga=q.isEventResizable,ra=q.eventEnd,sa=q.reportEvents,ha=q.reportEventClear,da=q.eventElementHandlers,na=q.setHeight,ua=q.getDaySegmentContainer,pa=q.getSlotSegmentContainer,U=q.getHoverListener,ca=q.getMaxMinute,ka=q.getMinMinute,qa=q.timePosition,G=q.colContentLeft,p=q.colContentRight,L=q.renderDaySegs,c=q.resizableDayEvent,z=q.getColCnt,
+H=q.getColWidth,T=q.getSlotHeight,X=q.getBodyContent,ya=q.reportEventElement,K=q.showEvents,i=q.hideEvents,C=q.eventDrop,P=q.eventResize,E=q.renderDayOverlay,B=q.clearOverlays,n=q.calendar,Y=n.formatDate,W=n.formatDates}function vc(a){var b,e,d,f,g,l;for(b=a.length-1;b>0;b--){f=a[b];for(e=0;e<f.length;e++){g=f[e];for(d=0;d<a[b-1].length;d++){l=a[b-1][d];if(Cb(g,l))l.forward=Math.max(l.forward||0,(g.forward||0)+1)}}}}function Kb(a,b,e){function d(G,p){G=qa[G];if(typeof G=="object")return jb(G,p||e);
+return G}function f(G,p){return b.trigger.apply(b,[G,p||da].concat(Array.prototype.slice.call(arguments,2),[da]))}function g(G){return j(G)&&!d("disableDragging")}function l(G){return j(G)&&!d("disableResizing")}function j(G){return Ta(G.editable,(G.source||{}).editable,d("editable"))}function t(G){U={};var p,L=G.length,c;for(p=0;p<L;p++){c=G[p];if(U[c._id])U[c._id].push(c);else U[c._id]=[c]}}function y(G){return G.end?N(G.end):na(G)}function S(G,p){ca.push(p);if(ka[G._id])ka[G._id].push(p);else ka[G._id]=
+[p]}function Q(){ca=[];ka={}}function q(G,p){p.click(function(L){if(!p.hasClass("ui-draggable-dragging")&&!p.hasClass("ui-resizable-resizing"))return f("eventClick",this,G,L)}).hover(function(L){f("eventMouseover",this,G,L)},function(L){f("eventMouseout",this,G,L)})}function u(G,p){oa(G,p,"show")}function fa(G,p){oa(G,p,"hide")}function oa(G,p,L){G=ka[G._id];var c,z=G.length;for(c=0;c<z;c++)if(!p||G[c][0]!=p[0])G[c][L]()}function ga(G,p,L,c,z,H,T){var X=p.allDay,ya=p._id;sa(U[ya],L,c,z);f("eventDrop",
+G,p,L,c,z,function(){sa(U[ya],-L,-c,X);pa(ya)},H,T);pa(ya)}function ra(G,p,L,c,z,H){var T=p._id;ha(U[T],L,c);f("eventResize",G,p,L,c,function(){ha(U[T],-L,-c);pa(T)},z,H);pa(T)}function sa(G,p,L,c){L=L||0;for(var z,H=G.length,T=0;T<H;T++){z=G[T];if(c!==ma)z.allDay=c;xa(ba(z.start,p,true),L);if(z.end)z.end=xa(ba(z.end,p,true),L);ua(z,qa)}}function ha(G,p,L){L=L||0;for(var c,z=G.length,H=0;H<z;H++){c=G[H];c.end=xa(ba(y(c),p,true),L);ua(c,qa)}}var da=this;da.element=a;da.calendar=b;da.name=e;da.opt=
+d;da.trigger=f;da.isEventDraggable=g;da.isEventResizable=l;da.reportEvents=t;da.eventEnd=y;da.reportEventElement=S;da.reportEventClear=Q;da.eventElementHandlers=q;da.showEvents=u;da.hideEvents=fa;da.eventDrop=ga;da.eventResize=ra;var na=da.defaultEventEnd,ua=b.normalizeEvent,pa=b.reportEventChange,U={},ca=[],ka={},qa=b.options}function Qb(){function a(i,C){var P=z(),E=pa(),B=U(),n=0,Y,W,o=i.length,s,v;P[0].innerHTML=e(i);d(i,P.children());f(i);g(i,P,C);l(i);j(i);t(i);C=y();for(P=0;P<E;P++){Y=[];for(W=
+0;W<B;W++)Y[W]=0;for(;n<o&&(s=i[n]).row==P;){W=Hb(Y.slice(s.startCol,s.endCol));s.top=W;W+=s.outerHeight;for(v=s.startCol;v<s.endCol;v++)Y[v]=W;n++}C[P].height(Hb(Y))}Q(i,S(C))}function b(i,C,P){var E=m("<div/>"),B=z(),n=i.length,Y;E[0].innerHTML=e(i);E=E.children();B.append(E);d(i,E);l(i);j(i);t(i);Q(i,S(y()));E=[];for(B=0;B<n;B++)if(Y=i[B].element){i[B].row===C&&Y.css("top",P);E.push(Y[0])}return m(E)}function e(i){var C=fa("isRTL"),P,E=i.length,B,n,Y,W;P=ka();var o=P.left,s=P.right,v,F,r,J,M,k=
+"";for(P=0;P<E;P++){B=i[P];n=B.event;W=["fc-event","fc-event-skin","fc-event-hori"];ga(n)&&W.push("fc-event-draggable");if(C){B.isStart&&W.push("fc-corner-right");B.isEnd&&W.push("fc-corner-left");v=p(B.end.getDay()-1);F=p(B.start.getDay());r=B.isEnd?qa(v):o;J=B.isStart?G(F):s}else{B.isStart&&W.push("fc-corner-left");B.isEnd&&W.push("fc-corner-right");v=p(B.start.getDay());F=p(B.end.getDay()-1);r=B.isStart?qa(v):o;J=B.isEnd?G(F):s}W=W.concat(n.className);if(n.source)W=W.concat(n.source.className||
+[]);Y=n.url;M=Jb(n,fa);k+=Y?"<a href='"+Qa(Y)+"'":"<div";k+=" class='"+W.join(" ")+"' style='position:absolute;z-index:8;left:"+r+"px;"+M+"'><div class='fc-event-inner fc-event-skin'"+(M?" style='"+M+"'":"")+">";if(!n.allDay&&B.isStart)k+="<span class='fc-event-time'>"+Qa(T(n.start,n.end,fa("timeFormat")))+"</span>";k+="<span class='fc-event-title'>"+Qa(n.title)+"</span></div>";if(B.isEnd&&ra(n))k+="<div class='ui-resizable-handle ui-resizable-"+(C?"w":"e")+"'>&nbsp;&nbsp;&nbsp;</div>";k+="</"+(Y?
+"a":"div")+">";B.left=r;B.outerWidth=J-r;B.startCol=v;B.endCol=F+1}return k}function d(i,C){var P,E=i.length,B,n,Y;for(P=0;P<E;P++){B=i[P];n=B.event;Y=m(C[P]);n=oa("eventRender",n,n,Y);if(n===false)Y.remove();else{if(n&&n!==true){n=m(n).css({position:"absolute",left:B.left});Y.replaceWith(n);Y=n}B.element=Y}}}function f(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];(B=E.element)&&ha(E.event,B)}}function g(i,C,P){var E,B=i.length,n,Y,W;for(E=0;E<B;E++){n=i[E];if(Y=n.element){W=n.event;if(W._id===
+P)H(W,Y,n);else Y[0]._fci=E}}Db(C,i,H)}function l(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key=Ib(B[0]);Y=W[n];if(Y===ma)Y=W[n]=pb(B,true);E.hsides=Y}}}function j(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];if(B=E.element)B[0].style.width=Math.max(0,E.outerWidth-E.hsides)+"px"}}function t(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key;Y=W[n];if(Y===ma)Y=W[n]=Fb(B);E.outerHeight=B[0].offsetHeight+Y}}}function y(){var i,C=pa(),
+P=[];for(i=0;i<C;i++)P[i]=ca(i).find("td:first div.fc-day-content > div");return P}function S(i){var C,P=i.length,E=[];for(C=0;C<P;C++)E[C]=i[C][0].offsetTop;return E}function Q(i,C){var P,E=i.length,B,n;for(P=0;P<E;P++){B=i[P];if(n=B.element){n[0].style.top=C[B.row]+(B.top||0)+"px";B=B.event;oa("eventAfterRender",B,B,n)}}}function q(i,C,P){var E=fa("isRTL"),B=E?"w":"e",n=C.find("div.ui-resizable-"+B),Y=false;qb(C);C.mousedown(function(W){W.preventDefault()}).click(function(W){if(Y){W.preventDefault();
+W.stopImmediatePropagation()}});n.mousedown(function(W){function o(ia){oa("eventResizeStop",this,i,ia);m("body").css("cursor","");s.stop();ya();k&&ua(this,i,k,0,ia);setTimeout(function(){Y=false},0)}if(W.which==1){Y=true;var s=u.getHoverListener(),v=pa(),F=U(),r=E?-1:1,J=E?F-1:0,M=C.css("top"),k,D,Z=m.extend({},i),ja=L(i.start);K();m("body").css("cursor",B+"-resize").one("mouseup",o);oa("eventResizeStart",this,i,W);s.start(function(ia,la){if(ia){var $=Math.max(ja.row,ia.row);ia=ia.col;if(v==1)$=0;
+if($==ja.row)ia=E?Math.min(ja.col,ia):Math.max(ja.col,ia);k=$*7+ia*r+J-(la.row*7+la.col*r+J);la=ba(sa(i),k,true);if(k){Z.end=la;$=D;D=b(c([Z]),P.row,M);D.find("*").css("cursor",B+"-resize");$&&$.remove();na(i)}else if(D){da(i);D.remove();D=null}ya();X(i.start,ba(N(la),1))}},W)}})}var u=this;u.renderDaySegs=a;u.resizableDayEvent=q;var fa=u.opt,oa=u.trigger,ga=u.isEventDraggable,ra=u.isEventResizable,sa=u.eventEnd,ha=u.reportEventElement,da=u.showEvents,na=u.hideEvents,ua=u.eventResize,pa=u.getRowCnt,
+U=u.getColCnt,ca=u.allDayRow,ka=u.allDayBounds,qa=u.colContentLeft,G=u.colContentRight,p=u.dayOfWeekCol,L=u.dateCell,c=u.compileDaySegs,z=u.getDaySegmentContainer,H=u.bindDaySeg,T=u.calendar.formatDates,X=u.renderDayOverlay,ya=u.clearOverlays,K=u.clearSelection}function Mb(){function a(Q,q,u){b();q||(q=j(Q,u));t(Q,q,u);e(Q,q,u)}function b(Q){if(S){S=false;y();l("unselect",null,Q)}}function e(Q,q,u,fa){S=true;l("select",null,Q,q,u,fa)}function d(Q){var q=f.cellDate,u=f.cellIsAllDay,fa=f.getHoverListener(),
+oa=f.reportDayClick;if(Q.which==1&&g("selectable")){b(Q);var ga;fa.start(function(ra,sa){y();if(ra&&u(ra)){ga=[q(sa),q(ra)].sort(Gb);t(ga[0],ga[1],true)}else ga=null},Q);m(document).one("mouseup",function(ra){fa.stop();if(ga){+ga[0]==+ga[1]&&oa(ga[0],true,ra);e(ga[0],ga[1],true,ra)}})}}var f=this;f.select=a;f.unselect=b;f.reportSelection=e;f.daySelectionMousedown=d;var g=f.opt,l=f.trigger,j=f.defaultSelectionEnd,t=f.renderSelection,y=f.clearSelection,S=false;g("selectable")&&g("unselectAuto")&&m(document).mousedown(function(Q){var q=
+g("unselectCancel");if(q)if(m(Q.target).parents(q).length)return;b(Q)})}function Lb(){function a(g,l){var j=f.shift();j||(j=m("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>"));j[0].parentNode!=l[0]&&j.appendTo(l);d.push(j.css(g).show());return j}function b(){for(var g;g=d.shift();)f.push(g.hide().unbind())}var e=this;e.renderOverlay=a;e.clearOverlays=b;var d=[],f=[]}function Nb(a){var b=this,e,d;b.build=function(){e=[];d=[];a(e,d)};b.cell=function(f,g){var l=e.length,j=d.length,
+t,y=-1,S=-1;for(t=0;t<l;t++)if(g>=e[t][0]&&g<e[t][1]){y=t;break}for(t=0;t<j;t++)if(f>=d[t][0]&&f<d[t][1]){S=t;break}return y>=0&&S>=0?{row:y,col:S}:null};b.rect=function(f,g,l,j,t){t=t.offset();return{top:e[f][0]-t.top,left:d[g][0]-t.left,width:d[j][1]-d[g][0],height:e[l][1]-e[f][0]}}}function Ob(a){function b(j){xc(j);j=a.cell(j.pageX,j.pageY);if(!j!=!l||j&&(j.row!=l.row||j.col!=l.col)){if(j){g||(g=j);f(j,g,j.row-g.row,j.col-g.col)}else f(j,g);l=j}}var e=this,d,f,g,l;e.start=function(j,t,y){f=j;
+g=l=null;a.build();b(t);d=y||"mousemove";m(document).bind(d,b)};e.stop=function(){m(document).unbind(d,b);return l}}function xc(a){if(a.pageX===ma){a.pageX=a.originalEvent.pageX;a.pageY=a.originalEvent.pageY}}function Pb(a){function b(l){return d[l]=d[l]||a(l)}var e=this,d={},f={},g={};e.left=function(l){return f[l]=f[l]===ma?b(l).position().left:f[l]};e.right=function(l){return g[l]=g[l]===ma?e.left(l)+b(l).width():g[l]};e.clear=function(){d={};f={};g={}}}var Ya={defaultView:"month",aspectRatio:1.35,
+header:{left:"title",center:"",right:"today prev,next"},weekends:true,allDayDefault:true,ignoreTimezone:true,lazyFetching:true,startParam:"start",endParam:"end",titleFormat:{month:"MMMM yyyy",week:"MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",day:"dddd, MMM d, yyyy"},columnFormat:{month:"ddd",week:"ddd M/d",day:"dddd M/d"},timeFormat:{"":"h(:mm)t"},isRTL:false,firstDay:0,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan",
+"Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],buttonText:{prev:"&nbsp;&#9668;&nbsp;",next:"&nbsp;&#9658;&nbsp;",prevYear:"&nbsp;&lt;&lt;&nbsp;",nextYear:"&nbsp;&gt;&gt;&nbsp;",today:"today",month:"month",week:"week",day:"day"},theme:false,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:true,dropAccept:"*"},yc=
+{header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:"&nbsp;&#9658;&nbsp;",next:"&nbsp;&#9668;&nbsp;",prevYear:"&nbsp;&gt;&gt;&nbsp;",nextYear:"&nbsp;&lt;&lt;&nbsp;"},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Aa=m.fullCalendar={version:"1.5.3"},Ja=Aa.views={};m.fn.fullCalendar=function(a){if(typeof a=="string"){var b=Array.prototype.slice.call(arguments,1),e;this.each(function(){var f=m.data(this,"fullCalendar");if(f&&m.isFunction(f[a])){f=f[a].apply(f,
+b);if(e===ma)e=f;a=="destroy"&&m.removeData(this,"fullCalendar")}});if(e!==ma)return e;return this}var d=a.eventSources||[];delete a.eventSources;if(a.events){d.push(a.events);delete a.events}a=m.extend(true,{},Ya,a.isRTL||a.isRTL===ma&&Ya.isRTL?yc:{},a);this.each(function(f,g){f=m(g);g=new Yb(f,a,d);f.data("fullCalendar",g);g.render()});return this};Aa.sourceNormalizers=[];Aa.sourceFetchers=[];var ac={dataType:"json",cache:false},bc=1;Aa.addDays=ba;Aa.cloneDate=N;Aa.parseDate=kb;Aa.parseISO8601=
+Bb;Aa.parseTime=mb;Aa.formatDate=Oa;Aa.formatDates=ib;var lc=["sun","mon","tue","wed","thu","fri","sat"],Ab=864E5,cc=36E5,wc=6E4,dc={s:function(a){return a.getSeconds()},ss:function(a){return Pa(a.getSeconds())},m:function(a){return a.getMinutes()},mm:function(a){return Pa(a.getMinutes())},h:function(a){return a.getHours()%12||12},hh:function(a){return Pa(a.getHours()%12||12)},H:function(a){return a.getHours()},HH:function(a){return Pa(a.getHours())},d:function(a){return a.getDate()},dd:function(a){return Pa(a.getDate())},
+ddd:function(a,b){return b.dayNamesShort[a.getDay()]},dddd:function(a,b){return b.dayNames[a.getDay()]},M:function(a){return a.getMonth()+1},MM:function(a){return Pa(a.getMonth()+1)},MMM:function(a,b){return b.monthNamesShort[a.getMonth()]},MMMM:function(a,b){return b.monthNames[a.getMonth()]},yy:function(a){return(a.getFullYear()+"").substring(2)},yyyy:function(a){return a.getFullYear()},t:function(a){return a.getHours()<12?"a":"p"},tt:function(a){return a.getHours()<12?"am":"pm"},T:function(a){return a.getHours()<
+12?"A":"P"},TT:function(a){return a.getHours()<12?"AM":"PM"},u:function(a){return Oa(a,"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(a){a=a.getDate();if(a>10&&a<20)return"th";return["st","nd","rd"][a%10-1]||"th"}};Aa.applyAll=$a;Ja.month=mc;Ja.basicWeek=nc;Ja.basicDay=oc;wb({weekMode:"fixed"});Ja.agendaWeek=qc;Ja.agendaDay=rc;wb({allDaySlot:true,allDayText:"all-day",firstHour:6,slotMinutes:30,defaultEventMinutes:120,axisFormat:"h(:mm)tt",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:0.5},minTime:0,
+maxTime:24})})(jQuery);
diff --git a/mod/event_calendar/views/default/js/event_calendar/fullcalendar.php b/mod/event_calendar/views/default/js/event_calendar/fullcalendar.php
new file mode 100644
index 000000000..d0321f64b
--- /dev/null
+++ b/mod/event_calendar/views/default/js/event_calendar/fullcalendar.php
@@ -0,0 +1,5227 @@
+//<script>
+/**
+ * @preserve
+ * FullCalendar v1.5.3
+ * http://arshaw.com/fullcalendar/
+ *
+ * Use fullcalendar.css for basic styling.
+ * For event drag & drop, requires jQuery UI draggable.
+ * For event resizing, requires jQuery UI resizable.
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Mon Feb 6 22:40:40 2012 -0800
+ *
+ */
+
+(function($, undefined) {
+
+
+var defaults = {
+
+ // display
+ defaultView: 'month',
+ aspectRatio: 1.35,
+ header: {
+ left: 'title',
+ center: '',
+ right: 'today prev,next'
+ },
+ weekends: true,
+
+ // editing
+ //editable: false,
+ //disableDragging: false,
+ //disableResizing: false,
+
+ allDayDefault: true,
+ ignoreTimezone: true,
+
+ // event ajax
+ lazyFetching: true,
+ startParam: 'start',
+ endParam: 'end',
+
+ // time formats
+ titleFormat: {
+ month: 'MMMM yyyy',
+ week: "MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",
+ day: 'dddd, MMM d, yyyy'
+ },
+ columnFormat: {
+ month: 'ddd',
+ week: 'ddd M/d',
+ day: 'dddd M/d'
+ },
+ timeFormat: { // for event elements
+ '': 'h(:mm)t' // default
+ },
+
+ // locale
+ isRTL: false,
+ firstDay: 0,
+ monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
+ monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
+ dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
+ dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
+ buttonText: {
+ prev: '&nbsp;&#9668;&nbsp;',
+ next: '&nbsp;&#9658;&nbsp;',
+ prevYear: '&nbsp;&lt;&lt;&nbsp;',
+ nextYear: '&nbsp;&gt;&gt;&nbsp;',
+ today: 'today',
+ month: 'month',
+ week: 'week',
+ day: 'day'
+ },
+
+ // jquery-ui theming
+ theme: false,
+ buttonIcons: {
+ prev: 'circle-triangle-w',
+ next: 'circle-triangle-e'
+ },
+
+ //selectable: false,
+ unselectAuto: true,
+
+ dropAccept: '*'
+
+};
+
+// right-to-left defaults
+var rtlDefaults = {
+ header: {
+ left: 'next,prev today',
+ center: '',
+ right: 'title'
+ },
+ buttonText: {
+ prev: '&nbsp;&#9658;&nbsp;',
+ next: '&nbsp;&#9668;&nbsp;',
+ prevYear: '&nbsp;&gt;&gt;&nbsp;',
+ nextYear: '&nbsp;&lt;&lt;&nbsp;'
+ },
+ buttonIcons: {
+ prev: 'circle-triangle-e',
+ next: 'circle-triangle-w'
+ }
+};
+
+
+
+var fc = $.fullCalendar = { version: "1.5.3" };
+var fcViews = fc.views = {};
+
+
+$.fn.fullCalendar = function(options) {
+
+
+ // method calling
+ if (typeof options == 'string') {
+ var args = Array.prototype.slice.call(arguments, 1);
+ var res;
+ this.each(function() {
+ var calendar = $.data(this, 'fullCalendar');
+ if (calendar && $.isFunction(calendar[options])) {
+ var r = calendar[options].apply(calendar, args);
+ if (res === undefined) {
+ res = r;
+ }
+ if (options == 'destroy') {
+ $.removeData(this, 'fullCalendar');
+ }
+ }
+ });
+ if (res !== undefined) {
+ return res;
+ }
+ return this;
+ }
+
+
+ // would like to have this logic in EventManager, but needs to happen before options are recursively extended
+ var eventSources = options.eventSources || [];
+ delete options.eventSources;
+ if (options.events) {
+ eventSources.push(options.events);
+ delete options.events;
+ }
+
+
+ options = $.extend(true, {},
+ defaults,
+ (options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
+ options
+ );
+
+
+ this.each(function(i, _element) {
+ var element = $(_element);
+ var calendar = new Calendar(element, options, eventSources);
+ element.data('fullCalendar', calendar); // TODO: look into memory leak implications
+ calendar.render();
+ });
+
+
+ return this;
+
+};
+
+
+// function for adding/overriding defaults
+function setDefaults(d) {
+ $.extend(true, defaults, d);
+}
+
+
+
+
+function Calendar(element, options, eventSources) {
+ var t = this;
+
+
+ // exports
+ t.options = options;
+ t.render = render;
+ t.destroy = destroy;
+ t.refetchEvents = refetchEvents;
+ t.reportEvents = reportEvents;
+ t.reportEventChange = reportEventChange;
+ t.rerenderEvents = rerenderEvents;
+ t.changeView = changeView;
+ t.select = select;
+ t.unselect = unselect;
+ t.prev = prev;
+ t.next = next;
+ t.prevYear = prevYear;
+ t.nextYear = nextYear;
+ t.today = today;
+ t.gotoDate = gotoDate;
+ t.incrementDate = incrementDate;
+ t.formatDate = function(format, date) { return formatDate(format, date, options) };
+ t.formatDates = function(format, date1, date2) { return formatDates(format, date1, date2, options) };
+ t.getDate = getDate;
+ t.getView = getView;
+ t.option = option;
+ t.trigger = trigger;
+
+
+ // imports
+ EventManager.call(t, options, eventSources);
+ var isFetchNeeded = t.isFetchNeeded;
+ var fetchEvents = t.fetchEvents;
+
+
+ // locals
+ var _element = element[0];
+ var header;
+ var headerElement;
+ var content;
+ var tm; // for making theme classes
+ var currentView;
+ var viewInstances = {};
+ var elementOuterWidth;
+ var suggestedViewHeight;
+ var absoluteViewElement;
+ var resizeUID = 0;
+ var ignoreWindowResize = 0;
+ var date = new Date();
+ var events = [];
+ var _dragElement;
+
+
+
+ /* Main Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ setYMD(date, options.year, options.month, options.date);
+
+
+ function render(inc) {
+ if (!content) {
+ initialRender();
+ }else{
+ calcSize();
+ markSizesDirty();
+ markEventsDirty();
+ renderView(inc);
+ }
+ }
+
+
+ function initialRender() {
+ tm = options.theme ? 'ui' : 'fc';
+ element.addClass('fc');
+ if (options.isRTL) {
+ element.addClass('fc-rtl');
+ }
+ if (options.theme) {
+ element.addClass('ui-widget');
+ }
+ content = $("<div class='fc-content' style='position:relative'/>")
+ .prependTo(element);
+ header = new Header(t, options);
+ headerElement = header.render();
+ if (headerElement) {
+ element.prepend(headerElement);
+ }
+ changeView(options.defaultView);
+ $(window).resize(windowResize);
+ // needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize
+ if (!bodyVisible()) {
+ lateRender();
+ }
+ }
+
+
+ // called when we know the calendar couldn't be rendered when it was initialized,
+ // but we think it's ready now
+ function lateRender() {
+ setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
+ if (!currentView.start && bodyVisible()) { // !currentView.start makes sure this never happens more than once
+ renderView();
+ }
+ },0);
+ }
+
+
+ function destroy() {
+ $(window).unbind('resize', windowResize);
+ header.destroy();
+ content.remove();
+ element.removeClass('fc fc-rtl ui-widget');
+ }
+
+
+
+ function elementVisible() {
+ return _element.offsetWidth !== 0;
+ }
+
+
+ function bodyVisible() {
+ return $('body')[0].offsetWidth !== 0;
+ }
+
+
+
+ /* View Rendering
+ -----------------------------------------------------------------------------*/
+
+ // TODO: improve view switching (still weird transition in IE, and FF has whiteout problem)
+
+ function changeView(newViewName) {
+ if (!currentView || newViewName != currentView.name) {
+ ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached
+
+ unselect();
+
+ var oldView = currentView;
+ var newViewElement;
+
+ if (oldView) {
+ (oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera)
+ setMinHeight(content, content.height());
+ oldView.element.hide();
+ }else{
+ setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated
+ }
+ content.css('overflow', 'hidden');
+
+ currentView = viewInstances[newViewName];
+ if (currentView) {
+ currentView.element.show();
+ }else{
+ currentView = viewInstances[newViewName] = new fcViews[newViewName](
+ newViewElement = absoluteViewElement =
+ $("<div class='fc-view fc-view-" + newViewName + "' style='position:absolute'/>")
+ .appendTo(content),
+ t // the calendar object
+ );
+ }
+
+ if (oldView) {
+ header.deactivateButton(oldView.name);
+ }
+ header.activateButton(newViewName);
+
+ renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
+
+ content.css('overflow', '');
+ if (oldView) {
+ setMinHeight(content, 1);
+ }
+
+ if (!newViewElement) {
+ (currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera)
+ }
+
+ ignoreWindowResize--;
+ }
+ }
+
+
+
+ function renderView(inc) {
+ if (elementVisible()) {
+ ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached
+
+ unselect();
+
+ if (suggestedViewHeight === undefined) {
+ calcSize();
+ }
+
+ var forceEventRender = false;
+ if (!currentView.start || inc || date < currentView.start || date >= currentView.end) {
+ // view must render an entire new date range (and refetch/render events)
+ currentView.render(date, inc || 0); // responsible for clearing events
+ setSize(true);
+ forceEventRender = true;
+ }
+ else if (currentView.sizeDirty) {
+ // view must resize (and rerender events)
+ currentView.clearEvents();
+ setSize();
+ forceEventRender = true;
+ }
+ else if (currentView.eventsDirty) {
+ currentView.clearEvents();
+ forceEventRender = true;
+ }
+ currentView.sizeDirty = false;
+ currentView.eventsDirty = false;
+ updateEvents(forceEventRender);
+
+ elementOuterWidth = element.outerWidth();
+
+ header.updateTitle(currentView.title);
+ var today = new Date();
+ if (today >= currentView.start && today < currentView.end) {
+ header.disableButton('today');
+ }else{
+ header.enableButton('today');
+ }
+
+ ignoreWindowResize--;
+ currentView.trigger('viewDisplay', _element);
+ }
+ }
+
+
+
+ /* Resizing
+ -----------------------------------------------------------------------------*/
+
+
+ function updateSize() {
+ markSizesDirty();
+ if (elementVisible()) {
+ calcSize();
+ setSize();
+ unselect();
+ currentView.clearEvents();
+ currentView.renderEvents(events);
+ currentView.sizeDirty = false;
+ }
+ }
+
+
+ function markSizesDirty() {
+ $.each(viewInstances, function(i, inst) {
+ inst.sizeDirty = true;
+ });
+ }
+
+
+ function calcSize() {
+ if (options.contentHeight) {
+ suggestedViewHeight = options.contentHeight;
+ }
+ else if (options.height) {
+ suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content);
+ }
+ else {
+ suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
+ }
+ }
+
+
+ function setSize(dateChanged) { // todo: dateChanged?
+ ignoreWindowResize++;
+ currentView.setHeight(suggestedViewHeight, dateChanged);
+ if (absoluteViewElement) {
+ absoluteViewElement.css('position', 'relative');
+ absoluteViewElement = null;
+ }
+ currentView.setWidth(content.width(), dateChanged);
+ ignoreWindowResize--;
+ }
+
+
+ function windowResize() {
+ if (!ignoreWindowResize) {
+ if (currentView.start) { // view has already been rendered
+ var uid = ++resizeUID;
+ setTimeout(function() { // add a delay
+ if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
+ if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
+ ignoreWindowResize++; // in case the windowResize callback changes the height
+ updateSize();
+ currentView.trigger('windowResize', _element);
+ ignoreWindowResize--;
+ }
+ }
+ }, 200);
+ }else{
+ // calendar must have been initialized in a 0x0 iframe that has just been resized
+ lateRender();
+ }
+ }
+ }
+
+
+
+ /* Event Fetching/Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ // fetches events if necessary, rerenders events if necessary (or if forced)
+ function updateEvents(forceRender) {
+ if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) {
+ refetchEvents();
+ }
+ else if (forceRender) {
+ rerenderEvents();
+ }
+ }
+
+
+ function refetchEvents() {
+ fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents
+ }
+
+
+ // called when event data arrives
+ function reportEvents(_events) {
+ events = _events;
+ rerenderEvents();
+ }
+
+
+ // called when a single event's data has been changed
+ function reportEventChange(eventID) {
+ rerenderEvents(eventID);
+ }
+
+
+ // attempts to rerenderEvents
+ function rerenderEvents(modifiedEventID) {
+ markEventsDirty();
+ if (elementVisible()) {
+ currentView.clearEvents();
+ currentView.renderEvents(events, modifiedEventID);
+ currentView.eventsDirty = false;
+ }
+ }
+
+
+ function markEventsDirty() {
+ $.each(viewInstances, function(i, inst) {
+ inst.eventsDirty = true;
+ });
+ }
+
+
+
+ /* Selection
+ -----------------------------------------------------------------------------*/
+
+
+ function select(start, end, allDay) {
+ currentView.select(start, end, allDay===undefined ? true : allDay);
+ }
+
+
+ function unselect() { // safe to be called before renderView
+ if (currentView) {
+ currentView.unselect();
+ }
+ }
+
+
+
+ /* Date
+ -----------------------------------------------------------------------------*/
+
+
+ function prev() {
+ renderView(-1);
+ }
+
+
+ function next() {
+ renderView(1);
+ }
+
+
+ function prevYear() {
+ addYears(date, -1);
+ renderView();
+ }
+
+
+ function nextYear() {
+ addYears(date, 1);
+ renderView();
+ }
+
+
+ function today() {
+ date = new Date();
+ renderView();
+ }
+
+
+ function gotoDate(year, month, dateOfMonth) {
+ if (year instanceof Date) {
+ date = cloneDate(year); // provided 1 argument, a Date
+ }else{
+ setYMD(date, year, month, dateOfMonth);
+ }
+ renderView();
+ }
+
+
+ function incrementDate(years, months, days) {
+ if (years !== undefined) {
+ addYears(date, years);
+ }
+ if (months !== undefined) {
+ addMonths(date, months);
+ }
+ if (days !== undefined) {
+ addDays(date, days);
+ }
+ renderView();
+ }
+
+
+ function getDate() {
+ return cloneDate(date);
+ }
+
+
+
+ /* Misc
+ -----------------------------------------------------------------------------*/
+
+
+ function getView() {
+ return currentView;
+ }
+
+
+ function option(name, value) {
+ if (value === undefined) {
+ return options[name];
+ }
+ if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
+ options[name] = value;
+ updateSize();
+ }
+ }
+
+
+ function trigger(name, thisObj) {
+ if (options[name]) {
+ return options[name].apply(
+ thisObj || _element,
+ Array.prototype.slice.call(arguments, 2)
+ );
+ }
+ }
+
+
+
+ /* External Dragging
+ ------------------------------------------------------------------------*/
+
+ if (options.droppable) {
+ $(document)
+ .bind('dragstart', function(ev, ui) {
+ var _e = ev.target;
+ var e = $(_e);
+ if (!e.parents('.fc').length) { // not already inside a calendar
+ var accept = options.dropAccept;
+ if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
+ _dragElement = _e;
+ currentView.dragStart(_dragElement, ev, ui);
+ }
+ }
+ })
+ .bind('dragstop', function(ev, ui) {
+ if (_dragElement) {
+ currentView.dragStop(_dragElement, ev, ui);
+ _dragElement = null;
+ }
+ });
+ }
+
+
+}
+
+function Header(calendar, options) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+ t.destroy = destroy;
+ t.updateTitle = updateTitle;
+ t.activateButton = activateButton;
+ t.deactivateButton = deactivateButton;
+ t.disableButton = disableButton;
+ t.enableButton = enableButton;
+
+
+ // locals
+ var element = $([]);
+ var tm;
+
+
+
+ function render() {
+ tm = options.theme ? 'ui' : 'fc';
+ var sections = options.header;
+ if (sections) {
+ element = $("<table class='fc-header' style='width:100%'/>")
+ .append(
+ $("<tr/>")
+ .append(renderSection('left'))
+ .append(renderSection('center'))
+ .append(renderSection('right'))
+ );
+ return element;
+ }
+ }
+
+
+ function destroy() {
+ element.remove();
+ }
+
+
+ function renderSection(position) {
+ var e = $("<td class='fc-header-" + position + "'/>");
+ var buttonStr = options.header[position];
+ if (buttonStr) {
+ $.each(buttonStr.split(' '), function(i) {
+ if (i > 0) {
+ e.append("<span class='fc-header-space'/>");
+ }
+ var prevButton;
+ $.each(this.split(','), function(j, buttonName) {
+ if (buttonName == 'title') {
+ e.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");
+ if (prevButton) {
+ prevButton.addClass(tm + '-corner-right');
+ }
+ prevButton = null;
+ }else{
+ var buttonClick;
+ if (calendar[buttonName]) {
+ buttonClick = calendar[buttonName]; // calendar method
+ }
+ else if (fcViews[buttonName]) {
+ buttonClick = function() {
+ button.removeClass(tm + '-state-hover'); // forget why
+ calendar.changeView(buttonName);
+ };
+ }
+ if (buttonClick) {
+ var icon = options.theme ? smartProperty(options.buttonIcons, buttonName) : null; // why are we using smartProperty here?
+ var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here?
+ var button = $(
+ "<span class='fc-button fc-button-" + buttonName + " " + tm + "-state-default'>" +
+ "<span class='fc-button-inner'>" +
+ "<span class='fc-button-content'>" +
+ (icon ?
+ "<span class='fc-icon-wrap'>" +
+ "<span class='ui-icon ui-icon-" + icon + "'/>" +
+ "</span>" :
+ text
+ ) +
+ "</span>" +
+ "<span class='fc-button-effect'><span></span></span>" +
+ "</span>" +
+ "</span>"
+ );
+ if (button) {
+ button
+ .click(function() {
+ if (!button.hasClass(tm + '-state-disabled')) {
+ buttonClick();
+ }
+ })
+ .mousedown(function() {
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-down');
+ })
+ .mouseup(function() {
+ button.removeClass(tm + '-state-down');
+ })
+ .hover(
+ function() {
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-hover');
+ },
+ function() {
+ button
+ .removeClass(tm + '-state-hover')
+ .removeClass(tm + '-state-down');
+ }
+ )
+ .appendTo(e);
+ if (!prevButton) {
+ button.addClass(tm + '-corner-left');
+ }
+ prevButton = button;
+ }
+ }
+ }
+ });
+ if (prevButton) {
+ prevButton.addClass(tm + '-corner-right');
+ }
+ });
+ }
+ return e;
+ }
+
+
+ function updateTitle(html) {
+ element.find('h2')
+ .html(html);
+ }
+
+
+ function activateButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .addClass(tm + '-state-active');
+ }
+
+
+ function deactivateButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .removeClass(tm + '-state-active');
+ }
+
+
+ function disableButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .addClass(tm + '-state-disabled');
+ }
+
+
+ function enableButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .removeClass(tm + '-state-disabled');
+ }
+
+
+}
+
+fc.sourceNormalizers = [];
+fc.sourceFetchers = [];
+
+var ajaxDefaults = {
+ dataType: 'json',
+ cache: false
+};
+
+var eventGUID = 1;
+
+
+function EventManager(options, _sources) {
+ var t = this;
+
+
+ // exports
+ t.isFetchNeeded = isFetchNeeded;
+ t.fetchEvents = fetchEvents;
+ t.addEventSource = addEventSource;
+ t.removeEventSource = removeEventSource;
+ t.updateEvent = updateEvent;
+ t.renderEvent = renderEvent;
+ t.removeEvents = removeEvents;
+ t.clientEvents = clientEvents;
+ t.normalizeEvent = normalizeEvent;
+
+
+ // imports
+ var trigger = t.trigger;
+ var getView = t.getView;
+ var reportEvents = t.reportEvents;
+
+
+ // locals
+ var stickySource = { events: [] };
+ var sources = [ stickySource ];
+ var rangeStart, rangeEnd;
+ var currentFetchID = 0;
+ var pendingSourceCnt = 0;
+ var loadingLevel = 0;
+ var cache = [];
+
+
+ for (var i=0; i<_sources.length; i++) {
+ _addEventSource(_sources[i]);
+ }
+
+
+
+ /* Fetching
+ -----------------------------------------------------------------------------*/
+
+
+ function isFetchNeeded(start, end) {
+ return !rangeStart || start < rangeStart || end > rangeEnd;
+ }
+
+
+ function fetchEvents(start, end) {
+ rangeStart = start;
+ rangeEnd = end;
+ cache = [];
+ var fetchID = ++currentFetchID;
+ var len = sources.length;
+ pendingSourceCnt = len;
+ for (var i=0; i<len; i++) {
+ fetchEventSource(sources[i], fetchID);
+ }
+ }
+
+
+ function fetchEventSource(source, fetchID) {
+ _fetchEventSource(source, function(events) {
+ if (fetchID == currentFetchID) {
+ if (events) {
+ for (var i=0; i<events.length; i++) {
+ events[i].source = source;
+ normalizeEvent(events[i]);
+ }
+ cache = cache.concat(events);
+ }
+ pendingSourceCnt--;
+ if (!pendingSourceCnt) {
+ reportEvents(cache);
+ }
+ }
+ });
+ }
+
+
+ function _fetchEventSource(source, callback) {
+ var i;
+ var fetchers = fc.sourceFetchers;
+ var res;
+ for (i=0; i<fetchers.length; i++) {
+ res = fetchers[i](source, rangeStart, rangeEnd, callback);
+ if (res === true) {
+ // the fetcher is in charge. made its own async request
+ return;
+ }
+ else if (typeof res == 'object') {
+ // the fetcher returned a new source. process it
+ _fetchEventSource(res, callback);
+ return;
+ }
+ }
+ var events = source.events;
+ if (events) {
+ if ($.isFunction(events)) {
+ pushLoading();
+ events(cloneDate(rangeStart), cloneDate(rangeEnd), function(events) {
+ callback(events);
+ popLoading();
+ });
+ }
+ else if ($.isArray(events)) {
+ callback(events);
+ }
+ else {
+ callback();
+ }
+ }else{
+ var url = source.url;
+ if (url) {
+ var success = source.success;
+ var error = source.error;
+ var complete = source.complete;
+ var data = $.extend({}, source.data || {});
+ var startParam = firstDefined(source.startParam, options.startParam);
+ var endParam = firstDefined(source.endParam, options.endParam);
+ if (startParam) {
+ data[startParam] = Math.round(+rangeStart / 1000);
+ }
+ if (endParam) {
+ data[endParam] = Math.round(+rangeEnd / 1000);
+ }
+ pushLoading();
+ $.ajax($.extend({}, ajaxDefaults, source, {
+ data: data,
+ success: function(events) {
+ events = events || [];
+ var res = applyAll(success, this, arguments);
+ if ($.isArray(res)) {
+ events = res;
+ }
+ callback(events);
+ },
+ error: function() {
+ applyAll(error, this, arguments);
+ callback();
+ },
+ complete: function() {
+ applyAll(complete, this, arguments);
+ popLoading();
+ }
+ }));
+ }else{
+ callback();
+ }
+ }
+ }
+
+
+
+ /* Sources
+ -----------------------------------------------------------------------------*/
+
+
+ function addEventSource(source) {
+ source = _addEventSource(source);
+ if (source) {
+ pendingSourceCnt++;
+ fetchEventSource(source, currentFetchID); // will eventually call reportEvents
+ }
+ }
+
+
+ function _addEventSource(source) {
+ if ($.isFunction(source) || $.isArray(source)) {
+ source = { events: source };
+ }
+ else if (typeof source == 'string') {
+ source = { url: source };
+ }
+ if (typeof source == 'object') {
+ normalizeSource(source);
+ sources.push(source);
+ return source;
+ }
+ }
+
+
+ function removeEventSource(source) {
+ sources = $.grep(sources, function(src) {
+ return !isSourcesEqual(src, source);
+ });
+ // remove all client events from that source
+ cache = $.grep(cache, function(e) {
+ return !isSourcesEqual(e.source, source);
+ });
+ reportEvents(cache);
+ }
+
+
+
+ /* Manipulation
+ -----------------------------------------------------------------------------*/
+
+
+ function updateEvent(event) { // update an existing event
+ var i, len = cache.length, e,
+ defaultEventEnd = getView().defaultEventEnd, // getView???
+ startDelta = event.start - event._start,
+ endDelta = event.end ?
+ (event.end - (event._end || defaultEventEnd(event))) // event._end would be null if event.end
+ : 0; // was null and event was just resized
+ for (i=0; i<len; i++) {
+ e = cache[i];
+ if (e._id == event._id && e != event) {
+ e.start = new Date(+e.start + startDelta);
+ if (event.end) {
+ if (e.end) {
+ e.end = new Date(+e.end + endDelta);
+ }else{
+ e.end = new Date(+defaultEventEnd(e) + endDelta);
+ }
+ }else{
+ e.end = null;
+ }
+ e.title = event.title;
+ e.url = event.url;
+ e.allDay = event.allDay;
+ e.className = event.className;
+ e.editable = event.editable;
+ e.color = event.color;
+ e.backgroudColor = event.backgroudColor;
+ e.borderColor = event.borderColor;
+ e.textColor = event.textColor;
+ normalizeEvent(e);
+ }
+ }
+ normalizeEvent(event);
+ reportEvents(cache);
+ }
+
+
+ function renderEvent(event, stick) {
+ normalizeEvent(event);
+ if (!event.source) {
+ if (stick) {
+ stickySource.events.push(event);
+ event.source = stickySource;
+ }
+ cache.push(event);
+ }
+ reportEvents(cache);
+ }
+
+
+ function removeEvents(filter) {
+ if (!filter) { // remove all
+ cache = [];
+ // clear all array sources
+ for (var i=0; i<sources.length; i++) {
+ if ($.isArray(sources[i].events)) {
+ sources[i].events = [];
+ }
+ }
+ }else{
+ if (!$.isFunction(filter)) { // an event ID
+ var id = filter + '';
+ filter = function(e) {
+ return e._id == id;
+ };
+ }
+ cache = $.grep(cache, filter, true);
+ // remove events from array sources
+ for (var i=0; i<sources.length; i++) {
+ if ($.isArray(sources[i].events)) {
+ sources[i].events = $.grep(sources[i].events, filter, true);
+ }
+ }
+ }
+ reportEvents(cache);
+ }
+
+
+ function clientEvents(filter) {
+ if ($.isFunction(filter)) {
+ return $.grep(cache, filter);
+ }
+ else if (filter) { // an event ID
+ filter += '';
+ return $.grep(cache, function(e) {
+ return e._id == filter;
+ });
+ }
+ return cache; // else, return all
+ }
+
+
+
+ /* Loading State
+ -----------------------------------------------------------------------------*/
+
+
+ function pushLoading() {
+ if (!loadingLevel++) {
+ trigger('loading', null, true);
+ }
+ }
+
+
+ function popLoading() {
+ if (!--loadingLevel) {
+ trigger('loading', null, false);
+ }
+ }
+
+
+
+ /* Event Normalization
+ -----------------------------------------------------------------------------*/
+
+
+ function normalizeEvent(event) {
+ var source = event.source || {};
+ var ignoreTimezone = firstDefined(source.ignoreTimezone, options.ignoreTimezone);
+ event._id = event._id || (event.id === undefined ? '_fc' + eventGUID++ : event.id + '');
+ if (event.date) {
+ if (!event.start) {
+ event.start = event.date;
+ }
+ delete event.date;
+ }
+ event._start = cloneDate(event.start = parseDate(event.start, ignoreTimezone));
+ event.end = parseDate(event.end, ignoreTimezone);
+ if (event.end && event.end <= event.start) {
+ event.end = null;
+ }
+ event._end = event.end ? cloneDate(event.end) : null;
+ if (event.allDay === undefined) {
+ event.allDay = firstDefined(source.allDayDefault, options.allDayDefault);
+ }
+ if (event.className) {
+ if (typeof event.className == 'string') {
+ event.className = event.className.split(/\s+/);
+ }
+ }else{
+ event.className = [];
+ }
+ // TODO: if there is no start date, return false to indicate an invalid event
+ }
+
+
+
+ /* Utils
+ ------------------------------------------------------------------------------*/
+
+
+ function normalizeSource(source) {
+ if (source.className) {
+ // TODO: repeat code, same code for event classNames
+ if (typeof source.className == 'string') {
+ source.className = source.className.split(/\s+/);
+ }
+ }else{
+ source.className = [];
+ }
+ var normalizers = fc.sourceNormalizers;
+ for (var i=0; i<normalizers.length; i++) {
+ normalizers[i](source);
+ }
+ }
+
+
+ function isSourcesEqual(source1, source2) {
+ return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
+ }
+
+
+ function getSourcePrimitive(source) {
+ return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
+ }
+
+
+}
+
+
+fc.addDays = addDays;
+fc.cloneDate = cloneDate;
+fc.parseDate = parseDate;
+fc.parseISO8601 = parseISO8601;
+fc.parseTime = parseTime;
+fc.formatDate = formatDate;
+fc.formatDates = formatDates;
+
+
+
+/* Date Math
+-----------------------------------------------------------------------------*/
+
+var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
+ DAY_MS = 86400000,
+ HOUR_MS = 3600000,
+ MINUTE_MS = 60000;
+
+
+function addYears(d, n, keepTime) {
+ d.setFullYear(d.getFullYear() + n);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ return d;
+}
+
+
+function addMonths(d, n, keepTime) { // prevents day overflow/underflow
+ if (+d) { // prevent infinite looping on invalid dates
+ var m = d.getMonth() + n,
+ check = cloneDate(d);
+ check.setDate(1);
+ check.setMonth(m);
+ d.setMonth(m);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ while (d.getMonth() != check.getMonth()) {
+ d.setDate(d.getDate() + (d < check ? 1 : -1));
+ }
+ }
+ return d;
+}
+
+
+function addDays(d, n, keepTime) { // deals with daylight savings
+ if (+d) {
+ var dd = d.getDate() + n,
+ check = cloneDate(d);
+ check.setHours(9); // set to middle of day
+ check.setDate(dd);
+ d.setDate(dd);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ fixDate(d, check);
+ }
+ return d;
+}
+
+
+function fixDate(d, check) { // force d to be on check's YMD, for daylight savings purposes
+ if (+d) { // prevent infinite looping on invalid dates
+ while (d.getDate() != check.getDate()) {
+ d.setTime(+d + (d < check ? 1 : -1) * HOUR_MS);
+ }
+ }
+}
+
+
+function addMinutes(d, n) {
+ d.setMinutes(d.getMinutes() + n);
+ return d;
+}
+
+
+function clearTime(d) {
+ d.setHours(0);
+ d.setMinutes(0);
+ d.setSeconds(0);
+ d.setMilliseconds(0);
+ return d;
+}
+
+
+function cloneDate(d, dontKeepTime) {
+ if (dontKeepTime) {
+ return clearTime(new Date(+d));
+ }
+ return new Date(+d);
+}
+
+
+function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1
+ var i=0, d;
+ do {
+ d = new Date(1970, i++, 1);
+ } while (d.getHours()); // != 0
+ return d;
+}
+
+
+function skipWeekend(date, inc, excl) {
+ inc = inc || 1;
+ while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
+ addDays(date, inc);
+ }
+ return date;
+}
+
+
+function dayDiff(d1, d2) { // d1 - d2
+ return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS);
+}
+
+
+function setYMD(date, y, m, d) {
+ if (y !== undefined && y != date.getFullYear()) {
+ date.setDate(1);
+ date.setMonth(0);
+ date.setFullYear(y);
+ }
+ if (m !== undefined && m != date.getMonth()) {
+ date.setDate(1);
+ date.setMonth(m);
+ }
+ if (d !== undefined) {
+ date.setDate(d);
+ }
+}
+
+
+
+/* Date Parsing
+-----------------------------------------------------------------------------*/
+
+
+function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
+ if (typeof s == 'object') { // already a Date object
+ return s;
+ }
+ if (typeof s == 'number') { // a UNIX timestamp
+ return new Date(s * 1000);
+ }
+ if (typeof s == 'string') {
+ if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
+ return new Date(parseFloat(s) * 1000);
+ }
+ if (ignoreTimezone === undefined) {
+ ignoreTimezone = true;
+ }
+ return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
+ }
+ // TODO: never return invalid dates (like from new Date(<string>)), return null instead
+ return null;
+}
+
+
+function parseISO8601(s, ignoreTimezone) { // ignoreTimezone defaults to false
+ // derived from http://delete.me.uk/2005/03/iso8601.html
+ // TODO: for a know glitch/feature, read tests/issue_206_parseDate_dst.html
+ var m = s.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);
+ if (!m) {
+ return null;
+ }
+ var date = new Date(m[1], 0, 1);
+ if (ignoreTimezone || !m[13]) {
+ var check = new Date(m[1], 0, 1, 9, 0);
+ if (m[3]) {
+ date.setMonth(m[3] - 1);
+ check.setMonth(m[3] - 1);
+ }
+ if (m[5]) {
+ date.setDate(m[5]);
+ check.setDate(m[5]);
+ }
+ fixDate(date, check);
+ if (m[7]) {
+ date.setHours(m[7]);
+ }
+ if (m[8]) {
+ date.setMinutes(m[8]);
+ }
+ if (m[10]) {
+ date.setSeconds(m[10]);
+ }
+ if (m[12]) {
+ date.setMilliseconds(Number("0." + m[12]) * 1000);
+ }
+ fixDate(date, check);
+ }else{
+ date.setUTCFullYear(
+ m[1],
+ m[3] ? m[3] - 1 : 0,
+ m[5] || 1
+ );
+ date.setUTCHours(
+ m[7] || 0,
+ m[8] || 0,
+ m[10] || 0,
+ m[12] ? Number("0." + m[12]) * 1000 : 0
+ );
+ if (m[14]) {
+ var offset = Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0);
+ offset *= m[15] == '-' ? 1 : -1;
+ date = new Date(+date + (offset * 60 * 1000));
+ }
+ }
+ return date;
+}
+
+
+function parseTime(s) { // returns minutes since start of day
+ if (typeof s == 'number') { // an hour
+ return s * 60;
+ }
+ if (typeof s == 'object') { // a Date object
+ return s.getHours() * 60 + s.getMinutes();
+ }
+ var m = s.match(/(\d+)(?::(\d+))?\s*(\w+)?/);
+ if (m) {
+ var h = parseInt(m[1], 10);
+ if (m[3]) {
+ h %= 12;
+ if (m[3].toLowerCase().charAt(0) == 'p') {
+ h += 12;
+ }
+ }
+ return h * 60 + (m[2] ? parseInt(m[2], 10) : 0);
+ }
+}
+
+
+
+/* Date Formatting
+-----------------------------------------------------------------------------*/
+// TODO: use same function formatDate(date, [date2], format, [options])
+
+
+function formatDate(date, format, options) {
+ return formatDates(date, null, format, options);
+}
+
+
+function formatDates(date1, date2, format, options) {
+ options = options || defaults;
+ var date = date1,
+ otherDate = date2,
+ i, len = format.length, c,
+ i2, formatter,
+ res = '';
+ for (i=0; i<len; i++) {
+ c = format.charAt(i);
+ if (c == "'") {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == "'") {
+ if (date) {
+ if (i2 == i+1) {
+ res += "'";
+ }else{
+ res += format.substring(i+1, i2);
+ }
+ i = i2;
+ }
+ break;
+ }
+ }
+ }
+ else if (c == '(') {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == ')') {
+ var subres = formatDate(date, format.substring(i+1, i2), options);
+ if (parseInt(subres.replace(/\D/, ''), 10)) {
+ res += subres;
+ }
+ i = i2;
+ break;
+ }
+ }
+ }
+ else if (c == '[') {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == ']') {
+ var subformat = format.substring(i+1, i2);
+ var subres = formatDate(date, subformat, options);
+ if (subres != formatDate(otherDate, subformat, options)) {
+ res += subres;
+ }
+ i = i2;
+ break;
+ }
+ }
+ }
+ else if (c == '{') {
+ date = date2;
+ otherDate = date1;
+ }
+ else if (c == '}') {
+ date = date1;
+ otherDate = date2;
+ }
+ else {
+ for (i2=len; i2>i; i2--) {
+ if (formatter = dateFormatters[format.substring(i, i2)]) {
+ if (date) {
+ res += formatter(date, options);
+ }
+ i = i2 - 1;
+ break;
+ }
+ }
+ if (i2 == i) {
+ if (date) {
+ res += c;
+ }
+ }
+ }
+ }
+ return res;
+};
+
+
+var dateFormatters = {
+ s : function(d) { return d.getSeconds() },
+ ss : function(d) { return zeroPad(d.getSeconds()) },
+ m : function(d) { return d.getMinutes() },
+ mm : function(d) { return zeroPad(d.getMinutes()) },
+ h : function(d) { return d.getUTCHours() % 12 || 12 },
+ hh : function(d) { return zeroPad(d.getUTCHours() % 12 || 12) },
+ H : function(d) { return d.getUTCHours() },
+ HH : function(d) { return zeroPad(d.getUTCHours()) },
+ d : function(d) { return d.getDate() },
+ dd : function(d) { return zeroPad(d.getDate()) },
+ ddd : function(d,o) { return o.dayNamesShort[d.getDay()] },
+ dddd: function(d,o) { return o.dayNames[d.getDay()] },
+ M : function(d) { return d.getMonth() + 1 },
+ MM : function(d) { return zeroPad(d.getMonth() + 1) },
+ MMM : function(d,o) { return o.monthNamesShort[d.getMonth()] },
+ MMMM: function(d,o) { return o.monthNames[d.getMonth()] },
+ yy : function(d) { return (d.getFullYear()+'').substring(2) },
+ yyyy: function(d) { return d.getFullYear() },
+ t : function(d) { return d.getUTCHours() < 12 ? 'a' : 'p' },
+ tt : function(d) { return d.getUTCHours() < 12 ? 'am' : 'pm' },
+ T : function(d) { return d.getUTCHours() < 12 ? 'A' : 'P' },
+ TT : function(d) { return d.getUTCHours() < 12 ? 'AM' : 'PM' },
+ u : function(d) { return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") },
+ S : function(d) {
+ var date = d.getDate();
+ if (date > 10 && date < 20) {
+ return 'th';
+ }
+ return ['st', 'nd', 'rd'][date%10-1] || 'th';
+ }
+};
+
+
+
+fc.applyAll = applyAll;
+
+
+/* Event Date Math
+-----------------------------------------------------------------------------*/
+
+
+function exclEndDay(event) {
+ if (event.end) {
+ return _exclEndDay(event.end, event.allDay);
+ }else{
+ return addDays(cloneDate(event.start), 1);
+ }
+}
+
+
+function _exclEndDay(end, allDay) {
+ end = cloneDate(end);
+ return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end);
+}
+
+
+function segCmp(a, b) {
+ return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
+}
+
+
+function segsCollide(seg1, seg2) {
+ return seg1.end > seg2.start && seg1.start < seg2.end;
+}
+
+
+
+/* Event Sorting
+-----------------------------------------------------------------------------*/
+
+
+// event rendering utilities
+function sliceSegs(events, visEventEnds, start, end) {
+ var segs = [],
+ i, len=events.length, event,
+ eventStart, eventEnd,
+ segStart, segEnd,
+ isStart, isEnd;
+ for (i=0; i<len; i++) {
+ event = events[i];
+ eventStart = event.start;
+ eventEnd = visEventEnds[i];
+ if (eventEnd > start && eventStart < end) {
+ if (eventStart < start) {
+ segStart = cloneDate(start);
+ isStart = false;
+ }else{
+ segStart = eventStart;
+ isStart = true;
+ }
+ if (eventEnd > end) {
+ segEnd = cloneDate(end);
+ isEnd = false;
+ }else{
+ segEnd = eventEnd;
+ isEnd = true;
+ }
+ segs.push({
+ event: event,
+ start: segStart,
+ end: segEnd,
+ isStart: isStart,
+ isEnd: isEnd,
+ msLength: segEnd - segStart
+ });
+ }
+ }
+ return segs.sort(segCmp);
+}
+
+
+// event rendering calculation utilities
+function stackSegs(segs) {
+ var levels = [],
+ i, len = segs.length, seg,
+ j, collide, k;
+ for (i=0; i<len; i++) {
+ seg = segs[i];
+ j = 0; // the level index where seg should belong
+ while (true) {
+ collide = false;
+ if (levels[j]) {
+ for (k=0; k<levels[j].length; k++) {
+ if (segsCollide(levels[j][k], seg)) {
+ collide = true;
+ break;
+ }
+ }
+ }
+ if (collide) {
+ j++;
+ }else{
+ break;
+ }
+ }
+ if (levels[j]) {
+ levels[j].push(seg);
+ }else{
+ levels[j] = [seg];
+ }
+ }
+ return levels;
+}
+
+
+
+/* Event Element Binding
+-----------------------------------------------------------------------------*/
+
+
+function lazySegBind(container, segs, bindHandlers) {
+ container.unbind('mouseover').mouseover(function(ev) {
+ var parent=ev.target, e,
+ i, seg;
+ while (parent != this) {
+ e = parent;
+ parent = parent.parentNode;
+ }
+ if ((i = e._fci) !== undefined) {
+ e._fci = undefined;
+ seg = segs[i];
+ bindHandlers(seg.event, seg.element, seg);
+ $(ev.target).trigger(ev);
+ }
+ ev.stopPropagation();
+ });
+}
+
+
+
+/* Element Dimensions
+-----------------------------------------------------------------------------*/
+
+
+function setOuterWidth(element, width, includeMargins) {
+ for (var i=0, e; i<element.length; i++) {
+ e = $(element[i]);
+ e.width(Math.max(0, width - hsides(e, includeMargins)));
+ }
+}
+
+
+function setOuterHeight(element, height, includeMargins) {
+ for (var i=0, e; i<element.length; i++) {
+ e = $(element[i]);
+ e.height(Math.max(0, height - vsides(e, includeMargins)));
+ }
+}
+
+
+// TODO: curCSS has been deprecated (jQuery 1.4.3 - 10/16/2010)
+
+
+function hsides(element, includeMargins) {
+ return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
+}
+
+
+function hpadding(element) {
+ return (parseFloat($.curCSS(element[0], 'paddingLeft', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'paddingRight', true)) || 0);
+}
+
+
+function hmargins(element) {
+ return (parseFloat($.curCSS(element[0], 'marginLeft', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'marginRight', true)) || 0);
+}
+
+
+function hborders(element) {
+ return (parseFloat($.curCSS(element[0], 'borderLeftWidth', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'borderRightWidth', true)) || 0);
+}
+
+
+function vsides(element, includeMargins) {
+ return vpadding(element) + vborders(element) + (includeMargins ? vmargins(element) : 0);
+}
+
+
+function vpadding(element) {
+ return (parseFloat($.curCSS(element[0], 'paddingTop', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'paddingBottom', true)) || 0);
+}
+
+
+function vmargins(element) {
+ return (parseFloat($.curCSS(element[0], 'marginTop', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'marginBottom', true)) || 0);
+}
+
+
+function vborders(element) {
+ return (parseFloat($.curCSS(element[0], 'borderTopWidth', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'borderBottomWidth', true)) || 0);
+}
+
+
+function setMinHeight(element, height) {
+ height = (typeof height == 'number' ? height + 'px' : height);
+ element.each(function(i, _element) {
+ _element.style.cssText += ';min-height:' + height + ';_height:' + height;
+ // why can't we just use .css() ? i forget
+ });
+}
+
+
+
+/* Misc Utils
+-----------------------------------------------------------------------------*/
+
+
+//TODO: arraySlice
+//TODO: isFunction, grep ?
+
+
+function noop() { }
+
+
+function cmp(a, b) {
+ return a - b;
+}
+
+
+function arrayMax(a) {
+ return Math.max.apply(Math, a);
+}
+
+
+function zeroPad(n) {
+ return (n < 10 ? '0' : '') + n;
+}
+
+
+function smartProperty(obj, name) { // get a camel-cased/namespaced property of an object
+ if (obj[name] !== undefined) {
+ return obj[name];
+ }
+ var parts = name.split(/(?=[A-Z])/),
+ i=parts.length-1, res;
+ for (; i>=0; i--) {
+ res = obj[parts[i].toLowerCase()];
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ return obj[''];
+}
+
+
+function htmlEscape(s) {
+ return s.replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/'/g, '&#039;')
+ .replace(/"/g, '&quot;')
+ .replace(/\n/g, '<br />');
+}
+
+
+function cssKey(_element) {
+ return _element.id + '/' + _element.className + '/' + _element.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig, '');
+}
+
+
+function disableTextSelection(element) {
+ element
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+}
+
+
+/*
+function enableTextSelection(element) {
+ element
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+}
+*/
+
+
+function markFirstLast(e) {
+ e.children()
+ .removeClass('fc-first fc-last')
+ .filter(':first-child')
+ .addClass('fc-first')
+ .end()
+ .filter(':last-child')
+ .addClass('fc-last');
+}
+
+
+function setDayID(cell, date) {
+ cell.each(function(i, _cell) {
+ _cell.className = _cell.className.replace(/^fc-\w*/, 'fc-' + dayIDs[date.getDay()]);
+ // TODO: make a way that doesn't rely on order of classes
+ });
+}
+
+
+function getSkinCss(event, opt) {
+ var source = event.source || {};
+ var eventColor = event.color;
+ var sourceColor = source.color;
+ var optionColor = opt('eventColor');
+ var backgroundColor =
+ event.backgroundColor ||
+ eventColor ||
+ source.backgroundColor ||
+ sourceColor ||
+ opt('eventBackgroundColor') ||
+ optionColor;
+ var borderColor =
+ event.borderColor ||
+ eventColor ||
+ source.borderColor ||
+ sourceColor ||
+ opt('eventBorderColor') ||
+ optionColor;
+ var textColor =
+ event.textColor ||
+ source.textColor ||
+ opt('eventTextColor');
+ var statements = [];
+ if (backgroundColor) {
+ statements.push('background-color:' + backgroundColor);
+ }
+ if (borderColor) {
+ statements.push('border-color:' + borderColor);
+ }
+ if (textColor) {
+ statements.push('color:' + textColor);
+ }
+ return statements.join(';');
+}
+
+
+function applyAll(functions, thisObj, args) {
+ if ($.isFunction(functions)) {
+ functions = [ functions ];
+ }
+ if (functions) {
+ var i;
+ var ret;
+ for (i=0; i<functions.length; i++) {
+ ret = functions[i].apply(thisObj, args) || ret;
+ }
+ return ret;
+ }
+}
+
+
+function firstDefined() {
+ for (var i=0; i<arguments.length; i++) {
+ if (arguments[i] !== undefined) {
+ return arguments[i];
+ }
+ }
+}
+
+
+
+fcViews.month = MonthView;
+
+function MonthView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'month');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addMonths(date, delta);
+ date.setDate(1);
+ }
+ var start = cloneDate(date, true);
+ start.setDate(1);
+ var end = addMonths(cloneDate(start), 1);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var firstDay = opt('firstDay');
+ var nwe = opt('weekends') ? 0 : 1;
+ if (nwe) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ addDays(visStart, -((visStart.getDay() - Math.max(firstDay, nwe) + 7) % 7));
+ addDays(visEnd, (7 - visEnd.getDay() + Math.max(firstDay, nwe)) % 7);
+ var rowCnt = Math.round((visEnd - visStart) / (DAY_MS * 7));
+ if (opt('weekMode') == 'fixed') {
+ addDays(visEnd, (6 - rowCnt) * 7);
+ rowCnt = 6;
+ }
+ t.title = formatDate(start, opt('titleFormat'));
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderBasic(6, rowCnt, nwe ? 5 : 7, true);
+ }
+
+
+}
+
+fcViews.basicWeek = BasicWeekView;
+
+function BasicWeekView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'basicWeek');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDates = calendar.formatDates;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta * 7);
+ }
+ var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
+ var end = addDays(cloneDate(start), 7);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var weekends = opt('weekends');
+ if (!weekends) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ t.title = formatDates(
+ visStart,
+ addDays(cloneDate(visEnd), -1),
+ opt('titleFormat')
+ );
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderBasic(1, 1, weekends ? 7 : 5, false);
+ }
+
+
+}
+
+fcViews.basicDay = BasicDayView;
+
+//TODO: when calendar's date starts out on a weekend, shouldn't happen
+
+
+function BasicDayView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'basicDay');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta);
+ if (!opt('weekends')) {
+ skipWeekend(date, delta < 0 ? -1 : 1);
+ }
+ }
+ t.title = formatDate(date, opt('titleFormat'));
+ t.start = t.visStart = cloneDate(date, true);
+ t.end = t.visEnd = addDays(cloneDate(t.start), 1);
+ renderBasic(1, 1, 1, false);
+ }
+
+
+}
+
+setDefaults({
+ weekMode: 'fixed'
+});
+
+
+function BasicView(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.renderBasic = renderBasic;
+ t.setHeight = setHeight;
+ t.setWidth = setWidth;
+ t.renderDayOverlay = renderDayOverlay;
+ t.defaultSelectionEnd = defaultSelectionEnd;
+ t.renderSelection = renderSelection;
+ t.clearSelection = clearSelection;
+ t.reportDayClick = reportDayClick; // for selection (kinda hacky)
+ t.dragStart = dragStart;
+ t.dragStop = dragStop;
+ t.defaultEventEnd = defaultEventEnd;
+ t.getHoverListener = function() { return hoverListener };
+ t.colContentLeft = colContentLeft;
+ t.colContentRight = colContentRight;
+ t.dayOfWeekCol = dayOfWeekCol;
+ t.dateCell = dateCell;
+ t.cellDate = cellDate;
+ t.cellIsAllDay = function() { return true };
+ t.allDayRow = allDayRow;
+ t.allDayBounds = allDayBounds;
+ t.getRowCnt = function() { return rowCnt };
+ t.getColCnt = function() { return colCnt };
+ t.getColWidth = function() { return colWidth };
+ t.getDaySegmentContainer = function() { return daySegmentContainer };
+
+
+ // imports
+ View.call(t, element, calendar, viewName);
+ OverlayManager.call(t);
+ SelectionManager.call(t);
+ BasicEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var clearEvents = t.clearEvents;
+ var renderOverlay = t.renderOverlay;
+ var clearOverlays = t.clearOverlays;
+ var daySelectionMousedown = t.daySelectionMousedown;
+ var formatDate = calendar.formatDate;
+
+
+ // locals
+
+ var head;
+ var headCells;
+ var body;
+ var bodyRows;
+ var bodyCells;
+ var bodyFirstCells;
+ var bodyCellTopInners;
+ var daySegmentContainer;
+
+ var viewWidth;
+ var viewHeight;
+ var colWidth;
+
+ var rowCnt, colCnt;
+ var coordinateGrid;
+ var hoverListener;
+ var colContentPositions;
+
+ var rtl, dis, dit;
+ var firstDay;
+ var nwe;
+ var tm;
+ var colFormat;
+
+
+
+ /* Rendering
+ ------------------------------------------------------------*/
+
+
+ disableTextSelection(element.addClass('fc-grid'));
+
+
+ function renderBasic(maxr, r, c, showNumbers) {
+ rowCnt = r;
+ colCnt = c;
+ updateOptions();
+ var firstTime = !body;
+ if (firstTime) {
+ buildSkeleton(maxr, showNumbers);
+ }else{
+ clearEvents();
+ }
+ updateCells(firstTime);
+ }
+
+
+
+ function updateOptions() {
+ rtl = opt('isRTL');
+ if (rtl) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+ firstDay = opt('firstDay');
+ nwe = opt('weekends') ? 0 : 1;
+ tm = opt('theme') ? 'ui' : 'fc';
+ colFormat = opt('columnFormat');
+ }
+
+
+
+ function buildSkeleton(maxRowCnt, showNumbers) {
+ var s;
+ var headerClass = tm + "-widget-header";
+ var contentClass = tm + "-widget-content";
+ var i, j;
+ var table;
+
+ s =
+ "<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
+ "<thead>" +
+ "<tr>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<th class='fc- " + headerClass + "'/>"; // need fc- for setDayID
+ }
+ s +=
+ "</tr>" +
+ "</thead>" +
+ "<tbody>";
+ for (i=0; i<maxRowCnt; i++) {
+ s +=
+ "<tr class='fc-week" + i + "'>";
+ for (j=0; j<colCnt; j++) {
+ s +=
+ "<td class='fc- " + contentClass + " fc-day" + (i*colCnt+j) + "'>" + // need fc- for setDayID
+ "<div>" +
+ (showNumbers ?
+ "<div class='fc-day-number'/>" :
+ ''
+ ) +
+ "<div class='fc-day-content'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</div>" +
+ "</div>" +
+ "</td>";
+ }
+ s +=
+ "</tr>";
+ }
+ s +=
+ "</tbody>" +
+ "</table>";
+ table = $(s).appendTo(element);
+
+ head = table.find('thead');
+ headCells = head.find('th');
+ body = table.find('tbody');
+ bodyRows = body.find('tr');
+ bodyCells = body.find('td');
+ bodyFirstCells = bodyCells.filter(':first-child');
+ bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div');
+
+ markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's
+ markFirstLast(bodyRows); // marks first+last td's
+ bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells
+
+ dayBind(bodyCells);
+
+ daySegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(element);
+ }
+
+
+
+ function updateCells(firstTime) {
+ var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
+ var month = t.start.getMonth();
+ var today = clearTime(new Date());
+ var cell;
+ var date;
+ var row;
+
+ if (dowDirty) {
+ headCells.each(function(i, _cell) {
+ cell = $(_cell);
+ date = indexDate(i);
+ cell.html(formatDate(date, colFormat));
+ setDayID(cell, date);
+ });
+ }
+
+ bodyCells.each(function(i, _cell) {
+ cell = $(_cell);
+ date = indexDate(i);
+ if (date.getMonth() == month) {
+ cell.removeClass('fc-other-month');
+ }else{
+ cell.addClass('fc-other-month');
+ }
+ if (+date == +today) {
+ cell.addClass(tm + '-state-highlight fc-today');
+ }else{
+ cell.removeClass(tm + '-state-highlight fc-today');
+ }
+ cell.find('div.fc-day-number').text(date.getDate());
+ if (dowDirty) {
+ setDayID(cell, date);
+ }
+ });
+
+ bodyRows.each(function(i, _row) {
+ row = $(_row);
+ if (i < rowCnt) {
+ row.show();
+ if (i == rowCnt-1) {
+ row.addClass('fc-last');
+ }else{
+ row.removeClass('fc-last');
+ }
+ }else{
+ row.hide();
+ }
+ });
+ }
+
+
+
+ function setHeight(height) {
+ viewHeight = height;
+
+ var bodyHeight = viewHeight - head.height();
+ var rowHeight;
+ var rowHeightLast;
+ var cell;
+
+ if (opt('weekMode') == 'variable') {
+ rowHeight = rowHeightLast = Math.floor(bodyHeight / (rowCnt==1 ? 2 : 6));
+ }else{
+ rowHeight = Math.floor(bodyHeight / rowCnt);
+ rowHeightLast = bodyHeight - rowHeight * (rowCnt-1);
+ }
+
+ bodyFirstCells.each(function(i, _cell) {
+ if (i < rowCnt) {
+ cell = $(_cell);
+ setMinHeight(
+ cell.find('> div'),
+ (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
+ );
+ }
+ });
+
+ }
+
+
+ function setWidth(width) {
+ viewWidth = width;
+ colContentPositions.clear();
+ colWidth = Math.floor(viewWidth / colCnt);
+ setOuterWidth(headCells.slice(0, -1), colWidth);
+ }
+
+
+
+ /* Day clicking and binding
+ -----------------------------------------------------------*/
+
+
+ function dayBind(days) {
+ days.click(dayClick)
+ .mousedown(daySelectionMousedown);
+ }
+
+
+ function dayClick(ev) {
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
+ var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data
+ var date = indexDate(index);
+ trigger('dayClick', this, date, true, ev);
+ }
+ }
+
+
+
+ /* Semi-transparent Overlay Helpers
+ ------------------------------------------------------*/
+
+
+ function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
+ if (refreshCoordinateGrid) {
+ coordinateGrid.build();
+ }
+ var rowStart = cloneDate(t.visStart);
+ var rowEnd = addDays(cloneDate(rowStart), colCnt);
+ for (var i=0; i<rowCnt; i++) {
+ var stretchStart = new Date(Math.max(rowStart, overlayStart));
+ var stretchEnd = new Date(Math.min(rowEnd, overlayEnd));
+ if (stretchStart < stretchEnd) {
+ var colStart, colEnd;
+ if (rtl) {
+ colStart = dayDiff(stretchEnd, rowStart)*dis+dit+1;
+ colEnd = dayDiff(stretchStart, rowStart)*dis+dit+1;
+ }else{
+ colStart = dayDiff(stretchStart, rowStart);
+ colEnd = dayDiff(stretchEnd, rowStart);
+ }
+ dayBind(
+ renderCellOverlay(i, colStart, i, colEnd-1)
+ );
+ }
+ addDays(rowStart, 7);
+ addDays(rowEnd, 7);
+ }
+ }
+
+
+ function renderCellOverlay(row0, col0, row1, col1) { // row1,col1 is inclusive
+ var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
+ return renderOverlay(rect, element);
+ }
+
+
+
+ /* Selection
+ -----------------------------------------------------------------------*/
+
+
+ function defaultSelectionEnd(startDate, allDay) {
+ return cloneDate(startDate);
+ }
+
+
+ function renderSelection(startDate, endDate, allDay) {
+ renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true); // rebuild every time???
+ }
+
+
+ function clearSelection() {
+ clearOverlays();
+ }
+
+
+ function reportDayClick(date, allDay, ev) {
+ var cell = dateCell(date);
+ var _element = bodyCells[cell.row*colCnt + cell.col];
+ trigger('dayClick', _element, date, allDay, ev);
+ }
+
+
+
+ /* External Dragging
+ -----------------------------------------------------------------------*/
+
+
+ function dragStart(_dragElement, ev, ui) {
+ hoverListener.start(function(cell) {
+ clearOverlays();
+ if (cell) {
+ renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
+ }
+ }, ev);
+ }
+
+
+ function dragStop(_dragElement, ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ if (cell) {
+ var d = cellDate(cell);
+ trigger('drop', _dragElement, d, true, ev, ui);
+ }
+ }
+
+
+
+ /* Utilities
+ --------------------------------------------------------*/
+
+
+ function defaultEventEnd(event) {
+ return cloneDate(event.start);
+ }
+
+
+ coordinateGrid = new CoordinateGrid(function(rows, cols) {
+ var e, n, p;
+ headCells.each(function(i, _e) {
+ e = $(_e);
+ n = e.offset().left;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ cols[i] = p;
+ });
+ p[1] = n + e.outerWidth();
+ bodyRows.each(function(i, _e) {
+ if (i < rowCnt) {
+ e = $(_e);
+ n = e.offset().top;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ rows[i] = p;
+ }
+ });
+ p[1] = n + e.outerHeight();
+ });
+
+
+ hoverListener = new HoverListener(coordinateGrid);
+
+
+ colContentPositions = new HorizontalPositionCache(function(col) {
+ return bodyCellTopInners.eq(col);
+ });
+
+
+ function colContentLeft(col) {
+ return colContentPositions.left(col);
+ }
+
+
+ function colContentRight(col) {
+ return colContentPositions.right(col);
+ }
+
+
+
+
+ function dateCell(date) {
+ return {
+ row: Math.floor(dayDiff(date, t.visStart) / 7),
+ col: dayOfWeekCol(date.getDay())
+ };
+ }
+
+
+ function cellDate(cell) {
+ return _cellDate(cell.row, cell.col);
+ }
+
+
+ function _cellDate(row, col) {
+ return addDays(cloneDate(t.visStart), row*7 + col*dis+dit);
+ // what about weekends in middle of week?
+ }
+
+
+ function indexDate(index) {
+ return _cellDate(Math.floor(index/colCnt), index%colCnt);
+ }
+
+
+ function dayOfWeekCol(dayOfWeek) {
+ return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt) * dis + dit;
+ }
+
+
+
+
+ function allDayRow(i) {
+ return bodyRows.eq(i);
+ }
+
+
+ function allDayBounds(i) {
+ return {
+ left: 0,
+ right: viewWidth
+ };
+ }
+
+
+}
+
+function BasicEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderEvents = renderEvents;
+ t.compileDaySegs = compileSegs; // for DayEventRenderer
+ t.clearEvents = clearEvents;
+ t.bindDaySeg = bindDaySeg;
+
+
+ // imports
+ DayEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ //var setOverflowHidden = t.setOverflowHidden;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var reportEvents = t.reportEvents;
+ var reportEventClear = t.reportEventClear;
+ var eventElementHandlers = t.eventElementHandlers;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventDrop = t.eventDrop;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var getHoverListener = t.getHoverListener;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var getRowCnt = t.getRowCnt;
+ var getColCnt = t.getColCnt;
+ var renderDaySegs = t.renderDaySegs;
+ var resizableDayEvent = t.resizableDayEvent;
+
+
+
+ /* Rendering
+ --------------------------------------------------------------------*/
+
+
+ function renderEvents(events, modifiedEventId) {
+ reportEvents(events);
+ renderDaySegs(compileSegs(events), modifiedEventId);
+ }
+
+
+ function clearEvents() {
+ reportEventClear();
+ getDaySegmentContainer().empty();
+ }
+
+
+ function compileSegs(events) {
+ var rowCnt = getRowCnt(),
+ colCnt = getColCnt(),
+ d1 = cloneDate(t.visStart),
+ d2 = addDays(cloneDate(d1), colCnt),
+ visEventsEnds = $.map(events, exclEndDay),
+ i, row,
+ j, level,
+ k, seg,
+ segs=[];
+ for (i=0; i<rowCnt; i++) {
+ row = stackSegs(sliceSegs(events, visEventsEnds, d1, d2));
+ for (j=0; j<row.length; j++) {
+ level = row[j];
+ for (k=0; k<level.length; k++) {
+ seg = level[k];
+ seg.row = i;
+ seg.level = j; // not needed anymore
+ segs.push(seg);
+ }
+ }
+ addDays(d1, 7);
+ addDays(d2, 7);
+ }
+ return segs;
+ }
+
+
+ function bindDaySeg(event, eventElement, seg) {
+ if (isEventDraggable(event)) {
+ draggableDayEvent(event, eventElement);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableDayEvent(event, eventElement, seg);
+ }
+ eventElementHandlers(event, eventElement);
+ // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
+ }
+
+
+
+ /* Dragging
+ ----------------------------------------------------------------------------*/
+
+
+ function draggableDayEvent(event, eventElement) {
+ var hoverListener = getHoverListener();
+ var dayDelta;
+ eventElement.draggable({
+ zIndex: 9,
+ delay: 50,
+ opacity: opt('dragOpacity'),
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
+ clearOverlays();
+ if (cell) {
+ //setOverflowHidden(true);
+ dayDelta = rowDelta*7 + colDelta * (opt('isRTL') ? -1 : 1);
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ }else{
+ //setOverflowHidden(false);
+ dayDelta = 0;
+ }
+ }, ev, 'drag');
+ },
+ stop: function(ev, ui) {
+ hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (dayDelta) {
+ eventDrop(this, event, dayDelta, 0, event.allDay, ev, ui);
+ }else{
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ showEvents(event, eventElement);
+ }
+ //setOverflowHidden(false);
+ }
+ });
+ }
+
+
+}
+
+fcViews.agendaWeek = AgendaWeekView;
+
+function AgendaWeekView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ AgendaView.call(t, element, calendar, 'agendaWeek');
+ var opt = t.opt;
+ var renderAgenda = t.renderAgenda;
+ var formatDates = calendar.formatDates;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta * 7);
+ }
+ var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
+ var end = addDays(cloneDate(start), 7);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var weekends = opt('weekends');
+ if (!weekends) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ t.title = formatDates(
+ visStart,
+ addDays(cloneDate(visEnd), -1),
+ opt('titleFormat')
+ );
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderAgenda(weekends ? 7 : 5);
+ }
+
+
+}
+
+fcViews.agendaDay = AgendaDayView;
+
+function AgendaDayView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ AgendaView.call(t, element, calendar, 'agendaDay');
+ var opt = t.opt;
+ var renderAgenda = t.renderAgenda;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta);
+ if (!opt('weekends')) {
+ skipWeekend(date, delta < 0 ? -1 : 1);
+ }
+ }
+ var start = cloneDate(date, true);
+ var end = addDays(cloneDate(start), 1);
+ t.title = formatDate(date, opt('titleFormat'));
+ t.start = t.visStart = start;
+ t.end = t.visEnd = end;
+ renderAgenda(1);
+ }
+
+
+}
+
+setDefaults({
+ allDaySlot: true,
+ allDayText: 'all-day',
+ firstHour: 6,
+ slotMinutes: 30,
+ defaultEventMinutes: 120,
+ axisFormat: 'h(:mm)tt',
+ timeFormat: {
+ agenda: 'h:mm{ - h:mm}'
+ },
+ dragOpacity: {
+ agenda: .5
+ },
+ minTime: 0,
+ maxTime: 24
+});
+
+
+// TODO: make it work in quirks mode (event corners, all-day height)
+// TODO: test liquid width, especially in IE6
+
+
+function AgendaView(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.renderAgenda = renderAgenda;
+ t.setWidth = setWidth;
+ t.setHeight = setHeight;
+ t.beforeHide = beforeHide;
+ t.afterShow = afterShow;
+ t.defaultEventEnd = defaultEventEnd;
+ t.timePosition = timePosition;
+ t.dayOfWeekCol = dayOfWeekCol;
+ t.dateCell = dateCell;
+ t.cellDate = cellDate;
+ t.cellIsAllDay = cellIsAllDay;
+ t.allDayRow = getAllDayRow;
+ t.allDayBounds = allDayBounds;
+ t.getHoverListener = function() { return hoverListener };
+ t.colContentLeft = colContentLeft;
+ t.colContentRight = colContentRight;
+ t.getDaySegmentContainer = function() { return daySegmentContainer };
+ t.getSlotSegmentContainer = function() { return slotSegmentContainer };
+ t.getMinMinute = function() { return minMinute };
+ t.getMaxMinute = function() { return maxMinute };
+ t.getBodyContent = function() { return slotContent }; // !!??
+ t.getRowCnt = function() { return 1 };
+ t.getColCnt = function() { return colCnt };
+ t.getColWidth = function() { return colWidth };
+ t.getSlotHeight = function() { return slotHeight };
+ t.defaultSelectionEnd = defaultSelectionEnd;
+ t.renderDayOverlay = renderDayOverlay;
+ t.renderSelection = renderSelection;
+ t.clearSelection = clearSelection;
+ t.reportDayClick = reportDayClick; // selection mousedown hack
+ t.dragStart = dragStart;
+ t.dragStop = dragStop;
+
+
+ // imports
+ View.call(t, element, calendar, viewName);
+ OverlayManager.call(t);
+ SelectionManager.call(t);
+ AgendaEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var clearEvents = t.clearEvents;
+ var renderOverlay = t.renderOverlay;
+ var clearOverlays = t.clearOverlays;
+ var reportSelection = t.reportSelection;
+ var unselect = t.unselect;
+ var daySelectionMousedown = t.daySelectionMousedown;
+ var slotSegHtml = t.slotSegHtml;
+ var formatDate = calendar.formatDate;
+
+
+ // locals
+
+ var dayTable;
+ var dayHead;
+ var dayHeadCells;
+ var dayBody;
+ var dayBodyCells;
+ var dayBodyCellInners;
+ var dayBodyFirstCell;
+ var dayBodyFirstCellStretcher;
+ var slotLayer;
+ var daySegmentContainer;
+ var allDayTable;
+ var allDayRow;
+ var slotScroller;
+ var slotContent;
+ var slotSegmentContainer;
+ var slotTable;
+ var slotTableFirstInner;
+ var axisFirstCells;
+ var gutterCells;
+ var selectionHelper;
+
+ var viewWidth;
+ var viewHeight;
+ var axisWidth;
+ var colWidth;
+ var gutterWidth;
+ var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
+ var savedScrollTop;
+
+ var colCnt;
+ var slotCnt;
+ var coordinateGrid;
+ var hoverListener;
+ var colContentPositions;
+ var slotTopCache = {};
+
+ var tm;
+ var firstDay;
+ var nwe; // no weekends (int)
+ var rtl, dis, dit; // day index sign / translate
+ var minMinute, maxMinute;
+ var colFormat;
+
+
+
+ /* Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ disableTextSelection(element.addClass('fc-agenda'));
+
+
+ function renderAgenda(c) {
+ colCnt = c;
+ updateOptions();
+ if (!dayTable) {
+ buildSkeleton();
+ }else{
+ clearEvents();
+ }
+ updateCells();
+ }
+
+
+
+ function updateOptions() {
+ tm = opt('theme') ? 'ui' : 'fc';
+ nwe = opt('weekends') ? 0 : 1;
+ firstDay = opt('firstDay');
+ if (rtl = opt('isRTL')) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+ minMinute = parseTime(opt('minTime'));
+ maxMinute = parseTime(opt('maxTime'));
+ colFormat = opt('columnFormat');
+ }
+
+
+
+ function buildSkeleton() {
+ var headerClass = tm + "-widget-header";
+ var contentClass = tm + "-widget-content";
+ var s;
+ var i;
+ var d;
+ var maxd;
+ var minutes;
+ var slotNormal = opt('slotMinutes') % 15 == 0;
+
+ s =
+ "<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
+ "<thead>" +
+ "<tr>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<th class='fc- fc-col" + i + ' ' + headerClass + "'/>"; // fc- needed for setDayID
+ }
+ s +=
+ "<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
+ "</tr>" +
+ "</thead>" +
+ "<tbody>" +
+ "<tr>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<td class='fc- fc-col" + i + ' ' + contentClass + "'>" + // fc- needed for setDayID
+ "<div>" +
+ "<div class='fc-day-content'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</div>" +
+ "</div>" +
+ "</td>";
+ }
+ s +=
+ "<td class='fc-agenda-gutter " + contentClass + "'>&nbsp;</td>" +
+ "</tr>" +
+ "</tbody>" +
+ "</table>";
+ dayTable = $(s).appendTo(element);
+ dayHead = dayTable.find('thead');
+ dayHeadCells = dayHead.find('th').slice(1, -1);
+ dayBody = dayTable.find('tbody');
+ dayBodyCells = dayBody.find('td').slice(0, -1);
+ dayBodyCellInners = dayBodyCells.find('div.fc-day-content div');
+ dayBodyFirstCell = dayBodyCells.eq(0);
+ dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div');
+
+ markFirstLast(dayHead.add(dayHead.find('tr')));
+ markFirstLast(dayBody.add(dayBody.find('tr')));
+
+ axisFirstCells = dayHead.find('th:first');
+ gutterCells = dayTable.find('.fc-agenda-gutter');
+
+ slotLayer =
+ $("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
+ .appendTo(element);
+
+ if (opt('allDaySlot')) {
+
+ daySegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(slotLayer);
+
+ s =
+ "<table style='width:100%' class='fc-agenda-allday' cellspacing='0'>" +
+ "<tr>" +
+ "<th class='" + headerClass + " fc-agenda-axis'>" + opt('allDayText') + "</th>" +
+ "<td>" +
+ "<div class='fc-day-content'><div style='position:relative'/></div>" +
+ "</td>" +
+ "<th class='" + headerClass + " fc-agenda-gutter'>&nbsp;</th>" +
+ "</tr>" +
+ "</table>";
+ allDayTable = $(s).appendTo(slotLayer);
+ allDayRow = allDayTable.find('tr');
+
+ dayBind(allDayRow.find('td'));
+
+ axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
+ gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
+
+ slotLayer.append(
+ "<div class='fc-agenda-divider " + headerClass + "'>" +
+ "<div class='fc-agenda-divider-inner'/>" +
+ "</div>"
+ );
+
+ }else{
+
+ daySegmentContainer = $([]); // in jQuery 1.4, we can just do $()
+
+ }
+
+ slotScroller =
+ $("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
+ .appendTo(slotLayer);
+
+ slotContent =
+ $("<div style='position:relative;width:100%;overflow:hidden'/>")
+ .appendTo(slotScroller);
+
+ slotSegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(slotContent);
+
+ s =
+ "<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
+ "<tbody>";
+ d = zeroDate();
+ maxd = addMinutes(cloneDate(d), maxMinute);
+ addMinutes(d, minMinute);
+ slotCnt = 0;
+ for (i=0; d < maxd; i++) {
+ minutes = d.getMinutes();
+ s +=
+ "<tr class='fc-slot" + i + ' ' + (!minutes ? '' : 'fc-minor') + "'>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>" +
+ ((!slotNormal || !minutes) ? formatDate(d, opt('axisFormat')) : '&nbsp;') +
+ "</th>" +
+ "<td class='" + contentClass + "'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</td>" +
+ "</tr>";
+ addMinutes(d, opt('slotMinutes'));
+ slotCnt++;
+ }
+ s +=
+ "</tbody>" +
+ "</table>";
+ slotTable = $(s).appendTo(slotContent);
+ slotTableFirstInner = slotTable.find('div:first');
+
+ slotBind(slotTable.find('td'));
+
+ axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
+ }
+
+
+
+ function updateCells() {
+ var i;
+ var headCell;
+ var bodyCell;
+ var date;
+ var today = clearTime(new Date());
+ for (i=0; i<colCnt; i++) {
+ date = colDate(i);
+ headCell = dayHeadCells.eq(i);
+ headCell.html(formatDate(date, colFormat));
+ bodyCell = dayBodyCells.eq(i);
+ if (+date == +today) {
+ bodyCell.addClass(tm + '-state-highlight fc-today');
+ }else{
+ bodyCell.removeClass(tm + '-state-highlight fc-today');
+ }
+ setDayID(headCell.add(bodyCell), date);
+ }
+ }
+
+
+
+ function setHeight(height, dateChanged) {
+ if (height === undefined) {
+ height = viewHeight;
+ }
+ viewHeight = height;
+ slotTopCache = {};
+
+ var headHeight = dayBody.position().top;
+ var allDayHeight = slotScroller.position().top; // including divider
+ var bodyHeight = Math.min( // total body height, including borders
+ height - headHeight, // when scrollbars
+ slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border
+ );
+
+ dayBodyFirstCellStretcher
+ .height(bodyHeight - vsides(dayBodyFirstCell));
+
+ slotLayer.css('top', headHeight);
+
+ slotScroller.height(bodyHeight - allDayHeight - 1);
+
+ slotHeight = slotTableFirstInner.height() + 1; // +1 for border
+
+ if (dateChanged) {
+ resetScroll();
+ }
+ }
+
+
+
+ function setWidth(width) {
+ viewWidth = width;
+ colContentPositions.clear();
+
+ axisWidth = 0;
+ setOuterWidth(
+ axisFirstCells
+ .width('')
+ .each(function(i, _cell) {
+ axisWidth = Math.max(axisWidth, $(_cell).outerWidth());
+ }),
+ axisWidth
+ );
+
+ var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
+ //slotTable.width(slotTableWidth);
+
+ gutterWidth = slotScroller.width() - slotTableWidth;
+ if (gutterWidth) {
+ setOuterWidth(gutterCells, gutterWidth);
+ gutterCells
+ .show()
+ .prev()
+ .removeClass('fc-last');
+ }else{
+ gutterCells
+ .hide()
+ .prev()
+ .addClass('fc-last');
+ }
+
+ colWidth = Math.floor((slotTableWidth - axisWidth) / colCnt);
+ setOuterWidth(dayHeadCells.slice(0, -1), colWidth);
+ }
+
+
+
+ function resetScroll() {
+ var d0 = zeroDate();
+ var scrollDate = cloneDate(d0);
+ scrollDate.setHours(opt('firstHour'));
+ var top = timePosition(d0, scrollDate) + 1; // +1 for the border
+ function scroll() {
+ slotScroller.scrollTop(top);
+ }
+ scroll();
+ setTimeout(scroll, 0); // overrides any previous scroll state made by the browser
+ }
+
+
+ function beforeHide() {
+ savedScrollTop = slotScroller.scrollTop();
+ }
+
+
+ function afterShow() {
+ slotScroller.scrollTop(savedScrollTop);
+ }
+
+
+
+ /* Slot/Day clicking and binding
+ -----------------------------------------------------------------------*/
+
+
+ function dayBind(cells) {
+ cells.click(slotClick)
+ .mousedown(daySelectionMousedown);
+ }
+
+
+ function slotBind(cells) {
+ cells.click(slotClick)
+ .mousedown(slotSelectionMousedown);
+ }
+
+
+ function slotClick(ev) {
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
+ var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
+ var date = colDate(col);
+ var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
+ if (rowMatch) {
+ var mins = parseInt(rowMatch[1]) * opt('slotMinutes');
+ var hours = Math.floor(mins/60);
+ date.setHours(hours);
+ date.setMinutes(mins%60 + minMinute);
+ trigger('dayClick', dayBodyCells[col], date, false, ev);
+ }else{
+ trigger('dayClick', dayBodyCells[col], date, true, ev);
+ }
+ }
+ }
+
+
+
+ /* Semi-transparent Overlay Helpers
+ -----------------------------------------------------*/
+
+
+ function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive
+ if (refreshCoordinateGrid) {
+ coordinateGrid.build();
+ }
+ var visStart = cloneDate(t.visStart);
+ var startCol, endCol;
+ if (rtl) {
+ startCol = dayDiff(endDate, visStart)*dis+dit+1;
+ endCol = dayDiff(startDate, visStart)*dis+dit+1;
+ }else{
+ startCol = dayDiff(startDate, visStart);
+ endCol = dayDiff(endDate, visStart);
+ }
+ startCol = Math.max(0, startCol);
+ endCol = Math.min(colCnt, endCol);
+ if (startCol < endCol) {
+ dayBind(
+ renderCellOverlay(0, startCol, 0, endCol-1)
+ );
+ }
+ }
+
+
+ function renderCellOverlay(row0, col0, row1, col1) { // only for all-day?
+ var rect = coordinateGrid.rect(row0, col0, row1, col1, slotLayer);
+ return renderOverlay(rect, slotLayer);
+ }
+
+
+ function renderSlotOverlay(overlayStart, overlayEnd) {
+ var dayStart = cloneDate(t.visStart);
+ var dayEnd = addDays(cloneDate(dayStart), 1);
+ for (var i=0; i<colCnt; i++) {
+ var stretchStart = new Date(Math.max(dayStart, overlayStart));
+ var stretchEnd = new Date(Math.min(dayEnd, overlayEnd));
+ if (stretchStart < stretchEnd) {
+ var col = i*dis+dit;
+ var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only use it for horizontal coords
+ var top = timePosition(dayStart, stretchStart);
+ var bottom = timePosition(dayStart, stretchEnd);
+ rect.top = top;
+ rect.height = bottom - top;
+ slotBind(
+ renderOverlay(rect, slotContent)
+ );
+ }
+ addDays(dayStart, 1);
+ addDays(dayEnd, 1);
+ }
+ }
+
+
+
+ /* Coordinate Utilities
+ -----------------------------------------------------------------------------*/
+
+
+ coordinateGrid = new CoordinateGrid(function(rows, cols) {
+ var e, n, p;
+ dayHeadCells.each(function(i, _e) {
+ e = $(_e);
+ n = e.offset().left;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ cols[i] = p;
+ });
+ p[1] = n + e.outerWidth();
+ if (opt('allDaySlot')) {
+ e = allDayRow;
+ n = e.offset().top;
+ rows[0] = [n, n+e.outerHeight()];
+ }
+ var slotTableTop = slotContent.offset().top;
+ var slotScrollerTop = slotScroller.offset().top;
+ var slotScrollerBottom = slotScrollerTop + slotScroller.outerHeight();
+ function constrain(n) {
+ return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
+ }
+ for (var i=0; i<slotCnt; i++) {
+ rows.push([
+ constrain(slotTableTop + slotHeight*i),
+ constrain(slotTableTop + slotHeight*(i+1))
+ ]);
+ }
+ });
+
+
+ hoverListener = new HoverListener(coordinateGrid);
+
+
+ colContentPositions = new HorizontalPositionCache(function(col) {
+ return dayBodyCellInners.eq(col);
+ });
+
+
+ function colContentLeft(col) {
+ return colContentPositions.left(col);
+ }
+
+
+ function colContentRight(col) {
+ return colContentPositions.right(col);
+ }
+
+
+
+
+ function dateCell(date) { // "cell" terminology is now confusing
+ return {
+ row: Math.floor(dayDiff(date, t.visStart) / 7),
+ col: dayOfWeekCol(date.getDay())
+ };
+ }
+
+
+ function cellDate(cell) {
+ var d = colDate(cell.col);
+ var slotIndex = cell.row;
+ if (opt('allDaySlot')) {
+ slotIndex--;
+ }
+ if (slotIndex >= 0) {
+ addMinutes(d, minMinute + slotIndex * opt('slotMinutes'));
+ }
+ return d;
+ }
+
+
+ function colDate(col) { // returns dates with 00:00:00
+ return addDays(cloneDate(t.visStart), col*dis+dit);
+ }
+
+
+ function cellIsAllDay(cell) {
+ return opt('allDaySlot') && !cell.row;
+ }
+
+
+ function dayOfWeekCol(dayOfWeek) {
+ return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit;
+ }
+
+
+
+
+ // get the Y coordinate of the given time on the given day (both Date objects)
+ function timePosition(day, time) { // both date objects. day holds 00:00 of current day
+ day = cloneDate(day, true);
+ if (time < addMinutes(cloneDate(day), minMinute)) {
+ return 0;
+ }
+ if (time >= addMinutes(cloneDate(day), maxMinute)) {
+ return slotTable.height();
+ }
+ var slotMinutes = opt('slotMinutes'),
+ minutes = time.getHours()*60 + time.getMinutes() - minMinute,
+ slotI = Math.floor(minutes / slotMinutes),
+ slotTop = slotTopCache[slotI];
+ if (slotTop === undefined) {
+ slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization???
+ }
+ return Math.max(0, Math.round(
+ slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
+ ));
+ }
+
+
+ function allDayBounds() {
+ return {
+ left: axisWidth,
+ right: viewWidth - gutterWidth
+ }
+ }
+
+
+ function getAllDayRow(index) {
+ return allDayRow;
+ }
+
+
+ function defaultEventEnd(event) {
+ var start = cloneDate(event.start);
+ if (event.allDay) {
+ return start;
+ }
+ return addMinutes(start, opt('defaultEventMinutes'));
+ }
+
+
+
+ /* Selection
+ ---------------------------------------------------------------------------------*/
+
+
+ function defaultSelectionEnd(startDate, allDay) {
+ if (allDay) {
+ return cloneDate(startDate);
+ }
+ return addMinutes(cloneDate(startDate), opt('slotMinutes'));
+ }
+
+
+ function renderSelection(startDate, endDate, allDay) { // only for all-day
+ if (allDay) {
+ if (opt('allDaySlot')) {
+ renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true);
+ }
+ }else{
+ renderSlotSelection(startDate, endDate);
+ }
+ }
+
+
+ function renderSlotSelection(startDate, endDate) {
+ var helperOption = opt('selectHelper');
+ coordinateGrid.build();
+ if (helperOption) {
+ var col = dayDiff(startDate, t.visStart) * dis + dit;
+ if (col >= 0 && col < colCnt) { // only works when times are on same day
+ var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords
+ var top = timePosition(startDate, startDate);
+ var bottom = timePosition(startDate, endDate);
+ if (bottom > top) { // protect against selections that are entirely before or after visible range
+ rect.top = top;
+ rect.height = bottom - top;
+ rect.left += 2;
+ rect.width -= 5;
+ if ($.isFunction(helperOption)) {
+ var helperRes = helperOption(startDate, endDate);
+ if (helperRes) {
+ rect.position = 'absolute';
+ rect.zIndex = 8;
+ selectionHelper = $(helperRes)
+ .css(rect)
+ .appendTo(slotContent);
+ }
+ }else{
+ rect.isStart = true; // conside rect a "seg" now
+ rect.isEnd = true; //
+ selectionHelper = $(slotSegHtml(
+ {
+ title: '',
+ start: startDate,
+ end: endDate,
+ className: ['fc-select-helper'],
+ editable: false
+ },
+ rect
+ ));
+ selectionHelper.css('opacity', opt('dragOpacity'));
+ }
+ if (selectionHelper) {
+ slotBind(selectionHelper);
+ slotContent.append(selectionHelper);
+ setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended
+ setOuterHeight(selectionHelper, rect.height, true);
+ }
+ }
+ }
+ }else{
+ renderSlotOverlay(startDate, endDate);
+ }
+ }
+
+
+ function clearSelection() {
+ clearOverlays();
+ if (selectionHelper) {
+ selectionHelper.remove();
+ selectionHelper = null;
+ }
+ }
+
+
+ function slotSelectionMousedown(ev) {
+ if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button
+ unselect(ev);
+ var dates;
+ hoverListener.start(function(cell, origCell) {
+ clearSelection();
+ if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) {
+ var d1 = cellDate(origCell);
+ var d2 = cellDate(cell);
+ dates = [
+ d1,
+ addMinutes(cloneDate(d1), opt('slotMinutes')),
+ d2,
+ addMinutes(cloneDate(d2), opt('slotMinutes'))
+ ].sort(cmp);
+ renderSlotSelection(dates[0], dates[3]);
+ }else{
+ dates = null;
+ }
+ }, ev);
+ $(document).one('mouseup', function(ev) {
+ hoverListener.stop();
+ if (dates) {
+ if (+dates[0] == +dates[1]) {
+ reportDayClick(dates[0], false, ev);
+ }
+ reportSelection(dates[0], dates[3], false, ev);
+ }
+ });
+ }
+ }
+
+
+ function reportDayClick(date, allDay, ev) {
+ trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev);
+ }
+
+
+
+ /* External Dragging
+ --------------------------------------------------------------------------------*/
+
+
+ function dragStart(_dragElement, ev, ui) {
+ hoverListener.start(function(cell) {
+ clearOverlays();
+ if (cell) {
+ if (cellIsAllDay(cell)) {
+ renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
+ }else{
+ var d1 = cellDate(cell);
+ var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes'));
+ renderSlotOverlay(d1, d2);
+ }
+ }
+ }, ev);
+ }
+
+
+ function dragStop(_dragElement, ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ if (cell) {
+ trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui);
+ }
+ }
+
+
+}
+
+function AgendaEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderEvents = renderEvents;
+ t.compileDaySegs = compileDaySegs; // for DayEventRenderer
+ t.clearEvents = clearEvents;
+ t.slotSegHtml = slotSegHtml;
+ t.bindDaySeg = bindDaySeg;
+
+
+ // imports
+ DayEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ //var setOverflowHidden = t.setOverflowHidden;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var eventEnd = t.eventEnd;
+ var reportEvents = t.reportEvents;
+ var reportEventClear = t.reportEventClear;
+ var eventElementHandlers = t.eventElementHandlers;
+ var setHeight = t.setHeight;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var getSlotSegmentContainer = t.getSlotSegmentContainer;
+ var getHoverListener = t.getHoverListener;
+ var getMaxMinute = t.getMaxMinute;
+ var getMinMinute = t.getMinMinute;
+ var timePosition = t.timePosition;
+ var colContentLeft = t.colContentLeft;
+ var colContentRight = t.colContentRight;
+ var renderDaySegs = t.renderDaySegs;
+ var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture
+ var getColCnt = t.getColCnt;
+ var getColWidth = t.getColWidth;
+ var getSlotHeight = t.getSlotHeight;
+ var getBodyContent = t.getBodyContent;
+ var reportEventElement = t.reportEventElement;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventDrop = t.eventDrop;
+ var eventResize = t.eventResize;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var calendar = t.calendar;
+ var formatDate = calendar.formatDate;
+ var formatDates = calendar.formatDates;
+
+
+
+ /* Rendering
+ ----------------------------------------------------------------------------*/
+
+
+ function renderEvents(events, modifiedEventId) {
+ reportEvents(events);
+ var i, len=events.length,
+ dayEvents=[],
+ slotEvents=[];
+ for (i=0; i<len; i++) {
+ if (events[i].allDay) {
+ dayEvents.push(events[i]);
+ }else{
+ slotEvents.push(events[i]);
+ }
+ }
+ if (opt('allDaySlot')) {
+ renderDaySegs(compileDaySegs(dayEvents), modifiedEventId);
+ setHeight(); // no params means set to viewHeight
+ }
+ renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
+ }
+
+
+ function clearEvents() {
+ reportEventClear();
+ getDaySegmentContainer().empty();
+ getSlotSegmentContainer().empty();
+ }
+
+
+ function compileDaySegs(events) {
+ var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)),
+ i, levelCnt=levels.length, level,
+ j, seg,
+ segs=[];
+ for (i=0; i<levelCnt; i++) {
+ level = levels[i];
+ for (j=0; j<level.length; j++) {
+ seg = level[j];
+ seg.row = 0;
+ seg.level = i; // not needed anymore
+ segs.push(seg);
+ }
+ }
+ return segs;
+ }
+
+
+ function compileSlotSegs(events) {
+ var colCnt = getColCnt(),
+ minMinute = getMinMinute(),
+ maxMinute = getMaxMinute(),
+ d = addMinutes(cloneDate(t.visStart), minMinute),
+ visEventEnds = $.map(events, slotEventEnd),
+ i, col,
+ j, level,
+ k, seg,
+ segs=[];
+ for (i=0; i<colCnt; i++) {
+ col = stackSegs(sliceSegs(events, visEventEnds, d, addMinutes(cloneDate(d), maxMinute-minMinute)));
+ countForwardSegs(col);
+ for (j=0; j<col.length; j++) {
+ level = col[j];
+ for (k=0; k<level.length; k++) {
+ seg = level[k];
+ seg.col = i;
+ seg.level = j;
+ segs.push(seg);
+ }
+ }
+ addDays(d, 1, true);
+ }
+ return segs;
+ }
+
+
+ function slotEventEnd(event) {
+ if (event.end) {
+ return cloneDate(event.end);
+ }else{
+ return addMinutes(cloneDate(event.start), opt('defaultEventMinutes'));
+ }
+ }
+
+
+ // renders events in the 'time slots' at the bottom
+
+ function renderSlotSegs(segs, modifiedEventId) {
+
+ var i, segCnt=segs.length, seg,
+ event,
+ classes,
+ top, bottom,
+ colI, levelI, forward,
+ leftmost,
+ availWidth,
+ outerWidth,
+ left,
+ html='',
+ eventElements,
+ eventElement,
+ triggerRes,
+ vsideCache={},
+ hsideCache={},
+ key, val,
+ contentElement,
+ height,
+ slotSegmentContainer = getSlotSegmentContainer(),
+ rtl, dis, dit,
+ colCnt = getColCnt();
+
+ if (rtl = opt('isRTL')) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+
+ // calculate position/dimensions, create html
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ top = timePosition(seg.start, seg.start);
+ bottom = timePosition(seg.start, seg.end);
+ colI = seg.col;
+ levelI = seg.level;
+ forward = seg.forward || 0;
+ leftmost = colContentLeft(colI*dis + dit);
+ availWidth = colContentRight(colI*dis + dit) - leftmost;
+ availWidth = Math.min(availWidth-6, availWidth*.95); // TODO: move this to CSS
+ if (levelI) {
+ // indented and thin
+ outerWidth = availWidth / (levelI + forward + 1);
+ }else{
+ if (forward) {
+ // moderately wide, aligned left still
+ outerWidth = ((availWidth / (forward + 1)) - (12/2)) * 2; // 12 is the predicted width of resizer =
+ }else{
+ // can be entire width, aligned left
+ outerWidth = availWidth;
+ }
+ }
+ left = leftmost + // leftmost possible
+ (availWidth / (levelI + forward + 1) * levelI) // indentation
+ * dis + (rtl ? availWidth - outerWidth : 0); // rtl
+ seg.top = top;
+ seg.left = left;
+ seg.outerWidth = outerWidth;
+ seg.outerHeight = bottom - top;
+ html += slotSegHtml(event, seg);
+ }
+ slotSegmentContainer[0].innerHTML = html; // faster than html()
+ eventElements = slotSegmentContainer.children();
+
+ // retrieve elements, run through eventRender callback, bind event handlers
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ eventElement = $(eventElements[i]); // faster than eq()
+ triggerRes = trigger('eventRender', event, event, eventElement);
+ if (triggerRes === false) {
+ eventElement.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ eventElement.remove();
+ eventElement = $(triggerRes)
+ .css({
+ position: 'absolute',
+ top: seg.top,
+ left: seg.left
+ })
+ .appendTo(slotSegmentContainer);
+ }
+ seg.element = eventElement;
+ if (event._id === modifiedEventId) {
+ bindSlotSeg(event, eventElement, seg);
+ }else{
+ eventElement[0]._fci = i; // for lazySegBind
+ }
+ reportEventElement(event, eventElement);
+ }
+ }
+
+ lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
+
+ // record event sides and title positions
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ if (eventElement = seg.element) {
+ val = vsideCache[key = seg.key = cssKey(eventElement[0])];
+ seg.vsides = val === undefined ? (vsideCache[key] = vsides(eventElement, true)) : val;
+ val = hsideCache[key];
+ seg.hsides = val === undefined ? (hsideCache[key] = hsides(eventElement, true)) : val;
+ contentElement = eventElement.find('div.fc-event-content');
+ if (contentElement.length) {
+ seg.contentTop = contentElement[0].offsetTop;
+ }
+ }
+ }
+
+ // set all positions/dimensions at once
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ if (eventElement = seg.element) {
+ eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
+ height = Math.max(0, seg.outerHeight - seg.vsides);
+ eventElement[0].style.height = height + 'px';
+ event = seg.event;
+ if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
+ // not enough room for title, put it in the time header
+ eventElement.find('div.fc-event-time')
+ .text(formatDate(event.start, opt('timeFormat')) + ' - ' + event.title);
+ eventElement.find('div.fc-event-title')
+ .remove();
+ }
+ trigger('eventAfterRender', event, event, eventElement);
+ }
+ }
+
+ }
+
+
+ function slotSegHtml(event, seg) {
+ var html = "<";
+ var url = event.url;
+ var skinCss = getSkinCss(event, opt);
+ var skinCssAttr = (skinCss ? " style='" + skinCss + "'" : '');
+ var classes = ['fc-event', 'fc-event-skin', 'fc-event-vert'];
+ if (isEventDraggable(event)) {
+ classes.push('fc-event-draggable');
+ }
+ if (seg.isStart) {
+ classes.push('fc-corner-top');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-bottom');
+ }
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ if (url) {
+ html += "a href='" + htmlEscape(event.url) + "'";
+ }else{
+ html += "div";
+ }
+ html +=
+ " class='" + classes.join(' ') + "'" +
+ " style='position:absolute;z-index:8;top:" + seg.top + "px;left:" + seg.left + "px;" + skinCss + "'" +
+ ">" +
+ "<div class='fc-event-inner fc-event-skin'" + skinCssAttr + ">" +
+ "<div class='fc-event-head fc-event-skin'" + skinCssAttr + ">" +
+ "<div class='fc-event-time'>" +
+ htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
+ "</div>" +
+ "</div>" +
+ "<div class='fc-event-content'>" +
+ "<div class='fc-event-title'>" +
+ htmlEscape(event.title) +
+ "</div>" +
+ "</div>" +
+ "<div class='fc-event-bg'></div>" +
+ "</div>"; // close inner
+ if (seg.isEnd && isEventResizable(event)) {
+ html +=
+ "<div class='ui-resizable-handle ui-resizable-s'>=</div>";
+ }
+ html +=
+ "</" + (url ? "a" : "div") + ">";
+ return html;
+ }
+
+
+ function bindDaySeg(event, eventElement, seg) {
+ if (isEventDraggable(event)) {
+ draggableDayEvent(event, eventElement, seg.isStart);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableDayEvent(event, eventElement, seg);
+ }
+ eventElementHandlers(event, eventElement);
+ // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
+ }
+
+
+ function bindSlotSeg(event, eventElement, seg) {
+ var timeElement = eventElement.find('div.fc-event-time');
+ if (isEventDraggable(event)) {
+ draggableSlotEvent(event, eventElement, timeElement);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableSlotEvent(event, eventElement, timeElement);
+ }
+ eventElementHandlers(event, eventElement);
+ }
+
+
+
+ /* Dragging
+ -----------------------------------------------------------------------------------*/
+
+
+ // when event starts out FULL-DAY
+
+ function draggableDayEvent(event, eventElement, isStart) {
+ var origWidth;
+ var revert;
+ var allDay=true;
+ var dayDelta;
+ var dis = opt('isRTL') ? -1 : 1;
+ var hoverListener = getHoverListener();
+ var colWidth = getColWidth();
+ var slotHeight = getSlotHeight();
+ var minMinute = getMinMinute();
+ eventElement.draggable({
+ zIndex: 9,
+ opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ origWidth = eventElement.width();
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ clearOverlays();
+ if (cell) {
+ //setOverflowHidden(true);
+ revert = false;
+ dayDelta = colDelta * dis;
+ if (!cell.row) {
+ // on full-days
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ resetElement();
+ }else{
+ // mouse is over bottom slots
+ if (isStart) {
+ if (allDay) {
+ // convert event to temporary slot-event
+ eventElement.width(colWidth - 10); // don't use entire width
+ setOuterHeight(
+ eventElement,
+ slotHeight * Math.round(
+ (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes'))
+ / opt('slotMinutes')
+ )
+ );
+ eventElement.draggable('option', 'grid', [colWidth, 1]);
+ allDay = false;
+ }
+ }else{
+ revert = true;
+ }
+ }
+ revert = revert || (allDay && !dayDelta);
+ }else{
+ resetElement();
+ //setOverflowHidden(false);
+ revert = true;
+ }
+ eventElement.draggable('option', 'revert', revert);
+ }, ev, 'drag');
+ },
+ stop: function(ev, ui) {
+ hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (revert) {
+ // hasn't moved or is out of bounds (draggable has already reverted)
+ resetElement();
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ showEvents(event, eventElement);
+ }else{
+ // changed!
+ var minuteDelta = 0;
+ if (!allDay) {
+ minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / slotHeight)
+ * opt('slotMinutes')
+ + minMinute
+ - (event.start.getHours() * 60 + event.start.getMinutes());
+ }
+ eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui);
+ }
+ //setOverflowHidden(false);
+ }
+ });
+ function resetElement() {
+ if (!allDay) {
+ eventElement
+ .width(origWidth)
+ .height('')
+ .draggable('option', 'grid', null);
+ allDay = true;
+ }
+ }
+ }
+
+
+ // when event starts out IN TIMESLOTS
+
+ function draggableSlotEvent(event, eventElement, timeElement) {
+ var origPosition;
+ var allDay=false;
+ var dayDelta;
+ var minuteDelta;
+ var prevMinuteDelta;
+ var dis = opt('isRTL') ? -1 : 1;
+ var hoverListener = getHoverListener();
+ var colCnt = getColCnt();
+ var colWidth = getColWidth();
+ var slotHeight = getSlotHeight();
+ eventElement.draggable({
+ zIndex: 9,
+ scroll: false,
+ grid: [colWidth, slotHeight],
+ axis: colCnt==1 ? 'y' : false,
+ opacity: opt('dragOpacity'),
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ origPosition = eventElement.position();
+ minuteDelta = prevMinuteDelta = 0;
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ eventElement.draggable('option', 'revert', !cell);
+ clearOverlays();
+ if (cell) {
+ dayDelta = colDelta * dis;
+ if (opt('allDaySlot') && !cell.row) {
+ // over full days
+ if (!allDay) {
+ // convert to temporary all-day event
+ allDay = true;
+ timeElement.hide();
+ eventElement.draggable('option', 'grid', null);
+ }
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ }else{
+ // on slots
+ resetElement();
+ }
+ }
+ }, ev, 'drag');
+ },
+ drag: function(ev, ui) {
+ minuteDelta = Math.round((ui.position.top - origPosition.top) / slotHeight) * opt('slotMinutes');
+ if (minuteDelta != prevMinuteDelta) {
+ if (!allDay) {
+ updateTimeText(minuteDelta);
+ }
+ prevMinuteDelta = minuteDelta;
+ }
+ },
+ stop: function(ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (cell && (dayDelta || minuteDelta || allDay)) {
+ // changed!
+ eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui);
+ }else{
+ // either no change or out-of-bounds (draggable has already reverted)
+ resetElement();
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position
+ updateTimeText(0);
+ showEvents(event, eventElement);
+ }
+ }
+ });
+ function updateTimeText(minuteDelta) {
+ var newStart = addMinutes(cloneDate(event.start), minuteDelta);
+ var newEnd;
+ if (event.end) {
+ newEnd = addMinutes(cloneDate(event.end), minuteDelta);
+ }
+ timeElement.text(formatDates(newStart, newEnd, opt('timeFormat')));
+ }
+ function resetElement() {
+ // convert back to original slot-event
+ if (allDay) {
+ timeElement.css('display', ''); // show() was causing display=inline
+ eventElement.draggable('option', 'grid', [colWidth, slotHeight]);
+ allDay = false;
+ }
+ }
+ }
+
+
+
+ /* Resizing
+ --------------------------------------------------------------------------------------*/
+
+
+ function resizableSlotEvent(event, eventElement, timeElement) {
+ var slotDelta, prevSlotDelta;
+ var slotHeight = getSlotHeight();
+ eventElement.resizable({
+ handles: {
+ s: 'div.ui-resizable-s'
+ },
+ grid: slotHeight,
+ start: function(ev, ui) {
+ slotDelta = prevSlotDelta = 0;
+ hideEvents(event, eventElement);
+ eventElement.css('z-index', 9);
+ trigger('eventResizeStart', this, event, ev, ui);
+ },
+ resize: function(ev, ui) {
+ // don't rely on ui.size.height, doesn't take grid into account
+ slotDelta = Math.round((Math.max(slotHeight, eventElement.height()) - ui.originalSize.height) / slotHeight);
+ if (slotDelta != prevSlotDelta) {
+ timeElement.text(
+ formatDates(
+ event.start,
+ (!slotDelta && !event.end) ? null : // no change, so don't display time range
+ addMinutes(eventEnd(event), opt('slotMinutes')*slotDelta),
+ opt('timeFormat')
+ )
+ );
+ prevSlotDelta = slotDelta;
+ }
+ },
+ stop: function(ev, ui) {
+ trigger('eventResizeStop', this, event, ev, ui);
+ if (slotDelta) {
+ eventResize(this, event, 0, opt('slotMinutes')*slotDelta, ev, ui);
+ }else{
+ eventElement.css('z-index', 8);
+ showEvents(event, eventElement);
+ // BUG: if event was really short, need to put title back in span
+ }
+ }
+ });
+ }
+
+
+}
+
+
+function countForwardSegs(levels) {
+ var i, j, k, level, segForward, segBack;
+ for (i=levels.length-1; i>0; i--) {
+ level = levels[i];
+ for (j=0; j<level.length; j++) {
+ segForward = level[j];
+ for (k=0; k<levels[i-1].length; k++) {
+ segBack = levels[i-1][k];
+ if (segsCollide(segForward, segBack)) {
+ segBack.forward = Math.max(segBack.forward||0, (segForward.forward||0)+1);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+function View(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.element = element;
+ t.calendar = calendar;
+ t.name = viewName;
+ t.opt = opt;
+ t.trigger = trigger;
+ //t.setOverflowHidden = setOverflowHidden;
+ t.isEventDraggable = isEventDraggable;
+ t.isEventResizable = isEventResizable;
+ t.reportEvents = reportEvents;
+ t.eventEnd = eventEnd;
+ t.reportEventElement = reportEventElement;
+ t.reportEventClear = reportEventClear;
+ t.eventElementHandlers = eventElementHandlers;
+ t.showEvents = showEvents;
+ t.hideEvents = hideEvents;
+ t.eventDrop = eventDrop;
+ t.eventResize = eventResize;
+ // t.title
+ // t.start, t.end
+ // t.visStart, t.visEnd
+
+
+ // imports
+ var defaultEventEnd = t.defaultEventEnd;
+ var normalizeEvent = calendar.normalizeEvent; // in EventManager
+ var reportEventChange = calendar.reportEventChange;
+
+
+ // locals
+ var eventsByID = {};
+ var eventElements = [];
+ var eventElementsByID = {};
+ var options = calendar.options;
+
+
+
+ function opt(name, viewNameOverride) {
+ var v = options[name];
+ if (typeof v == 'object') {
+ return smartProperty(v, viewNameOverride || viewName);
+ }
+ return v;
+ }
+
+
+ function trigger(name, thisObj) {
+ return calendar.trigger.apply(
+ calendar,
+ [name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
+ );
+ }
+
+
+ /*
+ function setOverflowHidden(bool) {
+ element.css('overflow', bool ? 'hidden' : '');
+ }
+ */
+
+
+ function isEventDraggable(event) {
+ return isEventEditable(event) && !opt('disableDragging');
+ }
+
+
+ function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
+ return isEventEditable(event) && !opt('disableResizing');
+ }
+
+
+ function isEventEditable(event) {
+ return firstDefined(event.editable, (event.source || {}).editable, opt('editable'));
+ }
+
+
+
+ /* Event Data
+ ------------------------------------------------------------------------------*/
+
+
+ // report when view receives new events
+ function reportEvents(events) { // events are already normalized at this point
+ eventsByID = {};
+ var i, len=events.length, event;
+ for (i=0; i<len; i++) {
+ event = events[i];
+ if (eventsByID[event._id]) {
+ eventsByID[event._id].push(event);
+ }else{
+ eventsByID[event._id] = [event];
+ }
+ }
+ }
+
+
+ // returns a Date object for an event's end
+ function eventEnd(event) {
+ return event.end ? cloneDate(event.end) : defaultEventEnd(event);
+ }
+
+
+
+ /* Event Elements
+ ------------------------------------------------------------------------------*/
+
+
+ // report when view creates an element for an event
+ function reportEventElement(event, element) {
+ eventElements.push(element);
+ if (eventElementsByID[event._id]) {
+ eventElementsByID[event._id].push(element);
+ }else{
+ eventElementsByID[event._id] = [element];
+ }
+ }
+
+
+ function reportEventClear() {
+ eventElements = [];
+ eventElementsByID = {};
+ }
+
+
+ // attaches eventClick, eventMouseover, eventMouseout
+ function eventElementHandlers(event, eventElement) {
+ eventElement
+ .click(function(ev) {
+ if (!eventElement.hasClass('ui-draggable-dragging') &&
+ !eventElement.hasClass('ui-resizable-resizing')) {
+ return trigger('eventClick', this, event, ev);
+ }
+ })
+ .hover(
+ function(ev) {
+ trigger('eventMouseover', this, event, ev);
+ },
+ function(ev) {
+ trigger('eventMouseout', this, event, ev);
+ }
+ );
+ // TODO: don't fire eventMouseover/eventMouseout *while* dragging is occuring (on subject element)
+ // TODO: same for resizing
+ }
+
+
+ function showEvents(event, exceptElement) {
+ eachEventElement(event, exceptElement, 'show');
+ }
+
+
+ function hideEvents(event, exceptElement) {
+ eachEventElement(event, exceptElement, 'hide');
+ }
+
+
+ function eachEventElement(event, exceptElement, funcName) {
+ var elements = eventElementsByID[event._id],
+ i, len = elements.length;
+ for (i=0; i<len; i++) {
+ if (!exceptElement || elements[i][0] != exceptElement[0]) {
+ elements[i][funcName]();
+ }
+ }
+ }
+
+
+
+ /* Event Modification Reporting
+ ---------------------------------------------------------------------------------*/
+
+
+ function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui) {
+ var oldAllDay = event.allDay;
+ var eventId = event._id;
+ moveEvents(eventsByID[eventId], dayDelta, minuteDelta, allDay);
+ trigger(
+ 'eventDrop',
+ e,
+ event,
+ dayDelta,
+ minuteDelta,
+ allDay,
+ function() {
+ // TODO: investigate cases where this inverse technique might not work
+ moveEvents(eventsByID[eventId], -dayDelta, -minuteDelta, oldAllDay);
+ reportEventChange(eventId);
+ },
+ ev,
+ ui
+ );
+ reportEventChange(eventId);
+ }
+
+
+ function eventResize(e, event, dayDelta, minuteDelta, ev, ui) {
+ var eventId = event._id;
+ elongateEvents(eventsByID[eventId], dayDelta, minuteDelta);
+ trigger(
+ 'eventResize',
+ e,
+ event,
+ dayDelta,
+ minuteDelta,
+ function() {
+ // TODO: investigate cases where this inverse technique might not work
+ elongateEvents(eventsByID[eventId], -dayDelta, -minuteDelta);
+ reportEventChange(eventId);
+ },
+ ev,
+ ui
+ );
+ reportEventChange(eventId);
+ }
+
+
+
+ /* Event Modification Math
+ ---------------------------------------------------------------------------------*/
+
+
+ function moveEvents(events, dayDelta, minuteDelta, allDay) {
+ minuteDelta = minuteDelta || 0;
+ for (var e, len=events.length, i=0; i<len; i++) {
+ e = events[i];
+ if (allDay !== undefined) {
+ e.allDay = allDay;
+ }
+ addMinutes(addDays(e.start, dayDelta, true), minuteDelta);
+ if (e.end) {
+ e.end = addMinutes(addDays(e.end, dayDelta, true), minuteDelta);
+ }
+ normalizeEvent(e, options);
+ }
+ }
+
+
+ function elongateEvents(events, dayDelta, minuteDelta) {
+ minuteDelta = minuteDelta || 0;
+ for (var e, len=events.length, i=0; i<len; i++) {
+ e = events[i];
+ e.end = addMinutes(addDays(eventEnd(e), dayDelta, true), minuteDelta);
+ normalizeEvent(e, options);
+ }
+ }
+
+
+}
+
+function DayEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderDaySegs = renderDaySegs;
+ t.resizableDayEvent = resizableDayEvent;
+
+
+ // imports
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var eventEnd = t.eventEnd;
+ var reportEventElement = t.reportEventElement;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventResize = t.eventResize;
+ var getRowCnt = t.getRowCnt;
+ var getColCnt = t.getColCnt;
+ var getColWidth = t.getColWidth;
+ var allDayRow = t.allDayRow;
+ var allDayBounds = t.allDayBounds;
+ var colContentLeft = t.colContentLeft;
+ var colContentRight = t.colContentRight;
+ var dayOfWeekCol = t.dayOfWeekCol;
+ var dateCell = t.dateCell;
+ var compileDaySegs = t.compileDaySegs;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var bindDaySeg = t.bindDaySeg; //TODO: streamline this
+ var formatDates = t.calendar.formatDates;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var clearSelection = t.clearSelection;
+
+
+
+ /* Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ function renderDaySegs(segs, modifiedEventId) {
+ var segmentContainer = getDaySegmentContainer();
+ var rowDivs;
+ var rowCnt = getRowCnt();
+ var colCnt = getColCnt();
+ var i = 0;
+ var rowI;
+ var levelI;
+ var colHeights;
+ var j;
+ var segCnt = segs.length;
+ var seg;
+ var top;
+ var k;
+ segmentContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
+ daySegElementResolve(segs, segmentContainer.children());
+ daySegElementReport(segs);
+ daySegHandlers(segs, segmentContainer, modifiedEventId);
+ daySegCalcHSides(segs);
+ daySegSetWidths(segs);
+ daySegCalcHeights(segs);
+ rowDivs = getRowDivs();
+ // set row heights, calculate event tops (in relation to row top)
+ for (rowI=0; rowI<rowCnt; rowI++) {
+ levelI = 0;
+ colHeights = [];
+ for (j=0; j<colCnt; j++) {
+ colHeights[j] = 0;
+ }
+ while (i<segCnt && (seg = segs[i]).row == rowI) {
+ // loop through segs in a row
+ top = arrayMax(colHeights.slice(seg.startCol, seg.endCol));
+ seg.top = top;
+ top += seg.outerHeight;
+ for (k=seg.startCol; k<seg.endCol; k++) {
+ colHeights[k] = top;
+ }
+ i++;
+ }
+ rowDivs[rowI].height(arrayMax(colHeights));
+ }
+ daySegSetTops(segs, getRowTops(rowDivs));
+ }
+
+
+ function renderTempDaySegs(segs, adjustRow, adjustTop) {
+ var tempContainer = $("<div/>");
+ var elements;
+ var segmentContainer = getDaySegmentContainer();
+ var i;
+ var segCnt = segs.length;
+ var element;
+ tempContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
+ elements = tempContainer.children();
+ segmentContainer.append(elements);
+ daySegElementResolve(segs, elements);
+ daySegCalcHSides(segs);
+ daySegSetWidths(segs);
+ daySegCalcHeights(segs);
+ daySegSetTops(segs, getRowTops(getRowDivs()));
+ elements = [];
+ for (i=0; i<segCnt; i++) {
+ element = segs[i].element;
+ if (element) {
+ if (segs[i].row === adjustRow) {
+ element.css('top', adjustTop);
+ }
+ elements.push(element[0]);
+ }
+ }
+ return $(elements);
+ }
+
+
+ function daySegHTML(segs) { // also sets seg.left and seg.outerWidth
+ var rtl = opt('isRTL');
+ var i;
+ var segCnt=segs.length;
+ var seg;
+ var event;
+ var url;
+ var classes;
+ var bounds = allDayBounds();
+ var minLeft = bounds.left;
+ var maxLeft = bounds.right;
+ var leftCol;
+ var rightCol;
+ var left;
+ var right;
+ var skinCss;
+ var html = '';
+ // calculate desired position/dimensions, create html
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ classes = ['fc-event', 'fc-event-skin', 'fc-event-hori'];
+ if (isEventDraggable(event)) {
+ classes.push('fc-event-draggable');
+ }
+ if (rtl) {
+ if (seg.isStart) {
+ classes.push('fc-corner-right');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-left');
+ }
+ leftCol = dayOfWeekCol(seg.end.getDay()-1);
+ rightCol = dayOfWeekCol(seg.start.getDay());
+ left = seg.isEnd ? colContentLeft(leftCol) : minLeft;
+ right = seg.isStart ? colContentRight(rightCol) : maxLeft;
+ }else{
+ if (seg.isStart) {
+ classes.push('fc-corner-left');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-right');
+ }
+ leftCol = dayOfWeekCol(seg.start.getDay());
+ rightCol = dayOfWeekCol(seg.end.getDay()-1);
+ left = seg.isStart ? colContentLeft(leftCol) : minLeft;
+ right = seg.isEnd ? colContentRight(rightCol) : maxLeft;
+ }
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ url = event.url;
+ skinCss = getSkinCss(event, opt);
+ if (url) {
+ html += "<a href='" + htmlEscape(url) + "'";
+ }else{
+ html += "<div";
+ }
+ html +=
+ " class='" + classes.join(' ') + "'" +
+ " style='position:absolute;z-index:8;left:"+left+"px;" + skinCss + "'" +
+ ">" +
+ "<div" +
+ " class='fc-event-inner fc-event-skin'" +
+ (skinCss ? " style='" + skinCss + "'" : '') +
+ ">";
+ if (!event.allDay && seg.isStart) {
+ html +=
+ "<span class='fc-event-time'>" +
+ htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
+ "</span>";
+ }
+ html +=
+ "<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" +
+ "</div>";
+ if (seg.isEnd && isEventResizable(event)) {
+ html +=
+ "<div class='ui-resizable-handle ui-resizable-" + (rtl ? 'w' : 'e') + "'>" +
+ "&nbsp;&nbsp;&nbsp;" + // makes hit area a lot better for IE6/7
+ "</div>";
+ }
+ html +=
+ "</" + (url ? "a" : "div" ) + ">";
+ seg.left = left;
+ seg.outerWidth = right - left;
+ seg.startCol = leftCol;
+ seg.endCol = rightCol + 1; // needs to be exclusive
+ }
+ return html;
+ }
+
+
+ function daySegElementResolve(segs, elements) { // sets seg.element
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var event;
+ var element;
+ var triggerRes;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ element = $(elements[i]); // faster than .eq()
+ triggerRes = trigger('eventRender', event, event, element);
+ if (triggerRes === false) {
+ element.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ triggerRes = $(triggerRes)
+ .css({
+ position: 'absolute',
+ left: seg.left
+ });
+ element.replaceWith(triggerRes);
+ element = triggerRes;
+ }
+ seg.element = element;
+ }
+ }
+ }
+
+
+ function daySegElementReport(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ reportEventElement(seg.event, element);
+ }
+ }
+ }
+
+
+ function daySegHandlers(segs, segmentContainer, modifiedEventId) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var event;
+ // retrieve elements, run through eventRender callback, bind handlers
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ event = seg.event;
+ if (event._id === modifiedEventId) {
+ bindDaySeg(event, element, seg);
+ }else{
+ element[0]._fci = i; // for lazySegBind
+ }
+ }
+ }
+ lazySegBind(segmentContainer, segs, bindDaySeg);
+ }
+
+
+ function daySegCalcHSides(segs) { // also sets seg.key
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var key, val;
+ var hsideCache = {};
+ // record event horizontal sides
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ key = seg.key = cssKey(element[0]);
+ val = hsideCache[key];
+ if (val === undefined) {
+ val = hsideCache[key] = hsides(element, true);
+ }
+ seg.hsides = val;
+ }
+ }
+ }
+
+
+ function daySegSetWidths(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ element[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
+ }
+ }
+ }
+
+
+ function daySegCalcHeights(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var key, val;
+ var vmarginCache = {};
+ // record event heights
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ key = seg.key; // created in daySegCalcHSides
+ val = vmarginCache[key];
+ if (val === undefined) {
+ val = vmarginCache[key] = vmargins(element);
+ }
+ seg.outerHeight = element[0].offsetHeight + val;
+ }
+ }
+ }
+
+
+ function getRowDivs() {
+ var i;
+ var rowCnt = getRowCnt();
+ var rowDivs = [];
+ for (i=0; i<rowCnt; i++) {
+ rowDivs[i] = allDayRow(i)
+ .find('td:first div.fc-day-content > div'); // optimal selector?
+ }
+ return rowDivs;
+ }
+
+
+ function getRowTops(rowDivs) {
+ var i;
+ var rowCnt = rowDivs.length;
+ var tops = [];
+ for (i=0; i<rowCnt; i++) {
+ tops[i] = rowDivs[i][0].offsetTop; // !!?? but this means the element needs position:relative if in a table cell!!!!
+ }
+ return tops;
+ }
+
+
+ function daySegSetTops(segs, rowTops) { // also triggers eventAfterRender
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var event;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ element[0].style.top = rowTops[seg.row] + (seg.top||0) + 'px';
+ event = seg.event;
+ trigger('eventAfterRender', event, event, element);
+ }
+ }
+ }
+
+
+
+ /* Resizing
+ -----------------------------------------------------------------------------------*/
+
+
+ function resizableDayEvent(event, element, seg) {
+ var rtl = opt('isRTL');
+ var direction = rtl ? 'w' : 'e';
+ var handle = element.find('div.ui-resizable-' + direction);
+ var isResizing = false;
+
+ // TODO: look into using jquery-ui mouse widget for this stuff
+ disableTextSelection(element); // prevent native <a> selection for IE
+ element
+ .mousedown(function(ev) { // prevent native <a> selection for others
+ ev.preventDefault();
+ })
+ .click(function(ev) {
+ if (isResizing) {
+ ev.preventDefault(); // prevent link from being visited (only method that worked in IE6)
+ ev.stopImmediatePropagation(); // prevent fullcalendar eventClick handler from being called
+ // (eventElementHandlers needs to be bound after resizableDayEvent)
+ }
+ });
+
+ handle.mousedown(function(ev) {
+ if (ev.which != 1) {
+ return; // needs to be left mouse button
+ }
+ isResizing = true;
+ var hoverListener = t.getHoverListener();
+ var rowCnt = getRowCnt();
+ var colCnt = getColCnt();
+ var dis = rtl ? -1 : 1;
+ var dit = rtl ? colCnt-1 : 0;
+ var elementTop = element.css('top');
+ var dayDelta;
+ var helpers;
+ var eventCopy = $.extend({}, event);
+ var minCell = dateCell(event.start);
+ clearSelection();
+ $('body')
+ .css('cursor', direction + '-resize')
+ .one('mouseup', mouseup);
+ trigger('eventResizeStart', this, event, ev);
+ hoverListener.start(function(cell, origCell) {
+ if (cell) {
+ var r = Math.max(minCell.row, cell.row);
+ var c = cell.col;
+ if (rowCnt == 1) {
+ r = 0; // hack for all-day area in agenda views
+ }
+ if (r == minCell.row) {
+ if (rtl) {
+ c = Math.min(minCell.col, c);
+ }else{
+ c = Math.max(minCell.col, c);
+ }
+ }
+ dayDelta = (r*7 + c*dis+dit) - (origCell.row*7 + origCell.col*dis+dit);
+ var newEnd = addDays(eventEnd(event), dayDelta, true);
+ if (dayDelta) {
+ eventCopy.end = newEnd;
+ var oldHelpers = helpers;
+ helpers = renderTempDaySegs(compileDaySegs([eventCopy]), seg.row, elementTop);
+ helpers.find('*').css('cursor', direction + '-resize');
+ if (oldHelpers) {
+ oldHelpers.remove();
+ }
+ hideEvents(event);
+ }else{
+ if (helpers) {
+ showEvents(event);
+ helpers.remove();
+ helpers = null;
+ }
+ }
+ clearOverlays();
+ renderDayOverlay(event.start, addDays(cloneDate(newEnd), 1)); // coordinate grid already rebuild at hoverListener.start
+ }
+ }, ev);
+
+ function mouseup(ev) {
+ trigger('eventResizeStop', this, event, ev);
+ $('body').css('cursor', '');
+ hoverListener.stop();
+ clearOverlays();
+ if (dayDelta) {
+ eventResize(this, event, dayDelta, 0, ev);
+ // event redraw will clear helpers
+ }
+ // otherwise, the drag handler already restored the old events
+
+ setTimeout(function() { // make this happen after the element's click event
+ isResizing = false;
+ },0);
+ }
+
+ });
+ }
+
+
+}
+
+//BUG: unselect needs to be triggered when events are dragged+dropped
+
+function SelectionManager() {
+ var t = this;
+
+
+ // exports
+ t.select = select;
+ t.unselect = unselect;
+ t.reportSelection = reportSelection;
+ t.daySelectionMousedown = daySelectionMousedown;
+
+
+ // imports
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var defaultSelectionEnd = t.defaultSelectionEnd;
+ var renderSelection = t.renderSelection;
+ var clearSelection = t.clearSelection;
+
+
+ // locals
+ var selected = false;
+
+
+
+ // unselectAuto
+ if (opt('selectable') && opt('unselectAuto')) {
+ $(document).mousedown(function(ev) {
+ var ignore = opt('unselectCancel');
+ if (ignore) {
+ if ($(ev.target).parents(ignore).length) { // could be optimized to stop after first match
+ return;
+ }
+ }
+ unselect(ev);
+ });
+ }
+
+
+ function select(startDate, endDate, allDay) {
+ unselect();
+ if (!endDate) {
+ endDate = defaultSelectionEnd(startDate, allDay);
+ }
+ renderSelection(startDate, endDate, allDay);
+ reportSelection(startDate, endDate, allDay);
+ }
+
+
+ function unselect(ev) {
+ if (selected) {
+ selected = false;
+ clearSelection();
+ trigger('unselect', null, ev);
+ }
+ }
+
+
+ function reportSelection(startDate, endDate, allDay, ev) {
+ selected = true;
+ trigger('select', null, startDate, endDate, allDay, ev);
+ }
+
+
+ function daySelectionMousedown(ev) { // not really a generic manager method, oh well
+ var cellDate = t.cellDate;
+ var cellIsAllDay = t.cellIsAllDay;
+ var hoverListener = t.getHoverListener();
+ var reportDayClick = t.reportDayClick; // this is hacky and sort of weird
+ if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
+ unselect(ev);
+ var _mousedownElement = this;
+ var dates;
+ hoverListener.start(function(cell, origCell) { // TODO: maybe put cellDate/cellIsAllDay info in cell
+ clearSelection();
+ if (cell && cellIsAllDay(cell)) {
+ dates = [ cellDate(origCell), cellDate(cell) ].sort(cmp);
+ renderSelection(dates[0], dates[1], true);
+ }else{
+ dates = null;
+ }
+ }, ev);
+ $(document).one('mouseup', function(ev) {
+ hoverListener.stop();
+ if (dates) {
+ if (+dates[0] == +dates[1]) {
+ reportDayClick(dates[0], true, ev);
+ }
+ reportSelection(dates[0], dates[1], true, ev);
+ }
+ });
+ }
+ }
+
+
+}
+
+function OverlayManager() {
+ var t = this;
+
+
+ // exports
+ t.renderOverlay = renderOverlay;
+ t.clearOverlays = clearOverlays;
+
+
+ // locals
+ var usedOverlays = [];
+ var unusedOverlays = [];
+
+
+ function renderOverlay(rect, parent) {
+ var e = unusedOverlays.shift();
+ if (!e) {
+ e = $("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>");
+ }
+ if (e[0].parentNode != parent[0]) {
+ e.appendTo(parent);
+ }
+ usedOverlays.push(e.css(rect).show());
+ return e;
+ }
+
+
+ function clearOverlays() {
+ var e;
+ while (e = usedOverlays.shift()) {
+ unusedOverlays.push(e.hide().unbind());
+ }
+ }
+
+
+}
+
+function CoordinateGrid(buildFunc) {
+
+ var t = this;
+ var rows;
+ var cols;
+
+
+ t.build = function() {
+ rows = [];
+ cols = [];
+ buildFunc(rows, cols);
+ };
+
+
+ t.cell = function(x, y) {
+ var rowCnt = rows.length;
+ var colCnt = cols.length;
+ var i, r=-1, c=-1;
+ for (i=0; i<rowCnt; i++) {
+ if (y >= rows[i][0] && y < rows[i][1]) {
+ r = i;
+ break;
+ }
+ }
+ for (i=0; i<colCnt; i++) {
+ if (x >= cols[i][0] && x < cols[i][1]) {
+ c = i;
+ break;
+ }
+ }
+ return (r>=0 && c>=0) ? { row:r, col:c } : null;
+ };
+
+
+ t.rect = function(row0, col0, row1, col1, originElement) { // row1,col1 is inclusive
+ var origin = originElement.offset();
+ return {
+ top: rows[row0][0] - origin.top,
+ left: cols[col0][0] - origin.left,
+ width: cols[col1][1] - cols[col0][0],
+ height: rows[row1][1] - rows[row0][0]
+ };
+ };
+
+}
+
+function HoverListener(coordinateGrid) {
+
+
+ var t = this;
+ var bindType;
+ var change;
+ var firstCell;
+ var cell;
+
+
+ t.start = function(_change, ev, _bindType) {
+ change = _change;
+ firstCell = cell = null;
+ coordinateGrid.build();
+ mouse(ev);
+ bindType = _bindType || 'mousemove';
+ $(document).bind(bindType, mouse);
+ };
+
+
+ function mouse(ev) {
+ _fixUIEvent(ev); // see below
+ var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
+ if (!newCell != !cell || newCell && (newCell.row != cell.row || newCell.col != cell.col)) {
+ if (newCell) {
+ if (!firstCell) {
+ firstCell = newCell;
+ }
+ change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
+ }else{
+ change(newCell, firstCell);
+ }
+ cell = newCell;
+ }
+ }
+
+
+ t.stop = function() {
+ $(document).unbind(bindType, mouse);
+ return cell;
+ };
+
+
+}
+
+
+
+// this fix was only necessary for jQuery UI 1.8.16 (and jQuery 1.7 or 1.7.1)
+// upgrading to jQuery UI 1.8.17 (and using either jQuery 1.7 or 1.7.1) fixed the problem
+// but keep this in here for 1.8.16 users
+// and maybe remove it down the line
+
+function _fixUIEvent(event) { // for issue 1168
+ if (event.pageX === undefined) {
+ event.pageX = event.originalEvent.pageX;
+ event.pageY = event.originalEvent.pageY;
+ }
+}
+function HorizontalPositionCache(getElement) {
+
+ var t = this,
+ elements = {},
+ lefts = {},
+ rights = {};
+
+ function e(i) {
+ return elements[i] = elements[i] || getElement(i);
+ }
+
+ t.left = function(i) {
+ return lefts[i] = lefts[i] === undefined ? e(i).position().left : lefts[i];
+ };
+
+ t.right = function(i) {
+ return rights[i] = rights[i] === undefined ? t.left(i) + e(i).width() : rights[i];
+ };
+
+ t.clear = function() {
+ elements = {};
+ lefts = {};
+ rights = {};
+ };
+
+}
+
+})(jQuery);
+
+//</script>
diff --git a/mod/event_calendar/views/default/js/event_calendar/gcal.js b/mod/event_calendar/views/default/js/event_calendar/gcal.js
new file mode 100644
index 000000000..e9bbe26d8
--- /dev/null
+++ b/mod/event_calendar/views/default/js/event_calendar/gcal.js
@@ -0,0 +1,112 @@
+/*
+ * FullCalendar v1.5.3 Google Calendar Plugin
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Mon Feb 6 22:40:40 2012 -0800
+ *
+ */
+
+(function($) {
+
+
+var fc = $.fullCalendar;
+var formatDate = fc.formatDate;
+var parseISO8601 = fc.parseISO8601;
+var addDays = fc.addDays;
+var applyAll = fc.applyAll;
+
+
+fc.sourceNormalizers.push(function(sourceOptions) {
+ if (sourceOptions.dataType == 'gcal' ||
+ sourceOptions.dataType === undefined &&
+ (sourceOptions.url || '').match(/^(http|https):\/\/www.google.com\/calendar\/feeds\//)) {
+ sourceOptions.dataType = 'gcal';
+ if (sourceOptions.editable === undefined) {
+ sourceOptions.editable = false;
+ }
+ }
+});
+
+
+fc.sourceFetchers.push(function(sourceOptions, start, end) {
+ if (sourceOptions.dataType == 'gcal') {
+ return transformOptions(sourceOptions, start, end);
+ }
+});
+
+
+function transformOptions(sourceOptions, start, end) {
+
+ var success = sourceOptions.success;
+ var data = $.extend({}, sourceOptions.data || {}, {
+ 'start-min': formatDate(start, 'u'),
+ 'start-max': formatDate(end, 'u'),
+ 'singleevents': true,
+ 'max-results': 9999
+ });
+
+ var ctz = sourceOptions.currentTimezone;
+ if (ctz) {
+ data.ctz = ctz = ctz.replace(' ', '_');
+ }
+
+ return $.extend({}, sourceOptions, {
+ url: sourceOptions.url.replace(/\/basic$/, '/full') + '?alt=json-in-script&callback=?',
+ dataType: 'jsonp',
+ data: data,
+ startParam: false,
+ endParam: false,
+ success: function(data) {
+ var events = [];
+ if (data.feed.entry) {
+ $.each(data.feed.entry, function(i, entry) {
+ var startStr = entry['gd$when'][0]['startTime'];
+ var start = parseISO8601(startStr, true);
+ var end = parseISO8601(entry['gd$when'][0]['endTime'], true);
+ var allDay = startStr.indexOf('T') == -1;
+ var url;
+ $.each(entry.link, function(i, link) {
+ if (link.type == 'text/html') {
+ url = link.href;
+ if (ctz) {
+ url += (url.indexOf('?') == -1 ? '?' : '&') + 'ctz=' + ctz;
+ }
+ }
+ });
+ if (allDay) {
+ addDays(end, -1); // make inclusive
+ }
+ events.push({
+ id: entry['gCal$uid']['value'],
+ title: entry['title']['$t'],
+ url: url,
+ start: start,
+ end: end,
+ allDay: allDay,
+ location: entry['gd$where'][0]['valueString'],
+ description: entry['content']['$t']
+ });
+ });
+ }
+ var args = [events].concat(Array.prototype.slice.call(arguments, 1));
+ var res = applyAll(success, this, args);
+ if ($.isArray(res)) {
+ return res;
+ }
+ return events;
+ }
+ });
+
+}
+
+
+// legacy
+fc.gcalFeed = function(url, sourceOptions) {
+ return $.extend({}, sourceOptions, { url: url, dataType: 'gcal' });
+};
+
+
+})(jQuery);
diff --git a/mod/event_calendar/views/default/object/event_calendar.php b/mod/event_calendar/views/default/object/event_calendar.php
new file mode 100644
index 000000000..17f7ff130
--- /dev/null
+++ b/mod/event_calendar/views/default/object/event_calendar.php
@@ -0,0 +1,115 @@
+<?php
+
+/**
+ * Elgg event_calendar object view
+ *
+ * @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/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$event = $vars['entity'];
+$full = elgg_extract('full_view', $vars, FALSE);
+
+if ($full) {
+ $body = elgg_view('event_calendar/strapline',$vars);
+ if ($event->web_conference) {
+ $body .= '<br />';
+ $body .= elgg_view('event_calendar/conference_button',array('event'=>$event));
+ }
+ $event_items = event_calendar_get_formatted_full_items($event);
+ $body .= '<br />';
+
+ foreach($event_items as $item) {
+ $value = $item->value;
+ if (!empty($value)) {
+
+ //This function controls the alternating class
+ $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
+ $body .= "<p class=\"{$even_odd}\"><b>";
+ $body .= $item->title.':</b> ';
+ $body .= $item->value;
+ }
+ }
+ $metadata = elgg_view_menu('entity', array(
+ 'entity' => $event,
+ 'handler' => 'event_calendar',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+ ));
+
+ $tags = elgg_view('output/tags', array('tags' => $event->tags));
+
+ $params = array(
+ 'entity' => $event,
+ 'metadata' => $metadata,
+ 'tags' => $tags,
+ 'title' => false,
+ );
+ $list_body = elgg_view('object/elements/summary', $params);
+ echo $list_body;
+ echo $body;
+ if ($event->long_description) {
+ echo '<div class="elgg-output">'.$event->long_description.'</div>';
+ } else {
+ echo '<div class="elgg-output">'.$event->description.'</div>';
+ }
+ if ($vars['light_box'] == TRUE) {
+ $event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+ if ($event_calendar_add_users == 'yes') {
+ $url = "event_calendar/manage_users/$event->guid";
+ echo '<p>'.elgg_view('output/url',array('text'=> elgg_echo('event_calendar:manage_users:breadcrumb'), 'href'=>$url)).'</p>';
+ }
+ }
+ if (elgg_get_plugin_setting('add_to_group_calendar', 'event_calendar') == 'yes') {
+ echo elgg_view('event_calendar/forms/add_to_group',array('event' => $event));
+ }
+
+} else {
+
+ $time_bit = event_calendar_get_formatted_time($event);
+ $icon = '<img src="'.elgg_view("icon/object/event_calendar/small").'" />';
+ $extras = array($time_bit);
+ if ($event->description) {
+ $extras[] = $event->description;
+ }
+
+ if ($event_calendar_venue_view = elgg_get_plugin_setting('venue_view', 'event_calendar') == 'yes') {
+ $extras[] = $event->venue;
+ }
+ if ($extras) {
+ $info = "<p>".implode("<br />",$extras)."</p>";
+ } else {
+ $info = '';
+ }
+
+ if (elgg_in_context('widgets')) {
+ $metadata = '';
+ } else {
+ $metadata = elgg_view_menu('entity', array(
+ 'entity' => $event,
+ 'handler' => 'event_calendar',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+ ));
+ }
+
+ $tags = elgg_view('output/tags', array('tags' => $event->tags));
+
+ $params = array(
+ 'entity' => $event,
+ 'metadata' => $metadata,
+ 'subtitle' => $info,
+ 'tags' => $tags,
+ );
+ $list_body = elgg_view('object/elements/summary', $params);
+
+ echo elgg_view_image_block($icon, $list_body);
+}
+
+?>
diff --git a/mod/event_calendar/views/default/plugins/event_calendar/settings.php b/mod/event_calendar/views/default/plugins/event_calendar/settings.php
new file mode 100644
index 000000000..a58647828
--- /dev/null
+++ b/mod/event_calendar/views/default/plugins/event_calendar/settings.php
@@ -0,0 +1,474 @@
+<?php
+$yn_options = array(elgg_echo('event_calendar:settings:yes')=>'yes',
+ elgg_echo('event_calendar:settings:no')=>'no',
+);
+
+$time_format_options = array(elgg_echo('event_calendar:time_format:12hour')=>'12',elgg_echo('event_calendar:time_format:24hour')=>'24');
+
+$membership_options = array(
+ elgg_echo('event_calendar:personal_manage:open') => 'open' ,
+ elgg_echo('event_calendar:personal_manage:closed') => 'closed',
+ elgg_echo('event_calendar:personal_manage:private') => 'private',
+ elgg_echo('event_calendar:personal_manage:by_event') => 'by_event',
+);
+
+$access_options = array( ACCESS_PRIVATE => elgg_echo("PRIVATE"),
+ ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"),
+ ACCESS_PUBLIC => elgg_echo("PUBLIC"));
+
+$listing_options = array(elgg_echo('event_calendar:settings:paged')=>'paged',
+ elgg_echo('event_calendar:settings:agenda')=>'agenda',
+ elgg_echo('event_calendar:settings:month')=>'month',
+ elgg_echo('event_calendar:settings:full')=>'full',
+);
+
+$body = '';
+
+/*$event_calendar_full_calendar = elgg_get_plugin_setting('full_calendar', 'event_calendar');
+if (!$event_calendar_full_calendar) {
+ $event_calendar_full_calendar = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:full_calendar:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[full_calendar]','value'=>$event_calendar_full_calendar,'options'=>$yn_options));
+
+$body .= '<br />';*/
+
+$event_calendar_hide_access = elgg_get_plugin_setting('hide_access', 'event_calendar');
+if (!$event_calendar_hide_access) {
+ $event_calendar_hide_access = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:hide_access:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[hide_access]','value'=>$event_calendar_hide_access,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_default_access = elgg_get_plugin_setting('default_access', 'event_calendar');
+if (!$event_calendar_default_access) {
+ $event_calendar_default_access = ACCESS_LOGGED_IN;
+}
+
+$body .= elgg_echo('event_calendar:settings:default_access:title');
+$body .= '<br />';
+$body .= elgg_view('input/dropdown',array('name'=>'params[default_access]','value'=>$event_calendar_default_access,'options_values'=>$access_options));
+
+$body .= '<br /><br />';
+
+$event_calendar_hide_end = elgg_get_plugin_setting('hide_end', 'event_calendar');
+if (!$event_calendar_hide_end) {
+ $event_calendar_hide_end = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:hide_end:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[hide_end]','value'=>$event_calendar_hide_end,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_listing_format = elgg_get_plugin_setting('listing_format', 'event_calendar');
+if (!$event_calendar_listing_format) {
+ $event_calendar_listing_format = 'month';
+}
+
+$body .= elgg_echo('event_calendar:settings:listing_format:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[listing_format]','value'=>$event_calendar_listing_format,'options'=>$listing_options));
+
+$body .= '<br />';
+
+$event_calendar_repeated_events = elgg_get_plugin_setting('repeated_events', 'event_calendar');
+if (!$event_calendar_repeated_events) {
+ $event_calendar_repeated_events = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:repeated_events:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[repeated_events]','value'=>$event_calendar_repeated_events,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_reminders = elgg_get_plugin_setting('reminders', 'event_calendar');
+if (!$event_calendar_reminders) {
+ $event_calendar_reminders = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:reminders:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[reminders]','value'=>$event_calendar_reminders,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar');
+if (!$event_calendar_times) {
+ $event_calendar_times = 'yes';
+}
+
+$body .= elgg_echo('event_calendar:settings:times:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[times]','value'=>$event_calendar_times,'options'=>$yn_options));
+
+$body .= '<br />';
+
+/*$event_calendar_restricted_times = elgg_get_plugin_setting('restricted_times', 'event_calendar');
+if (!$event_calendar_restricted_times) {
+ $event_calendar_restricted_times = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:restricted_times:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[restricted_times]','value'=>$event_calendar_restricted_times,'options'=>$yn_options));
+
+$body .= '<br />';*/
+
+$event_calendar_time_format = elgg_get_plugin_setting('timeformat', 'event_calendar');
+if (!$event_calendar_time_format) {
+ $event_calendar_time_format = '24';
+}
+
+$body .= elgg_echo('event_calendar:settings:timeformat:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[timeformat]','value'=>$event_calendar_time_format,'options'=>$time_format_options));
+
+$body .= '<br />';
+
+$event_calendar_autopersonal = elgg_get_plugin_setting('autopersonal', 'event_calendar');
+if (!$event_calendar_autopersonal) {
+ $event_calendar_autopersonal = 'yes';
+}
+
+$body .= elgg_echo('event_calendar:settings:autopersonal:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[autopersonal]','value'=>$event_calendar_autopersonal,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_autogroup = elgg_get_plugin_setting('autogroup', 'event_calendar');
+if (!$event_calendar_autogroup) {
+ $event_calendar_autogroup = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:autogroup:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[autogroup]','value'=>$event_calendar_autogroup,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_add_to_group_calendar = elgg_get_plugin_setting('add_to_group_calendar', 'event_calendar');
+if (!$event_calendar_add_to_group_calendar) {
+ $event_calendar_add_to_group_calendar = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:add_to_group_calendar:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[add_to_group_calendar]','value'=>$event_calendar_add_to_group_calendar,'options'=>$yn_options));
+
+$body .= '<br />';
+
+// agenda view is now handled in the listing area
+
+/*$event_calendar_agenda_view = elgg_get_plugin_setting('agenda_view', 'event_calendar');
+if (!$event_calendar_agenda_view) {
+ $event_calendar_agenda_view = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:agenda_view:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[agenda_view]','value'=>$event_calendar_agenda_view,'options'=>$yn_options));
+
+$body .= '<br />';*/
+
+$event_calendar_venue_view = elgg_get_plugin_setting('venue_view', 'event_calendar');
+if (!$event_calendar_venue_view) {
+ $event_calendar_venue_view = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:venue_view:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[venue_view]','value'=>$event_calendar_venue_view,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_fewer_fields = elgg_get_plugin_setting('fewer_fields', 'event_calendar');
+if (!$event_calendar_fewer_fields) {
+ $event_calendar_fewer_fields = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:fewer_fields:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[fewer_fields]','value'=>$event_calendar_fewer_fields,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$options = array(elgg_echo('event_calendar:settings:no')=>'no',
+ elgg_echo('event_calendar:settings:site_calendar:admin')=>'admin',
+ elgg_echo('event_calendar:settings:site_calendar:loggedin')=>'loggedin',
+);
+
+$event_calendar_site_calendar = elgg_get_plugin_setting('site_calendar', 'event_calendar');
+if (!$event_calendar_site_calendar) {
+ $event_calendar_site_calendar = 'admin';
+}
+
+$body .= elgg_echo('event_calendar:settings:site_calendar:title').'<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[site_calendar]','value'=>$event_calendar_site_calendar,'options'=>$options));
+
+$body .= '<br />';
+
+$options = array(elgg_echo('event_calendar:settings:no')=>'no',
+ elgg_echo('event_calendar:settings:group_calendar:admin')=>'admin',
+ elgg_echo('event_calendar:settings:group_calendar:members')=>'members',
+);
+
+$event_calendar_group_calendar = elgg_get_plugin_setting('group_calendar', 'event_calendar');
+if (!$event_calendar_group_calendar) {
+ $event_calendar_group_calendar = 'members';
+}
+
+$body .= elgg_echo('event_calendar:settings:group_calendar:title').'<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[group_calendar]','value'=>$event_calendar_group_calendar,'options'=>$options));
+
+$body .= '<br />';
+
+$options = array(elgg_echo('event_calendar:settings:group_default:yes')=>'yes',
+ elgg_echo('event_calendar:settings:group_default:no')=>'no',
+);
+
+$event_calendar_group_default = elgg_get_plugin_setting('group_default', 'event_calendar');
+if (!$event_calendar_group_default) {
+ $event_calendar_group_default = 'yes';
+}
+
+$body .= elgg_echo('event_calendar:settings:group_default:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[group_default]','value'=>$event_calendar_group_default,'options'=>$options));
+
+$body .= '<br />';
+
+$event_calendar_group_always_display = elgg_get_plugin_setting('group_always_display', 'event_calendar');
+if (!$event_calendar_group_always_display) {
+ $event_calendar_group_always_display = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:group_always_display:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[group_always_display]','value'=>$event_calendar_group_always_display,'options'=>$yn_options));
+
+$body .= '<br />';
+
+// There does not seem to be a way to determine where the group calendar box will appear in Elgg 1.8
+
+/*$options = array(elgg_echo('event_calendar:settings:group_profile_display_option:left')=>'left',
+ elgg_echo('event_calendar:settings:group_profile_display_option:right')=>'right',
+ elgg_echo('event_calendar:settings:group_profile_display_option:none')=>'none',
+);
+
+$event_calendar_group_profile_display = elgg_get_plugin_setting('group_profile_display', 'event_calendar');
+if (!$event_calendar_group_profile_display) {
+ $event_calendar_group_profile_display = 'right';
+}
+
+$body .= elgg_echo('event_calendar:settings:group_profile_display:title').'<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[group_profile_display]','value'=>$event_calendar_group_profile_display,'options'=>$options));
+
+$body .= '<br />';*/
+
+$event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+if (!$event_calendar_add_users) {
+ $event_calendar_add_users = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:add_users:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[add_users]','value'=>$event_calendar_add_users,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_add_users_notify = elgg_get_plugin_setting('add_users_notify', 'event_calendar');
+if (!$event_calendar_add_users_notify) {
+ $event_calendar_add_users_notify = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:add_users_notify:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[add_users_notify]','value'=>$event_calendar_add_users_notify,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar');
+if (!$event_calendar_personal_manage && $personal_manage == 'yes') {
+ $event_calendar_personal_manage = 'open';
+}
+
+$body .= elgg_echo('event_calendar:settings:personal_manage:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[personal_manage]','value'=>$event_calendar_personal_manage,'options'=>$membership_options));
+$body .= '<p>'.elgg_echo('event_calendar:settings:personal_manage:description').'</p>';
+
+$event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar');
+if (!$event_calendar_spots_display) {
+ $event_calendar_spots_display = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:spots_display:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[spots_display]','value'=>$event_calendar_spots_display,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_no_collisions = elgg_get_plugin_setting('no_collisions', 'event_calendar');
+if (!$event_calendar_no_collisions) {
+ $event_calendar_no_collisions = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:no_collisions:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[no_collisions]','value'=>$event_calendar_no_collisions,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_collision_length = elgg_get_plugin_setting('collision_length', 'event_calendar');
+if (!$event_calendar_collision_length) {
+ $event_calendar_collision_length = '3600';
+}
+
+$body .= elgg_echo('event_calendar:settings:collision_length:title');
+$body .= '<br />';
+$body .= elgg_view('input/text',array('name'=>'params[collision_length]','value'=>$event_calendar_collision_length));
+
+$body .= '<br /><br />';
+
+$event_calendar_region_display = elgg_get_plugin_setting('region_display', 'event_calendar');
+if (!$event_calendar_region_display) {
+ $event_calendar_region_display = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:region_display:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[region_display]','value'=>$event_calendar_region_display,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_region_list = elgg_get_plugin_setting('region_list', 'event_calendar');
+if (!$event_calendar_region_list) {
+ $event_calendar_region_list = '';
+}
+
+$body .= elgg_echo('event_calendar:settings:region_list:title');
+$body .= '<br />';
+$body .= elgg_view('input/plaintext',array('name'=>'params[region_list]','value'=>$event_calendar_region_list));
+
+$body .= '<br />';
+
+$event_calendar_region_list_handles = elgg_get_plugin_setting('region_list_handles', 'event_calendar');
+if (!$event_calendar_region_list_handles) {
+ $event_calendar_region_list_handles = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:region_list_handles:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[region_list_handles]','value'=>$event_calendar_region_list_handles,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_type_display = elgg_get_plugin_setting('type_display', 'event_calendar');
+if (!$event_calendar_type_display) {
+ $event_calendar_type_display = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:type_display:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[type_display]','value'=>$event_calendar_type_display,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_type_list = elgg_get_plugin_setting('type_list', 'event_calendar');
+if (!$event_calendar_type_list) {
+ $event_calendar_type_list = '';
+}
+
+$body .= elgg_echo('event_calendar:settings:type_list:title');
+$body .= '<br />';
+$body .= elgg_view('input/plaintext',array('name'=>'params[type_list]','value'=>$event_calendar_type_list));
+
+$body .= '<br />';
+
+$event_calendar_type_list_handles = elgg_get_plugin_setting('type_list_handles', 'event_calendar');
+if (!$event_calendar_type_list_handles) {
+ $event_calendar_type_list_handles = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:type_list_handles:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[type_list_handles]','value'=>$event_calendar_type_list_handles,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$event_calendar_first_date = elgg_get_plugin_setting('first_date', 'event_calendar');
+if (!$event_calendar_first_date) {
+ $event_calendar_first_date = '';
+}
+
+$body .= elgg_echo('event_calendar:settings:first_date:title');
+$body .= '<br />';
+$body .= elgg_view('input/text',array('name'=>'params[first_date]','value'=>$event_calendar_first_date));
+
+$body .= '<br /><br />';
+
+$event_calendar_last_date = elgg_get_plugin_setting('last_date', 'event_calendar');
+if (!$event_calendar_last_date) {
+ $event_calendar_last_date = '';
+}
+
+$body .= elgg_echo('event_calendar:settings:last_date:title');
+$body .= '<br />';
+$body .= elgg_view('input/text',array('name'=>'params[last_date]','value'=>$event_calendar_last_date));
+
+$body .= '<br /><br />';
+
+$event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar');
+if (!$event_calendar_more_required) {
+ $event_calendar_more_required = 'no';
+}
+
+$body .= elgg_echo('event_calendar:settings:more_required:title');
+$body .= '<br />';
+$body .= elgg_view('input/radio',array('name'=>'params[more_required]','value'=>$event_calendar_more_required,'options'=>$yn_options));
+
+$body .= '<br />';
+
+$ical_auth_file_name = elgg_get_plugin_setting('ical_auth_file_name', 'event_calendar');
+
+$body .= elgg_echo('event_calendar:ical_auth_file_name:title');
+$body .= '<br />';
+$body .= elgg_view('input/text',array('name'=>'params[ical_auth_file_name]','value'=>$ical_auth_file_name, 'class'=>'event-calendar-ical-auth-setting'));
+
+$body .= '<br /><br />';
+
+$event_calendar_bbb_server_url = elgg_get_plugin_setting('bbb_server_url', 'event_calendar');
+
+$body .= elgg_echo('event_calendar:bbb_server_url');
+$body .= '<br />';
+$body .= elgg_view('input/text', array(
+ 'name' => 'params[bbb_server_url]',
+ 'value' => $event_calendar_bbb_server_url,
+ 'class' => 'text_input',
+));
+
+$body .= '<br /><br />';
+
+$event_calendar_bbb_security_salt = elgg_get_plugin_setting('bbb_security_salt', 'event_calendar');
+
+$body .= elgg_echo('event_calendar:bbb_security_salt');
+$body .= '<br />';
+$body .= elgg_view('input/text', array(
+ 'name' => 'params[bbb_security_salt]',
+ 'value' => $event_calendar_bbb_security_salt,
+ 'class' => 'text_input',
+));
+
+$body .= '<br /><br />';
+
+echo $body;
diff --git a/mod/event_calendar/views/default/river/object/event_calendar/create.php b/mod/event_calendar/views/default/river/object/event_calendar/create.php
new file mode 100644
index 000000000..515389411
--- /dev/null
+++ b/mod/event_calendar/views/default/river/object/event_calendar/create.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Event river view.
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$object = $vars['item']->getObjectEntity();
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => event_calendar_get_formatted_time($object),
+));
diff --git a/mod/event_calendar/views/default/river/object/event_calendar/update.php b/mod/event_calendar/views/default/river/object/event_calendar/update.php
new file mode 100644
index 000000000..515389411
--- /dev/null
+++ b/mod/event_calendar/views/default/river/object/event_calendar/update.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Event river view.
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+$object = $vars['item']->getObjectEntity();
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => event_calendar_get_formatted_time($object),
+));
diff --git a/mod/event_calendar/views/default/widgets/event_calendar/content.php b/mod/event_calendar/views/default/widgets/event_calendar/content.php
new file mode 100644
index 000000000..eaedb76bd
--- /dev/null
+++ b/mod/event_calendar/views/default/widgets/event_calendar/content.php
@@ -0,0 +1,43 @@
+<?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
+ $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) {
+
+ 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
diff --git a/mod/event_calendar/views/default/widgets/event_calendar/edit.php b/mod/event_calendar/views/default/widgets/event_calendar/edit.php
new file mode 100644
index 000000000..716920c8a
--- /dev/null
+++ b/mod/event_calendar/views/default/widgets/event_calendar/edit.php
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * Elgg event_calendar group 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/
+ *
+ */
+
+if (!$vars['entity']->num_display) {
+ $num_display = 5;
+} else {
+ $num_display = $vars['entity']->num_display;
+}
+?>
+
+<p>
+ <?php echo elgg_echo("event_calendar:num_display"); ?>:
+ <select name="params[num_display]">
+ <option value="1" <?php if($num_display == 1) echo "SELECTED"; ?>>1</option>
+ <option value="2" <?php if($num_display == 2) echo "SELECTED"; ?>>2</option>
+ <option value="3" <?php if($num_display == 3) echo "SELECTED"; ?>>3</option>
+ <option value="4" <?php if($num_display == 4) echo "SELECTED"; ?>>4</option>
+ <option value="5" <?php if($num_display == 5) echo "SELECTED"; ?>>5</option>
+ <option value="6" <?php if($num_display == 6) echo "SELECTED"; ?>>6</option>
+ <option value="7" <?php if($num_display == 7) echo "SELECTED"; ?>>7</option>
+ <option value="8" <?php if($num_display == 8) echo "SELECTED"; ?>>8</option>
+ <option value="9" <?php if($num_display == 9) echo "SELECTED"; ?>>9</option>
+ <option value="10" <?php if($num_display == 10) echo "SELECTED"; ?>>10</option>
+ </select>
+</p>
diff --git a/mod/event_calendar/views/ical/event_calendar/show_events.php b/mod/event_calendar/views/ical/event_calendar/show_events.php
new file mode 100644
index 000000000..d357908b9
--- /dev/null
+++ b/mod/event_calendar/views/ical/event_calendar/show_events.php
@@ -0,0 +1,7 @@
+<?php
+if ($vars['events']) {
+ foreach ($vars['events'] as $entity) {
+ echo elgg_view_entity($entity['event']);
+ }
+ //echo elgg_view_entity_list($vars['events'], $vars['count'], $vars['offset'], $vars['limit'], false, false);
+}
diff --git a/mod/event_calendar/views/ical/object/event_calendar.php b/mod/event_calendar/views/ical/object/event_calendar.php
new file mode 100644
index 000000000..36d71a66c
--- /dev/null
+++ b/mod/event_calendar/views/ical/object/event_calendar.php
@@ -0,0 +1,44 @@
+<?php
+$event = $vars['entity'];
+if ($event->organizer) {
+ $organizer = "\nORGANIZER;CN={$event->organizer}\n";
+} else {
+ $organizer = '';
+}
+
+if ($event->description) {
+ // make sure that we are using Unix line endings
+ $description = str_replace("\r\n","\n",$event->description);
+ $description = str_replace("\r","\n",$description);
+
+ // now convert to icalendar format
+ $description = str_replace("\n",'\n',$description);
+ $description = wordwrap($description,75,"\r\n ",TRUE);
+} else {
+ $description = '';
+}
+?>
+BEGIN:VEVENT
+UID:<?php echo elgg_get_site_url().'event_calendar/view/'.$event->guid; ?>
+
+URL:<?php echo elgg_get_site_url().'event_calendar/view/'.$event->guid; ?>
+
+DTSTAMP:<?php echo date("Ymd\THis\Z", $event->getTimeUpdated())?>
+
+CREATED:<?php echo date("Ymd\THis\Z", $event->getTimeCreated())?>
+
+LAST-MODIFIED:<?php echo date("Ymd\THis\Z", $event->getTimeUpdated()) ?>
+
+DTSTART;VALUE=DATE:<?php echo date("Ymd\THis\Z", $event->start_date); ?>
+
+DTEND;VALUE=DATE:<?php echo date("Ymd\THis\Z", $event->real_end_time); ?>
+
+SUMMARY:<?php echo $event->title; ?>
+
+DESCRIPTION:<?php echo $description; ?>
+
+LOCATION:<?php echo $event->venue; ?><?php echo $organizer; ?>
+
+CATEGORIES:<?php implode(",",$event->tags); ?>
+
+END:VEVENT
diff --git a/mod/event_calendar/views/ical/page/default.php b/mod/event_calendar/views/ical/page/default.php
new file mode 100644
index 000000000..b4cd7eefb
--- /dev/null
+++ b/mod/event_calendar/views/ical/page/default.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Elgg ICAL output pageshell
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ */
+
+header("Content-Type: text/calendar");
+header("Content-Disposition: inline; filename=\"calendar.ics\"");
+?>
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Curverider Ltd//NONSGML Elgg <?php echo get_version(true); ?>//EN
+<?php echo $vars['body']; ?>
+END:VCALENDAR
diff --git a/mod/event_calendar/views/ical/page/layouts/default.php b/mod/event_calendar/views/ical/page/layouts/default.php
new file mode 100644
index 000000000..57598fa1b
--- /dev/null
+++ b/mod/event_calendar/views/ical/page/layouts/default.php
@@ -0,0 +1,2 @@
+<?php
+echo $vars['content']; \ No newline at end of file
diff --git a/mod/event_calendar/views/rss/event_calendar/show_events.php b/mod/event_calendar/views/rss/event_calendar/show_events.php
new file mode 100644
index 000000000..40c67ff6a
--- /dev/null
+++ b/mod/event_calendar/views/rss/event_calendar/show_events.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Elgg show events RSS view
+ *
+ * @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 2009
+ * @link http://radagast.biz/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+if ($vars['events']) {
+ $options = array(
+ 'count' => $vars['count'],
+ 'offset' => 0,
+ 'limit' => 15,
+ 'list_type_toggle' => FALSE,
+ 'pagination' => FALSE,
+ );
+ // echo elgg_view_entity_list($vars['events'], $vars['count'], $vars['offset'], $vars['limit'], false, false);
+ echo elgg_view_entity_list(event_calendar_flatten_event_structure($vars['events']), $options);
+}
diff --git a/mod/event_calendar/views/rss/object/event_calendar.php b/mod/event_calendar/views/rss/object/event_calendar.php
new file mode 100644
index 000000000..45b2d847a
--- /dev/null
+++ b/mod/event_calendar/views/rss/object/event_calendar.php
@@ -0,0 +1,61 @@
+<?php
+
+ /**
+ * Elgg default object view
+ *
+ * @package Elgg
+ * @subpackage Core
+
+ * @author Curverider Ltd
+
+ * @link http://elgg.org/
+ */
+
+ elgg_load_library('elgg:event_calendar');
+ $title = $vars['entity']->title;
+
+ $event_items = event_calendar_get_formatted_full_items($vars['entity']);
+ $items = array();
+ foreach($event_items as $item) {
+ if (trim($item->value)) {
+ $items[] = '<b>'.$item->title.'</b>: '.$item->value;
+ }
+ }
+
+ $description = '<p>'.implode('<br />',$items).'</p>';
+
+ if ($vars['entity']->long_description) {
+ $description .= '<p>'.autop($vars['entity']->long_description).'</p>';
+ } else {
+ $description .= '<p>'.$vars['entity']->description.'</p>';
+ }
+
+?>
+
+ <item>
+ <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>
+ <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>
+ <title><![CDATA[<?php echo $title; ?>]]></title>
+ <description><![CDATA[<?php echo $description; ?>]]></description>
+ <?php
+ $owner = $vars['entity']->getOwnerEntity();
+ if ($owner)
+ {
+?>
+ <dc:creator><?php echo $owner->name; ?></dc:creator>
+<?php
+ }
+ ?>
+ <?php
+ if (
+ ($vars['entity'] instanceof Locatable) &&
+ ($vars['entity']->getLongitude()) &&
+ ($vars['entity']->getLatitude())
+ ) {
+ ?>
+ <georss:point><?php echo $vars['entity']->getLatitude(); ?> <?php echo $vars['entity']->getLongitude(); ?></georss:point>
+ <?php
+ }
+ ?>
+ <?php echo elgg_view('extensions/item'); ?>
+ </item>