site_disclaimer.pages.inc in Site Disclaimer 6
Same filename and directory in other branches
Page callbacks for the Site Disclaimer module.
File
site_disclaimer.pages.incView source
<?php
/**
* @file
* Page callbacks for the Site Disclaimer module.
*/
/**
* Display the Site Disclaimer, when a user needs to confirm them after registering.
*/
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;
}
/**
* Submit handler for site_disclaimer_confirm()
*/
function site_disclaimer_confirm_submit($form, &$form_state) {
global $user;
$edit = array(
'site_disclaimer' => $form_state['values']['I_agree'],
);
user_save($user, $edit);
}
Functions
Name | Description |
---|---|
site_disclaimer_confirm | Display the Site Disclaimer, when a user needs to confirm them after registering. |
site_disclaimer_confirm_submit | Submit handler for site_disclaimer_confirm() |