You are here

function mongodb_block_ui_custom_block_delete_submit in MongoDB 7

Deletion of custom mongodb_block_uis.

File

mongodb_block_ui/mongodb_block_ui.admin.inc, line 535
Admin page callbacks for the mongodb_block_ui module.

Code

function mongodb_block_ui_custom_block_delete_submit($form, &$form_state) {

  // Remove the custom block.
  mongodb_collection('block_custom')
    ->remove(array(
    '_id' => $form_state['values']['delta'],
  ), mongodb_default_write_options());

  // Also remove customization for every theme.
  $id = array(
    'module' => $form_state['values']['module'],
    'delta' => $form_state['values']['delta'],
  );
  foreach (list_themes() as $theme) {
    mongodb_collection('block_customized', $theme->name)
      ->remove(array(
      '_id' => $id,
    ), mongodb_default_write_options());
  }
  drupal_set_message(t('The block %name has been removed.', array(
    '%name' => $form_state['values']['info'],
  )));
  cache_clear_all();
  $form_state['redirect'] = 'admin/structure/mongodb_block';
}