You are here

function block_class_form_submit in Block Class 6

Same name and namespace in other branches
  1. 6.2 block_class.module \block_class_form_submit()
  2. 7.2 block_class.module \block_class_form_submit()
  3. 7 block_class.module \block_class_form_submit()

Handle submission of the Block Class data.

Parameters

array $form: The array of form elements.

array $form_state: The form field data.

1 string reference to 'block_class_form_submit'
block_class_form_alter in ./block_class.module
Implements hook_form_FORM_ID_alter().

File

./block_class.module, line 125
Provides core logic for adding block classes.

Code

function block_class_form_submit($form, &$form_state) {
  if ($form_state['values']['form_id'] == 'block_admin_configure' || $form_state['values']['form_id'] == 'block_add_block_form') {
    if (isset($form_state['values']['css_class']) && user_access('administer blocks')) {
      $module = $form_state['values']['module'];
      $delta = $form_state['values']['delta'];
      $class = $form_state['values']['css_class'];

      // Adding new block (for the "Add Block" form) requires special handling.
      // $delta is null if this is the "Add Block" form.
      if ($form_state['values']['form_id'] == 'block_add_block_form') {
        $last_block = db_last_insert_id('blocks', 'bid');
        $delta = $last_block;
      }
      db_query("DELETE FROM {block_class} WHERE module = '%s' AND delta = '%s'", $module, $delta);
      if (!empty($class)) {
        db_query("INSERT INTO {block_class} (module, delta, css_class) VALUES ('%s', '%s', '%s')", $module, $delta, $class);
      }
    }
  }
}