function availability_calendars_edit_calendar in Availability Calendars 6.2
Same name and namespace in other branches
- 7.2 availability_calendars.node.inc \availability_calendars_edit_calendar()
Show the availability calendar. (callback for path availability-calendars/%)
Parameters
object $node the node to show the calendar for.:
int|NULL $year the year to show the calendar for. If NULL, show from current month onwards.:
int|NULL $month the month to show the calendar for. If NULL, show the whole year:
boolean $edit Whether to show the edit form for the given year and month?:
Return value
string themed calendar or edit calendar form
1 string reference to 'availability_calendars_edit_calendar'
- availability_calendars_menu in ./
availability_calendars.module - Implements hook_menu().
File
- ./
availability_calendars.node.inc, line 116
Code
function availability_calendars_edit_calendar($node = NULL, $year = NULL, $month = NULL, $edit = FALSE) {
if (is_object($node)) {
drupal_set_title(t('Availability for !name', array(
'!name' => $node->title,
)));
$calendar_node = $node->tnid && $node->tnid != $node->nid ? node_load($node->tnid) : $node;
$settings = availability_calendars_get_settings('node', $calendar_node->nid);
if (is_numeric($year) && is_numeric($month)) {
$settings->monthcount = 1;
}
elseif (is_numeric($year)) {
// Display availability calendar for a whole year
$month = 1;
$settings->monthcount = 12;
}
else {
// Display rolling availability calendar from this point onwards
$year = date('Y');
$month = date('m');
}
if ($edit == 'edit') {
// Display the edit form for the availability calendar on the node.
drupal_set_title(t('Availability for !name in !date', array(
'!name' => $node->title,
'!date' => format_date(mktime(12, 0, 0, $month, 1, $year), 'custom', 'F Y'),
)));
return drupal_get_form('availability_calendars_node_edit_calendar_month_form', $node, $year, $month, $settings);
}
else {
return theme('availability_calendars_node', $calendar_node, $year, $month, $settings);
}
}
else {
print drupal_not_found();
}
}