You are here

function ddblock_block_confirm_delete_form in Dynamic display block 7

Same name and namespace in other branches
  1. 6 ddblock.admin.inc \ddblock_block_confirm_delete_form()

Delete block form.

1 string reference to 'ddblock_block_confirm_delete_form'
ddblock_menu in ./ddblock.module
Implements hook_menu().

File

./ddblock.admin.inc, line 173
admin blocks of the ddblock module.

Code

function ddblock_block_confirm_delete_form($form, &$form_state, $delta) {
  $block = ddblock_get_blocks($delta);
  if (empty($block)) {
    drupal_set_message(t('The block with delta @delta was not found.', array(
      '@delta' => $delta,
    )), 'error');
    return array();
  }
  else {
    if ($block->enabled == 1) {

      //The question to ask the user.
      $question = t('Are you sure you want to delete the dynamic display block instance %title?', array(
        '%title' => $block->title,
      ));
    }
    else {

      //The question to ask the user.
      $question = t('Are you sure you want to delete the dynamic display block %title?', array(
        '%title' => $block->title,
      ));
    }

    // The page to go to if the user denies the action.
    $path = 'admin/structure/ddblock';

    // Additional text to display (defaults to "This action cannot be undone.").
    $description = t('This action cannot be undone.');

    // A caption for the button which confirms the action.
    $yes = t('Delete');

    // A caption for the link which denies the action.
    $no = t('Cancel');

    // set delta value to use in submit function.
    $form['delta'] = array(
      '#type' => 'value',
      '#value' => $delta,
    );

    // set original module value to use in submit function.
    $form['origin'] = array(
      '#type' => 'value',
      '#value' => $block->module,
    );

    // set the redirect path value to use in submit function.
    $form_state['redirect'] = $path;
    return confirm_form($form, $question, $path, $description, $yes, $no);
  }
}