mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
monitoring/detail: Don't display the comment of the active acknowledgement in the comment list
refs #9674
This commit is contained in:
parent
8a1592fd12
commit
f0e8340fbd
@ -26,6 +26,13 @@ abstract class MonitoredObject implements Filterable
|
|||||||
*/
|
*/
|
||||||
const TYPE_SERVICE = 'service';
|
const TYPE_SERVICE = 'service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acknowledgement of the host or service if any
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $acknowledgement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backend to fetch object information from
|
* Backend to fetch object information from
|
||||||
*
|
*
|
||||||
@ -224,13 +231,15 @@ abstract class MonitoredObject implements Filterable
|
|||||||
*/
|
*/
|
||||||
public function fetch()
|
public function fetch()
|
||||||
{
|
{
|
||||||
$this->properties = $this->getDataView()->applyFilter($this->getFilter())->getQuery()->fetchRow();
|
$properties = $this->getDataView()->applyFilter($this->getFilter())->getQuery()->fetchRow();
|
||||||
if ($this->properties === false) {
|
|
||||||
|
if ($properties === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isset($this->properties->host_contacts)) {
|
|
||||||
|
if (isset($properties->host_contacts)) {
|
||||||
$this->contacts = array();
|
$this->contacts = array();
|
||||||
foreach (preg_split('~,~', $this->properties->host_contacts) as $contact) {
|
foreach (preg_split('~,~', $properties->host_contacts) as $contact) {
|
||||||
$this->contacts[] = (object) array(
|
$this->contacts[] = (object) array(
|
||||||
'contact_name' => $contact,
|
'contact_name' => $contact,
|
||||||
'contact_alias' => $contact,
|
'contact_alias' => $contact,
|
||||||
@ -239,9 +248,24 @@ abstract class MonitoredObject implements Filterable
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->properties = $properties;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the object's acknowledgement
|
||||||
|
*/
|
||||||
|
public function fetchAcknowledgement()
|
||||||
|
{
|
||||||
|
if ($this->comments === null) {
|
||||||
|
$this->fetchComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the object's comments
|
* Fetch the object's comments
|
||||||
*
|
*
|
||||||
@ -253,23 +277,52 @@ abstract class MonitoredObject implements Filterable
|
|||||||
$this->comments = array();
|
$this->comments = array();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
$comments = $this->backend->select()->from('comment', array(
|
|
||||||
'id' => 'comment_internal_id',
|
$commentsView = $this->backend->select()->from('comment', array(
|
||||||
'timestamp' => 'comment_timestamp',
|
'author' => 'comment_author_name',
|
||||||
'author' => 'comment_author_name',
|
'comment' => 'comment_data',
|
||||||
'comment' => 'comment_data',
|
'expiration' => 'comment_expiration',
|
||||||
'type' => 'comment_type',
|
'id' => 'comment_internal_id',
|
||||||
))
|
'timestamp' => 'comment_timestamp',
|
||||||
->where('comment_type', array('comment'))
|
'type' => 'comment_type'
|
||||||
->where('object_type', $this->type);
|
));
|
||||||
if ($this->type === self::TYPE_SERVICE) {
|
if ($this->type === self::TYPE_SERVICE) {
|
||||||
$comments
|
$commentsView
|
||||||
->where('service_host_name', $this->host_name)
|
->where('service_host_name', $this->host_name)
|
||||||
->where('service_description', $this->service_description);
|
->where('service_description', $this->service_description);
|
||||||
} else {
|
} else {
|
||||||
$comments->where('host_name', $this->host_name);
|
$commentsView->where('host_name', $this->host_name);
|
||||||
}
|
}
|
||||||
$this->comments = $comments->getQuery()->fetchAll();
|
$commentsView
|
||||||
|
->where('comment_type', array('ack', 'comment'))
|
||||||
|
->where('object_type', $this->type);
|
||||||
|
|
||||||
|
$comments = $commentsView->fetchAll();
|
||||||
|
|
||||||
|
if ((bool) $this->properties->{$this->prefix . 'acknowledged'}) {
|
||||||
|
$ackCommentIdx = null;
|
||||||
|
|
||||||
|
foreach ($comments as $i => $comment) {
|
||||||
|
if ($comment->type === 'ack') {
|
||||||
|
$this->acknowledgement = new Acknowledgement(array(
|
||||||
|
'author' => $comment->author,
|
||||||
|
'comment' => $comment->comment,
|
||||||
|
'entry_time' => $comment->timestamp,
|
||||||
|
'expiration_time' => $comment->expiration,
|
||||||
|
'sticky' => (int) $this->properties->{$this->prefix . 'acknowledgement_type'} === 2
|
||||||
|
));
|
||||||
|
$ackCommentIdx = $i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ackCommentIdx !== null) {
|
||||||
|
unset($comments[$ackCommentIdx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->comments = $comments;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,8 +626,8 @@ abstract class MonitoredObject implements Filterable
|
|||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->fetchComments()
|
->fetchComments()
|
||||||
->fetchContacts()
|
|
||||||
->fetchContactgroups()
|
->fetchContactgroups()
|
||||||
|
->fetchContacts()
|
||||||
->fetchCustomvars()
|
->fetchCustomvars()
|
||||||
->fetchDowntimes();
|
->fetchDowntimes();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user