From 9191b50ad0a0f28ab24616e4b4a791ce3d1536a8 Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 5 Apr 2011 09:56:20 -0400 Subject: [PATCH 1/2] #1116854: Use #access to set visibility of user relationship mailer settings. --- .../user_relationship_mailer.module | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/user_relationship_mailer/user_relationship_mailer.module b/user_relationship_mailer/user_relationship_mailer.module index d423292..b1ac03a 100644 --- a/user_relationship_mailer/user_relationship_mailer.module +++ b/user_relationship_mailer/user_relationship_mailer.module @@ -184,13 +184,15 @@ function user_relationship_mailer_form_user_relationships_ui_settings_alter(&$fo * Implements hook_form_alter(). */ function user_relationship_mailer_form_alter(&$form, &$form_state, $form_id) { - if (($form_id == 'user_register_form' || $form_id == 'user_profile_form') && $form['#user_category'] == 'account' && variable_get('user_relationship_mailer_send_mail', FALSE) && user_access('maintain own relationships')) { + if (($form_id == 'user_register_form' || $form_id == 'user_profile_form') && $form['#user_category'] == 'account') { + $access = variable_get('user_relationship_mailer_send_mail', FALSE) && user_access('maintain own relationships'); $form['user_relationships_ui_settings']['user_relationship_mailer_send_mail'] = array( '#type' => 'checkbox', '#title' => t('Receive e-mail notification of relationship activity'), '#default_value' => isset($form['#user']->user_relationship_mailer_send_mail) ? $form['#user']->user_relationship_mailer_send_mail : TRUE, '#description' => t("If checked, we will e-mail you when there are changes to your relationship status with other users."), '#weight' => -10, + '#access' => $access, ); } } -- 1.7.4.1 From 4fd03d5aff36e8e90d7a5730e85fdd2239b2a53f Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Tue, 5 Apr 2011 09:57:05 -0400 Subject: [PATCH 2/2] #1116854: Use the account being viewed, and not the current user, when calculating access to mail settings. --- .../user_relationship_mailer.module | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/user_relationship_mailer/user_relationship_mailer.module b/user_relationship_mailer/user_relationship_mailer.module index b1ac03a..5e4dc74 100644 --- a/user_relationship_mailer/user_relationship_mailer.module +++ b/user_relationship_mailer/user_relationship_mailer.module @@ -185,7 +185,8 @@ function user_relationship_mailer_form_user_relationships_ui_settings_alter(&$fo */ function user_relationship_mailer_form_alter(&$form, &$form_state, $form_id) { if (($form_id == 'user_register_form' || $form_id == 'user_profile_form') && $form['#user_category'] == 'account') { - $access = variable_get('user_relationship_mailer_send_mail', FALSE) && user_access('maintain own relationships'); + $account = $form_state['user']; + $access = variable_get('user_relationship_mailer_send_mail', FALSE) && user_access('maintain own relationships', $account); $form['user_relationships_ui_settings']['user_relationship_mailer_send_mail'] = array( '#type' => 'checkbox', '#title' => t('Receive e-mail notification of relationship activity'), -- 1.7.4.1