You are here

function ad_owners_form_alter in Advertisement 6

Same name and namespace in other branches
  1. 6.3 owners/ad_owners.module \ad_owners_form_alter()
  2. 6.2 owners/ad_owners.module \ad_owners_form_alter()
  3. 7 owners/ad_owners.module \ad_owners_form_alter()

Implementation of hook_form_alter().

File

owners/ad_owners.module, line 95
Enhances the ad module to support ad owners.

Code

function ad_owners_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'ad_' . arg(4) . '_global_settings' || $form_id == 'ad_no_global_settings') {
    if (!isset($form['adtype'])) {
      $form['adtype'] = array(
        '#type' => 'value',
        '#value' => arg(4),
      );
    }
    $permissions = module_invoke_all('adapi', 'permissions', NULL);
    $form['permissions'] = array(
      '#type' => 'fieldset',
      '#title' => t('Permissions'),
      '#collapsible' => TRUE,
      '#description' => t('Select which permissions will be automatically granted to new owners of <em>!type</em> advertisements.', array(
        '!type' => ad_get_types('name', arg(4)),
      )),
    );
    $form['permissions']['default_permissions'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Default permissions for <em>!type</em> owners', array(
        '!type' => ad_get_types('name', arg(4)),
      )),
      '#options' => drupal_map_assoc($permissions),
      '#default_value' => variable_get('ad_' . arg(4) . '_default_permissions', array(
        'access statistics',
        'access click history',
        'manage status',
      )),
    );
    if (isset($form['save'])) {
      $form['save']['#weight'] = 10;
    }
    if (isset($form['#submit']) && is_array($form['#submit'])) {
      $form['#submit'] = array(
        'ad_global_settings_submit',
      ) + $form['#submit'];
    }
    else {
      $form['#submit'] = array(
        'ad_global_settings_submit',
      );
    }
  }
}