function pm_admin_settings in Drupal PM (Project Management) 7
Same name and namespace in other branches
- 8 includes/pm.settings.inc \pm_admin_settings()
- 7.3 includes/pm.settings.inc \pm_admin_settings()
- 7.2 pm.module \pm_admin_settings()
Defines the administration settings form for the Project Management module
File
- ./
pm.module, line 409 - Main module file for the Project Management module.
Code
function pm_admin_settings() {
$form = array();
$w = -10;
$form['icons'] = array(
'#type' => 'fieldset',
'#title' => t('Icons'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#weight' => $w++,
);
$form['icons']['pm_icons_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display Project Management icons'),
'#default_value' => variable_get('pm_icons_display', TRUE),
'#description' => t('The icons that ship with Project Management may not fit well with some themes. If this box is unchecked, icons will be hidden.'),
'#weight' => $w++,
);
$form['icons']['pm_icons_path'] = array(
'#type' => 'textfield',
'#title' => t('Icons directory'),
'#default_value' => variable_get('pm_icons_path', drupal_get_path('module', 'pm') . '/icons'),
'#description' => t("The directory that contains Project Management's icons."),
'#weight' => $w++,
'#element_validate' => array(
'pm_admin_settings_icons_path_validate',
),
);
$form['taxation'] = array(
'#type' => 'fieldset',
'#title' => t('Taxation defaults'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#weight' => $w++,
);
$form['taxation']['pm_tax1_app'] = array(
'#type' => 'select',
'#title' => t('Tax 1: Application'),
'#default_value' => variable_get('pm_tax1_app', 1),
'#description' => t('The method of application to use for Tax 1'),
'#options' => array(
1 => t('Apply to item amount'),
0 => t('Do not apply tax'),
),
'#weight' => $w++,
);
$form['taxation']['group0'] = array(
'#type' => 'markup',
// '#theme' => 'pm_form_group',
'#weight' => $w++,
);
$form['taxation']['group0']['pm_tax1_name'] = array(
'#type' => 'textfield',
'#title' => t('Tax 1: Name'),
'#default_value' => variable_get('pm_tax1_name', 'VAT'),
'#description' => t('The name to use for Tax 1'),
'#weight' => $w++,
);
$form['taxation']['group0']['pm_tax1_percent'] = array(
'#type' => 'textfield',
'#title' => t('Tax 1: Default percentage'),
'#default_value' => variable_get('pm_tax1_percent', 20),
'#description' => t('Default percentage for Tax 1'),
'#size' => 20,
'#weight' => $w++,
);
$form['taxation']['pm_tax2_app'] = array(
'#type' => 'select',
'#title' => t('Tax 2: Application'),
'#default_value' => variable_get('pm_tax2_app', 0),
'#description' => t('The method of application to use for Tax 2'),
'#options' => array(
2 => t('Apply to total of item amount plus previous tax'),
1 => t('Apply to item amount'),
0 => t('Do not apply tax'),
),
'#weight' => $w++,
);
$form['taxation']['group1'] = array(
'#type' => 'markup',
// '#theme' => 'pm_form_group',
'#weight' => $w++,
);
$form['taxation']['group1']['pm_tax2_name'] = array(
'#type' => 'textfield',
'#title' => t('Tax 2: Name'),
'#default_value' => variable_get('pm_tax2_name', 'Tax 2 Name'),
'#description' => t('The name to use for Tax 2'),
'#weight' => $w++,
);
$form['taxation']['group1']['pm_tax2_percent'] = array(
'#type' => 'textfield',
'#title' => t('Tax 2: Default percentage'),
'#default_value' => variable_get('pm_tax2_percent', 20),
'#description' => t('Default percentage for Tax 2'),
'#size' => 20,
'#weight' => $w++,
);
$form['taxation']['pm_tax_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display tax edit fields'),
'#default_value' => variable_get('pm_tax_display', TRUE),
'#description' => t('If disabled, all tax fields will use the default values and you will not be able to override them for any nodes until this setting is enabled again.'),
'#weight' => $w++,
);
$form['taxation']['pm_tax2_display'] = array(
'#type' => 'checkbox',
'#title' => t('Display tax 2 edit fields'),
'#default_value' => variable_get('pm_tax2_display', TRUE),
'#description' => t('If disabled, tax 2 fields will use the default values and you will not be able to override them for any nodes until this setting is enabled again. This setting will be ignored unless the general "Display tax edit fields" setting is enabled above.'),
'#weight' => $w++,
);
// DASHBOARD SETTINGS
$form['pm_dashboard_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Dashboard settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$types = module_invoke_all('pm_dashboard_types');
foreach ($types as $type => $type_data) {
$all_links_options = array();
$all_links = pm_dashboard_get_links(FALSE, $type);
foreach ($all_links as $link) {
$all_links_options[$link['path']] = l($link['title'], $link['path']);
}
$default_dashboard_settings = variable_get('pm_' . $type . 'dashboard_settings', array());
$form['pm_dashboard_settings'][$type] = array(
'#type' => 'fieldset',
'#title' => t($type_data['title']),
'#description' => $type_data['description'],
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['pm_dashboard_settings'][$type]['dashboard_links'] = array(
// '#theme' => 'pm_dashboard_links_weight_table',
'#infix' => $type,
);
$weight = 0;
foreach ($all_links_options as $path => $title) {
$form['pm_dashboard_settings'][$type]['dashboard_links'][$path][$type . '_pm_dashboard_link_active_' . $path] = array(
'#type' => 'checkbox',
'#title' => $title,
'#default_value' => isset($default_dashboard_settings[$path]['active']) ? $default_dashboard_settings[$path]['active'] : TRUE,
);
$form['pm_dashboard_settings'][$type]['dashboard_links'][$path][$type . '_pm_dashboard_link_weight_' . $path] = array(
'#type' => 'weight',
'#default_value' => isset($default_dashboard_settings[$path]['weight']) ? $default_dashboard_settings[$path]['weight'] : $weight,
'#delta' => 30,
);
$form['pm_dashboard_settings'][$type]['dashboard_links'][$path]['#value'] = $title;
$weight++;
}
}
if (empty($form['#submit'])) {
$form['#submit'] = array();
}
$form['#submit'] = array(
'pm_admin_settings_form_submit',
);
return system_settings_form($form);
}