3 require_once( dirname(__FILE__
).'/base/baserecurringdowntimeset.php' );
6 * Autogenerated class RecurringDowntimeSet_Model
10 class RecurringDowntimeSet_Model
extends BaseRecurringDowntimeSet_Model
{
11 protected function get_auth_filter() {
12 $auth = Auth
::instance();
14 'hosts' => $auth->authorized_for('host_view_all'),
15 'services' => $auth->authorized_for('service_view_all'),
16 'hostgroups' => $auth->authorized_for('hostgroup_view_all'),
17 'servicegroups' => $auth->authorized_for('servicegroup_view_all')
20 $auth_filter = new LivestatusFilterOr();
22 foreach ($has_auth as $type => $godmode) {
23 $filter = new LivestatusFilterAnd();
24 $auth_filter->add($filter);
25 $filter->add(new LivestatusFilterMatch('downtime_type', $type, '='));
26 // there are only four valid values, so always checking them is cheap
30 // this, though, isn't cheap :(
31 $res_schedules = $db->query('SELECT recurring_downtime.id FROM recurring_downtime WHERE downtime_type = '.$db->escape($type));
33 $poolname = ucfirst(substr($type, 0, -1)).'Pool_Model';
34 $id_check = new LivestatusFilterOr();
35 $filter->add($id_check);
36 foreach ($res_schedules as $schedule) {
37 $set = $poolname::none();
38 $objects = $db->query('SELECT recurring_downtime_objects.object_name FROM recurring_downtime_objects WHERE recurring_downtime_id = '.$schedule->id
);
39 $schedule_filter = new LivestatusFilterAnd();
40 foreach ($objects as $object) {
41 if ($type == 'services') {
42 list($hname, $sdesc) = split(';', $object->object_name
);
43 $set = $set->union($poolname::all()->reduce_by('host.name', $hname, '=')->reduce_by('description', $sdesc, '='));
46 $set = $set->union($poolname::all()->reduce_by('name', $object->object_name
, '='));
49 if (count($set) == count($objects)) {
50 $id_check->add(new LivestatusFilterMatch('id', $schedule->id
, '='));
54 $result_filter = new LivestatusFilterAnd();
55 $result_filter->add($this->filter
);
56 $result_filter->add($auth_filter);
57 return $result_filter;