You are here

function hosting_queue_summary_block in Hosting 6.2

Same name and namespace in other branches
  1. 5 hosting.module \hosting_queue_summary_block()
  2. 7.4 hosting.module \hosting_queue_summary_block()
  3. 7.3 hosting.module \hosting_queue_summary_block()

Build a block summarising the hosting queues.

1 call to hosting_queue_summary_block()
hosting_block in ./hosting.module
Implementation of hook_block().

File

./hosting.module, line 408
Hosting module.

Code

function hosting_queue_summary_block() {
  if (user_access('administer hosting queues')) {
    $queues = hosting_get_queues();
    $output = '';
    foreach ($queues as $queue => $info) {
      $disp = array();

      # special case
      if (!$info['enabled']) {
        $disp[] = t('Status: disabled');
        continue;
      }
      $disp[] = t('Status: enabled');
      foreach (array(
        'description' => t('Description'),
        'frequency' => t('Frequency'),
        'items' => t('Items per run'),
        'total_items' => t('Items in queue'),
        'last_run' => t('Last run'),
      ) as $key => $title) {
        if ($key == 'last_run') {
          $info[$key] = hosting_format_interval($info[$key]);
        }
        elseif ($key == 'frequency') {
          $info[$key] = t('every @interval', array(
            '@interval' => format_interval($info[$key]),
          ));
        }
        $disp[] = $title . ": " . $info[$key];
      }
      $output .= theme('item_list', $disp, $info['name']);
    }
    return $output;
  }
}