You are here

function domain_form_user_admin_account_alter in Domain Access 7.3

Same name and namespace in other branches
  1. 6.2 domain.module \domain_form_user_admin_account_alter()
  2. 7.2 domain.module \domain_form_user_admin_account_alter()

Implements hook_form_alter().

File

./domain.module, line 756
Core module functions for the Domain Access suite.

Code

function domain_form_user_admin_account_alter(&$form, $form_state) {
  global $_domain;
  if (!user_access('assign domain editors')) {
    return;
  }
  $form['options']['#weight'] = -2;
  $_domain = domain_get_domain();
  $options = array();
  $format = domain_select_format();
  foreach (domain_domains() as $data) {

    // The domain must be valid.
    if ($data['valid'] || user_access('access inactive domains')) {

      // Filter checkbox output but not select list.
      $options[$data['domain_id']] = empty($format) ? check_plain($data['sitename']) : $data['sitename'];
    }
  }
  $form['domain'] = array(
    '#type' => 'fieldset',
    '#title' => t('Affiliate editor options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#prefix' => '<div class="description">' . t('If you select <em>Assign users to domains</em> above, you should confirm the <em>Affiliate editor options</em> settings below.') . '</div>',
    '#weight' => -1,
  );
  $form['domain']['behavior'] = array(
    '#type' => 'radios',
    '#title' => t('Update behavior'),
    '#options' => array(
      0 => t('Replace old values with new settings'),
      1 => t('Add new settings to existing values'),
      2 => t('Remove selected domains from existing values'),
    ),
    '#description' => t('Defines how new grants will be applied to the updated users.'),
    '#default_value' => 0,
  );
  $form['domain']['domains'] = array(
    '#type' => empty($format) ? 'checkboxes' : 'select',
    '#title' => t('Assign to'),
    '#options' => $options,
    '#required' => FALSE,
    '#description' => t('Select which affiliates these users should belong to. <em>Note: this will erase any current assignment for the selected users.</em>'),
    '#default_value' => array(
      $_domain['domain_id'],
    ),
  );
  if ($format) {
    $form['domain']['domains']['#multiple'] = TRUE;
    $form['domain']['domains']['#size'] = count($options) > 10 ? 10 : count($options);
  }

  // Add our domain elements.
  $ops = array_pop($form['accounts']['#header']);
  $form['accounts']['#header']['domain_user'] = array(
    'data' => t('Assigned Domains'),
  );
  foreach (array_keys($form['accounts']['#options']) as $uid) {
    $form['accounts']['#options'][$uid]['domain_user'] = theme('item_list', array(
      'items' => _domain_user_list($uid),
    ));
  }
  $form['accounts']['#header']['operations'] = $ops;
  $form['#submit'][] = 'domain_update_users';
}