You are here

function domain_content_add_form_widget in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 domain_content/domain_content.module \domain_content_add_form_widget()
  2. 7.2 domain_content/domain_content.module \domain_content_add_form_widget()

Abstraction function for selecting domains for batch operations.

2 calls to domain_content_add_form_widget()
domain_content_form in domain_content/domain_content.admin.inc
Rewrites node_admin_nodes() to use db_rewrite_sql().
domain_content_form_node_admin_content_alter in domain_content/domain_content.module
Allow domain assignment to be made from the default content form.

File

domain_content/domain_content.module, line 213
Editorial overview module.

Code

function domain_content_add_form_widget(&$form) {
  global $_domain;

  // We have different settings for the two form contexts.
  // A blank form comes from core.
  $prefix = '<div class="description">' . t('If you select <em>Change affiliate publishing options</em>, you should confirm the <em>Affiliate publishing options</em> settings below.') . '</div>';
  $collapsed = TRUE;
  if (empty($form)) {
    $prefix = '';
    $collapsed = FALSE;
  }
  $options = array();
  $format = domain_select_format();
  foreach (domain_domains() as $data) {

    // Cannot pass zero in checkboxes.
    $key = $data['domain_id'] == 0 ? -1 : $data['domain_id'];

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

      // Filter checkboxes but not select lists.
      $options[$key] = empty($format) ? check_plain($data['sitename']) : $data['sitename'];
    }
  }
  $form['domain'] = array(
    '#type' => 'fieldset',
    '#title' => t('Affiliate publishing options'),
    '#collapsible' => TRUE,
    '#collapsed' => $collapsed,
    '#prefix' => $prefix,
  );
  $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 nodes.'),
    '#default_value' => 0,
  );
  $form['domain']['domain_site'] = array(
    '#type' => 'checkbox',
    '#prefix' => t('<p><b>Publishing options:</b>'),
    '#suffix' => '</p>',
    '#title' => t('Send to all affiliates'),
    '#required' => FALSE,
    '#description' => t('Select if this content can be shown to all affiliates.  This setting will override the options below.'),
    '#default_value' => variable_get('domain_behavior', DOMAIN_INSTALL_RULE),
  );
  $form['domain']['domains'] = array(
    '#type' => empty($format) ? 'checkboxes' : 'select',
    '#title' => t('Publish to'),
    '#options' => $options,
    '#required' => FALSE,
    '#description' => t('Select which affiliates can access this content.'),
    '#default_value' => array(
      $_domain['domain_id'] == 0 ? -1 : $_domain['domain_id'],
    ),
  );
  if ($format) {
    $form['domain']['domains']['#multiple'] = TRUE;
    $form['domain']['domains']['#size'] = count($options) > 10 ? 10 : count($options);
  }
}