You are here

commons_shoutbox.module in Drupal Commons 6.2

File

modules/features/commons_shoutbox/commons_shoutbox.module
View source
<?php

include_once 'commons_shoutbox.features.inc';

/**
 * Implementation of hook_og_features_registry()
 */
function commons_shoutbox_og_features_registry() {
  $registry = array();

  // Feature: commons_shoutbox
  $feature = new stdClass();
  $feature->id = 'commons_shoutbox';
  $feature->name = t('Shoutbox');
  $feature->description = t('Enable your users to post short messages to each other without creating a complete new page, and see (almost) live updates from other users.');
  $feature->components = array(
    'path' => array(
      'node/%node/shoutbox',
      'shoutbox/group/%node',
      'shoutbox/group/%node/js/view',
    ),
    'context' => array(
      'group-home-shoutbox',
    ),
    'og link' => array(
      'shoutbox',
    ),
  );
  $registry[$feature->id] = $feature;
  return $registry;
}

/**
 * Implementation of hook_menu_alter()
 */
function commons_shoutbox_menu_alter(&$items) {

  // Change the path of the group shoutbox page
  // so og_features can extract the group context
  $items['node/%node/shoutbox'] = $items['shoutbox/group/%node'];
  $items['node/%node/shoutbox']['page arguments'] = array(
    1,
  );
  $items['node/%node/shoutbox']['access arguments'] = array(
    'view',
    1,
  );
  unset($items['shoutbox/group/%node']);
}

/**
 * Implementation of hook_og_links_alter()
 */
function commons_shoutbox_og_links_alter(&$links) {

  // Remove the shoutbox link from this menu because
  // the block already provides it
  unset($links['shoutbox']);
}

/**
 * Implementation of hook_shoutbox()
 */
function commons_shoutbox_shoutbox($op, &$shout, &$a1 = NULL, $form_state = NULL) {
  switch ($op) {
    case 'link':

      // Change the "view all shouts" link to our new path
      if ($group = og_get_group_context()) {
        $a1 = "node/{$group->nid}/shoutbox";
      }
      break;
  }
}

Functions

Namesort descending Description
commons_shoutbox_menu_alter Implementation of hook_menu_alter()
commons_shoutbox_og_features_registry Implementation of hook_og_features_registry()
commons_shoutbox_og_links_alter Implementation of hook_og_links_alter()
commons_shoutbox_shoutbox Implementation of hook_shoutbox()