This file is indexed.

/usr/share/icingaweb2/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php is in icingaweb2-module-monitoring 2.1.0-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */

namespace Icinga\Module\Monitoring\Backend\Ido\Query;

use Zend_Db_Expr;
use Zend_Db_Select;
use Icinga\Data\Filter\Filter;

/**
 * Query for host and service comments
 */
class CommentQuery extends IdoQuery
{
    /**
     * {@inheritdoc}
     */
    protected $columnMap = array(
        'comments' => array(
            'comment_author'        => 'c.comment_author',
            'comment_author_name'   => 'c.comment_author_name',
            'comment_data'          => 'c.comment_data',
            'comment_expiration'    => 'c.comment_expiration',
            'comment_internal_id'   => 'c.comment_internal_id',
            'comment_is_persistent' => 'c.comment_is_persistent',
            'comment_timestamp'     => 'c.comment_timestamp',
            'comment_type'          => 'c.comment_type',
            'instance_name'         => 'c.instance_name',
            'object_type'           => 'c.object_type'
        ),
        'hosts' => array(
            'host_display_name' => 'c.host_display_name',
            'host_name'         => 'c.host_name',
            'host_state'        => 'c.host_state'
        ),
        'services' => array(
            'service_description'   => 'c.service_description',
            'service_display_name'  => 'c.service_display_name',
            'service_host_name'     => 'c.service_host_name',
            'service_state'         => 'c.service_state'
        )
    );

    /**
     * The union
     *
     * @var Zend_Db_Select
     */
    protected $commentQuery;

    /**
     * Subqueries used for the comment query
     *
     * @var IdoQuery[]
     */
    protected $subQueries = array();

    /**
     * {@inheritdoc}
     */
    public function allowsCustomVars()
    {
        foreach ($this->subQueries as $query) {
            if (! $query->allowsCustomVars()) {
                return false;
            }
        }

        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function addFilter(Filter $filter)
    {
        foreach ($this->subQueries as $sub) {
            $sub->applyFilter(clone $filter);
        }
        return $this;
    }

    /**
     * {@inheritdoc}
     */
    protected function joinBaseTables()
    {
        $this->commentQuery = $this->db->select();
        $this->select->from(
            array('c' => $this->commentQuery),
            array()
        );
        $this->joinedVirtualTables['comments'] = true;
    }

    /**
     * Join hosts
     */
    protected function joinHosts()
    {
        $columns = array_keys($this->columnMap['comments'] + $this->columnMap['hosts']);
        foreach (array_keys($this->columnMap['services']) as $column) {
            $columns[$column] = new Zend_Db_Expr('NULL');
        }
        $hosts = $this->createSubQuery('hostcomment', $columns);
        $this->subQueries[] = $hosts;
        $this->commentQuery->union(array($hosts), Zend_Db_Select::SQL_UNION_ALL);
    }

    /**
     * Join services
     */
    protected function joinServices()
    {
        $columns = array_keys($this->columnMap['comments'] + $this->columnMap['hosts'] + $this->columnMap['services']);
        $services = $this->createSubQuery('servicecomment', $columns);
        $this->subQueries[] = $services;
        $this->commentQuery->union(array($services), Zend_Db_Select::SQL_UNION_ALL);
    }

    /**
     * {@inheritdoc}
     */
    public function order($columnOrAlias, $dir = null)
    {
        foreach ($this->subQueries as $sub) {
            $sub->requireColumn($columnOrAlias);
        }
        return parent::order($columnOrAlias, $dir);
    }

    /**
     * {@inheritdoc}
     */
    public function where($condition, $value = null)
    {
        $this->requireColumn($condition);
        foreach ($this->subQueries as $sub) {
            $sub->where($condition, $value);
        }
        return $this;
    }
}