From a14f800d9e0223921336479657956c153cba0932 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 16 Jul 2015 10:35:28 +0200 Subject: [PATCH 01/93] Add support for IPv6 address refs #9645 --- .../application/controllers/HostController.php | 1 + .../application/controllers/HostsController.php | 2 ++ .../application/controllers/ListController.php | 2 ++ .../application/controllers/ServicesController.php | 2 ++ .../views/scripts/partials/host/object-header.phtml | 11 +++++++---- .../scripts/partials/service/object-header.phtml | 10 ++++++---- .../Monitoring/Backend/Ido/Query/HoststatusQuery.php | 1 + .../Backend/Ido/Query/ServicestatusQuery.php | 1 + .../Monitoring/Backend/Ido/Query/StatusQuery.php | 1 + .../library/Monitoring/DataView/Hoststatus.php | 1 + .../library/Monitoring/DataView/Servicestatus.php | 1 + .../monitoring/library/Monitoring/Object/Host.php | 1 + .../monitoring/library/Monitoring/Object/Macro.php | 12 +++++++----- .../monitoring/library/Monitoring/Object/Service.php | 1 + modules/monitoring/public/css/module.less | 11 +++++++++-- .../test/php/library/Monitoring/Object/MacroTest.php | 6 ++++++ 16 files changed, 49 insertions(+), 15 deletions(-) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index a7659726e..514ff4544 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -77,6 +77,7 @@ class Monitoring_HostController extends MonitoredObjectController 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_handled', 'service_description', 'service_display_name', diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 740b5cb5c..477b27fe0 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -52,6 +52,7 @@ class Monitoring_HostsController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_state', 'host_problem', 'host_handled', @@ -91,6 +92,7 @@ class Monitoring_HostsController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_state', 'host_problem', 'host_handled', diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 3625043a6..4cf7cbd74 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -75,6 +75,7 @@ class Monitoring_ListController extends Controller 'host_display_name', 'host_state' => $stateColumn, 'host_address', + 'host_address6', 'host_acknowledged', 'host_output', 'host_attempt', @@ -151,6 +152,7 @@ class Monitoring_ListController extends Controller 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_handled', 'service_description', 'service_display_name', diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index faebcd11c..36582eeaf 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -54,6 +54,7 @@ class Monitoring_ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', @@ -101,6 +102,7 @@ class Monitoring_ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 1a2fc356d..75cdf2cb9 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -14,11 +14,14 @@ use Icinga\Module\Monitoring\Object\Host; host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) - host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> + render('partials/host/statusicons.phtml'); ?> +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> + + host_address && $object->host_address !== $object->host_name): ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index c3df4044b..5a6fac2ea 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -15,11 +15,13 @@ use Icinga\Module\Monitoring\Object\Service; host_display_name !== $object->host_name): ?> (escape($object->host_name); ?>) - host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> + + host_address && $object->host_address !== $object->host_name): ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 3feb37a9e..0e94b5f30 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -25,6 +25,7 @@ class HoststatusQuery extends IdoQuery 'host' => 'ho.name1 COLLATE latin1_general_ci', 'host_action_url' => 'h.action_url', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_alias' => 'h.alias', 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_icon_image' => 'h.icon_image', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php index 0a03f273d..6362bb7ce 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php @@ -27,6 +27,7 @@ class ServicestatusQuery extends IdoQuery 'hosts' => array( 'host_action_url' => 'h.action_url', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_alias' => 'h.alias COLLATE latin1_general_ci', 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_icon_image' => 'h.icon_image', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index 5a3bba9e5..a5112d0ea 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -39,6 +39,7 @@ class StatusQuery extends IdoQuery 'host_display_name' => 'h.display_name COLLATE latin1_general_ci', 'host_alias' => 'h.alias', 'host_address' => 'h.address', + 'host_address6' => 'h.address6', 'host_ipv4' => 'INET_ATON(h.address)', 'host_icon_image' => 'h.icon_image', 'host_icon_image_alt' => 'h.icon_image_alt', diff --git a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php index 9c2848618..3cd76b1ce 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php @@ -15,6 +15,7 @@ class HostStatus extends DataView 'host_display_name', 'host_alias', 'host_address', + 'host_address6', 'host_state', 'host_state_type', 'host_handled', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php index a4516a93a..82f02ee58 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php @@ -29,6 +29,7 @@ class ServiceStatus extends DataView 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_problem', 'host_handled', 'service_description', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 3bb10d77e..77ee8db6b 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -96,6 +96,7 @@ class Host extends MonitoredObject 'host_active_checks_enabled', 'host_active_checks_enabled_changed', 'host_address', + 'host_address6', 'host_alias', 'host_check_command', 'host_check_execution_time', diff --git a/modules/monitoring/library/Monitoring/Object/Macro.php b/modules/monitoring/library/Monitoring/Object/Macro.php index 4a9045b58..a8a3552dd 100644 --- a/modules/monitoring/library/Monitoring/Object/Macro.php +++ b/modules/monitoring/library/Monitoring/Object/Macro.php @@ -14,11 +14,13 @@ class Macro * @var array */ private static $icingaMacros = array( - 'HOSTNAME' => 'host_name', - 'HOSTADDRESS' => 'host_address', - 'SERVICEDESC' => 'service_description', - 'host.name' => 'host_name', - 'host.address' => 'host_address', + 'HOSTNAME' => 'host_name', + 'HOSTADDRESS' => 'host_address', + 'HOSTADDRESS6' => 'host_address6', + 'SERVICEDESC' => 'service_description', + 'host.name' => 'host_name', + 'host.address' => 'host_address', + 'host.address6' => 'host_address6', 'service.description' => 'service_description' ); diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 855e62882..85668f4b4 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -111,6 +111,7 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_active_checks_enabled', 'host_address', + 'host_address6', 'host_alias', 'host_display_name', 'host_handled', diff --git a/modules/monitoring/public/css/module.less b/modules/monitoring/public/css/module.less index 406031c19..a8a53293e 100644 --- a/modules/monitoring/public/css/module.less +++ b/modules/monitoring/public/css/module.less @@ -4,12 +4,19 @@ width: 16em; } -p.pluginoutput { - width: 100%; +.padded { + padding: 0 5px; +} + +.address, p.pluginoutput { white-space: pre-wrap; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'DejaVu Sans Mono', 'Courier New', Courier, monospace; } +p.pluginoutput { + width: 100%; +} + table.action td .pluginoutput { font-size: 0.875em; line-height: 1.2em; diff --git a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php index e1b3595e3..89dae3b4d 100644 --- a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php @@ -16,11 +16,14 @@ class MacroTest extends BaseTestCase $hostMock = Mockery::mock('host'); $hostMock->host_name = 'test'; $hostMock->host_address = '1.1.1.1'; + $hostMock->host_address6 = '::1'; $this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $hostMock), $hostMock->host_name); $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $hostMock), $hostMock->host_address); + $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $hostMock), $hostMock->host_address6); $this->assertEquals(Macro::resolveMacros('$host.name$', $hostMock), $hostMock->host_name); $this->assertEquals(Macro::resolveMacros('$host.address$', $hostMock), $hostMock->host_address); + $this->assertEquals(Macro::resolveMacros('$host.address6$', $hostMock), $hostMock->host_address6); } public function testServiceMacros() @@ -28,13 +31,16 @@ class MacroTest extends BaseTestCase $svcMock = Mockery::mock('service'); $svcMock->host_name = 'test'; $svcMock->host_address = '1.1.1.1'; + $svcMock->host_address6 = '::1'; $svcMock->service_description = 'a service'; $this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $svcMock), $svcMock->host_name); $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $svcMock), $svcMock->host_address); + $this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $svcMock), $svcMock->host_address6); $this->assertEquals(Macro::resolveMacros('$SERVICEDESC$', $svcMock), $svcMock->service_description); $this->assertEquals(Macro::resolveMacros('$host.name$', $svcMock), $svcMock->host_name); $this->assertEquals(Macro::resolveMacros('$host.address$', $svcMock), $svcMock->host_address); + $this->assertEquals(Macro::resolveMacros('$host.address6$', $svcMock), $svcMock->host_address6); $this->assertEquals(Macro::resolveMacros('$service.description$', $svcMock), $svcMock->service_description); } From 083900dae05ef9e499519135df390620ea4802c0 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 4 Aug 2015 14:06:33 +0200 Subject: [PATCH 02/93] Implement DblClickSelect as a Icinga Behavior refs #9826 --- library/Icinga/Web/JavaScript.php | 3 +- .../scripts/partials/host/object-header.phtml | 8 ++-- .../partials/service/object-header.phtml | 10 ++--- public/js/icinga/behavior/dblclickselect.js | 45 +++++++++++++++++++ 4 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 public/js/icinga/behavior/dblclickselect.js diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index ed39c1b39..dafdee32a 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -27,7 +27,8 @@ class JavaScript 'js/icinga/behavior/tristate.js', 'js/icinga/behavior/navigation.js', 'js/icinga/behavior/form.js', - 'js/icinga/behavior/actiontable.js' + 'js/icinga/behavior/actiontable.js', + 'js/icinga/behavior/dblclickselect.js' ); protected static $vendorFiles = array( diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 75cdf2cb9..b9ad79f00 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -10,17 +10,17 @@ use Icinga\Module\Monitoring\Object\Host; iconImage()->host($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) render('partials/host/statusicons.phtml'); ?>
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index 5a6fac2ea..67f48e195 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -11,16 +11,16 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->service($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>)
host_address6 && $object->host_address6 !== $object->host_name): ?> - escape($object->host_address6); ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> - escape($object->host_address); ?> + escape($object->host_address); ?> @@ -31,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->host($object) ?> - translate('Service'); ?>: escape($object->service_display_name); ?> + translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/public/js/icinga/behavior/dblclickselect.js b/public/js/icinga/behavior/dblclickselect.js new file mode 100644 index 000000000..142857063 --- /dev/null +++ b/public/js/icinga/behavior/dblclickselect.js @@ -0,0 +1,45 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +(function(Icinga, $) { + + "use strict"; + + Icinga.Behaviors = Icinga.Behaviors || {}; + + var DblClickSelect = function (icinga) { + Icinga.EventListener.call(this, icinga); + this.on('rendered', this.onRendered, this); + }; + DblClickSelect.prototype = new Icinga.EventListener(); + + DblClickSelect.prototype.onRendered = function(evt) { + $(evt.target).on('dblclick', '.dblclickselect', function() { $(this).selectText(); }); + }; + + /** + * extend jQuery with a selectText function + * + * This function will create a browser selection of the choosen DOM object. + */ + $.fn.selectText = function() { + if (this.length === 0) return; + var e = this[0]; + + var b = document.body, r; + if (b.createTextRange) { + r = b.createTextRange(); + r.moveToElementText(e); + r.select(); + } else if (window.getSelection) { + var s = window.getSelection(); + r = document.createRange(); + r.selectNodeContents(e); + s.removeAllRanges(); + s.addRange(r); + } + }; + + // Export + Icinga.Behaviors.DblClickSelect = DblClickSelect; + +}) (Icinga, jQuery); From cd319f8c7d9e43017f8f48a31f21c8928ffdf852 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 22 Sep 2015 18:21:25 +0200 Subject: [PATCH 03/93] Let the error page look like the login page when a non-authenticated user requests a non-existent page refs #10009 --- application/controllers/ErrorController.php | 16 +++++++--- application/views/scripts/error/error.phtml | 35 +++++++++++++++------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/application/controllers/ErrorController.php b/application/controllers/ErrorController.php index 62198ec0c..670c64339 100644 --- a/application/controllers/ErrorController.php +++ b/application/controllers/ErrorController.php @@ -29,6 +29,7 @@ class ErrorController extends ActionController */ public function errorAction() { + $this->view->noAuthPageNotFound = false; $error = $this->_getParam('error_handler'); $exception = $error->exception; /** @var \Exception $exception */ @@ -45,11 +46,16 @@ class ErrorController extends ActionController $path = array_shift($path); $this->getResponse()->setHttpResponseCode(404); $this->view->message = $this->translate('Page not found.'); - if ($this->Auth()->isAuthenticated() && $modules->hasInstalled($path) && ! $modules->hasEnabled($path)) { - $this->view->message .= ' ' . sprintf( - $this->translate('Enabling the "%s" module might help!'), - $path - ); + if ($this->Auth()->isAuthenticated()) { + if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) { + $this->view->message .= ' ' . sprintf( + $this->translate('Enabling the "%s" module might help!'), + $path + ); + } + } else { + $this->innerLayout = 'inline'; + $this->view->noAuthPageNotFound = true; } break; diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml index 5b3480922..b7927983f 100644 --- a/application/views/scripts/error/error.phtml +++ b/application/views/scripts/error/error.phtml @@ -1,10 +1,25 @@ -
-tabs->showOnlyCloseButton() ?> -
-
-

escape($message)) ?>

- -
-
escape($stackTrace) ?>
- -
+ +
+ +
+
+

escape($message)) ?>

+
+
+
+ +
+ tabs->showOnlyCloseButton() ?> +
+
+

escape($message)) ?>

+ +
+
escape($stackTrace) ?>
+ +
+ From abcdc5adb1c890765ba0559a403c0cb8261c16be Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 04/93] Fetch Git commit ID from .git/HEAD if available refs #9247 --- library/Icinga/Application/Version.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index c06eca2c2..70ad6cd63 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -15,6 +15,17 @@ class Version */ public static function get() { + if (false !== ($gitHead = @file_get_contents(( + $gitDir = Icinga::app()->getBaseDir('.git') + ) . DIRECTORY_SEPARATOR . 'HEAD'))) { + $matches = array(); + if ((1 !== @preg_match('/(?.+?)$/ms', $gitHead, $matches) || false !== ( + $gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches['gitCommitID']) + )) && 1 === @preg_match('/(?[0-9a-f]+)$/ms', $gitHead, $matches)) { + return $matches; + } + } + if (false === ($appVersion = @file_get_contents( Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION' ))) { From d6cf6313b9bd3df68b86eb4f7041088090fefeaf Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 23 Sep 2015 15:53:10 +0200 Subject: [PATCH 05/93] Split complex if statements --- library/Icinga/Application/Version.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 70ad6cd63..85495966b 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -15,14 +15,21 @@ class Version */ public static function get() { - if (false !== ($gitHead = @file_get_contents(( - $gitDir = Icinga::app()->getBaseDir('.git') - ) . DIRECTORY_SEPARATOR . 'HEAD'))) { + $gitDir = Icinga::app()->getBaseDir('.git'); + $gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD'); + if (false !== $gitHead) { $matches = array(); - if ((1 !== @preg_match('/(?.+?)$/ms', $gitHead, $matches) || false !== ( - $gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches['gitCommitID']) - )) && 1 === @preg_match('/(?[0-9a-f]+)$/ms', $gitHead, $matches)) { - return $matches; + if (@preg_match('/(?[0-9a-f]+)$/ms', $gitCommitID, $matches)) { + return $matches; + } } } From 7c3b46fefa7e1050003062818f7cc6fdeeddbb3d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 23 Sep 2015 17:48:30 +0200 Subject: [PATCH 06/93] Make regex less complicated --- library/Icinga/Application/Version.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 85495966b..886ac1433 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -33,26 +33,26 @@ class Version } } - if (false === ($appVersion = @file_get_contents( - Icinga::app()->getApplicationDir() . DIRECTORY_SEPARATOR . 'VERSION' - ))) { + if (false === ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) { return false; } $matches = array(); - if (false === ($res = preg_match( - '/(?\w+)(?:\s*\(.*?(?:(?<=[\(,])\s*tag\s*:\s*v(?P.+?)\s*(?=[\),]).*?)?\))?\s*(?P\S+)/ms', - $appVersion, - $matches - )) || $res === 0) { + if (! @preg_match('/^(?P\S+)(?: \((.+?)\))? (?P\S+)/', $appVersion, $matches)) { return false; } - foreach ($matches as $key => $value) { - if (is_int($key) || $value === '') { - unset($matches[$key]); + if (array_key_exists(1, $matches)) { + $tagMatches = array(); + foreach (explode(', ', $matches[1]) as $gitRef) { + if (@preg_match('/^tag: v(.+)/', $gitRef, $tagMatches)) { + $matches['appVersion'] = $tagMatches[1]; + break; + } } + unset($matches[1]); } + return $matches; } } From 91377a4bd731c5b5e47544789c2a323d9a5abeef Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 07/93] Show copyright and license on the about page refs #9247 --- application/views/scripts/about/index.phtml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index e270a8eb9..71ae71bc0 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -22,4 +22,7 @@ : '

' . nl2br(implode("\n", $versionInfo), false) ) . '

'; ?> +

Copyright © 2013-2015 translate('The Icinga Project') + ?>
License: GNU GPL v2 or later

From cc4a47506f0c1433382a4521177f762388455a65 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 08/93] Fetch version from constant refs #9247 --- application/VERSION | 2 +- library/Icinga/Application/Version.php | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/application/VERSION b/application/VERSION index 519b667a7..f504e66fd 100644 --- a/application/VERSION +++ b/application/VERSION @@ -1 +1 @@ -$Format:%H%d %ci$ +$Format:%H %ci$ diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 886ac1433..528a40612 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -8,6 +8,8 @@ namespace Icinga\Application; */ class Version { + const VERSION = '2.0.0-rc1'; + /** * Get the version of this instance of Icinga Web 2 * @@ -28,6 +30,7 @@ class Version if (false !== $gitCommitID) { $matches = array(); if (@preg_match('/(?[0-9a-f]+)$/ms', $gitCommitID, $matches)) { + $matches['appVersion'] = self::VERSION; return $matches; } } @@ -38,21 +41,11 @@ class Version } $matches = array(); - if (! @preg_match('/^(?P\S+)(?: \((.+?)\))? (?P\S+)/', $appVersion, $matches)) { + if (! @preg_match('/^(?P\w+) (?P\S+)/', $appVersion, $matches)) { return false; } - if (array_key_exists(1, $matches)) { - $tagMatches = array(); - foreach (explode(', ', $matches[1]) as $gitRef) { - if (@preg_match('/^tag: v(.+)/', $gitRef, $tagMatches)) { - $matches['appVersion'] = $tagMatches[1]; - break; - } - } - unset($matches[1]); - } - + $matches['appVersion'] = self::VERSION; return $matches; } } From 3e99adbe63e568595f23069d0040060ed9029dd2 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 09/93] Version::get(): first try to parse application/VERSION refs #9247 --- library/Icinga/Application/Version.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 528a40612..0aa29314f 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -17,6 +17,14 @@ class Version */ public static function get() { + if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) { + $matches = array(); + if (@preg_match('/^(?P\w+) (?P\S+)/', $appVersion, $matches)) { + $matches['appVersion'] = self::VERSION; + return $matches; + } + } + $gitDir = Icinga::app()->getBaseDir('.git'); $gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD'); if (false !== $gitHead) { @@ -36,16 +44,6 @@ class Version } } - if (false === ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) { - return false; - } - - $matches = array(); - if (! @preg_match('/^(?P\w+) (?P\S+)/', $appVersion, $matches)) { - return false; - } - - $matches['appVersion'] = self::VERSION; - return $matches; + return false; } } From feb27b8a02c997859cfe2ff85c4aacb17da4c241 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 10/93] Rename application/VERSION to application/GITCOMMIT refs #9247 --- .gitattributes | 2 +- application/{VERSION => GITCOMMIT} | 0 icingaweb2.spec | 2 +- library/Icinga/Application/Version.php | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename application/{VERSION => GITCOMMIT} (100%) diff --git a/.gitattributes b/.gitattributes index 6ae8ee7af..4175dd6b3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,4 @@ Vagrantfile export-ignore .puppet* eol=lf # Include version information on `git archive' -/application/VERSION export-subst +/application/GITCOMMIT export-subst diff --git a/application/VERSION b/application/GITCOMMIT similarity index 100% rename from application/VERSION rename to application/GITCOMMIT diff --git a/icingaweb2.spec b/icingaweb2.spec index 3ea135589..fc221974e 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -204,7 +204,7 @@ rm -rf %{buildroot} %{basedir}/application/forms %{basedir}/application/layouts %{basedir}/application/views -%{basedir}/application/VERSION +%{basedir}/application/GITCOMMIT %{basedir}/doc %{basedir}/modules %{basedir}/public diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 0aa29314f..7d8f54fbf 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -17,7 +17,7 @@ class Version */ public static function get() { - if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('VERSION')))) { + if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('GITCOMMIT')))) { $matches = array(); if (@preg_match('/^(?P\w+) (?P\S+)/', $appVersion, $matches)) { $matches['appVersion'] = self::VERSION; From e2d6089ff3f004c221d7ea7cda34edc533c7d44c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 11/93] Make Version::get() failsafe refs #9247 --- application/views/scripts/about/index.phtml | 24 +++++++-------------- library/Icinga/Application/Version.php | 12 +++++------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index 71ae71bc0..d6d766e93 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -2,26 +2,18 @@

Icinga Web 2

$this->translate('Version: %s'), - 'gitCommitID' => $this->translate('Git commit ID: %s'), - 'gitCommitDate' => $this->translate('Git commit date: %s') - ) as $key => $label) { - if (array_key_exists($key, $version) && null !== ($value = $version[$key])) { - $versionInfo[] = sprintf($label, htmlspecialchars($value)); - } + foreach (array( + 'appVersion' => $this->translate('Version: %s'), + 'gitCommitID' => $this->translate('Git commit ID: %s'), + 'gitCommitDate' => $this->translate('Git commit date: %s') + ) as $key => $label) { + if (array_key_exists($key, $version) && null !== ($value = $version[$key])) { + $versionInfo[] = sprintf($label, htmlspecialchars($value)); } } - echo ( - 0 === count($versionInfo) - ? '

' . $this->translate( - 'Can\'t determine Icinga Web 2\'s version' - ) - : '

' . nl2br(implode("\n", $versionInfo), false) - ) . '

'; ?> +

', $versionInfo) ?>

Copyright © 2013-2015 translate('The Icinga Project') ?>
License: GNU GPL v2 or later

diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 7d8f54fbf..22b05f1cc 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -13,15 +13,16 @@ class Version /** * Get the version of this instance of Icinga Web 2 * - * @return array|false array on success, false otherwise + * @return array */ public static function get() { + $version = array('appVersion' => self::VERSION); + if (false !== ($appVersion = @file_get_contents(Icinga::app()->getApplicationDir('GITCOMMIT')))) { $matches = array(); if (@preg_match('/^(?P\w+) (?P\S+)/', $appVersion, $matches)) { - $matches['appVersion'] = self::VERSION; - return $matches; + return array_merge($version, $matches); } } @@ -38,12 +39,11 @@ class Version if (false !== $gitCommitID) { $matches = array(); if (@preg_match('/(?[0-9a-f]+)$/ms', $gitCommitID, $matches)) { - $matches['appVersion'] = self::VERSION; - return $matches; + return array_merge($version, $matches); } } } - return false; + return $version; } } From bfc2738fe5ed30da79b30b29ceef78554a0188d9 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 12/93] Translate license statement refs #9247 --- application/views/scripts/about/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index d6d766e93..4ee1b930c 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -16,5 +16,5 @@

', $versionInfo) ?>

Copyright © 2013-2015 translate('The Icinga Project') - ?>
License: GNU GPL v2 or later

+ ?>
translate('License: GNU GPL v2 or later') ?>

From 52221dd10a7b2dd9df95e40987ae51077b5457c7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jun 2015 12:38:55 +0200 Subject: [PATCH 13/93] Add doc and social media links to the about page refs #9247 --- application/views/scripts/about/index.phtml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index 4ee1b930c..f2ce994d1 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -17,4 +17,17 @@

Copyright © 2013-2015 translate('The Icinga Project') ?>
translate('License: GNU GPL v2 or later') ?>

+

translate('Report a bug') + ?>translate('Support') + ?>translate('Icinga Wiki') + ?>translate('Icinga Documentation') + ?>
translate('Icinga on Twitter') + ?>translate('Icinga on Facebook') + ?>

From f64db890d2ad8726a086372c474d8aa1daf67c62 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 24 Sep 2015 19:23:49 +0200 Subject: [PATCH 14/93] Show loaded modules in the about page refs #9381 --- application/controllers/AboutController.php | 2 ++ application/views/scripts/about/index.phtml | 25 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/application/controllers/AboutController.php b/application/controllers/AboutController.php index fc1c78931..f4ff2fb3c 100644 --- a/application/controllers/AboutController.php +++ b/application/controllers/AboutController.php @@ -5,11 +5,13 @@ namespace Icinga\Controllers; use Icinga\Application\Version; use Icinga\Web\Controller\ActionController; +use Icinga\Application\Icinga; class AboutController extends ActionController { public function indexAction() { $this->view->version = Version::get(); + $this->view->modules = Icinga::app()->getModuleManager()->getLoadedModules(); } } diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index e270a8eb9..a85407f22 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -22,4 +22,29 @@ : '

' . nl2br(implode("\n", $versionInfo), false) ) . '

'; ?> +

translate('Loaded modules') ?>

+ + + + + + + + + getName(); + ?> + + + + + + +
translate('Name') ?>translate('Version') ?>
qlink( + $name, + 'config/module/', + array('name' => $name), + array('title' => sprintf($this->translate('Show the overview of the %s module'), $name)) + ) ?>getVersion() ?>
From 4a85e112d22314b8569c5e391e099597e007258b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 24 Sep 2015 19:23:49 +0200 Subject: [PATCH 15/93] Don't link to loaded modules in the about page if the user doesn't have the required permission refs #9381 --- application/controllers/AboutController.php | 1 + application/views/scripts/about/index.phtml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/application/controllers/AboutController.php b/application/controllers/AboutController.php index f4ff2fb3c..f9f5be5b0 100644 --- a/application/controllers/AboutController.php +++ b/application/controllers/AboutController.php @@ -11,6 +11,7 @@ class AboutController extends ActionController { public function indexAction() { + $this->view->hasPermission = $this->hasPermission('config/modules'); $this->view->version = Version::get(); $this->view->modules = Icinga::app()->getModuleManager()->getLoadedModules(); } diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index a85407f22..76c23943c 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -36,12 +36,12 @@ $name = $module->getName(); ?> - qlink( + qlink( $name, 'config/module/', array('name' => $name), array('title' => sprintf($this->translate('Show the overview of the %s module'), $name)) - ) ?> + ) : $name ?> getVersion() ?> From 73715c94b152171935de3e3816a28a8a9de88826 Mon Sep 17 00:00:00 2001 From: Aaron Collins Date: Tue, 22 Sep 2015 13:00:43 -0700 Subject: [PATCH 16/93] Fixes for ldap group auth The current LdapUserGroupBackend was incomplete and suffered from a little over zealous copy pasta. It had over written certain functions that where unnecessary such as the constructor and a table validator. This patch aims to clean those up. Additionally it also makes this group auth work with posixGroup that use the username as the member identifier and not just inetGroups that use the full dn refs #9950 Signed-off-by: Eric Lippmann --- .../UserGroup/LdapUserGroupBackend.php | 95 +++++-------------- 1 file changed, 23 insertions(+), 72 deletions(-) diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index 1d29e018d..037588992 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -12,9 +12,8 @@ use Icinga\Protocol\Ldap\Expression; use Icinga\Repository\LdapRepository; use Icinga\Repository\RepositoryQuery; use Icinga\User; -use Icinga\Application\Logger; -class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBackendInterface +class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInterface { /** * The base DN to use for a user query @@ -119,30 +118,6 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken 'samaccountname' => 'sAMAccountName' ); - /** - * The name of this repository - * - * @var string - */ - protected $name; - - /** - * The datasource being used - * - * @var Connection - */ - protected $ds; - - /** - * Create a new LDAP repository object - * - * @param Connection $ds The data source to use - */ - public function __construct($ds) - { - $this->ds = $ds; - } - /** * Return the given attribute name normed to known LDAP enviroments, if possible * @@ -420,6 +395,7 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken public function select(array $columns = null) { $query = parent::select($columns); + $query->getQuery()->setBase($this->groupBaseDn); if ($this->groupFilter) { // TODO(jom): This should differentiate between groups and their memberships @@ -462,7 +438,7 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken 'created_at' => $createdAtAttribute, 'last_modified' => $lastModifiedAttribute ); - return array('group' => $columns, 'group_membership' => $columns); + return array( $this->groupClass => $columns, 'group_membership' => $columns); //dumb hack because of how groupcontroller fetches data and my limited knowledge of this codebase } /** @@ -501,29 +477,6 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken ); } - /** - * Validate that the requested table exists - * - * This will return $this->groupClass in case $table equals "group" or "group_membership". - * - * @param string $table The table to validate - * @param RepositoryQuery $query An optional query to pass as context - * (unused by the base implementation) - * - * @return string - * - * @throws ProgrammingError In case the given table does not exist - */ - public function requireTable($table, RepositoryQuery $query = null) - { - $table = parent::requireTable($table, $query); - if ($table === 'group' || $table === 'group_membership') { - $table = $this->groupClass; - } - - return $table; - } - /** * Return the groups the given user is a member of * @@ -533,43 +486,41 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken */ public function getMemberships(User $user) { - if ($this->groupClass === 'posixGroup') { - // Posix group only uses simple user name - $userDn = $user->getUsername(); - } else { - // LDAP groups use the complete DN - if (($userDn = $user->getAdditional('ldap_dn')) === null) { - $userQuery = $this->ds - ->select() - ->from($this->userClass) - ->where($this->userNameAttribute, $user->getUsername()) - ->setBase($this->userBaseDn) - ->setUsePagedResults(false); - if ($this->userFilter) { - $userQuery->where(new Expression($this->userFilter)); - } + if (($userDn = $user->getAdditional('ldap_dn')) === null) { + $userQuery = $this->ds + ->select() + ->from($this->userClass) + ->where($this->userNameAttribute, $user->getUsername()) + ->setBase($this->userBaseDn) + ->setUsePagedResults(false); + if ($this->userFilter) { + $userQuery->where(new Expression($this->userFilter)); + } - if (($userDn = $userQuery->fetchDn()) === null) { - return array(); - } + if ($this->groupClass == 'posixGroup') { + $queryUsername = $user->getUsername(); + } + else { + if (($queryUsername = $userQuery->fetchDn()) === null) { + return array(); + } } } $groupQuery = $this->ds ->select() ->from($this->groupClass, array($this->groupNameAttribute)) - ->where($this->groupMemberAttribute, $userDn) + ->where($this->groupMemberAttribute, $queryUsername) ->setBase($this->groupBaseDn); + if ($this->groupFilter) { $groupQuery->where(new Expression($this->groupFilter)); } - Logger::debug('Fetching groups for user %s using filter %s.', $user->getUsername(), $groupQuery->__toString()); $groups = array(); foreach ($groupQuery as $row) { $groups[] = $row->{$this->groupNameAttribute}; } - Logger::debug('Fetched %d groups: %s.', count($groups), join(', ', $groups)); return $groups; } @@ -661,4 +612,4 @@ class LdapUserGroupBackend /*extends LdapRepository*/ implements UserGroupBacken 'group_member_attribute' => 'member' )); } -} +} \ No newline at end of file From 23631c8f3964df813541b4a2c9f7ce3319d4d41e Mon Sep 17 00:00:00 2001 From: Aaron Collins Date: Tue, 22 Sep 2015 13:04:32 -0700 Subject: [PATCH 17/93] changed order of posix check refs #9950 Signed-off-by: Eric Lippmann --- .../Authentication/UserGroup/LdapUserGroupBackend.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index 037588992..9cd607c58 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -486,6 +486,8 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt */ public function getMemberships(User $user) { + $queryUsername = $user->getUsername(); + if (($userDn = $user->getAdditional('ldap_dn')) === null) { $userQuery = $this->ds ->select() @@ -497,10 +499,7 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt $userQuery->where(new Expression($this->userFilter)); } - if ($this->groupClass == 'posixGroup') { - $queryUsername = $user->getUsername(); - } - else { + if ($this->groupClass != 'posixGroup') { if (($queryUsername = $userQuery->fetchDn()) === null) { return array(); } From ed935696ac864e5e97698ad8e9b9fa36bdaea0c1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 22 Sep 2015 18:21:25 +0200 Subject: [PATCH 18/93] CSS: outsource .logo related rules into a new .less file `logo.less' refs #10009 --- library/Icinga/Web/StyleSheet.php | 1 + public/css/icinga/layout-structure.less | 3 --- public/css/icinga/login.less | 26 ------------------- public/css/icinga/logo.less | 33 +++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 public/css/icinga/logo.less diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index f22e66d33..dd45743fd 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -28,6 +28,7 @@ class StyleSheet 'css/icinga/pagination.less', 'css/icinga/selection-toolbar.less', 'css/icinga/login.less', + 'css/icinga/logo.less', 'css/icinga/controls.less' ); diff --git a/public/css/icinga/layout-structure.less b/public/css/icinga/layout-structure.less index 47adbca7c..fcb5ff390 100644 --- a/public/css/icinga/layout-structure.less +++ b/public/css/icinga/layout-structure.less @@ -280,9 +280,6 @@ html { } #login { - .logo .image img { - width: 70%; - } .form { width: 100%; margin: auto; diff --git a/public/css/icinga/login.less b/public/css/icinga/login.less index a24265e88..1ffdebd40 100644 --- a/public/css/icinga/login.less +++ b/public/css/icinga/login.less @@ -4,37 +4,11 @@ width: 100%; height: 100%; - .logo { - background-color: @colorPetrol; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 60%; - border-bottom: 1px solid #d9d9d9d; - text-align: center; - -webkit-box-shadow: 0 3px 7px -3px #000; - -moz-box-shadow: 0 3px 7px -3px #000; - box-shadow: 0 3px 7px -3px #000; - } - - .image { - position: absolute; - bottom: 1em; - left: 0px; - right: 0px; - text-align: center; - } - .error { margin-left:auto; margin-right:auto; } - .image img { - width: 375px; - } - .form { position: absolute; font-size: 0.9em; diff --git a/public/css/icinga/logo.less b/public/css/icinga/logo.less new file mode 100644 index 000000000..25860b112 --- /dev/null +++ b/public/css/icinga/logo.less @@ -0,0 +1,33 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +.logo { + background-color: @colorPetrol; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 60%; + border-bottom: 1px solid #d9d9d9d; + text-align: center; + -webkit-box-shadow: 0 3px 7px -3px #000; + -moz-box-shadow: 0 3px 7px -3px #000; + box-shadow: 0 3px 7px -3px #000; + + .image { + position: absolute; + bottom: 1em; + left: 0px; + right: 0px; + text-align: center; + + img { + width: 375px; + } + } +} + +#layout.minimal-layout { + .logo .image img { + width: 70%; + } +} From b19ecbfb430d5e915935bbeaea4e4f76cfe39dae Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 25 Sep 2015 16:21:33 +0200 Subject: [PATCH 19/93] LdapUserGroupBackend: Remove the remaining code duplicates refs #9950 refs #9772 --- .../UserGroup/LdapUserGroupBackend.php | 57 ------------------- 1 file changed, 57 deletions(-) diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index 9cd607c58..a56e1fe71 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -103,63 +103,6 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt ) ); - /** - * Normed attribute names based on known LDAP environments - * - * @var array - */ - protected $normedAttributes = array( - 'uid' => 'uid', - 'gid' => 'gid', - 'user' => 'user', - 'group' => 'group', - 'member' => 'member', - 'inetorgperson' => 'inetOrgPerson', - 'samaccountname' => 'sAMAccountName' - ); - - /** - * Return the given attribute name normed to known LDAP enviroments, if possible - * - * @param string $name - * - * @return string - */ - protected function getNormedAttribute($name) - { - $loweredName = strtolower($name); - if (array_key_exists($loweredName, $this->normedAttributes)) { - return $this->normedAttributes[$loweredName]; - } - - return $name; - } - - /** - * Set this repository's name - * - * @param string $name - * - * @return $this - */ - public function setName($name) - { - $this->name = $name; - return $this; - } - - /** - * Return this repository's name - * - * In case no name has been explicitly set yet, the class name is returned. - * - * @return string - */ - public function getName() - { - return $this->name; - } - /** * Set the base DN to use for a user query * From fe9ee48d653f54d08322ae91f5c65e1c900c01c2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 25 Sep 2015 16:23:13 +0200 Subject: [PATCH 20/93] LdapUserGroupBackend: Fix incorrect table name initialization refs #9950 --- .../Icinga/Authentication/UserGroup/LdapUserGroupBackend.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index a56e1fe71..b8b928118 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -338,7 +338,6 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt public function select(array $columns = null) { $query = parent::select($columns); - $query->getQuery()->setBase($this->groupBaseDn); if ($this->groupFilter) { // TODO(jom): This should differentiate between groups and their memberships @@ -381,7 +380,7 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt 'created_at' => $createdAtAttribute, 'last_modified' => $lastModifiedAttribute ); - return array( $this->groupClass => $columns, 'group_membership' => $columns); //dumb hack because of how groupcontroller fetches data and my limited knowledge of this codebase + return array('group' => $columns, 'group_membership' => $columns); } /** From e5f2174c1e3c336d450e7ca8b3ef95a1fd029228 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 25 Sep 2015 16:24:16 +0200 Subject: [PATCH 21/93] LdapUserGroupBackend: Restore method requireTable() refs #9950 --- .../UserGroup/LdapUserGroupBackend.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php index b8b928118..9b505bf39 100644 --- a/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/LdapUserGroupBackend.php @@ -419,6 +419,29 @@ class LdapUserGroupBackend extends LdapRepository implements UserGroupBackendInt ); } + /** + * Validate that the requested table exists + * + * This will return $this->groupClass in case $table equals "group" or "group_membership". + * + * @param string $table The table to validate + * @param RepositoryQuery $query An optional query to pass as context + * (unused by the base implementation) + * + * @return string + * + * @throws ProgrammingError In case the given table does not exist + */ + public function requireTable($table, RepositoryQuery $query = null) + { + $table = parent::requireTable($table, $query); + if ($table === 'group' || $table === 'group_membership') { + $table = $this->groupClass; + } + + return $table; + } + /** * Return the groups the given user is a member of * From 426f64e32a7b3989ecf1e23edf8135a730de52e0 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 22 Sep 2015 18:21:25 +0200 Subject: [PATCH 22/93] CSS: rename .form to .below-logo refs #10009 --- .../views/scripts/authentication/login.phtml | 2 +- application/views/scripts/error/error.phtml | 2 +- public/css/icinga/layout-structure.less | 6 +----- public/css/icinga/login.less | 15 +++------------ public/css/icinga/logo.less | 14 ++++++++++++++ 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/application/views/scripts/authentication/login.phtml b/application/views/scripts/authentication/login.phtml index 34a631778..7ae88584b 100644 --- a/application/views/scripts/authentication/login.phtml +++ b/application/views/scripts/authentication/login.phtml @@ -4,7 +4,7 @@ -
+
-
+