You are here

public function UltimateCronSerialLauncher::settingsForm in Ultimate Cron 7.2

Settings form for the crontab scheduler.

Overrides UltimateCronPlugin::settingsForm

File

plugins/ultimate_cron/launcher/serial.class.php, line 39
Serial cron job launcher for Ultimate Cron.

Class

UltimateCronSerialLauncher
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['timeouts'] = array(
    '#type' => 'fieldset',
    '#title' => t('Timeouts'),
  );
  $elements['launcher'] = array(
    '#type' => 'fieldset',
    '#title' => t('Launching options'),
  );
  $elements['timeouts']['lock_timeout'] = array(
    '#parents' => array(
      'settings',
      $this->type,
      $this->name,
      'lock_timeout',
    ),
    '#title' => t("Job lock timeout"),
    '#type' => 'textfield',
    '#default_value' => $values['lock_timeout'],
    '#description' => t('Number of seconds to keep lock on job.'),
    '#fallback' => TRUE,
    '#required' => TRUE,
  );
  if (!$job) {
    $max_threads = $values['max_threads'];
    $elements['launcher']['max_threads'] = array(
      '#parents' => array(
        'settings',
        $this->type,
        $this->name,
        'max_threads',
      ),
      '#title' => t("Maximum number of launcher threads"),
      '#type' => 'textfield',
      '#default_value' => $max_threads,
      '#description' => t('The maximum number of launch threads that can be running at any given time.'),
      '#fallback' => TRUE,
      '#required' => TRUE,
      '#element_validate' => array(
        'element_validate_number',
      ),
      '#weight' => 1,
    );
    $elements['launcher']['poorman_keepalive'] = array(
      '#parents' => array(
        'settings',
        $this->type,
        $this->name,
        'poorman_keepalive',
      ),
      '#title' => t("Poormans cron keepalive"),
      '#type' => 'checkbox',
      '#default_value' => $values['poorman_keepalive'],
      '#description' => t('Retrigger poormans cron after it has finished. Requires $base_url to be accessible from the webserver.'),
      '#fallback' => TRUE,
      '#weight' => 3,
    );
  }
  else {
    $settings = $this
      ->getDefaultSettings();
    $max_threads = $settings['max_threads'];
  }
  $options = array(
    'any' => '-- ' . t('Any') . ' --',
    'fixed' => '-- ' . t('Fixed') . ' --',
  );
  for ($i = 1; $i <= $max_threads; $i++) {
    $options[$i] = $i;
  }
  $elements['launcher']['thread'] = array(
    '#parents' => array(
      'settings',
      $this->type,
      $this->name,
      'thread',
    ),
    '#title' => t("Run in thread"),
    '#type' => 'select',
    '#default_value' => $values['thread'],
    '#options' => $options,
    '#description' => t('Which thread to run jobs in.') . "<br/>" . t('<strong>Any</strong>: Just use any available thread') . "<br/>" . t('<strong>Fixed</strong>: Only run in one specific thread. The maximum number of threads is spread across the jobs.') . "<br/>" . t('<strong>1-?</strong>: Only run when a specific thread is invoked. This setting only has an effect when cron is run through cron.php with an argument ?thread=N or through Drush with --options=thread=N.'),
    '#fallback' => TRUE,
    '#required' => TRUE,
    '#weight' => 2,
  );
}