From c5f28f81263e7c9bc00609c501c9b425200e1fc0 Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Tue, 5 Apr 2011 09:29:13 -0400
Subject: [PATCH] #1116854: Use #access to set visibility of user relationship mailer settings.

---
 .../user_relationship_mailer.module                |   24 ++++++++++----------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/user_relationship_mailer/user_relationship_mailer.module b/user_relationship_mailer/user_relationship_mailer.module
index b61a497..2cd3072 100644
--- a/user_relationship_mailer/user_relationship_mailer.module
+++ b/user_relationship_mailer/user_relationship_mailer.module
@@ -190,22 +190,22 @@ function user_relationship_mailer_user($type, &$edit, &$account, $category = NUL
   switch ($type) {
   case 'form':
     $form = array();
-    if (($category == 'account')
-      && variable_get('user_relationship_mailer_send_mail', FALSE)
-      && user_access('maintain own relationships', $account)
-    ) {
+    if ($category == 'account') {
+      // Note that we only need #access on the wrapper fieldset.
+      $access = variable_get('user_relationship_mailer_send_mail', FALSE) && user_access('maintain own relationships', $account);
       $form['user_relationship_mailer_settings'] = array(
         '#type'   => 'fieldset',
         '#title'  => t('Relationship email settings'),
-        '#weight' => 5
+        '#weight' => 5,
+        '#access' => $access,
+      );
+      $form['user_relationship_mailer_settings']['user_relationship_mailer_send_mail'] = array(
+        '#type'           => 'checkbox',
+        '#title'          => t('Receive relationship email notifications'),
+        '#options'        => $options,
+        '#default_value'  => isset($edit['user_relationship_mailer_send_mail']) ? $edit['user_relationship_mailer_send_mail'] : TRUE,
+        '#description'    => t("Check this if you'd like to receive relationship related email notifications"),
       );
-        $form['user_relationship_mailer_settings']['user_relationship_mailer_send_mail'] = array(
-          '#type'           => 'checkbox',
-          '#title'          => t('Receive relationship email notifications'),
-          '#options'        => $options,
-          '#default_value'  => isset($edit['user_relationship_mailer_send_mail']) ? $edit['user_relationship_mailer_send_mail'] : TRUE,
-          '#description'    => t("Check this if you'd like to receive relationship related email notifications")
-        );
     }
     return $form;
   }
-- 
1.7.4.1

