function bat_fullcalendar_configure in Booking and Availability Management Tools for Drupal 7
Same name and namespace in other branches
- 8 modules/bat_fullcalendar/bat_fullcalendar.module \bat_fullcalendar_configure()
Fullcalendar settings.
Parameters
array $user_settings:
Return value
array
1 call to bat_fullcalendar_configure()
- theme_bat_fullcalendar in modules/
bat_fullcalendar/ bat_fullcalendar.module - Theme function for FullCalendar.
File
- modules/
bat_fullcalendar/ bat_fullcalendar.module, line 486 - Manages the display of FullCalendar and provides ways for other modules to easily modify it.
Code
function bat_fullcalendar_configure($user_settings) {
global $language;
$settings = array();
foreach ($user_settings['batCalendar'] as $id => $user_setting) {
// Set the scheduler license.
$schedulerlicense = variable_get('bat_fullcalendar_scheduler_key', '');
switch ($schedulerlicense) {
case 'gpl':
$schedulerlicensekey = 'GPL-My-Project-Is-Open-Source';
break;
case 'non-commercial':
$schedulerlicensekey = 'CC-Attribution-NonCommercial-NoDerivatives';
break;
case 'commercial':
$schedulerlicensekey = variable_get('bat_fullcalendar_scheduler_commercial_key', '');
break;
case 'none':
$schedulerlicensekey = '';
break;
default:
$schedulerlicensekey = '';
break;
}
$calendar_views = 'timelineDay, timelineTenDay, timelineMonth, timelineYear';
$default_view = 'timelineDay';
if ($user_setting['eventGranularity'] == 'bat_daily') {
$calendar_views = 'timelineThirtyDay, timelineYear';
$default_view = 'timelineThirtyDay';
$default_date = (new DateTime())
->modify('-5 days')
->format('Y-m-d');
}
elseif ($user_setting['eventGranularity']) {
$calendar_views = 'timelineDay, timelineTenDay, timelineMonth';
$default_view = 'timelineDay';
$default_date = (new DateTime())
->format('Y-m-d');
}
if (isset($user_setting['views']) && !empty($user_setting['views'])) {
$calendar_views = $user_setting['views'];
}
if (isset($user_setting['defaultView']) && !empty($user_setting['defaultView'])) {
$default_view = $user_setting['defaultView'];
}
$business_hours = array(
'start' => '00:00',
'end' => '24:00',
'dow' => array(
0,
1,
2,
3,
4,
5,
6,
),
);
$config = array(
'schedulerLicenseKey' => $schedulerlicensekey,
'themeSystem' => 'standard',
'unitType' => '',
'eventType' => '',
'grouping_entity_type' => '',
'grouping_ids' => '',
'collapse_childrens' => 0,
'eventGranularity' => $user_setting['eventGranularity'],
'locale' => $language->language,
'slotWidth' => FALSE,
'calendarHeight' => 500,
'editable' => TRUE,
'selectable' => TRUE,
'eventStartEditable' => TRUE,
'eventDurationEditable' => TRUE,
'headerLeft' => 'prev, today, datepicker, next',
'headerCenter' => 'title',
'headerRight' => $calendar_views,
'views' => $calendar_views,
'defaultView' => $default_view,
'viewsTimelineDayButtonText' => ':15 slots',
'viewsTimelineDaySlotDuration' => '00:15',
'viewsTimelineDaySlotLabelFormat' => FALSE,
'viewsTimelineDayTitleFormat' => '',
'viewsTimelineSevenDayButtonText' => '7 days',
'viewsTimelineSevenDayDuration' => array(
'days' => 7,
),
'viewsTimelineSevenDaySlotDuration' => '01:00',
'viewsTimelineSevenDayTitleFormat' => '',
'viewsTimelineSevenDaySlotLabelFormat' => FALSE,
'viewsTimelineTenDayButtonText' => '10 days',
'viewsTimelineTenDayDuration' => array(
'days' => 10,
),
'viewsTimelineTenDaySlotDuration' => '01:00',
'viewsTimelineTenDaySlotLabelFormat' => FALSE,
'viewsTimelineTenDayTitleFormat' => '',
'viewsTimelineThirtyDayButtonText' => '30 days',
'viewsTimelineThirtyDayDuration' => array(
'days' => 30,
),
'viewsTimelineThirtyDaySlotDuration' => '01:00',
'viewsTimelineThirtyDaySlotLabelFormat' => FALSE,
'viewsTimelineThirtyDayTitleFormat' => '',
'viewsTimeline365DayButtonText' => '1 year',
'viewsTimeline365DayDuration' => array(
'days' => 365,
),
'viewsTimeline365DaySlotLabelFormat' => FALSE,
'viewsTimeline365DayTitleFormat' => '',
'viewsAgendaOneDayButtonText' => 'day',
'viewsAgendaOneDayDuration' => array(
'days' => 1,
),
'viewsAgendaSevenDayButtonText' => 'week',
'viewsAgendaSevenDayDuration' => array(
'days' => 7,
),
'resourceAreaWidth' => '25%',
'resourceLabelText' => t('Types'),
'errorMessage' => t('Action not allowed. User may not have the right permissions.'),
'businessHours' => $business_hours,
'selectConstraint' => NULL,
'scrollTime' => '06:00:00',
'minTime' => '00:00:00',
'maxTime' => '24:00:00',
'hiddenDays' => array(),
'validRange' => NULL,
'defaultDate' => $default_date,
'repeatEventTitle' => TRUE,
'showBackgroundEventTitle' => FALSE,
'enableModal' => TRUE,
'customButtons' => array(),
'eventOrder' => 'title',
'titleFormat' => '',
'slotLabelFormat' => FALSE,
'defaultTimedEventDuration' => '00:00:00',
'selectAllowBusinessHours' => FALSE,
'groupByResource' => FALSE,
'groupByDateAndResource' => FALSE,
'allDaySlot' => TRUE,
'hideResourceTypes' => FALSE,
'firstDay' => 0,
'viewsAgendaButtonText' => '',
'viewsWeekButtonText' => '',
'viewsDayButtonText' => '',
'allDayDefault' => NULL,
);
$settings['batCalendar'][$id] = array_replace_recursive($config, $user_setting);
// Allow other modules to alter further.
drupal_alter('bat_calendar_settings', $settings);
}
date_popup_add();
return $settings;
}