You are here

function spaces_dashboard_group_dashboard in Spaces 5.2

Same name and namespace in other branches
  1. 5 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_group_dashboard()

Implements a group dashboard for users in multiple groups TODO: implement "fires" listing

1 string reference to 'spaces_dashboard_group_dashboard'
spaces_dashboard_menu in spaces_dashboard/spaces_dashboard.module

File

spaces_dashboard/spaces_dashboard.module, line 122

Code

function spaces_dashboard_group_dashboard() {
  global $user;
  if ($space = spaces_get_space()) {
    $space
      ->redirect('home');
  }
  else {
    if ($user->uid != 0) {

      // User is a member of many groups, show the dashboard.
      if (count($user->og_groups)) {
        return views_build_view('page', views_get_view('spaces_group_dashboard'), null, true, 25);
      }
      else {

        // Set the context as if the view were built
        context_ui_set('views', 'spaces_group_dashboard');

        // Check whether any 'joinable' groups exist
        $group_count = db_result(db_query("SELECT count(n.nid) FROM {node} n JOIN {og} og ON n.nid = og.nid WHERE n.status = 1 AND og.selective = 0"));

        // There are groups to join
        if ($group_count) {
          $message = t("You are currently not a member of any groups. You can browse the group directory and join groups that interest you.");
          $buttons = l(t('Group Directory'), 'group_dashboard/group_directory', array(
            'class' => 'button',
          ));
        }
        else {

          // User can make groups
          if (node_access('create', $group_types[0])) {
            $message = t("There are currently no groups available for you to join. Please create your first group to get started.");
            $buttons = spaces_node_links();
          }
          else {
            $message = t("You are currently not a member of any groups. Please ask a site administrator to add your account to one of the site's groups.");
          }
        }
        drupal_set_message("<p>{$message}</p><div class='buttons'>{$buttons}</div>");
        return '';
      }
    }
    else {

      // User shouldn't be here.
      drupal_access_denied();
      exit;
    }
  }
}