diff --git a/bean.install b/bean.install index 837a0d7..b8ae0dc 100644 --- a/bean.install +++ b/bean.install @@ -229,6 +229,7 @@ function bean_uninstall() { variable_del('bean_ctools_separate'); variable_del('bean_ctools_prefix'); variable_del('bean_usage_results_per_page'); + variable_del('bean_config_blocks'); // Remove all variables for field bundle settings. db_delete('variable') ->condition('name', 'field_bundle_settings_bean%', 'LIKE') diff --git a/bean.module b/bean.module index 4c05d18..2a222c0 100644 --- a/bean.module +++ b/bean.module @@ -100,11 +100,58 @@ function bean_entity_info() { } /** + * Implements hook_form(). + */ +function bean_config_blocks_form($form, &$form_state) { + $beans = bean_get_all_beans(); + if ($beans) { + $options = array(); + foreach ($beans as $bean) { + $options[$bean->delta] = $bean->adminTitle() . '( ' . $bean->getInfo('cache_level') . ' )'; + } + $form['bean_config_blocks'] = array( + '#type' => 'checkboxes', + '#options' => $options, + '#title' => t('Select the block that you want to disable it'), + '#description' => t('This page enables you to create bean as entity type with add block for it'), + '#default_value' => variable_get('bean_config_blocks', array()) + ); + $form = system_settings_form($form); + $form['#submit'][] = 'bean_config_blocks_clear_cache'; + } + else { + $form['empty']['#markup'] = t('There are no Block Available'); + } + + return $form; +} + +/** + * Submit handler to clear block cache. + * + * @see bean_config_blocks_form. + */ +function bean_config_blocks_clear_cache($form, &$form_state){ + //Clear cache block in order to refresh the table blocks in database + cache_clear_all(NULL, 'cache_block'); +} + +/** * Implements hook_menu(). */ function bean_menu() { $items = array(); + $items['admin/content/config-blocks'] = array( + 'title' => 'Disable/Enable block', + 'description' => 'Bean Disable Enable blocks', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('bean_config_blocks_form'), + 'access arguments' => array('bean_access'), + 'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM, + ); + + $items['block/add'] = array( 'title' => 'Add Block', 'page callback' => 'bean_add_page', @@ -867,11 +914,14 @@ function bean_block_info() { $blocks = array(); $beans = bean_get_all_beans(); + $bean_config_blocks = variable_get('bean_config_blocks', array()); foreach ($beans as $bean) { - $blocks[$bean->delta] = array( - 'info' => $bean->adminTitle(), - 'cache' => $bean->getInfo('cache_level'), - ); + if (isset($bean_config_blocks[$bean->delta]) and $bean_config_blocks[$bean->delta] !== $bean->delta) { + $blocks[$bean->delta] = array( + 'info' => $bean->adminTitle(), + 'cache' => $bean->getInfo('cache_level'), + ); + } } cache_set('bean_block_info', $blocks, 'cache');