Merge "Make it possible to sort on simple custom columns"
[ninja.git] / modules / reports / libraries / Alert_history_options.php
blobed8c6ba60569249a2905f481ac3c028269404ef3
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 /**
7 * Callback helper for getting the bitmask host/service states into array form
8 */
9 function rewrite_states($name, $value, $obj) {
10 if (is_array($value))
11 return $value;
12 $res = array();
13 foreach ($obj->properties[$name]['options'] as $bit => $_) {
14 if ($value & $bit)
15 $res[$bit] = $bit;
17 return $res;
20 public function setup_properties() {
21 parent::setup_properties();
22 $this->properties['host_states']['type'] = 'array';
23 $this->properties['service_states']['type'] = 'array';
25 $this->properties['report_period']['default'] = 'forever';
26 $this->properties['report_type']['default'] = 'hosts';
27 $this->properties['summary_items']['default'] = config::get('pagination.default.items_per_page', '*');
28 $this->properties['host_name']['default'] = Report_options::ALL_AUTHORIZED;
29 if(ninja::has_module('synergy')) {
30 $this->properties['synergy_events'] = array('type' => 'boolean', 'default' => false);
32 $this->properties['host_states']['options'] = array(
33 1 => _('Up'),
34 2 => _('Down'),
35 4 => _('Unreachable'),
37 $this->properties['service_states']['options'] = array(
38 1 => _('Ok'),
39 2 => _('Warning'),
40 4 => _('Critical'),
41 8 => _('Unknown'),
44 $this->properties['page'] = array('type' => 'int', 'default' => 1); /**< Warning! 1 indexed */
45 $this->properties['include_downtime'] = array('type' => 'bool', 'default' => false);
46 $this->properties['include_process'] = array('type' => 'bool', 'default' => false);
47 $this->properties['oldest_first'] = array('type' => 'bool', 'default' => false);
48 $this->properties['filter_output'] = array('type' => 'string', 'default' => false);
50 $this->rename_options['service_states'] = array($this, 'rewrite_states');
51 $this->rename_options['host_states'] = array($this, 'rewrite_states');
54 protected function update_value($name, $value)
56 switch ($name) {
57 case 'host_states':
58 case 'service_states':
59 $value = array_sum(array_keys($value));
60 break;
62 parent::update_value($name, $value);