You are here

function site_disclaimer_confirm in Site Disclaimer 6

Same name and namespace in other branches
  1. 7 site_disclaimer.pages.inc \site_disclaimer_confirm()

Display the Site Disclaimer, when a user needs to confirm them after registering.

1 call to site_disclaimer_confirm()
site_disclaimer_admin_settings in ./site_disclaimer.admin.inc
Menu callback; show settings form.
1 string reference to 'site_disclaimer_confirm'
site_disclaimer_menu in ./site_disclaimer.module
Implementation of hook_menu().

File

./site_disclaimer.pages.inc, line 11
Page callbacks for the Site Disclaimer module.

Code

function site_disclaimer_confirm($form_state, $preview = FALSE) {
  global $user;
  $title = check_plain(variable_get('site_disclaimer_title', SITE_DISCLAIMER_DEFAULT_TITLE));
  if (!$preview) {
    drupal_set_title($title);
  }

  // Don't show the terms form if site_disclaimer is disabled or user already accepted the latest version.
  // We are doing a check here users may navigate to this page URL (from saved or cached link or ...).
  $site_disclaimer_enabled = _site_disclaimer_enabled();
  $site_disclaimer_version = variable_get('site_disclaimer_version', 1);
  if (!$site_disclaimer_enabled || !($preview || !isset($user->site_disclaimer) || $user->site_disclaimer < $site_disclaimer_version)) {
    return array(
      '#value' => t('There were no changes.'),
    );
  }
  $changes = filter_xss_admin(variable_get('site_disclaimer_version_details', ''));
  if (empty($changes)) {
    $changes = '.';
  }
  else {
    $changes = ':<br />' . $changes . '<br /><br />';
  }
  $form = array();
  $form['intro'] = array(
    '#type' => 'item',
    '#value' => t('There were recent changes to the %terms!changes Please review the new %terms below. You must accept the following to continue.', array(
      '%terms' => $title,
      '!changes' => $changes,
    )),
  );
  $form += array(
    '#parameters' => array(
      'site_disclaimer_confirm',
    ),
  );
  site_disclaimer_form_user_register_alter($form, $form_state, NULL, $preview);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Continue'),
    '#weight' => 50,
  );
  return $form;
}