1 layout.admin.inc layout_block_disable_page(Layout $layout, Block $block, $renderer_name)

Menu callback; Set a block as disabled.

File

core/modules/layout/layout.admin.inc, line 1968
Admin page callbacks for the Layout module.

Code

function layout_block_disable_page(Layout $layout, Block $block, $renderer_name) {
  if (backdrop_get_token('layout-' . $layout->name) !== $_GET['token']) {
    return MENU_ACCESS_DENIED;
  }

  $uuid = $block->uuid;
  $layout->content[$uuid]->status = $block->status ? BLOCK_DISABLED : BLOCK_ENABLED;
  layout_set_layout_tempstore($layout);

  $renderer = layout_create_renderer($renderer_name, $layout);
  $replace_block = $renderer->renderBlock($block);

  if (backdrop_is_ajax()) {
    if ($message = layout_locked_message($layout, 'layout')) {
      backdrop_set_message($message, 'warning');
      $commands[] = ajax_command_remove('#messages');
      $commands[] = ajax_command_html('#layout-messages', theme('status_messages'));
    }

    $commands[] = ajax_command_replace('#layout-editor-block-' . $block->uuid, $replace_block);
    return array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
  }
  else {
    backdrop_set_message(t('Block "@title" disabled.', array('@title' => $block->getAdminTitle())));
    backdrop_goto('admin/structure/layouts/manage/' . $layout->name);
  }

}