Merge branch 'maint/7.0'
[ninja.git] / modules / orm / models / notificationset.php
blob819473dedd3f3f398c479433ae4d6fe3b9aa3b40
1 <?php
3 require_once( dirname(__FILE__).'/base/basenotificationset.php' );
5 /**
6 * Describes a set of objects from livestatus
7 */
8 class NotificationSet_Model extends BaseNotificationSet_Model {
9 /**
10 * apply some extra filters to match for the authentication.
12 protected function get_auth_filter() {
13 $auth = Auth::instance();
14 $all_hosts = $auth->authorized_for('host_view_all');
15 $all_services = $auth->authorized_for('service_view_all');
16 $contact_name = $auth->get_user()->username;
18 // Authorized for everything? Don't filter anything...
19 if( $all_hosts && $all_services )
20 return $this->filter;
22 $auth_filter = new LivestatusFilterOr();
23 $auth_filter->add(new LivestatusFilterMatch('contact_name', $contact_name));
25 if( $all_hosts ) {
26 $auth_filter->add( new LivestatusFilterMatch('notification_type', nagstat::HOST_NOTIFICATION));
28 if( $all_services ) {
29 $auth_filter->add( new LivestatusFilterMatch('notification_type', nagstat::SERVICE_NOTIFICATION));
32 $result_filter = new LivestatusFilterAnd();
33 $result_filter->add($this->filter);
34 $result_filter->add($auth_filter);
35 return $result_filter;