You are here

function cdn_touch_file_form in CDN 7.2

Same name and namespace in other branches
  1. 6.2 cdn.stats.inc \cdn_touch_file_form()

@file Per-page CDN integration statistics functionality.

1 string reference to 'cdn_touch_file_form'
cdn_menu in ./cdn.module
Implements hook_menu().

File

./cdn.stats.inc, line 8
Per-page CDN integration statistics functionality.

Code

function cdn_touch_file_form($form, &$form_state) {

  // All arguments after the first two are in fact the different parts of the
  // file path that is being passed in.
  $additional_args = array_slice(func_get_args(), 2);
  $filepath = implode('/', $additional_args);

  // Store the page we should redirect to after the file has been touched, or
  // upon cancellation.
  if (!isset($form_state['storage']['redirect'])) {
    $form_state['storage']['redirect'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '<front>';
  }
  if (!file_exists($filepath)) {
    drupal_set_message(t('The file %filepath does not exist and thus could not be touched.', array(
      '%filepath' => $filepath,
    )), 'error');
    drupal_goto($form_state['storage']['redirect']);
  }
  else {
    $form_state['filepath'] = $filepath;
    return confirm_form(array(
      'filepath' => array(
        '#type' => 'value',
        '#markup' => $filepath,
      ),
      'redirect' => array(
        '#type' => 'value',
        '#markup' => $form_state['storage']['redirect'],
      ),
    ), t('Are you sure you want to touch %filepath?', array(
      '%filepath' => $filepath,
    )), $form_state['storage']['redirect'], t('This action cannot be undone, but is completely harmless. Touching a file merely means that its last modification date will be updated to \'right now\'.'), t('Touch file'), t('Cancel'));
  }
}