You are here

function spaces_dashboard_form_alter in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_form_alter()

File

spaces_dashboard/spaces_dashboard.module, line 57

Code

function spaces_dashboard_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'ucreate_user_form':
      if (!($gid = spaces_gid())) {
        context_set('spaces', 'feature', 'group_dashboard');
      }
      break;
    case 'views_filters':

      // Switch nid text filter to a select
      if ($form['view']['#value']->name == 'spaces_group_dashboard') {
        global $user;
        $options = array(
          '**ALL**' => '-- ' . t('All of my groups') . ' --',
        );
        foreach ($user->og_groups as $gid => $group) {
          $options[$gid] = truncate_utf8($group['title'], 30, false, true);
        }
        $form['filter0'] = array(
          '#type' => 'select',
          '#options' => $options,
          '#default_value' => $_GET['filter0'] ? $_GET['filter0'] : '**ALL**',
        );
        $form['#action'] = 'group_dashboard';
      }
      break;
  }
}