You are here

function ad_weight_probability_form_alter in Advertisement 5.2

Same name and namespace in other branches
  1. 6.3 weight/probability/ad_weight_probability.module \ad_weight_probability_form_alter()
  2. 6.2 weight/probability/ad_weight_probability.module \ad_weight_probability_form_alter()
  3. 7 weight/probability/ad_weight_probability.module \ad_weight_probability_form_alter()

Implementation of hook_form_alter(). Generate a form for assigning a weight to an advertisement.

File

weight/probability/ad_weight_probability.module, line 18
A plug in for the ad.module, allowing an admin to set the probability that a given advertisement will be displayed.

Code

function ad_weight_probability_form_alter($form_id, &$form) {
  if (isset($form['type']) && $form_id == 'ad_node_form') {
    $node = $form['#node'];
    $form['weighting'] = array(
      '#type' => 'fieldset',
      '#access' => user_access('configure ad probability'),
      '#title' => t('Weight'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['weighting']['probability'] = array(
      '#type' => 'select',
      '#access' => user_access('configure ad probability'),
      '#title' => t('Probability'),
      '#options' => _ad_weight_probability_weights(),
      '#default_value' => $node->probability,
      '#description' => t('The greater the probability, the more frequently this advertisement will be displayed.  An advertisement with a probablity of 2 will be displayed twice as frequently as an advertisement with a probability of 1.'),
    );
    $form['weighting']['#weight'] = -1;
  }
}