You are here

function fullcalendar_update in FullCalendar 6.2

Same name and namespace in other branches
  1. 6 fullcalendar.module \fullcalendar_update()
  2. 7.2 fullcalendar.module \fullcalendar_update()
  3. 7 fullcalendar.module \fullcalendar_update()

Saves the updated FullCalendar event's datetime.

Parameters

$action: Value can be 'drop' or 'resize'.

$node: The node that will be updated.

1 string reference to 'fullcalendar_update'
fullcalendar_menu in ./fullcalendar.module
Implementation of hook_menu().

File

./fullcalendar.module, line 97
Provides a views style plugin for FullCalendar

Code

function fullcalendar_update($action, $node) {

  // Retrieve the post vars form the ajax call.
  $field = $_POST['field'];
  $index = $_POST['index'];
  $dom_id = $_POST['dom_id'];
  $all_day = isset($_POST['all_day']) ? $_POST['all_day'] : '';
  $day_delta = $_POST['day_delta'];
  $minute_delta = $_POST['minute_delta'];
  if (!empty($field) && isset($index)) {
    $old_start = $node->{$field}[$index]['value'];
    $old_end = $node->{$field}[$index]['value2'];
    switch ($action) {
      case 'drop':
        $node->{$field}[$index]['value'] = date('Y-m-d H:i:s', strtotime($old_start . ' ' . $day_delta . ' days ' . $minute_delta . ' minutes'));
        $node->{$field}[$index]['value2'] = date('Y-m-d H:i:s', strtotime($old_end . ' ' . $day_delta . ' days ' . $minute_delta . ' minutes'));
        break;
      case 'resize':
        $node->{$field}[$index]['value2'] = date('Y-m-d H:i:s', strtotime($old_end . ' ' . $day_delta . ' days ' . $minute_delta . ' minutes'));
        break;
    }

    // Save the new start/end values.
    node_save($node);
    drupal_json(array(
      'msg' => t('The new event time has been saved.') . ' [' . l(t('Close'), NULL, array(
        'attributes' => array(
          'class' => 'fullcalendar-status-close',
        ),
      )) . ']',
      'dom_id' => $dom_id,
    ));
  }
}