You are here

function heartbeat_admin_settings in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 heartbeat.admin.inc \heartbeat_admin_settings()
  2. 6.2 heartbeat.admin.inc \heartbeat_admin_settings()
  3. 6.3 heartbeat.admin.inc \heartbeat_admin_settings()

Function to maintain and administer heartbeat settings.

Return value

settingsform

1 string reference to 'heartbeat_admin_settings'
heartbeat_ui_menu in modules/heartbeat_ui/heartbeat_ui.module
Implements hook_menu(). TODO Fix admin/structure/heartbeat/cache-clear

File

modules/heartbeat_ui/heartbeat_ui.admin.inc, line 130

Code

function heartbeat_admin_settings() {
  $form = array();
  $form['general'] = array(
    '#type' => 'vertical_tabs',
  );

  // log settings
  $form['hb_logging'] = array(
    '#type' => 'fieldset',
    '#weight' => -5,
    '#title' => t('Log activity'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#group' => 'general',
  );
  $form['hb_logging']['heartbeat_enabled'] = array(
    '#title' => t('Display heartbeat activity streams'),
    '#description' => t('This is a quick way to deny the stream from display.'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('heartbeat_enabled', 1),
    '#weight' => -5,
  );
  $form['hb_logging']['heartbeat_debug'] = array(
    '#title' => t('Run the heartbeat message builder in debug mode'),
    '#description' => t('This is not for production sites. It\'s a developer tool to see which messages are blocked for which reason. Note that this needs to show for all user roles!'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('heartbeat_debug', 0),
    '#weight' => -5,
  );
  $cron_delete_options = array(
    0 => t('Never, my queries are limited manually'),
    604800 => t('Older than a week'),
    2678400 => t('Older than a month'),
    5270400 => t('Older than two months'),
    7948800 => t('Older than three months'),
  );
  $form['hb_logging']['heartbeat_activity_log_cron_delete'] = array(
    '#title' => 'Delete messages older than ... (by cron)',
    '#type' => 'select',
    '#options' => $cron_delete_options,
    '#default_value' => variable_get('heartbeat_activity_log_cron_delete', 2678400),
  );
  $form['hb_logging']['heartbeat_activity_records_per_user'] = array(
    '#title' => t('Number of messages to keep in database for each user'),
    '#type' => 'textfield',
    '#default_value' => variable_get('heartbeat_activity_records_per_user', 10),
  );

  // display settings
  $form['hb_fields'] = array(
    '#type' => 'fieldset',
    '#weight' => -4,
    '#title' => t('Display activity'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'general',
  );
  $form['hb_fields']['heartbeat_include_default_style'] = array(
    '#title' => t('Enable default style'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('heartbeat_include_default_style', 1),
    '#description' => t('When disabled, heartbeat.css is not included meaning you don\'t have to override the FB-alike style.'),
  );
  $form['hb_fields']['heartbeat_allowed_html_tags'] = array(
    '#title' => t('Allowed html tags'),
    '#type' => 'textfield',
    '#default_value' => heartbeat_allowed_html_tags(),
    '#description' => t('Type html tags to allow in activity using a space to separate the tags.'),
  );
  $form['hb_fields']['heartbeat_show_message_times'] = array(
    '#title' => t('Show the time of action in message displays'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('heartbeat_show_message_times', 1),
    '#description' => t('Disabling the display overrules all other settings.'),
  );
  $form['hb_fields']['heartbeat_show_time_grouped_items'] = array(
    '#title' => t('Show the time of action with messages are grouped together'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('heartbeat_show_time_grouped_items', 1),
  );
  $value = variable_get('heartbeat_activity_grouping_seconds', 7200);
  $form['hb_fields']['heartbeat_activity_grouping_seconds'] = array(
    '#title' => t('Maximum gap (in seconds)'),
    '#type' => 'select',
    '#default_value' => $value,
    '#options' => array(
      300 => t('5 minutes'),
      600 => t('10 minutes'),
      1200 => t('20 minutes'),
      1800 => t('30 minutes'),
      3600 => t('1 hour'),
      7200 => t('2 hours'),
      14400 => t('4 hours'),
      86400 => t('24 hours'),
    ),
    '#description' => t('Maximum gap for the same activity to be grouped together and before an identical activity can be logged again'),
  );
  $form['hb_fields']['heartbeat_activity_grouping_how_many'] = array(
    '#title' => 'Maximum number of messages to group',
    '#type' => 'textfield',
    '#size' => 20,
    '#default_value' => variable_get('heartbeat_activity_grouping_how_many', 5),
    '#description' => 'Maximum number of items that can be grouped. This can be overruled for each heartbeat message specific.',
  );

  // profile settings
  $form['hb_profile'] = array(
    '#type' => 'fieldset',
    '#weight' => -3,
    '#title' => t('User profile'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'general',
  );
  $templates = array();
  ctools_include("export");
  foreach (ctools_export_crud_load_all('heartbeat_messages') as $template) {
    $templates[$template->message_id] = $template->message_id;
  }
  $form['hb_profile']['heartbeat_profile_message_templates'] = array(
    '#title' => t('Select the templates to show on the profile page'),
    '#description' => t('The enduser can have the possibility to set the restriction level of message types. Here the administrator can select and expose those message templates you want to display on the profile page.'),
    '#type' => 'select',
    '#multiple' => TRUE,
    '#options' => $templates,
    '#default_value' => variable_get('heartbeat_profile_message_templates', array()),
  );
  $form = system_settings_form($form);
  return $form;
}