You are here

function notifications_custom_user_form in Notifications 6

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

Build user account 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 127
Custom notifications module

Code

function notifications_custom_user_form($edit, $account, $category, $register = FALSE, $hidden = TRUE) {
  $form = $params = array();
  if ($register) {
    $params['register'] = 1;
  }
  if ($custom = notifications_custom_list($params)) {
    $form['notifications_custom'] = array(
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => t('Subscriptions'),
    );
    foreach ($custom as $subs) {
      if ($subs->visibility || user_access('administer users')) {
        $form['notifications_custom'][$subs->type] = array(
          '#type' => 'checkbox',
          '#title' => $subs->title,
          '#default_value' => $register ? $subs->default_value : (bool) notifications_custom_get_subscription($subs->type, $account->uid),
          '#description' => $subs->explanation,
        );
      }
      elseif ($hidden) {

        // Hidden option
        $form['notifications_custom'][$subs->type] = array(
          '#type' => 'value',
          '#value' => $subs->default_value,
        );
      }
    }
  }
  return $form;
}