From 616b9e82ba0d7be346c5e9b750733942f9ad6f64 Mon Sep 17 00:00:00 2001
From: madmatter23 <madmatter23@455714.no-reply.drupal.org>
Date: Wed, 2 Nov 2011 11:25:21 -0500
Subject: [PATCH] Adding option to add Terms of Use to User Login form

---
 terms_of_use.admin.inc |    6 ++++++
 terms_of_use.module    |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 terms_of_use.admin.inc
 mode change 100644 => 100755 terms_of_use.module

diff --git a/terms_of_use.admin.inc b/terms_of_use.admin.inc
old mode 100644
new mode 100755
index 59ca703..0d82a4d
--- a/terms_of_use.admin.inc
+++ b/terms_of_use.admin.inc
@@ -50,6 +50,12 @@ 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_login_requirement'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Add Terms of Use to the User Login form?'),
+    '#description' => t('If checked, users will be required to agree to the Terms of Service before logging in.'),
+    '#default_value' => variable_get('terms_of_use_login_requirement', 0),
+  );
 
   return system_settings_form($form);
 }
diff --git a/terms_of_use.module b/terms_of_use.module
old mode 100644
new mode 100755
index 2437e3d..c1f8cfa
--- a/terms_of_use.module
+++ b/terms_of_use.module
@@ -49,6 +49,38 @@ function terms_of_use_form_user_register_form_alter(&$form, $form_state) {
     return;
   }
 
+  $form = terms_of_use_generate_form($form, $form_state);
+
+  return $form;
+}
+
+/**
+ * Implementation of hook_form_form_id_alter().
+ *
+ * @param array $form
+ * @param array $form_state
+ * @return boolean
+ */
+function terms_of_use_form_user_login_alter(&$form, $form_state) {
+  // Check to see if Terms of Use are required for login.
+  $REQUIRE_ON_LOGIN = variable_get('terms_of_use_login_requirement', 0);
+  if (!$REQUIRE_ON_LOGIN) {
+    return;
+  }
+
+  $form = terms_of_use_generate_form($form, $form_state);
+
+  return $form;
+}
+
+
+/**
+ * @param array $form
+ * @param array $form_state
+ * @return boolean
+ */
+function terms_of_use_generate_form(&$form, $form_state) {
+
   $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')));
 
-- 
1.7.1

