You are here

function spaces_dashboard_editor in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_editor()
  2. 7.3 spaces_dashboard/spaces_dashboard.module \spaces_dashboard_editor()

Form builder: spaces dashboard editor. Clones and overrides form built by context_ui_editor().

1 string reference to 'spaces_dashboard_editor'
spaces_dashboard_block_view in spaces_dashboard/spaces_dashboard.module
Implements hook_block_view().

File

spaces_dashboard/spaces_dashboard.module, line 307

Code

function spaces_dashboard_editor($form, &$form_state, $contexts) {
  if ($context = context_get('spaces', 'dashboard')) {
    context_set('spaces_dashboard', 'form_build', TRUE);

    // Clone the context_ui_editor form and make some changes.
    $form = context_ui_editor($form, $form_state, $contexts);
    unset($form['contexts'][$context]['#type']);

    // Hide conditions.
    $form['contexts'][$context]['condition']['#access'] = FALSE;

    // Hide reactions other than blocks.
    foreach (array_keys(context_reactions()) as $reaction) {
      if ($reaction !== 'block' && isset($form['contexts'][$context]["reaction-{$reaction}"])) {
        $form['contexts'][$context]["reaction-{$reaction}"]['#access'] = FALSE;
      }
    }

    // Alter allowed layouts
    if (module_exists('context_layouts')) {
      $layouts = variable_get('spaces_dashboard_layouts', array());
      if (!empty($layouts) && isset($form['contexts'][$context]['reaction-block']['layout'])) {
        $layouts = array_filter($layouts);
        $layouts[0] = 1;
        $form['contexts'][$context]['reaction-block']['layout']['layout']['#options'] = array_intersect_key($form['contexts'][$context]['reaction-block']['layout']['layout']['#options'], $layouts);
      }
    }

    // We need to call this alter manually against our form.
    if (module_exists('spaces') && ($space = spaces_get_space())) {
      spaces_form_context_ui_editor_alter($form, $form_state);
    }
  }
  return $form;
}