function fullcalendar_update in FullCalendar 7
Same name and namespace in other branches
- 6.2 fullcalendar.module \fullcalendar_update()
- 6 fullcalendar.module \fullcalendar_update()
- 7.2 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 - Implements hook_menu().
File
- ./
fullcalendar.module, line 120 - 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'];
$all_day = isset($_POST['all_day']) ? $_POST['all_day'] : '';
$day_delta = $_POST['day_delta'];
$minute_delta = $_POST['minute_delta'];
if (!empty($field) && isset($index)) {
$langcode = field_language('node', $node, $field);
$old_start = $node->{$field}[$langcode][$index]['value'];
$old_end = $node->{$field}[$langcode][$index]['value2'];
switch ($action) {
case 'drop':
$node->{$field}[$langcode][$index]['value'] = date('Y-m-d H:i:s', strtotime($old_start . ' ' . $day_delta . ' days ' . $minute_delta . ' minutes'));
$node->{$field}[$langcode][$index]['value2'] = date('Y-m-d H:i:s', strtotime($old_end . ' ' . $day_delta . ' days ' . $minute_delta . ' minutes'));
break;
case 'resize':
$node->{$field}[$langcode][$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_output(array(
'msg' => 'The new event time has been saved. [<a href="javascript:void(0);" class="fullcalendar-status-close">close</a>]',
));
}
}