function calendar_date_default_argument_alter in Calendar 7.3
Same name and namespace in other branches
- 8 calendar.module \calendar_date_default_argument_alter()
Implements hook_date_default_argument_alter().
Adjust the default date for a view based on the stored session value.
File
- ./
calendar.module, line 116 - Adds calendar filtering and displays to Views.
Code
function calendar_date_default_argument_alter(&$argument, &$value) {
global $user;
$style_options = $argument->view->display_handler
->get_option('style_options');
$tracking = variable_get('calendar_track_date', 0);
if (!empty($tracking) && ($tracking == 2 || !empty($user->uid))) {
// If this is a default date, i.e. we are visiting a new calendar display,
// set the default date for the display. See if we already have a session
// date to use. If so, use it. Otherwise the default is the current date.
if (!empty($_SESSION[$argument->view->name]['default_date'])) {
$default_date = $_SESSION[$argument->view->name]['default_date'];
}
else {
$default_date = date_now();
$_SESSION[$argument->view->name]['default_date'] = $default_date;
}
// Get the current date from the session.
$value = $default_date
->format($argument->arg_format);
}
}