You are here

function boxes_form_block_admin_display_form_alter in Boxes 7

Same name and namespace in other branches
  1. 6 boxes.module \boxes_form_block_admin_display_form_alter()

Alters the block admin form to add delete links next to boxes blocks.

File

./boxes.module, line 599
Core functionality for boxes module.

Code

function boxes_form_block_admin_display_form_alter(&$form, $form_state) {
  foreach (element_children($form['blocks']) as $i) {
    if (isset($form['blocks'][$i]['module']['#value']) && $form['blocks'][$i]['module']['#value'] == 'boxes') {
      $delta = $form['blocks'][$i]['delta']['#value'];
      if (strpos($delta, 'boxes_add__') !== 0) {
        $box = boxes_box_load($delta);
        if ($box->export_type & EXPORT_IN_DATABASE && $box->export_type & EXPORT_IN_CODE) {
          $form['blocks'][$i]['delete'] = array(
            '#title' => t('revert'),
            '#type' => 'link',
            '#href' => 'admin/structure/block/manage/boxes/' . $delta . '/delete',
          );
        }
        elseif (!($box->export_type & EXPORT_IN_CODE)) {
          $form['blocks'][$i]['delete'] = array(
            '#title' => t('delete'),
            '#type' => 'link',
            '#href' => 'admin/structure/block/manage/boxes/' . $delta . '/delete',
          );
        }
      }
    }
  }
}