reports: Generalize dates, saved reports
[ninja.git] / modules / reports / libraries / Alert_history_options.php
blob1da4ada4d5e93df4d7fa7f8504b2bd8531499ade
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * Report options for alert history reports. Alert history reports are specialized summary reports.
4 */
5 class Alert_history_options extends Summary_options {
6 public static $type = 'alert_history';
8 /**
9 * Callback helper for getting the bitmask host/service states into array form
11 function rewrite_states($name, $value, $obj) {
12 if (is_array($value))
13 return $value;
14 $res = array();
15 foreach ($obj->properties[$name]['options'] as $bit => $_) {
16 if ($value & $bit)
17 $res[$bit] = $bit;
19 return $res;
22 public function setup_properties() {
23 parent::setup_properties();
24 $this->properties['host_states']['type'] = 'array';
25 $this->properties['service_states']['type'] = 'array';
27 $this->properties['report_period']['default'] = 'forever';
28 $this->properties['report_type']['default'] = 'hosts';
29 $this->properties['summary_items']['default'] = config::get('pagination.default.items_per_page', '*');
30 $this->properties['objects']['default'] = Report_options::ALL_AUTHORIZED;
31 if(ninja::has_module('synergy')) {
32 $this->properties['synergy_events'] = array('type' => 'boolean', 'default' => false);
34 $this->properties['host_states']['options'] = array(
35 1 => _('Up'),
36 2 => _('Down'),
37 4 => _('Unreachable'),
39 $this->properties['service_states']['options'] = array(
40 1 => _('Ok'),
41 2 => _('Warning'),
42 4 => _('Critical'),
43 8 => _('Unknown'),
46 $this->properties['page'] = array('type' => 'int', 'default' => 1); /**< Warning! 1 indexed */
47 $this->properties['include_downtime'] = array('type' => 'bool', 'default' => false);
48 $this->properties['include_process'] = array('type' => 'bool', 'default' => false);
49 $this->properties['oldest_first'] = array('type' => 'bool', 'default' => false);
50 $this->properties['filter_output'] = array('type' => 'string', 'default' => false);
52 $this->rename_options['service_states'] = array($this, 'rewrite_states');
53 $this->rename_options['host_states'] = array($this, 'rewrite_states');
56 protected function update_value($name, $value)
58 switch ($name) {
59 case 'host_states':
60 case 'service_states':
61 $value = array_sum(array_keys($value));
62 break;
64 parent::update_value($name, $value);