Merge branch 'master' into bugfix/drop-zend-config-7147
This commit is contained in:
commit
124f64ad89
|
@ -72,10 +72,7 @@ class LdapUserBackend extends UserBackend
|
|||
$q = $this->conn->select()->from($this->userClass);
|
||||
$result = $q->fetchRow();
|
||||
} catch (LdapException $e) {
|
||||
throw new AuthenticationException(
|
||||
'Connection not possible: %s',
|
||||
$e->getMessage()
|
||||
);
|
||||
throw new AuthenticationException('Connection not possible.', $e);
|
||||
}
|
||||
|
||||
if (! isset($result)) {
|
||||
|
@ -166,7 +163,7 @@ class LdapUserBackend extends UserBackend
|
|||
} catch (AuthenticationException $e) {
|
||||
// Authentication not possible
|
||||
throw new AuthenticationException(
|
||||
'Authentication against backend "%s" not possible: %s',
|
||||
'Authentication against backend "%s" not possible.',
|
||||
$this->getName(),
|
||||
$e
|
||||
);
|
||||
|
|
|
@ -335,9 +335,9 @@ class Connection
|
|||
|
||||
public function testCredentials($username, $password)
|
||||
{
|
||||
$ds = $this->prepareNewConnection();
|
||||
$this->connect();
|
||||
|
||||
$r = @ldap_bind($ds, $username, $password);
|
||||
$r = @ldap_bind($this->ds, $username, $password);
|
||||
if ($r) {
|
||||
Logger::debug(
|
||||
'Successfully tested LDAP credentials (%s / %s)',
|
||||
|
@ -350,7 +350,7 @@ class Connection
|
|||
'Testing LDAP credentials (%s / %s) failed: %s',
|
||||
$username,
|
||||
'***',
|
||||
ldap_error($ds)
|
||||
ldap_error($this->ds)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -387,7 +387,19 @@ class Connection
|
|||
}
|
||||
|
||||
$ds = ldap_connect($this->hostname, $this->port);
|
||||
list($cap, $namingContexts) = $this->discoverCapabilities($ds);
|
||||
try {
|
||||
$capabilities = $this->discoverCapabilities($ds);
|
||||
list($cap, $namingContexts) = $capabilities;
|
||||
} catch (LdapException $e) {
|
||||
|
||||
// discovery failed, guess defaults
|
||||
$cap = (object) array(
|
||||
'supports_ldapv3' => true,
|
||||
'supports_starttls' => false,
|
||||
'msCapabilities' => array()
|
||||
);
|
||||
$namingContexts = null;
|
||||
}
|
||||
$this->capabilities = $cap;
|
||||
$this->namingContexts = $namingContexts;
|
||||
|
||||
|
@ -625,7 +637,8 @@ class Connection
|
|||
if (! $result) {
|
||||
throw new LdapException(
|
||||
sprintf(
|
||||
'Capability query failed (%s:%d): %s',
|
||||
'Capability query failed (%s:%d): %s. Check if hostname and port of the ldap resource are correct '
|
||||
. ' and if anonymous access is permitted.',
|
||||
$this->hostname,
|
||||
$this->port,
|
||||
ldap_error($ds)
|
||||
|
@ -633,6 +646,16 @@ class Connection
|
|||
);
|
||||
}
|
||||
$entry = ldap_first_entry($ds, $result);
|
||||
if ($entry === false) {
|
||||
throw new LdapException(
|
||||
sprintf(
|
||||
'Capabilities not available (%s:%d): %s. Discovery of root DSE probably not permitted.',
|
||||
$this->hostname,
|
||||
$this->port,
|
||||
ldap_error($ds)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$cap = (object) array(
|
||||
'supports_ldapv3' => false,
|
||||
|
@ -640,10 +663,6 @@ class Connection
|
|||
'msCapabilities' => array()
|
||||
);
|
||||
|
||||
if ($entry === false) {
|
||||
// TODO: Is it OK to have no capabilities?
|
||||
return false;
|
||||
}
|
||||
$ldapAttributes = ldap_get_attributes($ds, $entry);
|
||||
$result = $this->cleanupAttributes($ldapAttributes);
|
||||
$cap->supports_ldapv3 = $this->hasCapabilityLdapV3($result);
|
||||
|
|
|
@ -296,7 +296,7 @@ class Monitoring_ListController extends Controller
|
|||
->order('downtime_scheduled_start', 'DESC');
|
||||
|
||||
$this->applyFilters($query);
|
||||
$this->view->downtimes = $query->paginate();
|
||||
|
||||
$this->setupSortControl(array(
|
||||
'downtime_is_in_effect' => $this->translate('Is In Effect'),
|
||||
'downtime_host' => $this->translate('Host / Service'),
|
||||
|
@ -308,6 +308,8 @@ class Monitoring_ListController extends Controller
|
|||
'downtime_scheduled_end' => $this->translate('Scheduled End'),
|
||||
'downtime_duration' => $this->translate('Duration'),
|
||||
));
|
||||
|
||||
$this->view->downtimes = $query->paginate();
|
||||
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
class Zend_View_Helper_Customvar extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Create dispatch instance
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function checkPerformance()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function customvar($struct)
|
||||
{
|
||||
if (is_string($struct) || is_int($struct) || is_float($struct)) {
|
||||
return $this->view->escape((string) $struct);
|
||||
} elseif (is_array($struct)) {
|
||||
return $this->renderArray($struct);
|
||||
} elseif (is_object($struct)) {
|
||||
return $this->renderObject($struct);
|
||||
}
|
||||
}
|
||||
|
||||
protected function renderArray($array)
|
||||
{
|
||||
if (empty($array)) {
|
||||
return '[]';
|
||||
}
|
||||
$out = "<ul>\n";
|
||||
foreach ($array as $val) {
|
||||
$out .= '<li>' . $this->customvar($val) . "</li>\n";
|
||||
}
|
||||
return $out . "</ul>\n";
|
||||
}
|
||||
|
||||
protected function renderObject($object)
|
||||
{
|
||||
if (empty($object)) {
|
||||
return '{}';
|
||||
}
|
||||
$out = "{<ul>\n";
|
||||
foreach ($object as $key => $val) {
|
||||
$out .= '<li>'
|
||||
. $this->view->escape($key)
|
||||
. ' => '
|
||||
. $this->customvar($val)
|
||||
. "</li>\n";
|
||||
}
|
||||
return $out . "</ul>}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -67,4 +67,6 @@
|
|||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<h1><?= $this->translate('Resources'); ?></h1>
|
||||
<a href="<?= $this->href('config/resource'); ?>"><?= $this->translate('Jump to resource configuration'); ?></a>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
<?= $this->tabs->render($this); ?>
|
||||
<div style="margin: 1em" class="dontprint">
|
||||
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
||||
<?php if (! $this->filterEditor): ?>
|
||||
<?= $this->filterPreview ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $downtimes->count())); ?>
|
||||
<?= $this->paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?>
|
||||
|
@ -10,6 +13,7 @@
|
|||
<?php endif ?>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->filterEditor ?>
|
||||
<?php if (empty($downtimes)): ?>
|
||||
<?= $this->translate('No downtimes matching the filter'); ?>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
foreach ($object->customvars as $name => $value) {
|
||||
|
||||
printf(
|
||||
"<tr><th>%s</th><td>%s</td></tr>\n",
|
||||
'<tr><th>%s</th><td class="customvar">%s</td></tr>' . "\n",
|
||||
$this->escape($name),
|
||||
$this->escape($value)
|
||||
$this->customvar($value)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class CustomvarQuery extends IdoQuery
|
|||
'customvars' => array(
|
||||
'varname' => 'cvs.varname',
|
||||
'varvalue' => 'cvs.varvalue',
|
||||
'is_json' => 'cvs.is_json',
|
||||
),
|
||||
'objects' => array(
|
||||
'host' => 'cvo.name1 COLLATE latin1_general_ci',
|
||||
|
@ -37,6 +38,10 @@ class CustomvarQuery extends IdoQuery
|
|||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
if (version_compare($this->getIdoVersion(), '1.12.0', '<')) {
|
||||
$this->columnMap['customvars']['is_json'] = '(0)';
|
||||
}
|
||||
|
||||
$this->select->from(
|
||||
array('cvs' => $this->prefix . 'customvariablestatus'),
|
||||
array()
|
||||
|
|
|
@ -16,6 +16,7 @@ class DowntimeQuery extends IdoQuery
|
|||
protected $columnMap = array(
|
||||
'downtime' => array(
|
||||
'downtime_author' => 'sd.author_name',
|
||||
'author' => 'sd.author_name',
|
||||
'downtime_comment' => 'sd.comment_data',
|
||||
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
|
||||
'downtime_is_fixed' => 'sd.is_fixed',
|
||||
|
|
|
@ -19,6 +19,7 @@ class Customvar extends DataView
|
|||
return array(
|
||||
'varname',
|
||||
'varvalue',
|
||||
'is_json',
|
||||
'object_type'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ class Downtime extends DataView
|
|||
return array(
|
||||
'downtime_objecttype',
|
||||
'downtime_author',
|
||||
'author',
|
||||
'downtime_comment',
|
||||
'downtime_entry_time',
|
||||
'downtime_is_fixed',
|
||||
|
|
|
@ -283,7 +283,8 @@ abstract class MonitoredObject
|
|||
|
||||
$query = $this->backend->select()->from('customvar', array(
|
||||
'varname',
|
||||
'varvalue'
|
||||
'varvalue',
|
||||
'is_json'
|
||||
))
|
||||
->where('object_type', $this->type)
|
||||
->where('host_name', $this->host_name);
|
||||
|
@ -293,13 +294,16 @@ abstract class MonitoredObject
|
|||
|
||||
$this->customvars = array();
|
||||
|
||||
$customvars = $query->getQuery()->fetchPairs();
|
||||
foreach ($customvars as $name => $value) {
|
||||
$name = ucwords(str_replace('_', ' ', strtolower($name)));
|
||||
if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
|
||||
$value = '***';
|
||||
$customvars = $query->getQuery()->fetchAll();
|
||||
foreach ($customvars as $name => $cv) {
|
||||
$name = ucwords(str_replace('_', ' ', strtolower($cv->varname)));
|
||||
if ($blacklistPattern && preg_match($blacklistPattern, $cv->varname)) {
|
||||
$this->customvars[$name] = '***';
|
||||
} elseif ($cv->is_json) {
|
||||
$this->customvars[$name] = json_decode($cv->varvalue);
|
||||
} else {
|
||||
$this->customvars[$name] = $cv->varvalue;
|
||||
}
|
||||
$this->customvars[$name] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -158,3 +158,11 @@ form.instance-features span.description, form.object-features span.description {
|
|||
margin: 0 10px 0 0;
|
||||
border-spacing: 10px 10px;
|
||||
}
|
||||
|
||||
table.avp .customvar ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue