Merge branch 'master' of git.icinga.org:icingaweb2

This commit is contained in:
Alexander Klimov 2014-03-06 14:18:32 +01:00
commit fdb5dede50
3 changed files with 25 additions and 115 deletions

View File

@ -34,6 +34,7 @@ use Zend_Db_Expr;
use Icinga\Authentication\UserBackend;
use Icinga\Data\Db\Connection;
use Icinga\User;
use \Zend_Db_Select;
class DbUserBackend extends UserBackend
{
@ -58,19 +59,22 @@ class DbUserBackend extends UserBackend
*/
public function hasUser(User $user)
{
$row = $this->conn->select()->from('account', array(new Zend_Db_Expr(1)))
$select = new Zend_Db_Select($this->conn->getConnection());
$row = $select->from('account', array(new Zend_Db_Expr(1)))
->where('username = ?', $user->getUsername())
->fetch();
return $row !== false ? true : false;
->query()->fetchObject();
return ($row !== false) ? true : false;
}
/**
* Authenticate
*
* @param User $user
* @param string $password
* @param User $user
* @param string $password
*
* @return bool
* @throws \Exception If we can not fetch the salt
*/
public function authenticate(User $user, $password)
{
@ -81,12 +85,15 @@ class DbUserBackend extends UserBackend
if ($salt === '') {
throw new Exception();
}
$row = $this->conn->select()->from('account', array(new Zend_Db_Expr(1)))
$select = new Zend_Db_Select($this->conn->getConnection());
$row = $select->from('account', array(new Zend_Db_Expr(1)))
->where('username = ?', $user->getUsername())
->where('active = ?', true)
->where('password = ?', $this->hashPassword($password, $salt))
->fetchRow();
return $row !== false ? true : false;
->query()->fetchObject();
return ($row !== false) ? true : false;
}
/**
@ -98,8 +105,9 @@ class DbUserBackend extends UserBackend
*/
private function getSalt($username)
{
$row = $this->conn->select()->from('account', array('salt'))->where('username = ?', $username)->fetchRow();
return $row !== false ? $row->salt : null;
$select = new Zend_Db_Select($this->conn->getConnection());
$row = $select->from('account', array('salt'))->where('username = ?', $username)->query()->fetchObject();
return ($row !== false) ? $row->salt : null;
}
/**
@ -121,6 +129,12 @@ class DbUserBackend extends UserBackend
*/
public function count()
{
return $this->conn->select()->from('account', array('count' => 'COUNT(*)'))->fetch()->count();
$select = new Zend_Db_Select($this->conn->getConnection());
$row = $select->from(
'account',
array('count' => 'COUNT(*)')
)->query()->fetchObject();
return ($row !== false) ? $row->count : 0;
}
}

View File

@ -1,97 +0,0 @@
<table class="action">
<tbody>
<?php
$helper = $this->getHelper('MonitoringState');
foreach ($services as $service):
$serviceLink = $this->href(
'monitoring/show/service',
array(
'host' => $service->host_name,
'service' => $service->service_description
)
);
$hostLink = $this->href(
'monitoring/show/host',
array('host' => $service->host_name)
);
$serviceStateName = strtolower($this->util()->getServiceStateName($service->service_state));
?>
<!-- <tr <?= ($this->activeRowHref === $serviceLink) ? 'class="active"' : ''; ?>>-->
<tr class="state <?= $serviceStateName ?><?= $service->service_handled ? ' handled' : '' ?>">
<!-- Color column -->
<!--
<td class="tacheader-status-<?= $serviceStateName; ?>">
<a style="visibility:hidden" href="<?= $serviceLink; ?>"></a>
</td>
<td>
<a style="visibility:hidden" href="<?= $serviceLink; ?>"></a>
<?php if (!$service->service_handled && $service->service_state > 0): ?>
<a href="#" title="Unhandled">
<i class="icon-table icinga-icon-unhandled"></i>
</a>
<?php endif; ?>
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
<a href="#" title="Acknowledged">
<i class="icon-table icinga-icon-acknowledgement"></i>
</a>
<?php endif; ?>
<?php if ($service->service_is_flapping): ?>
<a href="#" title="Flapping">
<i class="icon-table icinga-icon-flapping"></i>
</a>
<?php endif; ?>
<?php if (!$service->service_notifications_enabled): ?>
<a href="#" title="Notifications Disabled">
<i class="icon-table icinga-icon-notification-disabled"></i>
</a>
<?php endif; ?>
<?php if ($service->service_in_downtime): ?>
<a href="#" title="In Downtime">
<i class="icon-table icinga-icon-in-downtime"></i>
</a>
<?php endif; ?>
<?php if (!$service->service_active_checks_enabled): ?>
<?php if (!$service->service_passive_checks_enabled): ?>
<a href="#" title="Active And Passive Checks Disabled">
<i class="icon-table icinga-icon-active-passive-checks-disabled"></i>
</a>
<?php else: ?>
<a href="#" title="Active Checks Disabled">
<i class="icon-table icinga-icon-active-checks-disabled"></i>
</a>
<?php endif; ?>
<?php endif; ?>
<?php if (isset($service->service_last_comment) && $service->service_last_comment !== null): ?>
<a href="#" title="Comments">
<i class="icon-table icinga-icon-comment"></i>
</a>
<?php endif; ?>
</td>
-->
<td class="state" title="<?= $helper->getStateTitle($service, 'service'); ?>">
<?= $this->timeSince($service->service_last_state_change); ?>
</div>
</td>
<td>
<?= $this->perfdata($service->service_perfdata, true) ?>
<a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?></a><br />
<div class="pluginoutput">
<?= $this->escape(substr(strip_tags($service->service_output), 0, 10000)); ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@ -54,35 +54,30 @@ foreach ($services as $service):
<?php if (!$service->service_handled && $service->service_state > 0): ?>
<?= $this->img('img/icons/unhandled.png', array(
'title' => 'Unhandled',
'align' => 'right'
)) ?>
<?php endif ?>
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
<?= $this->img('img/icons/acknowledgement.png', array(
'title' => 'Acknowledged',
'align' => 'right'
)) ?>
<?php endif ?>
<?php if ($service->service_is_flapping): ?>
<?= $this->img('img/icons/flapping.png', array(
'title' => 'Flapping',
'align' => 'right'
)) ?>
<?php endif ?>
<?php if (!$service->service_notifications_enabled): ?>
<?= $this->img('img/icons/notification_disabled.png', array(
'title' => 'Notifications Disabled',
'align' => 'right'
)) ?>
<?php endif ?>
<?php if ($service->service_in_downtime): ?>
<?= $this->img('img/icons/in_downtime.png', array(
'title' => 'In Downtime',
'align' => 'right'
)) ?>
<?php endif ?>
@ -90,12 +85,10 @@ foreach ($services as $service):
<?php if (!$service->service_passive_checks_enabled): ?>
<?= $this->img('img/icons/active_passive_checks_disabled.png', array(
'title' => 'Active And Passive Checks Disabled',
'align' => 'right'
)) ?>
<?php else: ?>
<?= $this->img('img/icons/active_checks_disabled.png', array(
'title' => 'Active Checks Disabled',
'align' => 'right'
)) ?>
<?php endif ?>
<?php endif ?>