You are here

function availability_calendars_page in Availability Calendars 6

Same name and namespace in other branches
  1. 5 availability_calendars.module \availability_calendars_page()

Availability calendars page.

Parameters

int $nid:

int $year:

int $month:

boolean $edit:

Return value

string

1 string reference to 'availability_calendars_page'
availability_calendars_menu in ./availability_calendars.module
Implementation of hook_menu().

File

./availability_calendars.module, line 176
Availability Calendars Module.

Code

function availability_calendars_page($nid = NULL, $year = NULL, $month = NULL, $edit = FALSE) {
  $settings = availability_calendar_getsettings();
  if (is_numeric($nid)) {
    $node = node_load($nid);
    drupal_set_title(t('Availability for %name', array(
      '%name' => $node->title,
    )));
    if (is_numeric($year) && is_numeric($month)) {

      // #1093408: Summer/winter time offsets: don't use midnight sharp
      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'),
      )));
      if ($edit == 'edit') {

        // Display the edit form for the availability calendar on the node
        return availability_calendars_node_edit($node, $year, $month);
      }
      else {

        // Display availability calendar for single month
        $monthstodisplay = 1;
        return theme('availability_calendars_node', $node, $year, $month, $monthstodisplay);
      }
    }
    elseif (is_numeric($year)) {

      // Display availability calendar for a whole year
      $month = 1;
      $monthstodisplay = 12;
      return theme('availability_calendars_node', $node, $year, $month, $monthstodisplay);
    }
    else {

      // Display rolling availability calendar from this point onwards
      $year = date('Y');
      $month = date('m');
      $monthstodisplay = $settings->monthcount;
      return theme('availability_calendars_node', $node, $year, $month, $monthstodisplay);
    }
  }
  else {
    print drupal_not_found();
  }
}