function hosting_queues_configure in Hosting 6.2
Same name and namespace in other branches
- 5 hosting.module \hosting_queues_configure()
- 7.4 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 - Implementation of hook_menu().
File
- ./
hosting.module, line 620 - Hosting module.
Code
function hosting_queues_configure() {
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]['description'] = array(
'#type' => 'item',
'#value' => $info['name'],
'#description' => $info['description'],
);
$form[$queue]["enabled"] = array(
'#type' => 'checkbox',
'#default_value' => $info['enabled'],
);
$form[$queue]["last_run"] = array(
'#value' => 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'] == 'batch') {
$form[$queue]['frequency']['items'] = array(
'#value' => 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'],
'#suffix' => t(' %items every ', array(
'%items' => $info['plural'],
)),
'#attributes' => array(
'class' => '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' => 'hosting-select-frequency-ticks',
),
);
$form[$queue]['frequency']["unit"] = array(
'#type' => 'select',
'#options' => $units,
'#default_value' => $frequency_length,
'#attributes' => array(
'class' => '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;
}