You are here

function notifications_custom_user_form in Notifications 6.4

Same name and namespace in other branches
  1. 6 notifications_custom/notifications_custom.module \notifications_custom_user_form()

Build user account custom subscriptions form

1 call to notifications_custom_user_form()
notifications_custom_user in notifications_custom/notifications_custom.module
Implementation of hook_user().

File

notifications_custom/notifications_custom.module, line 165
Custom notifications module

Code

function notifications_custom_user_form($account, $register = FALSE) {
  $form = $params = array();
  if ($register) {
    $params['register'] = 1;
  }
  if ($custom_list = notifications_custom_build_list($params, $account)) {
    $visible = FALSE;
    $form['notifications_custom'] = array(
      '#tree' => TRUE,
    );
    foreach ($custom_list as $subscription) {
      $visible = $visible || $subscription
        ->is_visible();
      $form['notifications_custom'][$subscription->type] = $subscription
        ->form_element($register);
    }

    // If any of them is visible, add the full fieldset
    if ($visible) {
      $form['notifications_custom'] += array(
        '#type' => 'fieldset',
        '#title' => t('Subscriptions'),
      );
    }
  }
  return $form;
}