You are here

function bat_fullcalendar_bat_fullcalendar_modal_content in Booking and Availability Management Tools for Drupal 7

Same name and namespace in other branches
  1. 8 modules/bat_fullcalendar/bat_fullcalendar.module \bat_fullcalendar_bat_fullcalendar_modal_content()

Implements hook_bat_fullcalendar_modal_content().

File

modules/bat_fullcalendar/bat_fullcalendar.module, line 120
Manages the display of FullCalendar and provides ways for other modules to easily modify it.

Code

function bat_fullcalendar_bat_fullcalendar_modal_content($entity_id, $event_type, $event_id, $start_date, $end_date) {
  if ($event_id > 0) {

    // For existing events allow to edit in the modal.
    module_load_include('inc', 'bat_event', 'bat_event.admin');
    $event = bat_event_load($event_id);
    $form_state = array(
      'title' => t('Edit event'),
      'ajax' => TRUE,
      'build_info' => array(
        'args' => array(
          $event,
        ),
        'files' => array(
          'bat_event' => array(
            'module' => 'bat_event',
            'name' => 'bat_event.admin',
            'type' => 'inc',
          ),
        ),
      ),
    );

    // Wrap the form via ctools modal.
    $output = ctools_modal_form_wrapper('bat_event_edit_form', $form_state);
    if ($form_state['executed']) {
      if (!empty($form_state['event_deleted'])) {

        // If there are messages for the form, render them.
        $messages = theme('status_messages');
        $output = array();

        // If the form has not yet been rendered, render it.
        $output[] = ctools_modal_command_display(t('Event deleted'), $messages);
      }
      else {
        $output = array(
          ctools_modal_command_dismiss(),
        );
      }
    }
    return array(
      'bat_fullcalendar' => array(
        'commands' => $output,
      ),
    );
  }
  return array(
    'bat_fullcalendar' => array(
      'title' => t('Event Management'),
      'content' => drupal_get_form('bat_fullcalendar_event_manager_form', $entity_id, $event_type, $event_id, $start_date, $end_date),
    ),
  );
}