? allow_users.patch
Index: anonymous_contact.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/anonymous_contact/anonymous_contact.module,v
retrieving revision 1.2
diff -u -p -r1.2 anonymous_contact.module
--- anonymous_contact.module	1 Jun 2010 04:58:08 -0000	1.2
+++ anonymous_contact.module	29 Oct 2010 16:58:20 -0000
@@ -8,7 +8,8 @@ function anonymous_contact_menu() {
     'description' => 'Contact a User without needing to log in',
     'page callback' => 'anonymous_contact_page',
     'page arguments' => array(1),
-    'access arguments' => array('access anonymous contact form'),
+    'access callback' => 'anonymous_contact_access',
+    'access arguments' => array(1),
     'type' => MENU_CALLBACK,
   );
   $items['contact_form/%user'] = array(
@@ -16,7 +17,8 @@ function anonymous_contact_menu() {
     'description' => 'Contact a User without needing to log in',
     'page callback' => 'anonymous_contact_page',
     'page arguments' => array(1),
-    'access arguments' => array('access anonymous contact form'),
+    'access callback' => 'anonymous_contact_access',
+    'access arguments' => array(1),
     'type' => MENU_CALLBACK,
   );
   return $items;
@@ -30,6 +32,18 @@ function anonymous_contact_perm() {
 }
 
 /**
+ * Access callback function
+ */
+function anonymous_contact_access($account) {
+  if (user_access('access anonymous contact form') && $account->anonymous_contact == TRUE) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
+  }
+}
+
+/**
  * Contact form page
  */
 function anonymous_contact_page($account) {
@@ -147,3 +161,29 @@ function anonymous_contact_mail($key, &$
       break;
   }
 }
+
+/**
+ * Implementation of hook_user()
+ */
+function anonymous_contact_user($type, &$edit, &$user, $category = NULL) {
+  if ($type == 'form' && $category == 'account') {
+    // If the contact module is not activated
+    if (!module_exists("contact")) {
+      $form['contact'] = array('#type' => 'fieldset',
+        '#title' => t('Contact settings'),
+        '#weight' => 5,
+        '#collapsible' => TRUE,
+      );
+    }
+    $form['contact']['anonymous_contact'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Visitors contact form'),
+      '#default_value' => !empty($edit['anonymous_contact']) ? $edit['anonymous_contact'] : FALSE,
+      '#description' => t('Allow visitors to contact you by e-mail via a contact form.'),
+    );
+    return $form;
+  }
+  elseif ($type == 'validate') {
+    return array('anonymous_contact' => isset($edit['anonymous_contact']) ? $edit['anonymous_contact'] : FALSE);
+  }
+}
