ContactQuery: Provide ci query columns for aliases and email addresses

refs #8613
This commit is contained in:
Johannes Meyer 2015-04-10 09:45:23 +02:00
parent 3c47ba11eb
commit f00adc2138
8 changed files with 37 additions and 35 deletions

View File

@ -350,8 +350,8 @@ class Monitoring_ListController extends Controller
$query = $this->backend->select()->from('contact', array( $query = $this->backend->select()->from('contact', array(
'contact_name', 'contact_name',
'contact_id', 'contact_id',
'contact_alias', 'contact_alias_name',
'contact_email', 'contact_email_address',
'contact_pager', 'contact_pager',
'contact_notify_service_timeperiod', 'contact_notify_service_timeperiod',
'contact_notify_service_recovery', 'contact_notify_service_recovery',
@ -365,18 +365,18 @@ class Monitoring_ListController extends Controller
'contact_notify_host_down', 'contact_notify_host_down',
'contact_notify_host_unreachable', 'contact_notify_host_unreachable',
'contact_notify_host_flapping', 'contact_notify_host_flapping',
'contact_notify_host_downtime', 'contact_notify_host_downtime'
)); ));
$this->filterQuery($query); $this->filterQuery($query);
$this->view->contacts = $query->paginate(); $this->view->contacts = $query->paginate();
$this->setupSortControl(array( $this->setupSortControl(array(
'contact_name' => $this->translate('Name'), 'contact_name' => $this->translate('Name'),
'contact_alias' => $this->translate('Alias'), 'contact_alias_name' => $this->translate('Alias'),
'contact_email' => $this->translate('Email'), 'contact_email_address' => $this->translate('Email'),
'contact_pager' => $this->translate('Pager Address / Number'), 'contact_pager' => $this->translate('Pager Address / Number'),
'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'), 'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'),
'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod') 'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod')
)); ));
} }

View File

@ -124,8 +124,8 @@ class Monitoring_ShowController extends Controller
$query = $this->backend->select()->from('contact', array( $query = $this->backend->select()->from('contact', array(
'contact_name', 'contact_name',
'contact_id', 'contact_id',
'contact_alias', 'contact_alias_name',
'contact_email', 'contact_email_address',
'contact_pager', 'contact_pager',
'contact_object_id', 'contact_object_id',
'contact_notify_service_timeperiod', 'contact_notify_service_timeperiod',
@ -140,7 +140,7 @@ class Monitoring_ShowController extends Controller
'contact_notify_host_down', 'contact_notify_host_down',
'contact_notify_host_unreachable', 'contact_notify_host_unreachable',
'contact_notify_host_flapping', 'contact_notify_host_flapping',
'contact_notify_host_downtime', 'contact_notify_host_downtime'
)); ));
$query->where('contact_name', $contactName); $query->where('contact_name', $contactName);

View File

@ -14,19 +14,19 @@
} }
foreach ($contacts as $contact): ?> foreach ($contacts as $contact): ?>
<div class="contact"> <div class="contact">
<?= $this->img('/static/gravatar', array('email' => $contact->contact_email)); ?> <?= $this->img('/static/gravatar', array('email' => $contact->contact_email_address)); ?>
<strong><?= $this->qlink( <strong><?= $this->qlink(
$contact->contact_name, $contact->contact_name,
'monitoring/show/contact', 'monitoring/show/contact',
array('contact_name' => $contact->contact_name), array('contact_name' => $contact->contact_name),
array('title' => sprintf( array('title' => sprintf(
$this->translate('Show detailed information about %s'), $this->translate('Show detailed information about %s'),
$contact->contact_alias $contact->contact_alias_name
)) ))
); ?></strong> (<?= $contact->contact_alias; ?>) ); ?></strong> (<?= $contact->contact_alias_name; ?>)
<div> <div>
<?= $this->translate('Email'); ?>: <a href="mailto:<?= $contact->contact_email; ?>" title="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>" aria-label="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>"> <?= $this->translate('Email'); ?>: <a href="mailto:<?= $contact->contact_email_address; ?>" title="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias_name); ?>" aria-label="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias_name); ?>">
<?= $this->escape($contact->contact_email); ?> <?= $this->escape($contact->contact_email_address); ?>
</a> </a>
</div> </div>
<?php if ($contact->contact_pager): ?> <?php if ($contact->contact_pager): ?>

View File

@ -5,10 +5,10 @@ if (! empty($object->contacts)) {
$list = array(); $list = array();
foreach ($object->contacts as $contact) { foreach ($object->contacts as $contact) {
$list[] = $this->qlink( $list[] = $this->qlink(
$contact->contact_alias, $contact->contact_alias_name,
'monitoring/show/contact', 'monitoring/show/contact',
array('contact_name' => $contact->contact_name), array('contact_name' => $contact->contact_name),
array('title' => sprintf($this->translate('Show detailed information about %s'), $contact->contact_alias)) array('title' => sprintf($this->translate('Show detailed information about %s'), $contact->contact_alias_name))
); );
} }

View File

@ -3,7 +3,7 @@
<?= $this->tabs ?> <?= $this->tabs ?>
<h1><?= $this->translate('Contact details') ?></h1> <h1><?= $this->translate('Contact details') ?></h1>
<div class="circular" style="background-image: url('<?= <div class="circular" style="background-image: url('<?=
$this->href('static/gravatar', array('email' => $contact->contact_email)) $this->href('static/gravatar', array('email' => $contact->contact_email_address))
?>')"></div> ?>')"></div>
<?php if (! $contact): ?> <?php if (! $contact): ?>
@ -15,14 +15,14 @@
<tbody> <tbody>
<tr> <tr>
<th style="width: 20%"></th> <th style="width: 20%"></th>
<td><strong><?= $this->escape($contact->contact_alias) ?></strong> (<?= $contact->contact_name ?>)</td> <td><strong><?= $this->escape($contact->contact_alias_name) ?></strong> (<?= $contact->contact_name ?>)</td>
</tr> </tr>
<?php if ($contact->contact_email): ?> <?php if ($contact->contact_email_address): ?>
<tr> <tr>
<th><?= $this->translate('Email') ?></th> <th><?= $this->translate('Email') ?></th>
<td> <td>
<a href="mailto:<?= $contact->contact_email; ?>" title="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>" aria-label="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias); ?>"> <a href="mailto:<?= $contact->contact_email_address; ?>" title="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias_name); ?>" aria-label="<?= sprintf($this->translate('Send a mail to %s'), $contact->contact_alias_name); ?>">
<?= $this->escape($contact->contact_email); ?> <?= $this->escape($contact->contact_email_address); ?>
</a> </a>
</td> </td>
</tr> </tr>

View File

@ -9,8 +9,10 @@ class ContactQuery extends IdoQuery
'contacts' => array( 'contacts' => array(
'contact_id' => 'c.contact_id', 'contact_id' => 'c.contact_id',
'contact_name' => 'co.name1 COLLATE latin1_general_ci', 'contact_name' => 'co.name1 COLLATE latin1_general_ci',
'contact_alias' => 'c.alias COLLATE latin1_general_ci', 'alias' => 'c.alias COLLATE latin1_general_ci',
'contact_email' => 'c.email_address COLLATE latin1_general_ci', 'contact_alias_name' => 'c.alias',
'email' => 'c.email_address COLLATE latin1_general_ci',
'contact_email_address' => 'c.email_address',
'contact_pager' => 'c.pager_address', 'contact_pager' => 'c.pager_address',
'contact_object_id' => 'c.contact_object_id', 'contact_object_id' => 'c.contact_object_id',
'contact_has_host_notfications' => 'c.host_notifications_enabled', 'contact_has_host_notfications' => 'c.host_notifications_enabled',

View File

@ -19,8 +19,8 @@ class Contact extends DataView
return array( return array(
'contact', 'contact',
'contact_name', 'contact_name',
'contact_alias', 'contact_alias_name',
'contact_email', 'contact_email_address',
'contact_pager', 'contact_pager',
'contact_notify_hosts', 'contact_notify_hosts',
'contact_notify_services', 'contact_notify_services',
@ -57,7 +57,7 @@ class Contact extends DataView
public function getSortRules() public function getSortRules()
{ {
return array( return array(
'contact_alias' => array( 'contact_alias_name' => array(
'order' => self::SORT_DESC 'order' => self::SORT_DESC
) )
); );

View File

@ -185,10 +185,10 @@ abstract class MonitoredObject implements Filterable
$this->contacts = array(); $this->contacts = array();
foreach (preg_split('~,~', $this->properties->host_contacts) as $contact) { foreach (preg_split('~,~', $this->properties->host_contacts) as $contact) {
$this->contacts[] = (object) array( $this->contacts[] = (object) array(
'contact_name' => $contact, 'contact_name' => $contact,
'contact_alias' => $contact, 'contact_alias_name' => $contact,
'contact_email' => null, 'contact_email_address' => null,
'contact_pager' => null, 'contact_pager' => null
); );
} }
} }
@ -385,9 +385,9 @@ abstract class MonitoredObject implements Filterable
$contacts = $this->backend->select()->from('contact', array( $contacts = $this->backend->select()->from('contact', array(
'contact_name', 'contact_name',
'contact_alias', 'contact_alias_name',
'contact_email', 'contact_email_address',
'contact_pager', 'contact_pager'
)); ));
if ($this->type === self::TYPE_SERVICE) { if ($this->type === self::TYPE_SERVICE) {
$contacts $contacts