You are here

function oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete::exposed_form in Open Atrium Core 7.2

File

plugins/views/oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete.inc, line 71
Code to override field to add in auto option.

Class

oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete
@file Code to override field to add in auto option.

Code

function exposed_form(&$form, &$form_state) {
  parent::exposed_form($form, $form_state);
  global $user;
  $exposed = $this->view
    ->get_exposed_input();

  // just call OG for spaces, we don't care about subspaces
  // really we just need a count, but at least this doesn't load every space
  $full_user = user_load($user->uid);
  $groups = field_get_items('user', $full_user, 'og_user_node');

  // check is to check if part of any spaces.
  if (($id = $this->options['expose']['identifier']) && $groups) {
    $form[$id . '_mine'] = array(
      '#title' => t('My Spaces'),
      '#default_value' => 0,
      '#type' => 'checkbox',
    );
    if (!empty($exposed[$id . '_mine'])) {
      $form[$id]['#access'] = FALSE;

      // Need to set it here else the value is ignored when access is FALSE.
      if (!empty($exposed[$id])) {
        $form[$id] = array(
          '#type' => 'value',
          '#value' => $exposed[$id],
        );
      }
    }
  }
}