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.'));
|
||||
|
||||
// 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) {
|
||||
$data = array_filter($form->getValues());
|
||||
|
|
|
@ -71,7 +71,7 @@ class LoginForm extends Form
|
|||
if ($this->created) {
|
||||
$redirect = $this->getElement('redirect')->getValue();
|
||||
}
|
||||
if (empty($redirect)) {
|
||||
if (empty($redirect) || strpos($redirect, 'authentication/logout') !== 0) {
|
||||
$redirect = static::REDIRECT_URL;
|
||||
}
|
||||
return Url::fromPath($redirect);
|
||||
|
|
|
@ -74,6 +74,8 @@ class NavigationConfigForm extends ConfigForm
|
|||
*/
|
||||
protected $itemTypes;
|
||||
|
||||
private $defaultUrl;
|
||||
|
||||
/**
|
||||
* Initialize this form
|
||||
*/
|
||||
|
@ -129,7 +131,7 @@ class NavigationConfigForm extends ConfigForm
|
|||
*/
|
||||
public function getUserConfig($type = null)
|
||||
{
|
||||
if ($this->userConfig === null) {
|
||||
if ($this->userConfig === null || $type !== null) {
|
||||
if ($type === null) {
|
||||
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()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -689,6 +699,8 @@ class NavigationConfigForm extends ConfigForm
|
|||
$data = $this->getConfigForItem($this->itemToLoad)->getSection($this->itemToLoad)->toArray();
|
||||
$data['name'] = $this->itemToLoad;
|
||||
$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">
|
||||
<?php if (
|
||||
$this->hasPermission('config/authentication/users/show')
|
||||
&& method_exists($backend, 'getUserBackend')
|
||||
&& ($userBackend = $backend->getUserBackend()) !== null
|
||||
&& $userBackend instanceof Selectable
|
||||
): ?>
|
||||
|
|
|
@ -151,7 +151,7 @@ class Web extends EmbeddedWeb
|
|||
|
||||
if (isset($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']);
|
||||
return true;
|
||||
}
|
||||
|
@ -159,6 +159,11 @@ class Web extends EmbeddedWeb
|
|||
|
||||
if (isset($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());
|
||||
$matches = array_intersect($userGroups, $groups);
|
||||
if (! empty($matches)) {
|
||||
|
|
|
@ -808,7 +808,7 @@ class LdapConnection implements Selectable, Inspectable
|
|||
|
||||
$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()) {
|
||||
foreach ($query->getOrder() as $rule) {
|
||||
if (! in_array($rule[0], $fields)) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class LdapQuery extends SimpleQuery
|
|||
protected function init()
|
||||
{
|
||||
$this->filters = array();
|
||||
$this->usePagedResults = true;
|
||||
$this->usePagedResults = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,7 +138,6 @@ class NavigationItem implements IteratorAggregate
|
|||
public function __construct($name, array $properties = null)
|
||||
{
|
||||
$this->setName($name);
|
||||
$this->priority = 100;
|
||||
$this->children = new Navigation();
|
||||
|
||||
if (! empty($properties)) {
|
||||
|
@ -237,7 +236,7 @@ class NavigationItem implements IteratorAggregate
|
|||
*/
|
||||
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.');
|
||||
}
|
||||
|
||||
if ($item->getActive()) {
|
||||
$this->setActive();
|
||||
if ($this->priority === null) {
|
||||
$priority = $item->getPriority();
|
||||
if ($priority !== 100) {
|
||||
$this->setPriority($priority);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->getIcon()) {
|
||||
$this->setIcon($item->getIcon());
|
||||
}
|
||||
|
||||
if ($this->getLabel() === $this->getName()) {
|
||||
if ($this->getLabel() === $this->getName() && $item->getLabel() !== $item->getName()) {
|
||||
$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) {
|
||||
$this->setAttribute($name, $value);
|
||||
}
|
||||
|
|
|
@ -161,9 +161,12 @@ class Url
|
|||
if ($urlPath && $urlPath[0] === '/') {
|
||||
if ($baseUrl) {
|
||||
$urlPath = substr($urlPath, 1);
|
||||
} elseif (strpos($urlPath, $request->getBaseUrl()) === 0) {
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
$urlPath = substr($urlPath, strlen($baseUrl) + 1);
|
||||
} else {
|
||||
$requestBaseUrl = $request->getBaseUrl();
|
||||
if ($requestBaseUrl && $requestBaseUrl !== '/' && strpos($urlPath, $requestBaseUrl) === 0) {
|
||||
$urlPath = substr($urlPath, strlen($requestBaseUrl) + 1);
|
||||
$baseUrl = $requestBaseUrl;
|
||||
}
|
||||
}
|
||||
} elseif (! $baseUrl) {
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
|
|
@ -48,10 +48,10 @@ class MacroTest extends BaseTestCase
|
|||
{
|
||||
$objectMock = Mockery::mock('object');
|
||||
$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()
|
||||
|
@ -59,8 +59,8 @@ class MacroTest extends BaseTestCase
|
|||
$hostMock = Mockery::mock('host');
|
||||
$hostMock->host_name = 'test';
|
||||
$hostMock->customvars = array(
|
||||
'HOST' => 'te',
|
||||
'NAME' => 'st'
|
||||
'host' => 'te',
|
||||
'name' => 'st'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -73,12 +73,12 @@ class MacroTest extends BaseTestCase
|
|||
{
|
||||
$objectMock = Mockery::mock('object');
|
||||
$objectMock->customvars = array(
|
||||
'V€RY_SP3C|@L' => 'not too special!'
|
||||
'v€ry_sp3c|@l' => 'not too special!'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
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()
|
||||
{
|
||||
try {
|
||||
return $this
|
||||
$query = $this
|
||||
->createUserBackend()
|
||||
->select(array('user_name'))
|
||||
->order('user_name', 'asc', true)
|
||||
->fetchColumn();
|
||||
->order('user_name', 'asc', true);
|
||||
if (in_array($this->backendConfig['backend'], array('ldap', 'msldap'))) {
|
||||
$query->getQuery()->setUsePagedResults();
|
||||
}
|
||||
|
||||
return $query->fetchColumn();
|
||||
} catch (Exception $_) {
|
||||
// No need to handle anything special here. Error means no users found.
|
||||
return array();
|
||||
|
@ -346,10 +350,14 @@ class AdminAccountPage extends Form
|
|||
protected function fetchGroups()
|
||||
{
|
||||
try {
|
||||
return $this
|
||||
$query = $this
|
||||
->createUserGroupBackend()
|
||||
->select(array('group_name'))
|
||||
->fetchColumn();
|
||||
->select(array('group_name'));
|
||||
if (in_array($this->backendConfig['backend'], array('ldap', 'msldap'))) {
|
||||
$query->getQuery()->setUsePagedResults();
|
||||
}
|
||||
|
||||
return $query->fetchColumn();
|
||||
} catch (Exception $_) {
|
||||
// No need to handle anything special here. Error means no groups found.
|
||||
return array();
|
||||
|
|
|
@ -291,7 +291,9 @@
|
|||
// 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)
|
||||
setTimeout(function () {
|
||||
if ($target.attr('id') == $form.closest('.container').attr('id')) {
|
||||
$form.find(':input:not(:disabled)').prop('disabled', true);
|
||||
}
|
||||
}, 0);
|
||||
|
||||
if (autosubmit) {
|
||||
|
@ -331,7 +333,9 @@
|
|||
|
||||
// Disable all form controls to prevent resubmission except for our search input
|
||||
// Note that disabled form inputs will not be enabled via JavaScript again
|
||||
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
|
||||
if (autosubmit && typeof $el !== 'undefined' && $el.next().hasClass('spinner')) {
|
||||
|
|
|
@ -359,7 +359,7 @@
|
|||
url = parts.shift();
|
||||
var redirectionUrl = this.addUrlFlag(url, 'renderLayout');
|
||||
var r = this.loadUrl(redirectionUrl, $('#layout'));
|
||||
r.url = url;
|
||||
r.historyUrl = url;
|
||||
if (parts.length) {
|
||||
r.loadNext = parts;
|
||||
} else if (!! document.location.hash) {
|
||||
|
@ -608,7 +608,8 @@
|
|||
} else {
|
||||
// Request wasn't for a container, so it's usually the body
|
||||
// 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 ($('#col2').length) {
|
||||
this.loadUrl(req.loadNext[0], $('#col2'));
|
||||
var r = this.loadUrl(req.loadNext[0], $('#col2'));
|
||||
r.addToHistory = req.addToHistory;
|
||||
this.icinga.ui.layout2col();
|
||||
} else {
|
||||
this.icinga.logger.error('Failed to load URL for #col2', req.loadNext);
|
||||
|
|
|
@ -158,17 +158,14 @@ class UrlTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testWhetherFromPathProperlyRecognizesAndDecodesQueryParameters
|
||||
*/
|
||||
public function testWhetherGetRelativeUrlReturnsTheRelativeUrl()
|
||||
public function testWhetherGetRelativeUrlReturnsTheEmptyStringForAbsoluteUrls()
|
||||
{
|
||||
$url = Url::fromPath('/my/test/url.html?param=val¶m2=val2');
|
||||
|
||||
$this->assertEquals(
|
||||
'my/test/url.html?param=val¶m2=val2',
|
||||
'',
|
||||
$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