Merge branch 'master' into feature/dope-layout-5543
This commit is contained in:
commit
3d2521abf0
|
@ -215,7 +215,7 @@ class NavigationController extends Controller
|
||||||
$form->addDescription($this->translate('Create a new navigation item, such as a menu entry or dashlet.'));
|
$form->addDescription($this->translate('Create a new navigation item, such as a menu entry or dashlet.'));
|
||||||
|
|
||||||
// TODO: Fetch all "safe" parameters from the url and populate them
|
// TODO: Fetch all "safe" parameters from the url and populate them
|
||||||
$form->populate(array('url' => rawurldecode($this->params->get('url', ''))));
|
$form->setDefaultUrl(rawurldecode($this->params->get('url', '')));
|
||||||
|
|
||||||
$form->setOnSuccess(function (NavigationConfigForm $form) {
|
$form->setOnSuccess(function (NavigationConfigForm $form) {
|
||||||
$data = array_filter($form->getValues());
|
$data = array_filter($form->getValues());
|
||||||
|
|
|
@ -71,7 +71,7 @@ class LoginForm extends Form
|
||||||
if ($this->created) {
|
if ($this->created) {
|
||||||
$redirect = $this->getElement('redirect')->getValue();
|
$redirect = $this->getElement('redirect')->getValue();
|
||||||
}
|
}
|
||||||
if (empty($redirect)) {
|
if (empty($redirect) || strpos($redirect, 'authentication/logout') !== 0) {
|
||||||
$redirect = static::REDIRECT_URL;
|
$redirect = static::REDIRECT_URL;
|
||||||
}
|
}
|
||||||
return Url::fromPath($redirect);
|
return Url::fromPath($redirect);
|
||||||
|
|
|
@ -74,6 +74,8 @@ class NavigationConfigForm extends ConfigForm
|
||||||
*/
|
*/
|
||||||
protected $itemTypes;
|
protected $itemTypes;
|
||||||
|
|
||||||
|
private $defaultUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this form
|
* Initialize this form
|
||||||
*/
|
*/
|
||||||
|
@ -129,7 +131,7 @@ class NavigationConfigForm extends ConfigForm
|
||||||
*/
|
*/
|
||||||
public function getUserConfig($type = null)
|
public function getUserConfig($type = null)
|
||||||
{
|
{
|
||||||
if ($this->userConfig === null) {
|
if ($this->userConfig === null || $type !== null) {
|
||||||
if ($type === null) {
|
if ($type === null) {
|
||||||
throw new ProgrammingError('You need to pass a type if no user configuration is set');
|
throw new ProgrammingError('You need to pass a type if no user configuration is set');
|
||||||
}
|
}
|
||||||
|
@ -680,6 +682,14 @@ class NavigationConfigForm extends ConfigForm
|
||||||
$itemForm->create($formData); // May require a parent which gets set by addSubForm()
|
$itemForm->create($formData); // May require a parent which gets set by addSubForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT USE! This will be removed soon, very soon...
|
||||||
|
*/
|
||||||
|
public function setDefaultUrl($url)
|
||||||
|
{
|
||||||
|
$this->defaultUrl = $url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the configuration of the navigation item to load
|
* Populate the configuration of the navigation item to load
|
||||||
*/
|
*/
|
||||||
|
@ -689,6 +699,8 @@ class NavigationConfigForm extends ConfigForm
|
||||||
$data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray();
|
$data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray();
|
||||||
$data['name'] = $this->itemToLoad;
|
$data['name'] = $this->itemToLoad;
|
||||||
$this->populate($data);
|
$this->populate($data);
|
||||||
|
} elseif ($this->defaultUrl !== null) {
|
||||||
|
$this->populate(array('url' => $this->defaultUrl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ foreach ($members as $member): ?>
|
||||||
<td class="member-name">
|
<td class="member-name">
|
||||||
<?php if (
|
<?php if (
|
||||||
$this->hasPermission('config/authentication/users/show')
|
$this->hasPermission('config/authentication/users/show')
|
||||||
|
&& method_exists($backend, 'getUserBackend')
|
||||||
&& ($userBackend = $backend->getUserBackend()) !== null
|
&& ($userBackend = $backend->getUserBackend()) !== null
|
||||||
&& $userBackend instanceof Selectable
|
&& $userBackend instanceof Selectable
|
||||||
): ?>
|
): ?>
|
||||||
|
|
|
@ -151,7 +151,7 @@ class Web extends EmbeddedWeb
|
||||||
|
|
||||||
if (isset($config['users'])) {
|
if (isset($config['users'])) {
|
||||||
$users = array_map('trim', explode(',', strtolower($config['users'])));
|
$users = array_map('trim', explode(',', strtolower($config['users'])));
|
||||||
if (in_array($this->user->getUsername(), $users, true)) {
|
if (in_array('*', $users, true) || in_array($this->user->getUsername(), $users, true)) {
|
||||||
unset($config['users']);
|
unset($config['users']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,11 @@ class Web extends EmbeddedWeb
|
||||||
|
|
||||||
if (isset($config['groups'])) {
|
if (isset($config['groups'])) {
|
||||||
$groups = array_map('trim', explode(',', strtolower($config['groups'])));
|
$groups = array_map('trim', explode(',', strtolower($config['groups'])));
|
||||||
|
if (in_array('*', $groups, true)) {
|
||||||
|
unset($config['groups']);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$userGroups = array_map('strtolower', $this->user->getGroups());
|
$userGroups = array_map('strtolower', $this->user->getGroups());
|
||||||
$matches = array_intersect($userGroups, $groups);
|
$matches = array_intersect($userGroups, $groups);
|
||||||
if (! empty($matches)) {
|
if (! empty($matches)) {
|
||||||
|
|
|
@ -808,7 +808,7 @@ class LdapConnection implements Selectable, Inspectable
|
||||||
|
|
||||||
$ds = $this->getConnection();
|
$ds = $this->getConnection();
|
||||||
|
|
||||||
$serverSorting = $this->getCapabilities()->hasOid(LdapCapabilities::LDAP_SERVER_SORT_OID);
|
$serverSorting = false;//$this->getCapabilities()->hasOid(LdapCapabilities::LDAP_SERVER_SORT_OID);
|
||||||
if (! $serverSorting && $query->hasOrder()) {
|
if (! $serverSorting && $query->hasOrder()) {
|
||||||
foreach ($query->getOrder() as $rule) {
|
foreach ($query->getOrder() as $rule) {
|
||||||
if (! in_array($rule[0], $fields)) {
|
if (! in_array($rule[0], $fields)) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ class LdapQuery extends SimpleQuery
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->filters = array();
|
$this->filters = array();
|
||||||
$this->usePagedResults = true;
|
$this->usePagedResults = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -138,7 +138,6 @@ class NavigationItem implements IteratorAggregate
|
||||||
public function __construct($name, array $properties = null)
|
public function __construct($name, array $properties = null)
|
||||||
{
|
{
|
||||||
$this->setName($name);
|
$this->setName($name);
|
||||||
$this->priority = 100;
|
|
||||||
$this->children = new Navigation();
|
$this->children = new Navigation();
|
||||||
|
|
||||||
if (! empty($properties)) {
|
if (! empty($properties)) {
|
||||||
|
@ -237,7 +236,7 @@ class NavigationItem implements IteratorAggregate
|
||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority()
|
||||||
{
|
{
|
||||||
return $this->priority;
|
return $this->priority !== null ? $this->priority : 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,18 +626,32 @@ class NavigationItem implements IteratorAggregate
|
||||||
throw new ProgrammingError('Cannot merge, conflict detected.');
|
throw new ProgrammingError('Cannot merge, conflict detected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getActive()) {
|
if ($this->priority === null) {
|
||||||
$this->setActive();
|
$priority = $item->getPriority();
|
||||||
|
if ($priority !== 100) {
|
||||||
|
$this->setPriority($priority);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->getIcon()) {
|
if (! $this->getIcon()) {
|
||||||
$this->setIcon($item->getIcon());
|
$this->setIcon($item->getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getLabel() === $this->getName()) {
|
if ($this->getLabel() === $this->getName() && $item->getLabel() !== $item->getName()) {
|
||||||
$this->setLabel($item->getLabel());
|
$this->setLabel($item->getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->target === null && ($target = $item->getTarget()) !== null) {
|
||||||
|
$this->setTarget($target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->renderer === null) {
|
||||||
|
$renderer = $item->getRenderer();
|
||||||
|
if (get_class($renderer) !== 'NavigationItemRenderer') {
|
||||||
|
$this->setRenderer($renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($item->getAttributes() as $name => $value) {
|
foreach ($item->getAttributes() as $name => $value) {
|
||||||
$this->setAttribute($name, $value);
|
$this->setAttribute($name, $value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,9 +161,12 @@ class Url
|
||||||
if ($urlPath && $urlPath[0] === '/') {
|
if ($urlPath && $urlPath[0] === '/') {
|
||||||
if ($baseUrl) {
|
if ($baseUrl) {
|
||||||
$urlPath = substr($urlPath, 1);
|
$urlPath = substr($urlPath, 1);
|
||||||
} elseif (strpos($urlPath, $request->getBaseUrl()) === 0) {
|
} else {
|
||||||
$baseUrl = $request->getBaseUrl();
|
$requestBaseUrl = $request->getBaseUrl();
|
||||||
$urlPath = substr($urlPath, strlen($baseUrl) + 1);
|
if ($requestBaseUrl && $requestBaseUrl !== '/' && strpos($urlPath, $requestBaseUrl) === 0) {
|
||||||
|
$urlPath = substr($urlPath, strlen($requestBaseUrl) + 1);
|
||||||
|
$baseUrl = $requestBaseUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elseif (! $baseUrl) {
|
} elseif (! $baseUrl) {
|
||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
|
@ -48,10 +48,10 @@ class MacroTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
$objectMock = Mockery::mock('object');
|
$objectMock = Mockery::mock('object');
|
||||||
$objectMock->customvars = array(
|
$objectMock->customvars = array(
|
||||||
'CUSTOMVAR' => 'test'
|
'customvar' => 'test'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(Macro::resolveMacros('$CUSTOMVAR$', $objectMock), $objectMock->customvars['CUSTOMVAR']);
|
$this->assertEquals(Macro::resolveMacros('$CUSTOMVAR$', $objectMock), $objectMock->customvars['customvar']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFaultyMacros()
|
public function testFaultyMacros()
|
||||||
|
@ -59,8 +59,8 @@ class MacroTest extends BaseTestCase
|
||||||
$hostMock = Mockery::mock('host');
|
$hostMock = Mockery::mock('host');
|
||||||
$hostMock->host_name = 'test';
|
$hostMock->host_name = 'test';
|
||||||
$hostMock->customvars = array(
|
$hostMock->customvars = array(
|
||||||
'HOST' => 'te',
|
'host' => 'te',
|
||||||
'NAME' => 'st'
|
'name' => 'st'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -73,12 +73,12 @@ class MacroTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
$objectMock = Mockery::mock('object');
|
$objectMock = Mockery::mock('object');
|
||||||
$objectMock->customvars = array(
|
$objectMock->customvars = array(
|
||||||
'V€RY_SP3C|@L' => 'not too special!'
|
'v€ry_sp3c|@l' => 'not too special!'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
Macro::resolveMacros('$V€RY_SP3C|@L$', $objectMock),
|
Macro::resolveMacros('$V€RY_SP3C|@L$', $objectMock),
|
||||||
$objectMock->customvars['V€RY_SP3C|@L']
|
$objectMock->customvars['v€ry_sp3c|@l']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,11 +291,15 @@ class AdminAccountPage extends Form
|
||||||
protected function fetchUsers()
|
protected function fetchUsers()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this
|
$query = $this
|
||||||
->createUserBackend()
|
->createUserBackend()
|
||||||
->select(array('user_name'))
|
->select(array('user_name'))
|
||||||
->order('user_name', 'asc', true)
|
->order('user_name', 'asc', true);
|
||||||
->fetchColumn();
|
if (in_array($this->backendConfig['backend'], array('ldap', 'msldap'))) {
|
||||||
|
$query->getQuery()->setUsePagedResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->fetchColumn();
|
||||||
} catch (Exception $_) {
|
} catch (Exception $_) {
|
||||||
// No need to handle anything special here. Error means no users found.
|
// No need to handle anything special here. Error means no users found.
|
||||||
return array();
|
return array();
|
||||||
|
@ -346,10 +350,14 @@ class AdminAccountPage extends Form
|
||||||
protected function fetchGroups()
|
protected function fetchGroups()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this
|
$query = $this
|
||||||
->createUserGroupBackend()
|
->createUserGroupBackend()
|
||||||
->select(array('group_name'))
|
->select(array('group_name'));
|
||||||
->fetchColumn();
|
if (in_array($this->backendConfig['backend'], array('ldap', 'msldap'))) {
|
||||||
|
$query->getQuery()->setUsePagedResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->fetchColumn();
|
||||||
} catch (Exception $_) {
|
} catch (Exception $_) {
|
||||||
// No need to handle anything special here. Error means no groups found.
|
// No need to handle anything special here. Error means no groups found.
|
||||||
return array();
|
return array();
|
||||||
|
|
|
@ -291,7 +291,9 @@
|
||||||
// Disable all form controls to prevent resubmission as early as possible.
|
// Disable all form controls to prevent resubmission as early as possible.
|
||||||
// (This relies on native form submission, so using setTimeout is the only possible solution)
|
// (This relies on native form submission, so using setTimeout is the only possible solution)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$form.find(':input:not(:disabled)').prop('disabled', true);
|
if ($target.attr('id') == $form.closest('.container').attr('id')) {
|
||||||
|
$form.find(':input:not(:disabled)').prop('disabled', true);
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
if (autosubmit) {
|
if (autosubmit) {
|
||||||
|
@ -331,7 +333,9 @@
|
||||||
|
|
||||||
// Disable all form controls to prevent resubmission except for our search input
|
// Disable all form controls to prevent resubmission except for our search input
|
||||||
// Note that disabled form inputs will not be enabled via JavaScript again
|
// Note that disabled form inputs will not be enabled via JavaScript again
|
||||||
$form.find(':input:not(#search):not(:disabled)').prop('disabled', true);
|
if ($target.attr('id') == $form.closest('.container').attr('id')) {
|
||||||
|
$form.find(':input:not(#search):not(:disabled)').prop('disabled', true);
|
||||||
|
}
|
||||||
|
|
||||||
// Show a spinner depending on how the form is being submitted
|
// Show a spinner depending on how the form is being submitted
|
||||||
if (autosubmit && typeof $el !== 'undefined' && $el.next().hasClass('spinner')) {
|
if (autosubmit && typeof $el !== 'undefined' && $el.next().hasClass('spinner')) {
|
||||||
|
|
|
@ -359,7 +359,7 @@
|
||||||
url = parts.shift();
|
url = parts.shift();
|
||||||
var redirectionUrl = this.addUrlFlag(url, 'renderLayout');
|
var redirectionUrl = this.addUrlFlag(url, 'renderLayout');
|
||||||
var r = this.loadUrl(redirectionUrl, $('#layout'));
|
var r = this.loadUrl(redirectionUrl, $('#layout'));
|
||||||
r.url = url;
|
r.historyUrl = url;
|
||||||
if (parts.length) {
|
if (parts.length) {
|
||||||
r.loadNext = parts;
|
r.loadNext = parts;
|
||||||
} else if (!! document.location.hash) {
|
} else if (!! document.location.hash) {
|
||||||
|
@ -608,7 +608,8 @@
|
||||||
} else {
|
} else {
|
||||||
// Request wasn't for a container, so it's usually the body
|
// Request wasn't for a container, so it's usually the body
|
||||||
// or the full layout. Push request URL to history:
|
// or the full layout. Push request URL to history:
|
||||||
this.icinga.history.pushUrl(req.url);
|
var url = typeof req.historyUrl !== 'undefined' ? req.historyUrl : req.url;
|
||||||
|
this.icinga.history.pushUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +621,8 @@
|
||||||
|
|
||||||
if (typeof req.loadNext !== 'undefined' && req.loadNext.length) {
|
if (typeof req.loadNext !== 'undefined' && req.loadNext.length) {
|
||||||
if ($('#col2').length) {
|
if ($('#col2').length) {
|
||||||
this.loadUrl(req.loadNext[0], $('#col2'));
|
var r = this.loadUrl(req.loadNext[0], $('#col2'));
|
||||||
|
r.addToHistory = req.addToHistory;
|
||||||
this.icinga.ui.layout2col();
|
this.icinga.ui.layout2col();
|
||||||
} else {
|
} else {
|
||||||
this.icinga.logger.error('Failed to load URL for #col2', req.loadNext);
|
this.icinga.logger.error('Failed to load URL for #col2', req.loadNext);
|
||||||
|
|
|
@ -158,17 +158,14 @@ class UrlTest extends BaseTestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testWhetherGetRelativeUrlReturnsTheEmptyStringForAbsoluteUrls()
|
||||||
* @depends testWhetherFromPathProperlyRecognizesAndDecodesQueryParameters
|
|
||||||
*/
|
|
||||||
public function testWhetherGetRelativeUrlReturnsTheRelativeUrl()
|
|
||||||
{
|
{
|
||||||
$url = Url::fromPath('/my/test/url.html?param=val¶m2=val2');
|
$url = Url::fromPath('/my/test/url.html?param=val¶m2=val2');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'my/test/url.html?param=val¶m2=val2',
|
'',
|
||||||
$url->getRelativeUrl(),
|
$url->getRelativeUrl(),
|
||||||
'Url::getRelativeUrl does not return the relative url'
|
'Url::getRelativeUrl does not return the empty string for absolute urls'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue