You are here

function heartbeat_menu in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 heartbeat.module \heartbeat_menu()
  2. 6.2 heartbeat.module \heartbeat_menu()
  3. 6.3 heartbeat.module \heartbeat_menu()

Implements hook_menu().

File

./heartbeat.module, line 142
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_menu() {
  $items = array();

  // Menu page callbacks for each heartbeat stream.
  $streams = heartbeat_stream_config_load_all(TRUE);
  foreach ($streams as $class => $stream) {
    if (!empty($stream->stream_path)) {
      $items[$stream->stream_path] = array(
        'title' => $stream->title,
        'description' => $stream->name . ' page',
        'page callback' => 'heartbeat_messages_page',
        'page arguments' => array(
          $stream->class,
        ),
        'access callback' => 'heartbeat_stream_has_access',
        'access arguments' => array(
          $stream->class,
        ),
        'file' => 'heartbeat.pages.inc',
        'type' => MENU_CALLBACK,
      );
    }
    if (!empty($stream->stream_profile_path)) {
      $items['user/%user/' . $stream->stream_profile_path] = array(
        'title' => $stream->title,
        'page callback' => 'heartbeat_messages_page',
        'page arguments' => array(
          $stream->class,
          '0',
          1,
        ),
        'access callback' => 'heartbeat_stream_has_access',
        'access arguments' => array(
          $stream->class,
        ),
        'type' => MENU_LOCAL_TASK,
        'file' => 'heartbeat.pages.inc',
        'weight' => 50,
      );
    }
  }

  // Display one activity entity.
  $items['heartbeat/message/%heartbeat_activity'] = array(
    'title' => 'Single message',
    'description' => 'Activity message',
    'page callback' => 'heartbeat_message_activity',
    'page arguments' => array(
      2,
    ),
    'access callback' => '_heartbeat_message_has_access',
    'access arguments' => array(
      2,
    ),
    'file' => 'heartbeat.pages.inc',
  );

  // Ajax driven callback to delete activity
  $items['heartbeat/%ctools_js/activity/delete/%heartbeat_activity'] = array(
    'title' => 'Delete activity',
    'page callback' => 'heartbeat_activity_modal_delete',
    'page arguments' => array(
      1,
      4,
    ),
    'access callback' => '_heartbeat_message_delete_access',
    'access arguments' => array(
      4,
    ),
    'file' => 'heartbeat.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['heartbeat/js/poll'] = array(
    'page callback' => 'heartbeat_activity_poll',
    'access callback' => 'user_access',
    'access arguments' => array(
      'view heartbeat messages',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'heartbeat.pages.inc',
  );
  $items['heartbeat/js/older'] = array(
    'page callback' => 'heartbeat_activity_older',
    'access callback' => 'user_access',
    'access arguments' => array(
      'view heartbeat messages',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'heartbeat.pages.inc',
  );
  return $items;
}