You are here

public function UltimateCronBackgroundProcessLegacyLauncher::settingsForm in Ultimate Cron 7.2

Settings form for the crontab scheduler.

Overrides UltimateCronPlugin::settingsForm

File

plugins/ultimate_cron/launcher/background_process_legacy.class.php, line 141
Background Process 1.x launcher for Ultimate Cron.

Class

UltimateCronBackgroundProcessLegacyLauncher
Ultimate Cron launcher plugin class.

Code

public function settingsForm(&$form, &$form_state, $job = NULL) {
  $elements =& $form['settings'][$this->type][$this->name];
  $values =& $form_state['values']['settings'][$this->type][$this->name];
  $elements['recheck'] = array(
    '#title' => t("Re-check schedule"),
    '#type' => 'select',
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#default_value' => $values['recheck'],
    '#description' => t('If checked, the jobs schedule will be re-checked after launch in order to make sure, that the job is not run outside its launch window.'),
    '#fallback' => TRUE,
    '#required' => TRUE,
  );
  if (!$job) {
    $elements['max_threads'] = array(
      '#title' => t("Max threads"),
      '#type' => 'textfield',
      '#default_value' => $values['max_threads'],
      '#description' => t('Maximum number of concurrent cron jobs to run.'),
      '#fallback' => TRUE,
      '#required' => TRUE,
    );
  }
  $methods = module_invoke_all('service_group');
  $options = $this
    ->getServiceGroups();
  foreach ($options as $key => &$value) {
    $value = (empty($value['description']) ? $key : $value['description']) . ' (' . implode(',', $value['hosts']) . ') : ' . $methods['methods'][$value['method']];
  }
  $elements['service_group'] = array(
    '#title' => t("Service group"),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $values['service_group'],
    '#description' => $job ? t('Service group to use for this job.') : t('Service group to use for jobs.'),
    '#fallback' => TRUE,
    '#required' => TRUE,
  );
  if (!$job) {
    $elements['poorman_service_group'] = array(
      '#title' => t("Poormans Cron service group"),
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $values['poorman_service_group'],
      '#description' => t('Service group to use for the poormans cron launcher.'),
      '#fallback' => TRUE,
      '#required' => TRUE,
    );
  }
  $elements['daemonize'] = array(
    '#title' => t('Daemonize'),
    '#type' => 'checkbox',
    '#default_value' => $values['daemonize'],
    '#description' => t('Relaunch job immediately after it is finished.'),
  );
  $elements['daemonize_interval'] = array(
    '#title' => t('Interval'),
    '#type' => 'textfield',
    '#default_value' => $values['daemonize_interval'],
    '#description' => t('Seconds to run the job in the same thread before relaunching.'),
    '#states' => array(
      'visible' => array(
        ':input[name="settings[' . $this->type . '][' . $this->name . '][daemonize]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $elements['daemonize_delay'] = array(
    '#title' => t('Delay'),
    '#type' => 'textfield',
    '#default_value' => $values['daemonize_delay'],
    '#description' => t('Delay in seconds between in job execution.'),
    '#states' => array(
      'visible' => array(
        ':input[name="settings[' . $this->type . '][' . $this->name . '][daemonize]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
}