diff --git a/sites/all/modules/unl/unl_varnish/unl_varnish.info b/sites/all/modules/unl/unl_varnish/unl_varnish.info new file mode 100644 index 0000000000000000000000000000000000000000..1e44ffb0a0ae385217596d83c478dbdae0960ab8 --- /dev/null +++ b/sites/all/modules/unl/unl_varnish/unl_varnish.info @@ -0,0 +1,9 @@ +; $Id$ +name = UNL Varnish +description = Extends the Varnish module to do a few extra tasks. +package = UNL +dependencies[] = varnish +core = 7.x +version = "7.x-1.0-20110706" + +files[] = unl_varnish.module diff --git a/sites/all/modules/unl/unl_varnish/unl_varnish.module b/sites/all/modules/unl/unl_varnish/unl_varnish.module new file mode 100644 index 0000000000000000000000000000000000000000..27f4c0988760db7af8ffeeeb2e5fd1a539753423 --- /dev/null +++ b/sites/all/modules/unl/unl_varnish/unl_varnish.module @@ -0,0 +1,41 @@ +<?php + +/** + * Modifies the system performance settings form to add a button to purge the varnish cache. + */ +function unl_varnish_form_system_performance_settings_alter(&$form, &$form_state, $form_id) { + $form['clear_cache']['#weight'] = -2; + $form['purge_varnish'] = array( + '#type' => 'fieldset', + '#title' => 'Purge Varnish', + '#access' => user_access('administer varnish'), + '#weight' => -1, + + 'varnish_path' => array( + '#type' => 'radios', + '#required' => TRUE, + '#options' => array( + '^/wdn' => 'Just WDN template files (/wdn)', + '^/' => 'Everything', + ), + '#default_value' => '^/wdn', + ), + + 'purge' => array( + '#type' => 'submit', + '#value' => 'Purge varnish cache', + '#submit' => array('unl_varnish_purge_submit'), + ), + ); + + return $form; +} + +/** + * Uses the varnish module to purge varnish at the requested path. + */ +function unl_varnish_purge_submit($form, &$form_state) { + $path = $form_state['values']['varnish_path']; + _varnish_terminal_run("purge.url $path"); + drupal_set_message("Varnish purged paths matching $path.", 'status'); +}