function ad_permission_form_alter in Advertisement 5.2
Drupal _form_alter() hook.
File
- permission/
ad_permission.module, line 98 - Provide granular permissions for advertisements.
Code
function ad_permission_form_alter($form_id, &$form) {
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);
$all = array();
$perms = array();
foreach ($permissions as $permission => $default) {
if ($default) {
$perms[] = $permission;
}
$all[] = $permission;
}
$node = $form['node'];
$defaults = variable_get('ad_' . $form['adtype']['#value'] . '_default_permissions', $perms);
$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($all),
'#default_value' => $defaults,
);
if (isset($form['save'])) {
$form['save']['#weight'] = 10;
}
$form['#submit'] = array(
'ad_permission_defaults_submit' => array(),
) + (array) $form['#submit'];
}
}