You are here

function block_aria_landmark_roles_form_submit in Block ARIA Landmark Roles 7

Same name and namespace in other branches
  1. 6 block_aria_landmark_roles.module \block_aria_landmark_roles_form_submit()
  2. 7.2 block_aria_landmark_roles.module \block_aria_landmark_roles_form_submit()

Form submission handler for the ARIA landmark role.

Saves the data to the block_aria_landmark_roles table.

1 string reference to 'block_aria_landmark_roles_form_submit'
block_aria_landmark_roles_form_alter in ./block_aria_landmark_roles.module
Implements hook_form_alter().

File

./block_aria_landmark_roles.module, line 61
Adds additional elements on block administration forms to add ARIA landmark roles.

Code

function block_aria_landmark_roles_form_submit($form, &$form_state) {
  if (user_access('administer blocks')) {
    $module = $form_state['values']['module'];
    $delta = $form_state['values']['delta'];

    // ARIA Labels.
    if (isset($form_state['values']['aria_label'])) {
      $label = $form_state['values']['aria_label'];

      // Delete any existing label.
      db_delete('block_aria_landmark_roles_label')
        ->condition('module', $module)
        ->condition('delta', $delta)
        ->execute();

      // Save the new label.
      if (!empty($form_state['values']['aria_label'])) {
        db_insert('block_aria_landmark_roles_label')
          ->fields(array(
          'module' => $module,
          'delta' => $delta,
          'label' => $label,
        ))
          ->execute();
      }
    }

    // ARIA Landmark roles.
    if (isset($form_state['values']['role'])) {
      $role = $form_state['values']['role'];

      // Delete any existing role.
      db_delete('block_aria_landmark_roles')
        ->condition('module', $module)
        ->condition('delta', $delta)
        ->execute();

      // Save the new role.
      if (!empty($form_state['values']['role'])) {
        db_insert('block_aria_landmark_roles')
          ->fields(array(
          'module' => $module,
          'delta' => $delta,
          'role' => $role,
        ))
          ->execute();
      }
    }
  }
}