Report_options is an object representing the user-selected report. More...
Public Member Functions | |
setup_properties () | |
Properties should be completely setup - with translations and all - before loading any options, and options are loaded by the construct, so do initialization here. | |
__construct ($options=false) | |
Public constructor, which optionally takes an iterable with properties to set. | |
offsetGet ($str) | |
Required by ArrayAccess. | |
offsetSet ($key, $val) | |
Required by ArrayAccess. | |
offsetExists ($key) | |
Required by ArrayAccess. | |
offsetUnset ($key) | |
Required by ArrayAccess. | |
properties () | |
This looks silly. | |
get_alternatives ($key) | |
For applicable keys, this returns a list of all possible values. | |
get_value ($key) | |
Returns the user-friendly value, given a machine-friendly option key. | |
get_report_members () | |
Return all objects (hosts or services) this report applies to This will return hosts or services regardless if the report object selection uses groups or not. | |
set_options ($options) | |
Update the options for the report. | |
set ($name, $value) | |
Set an option, with some validation. | |
as_keyval ($anonymous=false, $obj_only=false) | |
A.k.a. | |
as_keyval_string ($anonymous=false, $obj_only=false) | |
Generate a standard HTTP keyval string, suitable for URLs or POST bodies. | |
as_form ($anonymous=false, $obj_only=false) | |
Return the report as a HTML string of hidden form elements. | |
as_json () | |
Return the report as a JSON string. | |
expand () | |
Expand the private structure, to make a traversal iterate over all the properties. | |
get_date ($var) | |
Return the given timestamp typed property as a date string of the configured kind. | |
get_time ($var) | |
Return the given timestamp typed property as a time string. | |
is_any_state_included ($var) | |
Return if the specified key has all the states. | |
remove_object ($object_type, $old_name) | |
Call. | |
rename_object ($object_type, $old_name, $new_name) | |
Call. | |
rewind () | |
Required by Iterator. | |
current () | |
Required by Iterator. | |
key () | |
Required by Iterator. | |
next () | |
Required by Iterator. | |
valid () | |
Required by Iterator. | |
count () | |
Required by Countable. | |
__toString () | |
Print the options themselves when printing the object. | |
save (&$message=NULL) | |
Save a report. | |
delete () | |
Delete a saved report. | |
Static Public Member Functions | |
static | discover_options ($input=false) |
Finds properties to inject into. | |
static | setup_options_obj ($type, $input=false) |
static | get_all_saved () |
Return all saved reports for this report type FIXME remove and replace calls here with usage of object pool for saved reports which already has mayi instead of authorized_for(). | |
Data Fields | |
const | ALL_AUTHORIZED = '*' |
Placeholder used instead of fetching all objects the user is authorized to see, to be able to fetch lazily and avoid large queries or filtering large result sets. | |
$options = array() | |
The the explicitly set options. | |
Static Public Attributes | |
static | $type = null |
A name for this report type that doesn't rely on splitting class_name() by _ This is used when saving the report. | |
static | $now = null |
This gives test suites the ability to override the "current time" as seen from the report period calculation code. | |
Protected Member Functions | |
calculate_time ($report_period) | |
Calculates $this['start_time'] and $this['end_time'] based on an availability report style period such as "today", "last24hours" or "lastmonth". | |
validate_value ($key, &$value) | |
Validates that $value isn't obviously unsuitable for $key. | |
update_value ($name, $value) | |
Will actually set the provided $name to the value $value. | |
load_options ($id) | |
Loads options for a saved report by id. | |
load ($id) | |
Loads a saved report. | |
Static Protected Member Functions | |
static | merge_with_loaded ($options, $report_info) |
So, my issue is, basically, that op5reports needs to override how what is loaded from DB, and our saved_reports_model is useless and fragile and scary and I'll kill it, as part of fixing #7491 at the very latest. | |
static | create_options_obj ($report_info=false) |
Combines the provided properties with any saved information. | |
Protected Attributes | |
$rename_options | |
Can contains options that must be renamed when provided - for legacy links. | |
$properties | |
Contains a definition of all legal keys for this type of Report_options. |
Report_options is an object representing the user-selected report.
It's created to improve consistency between report types and frontend/backend
Report_options::as_keyval | ( | $ | anonymous = false , |
|
$ | obj_only = false | |||
) |
A.k.a.
"to array"
$anonymous | If true, any option on the exact objects in this report will be purged, so it's suitable for linking to sub-reports. If false, all options will be kept, completely describing this exact report. | |
$obj_only | Does more-or-less the inverse of $anonymous - if true, don't include anything that does not refer to the members of the report. |
Report_options::as_keyval_string | ( | $ | anonymous = false , |
|
$ | obj_only = false | |||
) |
Generate a standard HTTP keyval string, suitable for URLs or POST bodies.
$anonymous | If true, any option on the exact objects in this report will be purged, so it's suitable for linking to sub-reports. If false, all options will be kept, completely describing this exact report. | |
$obj_only | Does more-or-less the inverse of $anonymous - if true, don't include anything that does not refer to the members of the report. |
Report_options::calculate_time | ( | $ | report_period | ) | [protected] |
Calculates $this['start_time'] and $this['end_time'] based on an availability report style period such as "today", "last24hours" or "lastmonth".
$report_period | The textual period to set our options by |
Reimplemented in Sla_options, and Summary_options.
static Report_options::create_options_obj | ( | $ | report_info = false |
) | [static, protected] |
Combines the provided properties with any saved information.
You probably want setup_options_obj instead.
Report_options::delete | ( | ) |
Delete a saved report.
static Report_options::discover_options | ( | $ | input = false |
) | [static] |
Finds properties to inject into.
. myself
You probably want setup_options_obj instead.
$input | array = false Autodiscovers options using superglobals: $input > POST > GET |
Reimplemented in Sla_options.
static Report_options::get_all_saved | ( | ) | [static] |
Report_options::load | ( | $ | id | ) | [protected] |
Loads a saved report.
Invoked automatically by create_options_obj
$id | int The saved report's id |
Report_options::load_options | ( | $ | id | ) | [protected] |
Loads options for a saved report by id.
Primarily exists so report-type-specific load-mangling can take place.
$id | int |
Reimplemented in Sla_options.
static Report_options::merge_with_loaded | ( | $ | options, | |
$ | report_info | |||
) | [static, protected] |
So, my issue is, basically, that op5reports needs to override how what is loaded from DB, and our saved_reports_model is useless and fragile and scary and I'll kill it, as part of fixing #7491 at the very latest.
Until then, I need to expose this algorithm so op5report can access it without having to copy-paste it or access the functionality the normal way.
Report_options::properties | ( | ) |
This looks silly.
..
Report_options::remove_object | ( | $ | object_type, | |
$ | old_name | |||
) |
Call.
$object_type | string (such as 'service') | |
$old_name | string |
Report_options::rename_object | ( | $ | object_type, | |
$ | old_name, | |||
$ | new_name | |||
) |
Call.
$object_type | string (such as 'service') | |
$old_name | string | |
$new_name | string |
Report_options::save | ( | &$ | message = NULL |
) |
Save a report.
If it has a report_id, this does an update, otherwise, a new report is saved.
$message | If set, will contain an error message on failure. |
Report_options::set | ( | $ | name, | |
$ | value | |||
) |
Set an option, with some validation.
$name | Option name | |
$value | Option value |
Reimplemented in Sla_options.
Report_options::set_options | ( | $ | options | ) |
Update the options for the report.
$options | New options |
Reimplemented in HttpApiEvent_options, and HttpApiState_options.
static Report_options::setup_options_obj | ( | $ | type, | |
$ | input = false | |||
) | [static] |
$type | string avail|sla|summary | |
$input | array = false |
Report_options::update_value | ( | $ | name, | |
$ | value | |||
) | [protected] |
Will actually set the provided $name to the value $value.
Warning: you probably want to use set() or utilize the ArrayAccess API
Reimplemented in Histogram_options, and Summary_options.
Report_options::validate_value | ( | $ | key, | |
&$ | value | |||
) | [protected] |
Validates that $value isn't obviously unsuitable for $key.
Warning: you probably want to use set() or utilize the ArrayAccess API
Reimplemented in HttpApiEvent_options, and HttpApiState_options.
Report_options::$now = null [static] |
This gives test suites the ability to override the "current time" as seen from the report period calculation code.
This is obviously dangerous and you should never, ever use it.
Report_options::$options = array() |
The the explicitly set options.
Should not be accessed directly, outside of debugging.