Is there a way to export and import calendar data with an ICS or XML file? I would like to synchronise all my calendars with another website which is not running on Drupal.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fietserwin’s picture

There currently is no way to do so, though I'm interested in it myself as well. Do you know of any known formats to exchange availability data (do booking.com or other large rental sites (abritel, ...) propose/support an automated exchange? Can you post some links to any info you know of.

towlie’s picture

Normally you are using iCal for that: http://en.wikipedia.org/wiki/ICalendar
It seems that HomeAway is supporting that too: http://community.homeaway.com/message/24862

Would be great to have such a functionality for Availability Calendars!

meshel’s picture

Here is a little sandbox plugin I wrote to EXPORT ICAL data for availability
http://drupal.org/sandbox/mosheeshel/1913944

I hope the readme is enough to explain, basically you install this and views_ical module (in addition to views which you probably have already) - and then create a new ICAL view (there is a sample view attached as well - for referenece purposes only)

fietserwin’s picture

Version: 7.x-3.2 » 7.x-4.x-dev
Category: support » feature
Status: Active » Needs work

#3: Thanks for creating this functionality. I (finally) had (the time to have) a look at your sandbox code and what it does. May I summarize it with:

  1. Views support for date types in ISO8601 format (yyyy-mm-dd + optional time part).
  2. Views support for the tables of the Availability Calendar module.

IMHO, the former (1) should be part of Views, but isn't. Alternatively it should be part of Date, but it also isn't. So, I'm willing to add it to this module, but with the following changes:

  • Comply with Drupal coding standards.
  • Comply with documentation standards. Each and every class and method is documented, including return type. All parameters are documented including their type. Methods that override base class methods, may just indicate so possibly with a short note of what and why.
  • 1 class per file, how small it may be.
  • The handlers are restricted to date support (i.e. without time part) for the date type(s) this module uses. Therefore, the handlers should be renamed to something with SqlDate or Iso8601Date (not sure which one is better) as Views itself inappropriately (IMO) uses date instead of datetime.
  • Handlers should also be renamed to begin with this module's name.
  • The sort handler should reduce the list of $this->options['granularity'] to day, month and year.
  • Do use public explicitly on all public methods.
  • You do use double quotes AND concatenation with variables:
        parent::op_between("UNIX_TIMESTAMP(" . $field . ")");
    

Regarding (2):
I prefer to define these tables to Enity api instead of just to Views. Other issues and current work have convinced me that this is inevitable. By defining these tables as entities, we not only get Views support, but also Rules support and, my current work, search api support.

What next?

May I ask you to do the work for (1)? If you post it over here, I will add it to this module and you can remove it from your sandbox module. The 2nd part will be done by me. In the mean time, i.e. as long as that is not finished and published, you could just use the remainder of your own module (with some renamings of the handlers) for use in your own project.

fietserwin’s picture

Assigned: Unassigned » fietserwin

Started working on (1) and (2). Stay tuned as I need you to test it.

fietserwin’s picture

Version: 7.x-4.x-dev » 7.x-5.x-dev
Status: Needs work » Needs review

@meshel: May I ask you to test and review the new 7.x-5.x-dev release? It should contain all features you added to your sandbox project, except for the example Views template. Look at the git commits to see a diff with the current stable version. That should make it easier to see what has been added, moved or changed.

Please post all your remarks, suggestions, improvements, patches in this issue.

@towly: Could you also join us as tester of this new version. together with the views_ical module mentioned in #3, you should be able to do what you requested for.

There are no data model changes, so your data should be save and you should be able to downgrade. But still I would advice you to test on a separate install. Please also read the README.txt and, even more important, CHANGELOG.txt that come with this install before starting your testing.

Thanks in advance

PS: can you let me know if you are able to do any testing (in the near future), so I am not waiting in vain.

meshel’s picture

@fietserwin sorry for replying only now, I have only just noticed this update - was actually starting to work on your comments at #4 comment on this thread.
I started testing, hoping to come back with feedback.

tymn’s picture

Issue summary: View changes

It seems that from the original request this allows for exporting but not importing. Importing would allow each property owner on a large listing site to decide whether to update the availability calendar or enter an ical url to populate it (probably from another listing site such as Home Away, AirBnB, Holiday Lettings etc).

Basic example of UI here: http://www.spain-holiday.com/rentalbuzz/ical-keep-all-your-calendars-in-...

Just wondering if anyone has done any work on this so far? Let me know if I should create a separate feature request.

fietserwin’s picture

#8: Sorry for the late reaction.

I think your request should indeed be seen as a separate request and can be handled in a separate module, though this may be a sub-module of A.C. If you have any code to share, please do so and I will consider adding it to this module (as a sub module). If you need any API changes,let's discuss that to and I can do that in the main module.

Diseño web Mallorca’s picture

@meshel @towly Hi could anyone help me to get this done? I import the view ok, bud what would I need to change to make it work with mi Content type and content Type fields in this file?

/* All You need to is to Modify this view to use relevant data
This view will collect the Availability data from your Apartments */

$view = new view();
$view->name = 'flat_availabilty_test2';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'availability_calendar_availability';
$view->human_name = 'Flat ICAL Export';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'iCal availability feed per apartment';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '100';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Availability Calendars: Availability Date */
$handler->display->display_options['fields']['date']['id'] = 'date';
$handler->display->display_options['fields']['date']['table'] = 'availability_calendar_availability';
$handler->display->display_options['fields']['date']['field'] = 'date';
$handler->display->display_options['fields']['date']['label'] = '';
$handler->display->display_options['fields']['date']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['date']['alter']['text'] = 'DTEND;VALUE=DATE:[date]
DTSTART;VALUE=DATE:[date]
UID:N!1[date]@feelathome.co.il
SUMMARY:Not available';
$handler->display->display_options['fields']['date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['date']['date_format'] = 'ical';
$handler->display->display_options['fields']['date']['timezone'] = 'UTC';
/* Contextual filter: Availability Calendars: Node ID */
$handler->display->display_options['arguments']['entity_id']['id'] = 'entity_id';
$handler->display->display_options['arguments']['entity_id']['table'] = 'field_data_field_calendar';
$handler->display->display_options['arguments']['entity_id']['field'] = 'entity_id';
$handler->display->display_options['arguments']['entity_id']['default_action'] = 'default';
$handler->display->display_options['arguments']['entity_id']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['entity_id']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['entity_id']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['entity_id']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Availability Calendars: Availability Status ID */
$handler->display->display_options['filters']['sid']['id'] = 'sid';
$handler->display->display_options['filters']['sid']['table'] = 'availability_calendar_availability';
$handler->display->display_options['filters']['sid']['field'] = 'sid';
$handler->display->display_options['filters']['sid']['operator'] = '!=';
$handler->display->display_options['filters']['sid']['value']['value'] = '2';
/* Filter criterion: Content: Availability Calendar enabled */
$handler->display->display_options['filters']['field_calendar_enabled']['id'] = 'field_calendar_enabled';
$handler->display->display_options['filters']['field_calendar_enabled']['table'] = 'field_data_field_calendar';
$handler->display->display_options['filters']['field_calendar_enabled']['field'] = 'field_calendar_enabled';
$handler->display->display_options['filters']['field_calendar_enabled']['value'] = '1';

/* Display: iCal availability feed per apartment */
$handler = $view->new_display('feed', 'iCal availability feed per apartment', 'feed_1');
$handler->display->display_options['display_description'] = 'Supplies an iCal feed (ics file) for each apartment';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'views_ical';
$handler->display->display_options['row_plugin'] = 'views_ical';
$handler->display->display_options['path'] = 'apartment/%/iCal/feed.ics';
$handler->display->display_options['sitename_title'] = 0;
$translatables['flat_availabilty_test2'] = array(
t('Master'),
t('iCal availability feed per apartment'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('DTEND;VALUE=DATE:[date]
DTSTART;VALUE=DATE:[date]
UID:N!1[date]@feelathome.co.il
SUMMARY:Not available'),
t('All'),
t('Supplies an iCal feed (ics file) for each apartment'),
);

caw67’s picture

with the version 5 the sandbox module http://drupal.org/sandbox/mosheeshel/1913944 do not work anymore...
can you integrate it in a new version of availibilty? because you have also views and entity

fietserwin’s picture

Status: Needs review » Fixed

I started working again on ical integration and as far as I can see the moshe's sandbox does no longer add any feature not already in A.C. itself. So I will close this issue as fixed. Regarding importing feeds, that's a different story. Other contrib modules I found so far and that could be helpful, are no longer maintained, do not work on PHP7, etc. So that will require additional effort from my side and I can't give any guarantee about that happening soon.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fietserwin’s picture

I just released 7.x-5.7 with iCal import and export support. See the readme.txt for how to set it up.