You are here

function ultimate_cron_function_settings_form in Ultimate Cron 6

Same name and namespace in other branches
  1. 8 ultimate_cron.admin.inc \ultimate_cron_function_settings_form()
  2. 7 ultimate_cron.admin.inc \ultimate_cron_function_settings_form()

Function settings form.

1 string reference to 'ultimate_cron_function_settings_form'
ultimate_cron_menu in ./ultimate_cron.module
Implementation of hook_menu().

File

./ultimate_cron.admin.inc, line 118

Code

function ultimate_cron_function_settings_form($form, $function) {

  // Load settings
  $hooks = ultimate_cron_get_hooks();
  if (!isset($hooks[(string) $function])) {
    drupal_not_found();
    exit;
  }

  // Load settings
  $hook = $hooks[$function];
  $conf = ultimate_cron_get_settings($function);
  $conf += _ultimate_cron_default_settings();

  // Setup form
  drupal_set_title(check_plain($function));
  $form = array();
  $advanced_help_enabled = module_exists('advanced_help');

  // General settings -----------------------------------
  $form['function'] = array(
    '#type' => 'value',
    '#value' => $function,
  );
  $form['general'] = array(
    '#title' => t('General'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#tree' => TRUE,
  );
  $form['general']['enabled'] = array(
    '#title' => t('Enabled'),
    '#type' => 'checkbox',
    '#default_value' => $conf['enabled'],
    '#description' => t('Enable this cron job.'),
  );
  $form['general']['rules'] = array(
    '#title' => t('Rules'),
    '#type' => 'textfield',
    '#default_value' => implode(';', $conf['rules']),
    '#description' => ($advanced_help_enabled ? theme('advanced_help_topic', 'ultimate_cron', 'rules') : '') . t('Semi-colon separated list of rules for this job. (blank = ' . implode(';', $hook['settings']['rules']) . ')'),
  );
  $form['general']['catch_up'] = array(
    '#title' => t('Catch up'),
    '#type' => 'textfield',
    '#default_value' => $conf['catch_up'],
    '#description' => ($advanced_help_enabled ? theme('advanced_help_topic', 'ultimate_cron', 'catch_up') : '') . t('Time in seconds to catch up, if a job could not be run within its time frame. (blank = ' . variable_get('ultimate_cron_catch_up', ULTIMATE_CRON_CATCH_UP) . ')'),
  );
  if (module_exists('drupal_queue') && strpos($function, 'ultimate_cron_queue_') === 0) {
    $form['general']['queue_lease_time'] = array(
      '#title' => t('Queue lease time'),
      '#type' => 'textfield',
      '#default_value' => $conf['queue_lease_time'],
      '#description' => ($advanced_help_enabled ? theme('advanced_help_topic', 'ultimate_cron', 'queue_lease_time') : '') . t('Time in seconds to keep lock on claimed item. (blank = ' . variable_get('ultimate_cron_queue_lease_time', ULTIMATE_CRON_QUEUE_LEASE_TIME) . ')'),
    );
    $form['general']['queue_polling_throttle'] = array(
      '#title' => t("Queue polling throttle"),
      '#type' => 'textfield',
      '#default_value' => $conf['queue_polling_throttle'],
      '#description' => ($advanced_help_enabled ? theme('advanced_help_topic', array(
        'module' => 'ultimate_cron',
        'topic' => 'polling_throttle',
        'type' => 'icon',
      )) : '') . t('Queue polling throttle in miliseconds.'),
    );
  }
  $methods = module_invoke_all('service_group');
  $service_groups = $options = ultimate_cron_get_service_groups();
  foreach ($options as $key => &$value) {
    $value = (empty($value['description']) ? $key : $value['description']) . ' (' . join(',', $value['hosts']) . ') : ' . $methods['methods'][$value['method']];
  }
  $options += array(
    NULL => 'Ultimate Cron service group (' . join(',', $service_groups[variable_get('ultimate_cron_service_group', ULTIMATE_CRON_SERVICE_GROUP)]['hosts']) . ') : ' . $methods['methods'][$service_groups[variable_get('ultimate_cron_service_group', ULTIMATE_CRON_SERVICE_GROUP)]['method']],
  );
  $form['general']['service_group'] = array(
    '#type' => 'select',
    '#title' => t('Service group'),
    '#description' => ($advanced_help_enabled ? theme('advanced_help_topic', 'ultimate_cron', 'service_group') : '') . t('Service group to use for this job. See Background Process !url for managing service groups.', array(
      '!url' => l(t('settings'), 'admin/settings/background-process'),
    )),
    '#options' => $options,
    '#default_value' => isset($conf['service_group']) ? $conf['service_group'] : NULL,
  );
  $form['buttons'] = array(
    '#weight' => 1000,
  );
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  $form['#redirect'] = 'admin/settings/cron';
  return $form;
}