function ad_form_alter in Advertisement 5
Same name and namespace in other branches
- 5.2 ad.module \ad_form_alter()
- 6.3 ad.module \ad_form_alter()
- 6 ad.module \ad_form_alter()
- 6.2 ad.module \ad_form_alter()
- 7 ad.module \ad_form_alter()
Drupal _form_alter() hook.
File
- ./
ad.module, line 780 - An advertising system for Drupal powered websites.
Code
function ad_form_alter($form_id, &$form) {
if ($form_id == 'taxonomy_form_vocabulary') {
// Remove taxonomy form options not applicable for ad groups.
if ($form['vid']['#value'] == _ad_get_vid()) {
$form['help_ad_vocab'] = array(
'#value' => t('This vocabulary was automatically created for use by the ad module. Only applicable options are available.'),
'#weight' => -1,
);
$form['nodes']['ad'] = array(
'#type' => 'checkbox',
'#title' => t('ad group'),
'#value' => 1,
'#attributes' => array(
'disabled' => '',
),
'#description' => t('Type %type is required to use this vocabulary.', array(
'%type' => t('ad group'),
)),
);
$form['tags']['#description'] = t('If enabled, ads are categorized by typing ad group names instead of choosing them from a list.');
$form['multiple']['#description'] = t('If enabled, allows ads to have more than one ad group (always true for free tagging).');
$form['required']['#description'] = t('If enabled, every ad <strong>must</strong> be assigned to at least one ad group.');
$form['hierarchy'] = array(
'#type' => 'value',
'#value' => 0,
);
unset($form['relations']);
}
else {
unset($form['nodes']['ad']);
}
}
else {
if ($form_id == 'taxonomy_form_term') {
if ($form['vid']['#value'] == _ad_get_vid()) {
$form['name']['#title'] = t('Ad group name');
$form['name']['#description'] = t('The name for this ad group. Example: "Linux".');
$form['description']['#description'] = t('A description of the ad group.');
$form['description']['#required'] = TRUE;
$form['weight']['#description'] = t('In listings, the heavier ad groups will sink and the lighter ad groups will be positioned nearer the top.');
unset($form['synonyms']);
}
}
else {
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 !type ads.', array(
'!type' => arg(4),
)),
);
$form['permissions']['default_permissions'] = array(
'#type' => 'checkboxes',
'#title' => t('Default permissions for !type ad owners', array(
'!type' => 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;
}
$form['#submit'] = array(
'ad_global_settings_submit' => array(),
) + (array) $form['#submit'];
}
}
}
}