You are here

function calendar_menu_local_tasks_alter in Calendar 7.3

Implements hook_menu_local_tasks_alter().

Takes the calendar links created in calendar_preprocess_date_views_pager() and reconfigures them as action items. The links can be altered before they are displayed using hook_calendar_links_alter().

File

./calendar.module, line 171
Adds calendar filtering and displays to Views.

Code

function calendar_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if (!empty($_SESSION['calendar_links']) && array_key_exists($root_path, $_SESSION['calendar_links'])) {
    $calendar_data = $_SESSION['calendar_links'][$root_path];
    if (!empty($calendar_data['actions'])) {
      foreach ($calendar_data['actions'] as $action) {
        $item = menu_get_item($action['path']);
        $item['title'] = $action['title'];

        // The add new content page would redirect to the new event
        // if we did not override that here. This way they will
        // redirect back to the calendar.
        if (!isset($item['localized_options'])) {
          $item['localized_options'] = array();
        }
        $item['localized_options'] += array(
          'query' => array(),
        );
        $item['localized_options']['query'] += drupal_get_destination();
        if (array_key_exists('access', $item) && $item['access']) {
          $data['actions']['output'][] = array(
            '#theme' => 'menu_local_action',
            '#link' => $item,
          );
        }
      }
    }
  }
  return;
}