From 4da1540a9fc8d535d2ce9f99431e23eb2dcc9d8d Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Fri, 20 Jan 2006 09:33:03 +0000
Subject: [PATCH] - Patch #45380 by Neil: usability improvement: disable
 anonymous commenting options when anonymous people can't comment.

---
 modules/comment.module         | 7 +++++--
 modules/comment/comment.module | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/comment.module b/modules/comment.module
index cadac359f5c2..4d2488b26e9d 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -390,14 +390,17 @@ function comment_configure() {
 
   $form['posting_settings']['comment_anonymous'] = array(
     '#type' => 'radios',
-    '#title' => t('Comment controls'),
+    '#title' => t('Anonymous commenting'),
     '#default_value' => variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT),
     '#options' => array(
       COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
       COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
       COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
-    '#description' => t('This feature is only useful if you allow anonymous users to post comments.  See the <a href="%url">permissions page</a>.', array('%url' => url('admin/access/permissions'))),
+    '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="%url">permissions page</a>.', array('%url' => url('admin/access'))),
   );
+  if (!user_access('post comments', user_load(array('uid' => 0)))) {
+    $form['posting_settings']['comment_anonymous']['#attributes'] = array('disabled' => 'disabled');
+  }
 
   $form['posting_settings']['comment_subject_field'] = array(
     '#type' => 'radios',
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index cadac359f5c2..4d2488b26e9d 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -390,14 +390,17 @@ function comment_configure() {
 
   $form['posting_settings']['comment_anonymous'] = array(
     '#type' => 'radios',
-    '#title' => t('Comment controls'),
+    '#title' => t('Anonymous commenting'),
     '#default_value' => variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT),
     '#options' => array(
       COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
       COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
       COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
-    '#description' => t('This feature is only useful if you allow anonymous users to post comments.  See the <a href="%url">permissions page</a>.', array('%url' => url('admin/access/permissions'))),
+    '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="%url">permissions page</a>.', array('%url' => url('admin/access'))),
   );
+  if (!user_access('post comments', user_load(array('uid' => 0)))) {
+    $form['posting_settings']['comment_anonymous']['#attributes'] = array('disabled' => 'disabled');
+  }
 
   $form['posting_settings']['comment_subject_field'] = array(
     '#type' => 'radios',
-- 
GitLab