'Add Terms of Use to the registration page.', 'title' => 'Terms of Use', 'page callback' => 'drupal_get_form', 'page arguments' => array('terms_of_use_admin_settings'), 'access arguments' => array('administer site configuration'), 'file' => 'terms_of_use.admin.inc', ); $items['terms_of_use/autocomplete'] = array( 'title' => 'Autocomplete node title', 'page callback' => 'terms_of_use_autocomplete', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, 'file' => 'terms_of_use.admin.inc', ); return $items; } /** * Implementation of hook_form_form_id_alter(). * * @param array $form * @param array $form_state * @return boolean */ function terms_of_use_form_user_register_form_alter(&$form, $form_state) { // Administrative users can skip this. So admin/user/user/create won't show // the terms of use. if (user_access('administer users')) { return; } $fieldset_name = filter_xss(variable_get('terms_of_use_fieldset_name', t('Terms of Use'))); $checkbox_label = filter_xss_admin(variable_get('terms_of_use_checkbox_label', t('I agree with these terms'))); // Adding the fieldset. $form['terms_of_use'] = array( '#type' => 'fieldset', '#title' => $fieldset_name, '#weight' => 10, ); $show_terms = TRUE; // Getting the nid of the the Terms of Use node. $terms_of_use_node_id = variable_get('terms_of_use_node_id', 0); // If the translation module is active the node might be available in other // languages. if (module_exists('translation')) { $translations = translation_node_get_translations($terms_of_use_node_id); if (!empty($translations[$GLOBALS['language']->language])) { $terms_of_use_node_id = $translations[$GLOBALS['language']->language]->nid; } } // A nid for the desired language was found. if ($terms_of_use_node_id) { $node = node_load($terms_of_use_node_id); // The node could be loaded. if ($node->nid) { // Show terms on the registration for or just a links if (strpos($checkbox_label, '@link') !== FALSE) { $checkbox_label = str_replace('@link', l($node->title, 'node/' . $node->nid), $checkbox_label); $show_terms = FALSE; } // Adding the nodes body by theme_terms_of_use() to the fieldset if desired. if ($show_terms) { if ($terms = $node->body[$node->language][0]['safe_value']) { $form['#attached']['css'] = array( drupal_get_path('module', 'terms_of_use') . '/terms_of_use.css' ); $form['terms_of_use']['terms_of_use_text'] = array( '#markup' => theme('terms_of_use', array('terms' => $terms, 'node' => $node)), ); } else { watchdog('terms_of_use', 'The body field of the terms of use node was empty. Please check the the nodes content.', array(), WATCHDOG_ALERT, l('Administer terms of use', 'admin/config/people/terms_of_use')); } } } else { watchdog('terms_of_use', 'The terms of use node could not be loaded. Please check the settings and the node.', array(), WATCHDOG_ALERT, l('Administer terms of use', 'admin/config/people/terms_of_use')); } } else { watchdog('terms_of_use', 'No node is set to use as terms of use in the currecnt language [' . $GLOBALS['language']->language . '].', array(), WATCHDOG_NOTICE, l('Administer terms of use', 'admin/config/people/terms_of_use')); } // Adding the checkbox to the fieldset. $form['terms_of_use']['terms_of_use'] = array( '#type' => 'checkbox', '#title' => $checkbox_label, '#required' => TRUE, ); return $form; } /** * Implementation of hook_theme(). */ function terms_of_use_theme() { return array( 'terms_of_use' => array( 'variables' => array('terms' => NULL, 'node' => NULL), ), ); } /** * Output the terms of service. * * @param $terms * The terms of service, already formatted. * @param $node * The $node object, in case we need it. * @return * HTML output. * @ingroup themeable */ function theme_terms_of_use($variables) { $output = '
'; $output .= $variables['terms']; $output .= '
'; return $output; }