function addtocal_google_link in Add to Cal 7
Redirects to a Google Calendar event. Called by hook_menu().
Parameters
$entity:
$field_name:
$view_mode:
1 string reference to 'addtocal_google_link'
- addtocal_menu in ./
addtocal.module  - Implements hook_menu().
 
File
- ./
addtocal.module, line 642  - addtocal.module General functions and hook implementations.
 
Code
function addtocal_google_link($entity, $field_name, $view_mode) {
  // Get entity type from the current path
  $entity_type = arg(0);
  list($entity_id) = entity_extract_ids($entity_type, $entity);
  $display = addtocal_get_display($entity, $entity_type, $field_name, $view_mode);
  $info = addtocal_extract_event_info($entity_type, $entity, $entity_id, $field_name, $display);
  $rfc_dates = addtocal_rfc_3339_date($info['start'], $info['end'], $info['timezone']);
  $google_url = url('http://www.google.com/calendar/event', array(
    'query' => array(
      'action' => 'TEMPLATE',
      'text' => $info['title'],
      'dates' => $rfc_dates['both'],
      'sprop' => 'website:' . $_SERVER['HTTP_HOST'],
      'location' => $info['location'],
      'details' => $info['description'],
      'website' => url($info['url'], array(
        'absolute' => TRUE,
      )),
    ),
  ));
  drupal_goto($google_url);
}