function oa_core_form_views_exposed_form_alter in Open Atrium Core 7.2
Implements hook_form_FORM_ID_alter().
File
- ./
oa_core.module, line 1332
Code
function oa_core_form_views_exposed_form_alter(&$form, &$form_state) {
if (_oa_core_set_default_value_for_view($form_state['view']->name) && $form_state['view']->display_handler
->get_url() != $_GET['q']) {
// Change exposed form to submit to given page instead of redirecting to
// view all.
$form['#action'] = url($_GET['q']);
}
if (!empty($form['og_group_ref_target_id'])) {
$form['#after_build'][] = 'oa_core_views_exposed_form_rearrange';
}
// If a Space was chosen, and we have a Section selector - then we need to
// change the available options to be the Sections in that Space (rather
// than the current Space). This is necessary to make the customizations
// work that were done in:
// oa_core_form_views_content_views_panes_content_type_edit_form_alter()
// Otherwise you'll get the 'An illegal choice has been detected.' message
// when selecting a Section in another Space.
if (!empty($form_state['input']['og_group_ref_target_id']) && !empty($form['oa_section_ref_target_id'])) {
$view = $form_state['view'];
$exposed_form_overrides = $view->display_handler
->get_option('exposed_form_overrides');
$pane_conf = $view->display_handler
->get_option('pane_conf');
$bypass_access = FALSE;
if (isset($exposed_form_overrides['filters']['oa_section_ref_target_id'])) {
// filter is available on panel pane config form
if (empty($exposed_form_overrides['filters']['oa_section_ref_target_id']) || isset($pane_conf['show_exposed_form']) && empty($pane_conf['show_exposed_form'])) {
// if field is not exposed, then bypass access so pane config
// options do not cause "Illegal choice" error on page
// when displaying widgets from private sections
$bypass_access = TRUE;
}
}
$space_id = str_replace(OA_SPACE_CURRENT, oa_core_get_space_context(), $form_state['input']['og_group_ref_target_id']);
$include_archived = user_access('view trash content') || is_numeric($space_id) && og_user_access('node', $space_id, 'view trash content', NULL, FALSE, TRUE);
// reload section option list with sections from given space id
$sections = array(
'' => t('- Active Section -'),
'All' => t('- Any -'),
);
if (is_numeric($space_id)) {
$sections += oa_core_space_sections($space_id, NULL, $bypass_access, array(), $include_archived);
}
$form['oa_section_ref_target_id']['#options'] = $sections;
}
}