You are here

function hosting_queue_summary_block in Hosting 7.3

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

Build a block summarising the hosting queues.

1 call to hosting_queue_summary_block()
hosting_block_view in ./hosting.module
Implements hook_block_view().

File

./hosting.module, line 613
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', array(
        'items' => $disp,
        'title' => $info['name'],
      ));
    }
    return $output;
  }
}