You are here

function hosting_queue_summary_block in Hostmaster (Aegir) 6

Build a block summarising the hosting queues.

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

File

modules/hosting/hosting.module, line 362
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;
  }
}