Commit 96893 by goba

#119038 by ximo, Pancho: user role editing usability: include disabled checkbox for authenticated role

--- modules/user/user.module    2008/01/16 22:54:41     1.888
+++ modules/user/user.module    2008/01/22 07:51:56     1.889
@@ -1422,14 +1422,38 @@
     );
   }
   if ($admin) {
-    $form['account']['status'] = array('#type' => 'radios', '#title' => t('Status'), '#default_value' => isset($edit['status']) ? $edit['status'] : 1, '#options' => array(t('Blocked'), t('Active')));
+    $form['account']['status'] = array(
+      '#type' => 'radios',
+      '#title' => t('Status'),
+      '#default_value' => isset($edit['status']) ? $edit['status'] : 1,
+      '#options' => array(t('Blocked'), t('Active'))
+    );
   }
   if (user_access('administer permissions')) {
     $roles = user_roles(TRUE);
+
+    // The disabled checkbox subelement for the 'authenticated user' role
+    // must be generated separately and added to the checkboxes element,
+    // because of a limitation in D6 FormAPI not supporting a single disabled
+    // checkbox within a set of checkboxes.
+    // TODO: This should be solved more elegantly. See issue #119038.
+    $checkbox_authenticated = array(
+      '#type' => 'checkbox',
+      '#title' => $roles[DRUPAL_AUTHENTICATED_RID],
+      '#default_value' => TRUE,
+      '#disabled' => TRUE,
+    );
+
     unset($roles[DRUPAL_AUTHENTICATED_RID]);
     if ($roles) {
       $default = empty($edit['roles']) ? array() : array_keys($edit['roles']);
-      $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => $default, '#options' => $roles, '#description' => t('The user receives the combined permissions of the %au role, and all roles selected here.', array('%au' => t('authenticated user'))));
+      $form['account']['roles'] = array(
+        '#type' => 'checkboxes',
+        '#title' => t('Roles'),
+        '#default_value' => $default,
+        '#options' => $roles,
+        DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
+      );
     }
   }
 
No votes yet