Index: /var/www/testbed6/sites/all/modules/legal/legal.module
===================================================================
--- /var/www/testbed6/sites/all/modules/legal/legal.module	(revision 4771)
+++ /var/www/testbed6/sites/all/modules/legal/legal.module	(working copy)
@@ -57,7 +57,7 @@
 	   'title' => 'Terms and Conditions',
 	   'page callback' => 'drupal_get_form',
 	   'page arguments' => array('legal_login'),
-	   'access arguments' => array(TRUE),
+	   'access arguments' => array('access content'),
 	   'type' => MENU_CALLBACK
 	   ); 
 
@@ -384,27 +384,29 @@
         
         $form_fields = legal_display_fields($conditions);
         
-        // disable checkbox if:
-        // user is already registered (administrator)
-        // if (!empty($user->uid)) {
-        //     $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
-        //     $form_fields['legal']['legal_accept']['#required'] = FALSE;
-        //     
-        //       
-        //         reset($conditions['extras']);
-        //         while (list ($key, $label) = each ($conditions['extras'])) {
-        //             if (!empty($label)) {
-        //                 $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
-        //                 $form_fields['legal'][$key]['#required'] = FALSE;
-        //             }
-        //         }
-        //    
-        //     
-        // } else {
-        //     $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
-        // } 
+        
+         //disable checkbox if:
+         //user is already registered (administrator)
+         if (!empty($user->uid)) {
+           $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
+           $form_fields['legal']['legal_accept']['#required'] = FALSE;
+           
+             
+           reset($conditions['extras']);
+           while (list ($key, $label) = each ($conditions['extras'])) {
+             if (!empty($label)) {
+               $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
+               $form_fields['legal'][$key]['#required'] = FALSE;
+             }
+           }
+            
+             
+         } else {
+           $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
+         } 
 
         // section above seems unnecessary (?) as only anonymous users can access registration page
+        // Incorrect - admins can access registration on admin/user/user/create!
  
         $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
         
@@ -531,7 +533,7 @@
         }
 
         // don't insert if user is already registered (administrator)
-        if (!empty($user->uid)) break;
+        if (!empty($user->uid) || !$account->uid) break;
 
         legal_save_accept($account->uid, $conditions['tc_id']);
         break;  
@@ -554,7 +556,7 @@
         $accepted = legal_version_check($account->uid, $conditions['tc_id']);
         
         if ($accepted == TRUE) break;
-        
+
         legal_save_accept($account->uid, $conditions['tc_id']);
         break;
         
@@ -564,7 +566,7 @@
   }
   
 // require registered users to accept new T&C  
-function legal_login($uid, $id_hash = NULL) {
+function legal_login(&$form_state, $uid, $id_hash = NULL) {
 
     $conditions = legal_get_conditions();
     $form = legal_display_fields($conditions);
@@ -611,7 +613,7 @@
       
     global $user;
     $user = user_load(array('uid' => $form_state['values']['uid']));
-
+    
     legal_save_accept($user->uid, $form_state['values']['tc_id']);
     watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
     
