You are here

function total_control_admin_settings in Total Control Admin Dashboard 6.2

Same name and namespace in other branches
  1. 7.2 total_control.admin.inc \total_control_admin_settings()

menu callback for settings page

1 string reference to 'total_control_admin_settings'
total_control_menu in ./total_control.module
Implementation of hook_menu().

File

./total_control.admin.inc, line 14
total_control.admin.inc

Code

function total_control_admin_settings() {

  // Redirect on log in
  $form['total_control_login_redirect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Redirect administrators to Dashboard after log in'),
    '#default_value' => variable_get('total_control_login_redirect', 0),
    '#description' => t('Users with the !permission can be automatically redirected to the Dashboard when they log in.', array(
      '!permission' => l(t('Have Total Control permission'), 'admin/user/permissions'),
    )),
  );
  $overridden = '<strong>' . t('  Automatic settings override these options.') . '</strong>';
  $collapse_type = FALSE;
  $collapse_role = FALSE;
  $collapse_auto = TRUE;
  $disable_type_pane = '';
  $disable_type_page = '';
  $disable_role_pane = '';
  $disable_role_page = '';
  $auto_pane_default = variable_get('total_control_auto_panels', array());
  $auto_page_default = variable_get('total_control_auto_pages', array());
  $types = node_get_types();
  $options = array();
  foreach ($types as $machine => $type) {
    $options[$machine] = $type->name;
  }
  if (!empty($auto_pane_default) && !($auto_pane_default['type'] === 0)) {
    $disable_type_pane = TRUE;
    $collapse_auto = FALSE;
  }
  if (!empty($auto_page_default) && !($auto_page_default['type'] === 0)) {
    $disable_type_page = TRUE;
    $collapse_auto = FALSE;
  }
  if (!empty($auto_page_default) && !empty($auto_pane_default) && !($auto_page_default['type'] === 0) && !($auto_pane_default['type'] === 0)) {
    $collapse_type = TRUE;
  }
  $roles = user_roles(TRUE);
  $role_options = array();
  $role_defaults = array(
    2,
  );
  foreach ($roles as $rid => $role) {
    $role_options[$rid] = $role . 's';
  }
  if (!empty($auto_pane_default) && !($auto_pane_default['role'] === 0)) {
    $disable_role_pane = TRUE;
    $collapse_auto = FALSE;
  }
  if (!empty($auto_page_default) && !($auto_page_default['role'] === 0)) {
    $disable_role_page = TURE;
    $collapse_auto = FALSE;
  }
  if (count($roles) == 1 || !($auto_page_default['role'] === 0) && !($auto_pane_default['role'] === 0) && (!empty($auto_page_default) && !empty($auto_pane_default))) {
    $collapse_role = TRUE;
  }
  $auto_options = array(
    'type' => t('Content Types'),
  );

  // Content types, pages and panes
  $form['types'] = array(
    '#type' => 'fieldset',
    '#title' => t('Types of content: pages and panes'),
    '#collapsible' => TRUE,
    '#collapsed' => $collapse_type,
  );
  $text = t('Make panes on the dashboard for these content types.');
  $description = $disable_type_pane ? $text . $overridden : $text;
  $form['types']['total_control_type_panels'] = array(
    '#type' => 'checkboxes',
    '#title' => t('On the Dashboard'),
    '#options' => $options,
    '#description' => $description,
    '#default_value' => variable_get('total_control_type_panels', array()),
    '#disabled' => $disable_type_pane,
  );
  $text = t('Make administration pages for these content types.');
  $description = $disable_type_page ? $text . $overridden : $text;
  $form['types']['total_control_type_pages'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Administration Pages'),
    '#options' => $options,
    '#description' => $description,
    '#default_value' => variable_get('total_control_type_pages', array()),
    '#disabled' => $disable_type_page,
  );

  // User roles, pages and panes
  $form['users'] = array(
    '#type' => 'fieldset',
    '#title' => t('Types of users: pages and panes'),
    '#collapsible' => TRUE,
    '#collapsed' => $collapse_role,
  );
  $form['users']['total_control_role_panels'] = array(
    '#type' => 'checkboxes',
    '#title' => t('On the Dashboard'),
    '#options' => $role_options,
    '#description' => t('Make panes on the dashboard for these user types'),
    '#default_value' => variable_get('total_control_role_panels', $role_defaults),
  );
  $form['users']['total_control_role_pages'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Administration Pages'),
    '#options' => $role_options,
    '#description' => t('Make administration pages for these user types'),
    '#default_value' => variable_get('total_control_role_pages', $role_defaults),
  );

  // Automatically add displays
  $form['auto'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced Settings: Automatically add pages and panes'),
    '#collapsible' => TRUE,
    '#collapsed' => $collapse_auto,
  );
  $form['auto']['total_control_auto_panels'] = array(
    '#type' => 'checkboxes',
    '#title' => t('On the Dashboard'),
    '#options' => $auto_options,
    '#description' => t('Automatically make panes on the dashboard when new content types or roles are added.'),
    '#default_value' => $auto_pane_default,
  );
  $form['auto']['total_control_auto_pages'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Administration Pages'),
    '#options' => $auto_options,
    '#description' => t('Automatically make administration pages when new content types or roles are added.'),
    '#default_value' => $auto_page_default,
  );
  $form['#submit'][] = 'total_control_admin_settings_submit';
  return system_settings_form($form);
}