function privatemsg_account_fieldset_remove_if_empty

7-1 privatemsg.module privatemsg_account_fieldset_remove_if_empty($element)
7-2 privatemsg.module privatemsg_account_fieldset_remove_if_empty($element)
6-2 privatemsg.module privatemsg_account_fieldset_remove_if_empty($element)

Hides the settings fieldset if there are no options to be displayed.

Parameters

array $element: Form element to check.

Return value

array Form element with '#access' key value TRUE if the fieldset has a child, FALSE if the fieldset has no child.

1 string reference to 'privatemsg_account_fieldset_remove_if_empty'
privatemsg_form_alter in ./privatemsg.module
Implements hook_form_alter().

File

./privatemsg.module, line 1383
Allows users to send private messages to other users.

Code

function privatemsg_account_fieldset_remove_if_empty($element) {
  // If there are no children elements, deny access.
  if (count(element_children($element)) == 0) {
    $element['#access'] = FALSE;
  }
  else {
    // If there are elements, check if at least one of them is visible. Deny
    // access.
    foreach (element_children($element) as $key) {
      if ($element[$key]['#type'] != 'value' && (!isset($element[$key]['#access']) || $element[$key]['#access'])) {
        return $element;
      }
    }
    $element['#access'] = FALSE;
  }
  return $element;
}