You are here

function total_control_overview_content_type_edit_form in Total Control Admin Dashboard 6

Same name and namespace in other branches
  1. 6.2 plugins/content_types/overview.inc \total_control_overview_content_type_edit_form()
  2. 7.2 plugins/content_types/overview.inc \total_control_overview_content_type_edit_form()

File

plugins/content_types/overview.inc, line 103

Code

function total_control_overview_content_type_edit_form(&$form, &$form_state) {
  $conf = $form_state['conf'];
  $types = node_get_types('types');
  $type_options = array();
  $type_defaults = array();
  $comment_defaults = array();
  foreach ($types as $type => $object) {
    $type_options[$type] = $object->name;
    $type_defaults[] = $type;
    if ($type == 'blog' || $type == 'forum topic') {
      $comment_defaults[] = $type;
    }
  }
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Include Stats on Content Types'),
    '#options' => $type_options,
    '#default_value' => $form_state['op'] == 'add' ? $type_defaults : $conf['types'],
  );
  $form['comments'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Include Comment Stats for Content Types'),
    '#options' => $type_options,
    '#default_value' => $form_state['op'] == 'add' ? $comment_defaults : $conf['comments'],
  );
  $spam_options = array(
    0 => t('no'),
    1 => t('Include Spam Comment count'),
  );
  $form['spam'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include Spam Comment count'),
    '#options' => $spam_options,
    '#default_value' => $form_state['op'] == 'add' ? TRUE : $conf['spam'],
  );
  $user_options = array(
    0 => t('no'),
    1 => t('Show User Stats'),
  );
  $form['user'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include User Counts'),
    '#options' => $user_options,
    '#default_value' => $form_state['op'] == 'add' ? TRUE : $conf['user'],
  );
  $roles = user_roles(TRUE);
  $roles_options = array();
  $roles_defaults = array();
  foreach ($roles as $rid => $role) {
    if ($rid != 2) {
      $roles_options[$rid] = $role;
      $roles_defaults[] = $rid;
    }
  }
  if (!empty($roles_options)) {
    $form['roles'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Include User counts in Roles'),
      '#options' => $roles_options,
      '#default_value' => $form_state['op'] == 'add' ? $roles_defaults : $conf['roles'],
    );
  }
  return $form;
}