function hosting_queues_configure in Hosting 7.4
Same name and namespace in other branches
- 5 hosting.module \hosting_queues_configure()
- 6.2 hosting.module \hosting_queues_configure()
- 7.3 hosting.module \hosting_queues_configure()
Form to configure the frequency of queue execution.
1 string reference to 'hosting_queues_configure'
- hosting_menu in ./
hosting.module - Implements hook_menu().
File
- ./
hosting.module, line 936 - Hosting module.
Code
function hosting_queues_configure($form, &$form_state) {
drupal_add_css(drupal_get_path('module', 'hosting') . '/hosting.css');
$units = array(
strtotime("1 second", 0) => t("Seconds"),
strtotime("1 minute", 0) => t("Minutes"),
strtotime("1 hour", 0) => t("Hours"),
strtotime("1 day", 0) => t("Days"),
strtotime("1 week", 0) => t("Weeks"),
);
$queues = hosting_get_queues();
$form['#tree'] = TRUE;
foreach ($queues as $queue => $info) {
$form[$queue]["enabled"] = array(
'#type' => 'checkbox',
'#default_value' => $info['enabled'],
'#title' => $info['name'],
'#description' => $info['description'],
);
$form[$queue]["last_run"] = array(
'#markup' => hosting_format_interval(variable_get('hosting_queue_' . $queue . '_last_run', FALSE)),
);
$form[$queue]['frequency']['#prefix'] = "<div class='hosting-queue-frequency'>";
$form[$queue]['frequency']['#suffix'] = "</div>";
if ($info['type'] == HOSTING_QUEUE_TYPE_BATCH) {
$form[$queue]['frequency']['items'] = array(
'#markup' => t('%count %items every', array(
"%count" => $info['total_items'],
"%items" => format_plural($info['total_items'], $info['singular'], $info['plural']),
)),
'#prefix' => "<div class='hosting-queue-frequency-items'>",
'#suffix' => "</div>",
);
}
elseif ($info['type'] == HOSTING_QUEUE_TYPE_SPREAD) {
$form[$queue]['frequency']['items'] = array(
'#markup' => t('%count %items every', array(
"%count" => $info['total_items'],
"%items" => format_plural($info['total_items'], $info['singular'], $info['plural']),
)),
'#prefix' => "<div class='hosting-queue-frequency-items'>",
'#suffix' => "</div>",
);
}
else {
$form[$queue]['frequency']['items'] = array(
'#type' => 'textfield',
'#size' => 3,
'#maxlength' => 3,
'#default_value' => $info['items'],
// @ignore i18n_11
'#suffix' => ' ' . t('%items every', array(
'%items' => $info['plural'],
)) . ' ',
'#attributes' => array(
'class' => array(
'hosting-select-frequency-items',
),
),
);
}
foreach (array_reverse(array_keys($units)) as $length) {
$unit = $units[$length];
if (!($info['frequency'] % $length)) {
$frequency_ticks = $info['frequency'] / $length;
$frequency_length = $length;
break;
}
}
$form[$queue]['frequency']["ticks"] = array(
'#type' => 'textfield',
'#default_value' => $frequency_ticks,
'#maxlength' => 5,
'#size' => 5,
'#attributes' => array(
'class' => array(
'hosting-select-frequency-ticks',
),
),
);
$form[$queue]['frequency']["unit"] = array(
'#type' => 'select',
'#options' => $units,
'#default_value' => $frequency_length,
'#attributes' => array(
'class' => array(
'hosting-select-frequency-unit',
),
),
);
}
$form['help'] = array(
'#type' => 'item',
'#description' => t("Increasing the queue frequency to every 1 second will not cause them to be dispatched every second, as the dispatcher can only run once per minute via cron. However, with such a short frequency, executing the hosting-dispatch command manually from the CLI will allow you to 'force' the queues to be dispatched between cron runs. This may be useful for development purposes."),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save changes'),
);
return $form;
}