function site_disclaimer_form_user_register_form_alter in Site Disclaimer 7
Implements hook_form_form_id_alter().
2 calls to site_disclaimer_form_user_register_form_alter()
- site_disclaimer_admin_settings in ./
site_disclaimer.admin.inc - Menu callback; show settings form.
- site_disclaimer_confirm in ./
site_disclaimer.pages.inc - Display the Site Disclaimer, when a user needs to confirm them after registering.
File
- ./
site_disclaimer.module, line 89 - This module adds Site Disclaimer to the registration page.
Code
function site_disclaimer_form_user_register_form_alter(&$form, $form_state, $form_id = NULL, $langcode = NULL, $preview = FALSE) {
// Administrative users can skip site_disclaimer on admin/user/user/create page.
if ((user_access('administer users') || user_access('administer site disclaimer') || user_access('bypass site disclaimer')) && !$preview && $form_id == 'user_register_form') {
return;
}
$height = variable_get('site_disclaimer_node_height', '');
if ($height) {
$css = '#site-disclaimer { height:' . check_plain($height) . '; overflow:auto; }';
// Revert the styling so print shows the full text.
$css2 = '#site-disclaimer { height:auto; overflow:visible; }';
$form['#attached']['css'] = array(
$css => array(
'type' => 'inline',
),
$css2 => array(
'type' => 'inline',
'media' => 'print',
),
);
// drupal_add_css('' . $css . '', array('type' => 'inline'));
// drupal_add_html_head('<style type="text/css" media="print">' . $css2 . '</style>', $key = NULL /* TODO Set this variable. */);
}
// Getting the node that contains the Site Disclaimer.
$nid = _site_disclaimer_nid_translated(variable_get('site_disclaimer_node_id', ''), $langcode);
$node = NULL;
if (!empty($nid)) {
$node = node_load($nid);
if (empty($node)) {
watchdog('Site Disclaimer', 'The Site Disclaimer node !nid could not be loaded. Please check the settings and the node.', array(
'!nid' => $nid,
), WATCHDOG_ALERT, l(t('Administer Site Disclaimer'), SITE_DISCLAIMER_SETTINGS_PATH));
}
}
// Will we show the full text of the Terms or only provide a link to the Terms.
// Reading the checkbox label to find out.
$checkbox_label = filter_xss_admin(_site_disclaimer_variable_get_translated('site_disclaimer_checkbox_label', SITE_DISCLAIMER_DEFAULT_CHECKBOX_LABEL, $langcode));
$use_link = strpos($checkbox_label, '@link') !== FALSE;
$use_named_links = strpos($checkbox_label, '@"') !== FALSE;
$show_node = $node && !$use_link && !$use_named_links;
// If there is no node to show and no links in the $checkbox_label, we don't show the terms form.
// Same logic as in _site_disclaimer_enabled()
if (!$use_link && !$use_named_links && !$node) {
return;
}
$checkbox_label = theme('site_disclaimer_checkbox_label', array(
'checkbox_label' => $checkbox_label,
'node' => $node,
));
$fieldset_en = variable_get('site_disclaimer_fieldset', 1);
if ($fieldset_en) {
// Adding the fieldset.
$form['site_disclaimer'] = array(
'#type' => 'fieldset',
'#title' => check_plain(_site_disclaimer_variable_get_translated('site_disclaimer_title', SITE_DISCLAIMER_DEFAULT_TITLE, $langcode)),
'#weight' => 10,
);
$fieldset =& $form['site_disclaimer'];
}
else {
$fieldset =& $form;
}
// Adding the Site Disclaimer to the fieldset.
if ($show_node) {
//D6 $terms = node_prepare($node);
$build = node_view($node, 'full');
if ($build) {
$build['#site_disclaimer'] = TRUE;
$build['#site_disclaimer_theme'] = isset($build['#theme']) ? $build['#theme'] : '';
$build['#theme'] = 'site_disclaimer_node';
$fieldset['site_disclaimer_text'] = array(
'node' => $build,
'#weight' => 9,
);
}
else {
watchdog('Site Disclaimer', 'The output of Site Disclaimer node !nid is empty. Please check the the node content.', array(
'!nid' => $nid,
), WATCHDOG_ALERT, l(t('Administer Site Disclaimer'), SITE_DISCLAIMER_SETTINGS_PATH));
}
}
// Adding the checkbox to the fieldset.
$fieldset['I_agree'] = array(
'#type' => 'checkbox',
'#title' => $checkbox_label,
'#required' => TRUE,
// The following adds "required" validation to the checkbox (patches core missing functionality as of D6.16)
'#element_validate' => array(
'_site_disclaimer_validate_checkbox',
),
'#return_value' => variable_get('site_disclaimer_version', 1),
'#weight' => 10,
);
return $form;
}