Add contact detail view

refs #4804
refs #6514
This commit is contained in:
Alexander Klimov 2014-07-18 11:48:26 +02:00
parent 2a204897b4
commit f9a274d079
2 changed files with 90 additions and 0 deletions

View File

@ -103,6 +103,40 @@ class Monitoring_ShowController extends Controller
));
}
public function contactAction()
{
$contact = $this->getParam('contact');
if (! $contact) {
throw new Zend_Controller_Action_Exception(
$this->translate('The parameter `contact\' is required'),
404
);
}
$query = $this->backend->select()->from('contact', array(
'contact_name',
'contact_id',
'contact_alias',
'contact_email',
'contact_pager',
'contact_notify_service_timeperiod',
'contact_notify_service_recovery',
'contact_notify_service_warning',
'contact_notify_service_critical',
'contact_notify_service_unknown',
'contact_notify_service_flapping',
'contact_notify_service_downtime',
'contact_notify_host_timeperiod',
'contact_notify_host_recovery',
'contact_notify_host_down',
'contact_notify_host_unreachable',
'contact_notify_host_flapping',
'contact_notify_host_downtime',
));
$query->where('contact_name', $contact);
$this->view->contacts = $query->paginate();
$this->view->contact_name = $contact;
}
/**
* Creating tabs for this controller
* @return Tabs

View File

@ -0,0 +1,56 @@
<?php
$contactHelper = $this->getHelper('ContactFlags');
?>
<div style="margin-top: 0.5em;">
<?php foreach ($contacts as $contact): ?>
<table style="border-spacing: 0.25em; border-collapse: separate;">
<thead>
<tr>
<th colspan="2" style="text-align: left">
<?= htmlspecialchars($contact->contact_name) ?><span style="font-weight: normal;"> (<?=
htmlspecialchars($contact->contact_alias)
?>)</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td><?= t('Email') ?></td>
<td><?php printf(
'<a href="mailto:%1$s">%1$s</a>',
htmlspecialchars($contact->contact_email)
); ?></td>
</tr>
<?php if ($contact->contact_pager): ?>
<tr>
<td><?= t('Pager') ?></td>
<td><?= htmlspecialchars($contact->contact_pager) ?></td>
</tr>
<?php endif; ?>
<tr>
<td><?= t('Flags (service)') ?></td>
<td><?= htmlspecialchars($contactHelper->contactFlags($contact, 'service')) ?></td>
</tr>
<tr>
<td><?= t('Flags (host)') ?></td>
<td><?= htmlspecialchars($contactHelper->contactFlags($contact, 'host')) ?></td>
</tr>
<tr>
<td><?= t('Service notification period') ?></td>
<td><?= htmlspecialchars($contact->contact_notify_service_timeperiod) ?></td>
</tr>
<tr>
<td><?= t('Host notification period') ?></td>
<td><?= htmlspecialchars($contact->contact_notify_host_timeperiod) ?></td>
</tr>
</tbody>
</table>
<?php
return;
endforeach;
printf(
'%s: `%s\'',
t('No such contact'), $contact_name
);
?>
</div>