function _acquia_purge_trigger_client_side_purging in Acquia Purge 6
Trigger client-side AJAX based purging during this request.
@returns Void, this function doesn't return anything.
1 call to _acquia_purge_trigger_client_side_purging()
- acquia_purge_init in ./
acquia_purge.module - Implements hook_init().
File
- ./
acquia_purge.module, line 1066 - Acquia Purge, Top-notch Varnish purging on Acquia Cloud!
Code
function _acquia_purge_trigger_client_side_purging() {
// Prevent API misuse and don't trigger when this user doesn't own the queue.
if (!_acquia_purge_queue_is_user_purging()) {
return;
}
// Load the JQuery logic that will start hitting 'acquia_purge_ajax_processor'
// which on its turn will process the queue. Because the back-end uses locks
// we don't have to worry about how many times we're hitting it. When the user
// doesn't have on-screen reporting enabled the HTML DIV won't be present
// causing the script to simply purge silently without notifying the user.
$module_path = drupal_get_path('module', 'acquia_purge');
drupal_add_js($module_path . '/acquia_purge.js');
// If the user has the permission 'purge notification' it means on-screen
// reporting is enabled and we'll set a standard drupal_set_message() that
// announces the AJAX powered purging. Because we're abusing the API with a
// non-standard message type our JQuery logic is smartly able to replace the
// nodes with the interactive progressbar.
if (user_access('purge notification')) {
$message = t("There have been changes to content, and these needs to be\n refreshed throughout the system. There may be a delay before the changes\n appear to all website visitors.");
// Set the message and don't repeat it if it is already set.
drupal_set_message($message, 'acquia_purge_messages', FALSE);
// Add inline CSS to initially hide the message (see d.o. 2014461). A
// separate file that could be cached would be non-sense for this one line
// declaration as this statement only occurs for authenticated users.
drupal_add_css($module_path . '/acquia_purge.css');
}
}