Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Eric Rasmussen
UNL-CMS
Commits
15ab8af5
Commit
15ab8af5
authored
Oct 24, 2012
by
Eric Rasmussen
Browse files
[gh-497] Add button for local site varnish purge
parent
a0b7a115
Changes
1
Hide whitespace changes
Inline
Side-by-side
sites/all/modules/unl/unl_varnish/unl_varnish.module
View file @
15ab8af5
...
...
@@ -5,15 +5,27 @@
* 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
[
'clear_cache'
][
'#weight'
]
=
-
3
;
// Add purge varnish button for single site
$form
[
'purge_varnish'
]
=
array
(
'#type'
=>
'fieldset'
,
'#title'
=>
t
(
'Purge varnish'
),
'#access'
=>
user_access
(
'administer site configuration'
),
'#weight'
=>
-
2
,
'purge'
=>
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Purge varnish cache'
),
'#submit'
=>
array
(
'unl_varnish_purge_submit'
),
),
);
// Add system-wide varnish purge for the default site only
$form
[
'purge_varnish_all_sites'
]
=
array
(
'#type'
=>
'fieldset'
,
'#title'
=>
'Purge varnish on all sites'
,
'#title'
=>
t
(
'Purge varnish on all sites'
)
,
'#access'
=>
user_access
(
'administer varnish'
)
&&
conf_path
()
==
'sites/default'
,
'#weight'
=>
-
1
,
'varnish_path'
=>
array
(
'#type'
=>
'radios'
,
'#required'
=>
TRUE
,
...
...
@@ -23,11 +35,10 @@ function unl_varnish_form_system_performance_settings_alter(&$form, &$form_state
),
'#default_value'
=>
'^/wdn'
,
),
'purge'
=>
array
(
'#type'
=>
'submit'
,
'#value'
=>
'Purge varnish
cach
e'
,
'#submit'
=>
array
(
'unl_varnish_purge_submit'
),
'#value'
=>
t
(
'Purge varnish
system-wid
e'
)
,
'#submit'
=>
array
(
'unl_varnish_purge_
all_sites_
submit'
),
),
);
...
...
@@ -35,9 +46,17 @@ function unl_varnish_form_system_performance_settings_alter(&$form, &$form_state
}
/**
* Uses the varnish module to purge varnish
at the requested path
.
*
Submit callback:
Uses the varnish module to purge varnish.
*/
function
unl_varnish_purge_submit
(
$form
,
&
$form_state
)
{
varnish_purge_all_pages
();
drupal_set_message
(
t
(
'Varnish purged.'
));
}
/**
* Submit callback: Uses the varnish module to purge varnish at the requested path.
*/
function
unl_varnish_purge_all_sites_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'
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment