You are here

function spaces_goto_grouphome in Spaces 5

Given a group id redirect a user to the group home page.

Parameters

$gid: Integer, the nid of the group node.

Return value

Boolean, false if users should be access denied, true if user should fall though. Generally this function will not return and the user will be redirected.

1 call to spaces_goto_grouphome()
spaces_router in ./spaces.module
Consolidated group context routing logic.

File

./spaces.module, line 694

Code

function spaces_goto_grouphome($gid) {
  if ($group_home = spaces_setting('spaces_home', $gid)) {
    if ($group_home == 'pass_thru') {

      // We may be on either the group node or the group homepage --
      // on a group node we want to send the user to the actual homepage
      // in order to "pass through"
      if (arg(0) == 'node') {
        context_prefix_goto('spaces', $gid);
      }
      else {
        return true;
      }
    }
    else {
      $features = spaces_features();

      // use the menu path of selected feature as homepage
      if (is_array($features[$group_home]->menu)) {
        $group_home = array_shift($features[$group_home]->menu);
      }

      // if group has specified a homepage, send to context/homepage
      context_prefix_goto('spaces', $gid, $group_home);
    }
  }
  else {
    if (user_access('administer group features')) {
      drupal_set_message(t("Please setup your group by enabling at least 1 feature and choosing a homepage setting."));
      context_prefix_goto('spaces', $gid, 'node/' . $gid . '/features');
    }
  }
  return false;
}