? .buildpath ? .project ? .settings ? blockcache_fieldset.patch ? sites/default/files ? sites/default/settings.php Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.32 diff -u -p -r1.32 block.admin.inc --- modules/block/block.admin.inc 16 Dec 2008 23:57:31 -0000 1.32 +++ modules/block/block.admin.inc 26 Jan 2009 20:23:52 -0000 @@ -154,7 +154,7 @@ function block_admin_configure(&$form_st '#value' => $delta, ); - $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {block} WHERE module = '%s' AND delta = '%s'", $module, $delta)); + $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title, cache FROM {block} WHERE module = '%s' AND delta = '%s'", $module, $delta)); $form['block_settings'] = array( '#type' => 'fieldset', @@ -262,7 +262,39 @@ function block_admin_configure(&$form_st '#default_value' => $edit['custom'], ); + // Blockcache options. + $options = array( + BLOCK_NO_CACHE => t('Do not cache'), + BLOCK_CACHE_GLOBAL => t('Cache once for everything (global)'), + BLOCK_CACHE_PER_PAGE => t('Per page'), + BLOCK_CACHE_PER_ROLE => t('Per role'), + BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE => t('Per role per page'), + BLOCK_CACHE_PER_USER => t('Per user'), + BLOCK_CACHE_PER_USER | BLOCK_CACHE_PER_PAGE => t('Per user per page'), + ); + + // Create cache settings fieldset. + $form['cache_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Cache settings'), + '#weight' => 1, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['cache_settings']['cache'] = array( + '#type' => 'select', + '#title' => t('Cache setting'), + '#description' => t('Select the appropriate cache setting for this block.'), + '#options' => $options, + '#default_value' => $edit['cache'], + ); + + if (variable_get('block_cache', CACHE_DISABLED) == CACHE_DISABLED) { + $form['cache_settings']['cache']['#description'] = t('Block cache is disabled. For changes to take effect, you have to enable it on the performance page.', array('!url' => url('admin/settings/performance'))); + } + $form['submit'] = array( + '#weight' => 10, '#type' => 'submit', '#value' => t('Save block'), ); @@ -280,7 +312,7 @@ function block_admin_configure_validate( function block_admin_configure_submit($form, &$form_state) { if (!form_get_errors()) { - db_query("UPDATE {block} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']); + db_query("UPDATE {block} SET visibility = %d, pages = '%s', custom = %d, title = '%s', cache = %d WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['cache'], $form_state['values']['module'], $form_state['values']['delta']); db_query("DELETE FROM {block_role} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']); foreach (array_filter($form_state['values']['roles']) as $rid) { db_query("INSERT INTO {block_role} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);