? LICENSE.txt ? terms_of_use_link.patch ? terms_of_use_versions.patch ? translations Index: terms_of_use.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/terms_of_use/Attic/terms_of_use.install,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 terms_of_use.install --- terms_of_use.install 23 Mar 2009 21:19:34 -0000 1.1.2.1 +++ terms_of_use.install 15 Oct 2009 13:40:09 -0000 @@ -10,5 +10,6 @@ function terms_of_use_uninstall() { variable_del('terms_of_use_fieldset_name'); variable_del('terms_of_use_checkbox_label'); variable_del('terms_of_use_node_id'); + variable_del('terms_of_use_version'); } Index: terms_of_use.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/terms_of_use/terms_of_use.module,v retrieving revision 1.1.2.8 diff -u -p -r1.1.2.8 terms_of_use.module --- terms_of_use.module 23 Mar 2009 21:20:27 -0000 1.1.2.8 +++ terms_of_use.module 15 Oct 2009 13:40:09 -0000 @@ -37,10 +37,43 @@ function terms_of_use_menu() { 'file' => 'terms_of_use.pages.inc', ); + $items['terms_of_use'] = array( + 'page callback' => 'drupal_get_form', + 'page arguments' => array('terms_of_use_confirm'), + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + 'file' => 'terms_of_use.pages.inc', + ); + return $items; } /** + * Display the terms of use, when a user needs to confirm them after registering. + */ +function terms_of_use_confirm($form_state) { + $form = array(); + + terms_of_use_form_user_register_alter($form, $form_state); + drupal_set_title($form['terms_of_use']['#title']); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Continue'), + '#weight' => 50, + ); + + return $form; +} + +function terms_of_use_confirm_submit($form, &$form_state) { + global $user; + $edit = array( + 'terms_of_use' => $form_state['values']['I_agree'], + ); + user_save($user, $edit); +} + +/** * Menu callback; show settings form. * @see terms_of_use_admin_settings_validate() * @@ -86,6 +119,23 @@ function terms_of_use_admin_settings() { '#default_value' => variable_get('terms_of_use_checkbox_label', t('I agree with these terms.')), '#description' => t('Type here something like "I agree with these terms." or "I CERTIFY THAT I AM OVER THE AGE OF 18 YEARS OLD.", without quotes. You can use the token @link to insert a link to the Terms in this label. For example, the label can be: "I agree with the @link.", without quotes. You may want to link to the Terms if you prefer not to show the full text of the Terms in the registration form. If you use the token, the Terms will not be shown.'), ); + + $form['terms_of_use_advanced'] = array( + '#type' => 'fieldset', + ); + $version = variable_get('terms_of_use_version', 1); + $options = array( + $version => t('@version (current version)', array('@version' => $version)), + $version + 1 => t('@version (add a new version)', array('@version' => $version + 1)), + ); + + $form['terms_of_use_advanced']['terms_of_use_version'] = array( + '#type' => 'radios', + '#title' => t('Terms of use version'), + '#description' => t('WARNING: Changing this value will force all logged-in users to accept the new terms of use before they can do anything else on the site.'), + '#options' => $options, + '#default_value' => $version, + ); return system_settings_form($form); } @@ -170,6 +220,7 @@ function terms_of_use_form_user_register '#title' => $checkbox_label . ' *', '#required' => TRUE, '#element_validate' => array('_terms_of_use_validate_checkbox'), + '#return_value' => variable_get('terms_of_use_version', 1), ); return $form; @@ -180,11 +231,45 @@ function terms_of_use_form_user_register */ function _terms_of_use_validate_checkbox($form, &$form_state) { $value = $form_state['values']['I_agree']; - if ($value == 0) { + if ($value != variable_get('terms_of_use_version', 1)) { form_set_error('I_agree', t('You must agree with the !terms to get an account.', array('!terms' => variable_get('terms_of_use_fieldset_name', t('Terms of Use'))))); } } +/** + * Implementation of hook_user(). + */ +function terms_of_use_user($op, &$edit, &$account, $category = NULL) { + switch ($op) { + case 'insert': + drupal_set_message(print_r($account, TRUE)); + drupal_set_message(print_r($edit, TRUE)); + + if (isset($edit['I_agree'])) { + $edit['terms_of_use'] = $edit['I_agree']; + unset ($edit['I_agree']); + } + drupal_set_message(print_r($account, TRUE)); + break; + } +} + +/** + * Implementation of hook_init(). + */ +function terms_of_use_init() { + global $user; + + if ($user->uid > 0) { + $terms_of_use_version = variable_get('terms_of_use_version', 1); + $terms_of_use_node_id = variable_get('terms_of_use_node_id', ''); + if ($terms_of_use_node_id > 0 && (!isset($user->terms_of_use) || $user->terms_of_use < $terms_of_use_version)) { + if (arg(0) != 'terms_of_use') { + drupal_goto('terms_of_use', drupal_get_destination()); + } + } + } +} /** * Implementation of hook_theme().