Merge branch 'master' into feature/localization-form-6073

Conflicts:
	application/forms/Config/GeneralForm.php
	application/forms/Preference/GeneralForm.php
	library/Icinga/Application/Web.php
This commit is contained in:
Alexander Fuhr 2014-11-05 13:27:45 +01:00
commit 2e24c53224
770 changed files with 27860 additions and 30386 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
.git* export-ignore

9
.gitignore vendored
View File

@ -10,7 +10,8 @@
!.gitkeep !.gitkeep
build/ build/
test/js/npm-debug.log
development/
# ./configure output # ./configure output
config.log config.log
@ -20,10 +21,9 @@ config.status
Makefile Makefile
# cmd tester # cmd tester
test/php/bin/extcmd_test modules/test/bin/extcmd_test
# misc test output # misc test output
test/frontend/static/public
test/php/library/Icinga/Protocol/Statusdat/.cache test/php/library/Icinga/Protocol/Statusdat/.cache
# Generated API documentation # Generated API documentation
@ -38,6 +38,9 @@ config/preferences/*.ini
# Application logfiles # Application logfiles
var/log/*.log var/log/*.log
# Packaging
/debian /debian
*.tar.gz
*.komodoproject

View File

@ -1,6 +1,6 @@
object CheckCommand "dummy-host" { object CheckCommand "dummy-host" {
import "plugin-check-command" import "plugin-check-command"
command = [ PluginDir + "/libexec/test_hostcheck.pl" ] command = [ PluginDir + "/test_hostcheck.pl" ]
arguments = { arguments = {
"--type" = "$check_type$" "--type" = "$check_type$"
"--failchance" = "$check_failchance$" "--failchance" = "$check_failchance$"
@ -18,7 +18,7 @@ object CheckCommand "dummy-host" {
object CheckCommand "dummy-service" { object CheckCommand "dummy-service" {
import "plugin-check-command" import "plugin-check-command"
command = [ PluginDir + "/libexec/test_servicecheck.pl" ] command = [ PluginDir + "/test_servicecheck.pl" ]
arguments = { arguments = {
"--total-critical-on-host" = "$check_critical_on_host$" "--total-critical-on-host" = "$check_critical_on_host$"
"--total-warning-on-host" = "$check_warning_on_host$" "--total-warning-on-host" = "$check_warning_on_host$"
@ -76,7 +76,7 @@ __function createService(service_type, num) {
enable_active_checks = (service_type != "pending") enable_active_checks = (service_type != "pending")
vars.check_type = service_type vars.check_type = service_type
assign where match("*" + service_type + "*", host.vars.check_config) assign where service_type in host.vars.check_config
} }
} }
@ -102,12 +102,12 @@ __function createHost(checkType, checkConfig, num, checkEnabled) {
} }
__for (num in range(10)) { __for (num in range(10)) {
createHost("ok", "ok", num, true) createHost("ok", [ "ok" ], num, true)
createHost("random", "random,flapping", num, true) createHost("random", [ "random", "flapping" ], num, true)
createHost("down", "warning,critical", num, true) createHost("down", [ "warning", "critical" ], num, true)
createHost("unreachable", "unknown", num, true) createHost("unreachable", [ "unknown" ], num, true)
createHost("pending", "pending", num, false) createHost("pending", [ "pending" ], num, false)
createHost("flap", "flapping", num, true) createHost("flap", [ "flapping" ], num, true)
} }
// EOF // EOF

View File

@ -1,35 +0,0 @@
[Incidents]
title = "Current incidents"
[Incidents.Service Problems]
url = "monitoring/list/services"
service_problem = 1
limit = 10
sort = service_severity
[Incidents.Recently Recovered Services]
url = "monitoring/list/services"
sort = "service_last_state_change"
service_state = 0
limit = 10
dir = "desc"
[Incidents.Host Problems]
url = "monitoring/list/hosts"
host_problem = 1
sort = host_severity
[Landing]
title = "Landing page"
[Landing.Hostgroups]
url = "monitoring/chart/hostgroup?height=400&width=500"
[Landing.Servicegroups]
url = "monitoring/chart/servicegroup?height=360&width=450"
[Landing.Unhandled Problem Services]
url = "monitoring/list/services?service_handled=0&service_problem=1"
[Landing.Unhandled Problem Hosts]
url = "monitoring/list/hosts?host_handled=0&host_problem=1"

View File

@ -1,25 +0,0 @@
[Dashboard]
title = "Dashboard"
url = "dashboard"
icon = "img/icons/dashboard.png"
priority = 10
[System]
icon = img/icons/configuration.png
priority = 200
[System.Preferences]
title = "Preferences"
url = "preference"
priority = 200
[System.Configuration]
title = "Configuration"
url = "config"
priority = 300
[Logout]
url = "authentication/logout"
icon = img/icons/logout.png
priority = 300

View File

@ -1,100 +0,0 @@
[Problems]
priority = 20
icon = "img/icons/error.png"
[Problems.Unhandled Hosts]
priority = 40
url = "monitoring/list/hosts?host_problem=1&host_handled=0"
[Problems.Unhandled Services]
priority = 40
url = "monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity"
[Problems.Host Problems]
priority = 50
url = "monitoring/list/hosts?host_problem=1&sort=host_severity"
[Problems.Service Problems]
priority = 50
url = "monitoring/list/services?service_problem=1&sort=service_severity&dir=desc"
[Problems.Current Downtimes]
url = "monitoring/list/downtimes?downtime_is_in_effect=1"
[Overview]
priority = 30
icon = "img/icons/hostgroup.png"
[Overview.Tactical Overview]
title = "Tactical Overview"
url = "monitoring/tactical"
priority = 40
[Overview.Hosts]
title = "Hosts"
url = "monitoring/list/hosts"
priority = 50
[Overview.Services]
title = "Services"
url = "monitoring/list/services"
priority = 50
[Overview.Servicematrix]
title = "Servicematrix"
url = "monitoring/list/servicematrix?service_problem=1"
priority = 51
[Overview.Servicegroups]
title = "Servicegroups"
url = "monitoring/list/servicegroups"
priority = 60
[Overview.Hostgroups]
title = "Hostgroups"
url = "monitoring/list/hostgroups"
priority = 60
[Overview.Contactgroups]
title = "Contactgroups"
url = "monitoring/list/contactgroups"
priority = 61
[Overview.Downtimes]
title = "Downtimes"
url = "monitoring/list/downtimes"
priority = 70
[Overview.Comments]
title = "Comments"
url = "monitoring/list/comments"
priority = 70
[History]
icon = "img/icons/history.png"
[History.Critical Events]
title = "Critical Events"
url = "monitoring/list/statehistorysummary"
priority = 50
[History.Notifications]
title = "Notifications"
url = "monitoring/list/notifications"
[History.Events]
title = "All Events"
url = "monitoring/list/eventhistory?timestamp>=-7%20days"
[System.Process Info]
title = "Process Info"
url = "monitoring/process/info"
priority = 120
[System.Performance Info]
title = "Performance Info"
url = "monitoring/process/performance"
priority = 130

View File

@ -1,3 +1,5 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
include '/vagrant/library/Icinga/Application/webrouter.php'; include '/vagrant/library/Icinga/Application/webrouter.php';

View File

@ -3,10 +3,14 @@ include mysql
include pgsql include pgsql
include openldap include openldap
Exec { path => '/bin:/usr/bin:/sbin' } Exec { path => '/bin:/usr/bin:/sbin:/usr/sbin' }
$icingaVersion = '1.11.2' $icingaVersion = '1.11.5'
$icinga2Version = '2.0.0' $icinga2Version = '2.0.1'
$pluginVersion = '2.0'
$livestatusVersion = '1.2.4p5'
$phantomjsVersion = '1.9.1'
$casperjsVersion = '1.0.2'
exec { 'create-mysql-icinga-db': exec { 'create-mysql-icinga-db':
unless => 'mysql -uicinga -picinga icinga', unless => 'mysql -uicinga -picinga icinga',
@ -72,10 +76,10 @@ cmmi { 'icinga-mysql':
--with-htmurl=/icinga-mysql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-mysql.conf \ --with-htmurl=/icinga-mysql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-mysql.conf \
--with-cgiurl=/icinga-mysql/cgi-bin \ --with-cgiurl=/icinga-mysql/cgi-bin \
--with-http-auth-file=/usr/share/icinga/htpasswd.users \ --with-http-auth-file=/usr/share/icinga/htpasswd.users \
--with-plugin-dir=/usr/lib64/nagios/plugins/libexec', --with-plugin-dir=/usr/lib64/nagios/plugins',
creates => '/usr/local/icinga-mysql', creates => '/usr/local/icinga-mysql',
make => 'make all && make fullinstall install-config', make => 'make all && make fullinstall install-config',
require => [ User['icinga'], Cmmi['icinga-plugins'], Package['apache'] ], require => [ User['icinga'], Class['monitoring-plugins'], Package['apache'] ],
notify => Service['apache'] notify => Service['apache']
} }
@ -98,10 +102,10 @@ cmmi { 'icinga-pgsql':
--with-htmurl=/icinga-pgsql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-pgsql.conf \ --with-htmurl=/icinga-pgsql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-pgsql.conf \
--with-cgiurl=/icinga-pgsql/cgi-bin \ --with-cgiurl=/icinga-pgsql/cgi-bin \
--with-http-auth-file=/usr/share/icinga/htpasswd.users \ --with-http-auth-file=/usr/share/icinga/htpasswd.users \
--with-plugin-dir=/usr/lib64/nagios/plugins/libexec', --with-plugin-dir=/usr/lib64/nagios/plugins',
creates => '/usr/local/icinga-pgsql', creates => '/usr/local/icinga-pgsql',
make => 'make all && make fullinstall install-config', make => 'make all && make fullinstall install-config',
require => [ User['icinga'], Cmmi['icinga-plugins'], Package['apache'] ], require => [ User['icinga'], Class['monitoring-plugins'], Package['apache'] ],
notify => Service['apache'] notify => Service['apache']
} }
@ -202,24 +206,15 @@ exec { 'iptables-allow-http':
exec { 'icinga-htpasswd': exec { 'icinga-htpasswd':
creates => '/usr/share/icinga/htpasswd.users', creates => '/usr/share/icinga/htpasswd.users',
command => 'mkdir /usr/share/icinga && htpasswd -b -c /usr/share/icinga/htpasswd.users icingaadmin icinga', command => 'mkdir -p /usr/share/icinga && htpasswd -b -c /usr/share/icinga/htpasswd.users icingaadmin icinga',
require => Class['apache'] require => Class['apache']
} }
cmmi { 'icinga-plugins': include monitoring-plugins
url => 'https://www.monitoring-plugins.org/download/nagios-plugins-1.5.tar.gz',
output => 'nagios-plugins-1.5.tar.gz',
flags => '--prefix=/usr/lib64/nagios/plugins \
--with-nagios-user=icinga --with-nagios-group=icinga \
--with-cgiurl=/icinga-mysql/cgi-bin',
creates => '/usr/lib64/nagios/plugins/libexec',
make => 'make && make install',
require => User['icinga']
}
cmmi { 'mk-livestatus': cmmi { 'mk-livestatus':
url => 'http://mathias-kettner.de/download/mk-livestatus-1.2.2p1.tar.gz', url => "http://mathias-kettner.de/download/mk-livestatus-${livestatusVersion}.tar.gz",
output => 'mk-livestatus-1.2.2p1.tar.gz', output => "mk-livestatus-${livestatusVersion}.tar.gz",
flags => '--prefix=/usr/local/icinga-mysql --exec-prefix=/usr/local/icinga-mysql', flags => '--prefix=/usr/local/icinga-mysql --exec-prefix=/usr/local/icinga-mysql',
creates => '/usr/local/icinga-mysql/lib/mk-livestatus', creates => '/usr/local/icinga-mysql/lib/mk-livestatus',
make => 'make && make install', make => 'make && make install',
@ -262,14 +257,14 @@ exec { 'populate-openldap':
} }
class { 'phantomjs': class { 'phantomjs':
url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2', url => "https://phantomjs.googlecode.com/files/phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2",
output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2', output => "phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2",
creates => '/usr/local/phantomjs' creates => '/usr/local/phantomjs'
} }
class { 'casperjs': class { 'casperjs':
url => 'https://github.com/n1k0/casperjs/tarball/1.0.2', url => "https://github.com/n1k0/casperjs/tarball/${casperjsVersion}",
output => 'casperjs-1.0.2.tar.gz', output => "casperjs-${casperjsVersion}.tar.gz",
creates => '/usr/local/casperjs' creates => '/usr/local/casperjs'
} }
@ -421,11 +416,10 @@ package { 'icinga2-ido-mysql':
exec { 'populate-icinga2-mysql-db': exec { 'populate-icinga2-mysql-db':
unless => 'mysql -uicinga2 -picinga2 icinga2 -e "SELECT * FROM icinga_dbversion;" &> /dev/null', unless => 'mysql -uicinga2 -picinga2 icinga2 -e "SELECT * FROM icinga_dbversion;" &> /dev/null',
command => "mysql -uroot icinga2 < /usr/share/doc/icinga2-ido-mysql-$icinga2Version/schema/mysql.sql", command => 'mysql -uroot icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql',
require => [ Exec['create-mysql-icinga2-db'], Package['icinga2-ido-mysql'] ] require => [ Exec['create-mysql-icinga2-db'], Package['icinga2-ido-mysql'] ]
} }
file { '/etc/icinga2/features-available/ido-mysql.conf': file { '/etc/icinga2/features-available/ido-mysql.conf':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf', source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf',
owner => 'icinga', owner => 'icinga',
@ -574,7 +568,7 @@ populate_monitoring_test_config { ['commands', 'contacts', 'dependencies',
} }
define populate_monitoring_test_config_plugins { define populate_monitoring_test_config_plugins {
file { "/usr/lib64/nagios/plugins/libexec/${name}": file { "/usr/lib64/nagios/plugins/${name}":
owner => 'icinga', owner => 'icinga',
group => 'icinga', group => 'icinga',
source => "/usr/local/share/misc/monitoring_test_config/plugins/${name}", source => "/usr/local/share/misc/monitoring_test_config/plugins/${name}",
@ -702,6 +696,13 @@ file { '/etc/icingaweb':
group => 'apache' group => 'apache'
} }
file { '/etc/icingaweb/preferences':
ensure => 'directory',
owner => 'apache',
group => 'apache',
require => File['/etc/icingaweb']
}
file { '/etc/icingaweb/authentication.ini': file { '/etc/icingaweb/authentication.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/authentication.ini', source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/authentication.ini',
owner => 'apache', owner => 'apache',
@ -715,13 +716,6 @@ file { '/etc/icingaweb/config.ini':
group => 'apache', group => 'apache',
} }
file { '/etc/icingaweb/menu.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/menu.ini',
owner => 'apache',
group => 'apache',
# replace => false,
}
file { '/etc/icingaweb/resources.ini': file { '/etc/icingaweb/resources.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/resources.ini', source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/resources.ini',
owner => 'apache', owner => 'apache',
@ -741,30 +735,18 @@ file { '/etc/icingaweb/modules/monitoring/backends.ini':
group => 'apache', group => 'apache',
} }
file { '/etc/icingaweb/modules/monitoring/config.ini':
source => 'puppet:////vagrant/config/modules/monitoring/config.ini',
owner => 'apache',
group => 'apache',
}
file { '/etc/icingaweb/modules/monitoring/instances.ini': file { '/etc/icingaweb/modules/monitoring/instances.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini', source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini',
owner => 'apache', owner => 'apache',
group => 'apache', group => 'apache',
} }
file { '/etc/icingaweb/modules/monitoring/menu.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/menu.ini',
owner => 'apache',
group => 'apache',
}
file { '/etc/icingaweb/dashboard':
ensure => 'directory',
owner => 'apache',
group => 'apache',
}
file { '/etc/icingaweb/dashboard/dashboard.ini':
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/dashboard/dashboard.ini',
owner => 'apache',
group => 'apache',
}
# pear::package { 'deepend/Mockery': # pear::package { 'deepend/Mockery':
# channel => 'pear.survivethedeepend.com' # channel => 'pear.survivethedeepend.com'
# } # }
@ -791,4 +773,3 @@ file { '/etc/bash_completion.d/icingacli':
mode => 755, mode => 755,
require => Exec['install bash-completion'] require => Exec['install bash-completion']
} }

View File

@ -40,7 +40,7 @@ class casperjs(
require => Class['wget'] require => Class['wget']
} }
$tld = inline_template('<%= File.basename(output, ".tar.bz2") %>') $tld = inline_template('<%= File.basename(@output, ".tar.bz2") %>')
$src = "${cwd}/casperjs" $src = "${cwd}/casperjs"
exec { 'extract-casperjs': exec { 'extract-casperjs':

View File

@ -51,7 +51,7 @@ define cmmi(
require => Class['wget'] require => Class['wget']
} }
$tld = inline_template('<%= File.basename(output, ".tar.gz") %>') $tld = inline_template('<%= File.basename(@output, ".tar.gz") %>')
$src = "${cwd}/${name}/${tld}" $src = "${cwd}/${name}/${tld}"
exec { "extract-${name}": exec { "extract-${name}":

View File

@ -0,0 +1,9 @@
class monitoring-plugins {
include epel
# nagios plugins from epel
package { 'nagios-plugins-all':
ensure => installed,
require => Class['epel']
}
}

View File

@ -32,8 +32,8 @@ install: install-config install-basic ensure-writable-folders install-cli
# #
install-cli: install-cli:
$(INSTALL) -m 755 -d $(INSTALL_OPTS) $(bindir) $(INSTALL) -m 755 -d $(INSTALL_OPTS) $(bindir)
$(INSTALL) -m 755 $(INSTALL_OPTS) "./bin/icingacli" $(bindir)/icingacli; $(INSTALL) -m 755 $(INSTALL_OPTS) "./bin/icingacli" $(bindir)/icingacli;
# #
# Installs the whole application w\o configuration # Installs the whole application w\o configuration

View File

@ -2,13 +2,59 @@
## Table of Contents ## Table of Contents
1. [Vagrant - Virtual development environment](#vagrant) 0. [General Information](#general information)
1. [Installation](#installation)
2. [Support](#support)
3. [Vagrant - Virtual development environment](#vagrant)
## General Information
`Icinga Web 2` is the next generation monitoring web interface, framework
and CLI tool developed by the [Icinga Project](https://www.icinga.org/community/team/).
Responsive and fast, rewritten from scratch supporting multiple backends and
providing a CLI tool. Compatible with Icinga Core 2.x and 1.x.
Check the Icinga website for some [insights](https://www.icinga.org/icinga/screenshots/icinga-web-2/).
> **Note**
>
> `Icinga Web 2` is still in development and not meant for production deployment.
> Watch the [development roadmap](https://dev.icinga.org/projects/icingaweb2/roadmap)
> and [Icinga website](https://www.icinga.org/) for release schedule updates!
## Installation
Please navigate to [doc/installation.md](doc/installation.md) for updated details.
## Support
Please head over to the [community support channels](https://www.icinga.org/icinga/faq/get-help/)
in case of questions, bugs, etc.
Please make sure to provide the following details:
* OS, distribution, version
* PHP and/or MySQL/PostgreSQL version
* Which browser and its version
* Screenshot and problem description
## Vagrant ## Vagrant
> **Note** that the deployment of the virtual machine is tested against Vagrant starting with version 1.1. ### Requirements
* Vagrant 1.2+
* Virtualbox 4.2.16+
* a fairly powerful hardware (quad core, 4gb ram, fast hdd)
> **Note**
>
> The deployment of the virtual machine is tested against Vagrant starting with version 1.2.
> Unfortunately older versions will not work. > Unfortunately older versions will not work.
### General
The Icinga Web 2 project ships with a Vagrant virtual machine that integrates The Icinga Web 2 project ships with a Vagrant virtual machine that integrates
the source code with various services and example data in a controlled the source code with various services and example data in a controlled
environment. This enables developers and users to test Livestatus, status.dat, environment. This enables developers and users to test Livestatus, status.dat,
@ -17,7 +63,9 @@ have to do is install Vagrant and run:
vagrant up vagrant up
> **Note** that the first boot of the vm takes a fairly long time because > **Note**
>
> The first boot of the vm takes a fairly long time because
> you'll download a plain CentOS base box and Vagrant will automatically > you'll download a plain CentOS base box and Vagrant will automatically
> provision the environment on the first go. > provision the environment on the first go.
@ -68,7 +116,7 @@ After you should be able to browse [localhost:8080/icingaweb](http://localhost:8
**Installed files**: **Installed files**:
* `/usr/share/icinga/htpasswd.users` account information for logging into the Icinga classic web interface for both icinga instances * `/usr/share/icinga/htpasswd.users` account information for logging into the Icinga classic web interface for both icinga instances
* `/usr/lib64/nagios/plugins` Nagios Plugins for both icinga instances * `/usr/lib64/nagios/plugins` Monitoring Plugins for all Icinga instances
#### Icinga with IDOUtils using a MySQL database #### Icinga with IDOUtils using a MySQL database
@ -196,12 +244,13 @@ code style issues.
#### Icinga 2 #### Icinga 2
**Installation path**: `/usr/local/icinga2` Installed from the Icinga [snapshot package repository](http://packages.icinga.org/epel/).
The configuration is located in `/etc/icinga2`.
**Example usage**: **Example usage**:
cd /usr/local/icinga2 /etc/init.d/icinga2 (start|stop|restart|reload)
./sbin/icinga2 -c etc/icinga2/icinga2.conf.dist
## Log into Icinga Web 2 ## Log into Icinga Web 2
@ -211,3 +260,9 @@ If you've configure LDAP as authentication backend (which is the default) use th
> **Password**: password > **Password**: password
Have a look at [LDAP example data](#ldap example data) for more accounts. Have a look at [LDAP example data](#ldap example data) for more accounts.
Using MySQL as backend:
> **Username**: icingaadmin
> **Password**: icinga

View File

@ -1,5 +1,6 @@
<?php <?php
// @codeCoverageIgnoreStart // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Clicommands; namespace Icinga\Clicommands;
@ -118,4 +119,3 @@ class AutocompleteCommand extends Command
} }
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,5 +1,6 @@
<?php <?php
// @codeCoverageIgnoreStart // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Clicommands; namespace Icinga\Clicommands;
@ -41,4 +42,3 @@ class HelpCommand extends Command
); );
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,5 +1,6 @@
<?php <?php
// @codeCoverageIgnoreStart // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Clicommands; namespace Icinga\Clicommands;
@ -212,4 +213,3 @@ class ModuleCommand extends Command
$this->fail("Not implemented yet"); $this->fail("Not implemented yet");
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,10 +1,11 @@
<?php <?php
// @codeCoverageIgnoreStart // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Clicommands; namespace Icinga\Clicommands;
use Icinga\Cli\Command; use Icinga\Cli\Command;
use Exception; use Icinga\Exception\IcingaException;
class WebCommand extends Command class WebCommand extends Command
{ {
@ -12,11 +13,11 @@ class WebCommand extends Command
{ {
$minVersion = '5.4.0'; $minVersion = '5.4.0';
if (version_compare(PHP_VERSION, $minVersion) < 0) { if (version_compare(PHP_VERSION, $minVersion) < 0) {
throw new Exception(sprintf( throw new IcingaException(
'You are running PHP %s, internal webserver requires %s.', 'You are running PHP %s, internal webserver requires %s.',
PHP_VERSION, PHP_VERSION,
$minVersion $minVersion
)); );
} }
$fork = $this->params->get('daemonize'); $fork = $this->params->get('daemonize');
@ -26,12 +27,12 @@ class WebCommand extends Command
// TODO: Sanity check!! // TODO: Sanity check!!
if ($socket === null) { if ($socket === null) {
$socket = '0.0.0.0:80'; $socket = '0.0.0.0:80';
// throw new Exception('Socket is required'); // throw new IcingaException('Socket is required');
} }
if ($basedir === null) { if ($basedir === null) {
$basedir = dirname(ICINGAWEB_APPDIR) . '/public'; $basedir = dirname(ICINGAWEB_APPDIR) . '/public';
if (! file_exists($basedir) || ! is_dir($basedir)) { if (! file_exists($basedir) || ! is_dir($basedir)) {
throw new Exception('Basedir is required'); throw new IcingaException('Basedir is required');
} }
} }
$basedir = realpath($basedir); $basedir = realpath($basedir);
@ -67,7 +68,7 @@ class WebCommand extends Command
{ {
$pid = pcntl_fork(); $pid = pcntl_fork();
if ($pid == -1) { if ($pid == -1) {
throw new Exception('Could not fork'); throw new IcingaException('Could not fork');
} else if ($pid) { } else if ($pid) {
echo $this->screen->colorize('[OK]') echo $this->screen->colorize('[OK]')
. " Icinga Web server forked successfully\n"; . " Icinga Web server forked successfully\n";
@ -81,4 +82,3 @@ class WebCommand extends Command
} }
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,31 +1,5 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
# namespace Icinga\Application\Controllers; # namespace Icinga\Application\Controllers;
@ -35,7 +9,7 @@ use Icinga\Web\Controller\ActionController;
use Icinga\Form\Authentication\LoginForm; use Icinga\Form\Authentication\LoginForm;
use Icinga\Authentication\AuthChain; use Icinga\Authentication\AuthChain;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Logger\Logger; use Icinga\Application\Logger;
use Icinga\Exception\AuthenticationException; use Icinga\Exception\AuthenticationException;
use Icinga\Exception\NotReadableError; use Icinga\Exception\NotReadableError;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
@ -60,12 +34,16 @@ class AuthenticationController extends ActionController
public function loginAction() public function loginAction()
{ {
$auth = $this->Auth(); $auth = $this->Auth();
$this->view->form = new LoginForm(); $this->view->form = $form = new LoginForm();
$this->view->form->setRequest($this->_request);
$this->view->title = $this->translate('Icingaweb Login'); $this->view->title = $this->translate('Icingaweb Login');
try { try {
$redirectUrl = Url::fromPath($this->params->get('redirect', 'dashboard')); $redirectUrl = $this->view->form->getValue('redirect');
if ($redirectUrl) {
$redirectUrl = Url::fromPath($redirectUrl);
} else {
$redirectUrl = Url::fromPath('dashboard');
}
if ($auth->isAuthenticated()) { if ($auth->isAuthenticated()) {
$this->rerenderLayout()->redirectNow($redirectUrl); $this->rerenderLayout()->redirectNow($redirectUrl);
@ -74,35 +52,29 @@ class AuthenticationController extends ActionController
try { try {
$config = Config::app('authentication'); $config = Config::app('authentication');
} catch (NotReadableError $e) { } catch (NotReadableError $e) {
Logger::error(
new Exception('Cannot load authentication configuration. An exception was thrown:', 0, $e)
);
throw new ConfigurationError( throw new ConfigurationError(
'No authentication methods available. It seems that none authentication method has been set' $this->translate('Could not read your authentiction.ini, no authentication methods are available.'),
. ' up. Please check the system log or Icinga Web 2 log for more information' 0,
$e
); );
} }
$chain = new AuthChain($config); $chain = new AuthChain($config);
$request = $this->getRequest();
if ($request->isPost() && $this->view->form->isValid($request->getPost())) {
if ($this->getRequest()->isGet()) {
$user = new User('');
foreach ($chain as $backend) {
if ($backend instanceof AutoLoginBackend) {
$authenticated = $backend->authenticate($user);
if ($authenticated === true) {
$auth->setAuthenticated($user);
$this->rerenderLayout()->redirectNow($redirectUrl);
}
}
}
} elseif ($this->view->form->isSubmittedAndValid()) {
$user = new User($this->view->form->getValue('username')); $user = new User($this->view->form->getValue('username'));
$password = $this->view->form->getValue('password'); $password = $this->view->form->getValue('password');
$backendsTried = 0; $backendsTried = 0;
$backendsWithError = 0; $backendsWithError = 0;
$redirectUrl = $form->getValue('redirect');
if ($redirectUrl) {
$redirectUrl = Url::fromPath($redirectUrl);
} else {
$redirectUrl = Url::fromPath('dashboard');
}
foreach ($chain as $backend) { foreach ($chain as $backend) {
if ($backend instanceof AutoLoginBackend) { if ($backend instanceof AutoLoginBackend) {
continue; continue;
@ -120,23 +92,44 @@ class AuthenticationController extends ActionController
$this->rerenderLayout()->redirectNow($redirectUrl); $this->rerenderLayout()->redirectNow($redirectUrl);
} }
} }
if ($backendsWithError === $backendsTried) { if ($backendsTried === 0) {
throw new ConfigurationError( throw new ConfigurationError(
$this->translate( $this->translate(
'No authentication methods available. It seems that all set up authentication methods have' 'No authentication methods available. Did you create'
. ' errors. Please check the system log or Icinga Web 2 log for more information' . ' authentication.ini when installing Icinga Web 2?'
)
);
}
if ($backendsTried === $backendsWithError) {
throw new ConfigurationError(
$this->translate(
'All configured authentication methods failed.'
. ' Please check the system log or Icinga Web 2 log for more information.'
) )
); );
} }
if ($backendsWithError) { if ($backendsWithError) {
$this->view->form->addNote( $this->view->form->getElement('username')->addError(
$this->translate( $this->translate(
'Note that not all authentication backends are available for authentication because they' 'Please note that not all authentication methods were available.'
. ' have errors. Please check the system log or Icinga Web 2 log for more information' . ' Check the system log or Icinga Web 2 log for more information.'
) )
); );
} }
$this->view->form->getElement('password')->addError($this->translate('Incorrect username or password')); $this->view->form->getElement('password')->addError($this->translate('Incorrect username or password'));
} elseif ($request->isGet()) {
$user = new User('');
foreach ($chain as $backend) {
if ($backend instanceof AutoLoginBackend) {
$authenticated = $backend->authenticate($user);
if ($authenticated === true) {
$auth->setAuthenticated($user);
$this->rerenderLayout()->redirectNow(
Url::fromPath(Url::fromRequest()->getParam('redirect', 'dashboard'))
);
}
}
}
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->view->errorInfo = $e->getMessage(); $this->view->errorInfo = $e->getMessage();
@ -149,14 +142,15 @@ class AuthenticationController extends ActionController
public function logoutAction() public function logoutAction()
{ {
$auth = $this->Auth(); $auth = $this->Auth();
if (! $auth->isAuthenticated()) {
$this->redirectToLogin();
}
$isRemoteUser = $auth->getUser()->isRemoteUser();
$auth->removeAuthorization(); $auth->removeAuthorization();
if ($isRemoteUser === true) {
if ($auth->isAuthenticatedFromRemoteUser()) {
$this->_helper->layout->setLayout('login');
$this->_response->setHttpResponseCode(401); $this->_response->setHttpResponseCode(401);
} else { } else {
$this->rerenderLayout()->redirectToLogin(); $this->redirectToLogin();
} }
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,64 +1,26 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\BaseConfigController; use Icinga\Web\Controller\ActionController;
use Icinga\Web\Widget\Tab;
use Icinga\Web\Widget\AlertMessageBox;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Application\Modules\Module; use Icinga\Application\Modules\Module;
use Icinga\Web\Url;
use Icinga\Web\Widget; use Icinga\Web\Widget;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Application\Config as IcingaConfig; use Icinga\Application\Config as IcingaConfig;
use Icinga\Form\Config\GeneralConfigForm;
use Icinga\Form\Config\AuthenticationBackendReorderForm;
use Icinga\Form\Config\AuthenticationBackendConfigForm;
use Icinga\Form\Config\ResourceConfigForm;
use Icinga\Form\ConfirmRemovalForm;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Form\Config\GeneralForm;
use Icinga\Form\Config\Authentication\ReorderForm;
use Icinga\Form\Config\Authentication\LdapBackendForm;
use Icinga\Form\Config\Authentication\DbBackendForm;
use Icinga\Form\Config\ResourceForm;
use Icinga\Form\Config\LoggingForm;
use Icinga\Form\Config\ConfirmRemovalForm;
use Icinga\Config\PreservingIniWriter;
/** /**
* Application wide controller for application preferences * Application wide controller for application preferences
*/ */
class ConfigController extends BaseConfigController class ConfigController extends ActionController
{ {
/**
* The resource types that are available.
*
* @var array
*/
private $resourceTypes = array('livestatus', 'ido', 'statusdat', 'ldap');
public function init() public function init()
{ {
$this->view->tabs = Widget::create('tabs')->add('index', array( $this->view->tabs = Widget::create('tabs')->add('index', array(
@ -70,56 +32,25 @@ class ConfigController extends BaseConfigController
))->add('resources', array( ))->add('resources', array(
'title' => 'Resources', 'title' => 'Resources',
'url' => 'config/resource' 'url' => 'config/resource'
))->add('logging', array(
'title' => 'Logging',
'url' => 'config/logging'
))->add('modules', array(
'title' => 'Modules',
'url' => 'config/modules'
)); ));
} }
public function devtoolsAction()
{
$this->view->tabs = null;
}
/** /**
* Index action, entry point for configuration * Index action, entry point for configuration
*/ */
public function indexAction() public function indexAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new GeneralConfigForm();
$form->setIniConfig(IcingaConfig::app());
$form->handleRequest();
$this->view->form = $form;
$this->view->tabs->activate('index'); $this->view->tabs->activate('index');
$form = new GeneralForm();
$form->setConfiguration(IcingaConfig::app());
$form->setRequest($this->_request);
if ($form->isSubmittedAndValid()) {
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
return;
}
Notification::success('New configuration has successfully been stored');
$form->setConfiguration(IcingaConfig::app(), true);
$this->redirectNow('config/index');
}
$this->view->form = $form;
}
/**
* Form for modifying the logging configuration
*/
public function loggingAction()
{
$this->view->messageBox = new AlertMessageBox(true);
$this->view->tabs->activate('logging');
$form = new LoggingForm();
$form->setConfiguration(IcingaConfig::app());
$form->setRequest($this->_request);
if ($form->isSubmittedAndValid()) {
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
return;
}
Notification::success('New configuration has sucessfully been stored');
$form->setConfiguration(IcingaConfig::app(), true);
$this->redirectNow('config/logging');
}
$this->view->form = $form;
} }
/** /**
@ -127,6 +58,11 @@ class ConfigController extends BaseConfigController
*/ */
public function modulesAction() public function modulesAction()
{ {
$this->view->tabs = Widget::create('tabs')->add('modules', array(
'title' => 'Modules',
'url' => 'config/modules'
));
$this->view->tabs->activate('modules'); $this->view->tabs->activate('modules');
$this->view->modules = Icinga::app()->getModuleManager()->select() $this->view->modules = Icinga::app()->getModuleManager()->select()
->from('modules') ->from('modules')
@ -160,7 +96,7 @@ class ConfigController extends BaseConfigController
try { try {
$manager->enableModule($module); $manager->enableModule($module);
$manager->loadModule($module); $manager->loadModule($module);
Notification::success('Module "' . $module . '" enabled'); Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules'); $this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
} catch (Exception $e) { } catch (Exception $e) {
$this->view->exceptionMesssage = $e->getMessage(); $this->view->exceptionMesssage = $e->getMessage();
@ -179,7 +115,7 @@ class ConfigController extends BaseConfigController
$manager = Icinga::app()->getModuleManager(); $manager = Icinga::app()->getModuleManager();
try { try {
$manager->disableModule($module); $manager->disableModule($module);
Notification::success('Module "' . $module . '" disabled'); Notification::success(sprintf($this->translate('Module "%s" disabled'), $module));
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules'); $this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
} catch (Exception $e) { } catch (Exception $e) {
$this->view->exceptionMessage = $e->getMessage(); $this->view->exceptionMessage = $e->getMessage();
@ -190,40 +126,17 @@ class ConfigController extends BaseConfigController
} }
/** /**
* Action for creating a new authentication backend * Action for listing and reordering authentication backends
*/ */
public function authenticationAction() public function authenticationAction()
{ {
$config = IcingaConfig::app('authentication', true); $form = new AuthenticationBackendReorderForm();
$form->setIniConfig(IcingaConfig::app('authentication'));
$form->handleRequest();
$this->view->form = $form;
$this->view->tabs->activate('authentication'); $this->view->tabs->activate('authentication');
$this->render('authentication/reorder');
$order = array_keys($config->toArray());
$this->view->messageBox = new AlertMessageBox(true);
$backends = array();
foreach ($order as $backend) {
$form = new ReorderForm();
$form->setName('form_reorder_backend_' . $backend);
$form->setBackendName($backend);
$form->setCurrentOrder($order);
$form->setRequest($this->_request);
if ($form->isSubmittedAndValid()) {
if ($this->writeAuthenticationFile($form->getReorderedConfig($config))) {
Notification::success('Authentication Order Updated');
$this->redirectNow('config/authentication');
}
return;
}
$backends[] = (object) array(
'name' => $backend,
'reorderForm' => $form
);
}
$this->view->backends = $backends;
} }
/** /**
@ -231,317 +144,151 @@ class ConfigController extends BaseConfigController
*/ */
public function createauthenticationbackendAction() public function createauthenticationbackendAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new AuthenticationBackendConfigForm();
$form->setIniConfig(IcingaConfig::app('authentication'));
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
$form->setRedirectUrl('config/authentication');
$form->handleRequest();
if ($this->getRequest()->getParam('type') === 'ldap') {
$form = new LdapBackendForm();
} else {
$form = new DbBackendForm();
}
if ($this->getParam('auth_backend')) {
$form->setBackendName($this->getParam('auth_backend'));
}
$form->setRequest($this->getRequest());
if ($form->isSubmittedAndValid()) {
$backendCfg = IcingaConfig::app('authentication')->toArray();
foreach ($backendCfg as $backendName => $settings) {
unset($backendCfg[$backendName]['name']);
}
foreach ($form->getConfig() as $backendName => $settings) {
unset($settings->{'name'});
if (isset($backendCfg[$backendName])) {
$this->addErrorMessage('Backend name already exists');
$this->view->form = $form;
$this->render('authentication/create');
return;
}
$backendCfg[$backendName] = $settings;
}
if ($this->writeAuthenticationFile($backendCfg)) {
// redirect to overview with success message
Notification::success('Backend Modification Written.');
$this->redirectNow("config/authentication");
}
return;
}
$this->view->messageBox->addForm($form);
$this->view->form = $form; $this->view->form = $form;
$this->view->tabs->activate('authentication');
$this->render('authentication/create'); $this->render('authentication/create');
} }
/** /**
* Form for editing backends * Action for editing authentication backends
*
* Mostly the same like the createAuthenticationBackendAction, but with additional checks for backend existence
* and form population
*/ */
public function editauthenticationbackendAction() public function editauthenticationbackendAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new AuthenticationBackendConfigForm();
$form->setIniConfig(IcingaConfig::app('authentication'));
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
$form->setRedirectUrl('config/authentication');
$form->handleRequest();
$configArray = IcingaConfig::app('authentication', true)->toArray();
$authBackend = $this->getParam('auth_backend');
if (!isset($configArray[$authBackend])) {
$this->addErrorMessage('Can\'t edit: Unknown Authentication Backend Provided');
$this->configurationerrorAction();
return;
}
if (!array_key_exists('resource', $configArray[$authBackend])) {
$this->addErrorMessage('Configuration error: Backend "' . $authBackend . '" has no Resource');
$this->configurationerrorAction();
return;
}
$type = ResourceFactory::getResourceConfig($configArray[$authBackend]['resource'])->type;
switch ($type) {
case 'ldap':
$form = new LdapBackendForm();
break;
case 'db':
$form = new DbBackendForm();
break;
default:
$this->addErrorMessage('Can\'t edit: backend type "' . $type . '" of given resource not supported.');
$this->configurationerrorAction();
return;
}
$form->setBackendName($this->getParam('auth_backend'));
$form->setBackend(IcingaConfig::app('authentication', true)->$authBackend);
$form->setRequest($this->getRequest());
if ($form->isSubmittedAndValid()) {
$backendCfg = IcingaConfig::app('authentication')->toArray();
foreach ($form->getConfig() as $backendName => $settings) {
$backendCfg[$backendName] = $settings;
// Remove the old section if the backend is renamed
if ($backendName != $authBackend) {
unset($backendCfg[$authBackend]);
}
unset($settings['name']);
}
if ($this->writeAuthenticationFile($backendCfg)) {
// redirect to overview with success message
Notification::success('Backend "' . $authBackend . '" created');
$this->redirectNow("config/authentication");
}
return;
}
$this->view->messageBox->addForm($form);
$this->view->name = $authBackend;
$this->view->form = $form; $this->view->form = $form;
$this->view->tabs->activate('authentication');
$this->render('authentication/modify'); $this->render('authentication/modify');
} }
/** /**
* Action for removing a backend from the authentication list. * Action for removing a backend from the authentication list
*
* Redirects to the overview after removal is finished
*/ */
public function removeauthenticationbackendAction() public function removeauthenticationbackendAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new ConfirmRemovalForm(array(
'onSuccess' => function ($request) {
$configForm = new AuthenticationBackendConfigForm();
$configForm->setIniConfig(IcingaConfig::app('authentication'));
$authBackend = $request->getQuery('auth_backend');
$configArray = IcingaConfig::app('authentication', true)->toArray(); try {
$authBackend = $this->getParam('auth_backend'); $configForm->remove($authBackend);
if (!isset($configArray[$authBackend])) { } catch (InvalidArgumentException $e) {
Notification::error('Can\'t perform removal: Unknown Authentication Backend Provided'); Notification::error($e->getMessage());
$this->render('authentication/remove'); return;
return; }
}
$form = new ConfirmRemovalForm(); if ($configForm->save()) {
$form->setRequest($this->getRequest()); Notification::success(sprintf(
$form->setRemoveTarget('auth_backend', $authBackend); t('Authentication backend "%s" has been successfully removed'),
$authBackend
if ($form->isSubmittedAndValid()) { ));
unset($configArray[$authBackend]); } else {
if ($this->writeAuthenticationFile($configArray)) { return false;
Notification::success('Authentication Backend "' . $authBackend . '" Removed'); }
$this->redirectNow("config/authentication");
} }
return; ));
} $form->setRedirectUrl('config/authentication');
$form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->view->name = $authBackend; $this->view->tabs->activate('authentication');
$this->render('authentication/remove'); $this->render('authentication/remove');
} }
public function resourceAction($showOnly = false) /**
* Display all available resources and a link to create a new one and to remove existing ones
*/
public function resourceAction()
{ {
$this->view->tabs->activate('resources');
$this->view->messageBox = new AlertMessageBox(true);
$this->view->resources = IcingaConfig::app('resources', true)->toArray(); $this->view->resources = IcingaConfig::app('resources', true)->toArray();
$this->render('resource'); $this->view->tabs->activate('resources');
} }
/**
* Display a form to create a new resource
*/
public function createresourceAction() public function createresourceAction()
{ {
$this->view->resourceTypes = $this->resourceTypes; $form = new ResourceConfigForm();
$resources = IcingaConfig::app('resources', true); $form->setIniConfig(IcingaConfig::app('resources'));
$form = new ResourceForm(); $form->setRedirectUrl('config/resource');
$form->setRequest($this->_request); $form->handleRequest();
if ($form->isSubmittedAndValid()) {
$name = $form->getName();
if (isset($resources->{$name})) {
$this->addErrorMessage('Resource name "' . $name .'" already in use.');
} else {
$resources->{$name} = $form->getConfig();
if ($this->writeConfigFile($resources, 'resources')) {
$this->addSuccessMessage('Resource "' . $name . '" created.');
$this->redirectNow("config/resource");
}
}
}
$this->view->messageBox = new AlertMessageBox(true);
$this->view->messageBox->addForm($form);
$this->view->form = $form; $this->view->form = $form;
$this->render('resource/create'); $this->render('resource/create');
} }
/**
* Display a form to edit a existing resource
*/
public function editresourceAction() public function editresourceAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new ResourceConfigForm();
$form->setIniConfig(IcingaConfig::app('resources'));
$form->setRedirectUrl('config/resource');
$form->handleRequest();
$resources = ResourceFactory::getResourceConfigs();
$name = $this->getParam('resource');
if ($resources->get($name) === null) {
$this->addErrorMessage('Can\'t edit: Unknown Resource Provided');
$this->render('resource/modify');
return;
}
$form = new ResourceForm();
if ($this->_request->isPost() === false) {
$form->setOldName($name);
$form->setName($name);
}
$form->setRequest($this->_request);
$form->setResource($resources->get($name));
if ($form->isSubmittedAndValid()) {
$oldName = $form->getOldName();
$name = $form->getName();
if ($oldName !== $name) {
unset($resources->{$oldName});
}
$resources->{$name} = $form->getConfig();
if ($this->writeConfigFile($resources, 'resources')) {
$this->addSuccessMessage('Resource "' . $name . '" edited.');
$this->redirectNow("config/resource");
}
return;
}
$this->view->messageBox->addForm($form);
$this->view->form = $form; $this->view->form = $form;
$this->view->name = $name;
$this->render('resource/modify'); $this->render('resource/modify');
} }
/**
* Display a confirmation form to remove a resource
*/
public function removeresourceAction() public function removeresourceAction()
{ {
$this->view->messageBox = new AlertMessageBox(true); $form = new ConfirmRemovalForm(array(
'onSuccess' => function ($request) {
$configForm = new ResourceConfigForm();
$configForm->setIniConfig(IcingaConfig::app('resources'));
$resource = $request->getQuery('resource');
$resources = ResourceFactory::getResourceConfigs()->toArray(); try {
$name = $this->getParam('resource'); $configForm->remove($resource);
if (!isset($resources[$name])) { } catch (InvalidArgumentException $e) {
$this->addSuccessMessage('Can\'t remove: Unknown resource provided'); Notification::error($e->getMessage());
$this->render('resource/remove'); return;
return; }
}
$form = new ConfirmRemovalForm(); if ($configForm->save()) {
$form->setRequest($this->getRequest()); Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource));
$form->setRemoveTarget('resource', $name); } else {
return false;
}
}
));
$form->setRedirectUrl('config/resource');
$form->handleRequest();
// Check if selected resource is currently used for authentication // Check if selected resource is currently used for authentication
$authConfig = IcingaConfig::app('authentication', true)->toArray(); $resource = $this->getRequest()->getQuery('resource');
$authConfig = IcingaConfig::app('authentication')->toArray();
foreach ($authConfig as $backendName => $config) { foreach ($authConfig as $backendName => $config) {
if (array_key_exists('resource', $config) && $config['resource'] === $name) { if (array_key_exists('resource', $config) && $config['resource'] === $resource) {
$this->addErrorMessage( $form->addError(sprintf(
'Warning: The resource "' . $name . '" is currently used for user authentication by "' . $backendName . '". ' . $this->translate(
' Deleting it could eventally make login impossible.' 'The resource "%s" is currently in use by the authentication backend "%s". ' .
); 'Removing the resource can result in noone being able to log in any longer.'
} ),
} $resource,
$backendName
if ($form->isSubmittedAndValid()) { ));
unset($resources[$name]);
if ($this->writeConfigFile($resources, 'resources')) {
$this->addSuccessMessage('Resource "' . $name . '" removed.');
$this->redirectNow('config/resource');
} }
return;
} }
$this->view->name = $name;
$this->view->form = $form; $this->view->form = $form;
$this->render('resource/remove'); $this->render('resource/remove');
} }
/**
* Redirect target only for error-states
*
* When an error is opened in the side-pane, redirecting this request to the index or the overview will look
* weird. This action returns a clear page containing only an AlertMessageBox.
*/
public function configurationerrorAction()
{
$this->view->messageBox = new AlertMessageBox(true);
$this->render('error/error', null, true);
}
/**
* Write changes to an authentication file
*
* @param array $config The configuration changes
*
* @return bool True when persisting succeeded, otherwise false
*
* @see writeConfigFile()
*/
private function writeAuthenticationFile($config) {
return $this->writeConfigFile($config, 'authentication');
}
/**
* Write changes to a configuration file $file, using the supplied writer or PreservingIniWriter if none is set
*
* @param array|Zend_Config $config The configuration to write
* @param string $file The filename to write to (without .ini)
* @param Zend_Config_Writer $writer An optional writer to use for persisting changes
*
* @return bool True when persisting succeeded, otherwise false
*/
private function writeConfigFile($config, $file, $writer = null)
{
if (is_array($config)) {
$config = new Zend_Config($config);
}
if ($writer === null) {
$writer = new PreservingIniWriter(
array(
'config' => $config,
'filename' => IcingaConfig::app($file)->getConfigFile()
)
);
}
try {
$writer->write();
return true;
} catch (Exception $exc) {
$this->view->exceptionMessage = $exc->getMessage();
$this->view->iniConfigurationString = $writer->render();
$this->view->file = $file;
$this->render('show-configuration');
return false;
}
}
} }
// @codeCoverageIgnoreEnd

View File

@ -1,43 +1,17 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Config; use Icinga\Application\Config;
use Icinga\Web\Url; use Icinga\Application\Logger;
use Icinga\Logger\Logger;
use Icinga\Config\PreservingIniWriter;
use Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Widget\Dashboard;
use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Exception\NotReadableError;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Exception\IcingaException;
use Icinga\Exception\NotReadableError;
use Icinga\File\Ini\IniWriter;
use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Web\Url;
use Icinga\Web\Widget\Dashboard;
/** /**
* Handle creation, removal and displaying of dashboards, panes and components * Handle creation, removal and displaying of dashboards, panes and components
@ -62,13 +36,13 @@ class DashboardController extends ActionController
{ {
$dashboard = new Dashboard(); $dashboard = new Dashboard();
try { try {
$dashboardConfig = IcingaConfig::app($config); $dashboardConfig = Config::app($config);
if (count($dashboardConfig) === 0) { if (count($dashboardConfig) === 0) {
return null; return null;
} }
$dashboard->readConfig($dashboardConfig); $dashboard->readConfig($dashboardConfig);
} catch (NotReadableError $e) { } catch (NotReadableError $e) {
Logger::error(new Exception('Cannot load dashboard configuration. An exception was thrown:', 0, $e)); Logger::error(new IcingaException('Cannot load dashboard configuration. An exception was thrown:', $e));
return null; return null;
} }
return $dashboard; return $dashboard;
@ -108,25 +82,29 @@ class DashboardController extends ActionController
)->activate('addurl'); )->activate('addurl');
$form = new AddUrlForm(); $form = new AddUrlForm();
$form->setRequest($this->getRequest()); $request = $this->getRequest();
$form->setAction(Url::fromRequest()->setParams(array())->getAbsoluteUrl()); if ($request->isPost()) {
$this->view->form = $form; if ($form->isValid($request->getPost()) && $form->isSubmitted()) {
$dashboard = $this->getDashboard();
$dashboard->setComponentUrl(
$form->getValue('pane'),
$form->getValue('component'),
ltrim($form->getValue('url'), '/')
);
if ($form->isSubmittedAndValid()) { $configFile = Config::app('dashboard/dashboard')->getConfigFile();
$dashboard = $this->getDashboard(); if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) {
$dashboard->setComponentUrl( $this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
$form->getValue('pane'), } else {
$form->getValue('component'), $this->render('showConfiguration');
ltrim($form->getValue('url'), '/') return;
); }
$configFile = IcingaConfig::app('dashboard/dashboard')->getConfigFile();
if ($this->writeConfiguration(new Zend_Config($dashboard->toArray()), $configFile)) {
$this->redirectNow(Url::fromPath('dashboard', array('pane' => $form->getValue('pane'))));
} else {
$this->render('show-configuration');
} }
} else {
$form->create()->setDefault('url', htmlspecialchars_decode($request->getParam('url', '')));
} }
$this->view->form = $form;
} }
/** /**
@ -137,19 +115,23 @@ class DashboardController extends ActionController
*/ */
public function indexAction() public function indexAction()
{ {
$dashboard = $this->getDashboard(); $dashboard = Dashboard::load();
if ($this->_getParam('pane')) {
$pane = $this->_getParam('pane');
$dashboard->activate($pane);
}
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG); if (! $dashboard->hasPanes()) {
if ($dashboard === null) {
$this->view->title = 'Dashboard'; $this->view->title = 'Dashboard';
} else { } else {
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard'; if ($this->_getParam('pane')) {
$this->view->tabs = $dashboard->getTabs(); $pane = $this->_getParam('pane');
$dashboard->activate($pane);
}
$this->view->configPath = Config::resolvePath(self::DEFAULT_CONFIG);
if ($dashboard === null) {
$this->view->title = 'Dashboard';
} else {
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
$this->view->tabs = $dashboard->getTabs();
/* Temporarily removed /* Temporarily removed
$this->view->tabs->add( $this->view->tabs->add(
@ -161,8 +143,8 @@ class DashboardController extends ActionController
); );
*/ */
$this->view->dashboard = $dashboard; $this->view->dashboard = $dashboard;
}
} }
} }
@ -176,19 +158,18 @@ class DashboardController extends ActionController
*/ */
protected function writeConfiguration(Zend_Config $config, $target) protected function writeConfiguration(Zend_Config $config, $target)
{ {
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target)); $writer = new IniWriter(array('config' => $config, 'filename' => $target));
try { try {
$writer->write(); $writer->write();
} catch (Exception $e) { } catch (Exception $e) {
Logger::error(new ConfiguationError("Cannot write dashboard to $target", 0, $e)); Logger::error(new ConfiguationError("Cannot write dashboard to $target", 0, $e));
$this->view->iniConfigurationString = $writer->render(); $this->view->configString = $writer->render();
$this->view->exceptionMessage = $e->getMessage(); $this->view->errorMessage = $e->getMessage();
$this->view->file = $target; $this->view->filePath = $target;
return false; return false;
} }
return true; return true;
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,35 +1,10 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// namespace Icinga\Application\Controllers; // namespace Icinga\Application\Controllers;
use Icinga\Application\Logger;
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
@ -47,6 +22,10 @@ class ErrorController extends ActionController
{ {
$error = $this->_getParam('error_handler'); $error = $this->_getParam('error_handler');
$exception = $error->exception; $exception = $error->exception;
Logger::error($exception);
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
switch ($error->type) { switch ($error->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
@ -78,4 +57,3 @@ class ErrorController extends ActionController
$this->view->request = $error->request; $this->view->request = $error->request;
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,36 +1,10 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Filter\Filter; use Icinga\Filter\Filter;
use Icinga\Logger\Logger; use Icinga\Application\Logger;
/** /**
* Application wide interface for filtering * Application wide interface for filtering
@ -117,4 +91,3 @@ class FilterController extends ActionController
} }
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,31 +1,5 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
# namespace Icinga\Application\Controllers; # namespace Icinga\Application\Controllers;
@ -45,7 +19,7 @@ class IndexController extends ActionController
public function preDispatch() public function preDispatch()
{ {
if ($this->getRequest()->getActionName() !== 'welcome') { if ($this->getRequest()->getActionName() !== 'welcome') {
$this->redirectNow('dashboard'); $this->redirectNow(Url::fromRequest()->setPath('dashboard'));
} }
} }
@ -56,4 +30,3 @@ class IndexController extends ActionController
{ {
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,111 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Session;
use Icinga\Web\Wizard\Wizard;
use Icinga\Web\Controller\ActionController;
class InstallController extends ActionController
{
/**
* Whether the controller requires the user to be authenticated
*
* The install wizard has its own authentication mechanism.
*
* @var bool
*/
protected $requiresAuthentication = false;
/**
* Whether the controller requires configuration
*
* The install wizard does not require any configuration.
*
* @var bool
*/
protected $requiresConfiguration = false;
/**
* Show the wizard and run the installation once its finished
*/
public function indexAction()
{
$wizard = $this->createWizard();
if ($wizard->isSubmittedAndValid()) {
$wizard->navigate();
if ($wizard->isFinished()) {
// TODO: Run the installer (Who creates an installer? How do we handle module installers?)
$this->dropConfiguration(); // TODO: Should only be done if the installation has been successfully completed
$this->view->installer = '';
} else {
$this->storeConfiguration($wizard->getConfig());
}
}
$this->view->wizard = $wizard;
}
/**
* Create the wizard and register all pages
*
* @return Wizard
*/
protected function createWizard()
{
$wizard = new Wizard();
$wizard->setTitle('Web');
$wizard->setRequest($this->getRequest());
$wizard->setConfiguration($this->loadConfiguration());
$wizard->addPages(
array(
// t('Welcome') => 'Icinga\Form\Install\WelcomePage',
// t('Requirements') => 'Icinga\Form\Install\RequirementsPage',
// t('Authentication') => 'Icinga\Form\Install\AuthenticationPage',
// t('Administration') => 'Icinga\Form\Install\AdministrationPage',
// t('Preferences') => 'Icinga\Form\Install\PreferencesPage',
t('Logging') => 'Icinga\Form\Install\LoggingPage',
// t('Database Setup') => 'Icinga\Form\Install\DatabasePage',
// t('Summary') => 'Icinga\Form\Install\SummaryPage'
)
);
return $wizard;
}
/**
* Store the given configuration values
*
* @param Zend_Config $config The configuration
*/
protected function storeConfiguration(Zend_Config $config)
{
$session = Session::getSession();
$session->getNamespace('WebWizard')->setAll($config->toArray(), true);
$session->write();
}
/**
* Load all configuration values
*
* @return Zend_Config
*/
protected function loadConfiguration()
{
return new Zend_Config(Session::getSession()->getNamespace('WebWizard')->getAll(), true);
}
/**
* Clear all stored configuration values
*/
protected function dropConfiguration()
{
$session = Session::getSession();
$session->removeNamespace('WebWizard');
$session->write();
}
}
// @codeCoverageIgnoreEnd

View File

@ -1,8 +1,8 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\MenuRenderer;
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Web\Menu; use Icinga\Web\Menu;
@ -18,9 +18,12 @@ class LayoutController extends ActionController
*/ */
public function menuAction() public function menuAction()
{ {
$this->view->url = Url::fromRequest()->getRelativeUrl(); $this->setAutorefreshInterval(15);
$this->view->items = Menu::fromConfig()->getChildren(); $this->_helper->layout()->disableLayout();
$this->view->sub = false;
$url = Url::fromRequest();
$menu = new MenuRenderer(Menu::load(), $url->getRelativeUrl());
$this->view->menuRenderer = $menu->useCustomRenderer();
} }
/** /**
@ -30,11 +33,11 @@ class LayoutController extends ActionController
{ {
$topbarHtmlParts = array(); $topbarHtmlParts = array();
/** @var Hook\Layout\TopBar $hook */ /** @var Hook\TopBarHook $hook */
$hook = null; $hook = null;
foreach (Hook::all('TopBar') as $hook) { foreach (Hook::all('TopBar') as $hook) {
$topbarHtmlParts[] = $hook->getHtml($this->getRequest(), $this->view); $topbarHtmlParts[] = $hook->getHtml($this->getRequest());
} }
$this->view->topbarHtmlParts = $topbarHtmlParts; $this->view->topbarHtmlParts = $topbarHtmlParts;
@ -43,4 +46,3 @@ class LayoutController extends ActionController
$this->renderScript('parts/topbar.phtml'); $this->renderScript('parts/topbar.phtml');
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,38 +1,13 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Data\ResourceFactory; use Icinga\Application\Logger;
use Icinga\Protocol\File\FileReader;
use \Zend_Controller_Action_Exception as ActionError;
/** /**
* Class ListController * Class ListController
@ -62,21 +37,21 @@ class ListController extends Controller
*/ */
public function applicationlogAction() public function applicationlogAction()
{ {
$this->addTitleTab('application log'); if (! Logger::writesToFile()) {
$config_ini = IcingaConfig::app()->toArray(); throw new ActionError('Site not found', 404);
if (!in_array('logging', $config_ini) || (
in_array('type', $config_ini['logging']) &&
$config_ini['logging']['type'] === 'file' &&
in_array('target', $config_ini['logging']) &&
file_exists($config_ini['logging']['target'])
)
) {
$config = ResourceFactory::getResourceConfig('logfile');
$resource = ResourceFactory::createResource($config);
$this->view->logData = $resource->select()->order('DESC')->paginate();
} else {
$this->view->logData = null;
} }
$this->addTitleTab('application log');
$pattern = '/^(?<datetime>[0-9]{4}(-[0-9]{2}){2}' // date
. 'T[0-9]{2}(:[0-9]{2}){2}([\\+\\-][0-9]{2}:[0-9]{2})?)' // time
. ' - (?<loglevel>[A-Za-z]+)' // loglevel
. ' - (?<message>.*)$/'; // message
$loggerWriter = Logger::getInstance()->getWriter();
$resource = new FileReader(new Zend_Config(array(
'filename' => $loggerWriter->getPath(),
'fields' => $pattern
)));
$this->view->logData = $resource->select()->order('DESC')->paginate();
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,38 +1,14 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\BasePreferenceController; use Icinga\Web\Controller\BasePreferenceController;
use Icinga\Web\Widget\Tab;
use Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Form\Preference\GeneralForm; use Icinga\Web\Widget\Tab;
use Icinga\Application\Config;
use Icinga\Form\PreferenceForm;
use Icinga\Exception\ConfigurationError;
use Icinga\User\Preferences\PreferencesStore;
/** /**
* Application wide preference controller for user preferences * Application wide preference controller for user preferences
@ -59,28 +35,22 @@ class PreferenceController extends BasePreferenceController
} }
/** /**
* General settings for date and time * Show form to adjust user preferences
*/ */
public function indexAction() public function indexAction()
{ {
$form = new GeneralForm(); $storeConfig = Config::app()->preferences;
$this->getTabs()->activate('general'); if ($storeConfig === null) {
$form->setConfiguration(IcingaConfig::app()) throw new ConfigurationError(t('You need to configure how to store preferences first.'));
->setRequest($this->getRequest());
if ($form->isSubmittedAndValid()) {
try {
$this->savePreferences($form->getPreferences());
$this->view->successMessage = 'Preferences Updated Successfully';
// Recreate form to show new values
// TODO(el): It must sufficient to call $form->populate(...)
$form = new GeneralForm();
$form->setConfiguration(IcingaConfig::app());
$form->setRequest($this->getRequest());
} catch (Exception $e) {
$this->view->exceptionMessage = $e->getMessage();
}
} }
$user = $this->getRequest()->getUser();
$form = new PreferenceForm();
$form->setPreferences($user->getPreferences());
$form->setStore(PreferencesStore::create($storeConfig, $user));
$form->handleRequest();
$this->view->form = $form; $this->view->form = $form;
$this->getTabs()->activate('general');
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,10 +1,10 @@
<?php <?php
// @codeCoverageIgnoreStart // {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;
use Icinga\Web\Widget; use Icinga\Web\Widget;
use Icinga\Web\Url; use Icinga\Web\Widget\SearchDashboard;
/** /**
* Search controller * Search controller
@ -13,48 +13,13 @@ class SearchController extends ActionController
{ {
public function indexAction() public function indexAction()
{ {
$search = $this->_request->getParam('q'); $this->view->dashboard = SearchDashboard::search($this->params->get('q'));
if (! $search) {
$this->view->tabs = Widget::create('tabs')->add( // NOTE: This renders the dashboard twice. Remove this once we can catch exceptions thrown in view scripts.
'search', $this->view->dashboard->render();
array( }
'title' => $this->translate('Search'),
'url' => '/search', public function hintAction()
) {
)->activate('search');
$this->render('hint');
return;
}
$dashboard = Widget::create('dashboard')->createPane($this->translate('Search'));
$pane = $dashboard->getPane($this->translate('Search'));
$suffix = strlen($search) ? ': ' . rtrim($search, '*') . '*' : '';
$pane->addComponent(
$this->translate('Hosts') . $suffix,
Url::fromPath('monitoring/list/hosts', array(
'host_name' => $search . '*',
'sort' => 'host_severity',
'limit' => 10,
)
));
$pane->addComponent(
$this->translate('Services') . $suffix,
Url::fromPath('monitoring/list/services', array(
'service_description' => $search . '*',
'sort' => 'service_severity',
'limit' => 10,
)
));
$pane->addComponent('Hostgroups' . $suffix, Url::fromPath('monitoring/list/hostgroups', array(
'hostgroup' => $search . '*',
'limit' => 10,
)));
$pane->addComponent('Servicegroups' . $suffix, Url::fromPath('monitoring/list/servicegroups', array(
'servicegroup' => $search . '*',
'limit' => 10,
)));
$dashboard->activate($this->translate('Search'));
$this->view->dashboard = $dashboard;
$this->view->tabs = $dashboard->getTabs();
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,37 +1,12 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Controller_Action_Exception as ActionException;
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Logger\Logger; use Icinga\Application\Logger;
use Icinga\Web\FileCache;
use Zend_Controller_Action_Exception as ActionException;
/** /**
* Delivery static content to clients * Delivery static content to clients
@ -56,8 +31,25 @@ class StaticController extends ActionController
public function gravatarAction() public function gravatarAction()
{ {
$img = file_get_contents('http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->_request->getParam('email')))) . '?s=200&d=mm'); $cache = FileCache::instance();
header('image/jpeg'); $filename = md5(strtolower(trim($this->_request->getParam('email'))));
$cacheFile = 'gravatar-' . $filename;
header('Cache-Control: public');
header('Pragma: cache');
if ($etag = $cache->etagMatchesCachedFile($cacheFile)) {
header("HTTP/1.1 304 Not Modified");
return;
}
header('Content-Type: image/jpg');
if ($cache->has($cacheFile)) {
header('ETag: "' . $cache->etagForCachedFile($cacheFile) . '"');
$cache->send($cacheFile);
return;
}
$img = file_get_contents('http://www.gravatar.com/avatar/' . $filename . '?s=120&d=mm');
$cache->store($cacheFile, $img);
header('ETag: "' . $cache->etagForCachedFile($cacheFile) . '"');
echo $img; echo $img;
} }
@ -67,13 +59,12 @@ class StaticController extends ActionController
public function imgAction() public function imgAction()
{ {
$module = $this->_getParam('module_name'); $module = $this->_getParam('module_name');
// TODO: This is more than dangerous, must be fixed!!
$file = $this->_getParam('file'); $file = $this->_getParam('file');
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir(); $basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
$filePath = $basedir . '/public/img/' . $file; $filePath = realpath($basedir . '/public/img/' . $file);
if (! file_exists($filePath)) {
if (! $filePath || strpos($filePath, $basedir) !== 0) {
throw new ActionException(sprintf( throw new ActionException(sprintf(
'%s does not exist', '%s does not exist',
$filePath $filePath
@ -188,4 +179,3 @@ class StaticController extends ActionController
$lessCompiler->printStack(); $lessCompiler->printStack();
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,8 +1,11 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Authentication; namespace Icinga\Form\Authentication;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Url;
/** /**
* Class LoginForm * Class LoginForm
@ -10,34 +13,45 @@ use Icinga\Web\Form;
class LoginForm extends Form class LoginForm extends Form
{ {
/** /**
* Disable CSRF protection * Initialize this login form
* @var bool
*/ */
protected $tokenDisabled = true; public function init()
/**
* Interface how the form should be created
*/
protected function create()
{ {
$this->setName('form_login'); $this->setName('form_login');
$this->addElement('text', 'username', array( $this->setSubmitLabel(t('Login'));
'label' => t('Username'), }
'placeholder' => t('Please enter your username...'),
'required' => true,
));
$this->addElement('password', 'password', array( /**
'label' => t('Password'), * @see Form::createElements()
'placeholder' => t('...and your password'), */
'required' => true public function createElements(array $formData)
)); {
// TODO: We need a place to intercept filled forms before rendering $this->addElement(
if (isset($_POST['username'])) { 'text',
$this->getElement('password')->setAttrib('class', 'autofocus'); 'username',
} else { array(
$this->getElement('username')->setAttrib('class', 'autofocus'); 'required' => true,
} 'label' => t('Username'),
$this->setSubmitLabel('Login'); 'placeholder' => t('Please enter your username...'),
'class' => false === isset($formData['username']) ? 'autofocus' : ''
)
);
$this->addElement(
'password',
'password',
array(
'required' => true,
'label' => t('Password'),
'placeholder' => t('...and your password'),
'class' => isset($formData['username']) ? 'autofocus' : ''
)
);
$this->addElement(
'hidden',
'redirect',
array(
'value' => Url::fromRequest()->getParam('redirect')
)
);
} }
} }

View File

@ -0,0 +1,89 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Authentication;
use Zend_Validate_Callback;
use Icinga\Web\Form;
/**
* Form class for adding/modifying autologin authentication backends
*/
class AutologinBackendForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_authbackend_autologin');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'name',
array(
'required' => true,
'label' => t('Backend Name'),
'description' => t('The name of this authentication backend'),
'validators' => array(
array(
'Regex',
false,
array(
'pattern' => '/^[^\\[\\]:]+$/',
'messages' => array(
'regexNotMatch' => 'The backend name cannot contain \'[\', \']\' or \':\'.'
)
)
)
)
)
);
$this->addElement(
'text',
'strip_username_regexp',
array(
'required' => true,
'label' => t('Backend Domain Pattern'),
'description' => t('The domain pattern of this authentication backend'),
'value' => '/\@[^$]+$/',
'validators' => array(
new Zend_Validate_Callback(function ($value) {
return @preg_match($value, '') !== false;
})
)
)
);
$this->addElement(
'hidden',
'backend',
array(
'required' => true,
'value' => 'autologin'
)
);
return $this;
}
/**
* Validate the configuration by creating a backend and requesting the user count
*
* Returns always true as autologin backends are just "passive" backends. (The webserver authenticates users.)
*
* @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/
public function isValidAuthenticationBackend(Form $form)
{
return true;
}
}

View File

@ -1,189 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Authentication;
use \Zend_Config;
use \Zend_Form_Element_Checkbox;
use Icinga\Web\Form;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form\Decorator\HelpText;
/**
* Base form for authentication backend forms
*/
abstract class BaseBackendForm extends Form
{
/**
* The name of the backend currently displayed in this form
*
* Will be the section in the authentication.ini file
*
* @var string
*/
protected $backendName = '';
/**
* The backend configuration as a Zend_Config object
*
* @var Zend_Config
*/
protected $backend;
/**
* The resources to use instead of the factory provided ones (use for testing)
*
* @var Zend_Config
*/
protected $resources;
/**
* Set the name of the currently displayed backend
*
* @param string $name The name to be stored as the section when persisting
*/
public function setBackendName($name)
{
$this->backendName = $name;
}
/**
* Return the backend name of this form
*
* @return string
*/
public function getBackendName()
{
return $this->backendName;
}
/**
* Return the backend configuration or a empty Zend_Config object if none is given
*
* @return Zend_Config
*/
public function getBackend()
{
return ($this->backend !== null) ? $this->backend : new Zend_Config(array());
}
/**
* Set the backend configuration for initial population
*
* @param Zend_Config $backend The backend to display in this form
*/
public function setBackend(Zend_Config $backend)
{
$this->backend = $backend;
}
/**
* Set an alternative array of resources that should be used instead of the DBFactory resource set
*
* @param array $resources The resources to use for populating the db selection field
*/
public function setResources(array $resources)
{
$this->resources = $resources;
}
/**
* Return content of the resources.ini or previously set resources
*
* @return array
*/
public function getResources()
{
if ($this->resources === null) {
return ResourceFactory::getResourceConfigs()->toArray();
} else {
return $this->resources;
}
}
/**
* Add checkbox at the beginning of the form which allows to skip logic connection validation
*/
protected function addForceCreationCheckbox()
{
$checkbox = new Zend_Form_Element_Checkbox(
array(
'name' => 'backend_force_creation',
'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation'),
'order' => 0
)
);
$checkbox->addDecorator(new HelpText());
$this->addElement($checkbox);
}
/**
* Validate this form with the Zend validation mechanism and perform a logic validation of the connection.
*
* If logic validation fails, the 'backend_force_creation' checkbox is prepended to the form to allow users to
* skip the logic connection validation.
*
* @param array $data The form input to validate
*
* @return bool Whether validation succeeded or not
*/
public function isValid($data)
{
if (!parent::isValid($data)) {
return false;
}
if (isset($data['backend_force_creation']) && $data['backend_force_creation']) {
return true;
}
if (!$this->isValidAuthenticationBackend()) {
$this->addForceCreationCheckbox();
return false;
}
return true;
}
/**
* Return an array containing all sections defined by this form as the key and all settings
* as an key-value sub-array
*
* @return array
*/
abstract public function getConfig();
/**
* Validate the configuration state of this backend with the concrete authentication backend.
*
* An implementation should not throw any exception, but use the add/setErrorMessages method of
* Zend_Form. If the 'backend_force_creation' checkbox is set, this method won't be called.
*
* @return bool Whether validation succeeded or not
*/
abstract public function isValidAuthenticationBackend();
}

View File

@ -1,151 +1,117 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Authentication; namespace Icinga\Form\Config\Authentication;
use \Exception; use Exception;
use \Icinga\Authentication\Backend\DbUserBackend; use Icinga\Web\Form;
use \Zend_Config; use Icinga\Web\Request;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Authentication\UserBackend; use Icinga\Authentication\Backend\DbUserBackend;
/** /**
* Form class for adding/modifying database authentication backends * Form class for adding/modifying database authentication backends
*/ */
class DbBackendForm extends BaseBackendForm class DbBackendForm extends Form
{ {
/** /**
* Return content of the resources.ini or previously set resources * The database resource names the user can choose from
* *
* @return array * @var array
*/ */
public function getResources() protected $resources;
/**
* Initialize this form
*/
public function init()
{ {
if ($this->resources === null) { $this->setName('form_config_authbackend_db');
$res = ResourceFactory::getResourceConfigs('db')->toArray(); }
foreach (array_keys($res) as $key) { /**
$res[$key] = $key; * Set the resource names the user can choose from
} *
* @param array $resources The resources to choose from
*
* @return self
*/
public function setResources(array $resources)
{
$this->resources = $resources;
return $this;
}
return $res; /**
} else { * @see Form::createElements()
return $this->resources; */
public function createElements(array $formData)
{
$this->addElement(
'text',
'name',
array(
'required' => true,
'label' => t('Backend Name'),
'description' => t('The name of this authentication provider'),
)
);
$this->addElement(
'select',
'resource',
array(
'required' => true,
'label' => t('Database Connection'),
'description' => t('The database connection to use for authenticating with this provider'),
'multiOptions' => false === empty($this->resources)
? array_combine($this->resources, $this->resources)
: array()
)
);
$this->addElement(
'hidden',
'backend',
array(
'required' => true,
'value' => 'db'
)
);
return $this;
}
/**
* Validate that the selected resource is a valid database authentication backend
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (false === $this->isValidAuthenticationBackend($this)) {
return false;
} }
} }
/** /**
* Create this form and add all required elements * Validate the configuration by creating a backend and requesting the user count
* *
* @see Form::create() * @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/ */
public function create() public function isValidAuthenticationBackend(Form $form)
{ {
$this->setName('form_modify_backend'); $element = $form->getElement('resource');
$name = $this->filterName($this->getBackendName());
$this->addElement(
'text',
'backend_' . $name . '_name',
array(
'required' => true,
'allowEmpty' => false,
'label' => t('Backend Name'),
'helptext' => t('The name of this authentication provider'),
'value' => $this->getBackendName()
)
);
$this->addElement(
'select',
'backend_' . $name . '_resource',
array(
'required' => true,
'allowEmpty' => false,
'label' => t('Database Connection'),
'helptext' => t('The database connection to use for authenticating with this provider'),
'value' => $this->getBackend()->get('resource'),
'multiOptions' => $this->getResources()
)
);
$this->addElement(
'button',
'btn_submit',
array(
'type' => 'submit',
'value' => '1',
'escape' => false,
'class' => 'btn btn-cta btn-wide',
'label' => '<i class="icinga-icon-save"></i> Save Backend'
)
);
}
/**
* Return the datatbase authentication backend configuration for this form
*
* @return array
*
* @see BaseBackendForm::getConfig()
*/
public function getConfig()
{
$prefix = 'backend_' . $this->filterName($this->getBackendName()) . '_';
$section = $this->getValue($prefix . 'name');
$cfg = array(
'backend' => 'db',
'resource' => $this->getValue($prefix . 'resource'),
);
return array($section => $cfg);
}
/**
* Validate the current configuration by creating a backend and requesting the user count
*
* @return bool Whether validation succeeded or not
*
* @see BaseBackendForm::isValidAuthenticationBackend
*/
public function isValidAuthenticationBackend()
{
try { try {
$testConnection = ResourceFactory::createResource(ResourceFactory::getResourceConfig( $dbUserBackend = new DbUserBackend(ResourceFactory::create($element->getValue()));
$this->getValue('backend_' . $this->filterName($this->getBackendName()) . '_resource')
));
$dbUserBackend = new DbUserBackend($testConnection);
if ($dbUserBackend->count() < 1) { if ($dbUserBackend->count() < 1) {
$this->addErrorMessage(t("No users found under the specified database backend")); $element->addError(t('No users found under the specified database backend'));
return false; return false;
} }
} catch (Exception $e) { } catch (Exception $e) {
$this->addErrorMessage(sprintf(t('Using the specified backend failed: %s'), $e->getMessage())); $element->addError(sprintf(t('Using the specified backend failed: %s'), $e->getMessage()));
return false; return false;
} }

View File

@ -1,194 +1,138 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Authentication; namespace Icinga\Form\Config\Authentication;
use \Exception; use Exception;
use \Zend_Config;
use Icinga\Web\Form; use Icinga\Web\Form;
use Icinga\Web\Request;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Authentication\Backend\LdapUserBackend; use Icinga\Authentication\Backend\LdapUserBackend;
/** /**
* Form for adding or modifying LDAP authentication backends * Form class for adding/modifying LDAP authentication backends
*/ */
class LdapBackendForm extends BaseBackendForm class LdapBackendForm extends Form
{ {
/** /**
* Return content of the resources.ini or previously set resources * The ldap resource names the user can choose from
* *
* @return array * @var array
*/ */
public function getResources() protected $resources;
/**
* Initialize this form
*/
public function init()
{ {
if ($this->resources === null) { $this->setName('form_config_authbackend_ldap');
$res = ResourceFactory::getResourceConfigs('ldap')->toArray();
foreach (array_keys($res) as $key) {
$res[$key] = $key;
}
return $res;
} else {
return $this->resources;
}
} }
/** /**
* Create this form and add all required elements * Set the resource names the user can choose from
* *
* @see Form::create() * @param array $resources The resources to choose from
*
* @return self
*/ */
public function create() public function setResources(array $resources)
{ {
$this->setName('form_modify_backend'); $this->resources = $resources;
$name = $this->filterName($this->getBackendName()); return $this;
$backend = $this->getBackend(); }
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement( $this->addElement(
'text', 'text',
'backend_' . $name . '_name', 'name',
array( array(
'required' => true, 'required' => true,
'allowEmpty' => false,
'label' => t('Backend Name'), 'label' => t('Backend Name'),
'helptext' => t('The name of this authentication backend'), 'description' => t('The name of this authentication backend')
'value' => $this->getBackendName()
) )
); );
$this->addElement( $this->addElement(
'select', 'select',
'backend_' . $name . '_resource', 'resource',
array( array(
'required' => true, 'required' => true,
'allowEmpty' => false,
'label' => t('LDAP Resource'), 'label' => t('LDAP Resource'),
'helptext' => t('The resource to use for authenticating with this provider'), 'description' => t('The resource to use for authenticating with this provider'),
'value' => $this->getBackend()->get('resource'), 'multiOptions' => false === empty($this->resources)
'multiOptions' => $this->getResources() ? array_combine($this->resources, $this->resources)
: array()
) )
); );
$this->addElement( $this->addElement(
'text', 'text',
'backend_' . $name . '_user_class', 'user_class',
array( array(
'required' => true, 'required' => true,
'label' => t('LDAP User Object Class'), 'label' => t('LDAP User Object Class'),
'helptext' => t('The object class used for storing users on the ldap server'), 'description' => t('The object class used for storing users on the ldap server'),
'value' => $backend->get('user_class', 'inetOrgPerson') 'value' => 'inetOrgPerson'
) )
); );
$this->addElement( $this->addElement(
'text', 'text',
'backend_' . $name . '_user_name_attribute', 'user_name_attribute',
array(
'required' => true,
'label' => t('LDAP User Name Attribute'),
'description' => t('The attribute name used for storing the user name on the ldap server'),
'value' => 'uid'
)
);
$this->addElement(
'hidden',
'backend',
array( array(
'required' => true, 'required' => true,
'label' => t('LDAP User Name Attribute'), 'value' => 'ldap'
'helptext' => t('The attribute name used for storing the user name on the ldap server'),
'value' => $backend->get('user_name_attribute', 'uid')
) )
); );
$this->addElement( return $this;
'button',
'btn_submit',
array(
'type' => 'submit',
'value' => '1',
'escape' => false,
'class' => 'btn btn-cta btn-wide',
'label' => '<i class="icinga-icon-save"></i> Save Backend'
)
);
} }
/** /**
* Return the ldap authentication backend configuration for this form * Validate that the selected resource is a valid ldap authentication backend
* *
* @return array * @see Form::onSuccess()
*
* @see BaseBackendForm::getConfig()
*/ */
public function getConfig() public function onSuccess(Request $request)
{ {
$prefix = 'backend_' . $this->filterName($this->getBackendName()) . '_'; if (false === $this->isValidAuthenticationBackend($this)) {
$section = $this->getValue($prefix . 'name');
$cfg = array(
'backend' => 'ldap',
'resource' => $this->getValue($prefix . 'resource'),
'user_class' => $this->getValue($prefix . 'user_class'),
'user_name_attribute' => $this->getValue($prefix . 'user_name_attribute')
);
return array($section => $cfg);
}
/**
* Validate the current configuration by creating a backend and requesting the user count
*
* @return bool Whether validation succeeded or not
*
* @see BaseBackendForm::isValidAuthenticationBacken
*/
public function isValidAuthenticationBackend()
{
if (!ResourceFactory::ldapAvailable()) {
/*
* It should be possible to run icingaweb without the php ldap extension, when
* no ldap backends are needed. When the user tries to create an ldap backend
* without ldap installed we need to show him an error.
*/
$this->addErrorMessage(t('Using ldap is not possible, the php extension "ldap" is not installed.'));
return false; return false;
} }
}
/**
* Validate the configuration by creating a backend and requesting the user count
*
* @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/
public function isValidAuthenticationBackend(Form $form)
{
$element = $form->getElement('resource');
try { try {
$cfg = $this->getConfig(); $ldapUserBackend = new LdapUserBackend(
$backendName = 'backend_' . $this->filterName($this->getBackendName()) . '_name'; ResourceFactory::create($element->getValue()),
$backendConfig = new Zend_Config($cfg[$this->getValue($backendName)]); $form->getElement('user_class')->getValue(),
$backend = ResourceFactory::createResource(ResourceFactory::getResourceConfig($backendConfig->resource)); $form->getElement('user_name_attribute')->getValue()
$testConn = new LdapUserBackend(
$backend,
$backendConfig->user_class,
$backendConfig->user_name_attribute
);
$testConn->assertAuthenticationPossible();
/*
if ($testConn->count() === 0) {
throw new Exception('No Users Found On Directory Server');
}
*/
} catch (Exception $exc) {
$this->addErrorMessage(
t('Connection Validation Failed: ' . $exc->getMessage())
); );
$ldapUserBackend->assertAuthenticationPossible();
} catch (Exception $e) {
$element->addError(sprintf(t('Connection validation failed: %s'), $e->getMessage()));
return false; return false;
} }

View File

@ -1,258 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Authentication;
use \Zend_Config;
use Icinga\Web\Form;
/**
* Form for modifying the authentication provider order
*/
class ReorderForm extends Form
{
/**
* The name of the current backend which will get action buttons for up and down movement
*
* @var string
*/
protected $backend;
/**
* The current ordering of all backends, required to determine possible changes
*
* @var array
*/
protected $currentOrder = array();
/**
* Set an array with the current order of all backends
*
* @param array $order An array containing backend names in the order
* they are defined in the authentication.ini
*/
public function setCurrentOrder(array $order)
{
$this->currentOrder = $order;
}
/**
* Set the name of the authentication backend for which to create the form
*
* @param string $backend The name of the authentication backend
*/
public function setBackendName($backend)
{
$this->backend = $backend;
}
/**
* Return the name of the currently set backend as it will appear in the form
*
* @return string The name of the backend
*/
public function getBackendName()
{
return $this->filterName($this->backend);
}
/**
* Create this form
*
* @see Form::create
*/
public function create()
{
if ($this->moveElementUp($this->backend, $this->currentOrder) !== $this->currentOrder) {
$upForm = new Form();
$upForm->addElement(
'hidden',
'form_backend_order',
array(
'required' => true,
'value' => join(',', $this->moveElementUp($this->backend, $this->currentOrder))
)
);
$upForm->addElement(
'button',
'btn_' . $this->getBackendName() . '_reorder_up',
array(
'type' => 'submit',
'escape' => false,
'value' => 'btn_' . $this->getBackendName() . '_reorder_up',
'name' => 'btn_' . $this->getBackendName() . '_reorder_up',
'label' => $this->getView()->icon('up.png', t('Move up in authentication order'))
)
);
$this->addSubForm($upForm, 'btn_reorder_up');
}
if ($this->moveElementDown($this->backend, $this->currentOrder) !== $this->currentOrder) {
$downForm = new Form();
$downForm->addElement(
'hidden',
'form_backend_order',
array(
'required' => true,
'value' => join(',', $this->moveElementDown($this->backend, $this->currentOrder))
)
);
$downForm->addElement(
'button',
'btn_' . $this->getBackendName() . '_reorder_down',
array(
'type' => 'submit',
'escape' => false,
'value' => 'btn_' . $this->getBackendName() . '_reorder_down',
'name' => 'btn_' . $this->getBackendName() . '_reorder_down',
'label' => $this->getView()->icon('down.png', t('Move down in authentication order'))
)
);
$this->addSubForm($downForm, 'btn_reorder_down');
}
}
/**
* Return the flattened result of $this->getValues
*
* @return array The currently set values
*
* @see Form::getValues()
*/
protected function getFlattenedValues()
{
$result = array();
foreach (parent::getValues() as $key => $value) {
if (is_array($value)) {
$result += $value;
} else {
$result[$key] = $value;
}
}
return $result;
}
/**
* Determine whether this form is submitted by testing the submit buttons of both subforms
*
* @return bool Whether the form has been submitted or not
*/
public function isSubmitted()
{
$checkData = $this->getRequest()->getParams();
return isset($checkData['btn_' . $this->getBackendName() . '_reorder_up']) ||
isset($checkData['btn_' . $this->getBackendName() . '_reorder_down']);
}
/**
* Return the reordered configuration after a reorder button has been submitted
*
* @param Zend_Config $config The configuration to reorder
*
* @return array An array containing the reordered configuration
*/
public function getReorderedConfig(Zend_Config $config)
{
$originalConfig = $config->toArray();
$newOrder = $this->getFlattenedValues();
$order = explode(',', $newOrder['form_backend_order']);
$reordered = array();
foreach ($order as $key) {
if (isset($originalConfig[$key])) {
$reordered[$key] = $originalConfig[$key];
}
}
return $reordered;
}
/**
* Static helper for moving an element in an array one slot up, if possible
*
* Example:
*
* <pre>
* $array = array('first', 'second', 'third');
* moveElementUp('third', $array); // returns ['first', 'third', 'second']
* </pre>
*
* @param string $key The key to bubble up one slot
* @param array $array The array to work with
*
* @return array The modified array
*/
protected static function moveElementUp($key, array $array)
{
for ($i = 0; $i < count($array) - 1; $i++) {
if ($array[$i + 1] === $key) {
$swap = $array[$i];
$array[$i] = $array[$i + 1];
$array[$i + 1] = $swap;
return $array;
}
}
return $array;
}
/**
* Static helper for moving an element in an array one slot down, if possible
*
* Example:
*
* <pre>
* $array = array('first', 'second', 'third');
* moveElementDown('first', $array); // returns ['second', 'first', 'third']
* </pre>
*
* @param string $key The key to bubble up one slot
* @param array $array The array to work with
*
* @return array The modified array
*/
protected static function moveElementDown($key, array $array)
{
for ($i = 0; $i < count($array) - 1; $i++) {
if ($array[$i] === $key) {
$swap = $array[$i + 1];
$array[$i + 1] = $array[$i];
$array[$i] = $swap;
return $array;
}
}
return $array;
}
}

View File

@ -0,0 +1,322 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use InvalidArgumentException;
use Icinga\Web\Request;
use Icinga\Form\ConfigForm;
use Icinga\Web\Notification;
use Icinga\Application\Config;
use Icinga\Application\Platform;
use Icinga\Exception\ConfigurationError;
use Icinga\Form\Config\Authentication\DbBackendForm;
use Icinga\Form\Config\Authentication\LdapBackendForm;
use Icinga\Form\Config\Authentication\AutologinBackendForm;
class AuthenticationBackendConfigForm extends ConfigForm
{
/**
* The available resources split by type
*
* @var array
*/
protected $resources;
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_authbackend');
$this->setSubmitLabel(t('Save Changes'));
}
/**
* Set the resource configuration to use
*
* @param Config $resources The resource configuration
*
* @return self
*
* @throws ConfigurationError In case no resources are available for authentication
*/
public function setResourceConfig(Config $resourceConfig)
{
$resources = array();
foreach ($resourceConfig as $name => $resource) {
$resources[strtolower($resource->type)][] = $name;
}
if (empty($resources)) {
throw new ConfigurationError(t('Could not find any resources for authentication'));
}
$this->resources = $resources;
return $this;
}
/**
* Return a form object for the given backend type
*
* @param string $type The backend type for which to return a form
*
* @return Form
*/
public function getBackendForm($type)
{
if ($type === 'db') {
$form = new DbBackendForm();
$form->setResources(isset($this->resources['db']) ? $this->resources['db'] : array());
} elseif ($type === 'ldap') {
$form = new LdapBackendForm();
$form->setResources(isset($this->resources['ldap']) ? $this->resources['ldap'] : array());
} elseif ($type === 'autologin') {
$form = new AutologinBackendForm();
} else {
throw new InvalidArgumentException(sprintf(t('Invalid backend type "%s" provided'), $type));
}
return $form;
}
/**
* Add a particular authentication backend
*
* The backend to add is identified by the array-key `name'.
*
* @param array $values The values to extend the configuration with
*
* @return self
*
* @throws InvalidArgumentException In case the backend does already exist
*/
public function add(array $values)
{
$name = isset($values['name']) ? $values['name'] : '';
if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing'));
} elseif ($this->config->get($name) !== null) {
throw new InvalidArgumentException(t('Authentication backend already exists'));
}
unset($values['name']);
$this->config->{$name} = $values;
return $this;
}
/**
* Edit a particular authentication backend
*
* @param string $name The name of the backend to edit
* @param array $values The values to edit the configuration with
*
* @return array The edited backend configuration
*
* @throws InvalidArgumentException In case the backend does not exist
*/
public function edit($name, array $values)
{
if (! $name) {
throw new InvalidArgumentException(t('Old authentication backend name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
throw new InvalidArgumentException(t('New authentication backend name missing'));
} elseif (($backendConfig = $this->config->get($name)) === null) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}
if ($newName !== $name) {
// Only remove the old entry if it has changed as the order gets screwed when editing backend names
unset($this->config->{$name});
}
unset($values['name']);
$this->config->{$newName} = array_merge($backendConfig->toArray(), $values);
return $this->config->{$newName};
}
/**
* Remove the given authentication backend
*
* @param string $name The name of the backend to remove
*
* @return array The removed backend configuration
*
* @throws InvalidArgumentException In case the backend does not exist
*/
public function remove($name)
{
if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing'));
} elseif (($backendConfig = $this->config->get($name)) === null) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}
unset($this->config->{$name});
return $backendConfig;
}
/**
* Move the given authentication backend up or down in order
*
* @param string $name The name of the backend to be moved
* @param int $position The new (absolute) position of the backend
*
* @return self
*
* @throws InvalidArgumentException In case the backend does not exist
*/
public function move($name, $position)
{
if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing'));
} elseif ($this->config->get($name) === null) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}
$backendOrder = $this->config->keys();
array_splice($backendOrder, array_search($name, $backendOrder), 1);
array_splice($backendOrder, $position, 0, $name);
$newConfig = array();
foreach ($backendOrder as $backendName) {
$newConfig[$backendName] = $this->config->get($backendName);
}
$config = new Config($newConfig);
$this->config = $config->setConfigFile($this->config->getConfigFile());
return $this;
}
/**
* Add or edit an authentication backend and save the configuration
*
* Performs a connectivity validation using the submitted values. A checkbox is
* added to the form to skip the check if it fails and redirection is aborted.
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
$backendForm = $this->getBackendForm($this->getElement('type')->getValue());
if (false === $backendForm->isValidAuthenticationBackend($this)) {
$this->addElement($this->getForceCreationCheckbox());
return false;
}
}
$authBackend = $request->getQuery('auth_backend');
try {
if ($authBackend === null) { // create new backend
$this->add($this->getValues());
$message = t('Authentication backend "%s" has been successfully created');
} else { // edit existing backend
$this->edit($authBackend, $this->getValues());
$message = t('Authentication backend "%s" has been successfully changed');
}
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
return;
}
if ($this->save()) {
Notification::success(sprintf($message, $this->getElement('name')->getValue()));
} else {
return false;
}
}
/**
* Populate the form in case an authentication backend is being edited
*
* @see Form::onRequest()
*
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
*/
public function onRequest(Request $request)
{
$authBackend = $request->getQuery('auth_backend');
if ($authBackend !== null) {
if ($authBackend === '') {
throw new ConfigurationError(t('Authentication backend name missing'));
} elseif (false === isset($this->config->{$authBackend})) {
throw new ConfigurationError(t('Unknown authentication backend provided'));
} elseif (false === isset($this->config->{$authBackend}->backend)) {
throw new ConfigurationError(sprintf(t('Backend "%s" has no `backend\' setting'), $authBackend));
}
$configValues = $this->config->{$authBackend}->toArray();
$configValues['type'] = $configValues['backend'];
$configValues['name'] = $authBackend;
$this->populate($configValues);
}
}
/**
* Return a checkbox to be displayed at the beginning of the form
* which allows the user to skip the connection validation
*
* @return Zend_Form_Element
*/
protected function getForceCreationCheckbox()
{
return $this->createElement(
'checkbox',
'force_creation',
array(
'order' => 0,
'ignore' => true,
'label' => t('Force Changes'),
'description' => t('Check this box to enforce changes without connectivity validation')
)
);
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$backendTypes = array();
$backendType = isset($formData['type']) ? $formData['type'] : 'db';
if (isset($this->resources['db'])) {
$backendTypes['db'] = t('Database');
}
if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) {
$backendTypes['ldap'] = 'LDAP';
}
$autologinBackends = array_filter(
$this->config->toArray(),
function ($authBackendCfg) {
return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'autologin';
}
);
if ($backendType === 'autologin' || empty($autologinBackends)) {
$backendTypes['autologin'] = t('Autologin');
}
$this->addElement(
'select',
'type',
array(
'ignore' => true,
'required' => true,
'autosubmit' => true,
'label' => t('Backend Type'),
'description' => t('The type of the resource to use for this authenticaton backend'),
'multiOptions' => $backendTypes
)
);
if (isset($formData['force_creation']) && $formData['force_creation']) {
// In case another error occured and the checkbox was displayed before
$this->addElement($this->getForceCreationCheckbox());
}
$this->addElements($this->getBackendForm($backendType)->createElements($formData)->getElements());
}
}

View File

@ -0,0 +1,68 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use InvalidArgumentException;
use Icinga\Web\Request;
use Icinga\Web\Notification;
use Icinga\Form\ConfigForm;
class AuthenticationBackendReorderForm extends ConfigForm
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_reorder_authbackend');
$this->setViewScript('form/reorder-authbackend.phtml');
}
/**
* Return the ordered backend names
*
* @return array
*/
public function getBackendOrder()
{
return $this->config->keys();
}
/**
* Update the authentication backend order and save the configuration
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
$formData = $this->getRequestData($request);
if (isset($formData['backend_newpos'])) {
$configForm = $this->getConfigForm();
list($backendName, $position) = explode('|', $formData['backend_newpos'], 2);
try {
if ($configForm->move($backendName, $position)->save()) {
Notification::success(t('Authentication order updated!'));
} else {
return false;
}
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
}
}
}
/**
* Return the config form for authentication backends
*
* @return ConfigForm
*/
protected function getConfigForm()
{
$form = new AuthenticationBackendConfigForm();
$form->setIniConfig($this->config);
return $form;
}
}

View File

@ -1,96 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use Icinga\Web\Form;
/**
* Form for confirming removal of an object
*/
class ConfirmRemovalForm extends Form
{
/**
* The value of the target to remove
*
* @var string
*/
private $removeTarget;
/**
* The name of the target parameter to remove
*
* @var string
*/
private $targetName;
/**
* Set the remove target in this field to be a hidden field with $name and value $target
*
* @param string $name The name to be set in the hidden field
* @param string $target The value to be set in the hidden field
*/
public function setRemoveTarget($name, $target)
{
$this->targetName = $name;
$this->removeTarget = $target;
}
/**
* Create the confirmation form
*
* @see Form::create()
*/
public function create()
{
$this->setName('form_confirm_removal');
$this->addElement(
'hidden',
$this->targetName,
array(
'value' => $this->removeTarget,
'required' => true
)
);
$this->addElement(
'button',
'btn_submit',
array(
'type' => 'submit',
'escape' => false,
'value' => '1',
'class' => 'btn btn-cta btn-common',
'label' => '<i class="icinga-icon-remove"></i> Confirm Removal'
)
);
}
}
// @codeCoverageIgnoreEnd

View File

@ -0,0 +1,100 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\General;
use DateTimeZone;
use Icinga\Web\Form;
use Icinga\Util\Translator;
use Icinga\Data\ResourceFactory;
/**
* Form class to modify the general application configuration
*/
class ApplicationConfigForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_general_application');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$tzList = array();
foreach (DateTimeZone::listIdentifiers() as $tz) {
$tzList[$tz] = $tz;
}
$this->addElement(
'select',
'global_timezone',
array(
'label' => t('Default Application Timezone'),
'required' => true,
'multiOptions' => $tzList,
'description' => t(
'Select the timezone to be used as the default. User\'s can set their own timezone if'
. ' they like to, but this is the timezone to be used as the default setting .'
),
'value' => date_default_timezone_get()
)
);
$this->addElement(
'text',
'global_modulePath',
array(
'label' => t('Module Path'),
'required' => true,
'description' => t(
'Contains the directories that will be searched for available modules, separated by '
. 'colons. Modules that don\'t exist in these directories can still be symlinked in '
. 'the module folder, but won\'t show up in the list of disabled modules.'
),
'value' => realpath(ICINGAWEB_APPDIR . '/../modules')
)
);
$this->addElement(
'select',
'preferences_type',
array(
'required' => true,
'autosubmit' => true,
'label' => t('User Preference Storage Type'),
'multiOptions' => array(
'ini' => t('File System (INI Files)'),
'db' => t('Database'),
'null' => t('Don\'t Store Preferences')
)
)
);
if (isset($formData['preferences_type']) && $formData['preferences_type'] === 'db') {
$backends = array();
foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) {
if ($resource['type'] === 'db') {
$backends[$name] = $name;
}
}
$this->addElement(
'select',
'preferences_resource',
array(
'required' => true,
'multiOptions' => $backends,
'label' => t('Database Connection')
)
);
}
return $this;
}
}

View File

@ -0,0 +1,127 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\General;
use Icinga\Application\Icinga;
use Icinga\Application\Logger;
use Icinga\Web\Form;
use Icinga\Web\Form\Validator\WritablePathValidator;
class LoggingConfigForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_general_logging');
}
/**
* (non-PHPDoc)
* @see Form::createElements() For the method documentation.
*/
public function createElements(array $formData)
{
$this->addElement(
'select',
'logging_log',
array(
'required' => true,
'class' => 'autosubmit',
'label' => t('Logging Type'),
'description' => t('The type of logging to utilize.'),
'multiOptions' => array(
'syslog' => 'Syslog',
'file' => t('File'),
'none' => t('None')
)
)
);
if (! isset($formData['logging_log']) || $formData['logging_log'] !== 'none') {
$this->addElement(
'select',
'logging_level',
array(
'required' => true,
'label' => t('Logging Level'),
'description' => t('The maximum logging level to emit.'),
'multiOptions' => array(
Logger::$levels[Logger::ERROR] => t('Error'),
Logger::$levels[Logger::WARNING] => t('Warning'),
Logger::$levels[Logger::INFO] => t('Information'),
Logger::$levels[Logger::DEBUG] => t('Debug')
)
)
);
}
if (isset($formData['logging_log']) && $formData['logging_log'] === 'syslog') {
$this->addElement(
'text',
'logging_application',
array(
'required' => true,
'label' => t('Application Prefix'),
'description' => t('The name of the application by which to prefix syslog messages.'),
'value' => 'icingaweb',
'validators' => array(
array(
'Regex',
false,
array(
'pattern' => '/^[^\W]+$/',
'messages' => array(
'regexNotMatch' => 'The application prefix cannot contain any whitespaces.'
)
)
)
)
)
);
/*
* Note(el): Since we provide only one possible value for the syslog facility, I opt against exposing
* this configuration.
*/
// $this->addElement(
// 'select',
// 'logging_facility',
// array(
// 'required' => true,
// 'label' => t('Facility'),
// 'description' => t('The syslog facility to utilize.'),
// 'multiOptions' => array(
// 'user' => 'LOG_USER'
// )
// )
// );
} elseif (isset($formData['logging_log']) && $formData['logging_log'] === 'file') {
$this->addElement(
'text',
'logging_file',
array(
'required' => true,
'label' => t('File path'),
'description' => t('The full path to the log file to write messages to.'),
'value' => $this->getDefaultLogDir(),
'validators' => array(new WritablePathValidator())
)
);
}
return $this;
}
/**
* Return the default logging directory for type 'file'
*
* @return string
*/
protected function getDefaultLogDir()
{
return realpath(Icinga::app()->getApplicationDir('../var/log/icingaweb.log'));
}
}

View File

@ -0,0 +1,76 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use Icinga\Web\Request;
use Icinga\Web\Notification;
use Icinga\Form\ConfigForm;
use Icinga\Form\Config\General\LoggingConfigForm;
use Icinga\Form\Config\General\ApplicationConfigForm;
/**
* Form class for application-wide and logging specific settings
*/
class GeneralConfigForm extends ConfigForm
{
/**
* Initialize this configuration form
*/
public function init()
{
$this->setName('form_config_general');
$this->setSubmitLabel(t('Save Changes'));
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$appConfigForm = new ApplicationConfigForm();
$loggingConfigForm = new LoggingConfigForm();
$this->addElements($appConfigForm->createElements($formData)->getElements());
$this->addElements($loggingConfigForm->createElements($formData)->getElements());
}
/**
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
$sections = array();
foreach ($this->getValues() as $sectionAndPropertyName => $value) {
list($section, $property) = explode('_', $sectionAndPropertyName);
if (! isset($sections[$section])) {
$sections[$section] = array();
}
$sections[$section][$property] = $value;
}
foreach ($sections as $section => $config) {
$this->config->{$section} = $config;
}
if ($this->save()) {
Notification::success(t('New configuration has successfully been stored'));
} else {
return false;
}
}
/**
* @see Form::onRequest()
*/
public function onRequest(Request $request)
{
$values = array();
foreach ($this->config as $section => $properties) {
foreach ($properties as $name => $value) {
$values[$section . '_' . $name] = $value;
}
}
$this->populate($values);
}
}

View File

@ -1,266 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use Icinga\Application\Config as IcingaConfig;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form;
use Icinga\Util\Translator;
use Icinga\Web\Form\Validator\WritablePathValidator;
use Icinga\Web\Form\Decorator\ConditionalHidden;
use DateTimeZone;
use Zend_Form_Element_Select;
use Zend_Config;
/**
* Configuration form for general, application-wide settings
*/
class GeneralForm extends Form
{
/**
* The base directory of the icingaweb configuration
*
* @var string
*/
private $configDir = null;
/**
* The resources to use instead of the factory provided ones (use for testing)
*
* @var null
*/
private $resources;
/**
* Set a specific configuration directory to use for configuration specific default paths
*
* @param string $dir
*/
public function setConfigDir($dir)
{
$this->configDir = $dir;
}
/**
* Return the config path set for this form or the application wide config path if none is set
*
* @return string
*
* @see IcingaConfig::configDir
*/
public function getConfigDir()
{
return $this->configDir === null ? IcingaConfig::$configDir : $this->configDir;
}
/**
* Set an alternative array of resources that should be used instead of the DBFactory resource set
* (used for testing)
*
* @param array $resources The resources to use for populating the db selection field
*/
public function setResources(array $resources)
{
$this->resources = $resources;
}
/**
* Return content of the resources.ini or previously set resources for displaying in the database selection field
*
* @return array
*/
public function getResources()
{
if ($this->resources === null) {
return ResourceFactory::getResourceConfigs()->toArray();
} else {
return $this->resources;
}
}
/**
* Add a select field for setting the default timezone.
*
* Possible values are determined by DateTimeZone::listIdentifiers
*
* @param Zend_Config $cfg The "global" section of the config.ini
*/
private function addTimezoneSelection(Zend_Config $cfg)
{
$tzList = array();
foreach (DateTimeZone::listIdentifiers() as $tz) {
$tzList[$tz] = $tz;
}
$helptext = 'Select the timezone to be used as the default. User\'s can set their own timezone if'
. ' they like to, but this is the timezone to be used as the default setting .';
$this->addElement(
'select',
'timezone',
array(
'label' => 'Default Application Timezone',
'required' => true,
'multiOptions' => $tzList,
'helptext' => $helptext,
'value' => $cfg->get('timezone', date_default_timezone_get())
)
);
}
/**
* Add configuration settings for module paths
*
* @param Zend_Config $cfg The "global" section of the config.ini
*/
private function addModuleSettings(Zend_Config $cfg)
{
$this->addElement(
'text',
'module_path',
array(
'label' => 'Module Path',
'required' => true,
'helptext' => 'Contains the directories that will be searched for available modules, separated by ' .
' colons. Modules that don\'t exist in these directories can still be symlinked in the module ' .
' folder, but won\'t show up in the list of disabled modules.',
'value' => $cfg->get('modulePath', realpath(ICINGAWEB_APPDIR . '/../modules'))
)
);
}
/**
* Add form elements for setting the user preference storage backend
*
* @param Zend_Config $cfg The Zend_config object of preference section
*/
public function addUserPreferencesDialog(Zend_Config $cfg)
{
$backend = $cfg->get('type', 'ini');
if ($this->getRequest()->get('preferences_type', null) !== null) {
$backend = $this->getRequest()->get('preferences_type');
}
$this->addElement(
'select',
'preferences_type',
array(
'label' => 'User Preference Storage Type',
'required' => true,
'value' => $backend,
'multiOptions' => array(
'ini' => 'File System (INI Files)',
'db' => 'Database',
'null' => 'Don\'t Store Preferences'
)
)
);
$backends = array();
foreach ($this->getResources() as $name => $resource) {
if ($resource['type'] !== 'db') {
continue;
}
$backends[$name] = $name;
}
$txtPreferencesDbResource = new Zend_Form_Element_Select(
array(
'name' => 'preferences_db_resource',
'label' => 'Database Connection',
'required' => $backend === 'db',
'condition' => $backend === 'db',
'value' => $cfg->get('resource'),
'multiOptions' => $backends
)
);
$validator = new WritablePathValidator();
$validator->setRequireExistence();
$this->addElement($txtPreferencesDbResource);
$txtPreferencesDbResource->addDecorator(new ConditionalHidden());
$this->enableAutoSubmit(
array(
'preferences_type'
)
);
}
/**
* Create the general form, using the provided configuration
*
* @see Form::create()
*/
public function create()
{
$config = $this->getConfiguration();
$global = $config->global;
if ($global === null) {
$global = new Zend_Config(array());
}
$preferences = $config->preferences;
if ($preferences === null) {
$preferences = new Zend_Config(array());
}
$this->setName('form_config_general');
$this->addTimezoneSelection($global);
$this->addModuleSettings($global);
$this->addUserPreferencesDialog($preferences);
$this->setSubmitLabel('Save Changes');
}
/**
* Return an Zend_Config object containing the configuration set in this form
*
* @return Zend_Config
*/
public function getConfig()
{
$config = $this->getConfiguration();
if ($config->global === null) {
$config->global = new Zend_Config(array(), true);
}
if ($config->preferences === null) {
$config->preferences = new Zend_Config(array(), true);
}
$values = $this->getValues();
$cfg = clone $config;
$cfg->global->timezone = $values['timezone'];
$cfg->global->modulePath = $values['module_path'];
$cfg->preferences->type = $values['preferences_type'];
if ($cfg->preferences->type === 'db') {
$cfg->preferences->resource = $values['preferences_db_resource'];
}
return $cfg;
}
}
// @codeCoverageIgnoreEnd

View File

@ -1,205 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use \Zend_Config;
use Icinga\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Web\Form\Validator\WritablePathValidator;
/**
* Form class for setting the application wide logging configuration
*/
class LoggingForm extends Form
{
/**
* Return the default logging directory for type "file"
*
* @return string
*/
protected function getDefaultLogDir()
{
return realpath(Icinga::app()->getApplicationDir() . '/../var/log/icingaweb.log');
}
/**
* Create this logging configuration form
*
* @see Form::create()
*/
public function create()
{
$this->setName('form_config_logging');
$config = $this->getConfiguration();
if (($loggingConfig = $config->logging) === null) {
$loggingConfig = new Zend_Config(array());
}
$this->addElement(
'checkbox',
'logging_enable',
array(
'required' => true,
'label' => t('Logging Enabled'),
'helptext' => t('Check this to enable logging.'),
'value' => $loggingConfig->enable ? 1 : 0
)
);
$this->addElement(
'select',
'logging_level',
array(
'required' => true,
'label' => t('Logging Level'),
'helptext' => t('The maximum loglevel to emit.'),
'value' => intval($loggingConfig->get('level', 0)),
'multiOptions' => array(
0 => t('Error'),
1 => t('Warning'),
2 => t('Information'),
3 => t('Debug')
)
)
);
$this->addElement(
'select',
'logging_type',
array(
'required' => true,
'label' => t('Logging Type'),
'helptext' => t('The type of logging to utilize.'),
'value' => $loggingConfig->get('type', 'file'),
'multiOptions' => array(
'file' => t('File'),
'syslog' => 'Syslog'
)
)
);
$this->enableAutoSubmit(array('logging_type'));
switch ($this->getRequest()->getParam('logging_type', $loggingConfig->get('type', 'file')))
{
case 'syslog':
$this->addElement(
'text',
'logging_application',
array(
'required' => true,
'label' => t('Application Prefix'),
'helptext' => t('The name of the application by which to prefix syslog messages.'),
'value' => $loggingConfig->get('application', 'icingaweb'),
'validators' => array(
array(
'Regex',
false,
array(
'pattern' => '/^[^\W]+$/',
'messages' => array(
'regexNotMatch' => 'The application prefix cannot contain any whitespaces.'
)
)
)
)
)
);
$this->addElement(
'select',
'logging_facility',
array(
'required' => true,
'label' => t('Facility'),
'helptext' => t('The Syslog facility to utilize.'),
'value' => $loggingConfig->get('facility', 'LOG_USER'),
'multiOptions' => array(
'LOG_USER' => 'LOG_USER'
)
)
);
break;
case 'file':
default:
$this->addElement(
'text',
'logging_target',
array(
'required' => true,
'label' => t('Filepath'),
'helptext' => t('The logfile to write messages to.'),
'value' => $loggingConfig->target ? $loggingConfig->target : $this->getDefaultLogDir(),
'validators' => array(new WritablePathValidator())
)
);
}
$this->setSubmitLabel('{{SAVE_ICON}} Save Changes');
}
public function isValid($data) {
foreach ($this->getElements() as $key => $element) {
// Initialize all empty elements with their default values.
if (!isset($data[$key])) {
$data[$key] = $element->getValue();
}
}
return parent::isValid($data);
}
/**
* Return a Zend_Config object containing the state defined in this form
*
* @return Zend_Config The config defined in this form
*/
public function getConfig()
{
$values = $this->getValues();
$cfg = $this->getConfiguration()->toArray();
$cfg['logging']['enable'] = $values['logging_enable'] == 1;
$cfg['logging']['level'] = $values['logging_level'];
switch ($values['logging_type'])
{
case 'file':
$cfg['logging']['type'] = 'file';
$cfg['logging']['target'] = $values['logging_target'];
break;
case 'syslog':
$cfg['logging']['type'] = 'syslog';
$cfg['logging']['application'] = $values['logging_application'];
$cfg['logging']['facility'] = $values['logging_facility'];
break;
}
return new Zend_Config($cfg);
}
}
// @codeCoverageIgnoreEnd

View File

@ -0,0 +1,130 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Resource;
use Exception;
use Zend_Config;
use Icinga\Web\Form;
use Icinga\Web\Request;
use Icinga\Web\Form\Element\Number;
use Icinga\Data\ResourceFactory;
/**
* Form class for adding/modifying database resources
*/
class DbResourceForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_resource_db');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'select',
'db',
array(
'required' => true,
'label' => t('Database Type'),
'description' => t('The type of SQL database'),
'multiOptions' => array(
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL'
//'oracle' => 'Oracle'
)
)
);
$this->addElement(
'text',
'host',
array (
'required' => true,
'label' => t('Host'),
'description' => t('The hostname of the database'),
'value' => 'localhost'
)
);
$this->addElement(
new Number(
array(
'required' => true,
'name' => 'port',
'label' => t('Port'),
'description' => t('The port to use'),
'value' => 3306
)
)
);
$this->addElement(
'text',
'dbname',
array(
'required' => true,
'label' => t('Database Name'),
'description' => t('The name of the database to use')
)
);
$this->addElement(
'text',
'username',
array (
'required' => true,
'label' => t('Username'),
'description' => t('The user name to use for authentication')
)
);
$this->addElement(
'password',
'password',
array(
'required' => true,
'renderPassword' => true,
'label' => t('Password'),
'description' => t('The password to use for authentication')
)
);
return $this;
}
/**
* Validate that the current configuration points to a valid resource
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (false === $this->isValidResource($this)) {
return false;
}
}
/**
* Validate the resource configuration by trying to connect with it
*
* @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/
public function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
$resource->getConnection()->getConnection();
} catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,50 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Resource;
use Icinga\Web\Form;
use Icinga\Web\Form\Validator\ReadablePathValidator;
/**
* Form class for adding/modifying file resources
*/
class FileResourceForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_resource_file');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'filename',
array(
'required' => true,
'label' => t('Filepath'),
'description' => t('The filename to fetch information from'),
'validators' => array(new ReadablePathValidator())
)
);
$this->addElement(
'text',
'fields',
array(
'required' => true,
'label' => t('Pattern'),
'description' => t('The regular expression by which to identify columns')
)
);
return $this;
}
}

View File

@ -0,0 +1,116 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Resource;
use Exception;
use Zend_Config;
use Icinga\Web\Form;
use Icinga\Web\Request;
use Icinga\Web\Form\Element\Number;
use Icinga\Data\ResourceFactory;
/**
* Form class for adding/modifying ldap resources
*/
class LdapResourceForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_resource_ldap');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'hostname',
array(
'required' => true,
'label' => t('Host'),
'description' => t('The hostname or address of the LDAP server to use for authentication'),
'value' => 'localhost'
)
);
$this->addElement(
new Number(
array(
'required' => true,
'name' => 'port',
'label' => t('Port'),
'description' => t('The port of the LDAP server to use for authentication'),
'value' => 389
)
)
);
$this->addElement(
'text',
'root_dn',
array(
'required' => true,
'label' => t('Root DN'),
'description' => t('The path where users can be found on the ldap server')
)
);
$this->addElement(
'text',
'bind_dn',
array(
'required' => true,
'label' => t('Bind DN'),
'description' => t('The user dn to use for querying the ldap server')
)
);
$this->addElement(
'password',
'bind_pw',
array(
'required' => true,
'renderPassword' => true,
'label' => t('Bind Password'),
'description' => t('The password to use for querying the ldap server')
)
);
return $this;
}
/**
* Validate that the current configuration points to a valid resource
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (false === $this->isValidResource($this)) {
return false;
}
}
/**
* Validate the resource configuration by trying to connect with it
*
* @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/
public function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
$resource->connect();
} catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,77 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config\Resource;
use Exception;
use Zend_Config;
use Icinga\Web\Form;
use Icinga\Web\Request;
use Icinga\Application\Icinga;
use Icinga\Data\ResourceFactory;
/**
* Form class for adding/modifying livestatus resources
*/
class LivestatusResourceForm extends Form
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_resource_livestatus');
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'socket',
array(
'required' => true,
'label' => t('Socket'),
'description' => t('The path to your livestatus socket used for querying monitoring data'),
'value' => realpath(Icinga::app()->getApplicationDir() . '/../var/rw/livestatus')
)
);
return $this;
}
/**
* Validate that the current configuration points to a valid resource
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (false === $this->isValidResource($this)) {
return false;
}
}
/**
* Validate the resource configuration by trying to connect with it
*
* @param Form $form The form to fetch the configuration values from
*
* @return bool Whether validation succeeded or not
*/
public function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Zend_Config($form->getValues()));
$resource->connect()->disconnect();
} catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,252 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use InvalidArgumentException;
use Icinga\Web\Request;
use Icinga\Web\Notification;
use Icinga\Form\ConfigForm;
use Icinga\Form\Config\Resource\DbResourceForm;
use Icinga\Form\Config\Resource\FileResourceForm;
use Icinga\Form\Config\Resource\LdapResourceForm;
use Icinga\Form\Config\Resource\LivestatusResourceForm;
use Icinga\Application\Platform;
use Icinga\Exception\ConfigurationError;
class ResourceConfigForm extends ConfigForm
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_resource');
$this->setSubmitLabel(t('Save Changes'));
}
/**
* Return a form object for the given resource type
*
* @param string $type The resource type for which to return a form
*
* @return Form
*/
public function getResourceForm($type)
{
if ($type === 'db') {
return new DbResourceForm();
} elseif ($type === 'ldap') {
return new LdapResourceForm();
} elseif ($type === 'livestatus') {
return new LivestatusResourceForm();
} elseif ($type === 'file') {
return new FileResourceForm();
} else {
throw new InvalidArgumentException(sprintf(t('Invalid resource type "%s" provided'), $type));
}
}
/**
* Add a particular resource
*
* The backend to add is identified by the array-key `name'.
*
* @param array $values The values to extend the configuration with
*
* @return self
*
* @thrwos InvalidArgumentException In case the resource does already exist
*/
public function add(array $values)
{
$name = isset($values['name']) ? $values['name'] : '';
if (! $name) {
throw new InvalidArgumentException(t('Resource name missing'));
} elseif ($this->config->{$name} !== null) {
throw new InvalidArgumentException(t('Resource already exists'));
}
unset($values['name']);
$this->config->{$name} = $values;
return $this;
}
/**
* Edit a particular resource
*
* @param string $name The name of the resource to edit
* @param array $values The values to edit the configuration with
*
* @return array The edited configuration
*
* @throws InvalidArgumentException In case the resource does not exist
*/
public function edit($name, array $values)
{
if (! $name) {
throw new InvalidArgumentException(t('Old resource name missing'));
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
throw new InvalidArgumentException(t('New resource name missing'));
} elseif (($resourceConfig = $this->config->get($name)) === null) {
throw new InvalidArgumentException(t('Unknown resource provided'));
}
unset($values['name']);
unset($this->config->{$name});
$this->config->{$newName} = array_merge($resourceConfig->toArray(), $values);
return $this->config->{$newName};
}
/**
* Remove a particular resource
*
* @param string $name The name of the resource to remove
*
* @return array The removed resource configuration
*
* @throws InvalidArgumentException In case the resource does not exist
*/
public function remove($name)
{
if (! $name) {
throw new InvalidArgumentException(t('Resource name missing'));
} elseif (($resourceConfig = $this->config->get($name)) === null) {
throw new InvalidArgumentException(t('Unknown resource provided'));
}
unset($this->config->{$name});
return $resourceConfig;
}
/**
* Add or edit a resource and save the configuration
*
* Performs a connectivity validation using the submitted values. A checkbox is
* added to the form to skip the check if it fails and redirection is aborted.
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
$resourceForm = $this->getResourceForm($this->getElement('type')->getValue());
if (method_exists($resourceForm, 'isValidResource') && false === $resourceForm->isValidResource($this)) {
$this->addElement($this->getForceCreationCheckbox());
return false;
}
}
$resource = $request->getQuery('resource');
try {
if ($resource === null) { // create new resource
$this->add($this->getValues());
$message = t('Resource "%s" has been successfully created');
} else { // edit existing resource
$this->edit($resource, $this->getValues());
$message = t('Resource "%s" has been successfully changed');
}
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
return;
}
if ($this->save()) {
Notification::success(sprintf($message, $this->getElement('name')->getValue()));
} else {
return false;
}
}
/**
* Populate the form in case a resource is being edited
*
* @see Form::onRequest()
*
* @throws ConfigurationError In case the backend name is missing in the request or is invalid
*/
public function onRequest(Request $request)
{
$resource = $request->getQuery('resource');
if ($resource !== null) {
if ($resource === '') {
throw new ConfigurationError(t('Resource name missing'));
} elseif (false === isset($this->config->{$resource})) {
throw new ConfigurationError(t('Unknown resource provided'));
}
$configValues = $this->config->{$resource}->toArray();
$configValues['name'] = $resource;
$this->populate($configValues);
}
}
/**
* Return a checkbox to be displayed at the beginning of the form
* which allows the user to skip the connection validation
*
* @return Zend_Form_Element
*/
protected function getForceCreationCheckbox()
{
return $this->createElement(
'checkbox',
'force_creation',
array(
'order' => 0,
'ignore' => true,
'label' => t('Force Changes'),
'description' => t('Check this box to enforce changes without connectivity validation')
)
);
}
/**
* @see Form::createElemeents()
*/
public function createElements(array $formData)
{
$resourceType = isset($formData['type']) ? $formData['type'] : 'db';
$resourceTypes = array(
'file' => t('File'),
'livestatus' => 'Livestatus',
);
if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) {
$resourceTypes['ldap'] = 'LDAP';
}
if ($resourceType === 'db' || Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) {
$resourceTypes['db'] = t('SQL Database');
}
$this->addElement(
'text',
'name',
array(
'required' => true,
'label' => t('Resource Name'),
'description' => t('The unique name of this resource')
)
);
$this->addElement(
'select',
'type',
array(
'required' => true,
'autosubmit' => true,
'label' => t('Resource Type'),
'description' => t('The type of resource'),
'multiOptions' => $resourceTypes,
'value' => $resourceType
)
);
if (isset($formData['force_creation']) && $formData['force_creation']) {
// In case another error occured and the checkbox was displayed before
$this->addElement($this->getForceCreationCheckbox());
}
$this->addElements($this->getResourceForm($resourceType)->createElements($formData)->getElements());
}
}

View File

@ -1,531 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Config;
use Exception;
use Zend_Config;
use Zend_Form_Element_Checkbox;
use Icinga\Web\Form;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form\Element\Number;
use Icinga\Web\Form\Decorator\HelpText;
class ResourceForm extends Form
{
/**
* The resource
*
* @var Zend_Config
*/
protected $resource;
/**
* The (new) name of the resource
*
* @var string
*/
protected $name;
/**
* The old name of the resource
*
* @var string
*/
protected $oldName;
/**
* Set the current resource name
*
* @param string $name The name to set
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get the current resource name
*
* @return null|string
*/
public function getName()
{
$name = $this->getValue('resource_all_name');
if (!$name) {
return $this->name;
}
return $name;
}
/**
* Set the original name of the resource
*
* @param string $name The name to set
*/
public function setOldName($name)
{
$this->oldName = $name;
}
/**
* Get the resource name that was initially set
*
* @return null|string
*/
public function getOldName()
{
$oldName = $this->getValue('resource_all_name_old');
if (!$oldName) {
return $this->oldName;
}
return $oldName;
}
/**
* Set the resource configuration to edit.
*
* @param Zend_Config $resource The config to set
*/
public function setResource(Zend_Config $resource)
{
$this->resource = $resource;
}
/**
* Get the current resource configuration.
*
* @return Zend_Config
*/
public function getResource()
{
if (!isset($this->resource)) {
$this->resource = new Zend_Config(array('type' => 'db'));
}
return $this->resource;
}
protected function addDbForm()
{
$this->addElement(
'select',
'resource_db_db',
array(
'required' => true,
'label' => t('Database Type'),
'helptext' => t('The type of SQL database you want to create.'),
'value' => $this->getResource()->get('db', 'mysql'),
'multiOptions' => array(
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL'
//'oracle' => 'Oracle'
)
)
);
$this->addElement(
'text',
'resource_db_host',
array (
'required' => true,
'label' => t('Host'),
'helptext' => t('The hostname of the database.'),
'value' => $this->getResource()->get('host', 'localhost')
)
);
$this->addElement(
new Number(
array(
'name' => 'resource_db_port',
'required' => true,
'label' => t('Port'),
'helptext' => t('The port to use.'),
'value' => $this->getResource()->get('port', 3306)
)
)
);
$this->addElement(
'text',
'resource_db_dbname',
array(
'required' => true,
'label' => t('Database Name'),
'helptext' => t('The name of the database to use'),
'value' => $this->getResource()->get('dbname', '')
)
);
$this->addElement(
'text',
'resource_db_username',
array (
'required' => true,
'label' => t('Username'),
'helptext' => t('The user name to use for authentication.'),
'value' => $this->getResource()->get('username', '')
)
);
$this->addElement(
'password',
'resource_db_password',
array(
'required' => true,
'renderPassword' => true,
'label' => t('Password'),
'helptext' => t('The password to use for authentication'),
'value' => $this->getResource()->get('password', '')
)
);
}
protected function addStatusdatForm()
{
$this->addElement(
'text',
'resource_statusdat_status_file',
array(
'required' => true,
'label' => t('Filepath'),
'helptext' => t('Location of your icinga status.dat file'),
'value' => $this->getResource()->get('status_file', '/usr/local/icinga/var/status.dat')
)
);
$this->addElement(
'text',
'resource_statusdat_object_file',
array(
'required' => true,
'label' => t('Filepath'),
'helptext' => t('Location of your icinga objects.cache file'),
'value' => $this->getResource()->get('status_file', '/usr/local/icinga/var/objects.cache')
)
);
}
protected function addLivestatusForm()
{
$this->addElement(
'text',
'resource_livestatus_socket',
array(
'required' => true,
'label' => t('Socket'),
'helptext' => t('The path to your livestatus socket used for querying monitoring data'),
'value' => $this->getResource()->get('socket', '/usr/local/icinga/var/rw/livestatus')
)
);
}
protected function addLdapForm()
{
$this->addElement(
'text',
'resource_ldap_hostname',
array(
'required' => true,
'allowEmpty' => false,
'label' => t('Host'),
'helptext' => t('The hostname or address of the LDAP server to use for authentication'),
'value' => $this->getResource()->get('hostname', 'localhost')
)
);
$this->addElement(
'text',
'resource_ldap_root_dn',
array(
'required' => true,
'label' => t('Root DN'),
'helptext' => t('The path where users can be found on the ldap server'),
'value' => $this->getResource()->get('root_dn', 'ou=people,dc=icinga,dc=org')
)
);
$this->addElement(
'text',
'resource_ldap_bind_dn',
array(
'required' => true,
'label' => t('Bind DN'),
'helptext' => t('The user dn to use for querying the ldap server'),
'value' => $this->getResource()->get('bind_dn', 'cn=admin,cn=config')
)
);
$this->addElement(
'password',
'resource_ldap_bind_pw',
array(
'required' => true,
'renderPassword' => true,
'label' => t('Bind Password'),
'helptext' => t('The password to use for querying the ldap server'),
'value' => $this->getResource()->get('bind_pw', '')
)
);
}
protected function addFileForm()
{
$this->addElement(
'text',
'resource_file_filename',
array(
'required' => true,
'label' => t('Filepath'),
'helptext' => t('The filename to fetch information from'),
'value' => $this->getResource()->get('filename', '')
)
);
$this->addElement(
'text',
'resource_file_fields',
array(
'required' => true,
'label' => t('Pattern'),
'helptext' => t('The regular expression by which to identify columns'),
'value' => $this->getResource()->get('fields', '')
)
);
}
protected function addNameFields()
{
$this->addElement(
'text',
'resource_all_name',
array(
'required' => true,
'label' => t('Resource Name'),
'helptext' => t('The unique name of this resource'),
'value' => $this->getName()
)
);
$this->addElement(
'hidden',
'resource_all_name_old',
array(
'value' => $this->getOldName()
)
);
}
/**
* Add checkbox at the beginning of the form which allows to skip connection validation
*/
protected function addForceCreationCheckbox()
{
$checkbox = new Zend_Form_Element_Checkbox(
array(
'order' => 0,
'name' => 'resource_force_creation',
'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation')
)
);
$checkbox->addDecorator(new HelpText());
$this->addElement($checkbox);
}
/**
* Add a select box for choosing the type to use for this backend
*/
protected function addTypeSelectionBox()
{
$this->addElement(
'select',
'resource_type',
array(
'required' => true,
'label' => t('Resource Type'),
'helptext' => t('The type of resource'),
'value' => $this->getResource()->type,
'multiOptions' => array(
'db' => t('SQL Database'),
'ldap' => 'LDAP',
'statusdat' => 'Status.dat',
'livestatus' => 'Livestatus',
'file' => t('File')
)
)
);
$this->enableAutoSubmit(array('resource_type'));
}
/**
* Validate this form with the Zend validation mechanism and perform a validation of the connection
*
* If validation fails, the 'resource_force_creation' checkbox is prepended to the form to allow users to
* skip the connection validation
*
* @param array $data The form input to validate
*
* @return bool True when validation succeeded, false if not
*/
public function isValid($data)
{
if (!parent::isValid($data)) {
return false;
}
if (isset($data['resource_force_creation']) && $data['resource_force_creation']) {
return true;
}
if (!$this->isValidResource()) {
$this->addForceCreationCheckbox();
return false;
}
return true;
}
/**
* Test if the changed resource is a valid resource, by instantiating it and
* checking if a connection is possible
*
* @return bool True when a connection to the resource is possible
*/
public function isValidResource()
{
$config = $this->getConfig();
try {
switch ($config->type) {
case 'db':
/*
* It should be possible to run icingaweb without the pgsql or mysql extension or Zend-Pdo-Classes,
* in case they aren't actually used. When the user tries to create a resource that depends on an
* uninstalled extension, an error should be displayed.
*/
if ($config->db === 'mysql' && !ResourceFactory::mysqlAvailable()) {
$this->addErrorMessage(
t('You need to install the php extension "mysql" and the ' .
'Zend_Pdo_Mysql classes to use MySQL database resources.')
);
return false;
}
if ($config->db === 'pgsql' && !ResourceFactory::pgsqlAvailable()) {
$this->addErrorMessage(
t('You need to install the php extension "pgsql" and the ' .
'Zend_Pdo_Pgsql classes to use PostgreSQL database resources.')
);
return false;
}
$resource = ResourceFactory::createResource($config);
$resource->getConnection()->getConnection();
break;
case 'statusdat':
if (!file_exists($config->object_file) || !file_exists($config->status_file)) {
$this->addErrorMessage(
t('Connectivity validation failed, the provided file does not exist.')
);
return false;
}
break;
case 'livestatus':
$resource = ResourceFactory::createResource($config);
$resource->connect()->disconnect();
break;
case 'ldap':
$resource = ResourceFactory::createResource($config);
$resource->connect();
break;
case 'file':
if (!file_exists($config->filename)) {
$this->addErrorMessage(
t('Connectivity validation failed, the provided file does not exist.')
);
return false;
}
break;
}
} catch (Exception $e) {
$this->addErrorMessage(t('Connectivity validation failed, connection to the given resource not possible.'));
return false;
}
return true;
}
public function create()
{
$this->addNameFields();
$this->addTypeSelectionBox();
switch ($this->getRequest()->getParam('resource_type', $this->getResource()->type)) {
case 'db':
$this->addDbForm();
break;
case 'statusdat':
$this->addStatusdatForm();
break;
case 'livestatus':
$this->addLivestatusForm();
break;
case 'ldap':
$this->addLdapForm();
break;
case 'file':
$this->addFileForm();
break;
}
$this->setSubmitLabel('{{SAVE_ICON}} Save Changes');
}
/**
* Return a configuration containing the backend settings entered in this form
*
* @return Zend_Config The updated configuration for this backend
*/
public function getConfig()
{
$values = $this->getValues();
$result = array('type' => $values['resource_type']);
foreach ($values as $key => $value) {
if ($key !== 'resource_type' && $key !== 'resource_all_name' && $key !== 'resource_all_name_old') {
$configKey = explode('_', $key, 3);
if (count($configKey) === 3) {
$result[$configKey[2]] = $value;
}
}
}
return new Zend_Config($result);
}
}

View File

@ -0,0 +1,68 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form;
use Exception;
use Icinga\Web\Form;
use Icinga\Application\Config;
use Icinga\File\Ini\IniWriter;
/**
* Form base-class providing standard functionality for configuration forms
*/
class ConfigForm extends Form
{
/**
* The configuration to work with
*
* @var Config
*/
protected $config;
/**
* Set the configuration to use when populating the form or when saving the user's input
*
* @param Config $config The configuration to use
*
* @return self
*/
public function setIniConfig(Config $config)
{
$this->config = $config;
return $this;
}
/**
* Persist the current configuration to disk
*
* If an error occurs the user is shown a view describing the issue and displaying the raw INI configuration.
*
* @return bool Whether the configuration could be persisted
*/
public function save()
{
$writer = new IniWriter(
array(
'config' => $this->config,
'filename' => $this->config->getConfigFile()
)
);
try {
$writer->write();
} catch (Exception $e) {
$this->addDecorator('ViewScript', array(
'viewModule' => 'default',
'viewScript' => 'showConfiguration.phtml',
'errorMessage' => $e->getMessage(),
'configString' => $writer->render(),
'filePath' => $this->config->getConfigFile()
));
return false;
}
return true;
}
}

View File

@ -0,0 +1,22 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form;
use Icinga\Web\Form;
/**
* Form for confirming removal of an object
*/
class ConfirmRemovalForm extends Form
{
/**
* Initalize this form
*/
public function init()
{
$this->setName('form_confirm_removal');
$this->setSubmitLabel(t('Confirm Removal'));
}
}

View File

@ -1,42 +1,12 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Dashboard; namespace Icinga\Form\Dashboard;
use Icinga\Application\Config as IcingaConfig; use Icinga\Application\Config as IcingaConfig;
use Icinga\Web\Form;
use Icinga\Web\Widget\Dashboard; use Icinga\Web\Widget\Dashboard;
use Zend_Form_Element_Text; use Icinga\Web\Form;
use Zend_Form_Element_Submit;
use Zend_Form_Element_Hidden;
use Zend_Form_Element_Select;
/** /**
* Form to add an url a dashboard pane * Form to add an url a dashboard pane
@ -44,125 +14,103 @@ use Zend_Form_Element_Select;
class AddUrlForm extends Form class AddUrlForm extends Form
{ {
/** /**
* Add a selection box for different panes to the form * Initialize this form
*
* @param Dashboard $dashboard The dashboard to retrieve the panes from
*/ */
private function addPaneSelectionBox(Dashboard $dashboard) public function init()
{ {
$selectPane = new Zend_Form_Element_Select( $this->setName('form_dashboard_addurl');
'pane', $this->setSubmitLabel(t('Add To Dashboard'));
array(
'label' => 'Dashboard',
'required' => true,
'style' => 'display:inline-block;',
'multiOptions' => $dashboard->getPaneKeyTitleArray()
)
);
$newDashboardBtn = new Zend_Form_Element_Submit(
'create_new_pane',
array(
'label' => 'Create A New Pane',
'required' => false,
'class' => 'btn btn-default',
'style' => 'display:inline-block'
)
);
$newDashboardBtn->removeDecorator('DtDdWrapper');
$selectPane->removeDecorator('DtDdWrapper');
$selectPane->removeDecorator('htmlTag');
$this->addElement($selectPane);
$this->addElement($newDashboardBtn);
$this->enableAutoSubmit(array('create_new_pane'));
} }
/** /**
* Add a textfield for creating a new pane to this form * @see Form::createElements()
*/ */
private function addNewPaneTextField($showExistingButton = true) public function createElements(array $formData)
{ {
$txtCreatePane = new Zend_Form_Element_Text(
'pane',
array(
'label' => 'New Dashboard Title',
'required' => true,
'style' => 'display:inline-block'
)
);
// Marks this field as a new pane (and prevents the checkbox being displayed when validation errors occur)
$markAsNewPane = new Zend_Form_Element_Hidden(
'create_new_pane',
array(
'required' => true,
'value' => 1
)
);
$cancelDashboardBtn = new Zend_Form_Element_Submit(
'use_existing_dashboard',
array(
'class' => 'btn',
'escape' => false,
'label' => 'Use An Existing Dashboard',
'required' => false
)
);
$cancelDashboardBtn->removeDecorator('DtDdWrapper');
$txtCreatePane->removeDecorator('DtDdWrapper');
$txtCreatePane->removeDecorator('htmlTag');
$this->addElement($txtCreatePane);
if ($showExistingButton) {
$this->addElement($cancelDashboardBtn);
}
$this->addElement($markAsNewPane);
}
/**
* Add elements to this form (used by extending classes)
*/
protected function create()
{
$dashboard = new Dashboard();
$this->setName('form_dashboard_add');
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
$this->addElement( $this->addElement(
'text', 'text',
'url', 'url',
array( array(
'label' => 'Url', 'required' => true,
'required' => true, 'label' => t('Url'),
'value' => htmlspecialchars_decode($this->getRequest()->getParam('url', '')) 'helptext' => t('The url being loaded in the dashlet')
) )
); );
$elems = $dashboard->getPaneKeyTitleArray();
if (empty($elems) || // show textfield instead of combobox when no pane is available $paneSelectionValues = $this->getDashboardPaneSelectionValues();
($this->getRequest()->getPost('create_new_pane', '0') && // or when a new pane should be created (+ button) if (empty($paneSelectionValues) ||
!$this->getRequest()->getPost('use_existing_dashboard', '0')) // and the user didn't click the 'use ((isset($formData['create_new_pane']) && $formData['create_new_pane'] != false) &&
// existing' button (false === isset($formData['use_existing_dashboard']) || $formData['use_existing_dashboard'] != true))
) { ) {
$this->addNewPaneTextField(!empty($elems)); $this->addElement(
'text',
'pane',
array(
'required' => true,
'label' => t("The New Pane's Title"),
'style' => 'display: inline-block'
)
);
$this->addElement( // Prevent the button from being displayed again on validation errors
'hidden',
'create_new_pane',
array(
'value' => 1
)
);
if (false === empty($paneSelectionValues)) {
$this->addElement(
'submit',
'use_existing_dashboard',
array(
'ignore' => true,
'label' => t('Use An Existing Pane'),
'style' => 'display: inline-block'
)
);
}
} else { } else {
$this->addPaneSelectionBox($dashboard); $this->addElement(
'select',
'pane',
array(
'required' => true,
'label' => t('Pane'),
'style' => 'display: inline-block;',
'multiOptions' => $paneSelectionValues
)
);
$this->addElement(
'submit',
'create_new_pane',
array(
'ignore' => true,
'label' => t('Create A New Pane'),
'style' => 'display: inline-block'
)
);
} }
$this->addElement( $this->addElement(
'text', 'text',
'component', 'component',
array( array(
'label' => 'Title', 'required' => true,
'required' => true, 'label' => t('Title'),
'helptext' => t('The title for the dashlet')
) )
); );
$this->setSubmitLabel("Add To Dashboard"); }
/**
* Return the names and titles of the available dashboard panes as key-value array
*
* @return array
*/
protected function getDashboardPaneSelectionValues()
{
$dashboard = new Dashboard();
$dashboard->readConfig(IcingaConfig::app('dashboard/dashboard'));
return $dashboard->getPaneKeyTitleArray();
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,67 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Install;
use Zend_Config;
use Icinga\Web\Wizard\Page;
use Icinga\Form\Config\LoggingForm;
class LoggingPage extends Page
{
/**
* The logging form
*
* @var LoggingForm
*/
protected $loggingForm;
/**
* Initialize this LoggingPage
*/
public function init()
{
$this->setName('logging');
}
/**
* Create and return the logging form
*
* @return LoggingForm
*/
protected function createForm()
{
if ($this->loggingForm === null) {
$this->loggingForm = new LoggingForm();
$this->loggingForm->hideButtons();
$this->loggingForm->setTokenDisabled();
$this->loggingForm->setRequest($this->getRequest());
$this->loggingForm->setConfiguration($this->getConfiguration());
}
return $this->loggingForm;
}
/**
* Create this wizard page
*/
protected function create()
{
$loggingForm = $this->createForm();
$loggingForm->buildForm(); // Needs to get called manually as it's nothing that Zend knows about
$this->addSubForm($loggingForm, $loggingForm->getName());
}
/**
* Return a config containing all values provided by the user
*
* @return Zend_Config
*/
public function getConfig()
{
return $this->createForm()->getConfig();
}
}
// @codeCoverageIgnoreEnd

View File

@ -1,174 +0,0 @@
<?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form\Preference;
use DateTimeZone;
use Zend_Config;
use Zend_Form_Element_Select;
use Icinga\Web\Form;
use Icinga\Util\Translator;
/**
* General user preferences
*/
class GeneralForm extends Form
{
/**
* Add a select field for setting the user's language
*
* Possible values are determined by Translator::getAvailableLocaleCodes.
* Also, a 'use browser language' checkbox is added in order to allow a user to discard his setting
*/
private function addLanguageSelection()
{
$languages = array();
foreach (Translator::getAvailableLocaleCodes() as $language) {
$languages[$language] = $language;
}
$languages[Translator::DEFAULT_LOCALE] = Translator::DEFAULT_LOCALE;
$useBrowserLanguage = $this->getRequest()->getParam(
'browser_language',
!$this->getUserPreferences()->has('app.language')
);
$this->addElement(
'checkbox',
'browser_language',
array(
'label' => t('Use your browser\'s language suggestions'),
'value' => $useBrowserLanguage,
'required' => true
)
);
$selectOptions = array(
'label' => t('Your Current Language'),
'required' => !$useBrowserLanguage,
'multiOptions' => $languages,
'helptext' => t('Use the following language to display texts and messages'),
'value' => substr(setlocale(LC_ALL, 0), 0, 5)
);
if ($useBrowserLanguage) {
$selectOptions['disabled'] = 'disabled';
}
$this->addElement('select', 'language', $selectOptions);
$this->enableAutoSubmit(array('browser_language'));
}
/**
* Add a select field for setting the user's timezone.
*
* Possible values are determined by DateTimeZone::listIdentifiers
* Also, a 'use default format' checkbox is added in order to allow a user to discard his overwritten setting
*
* @param Zend_Config $cfg The "global" section of the config.ini to be used as default value
*/
private function addTimezoneSelection(Zend_Config $cfg)
{
$tzList = array();
foreach (DateTimeZone::listIdentifiers() as $tz) {
$tzList[$tz] = $tz;
}
$helptext = 'Use the following timezone for dates and times';
$prefs = $this->getUserPreferences();
$useGlobalTimezone = $this->getRequest()->getParam('default_timezone', !$prefs->has('app.timezone'));
$selectTimezone = new Zend_Form_Element_Select(
array(
'name' => 'timezone',
'label' => 'Your Current Timezone',
'required' => !$useGlobalTimezone,
'multiOptions' => $tzList,
'helptext' => $helptext,
'value' => $prefs->get('app.timezone', $cfg->get('timezone', date_default_timezone_get()))
)
);
$this->addElement(
'checkbox',
'default_timezone',
array(
'label' => 'Use Default Timezone',
'value' => $useGlobalTimezone,
'required' => true
)
);
if ($useGlobalTimezone) {
$selectTimezone->setAttrib('disabled', 1);
}
$this->addElement($selectTimezone);
$this->enableAutoSubmit(array('default_timezone'));
}
/**
* Create the general form, using the global configuration as fallback values for preferences
*
* @see Form::create()
*/
public function create()
{
$this->setName('form_preference_set');
$config = $this->getConfiguration();
$global = $config->global;
if ($global === null) {
$global = new Zend_Config(array());
}
$this->addLanguageSelection();
$this->addTimezoneSelection($global);
$this->setSubmitLabel('Save Changes');
$this->addElement(
'checkbox',
'show_benchmark',
array(
'label' => 'Use benchmark',
'value' => $this->getUserPreferences()->get('app.show_benchmark')
)
);
}
/**
* Return an array containing the preferences set in this form
*
* @return array
*/
public function getPreferences()
{
$values = $this->getValues();
return array(
'app.language' => $values['browser_language'] ? null : $values['language'],
'app.timezone' => $values['default_timezone'] ? null : $values['timezone'],
'app.show_benchmark' => $values['show_benchmark'] === '1' ? true : false
);
}
}
// @codeCoverageIgnoreEnd

View File

@ -0,0 +1,227 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Form;
use Exception;
use DateTimeZone;
use Icinga\Application\Logger;
use Icinga\User\Preferences;
use Icinga\User\Preferences\PreferencesStore;
use Icinga\Util\TimezoneDetect;
use Icinga\Util\Translator;
use Icinga\Web\Form;
use Icinga\Web\Notification;
use Icinga\Web\Request;
use Icinga\Web\Session;
/**
* Form class to adjust user preferences
*/
class PreferenceForm extends Form
{
/**
* The preferences to work with
*
* @var Preferences
*/
protected $preferences;
/**
* The preference store to use
*
* @var PreferencesStore
*/
protected $store;
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_preferences');
$this->setSubmitLabel(t('Save Changes'));
}
/**
* Set preferences to work with
*
* @param Preferences $preferences The preferences to work with
*
* @return self
*/
public function setPreferences(Preferences $preferences)
{
$this->preferences = $preferences;
return $this;
}
/**
* Set the preference store to use
*
* @param PreferencesStore $store The preference store to use
*
* @return self
*/
public function setStore(PreferencesStore $store)
{
$this->store = $store;
}
/**
* Persist preferences
*
* @return self
*/
public function save()
{
$this->store->load(); // Necessary for patching existing preferences
$this->store->save($this->preferences);
return $this;
}
/**
* Adjust preferences and persist them
*
* @see Form::onSuccess()
*/
public function onSuccess(Request $request)
{
$webPreferences = $this->preferences->get('icingaweb', array());
foreach ($this->getValues() as $key => $value) {
if ($value === null) {
if (isset($webPreferences[$key])) {
unset($webPreferences[$key]);
}
} else {
$webPreferences[$key] = $value;
}
}
$this->preferences->icingaweb = $webPreferences;
// TODO: Is this even necessary in case the session is written on response?
$session = Session::getSession();
$session->user->setPreferences($this->preferences);
$session->write();
try {
$this->save();
Notification::success(t('Preferences successfully saved'));
} catch (Exception $e) {
Logger::error($e);
Notification::error($e->getMessage());
}
}
/**
* Populate preferences
*
* @see Form::onRequest()
*/
public function onRequest(Request $request)
{
$values = $this->preferences->get('icingaweb', array());
$values['browser_language'] = false === isset($values['language']);
$values['local_timezone'] = false === isset($values['timezone']);
$this->populate($values);
}
/**
* @see Form::createElements()
*/
public function createElements(array $formData)
{
$languages = array();
foreach (Translator::getAvailableLocaleCodes() as $language) {
$languages[$language] = $language;
}
$tzList = array();
foreach (DateTimeZone::listIdentifiers() as $tz) {
$tzList[$tz] = $tz;
}
$this->addElement(
'checkbox',
'browser_language',
array(
'ignore' => true,
'required' => true,
'autosubmit' => true,
'value' => true,
'label' => t('Use your browser\'s language suggestions')
)
);
$useBrowserLanguage = isset($formData['browser_language']) ? $formData['browser_language'] == 1 : true;
$languageSelection = $this->createElement(
'select',
'language',
array(
'required' => false === $useBrowserLanguage,
'label' => t('Your Current Language'),
'description' => t('Use the following language to display texts and messages'),
'multiOptions' => $languages,
'value' => substr(setlocale(LC_ALL, 0), 0, 5)
)
);
if ($useBrowserLanguage) {
$languageSelection->setAttrib('disabled', 'disabled');
}
$this->addElement($languageSelection);
$this->addElement(
'checkbox',
'local_timezone',
array(
'ignore' => true,
'required' => true,
'autosubmit' => true,
'value' => true,
'label' => t('Use your local timezone')
)
);
$useLocalTimezone = isset($formData['local_timezone']) ? $formData['local_timezone'] == 1 : true;
$timezoneSelection = $this->createElement(
'select',
'timezone',
array(
'required' => false === $useLocalTimezone,
'label' => t('Your Current Timezone'),
'description' => t('Use the following timezone for dates and times'),
'multiOptions' => $tzList,
'value' => $this->getDefaultTimezone()
)
);
if ($useLocalTimezone) {
$timezoneSelection->setAttrib('disabled', 'disabled');
}
$this->addElement($timezoneSelection);
$this->addElement(
'checkbox',
'show_benchmark',
array(
'required' => true,
'label' => t('Use benchmark')
)
);
}
/**
* Return the current default timezone
*
* @return string
*/
protected function getDefaultTimezone()
{
$detect = new TimezoneDetect();
if ($detect->success()) {
return $detect->getTimezoneName();
} else {
return date_default_timezone_get();
}
}
}

View File

@ -38,7 +38,7 @@ if ($notifications->hasMessages()) {
</div> </div>
<?php endif ?> <?php endif ?>
<div id="main" role="main"> <div id="main" role="main">
<div id="col1" class="container<?= $moduleClass ?>"<?php if ($moduleName): ?> data-icinga-module="<?= $moduleName ?>" <?php endif ?> data-icinga-url="<?= Url::fromRequest() ?>"<?= $refresh ?> style="display: block"> <div id="col1" class="container<?= $moduleClass ?>"<?php if ($moduleName): ?> data-icinga-module="<?= $moduleName ?>" <?php endif ?> data-icinga-url="<?= Url::fromRequest()->without('renderLayout') ?>"<?= $refresh ?> style="display: block">
<?= $this->render('inline.phtml') ?> <?= $this->render('inline.phtml') ?>
</div> </div>
<div id="col2" class="container"> <div id="col2" class="container">

View File

@ -29,21 +29,22 @@ $iframeClass = $isIframe ? ' iframe' : '';
<title><?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?></title> <title><?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?></title>
<!-- TODO: viewport and scale settings make no sense for us, fix this --> <!-- TODO: viewport and scale settings make no sense for us, fix this -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" /> <?php if ($isIframe): ?>
<? if ($isIframe): ?>
<base target="_parent"/> <base target="_parent"/>
<?php else: ?> <?php else: ?>
<script type="text/javascript"> <script type="text/javascript">
(function() { (function() {
var html = document.getElementsByTagName('html')[0]; var html = document.getElementsByTagName('html')[0];
html.className = html.className.replace(/no-js/, 'js'); html.className = html.className.replace(/no-js/, 'js');
}()); }());
</script> </script>
<?php endif ?> <?php endif ?>
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" />
<!-- Respond.js IE8 support of media queries --> <!-- Respond.js IE8 support of media queries -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="<?= $this->baseUrl('js/vendor/respond.min.js');?>"></script> <script src="<?= $this->baseUrl('js/vendor/respond.min.js');?>"></script>
<![endif]--> <![endif]-->
<link type="image/png" rel="shortcut icon" href="<?= $this->baseUrl('img/favicon.png') ?>" />
</head> </head>
<body id="body"> <body id="body">
@ -51,7 +52,6 @@ $iframeClass = $isIframe ? ' iframe' : '';
<div id="layout" class="default-layout"> <div id="layout" class="default-layout">
<?= $this->render('body.phtml') ?> <?= $this->render('body.phtml') ?>
</div> </div>
<?php if (! $isIframe): ?>
<!--[if IE 8]> <!--[if IE 8]>
<script type="text/javascript" src="<?= $this->href($ie8jsfile) ?>"></script> <script type="text/javascript" src="<?= $this->href($ie8jsfile) ?>"></script>
<![endif]--> <![endif]-->
@ -63,6 +63,5 @@ var icinga = new Icinga({
baseUrl: '<?= $this->href('/') ?>' baseUrl: '<?= $this->href('/') ?>'
}); });
</script> </script>
<?php endif ?>
</body> </body>
</html> </html>

View File

@ -1,33 +0,0 @@
<?php
if (! $this->level) {
$this->level = 0;
}
?>
<ul<?= $this->level === 0 ? ' role="navigation"' : '' ?>>
<?php
foreach ($this->items as $item) {
printf(
' <li%s><a href="%s">%s%s</a>',
$this->href($this->url) === $this->href($item->getUrl()) ? ' class="active"' : '',
$item->getUrl() ? $this->href($item->getUrl()) : '#',
$item->getIcon() ? $this->img(
$item->getIcon(),
array('class' => 'icon')
) . ' ' : '',
$this->escape($item->getTitle())
);
if ($item->hasChildren()) {
echo $this->partial(
'parts/menu.phtml',
array('items' => $item->getChildren(), 'url' => $this->url, 'level' => $this->level + 1)
);
}
echo "</li>\n";
}
?>
</ul>

View File

@ -2,22 +2,24 @@
use Icinga\Web\Url; use Icinga\Web\Url;
use Icinga\Web\Menu; use Icinga\Web\Menu;
use Icinga\Web\MenuRenderer;
use Icinga\Web\Widget\SearchDashboard;
// Don't render a menu for unauthenticated users unless menu is auth aware // Don't render a menu for unauthenticated users unless menu is auth aware
if (! $this->auth()->isAuthenticated()) { if (! $this->auth()->isAuthenticated()) {
return; return;
} }
// Current url
$url = Url::fromRequest()->getRelativeUrl();
$menu = Menu::fromConfig();
?> ?>
<div id="menu" data-base-target="_main"> <div
<form action="<?= $this->href('search') ?>" method="get" role="search"> id="menu" data-last-update="<?= (time() - 14) ?>000" data-base-target="_main" class="container" data-icinga-url="<?=$this->href('layout/menu');?>"
<input type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /> data-icinga-refresh="15"
</form> >
<?= $this->partial('parts/menu.phtml', array( <? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
'items' => $menu->getChildren(), <form action="<?= $this->href('search') ?>" method="get" role="search">
'url' => $url <input type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>"
)) ?> autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
</form>
<? endif; ?>
<?= new MenuRenderer(Menu::load(), Url::fromRequest()->without('renderLayout')->getRelativeUrl()); ?>
</div> </div>

Binary file not shown.

View File

@ -5,121 +5,191 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Icinga Web 2 (0.1)\n" "Project-Id-Version: Icinga Web 2 (None)\n"
"Report-Msgid-Bugs-To: dev@icinga.org\n" "Report-Msgid-Bugs-To: dev@icinga.org\n"
"POT-Creation-Date: 2014-05-29 11:12+0000\n" "POT-Creation-Date: 2014-08-22 17:30+0200\n"
"PO-Revision-Date: 2014-05-29 13:19+0100\n" "PO-Revision-Date: 2014-08-22 17:52+0100\n"
"Last-Translator: Thomas Gelf <thomas@gelf.net>\n" "Last-Translator: Thomas Gelf <thomas@gelf.net>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:15
#, php-format
msgid "%d to %d of %d"
msgstr "%d bis %d von %d"
#: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:9 #: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:9
#, php-format #, php-format
msgid "%s: %d to %d of %d" msgid "%s: %d to %d of %d"
msgstr "%s: %d bis %d von %d" msgstr "%s: %d bis %d von %d"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:117 #: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:36
msgid "...and your password"
msgstr "...und dein Kennwort ein"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:132
msgid "Add"
msgstr "Hinzufügen"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:81
msgid "Add filter..."
msgstr "Filter hinzufügen..."
#: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:118
msgid "All configured authentication methods failed. Please check the system log or Icinga Web 2 log for more information."
msgstr "Alle konfigurierten Authentifizierungsmethoden sind fehlgeschlagen. Bitte überprüfe das Systemlog oder jenes von Icinga Web 2 für weitere Details."
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:91
msgid "Application Prefix" msgid "Application Prefix"
msgstr "Anwendungspräfix" msgstr "Anwendungspräfix"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:78 #: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:197
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:80 msgid "ApplicationLog"
msgstr "Anwendungslog"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Form/notyet_FormWizard.php:31
msgid "Back"
msgstr "Zurück"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:53
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:55
msgid "Backend Name" msgid "Backend Name"
msgstr "Backend-Name" msgstr "Backend-Name"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:282 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:257
msgid "Bind DN" msgid "Bind DN"
msgstr "Bind DN" msgstr "Bind DN"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:294 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:269
msgid "Bind Password" msgid "Bind Password"
msgstr "Bind Kennwort" msgstr "Bind Kennwort"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:358 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:333
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:139 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:114
msgid "Check this box to enforce changes without connectivity validation" msgid "Check this box to enforce changes without connectivity validation"
msgstr "Aktiviere dieses Häkchen um die Änderungen ohne Validierung der Verbindung zu speichern" msgstr "Aktiviere dieses Häkchen um die Änderungen ohne Validierung der Verbindung zu speichern"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:73 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:47
msgid "Check this to enable logging." msgid "Check this to enable logging."
msgstr "Aktiviere dieses Häkchen um das Logging zu aktivieren." msgstr "Aktiviere dieses Häkchen um das Logging zu aktivieren."
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:187 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:108
msgid "Click to add a filter expression to this operator"
msgstr "Hier klicken, um einen Filter-Ausdruck zu diesem Operator hinzuzufügen"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:105
msgid "Click to add another operator below this one"
msgstr "Hier klicken, um unterhalb dieses Operators einen weiteren hinzuzufügen"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:97
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:69
msgid "Click to remove this part of your filter"
msgstr "Klicken, um diesen Teil des Filters zu löschen"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:189
msgid "Configuration"
msgstr "Konfiguration"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:165
msgid "Connection Validation Failed: " msgid "Connection Validation Failed: "
msgstr "Überprüfung der Verbindung fehlgeschlagen: " msgstr "Überprüfung der Verbindung fehlgeschlagen: "
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:477 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:452
msgid "Connectivity validation failed, connection to the given resource not possible." msgid "Connectivity validation failed, connection to the given resource not possible."
msgstr "Überprüfung fehlgeschlagen, konnte keine Verbindung zu der angegebenen Ressource herstellen." msgstr "Überprüfung fehlgeschlagen, konnte keine Verbindung zu der angegebenen Ressource herstellen."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:454 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:429
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:470 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:445
msgid "Connectivity validation failed, the provided file does not exist." msgid "Connectivity validation failed, the provided file does not exist."
msgstr "Überprüfung fehlgeschlagen, die angegebene Datei existiert nicht." msgstr "Überprüfung fehlgeschlagen, die angegebene Datei existiert nicht."
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:90 #: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:59
msgid "Could not read your authentiction.ini, no authentication methods are available."
msgstr "Deine authentication.ini konnte nicht gelesen werden, darum sind keine Authentifizierungsmethoden verfügbar."
#: /usr/local/src/bugfix.master/application/layouts/scripts/body.phtml:31
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:175
msgid "Dashboard"
msgstr "Dashboard"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:65
msgid "Database Connection" msgid "Database Connection"
msgstr "Datenbankverbindung" msgstr "Datenbankverbindung"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:183 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:158
msgid "Database Name" msgid "Database Name"
msgstr "Datenbankname" msgstr "Datenbankname"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:144 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:119
msgid "Database Type" msgid "Database Type"
msgstr "Datenbanktyp" msgstr "Datenbanktyp"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:89 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:63
msgid "Debug" msgid "Debug"
msgstr "Debug" msgstr "Debug"
#: /usr/local/src/bugfix.master/application/forms/Config/GeneralForm.php:185 #: /usr/local/src/bugfix.master/application/forms/Config/GeneralForm.php:101
msgid "Default Language" msgid "Default Language"
msgstr "Standardsprache" msgstr "Standardsprache"
#: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:62 #: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:36
#, php-format #, php-format
msgid "Enabling the \"%s\" module might help!" msgid "Enabling the \"%s\" module might help!"
msgstr "Das Modul \"%s\" zu aktivieren könnte helfen!" msgstr "Das Modul \"%s\" zu aktivieren könnte helfen!"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:86 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:60
msgid "Error" msgid "Error"
msgstr "Fehler" msgstr "Fehler"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:139 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:109
msgid "Expression"
msgstr "Ausdruck"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:113
msgid "Facility" msgid "Facility"
msgstr "Facility" msgstr "Facility"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:102 #: /usr/local/src/bugfix.master/application/controllers/PreferenceController.php:55
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:383 #, php-format
msgid "Failed to persist preferences. (%s)"
msgstr "Persistierung der Einstellungen fehlgeschlagen. (%s)"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:76
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:358
msgid "File" msgid "File"
msgstr "Datei" msgstr "Datei"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:155 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:129
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:220 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:195
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:231 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:206
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:308 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:283
msgid "Filepath" msgid "Filepath"
msgstr "Dateipfad" msgstr "Dateipfad"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:357 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:90
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:138 msgid "Filter this list"
msgstr "Diese Liste filtern"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:94
msgid "Filtered"
msgstr "Gefiltert"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Form/notyet_FormWizard.php:32
msgid "Finish"
msgstr "Fertigstellen"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:332
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:113
msgid "Force Changes" msgid "Force Changes"
msgstr "Änderungen erzwingen" msgstr "Änderungen erzwingen"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Form/notyet_QuickForm.php:147
msgid "Form has successfully been sent"
msgstr "Das Formular wurde erfolgreich versendet"
#: /usr/local/src/bugfix.master/application/views/scripts/search/hint.phtml:7 #: /usr/local/src/bugfix.master/application/views/scripts/search/hint.phtml:7
msgid "Hint" msgid "Hint"
msgstr "Hinweis" msgstr "Hinweis"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:160 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:135
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:260 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:235
msgid "Host" msgid "Host"
msgstr "Host" msgstr "Host"
@ -132,165 +202,183 @@ msgstr "Hosts"
msgid "I'm ready to search, waiting for your input" msgid "I'm ready to search, waiting for your input"
msgstr "Ich bin bereit zur Suche, warte auf deine Eingabe" msgstr "Ich bin bereit zur Suche, warte auf deine Eingabe"
#: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:63 #: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:40
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/login.phtml:8 #: /usr/local/src/bugfix.master/application/views/scripts/authentication/login.phtml:8
msgid "Icingaweb Login" msgid "Icingaweb Login"
msgstr "Icingaweb Anmeldung" msgstr "Icingaweb Anmeldung"
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:17 #: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:14
msgid "If this message does not disappear, it might be necessary to quit the current session manually by clearing the cache, or by closing the current browser session." msgid "If this message does not disappear, it might be necessary to quit the current session manually by clearing the cache, or by closing the current browser session."
msgstr "Wenn diese Nachricht nicht verschwindet könnte es nötig sein die aktuelle Sitzung manuell zu beenden indem der Cache gelöscht order die Browsersitzung geschlossen wird." msgstr "Wenn diese Nachricht nicht verschwindet könnte es nötig sein die aktuelle Sitzung manuell zu beenden indem der Cache gelöscht order die Browsersitzung geschlossen wird."
#: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:118 #: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:131
msgid "Incorrect username or password" msgid "Incorrect username or password"
msgstr "Benutzername oder Kennwort ungültig" msgstr "Benutzername oder Kennwort ungültig"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:88 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:62
msgid "Information" msgid "Information"
msgstr "Information" msgstr "Information"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:337 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:67
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:380
msgid "Install"
msgstr "Installieren"
#: /usr/local/src/bugfix.master/application/views/scripts/install/index.phtml:29
msgid "Installation"
msgstr "Installation"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:92
msgid "LDAP Resource" msgid "LDAP Resource"
msgstr "LDAP Ressource" msgstr "LDAP Ressource"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:115 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:90
msgid "LDAP User Name Attribute" msgid "LDAP User Name Attribute"
msgstr "LDAP-Attribut für Benutzername" msgstr "LDAP-Attribut für Benutzername"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:104 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:79
msgid "LDAP User Object Class" msgid "LDAP User Object Class"
msgstr "LDAP Objektklasse für Benutzer" msgstr "LDAP Objektklasse für Benutzer"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:232 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:207
msgid "Location of your icinga objects.cache file" msgid "Location of your icinga objects.cache file"
msgstr "Pfad zur Datei objects.cache von Icinga" msgstr "Pfad zur Datei objects.cache von Icinga"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:221 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:196
msgid "Location of your icinga status.dat file" msgid "Location of your icinga status.dat file"
msgstr "Pfad zur Datei status.dat von Icinga" msgstr "Pfad zur Datei status.dat von Icinga"
#: /usr/local/src/bugfix.master/application/controllers/InstallController.php:69 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:46
msgid "Logging"
msgstr "Logging"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:72
msgid "Logging Enabled" msgid "Logging Enabled"
msgstr "Logging aktiv" msgstr "Logging aktiv"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:82 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:56
msgid "Logging Level" msgid "Logging Level"
msgstr "Log-Level" msgstr "Log-Level"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:98 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:72
msgid "Logging Type" msgid "Logging Type"
msgstr "Logging-Typ" msgstr "Logging-Typ"
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:15 #: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:12
msgid "Logging out..." msgid "Logging out..."
msgstr "Abmelden..." msgstr "Abmelden..."
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:28 #: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:21
msgid "Login" msgid "Login"
msgstr "Anmelden" msgstr "Anmelden"
#: /usr/local/src/bugfix.master/application/layouts/scripts/body.phtml:39
#: /usr/local/src/bugfix.master/application/layouts/scripts/parts/topbar.phtml:35 #: /usr/local/src/bugfix.master/application/layouts/scripts/parts/topbar.phtml:35
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:202
msgid "Logout" msgid "Logout"
msgstr "Abmelden" msgstr "Abmelden"
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:64 #: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:43
msgid "Logout not possible, it may be necessary to quit the session manually by clearing the cache, or closing the current browser session. Error: "
msgstr ""
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:69
msgid "Logout successful!" msgid "Logout successful!"
msgstr "Abmelden erfolgreich!" msgstr "Abmelden erfolgreich!"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/ReorderForm.php:137 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:235
msgid "Move down in authentication order" #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:95
msgstr "" msgid "Modify this filter"
msgstr "Diesen Filter bearbeiten"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/ReorderForm.php:111 #: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:193
msgid "Modules"
msgstr "Module"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/ReorderForm.php:112
msgid "Move down in authentication order"
msgstr "In der Authentifizierungsreihenfolge nach unten schieben"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/ReorderForm.php:86
msgid "Move up in authentication order" msgid "Move up in authentication order"
msgstr "" msgstr "In der Authentifizierungsreihenfolge nach oben schieben"
#: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:16 #: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:16
msgid "Navigation" msgid "Navigation"
msgstr "Navigation" msgstr "Navigation"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:83
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:86 #: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:86
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:337 #: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:89
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:380 #: /usr/local/src/bugfix.master/library/Icinga/Web/Form/notyet_FormWizard.php:30
msgid "Next" msgid "Next"
msgstr "Weiter" msgstr "Weiter"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:144 #: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:110
msgid "No users found under the specified database backend" msgid "No authentication methods available. Did you create authentication.ini when installing Icinga Web 2?"
msgstr "" msgstr "Keine Authentifizierungsmethode verfügbar. Hast du beim Installieren von Icinga Web 2 eine authentication.ini erstellt?"
#: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:59 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:119
msgid "No users found under the specified database backend"
msgstr "Im konfigurierten Datenbankbackend wurden keine Benutzer gefunden"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:106
msgid "Operator"
msgstr "Operator"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:33
msgid "Page"
msgstr "Seite"
#: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:33
msgid "Page not found." msgid "Page not found."
msgstr "Seite nicht gefunden." msgstr "Seite nicht gefunden."
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:65 #: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:12
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:206 msgid "Pagination"
msgstr "Seitennavigation"
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:35
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:181
msgid "Password" msgid "Password"
msgstr "Kennwort" msgstr "Kennwort"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:319 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:294
msgid "Pattern" msgid "Pattern"
msgstr "Muster" msgstr "Muster"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Form/Element/Number.php:61 #: /usr/local/src/bugfix.master/library/Icinga/Web/Form/Element/Number.php:36
msgid "Please enter a number." msgid "Please enter a number."
msgstr "Bitte eine Nummer eingeben." msgstr "Bitte eine Nummer eingeben."
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:25
msgid "Please enter your username..."
msgstr "Bitte gib deinen Benutzernamen..."
#: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:126
msgid "Please note that not all authentication methods where available. Check the system log or Icinga Web 2 log for more information."
msgstr "Beachte bitte dass nicht alle Authentifizierungsmethoden verfügbar waren. Überprüfe das Systemlog oder jenes von Icinga Web 2 für weitere Informationen."
#: /usr/local/src/bugfix.master/application/views/scripts/search/hint.phtml:8 #: /usr/local/src/bugfix.master/application/views/scripts/search/hint.phtml:8
msgid "Please use the asterisk (*) as a placeholder for wildcard searches. For convenience I'll always add a wildcard after the last character you typed." msgid "Please use the asterisk (*) as a placeholder for wildcard searches. For convenience I'll always add a wildcard after the last character you typed."
msgstr "Bitte benutze das Sternchen (*) als Jokerzeichen für eine Suche mit Platzhaltern. Der Einfachheit halber hänge ich immer einen Platzhalter hinter das letzte von dir getippte Zeichen." msgstr "Bitte benutze das Sternchen (*) als Jokerzeichen für eine Suche mit Platzhaltern. Der Einfachheit halber hänge ich immer einen Platzhalter hinter das letzte von dir getippte Zeichen."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:171 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:146
msgid "Port" msgid "Port"
msgstr "Port" msgstr "Port"
#: /usr/local/src/bugfix.master/application/layouts/scripts/body.phtml:38
#: /usr/local/src/bugfix.master/application/layouts/scripts/parts/topbar.phtml:32 #: /usr/local/src/bugfix.master/application/layouts/scripts/parts/topbar.phtml:32
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:185
msgid "Preferences" msgid "Preferences"
msgstr "Einstellungen" msgstr "Einstellungen"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:45 #: /usr/local/src/bugfix.master/application/controllers/PreferenceController.php:48
msgid "Preferences updated successfully"
msgstr "Einstellungen erfolgreich aktualisiert"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:48 #: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:48
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:51
msgid "Prev" msgid "Prev"
msgstr "Zurück" msgstr "Zurück"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:326 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:99
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:367 msgid "Remove this filter"
msgid "Previous" msgstr "Diesen Filter entfernen"
msgstr "Vorheriges"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:333 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:308
msgid "Resource Name" msgid "Resource Name"
msgstr "" msgstr "Ressourcename"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:375 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:350
msgid "Resource Type" msgid "Resource Type"
msgstr "" msgstr "Ressourcetyp"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:271 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:246
msgid "Root DN" msgid "Root DN"
msgstr "Wurzel-DN" msgstr "Wurzel-DN"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:379 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:354
msgid "SQL Database" msgid "SQL Database"
msgstr "SQL Datenbank" msgstr "SQL Datenbank"
@ -301,187 +389,241 @@ msgstr "SQL Datenbank"
msgid "Search" msgid "Search"
msgstr "Suche" msgstr "Suche"
#: /usr/local/src/bugfix.master/application/layouts/scripts/parts/navigation.phtml:17 #: /usr/local/src/bugfix.master/application/layouts/scripts/parts/navigation.phtml:15
msgid "Search..." msgid "Search..."
msgstr "Suche..." msgstr "Suche..."
#: /usr/local/src/bugfix.master/application/forms/Config/GeneralForm.php:189 #: /usr/local/src/bugfix.master/library/Icinga/Web/Form/Validator/notyet_CsrfTokenValidator.php:20
msgid "Security check failed, please submit your form again"
msgstr "Sicherheitscheck fehlgeschlagen, bitte sende das Formular erneut ab"
#: /usr/local/src/bugfix.master/application/forms/Config/GeneralForm.php:105
msgid "Select the language to use by default. Can be overwritten by a user in his preferences." msgid "Select the language to use by default. Can be overwritten by a user in his preferences."
msgstr "" msgstr "Die zu benutzende Standard-Sprache. Kann von Benutzern in deren Einstellungen überschrieben werden."
#: /usr/local/src/bugfix.master/application/controllers/SearchController.php:41 #: /usr/local/src/bugfix.master/application/controllers/SearchController.php:41
#: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:34 #: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:34
msgid "Services" msgid "Services"
msgstr "Services" msgstr "Services"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:245 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/Limiter.php:84
#, php-format
msgid "Show %s rows on one page"
msgstr "Zeige %s Zeilen pro Seite"
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:16
#, php-format
msgid "Show rows %d to %d of %d"
msgstr "Zeige die Zeilen %d bis %d von %d"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:220
msgid "Socket" msgid "Socket"
msgstr "" msgstr "Socket"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:140 #: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:22
msgid "State"
msgstr "Status"
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:181
msgid "System"
msgstr "System"
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/login.phtml:4
msgid "The Icinga logo"
msgstr "Das Icinga Logo"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:114
msgid "The Syslog facility to utilize." msgid "The Syslog facility to utilize."
msgstr "" msgstr "Die zu benutzende Syslog-Facility"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:116 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:91
msgid "The attribute name used for storing the user name on the ldap server" msgid "The attribute name used for storing the user name on the ldap server"
msgstr "" msgstr "Der Attributname welcher benutzt wird, um Benutzernamen auf dem LDAP-Server abzulegen"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:91 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:66
msgid "The database connection to use for authenticating with this provider" msgid "The database connection to use for authenticating with this provider"
msgstr "" msgstr "Die Datenbankverbindung, welche zur Authentifizierung mit diesem Provider genutzt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:309 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:284
msgid "The filename to fetch information from" msgid "The filename to fetch information from"
msgstr "" msgstr "Die Datei aus welcher Informationen gelesen werden sollen"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:161 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:136
msgid "The hostname of the database." msgid "The hostname of the database."
msgstr "" msgstr "Der Hostname der Datenbank."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:261 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:236
msgid "The hostname or address of the LDAP server to use for authentication" msgid "The hostname or address of the LDAP server to use for authentication"
msgstr "" msgstr "Der Hostname oder die IP-Adresse des LDAP-Servers der zur Authentifizierung genutzt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:156 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:130
msgid "The logfile to write messages to." msgid "The logfile to write messages to."
msgstr "" msgstr "Das Logfile in welches Nachrichten geschrieben werden sollen."
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:83 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:57
msgid "The maximum loglevel to emit." msgid "The maximum loglevel to emit."
msgstr "" msgstr "Loglevel bis zu welchem Nachrichten ausgegeben werden sollen."
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:118 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:92
msgid "The name of the application by which to prefix syslog messages." msgid "The name of the application by which to prefix syslog messages."
msgstr "" msgstr "Der Anwendungsname welcher Syslog-Nachrichten vorangestellt werden soll."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:184 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:159
msgid "The name of the database to use" msgid "The name of the database to use"
msgstr "" msgstr "Der Name der zu benutzenden Datenbank"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:81 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:56
msgid "The name of this authentication backend" msgid "The name of this authentication backend"
msgstr "" msgstr "Der Name dieses Authentifizierungsbackends"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:79 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:54
msgid "The name of this authentication provider" msgid "The name of this authentication provider"
msgstr "" msgstr "Der Name dieses Authentifizierungsproviders"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:105 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:80
msgid "The object class used for storing users on the ldap server" msgid "The object class used for storing users on the ldap server"
msgstr "" msgstr "Die Objekt-Klasse welche benutzt wird, um Benutzer auf diesem LDAP-Server abzulegen"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:207 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:182
msgid "The password to use for authentication" msgid "The password to use for authentication"
msgstr "" msgstr "Das Kennwort welches zur Authentifizierung benutzt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:270
msgid "The password to use for querying the ldap server"
msgstr "Das Kennwort welches zum Abfragen des LDAP-Servers benutzt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:221
msgid "The path to your livestatus socket used for querying monitoring data"
msgstr "Der Pfad zu deinem Live-Status Socket, über welchen Monitoring-Daten abgefragt werden sollen"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:247
msgid "The path where users can be found on the ldap server"
msgstr "Der Pfad unter welchem Benutzer auf diesem LDAP-Server gefunden werden können."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:147
msgid "The port to use."
msgstr "Der zu benutzende Port."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:295 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:295
msgid "The password to use for querying the ldap server"
msgstr ""
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:246
msgid "The path to your livestatus socket used for querying monitoring data"
msgstr ""
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:272
msgid "The path where users can be found on the ldap server"
msgstr ""
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:172
msgid "The port to use."
msgstr ""
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:320
msgid "The regular expression by which to identify columns" msgid "The regular expression by which to identify columns"
msgstr "" msgstr "Der zu benutzende reguläre Ausdruck, mit welchem Spalten identifiziert werden können"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:93 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:68
msgid "The resource to use for authenticating with this provider" msgid "The resource to use for authenticating with this provider"
msgstr "" msgstr "Die Resource die zum Authentifizieren mit diesem Provider genutzt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:145 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:120
msgid "The type of SQL database you want to create." msgid "The type of SQL database you want to create."
msgstr "" msgstr "Der Typ der zu benutzenden SQL Datenbank."
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:99 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:73
msgid "The type of logging to utilize." msgid "The type of logging to utilize."
msgstr "" msgstr "Der Typ des zu benutzenden Loggings."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:376 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:351
msgid "The type of resource" msgid "The type of resource"
msgstr "" msgstr "Der Typ der Ressource"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:334 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:309
msgid "The unique name of this resource" msgid "The unique name of this resource"
msgstr "" msgstr "Der eindeutige Name dieser Resource"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:283 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:258
msgid "The user dn to use for querying the ldap server" msgid "The user dn to use for querying the ldap server"
msgstr "" msgstr "Die DN des Benutzers mit welchem dieser LDAP-Server befragt werden soll"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:195 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:170
msgid "The user name to use for authentication." msgid "The user name to use for authentication."
msgstr "" msgstr "Der zur Authentifizierung zu benutzende Benutzername."
#: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:6 #: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:6
msgid "There is no such module installed." msgid "There is no such module installed."
msgstr "Gegenwärtig ist kein solches Modul installiert." msgstr "Gegenwärtig ist kein solches Modul installiert."
#: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:32 #: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:46
msgid "This module has no dependencies" msgid "This module has no dependencies"
msgstr "Dieses Modul hat keine Abhängigkeiten" msgstr "Dieses Modul hat keine Abhängigkeiten"
#: /usr/local/src/bugfix.master/library/Icinga/Application/Modules/Module.php:383 #: /usr/local/src/bugfix.master/library/Icinga/Application/Modules/Module.php:435
msgid "This module has no description" msgid "This module has no description"
msgstr "Dieses Modul hat keine Beschreibung" msgstr "Dieses Modul hat keine Beschreibung"
#: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:100 #: /usr/local/src/bugfix.master/application/views/scripts/config/devtools.phtml:5
msgid "UI Debug"
msgstr "UI Debug"
#: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:43
msgid "Use Default Language" msgid "Use Default Language"
msgstr "Standardsprache verwenden" msgstr "Standardsprache verwenden"
#: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:109 #: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:52
msgid "Use the following language to display texts and messages" msgid "Use the following language to display texts and messages"
msgstr "" msgstr "Die folgende Sprache benutzen, um Texte und Nachrichten anzuzeigen"
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:57 #: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:24
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:194 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:169
msgid "Username" msgid "Username"
msgstr "Benutzername" msgstr "Benutzername"
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:169 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:144
msgid "Using ldap is not possible, the php extension \"ldap\" is not installed." msgid "Using ldap is not possible, the php extension \"ldap\" is not installed."
msgstr "" msgstr "Es ist nicht möglich, LDAP zu benutzen, da die PHP-Erweiterung \"LDAP\" nicht installiert ist."
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:148 #: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:123
#, php-format #, php-format
msgid "Using the specified backend failed: %s" msgid "Using the specified backend failed: %s"
msgstr "" msgstr "Die angegebene Datenbank zu benutzen war nicht möglich: %s"
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:87 #: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:61
msgid "Warning" msgid "Warning"
msgstr "Warnung" msgstr "Warnung"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:435 #: /usr/local/src/bugfix.master/application/views/scripts/dashboard/index.phtml:13
msgid "We tried to load a dashboard configuration with no success. Please have look that the configuration does exist:"
msgstr "Der Versuch die Dashboard-Konfiguration zu laden war nicht erfolgreich. Bitte stelle sicher, dass die folgende Konfigurationsdatei existiert:"
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:410
msgid "You need to install the php extension \"mysql\" and the Zend_Pdo_Mysql classes to use MySQL database resources." msgid "You need to install the php extension \"mysql\" and the Zend_Pdo_Mysql classes to use MySQL database resources."
msgstr "" msgstr "Um MySQL Datenbank-Ressourcen nutzen zu können müssen die PHP-Erweiterung \"mysql\" sowie die Zend_Pdo_Mysql Klassen installiert sein."
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:442 #: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:417
msgid "You need to install the php extension \"pgsql\" and the Zend_Pdo_Pgsql classes to use PostgreSQL database resources." msgid "You need to install the php extension \"pgsql\" and the Zend_Pdo_Pgsql classes to use PostgreSQL database resources."
msgstr "" msgstr "Um PostgreSQL Datenbank-Ressourcen nutzen zu können müssen die PHP-Erweiterung \"pqsql\" sowie die Zend_Pdo_Pgsql Klassen installiert sein."
#: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:106 #: /usr/local/src/bugfix.master/application/forms/Preference/GeneralForm.php:49
msgid "Your Current Language" msgid "Your Current Language"
msgstr "Deine aktuelle Sprache" msgstr "Deine aktuelle Sprache"
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:108 #: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/Limiter.php:58
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:114 msgid "all"
msgstr "alle"
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:83
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:89
msgid "for" msgid "for"
msgstr "für" msgstr "für"
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:112 #: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:87
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:131 #: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:106
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:133 #: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:108
msgid "since" msgid "since"
msgstr "seit" msgstr "seit"
#: /usr/local/src/bugfix.master/application/views/scripts/config/devtools.phtml:5
msgid "toggle"
msgstr "umschalten"
#~ msgid "%d to %d of %d"
#~ msgstr "%d bis %d von %d"
#~ msgid "Installation"
#~ msgstr "Installation"
#~ msgid "Logging"
#~ msgstr "Logging"
#~ msgid "Previous"
#~ msgstr "Vorheriges"
#~ msgid "Icinga Users Login" #~ msgid "Icinga Users Login"
#~ msgstr "Icinga Benutzeranmeldung" #~ msgstr "Icinga Benutzeranmeldung"

View File

@ -1,36 +1,9 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Application\Config;
use Icinga\Util\DateTimeFactory; use Icinga\Util\DateTimeFactory;
use Icinga\Web\Form\Validator\DateTimeValidator;
/** /**
* Helper to format date and time. Utilizes DateTimeFactory to ensure time zone awareness * Helper to format date and time. Utilizes DateTimeFactory to ensure time zone awareness
@ -83,7 +56,7 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract
public function format($timestamp, $format) public function format($timestamp, $format)
{ {
$dt = DateTimeFactory::create(); $dt = DateTimeFactory::create();
if (DateTimeValidator::isUnixTimestamp($timestamp)) { if (DateTimeFactory::isUnixTimestamp($timestamp)) {
$dt->setTimestamp($timestamp); $dt->setTimestamp($timestamp);
} else { } else {
return $timestamp; return $timestamp;
@ -134,10 +107,8 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract
*/ */
public function getDateFormat() public function getDateFormat()
{ {
return $this->request->getUser()->getPreferences()->get( // TODO(mh): Missing localized format (#6077)
'app.dateFormat', return 'd/m/Y';
Config::app()->global !== null ? Config::app()->global->get('dateFormat', 'd/m/Y') : 'd/m/Y'
);
} }
/** /**
@ -147,10 +118,8 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract
*/ */
public function getTimeFormat() public function getTimeFormat()
{ {
return $this->request->getUser()->getPreferences()->get( // TODO(mh): Missing localized format (#6077)
'app.timeFormat', return 'g:i A';
Config::app()->global !== null ? Config::app()->global->get('timeFormat', 'g:i A') : 'g:i A'
);
} }
/** /**

View File

@ -1,45 +1,31 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use \Zend_View_Helper_FormElement;
/** /**
* Helper to generate a "datetime" element * Render date-and-time input controls
*/ */
class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement
{ {
/** /**
* Generate a 'datetime' element * Format date and time
*
* @param DateTime $dateTime
* @param bool $local
*
* @return string
*/
public function formatDate(DateTime $dateTime, $local)
{
$format = (bool) $local === true ? 'Y-m-d\TH:i:s' : DateTime::RFC3339;
return $dateTime->format($format);
}
/**
* Render the date-and-time input control
* *
* @param string $name The element name * @param string $name The element name
* @param int $value The default timestamp * @param DateTime $value The default timestamp
* @param array $attribs Attributes for the element tag * @param array $attribs Attributes for the element tag
* *
* @return string The element XHTML * @return string The element XHTML
@ -47,51 +33,41 @@ class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement
public function formDateTime($name, $value = null, $attribs = null) public function formDateTime($name, $value = null, $attribs = null)
{ {
$info = $this->_getInfo($name, $value, $attribs); $info = $this->_getInfo($name, $value, $attribs);
extract($info); // name, value, attribs, options, listsep, disable extract($info); // name, id, value, attribs, options, listsep, disable
// Is it disabled? /** @var string $id */
/** @var bool $disable */
$disabled = ''; $disabled = '';
if ($disabled) { if ($disable) {
$disabled = ' disabled="disabled"'; $disabled = ' disabled="disabled"';
} }
if ($value instanceof DateTime) {
$jspicker = (isset($attribs['jspicker']) && $attribs['jspicker'] === true) ? true : false; // If value was valid, it's a DateTime object
$value = $this->formatDate($value, $attribs['local']);
if (isset($value) && !empty($value)) {
if ($jspicker) {
$value = ' value="' . $this->view->dateFormat()->format($value, $attribs['defaultFormat']) . '"';
} else {
$value = ' value="' . $this->view->dateFormat()->formatDateTime($value) . '"';
}
} else {
$value = '';
} }
$min = '';
// Build the element if (! empty($attribs['min'])) {
$xhtml = '<div class="datetime' . (($jspicker === true) ? ' input-group' : ''). '">'; $min = sprintf(' min="%s"', $this->formatDate($attribs['min'], $attribs['local']));
$xhtml .= '<input type="text" name="' . $name . '"'
. ' id="' . $name . '"'
. $value
. $disabled
. $this->_htmlAttribs($attribs);
if ($jspicker === true) {
$xhtml .= 'data-icinga-component="app/datetime"';
} }
unset($attribs['min']); // Unset min to not render it again in $this->_htmlAttribs($attribs)
$xhtml .= $this->getClosingBracket(); $max = '';
if (! empty($attribs['max'])) {
if ($jspicker === true) { $max = sprintf(' max="%s"', $this->formatDate($attribs['max'], $attribs['local']));
$xhtml .= '<span class="input-group-addon">'
. '<a href="#">'
. '<i class="icinga-icon-reschedule"></i>'
. '</a>'
. '</span>';
} }
unset($attribs['max']); // Unset max to not render it again in $this->_htmlAttribs($attribs)
$xhtml .= '</div>'; $type = $attribs['local'] === true ? 'datetime-local' : 'datetime';
unset($attribs['local']); // Unset local to not render it again in $this->_htmlAttribs($attribs)
return $xhtml; $html5 = sprintf(
'<input type="%s" name="%s" id="%s" value="%s"%s%s%s%s%s',
$type,
$this->view->escape($name),
$this->view->escape($id),
$this->view->escape($value),
$min,
$max,
$disabled,
$this->_htmlAttribs($attribs),
$this->getClosingBracket()
);
return $html5;
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,57 +1,80 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use \Zend_View_Helper_FormElement;
/** /**
* Helper to generate a number input * Render number input controls
*/ */
class Zend_View_Helper_FormNumber extends \Zend_View_Helper_FormText class Zend_View_Helper_FormNumber extends Zend_View_Helper_FormElement
{ {
/** /**
* Generates a html number input * Format a number
* *
* @access public * @param $number
* *
* @param string $name The element name. * @return string
* @param string $value The default value. */
* @param array $attribs Attributes which should be added to the input tag. public function formatNumber($number)
{
if (empty($number)) {
return $number;
}
return $this->view->escape(
sprintf(
ctype_digit((string) $number) ? '%d' : '%F',
$number
)
);
}
/**
* Render the number input control
* *
* @return string The input tag and options XHTML. * @param string $name
* @param int $value
* @param array $attribs
*
* @return string The rendered number input control
*/ */
public function formNumber($name, $value = null, $attribs = null) public function formNumber($name, $value = null, $attribs = null)
{ {
return '<input type="number"' $info = $this->_getInfo($name, $value, $attribs);
. ' name="' . $this->view->escape($name) . '"' extract($info); // name, id, value, attribs, options, listsep, disable
. ' value="' . $this->view->escape($value) . '"' /** @var string $id */
. ' id="' . $this->view->escape($name) . '"' /** @var bool $disable */
. $this->_htmlAttribs($attribs) $disabled = '';
. $this->getClosingBracket(); if ($disable) {
$disabled = ' disabled="disabled"';
}
$min = '';
if (isset($attribs['min'])) {
$min = sprintf(' min="%s"', $this->formatNumber($attribs['min']));
}
unset($attribs['min']); // Unset min to not render it again in $this->_htmlAttribs($attribs)
$max = '';
if (isset($attribs['max'])) {
$max = sprintf(' max="%s"', $this->formatNumber($attribs['max']));
}
unset($attribs['max']); // Unset max to not render it again in $this->_htmlAttribs($attribs)
$step = '';
if (isset($attribs['step'])) {
$step = sprintf(' step="%s"', $attribs['step'] === 'any' ? 'any' : $this->formatNumber($attribs['step']));
}
unset($attribs['step']); // Unset step to not render it again in $this->_htmlAttribs($attribs)
$html5 = sprintf(
'<input type="number" name="%s" id="%s" value="%s"%s%s%s%s%s%s',
$this->view->escape($name),
$this->view->escape($id),
$this->view->escape($this->formatNumber($value)),
$min,
$max,
$step,
$disabled,
$this->_htmlAttribs($attribs),
$this->getClosingBracket()
);
return $html5;
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,31 +1,5 @@
<?php <?php
// @codeCoverageIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
use \Zend_View_Helper_FormElement; use \Zend_View_Helper_FormElement;
@ -63,4 +37,3 @@ class Zend_View_Helper_FormTriStateCheckbox extends Zend_View_Helper_FormElement
return $xhtml . '</div>'; return $xhtml . '</div>';
} }
} }
// @codeCoverageIgnoreEnd

View File

@ -1,32 +1,5 @@
<?php <?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga Web 2.
*
* Icinga Web 2 - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*
*/
// {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}}
/** /**
@ -91,6 +64,9 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
return date('H:i d.m.Y', $timestamp); return date('H:i d.m.Y', $timestamp);
} }
/**
* @deprecated Not used. This is monitoring module stuff.
*/
public static function getHostStateClassName($state) public static function getHostStateClassName($state)
{ {
$class = 'unknown'; $class = 'unknown';
@ -109,6 +85,9 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
return $class; return $class;
} }
/**
* @deprecated Crap. This is monitoring module stuff.
*/
public static function getHostStateName($state) public static function getHostStateName($state)
{ {
$states = array( $states = array(
@ -125,6 +104,9 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
return sprintf('OUT OF BOUNDS (%s)', var_export($state, 1)); return sprintf('OUT OF BOUNDS (%s)', var_export($state, 1));
} }
/**
* @deprecated Crap. This is monitoring module stuff.
*/
public static function getServiceStateName($state) public static function getServiceStateName($state)
{ {
if ($state === null) { $state = 3; } // really? if ($state === null) { $state = 3; } // really?
@ -142,5 +124,3 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
return sprintf('OUT OF BOUND (%d)' . $state, (int) $state); return sprintf('OUT OF BOUND (%d)' . $state, (int) $state);
} }
} }
// @codingStandardsIgnoreStop

View File

@ -7,10 +7,7 @@
in every further request until the browser was closed. To allow logout and to allow the user to change the in every further request until the browser was closed. To allow logout and to allow the user to change the
logged-in user this JavaScript provides a workaround to force a new authentication prompt in most browsers. logged-in user this JavaScript provides a workaround to force a new authentication prompt in most browsers.
--> -->
<div class="content">
<div class="row">
<br/>
<div class="md-offset-3 col-md-6 col-sm-6 col-sm-offset-3">
<div class="alert alert-warning" id="logout-status"> <div class="alert alert-warning" id="logout-status">
<b> <?= t('Logging out...'); ?> </b> <br /> <b> <?= t('Logging out...'); ?> </b> <br />
<?= t( <?= t(
@ -19,37 +16,19 @@
'browser session.' 'browser session.'
); ?> ); ?>
</div> </div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3">
<div class="container" > <div class="container" >
<a class="button btn btn-cta form-control input-sm" href="<?= $this->href('dashboard/index'); ?>"> <?= t('Login'); ?></a> <a href="<?= $this->href('dashboard/index'); ?>"> <?= t('Login'); ?></a>
</div> </div>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
/** /**
* When JavaScript is available, trigger an XmlHTTPRequest with the non-existing user 'logout' and abort it * When JavaScript is available, trigger an XmlHTTPRequest with the non-existing user 'logout' and abort it
* before it is able to finish. This will cause the browser to show a new authentication prompt in the next * before it is able to finish. This will cause the browser to show a new authentication prompt in the next
* request. * request.
*/ */
window.onload = function () { $(document).ready(function() {
function getXMLHttpRequest() { msg = $('#logout-status');
var xmlhttp = null;
try {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
} catch (e) {}
return xmlhttp;
}
var msg = document.getElementById('logout-status');
try { try {
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) { if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
document.execCommand('ClearAuthenticationCache'); document.execCommand('ClearAuthenticationCache');
@ -60,13 +39,9 @@
xhttp.abort(); xhttp.abort();
} }
} catch (e) { } catch (e) {
msg.innerHTML = '<?= t(
'Logout not possible, it may be necessary to quit the session manually ' .
'by clearing the cache, or closing the current browser session. Error: '
);?>' + ': ' + e.getMessage() ;
msg.setAttribute('class', 'alert alert-danger');
} }
msg.innerHTML = '<?= t('Logout successful!'); ?>'; msg.html('<?= t('Logout successful!'); ?>');
msg.setAttribute('class', 'alert alert-success'); msg.removeClass();
}; msg.addClass('alert alert-success');
});
</script> </script>

View File

@ -1,45 +0,0 @@
<div class="controls">
<?= $this->tabs ?>
</div>
<div class="content" data-base-target="_next">
<?php
if (isset($this->messageBox)) {
// TODO: Get rid of such boxes -> notifications?
echo $this->messageBox->render();
}
?>
<p>
<a href="<?= $this->href('/config/createAuthenticationBackend', array('type' => 'ldap')) ?>"><?= $this->icon('create.png'); ?> Create A New LDAP Authentication Backend</a>
<br />
<a href="<?= $this->href('/config/createAuthenticationBackend', array('type' => 'db')) ?>"><?= $this->icon('create.png'); ?> Create A New DB Authentication Backend</a>
</p>
<table class="action">
<thead>
<th>Resource</th>
<th style="width: 5em">Remove</th>
<th style="width: 5em">Order</th>
</thead>
<tbody>
<?php foreach ($this->backends as $backend): ?>
<tr>
<td class="action">
<a href="<?= $this->href('config/editAuthenticationBackend', array('auth_backend' => $backend->name)) ?>">
<?= $this->icon('edit.png') ?> <?= $this->escape($backend->name); ?>
</a>
</td>
<td>
<a href="<?= $this->href('config/removeAuthenticationBackend', array('auth_backend' => $backend->name)) ?>">
<?= $this->icon('remove.png', 'Remove') ?>
</a>
</td>
<td>
<?= $backend->reorderForm; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>

View File

@ -1,15 +1,10 @@
<h4> <div class="controls">
<i class="icinga-icon-create"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Create New Authentication Backend </div>
</h4> <h4><?= $this->translate('Create New Authentication Backend'); ?></h4>
<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<p> <p>
Create a new backend for authenticating your users. This backend will be added at the end of your authentication order. <?= $this->translate(
'Create a new backend for authenticating your users. This backend will be added at the end of your authentication order.'
); ?>
</p> </p>
<?= $form; ?>
<?= $this->form ?>

View File

@ -1,18 +1,5 @@
<h4> <div class="controls">
<i class="icinga-icon-edit"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Edit Backend "<?= $this->escape($this->name); ?>"
</h4>
<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<?php if ($this->form->getErrorMessages()): ?>
<div>
<?php foreach ($this->form->getErrorMessages() as $error): ?>
<?= $this->escape($error); ?><br/>
<?php endforeach; ?>
</div> </div>
<?php endif; ?> <h4><?= $this->translate('Edit Backend'); ?></h4>
<?= $form; ?>
<?= $this->form ?>

View File

@ -1,10 +1,5 @@
<h4> <div class="controls">
<i class="icinga-icon-remove"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Remove Backend "<?= $this->escape($this->name); ?>" </div>
</h4> <h4><?= $this->translate('Remove Backend'); ?></h4>
<?= $form; ?>
<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<?= $this->form ?>

View File

@ -0,0 +1,11 @@
<div class="controls">
<?= $tabs; ?>
</div>
<div class="content" data-base-target="_next">
<p>
<a href="<?= $this->href('/config/createAuthenticationBackend'); ?>">
<?= $this->icon('create.png'); ?><?= $this->translate('Create A New Authentication Backend'); ?>
</a>
</p>
<?= $form; ?>
</div>

View File

@ -4,7 +4,7 @@
<div class="content"> <div class="content">
<?php if (! $module): ?> <?php if (! $module): ?>
<?= $this->translate('There is no such module installed.') ?> <?= $this->translate('There is no such module installed.') ?>
<? return; endif ?> <?php return; endif ?>
<?php <?php
$dependencies = $module->getDependencies(); $dependencies = $module->getDependencies();
$restrictions = $module->getProvidedRestrictions(); $restrictions = $module->getProvidedRestrictions();

View File

@ -1,6 +1,6 @@
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->tabs ?>
<h1>Installed Modules</h1> <h1><?= $this->translate('Installed Modules') ?></h1>
<?= $this->paginationControl($modules) ?> <?= $this->paginationControl($modules) ?>
</div> </div>
@ -11,10 +11,10 @@
<tr> <tr>
<td> <td>
<?php if ($module->enabled): ?> <?php if ($module->enabled): ?>
<?= $this->icon('success.png', 'Module is enabled') ?> <?= $this->icon('success.png', $this->translate('Module is enabled')) ?>
<?php else: ?> <?php else: ?>
<?= $this->icon('remove.png', 'Module is disabled') ?> <?= $this->icon('remove.png', $this->translate('Module is disabled')) ?>
<? endif ?> <?php endif ?>
<a href="<?= $this->url( <a href="<?= $this->url(
'config/module/', 'config/module/',
array('name' => $module->name) array('name' => $module->name)
@ -23,7 +23,7 @@
?>) ?>)
</td> </td>
</tr> </tr>
<? endforeach ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -1,30 +1,32 @@
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $tabs; ?>
</div> </div>
<div class="content" data-base-target="_next"> <div class="content" data-base-target="_next">
<?php <p>
<a href="<?= $this->href('/config/createresource'); ?>">
if (isset($this->messageBox)) { <?= $this->icon('create.png'); ?> <?= $this->translate('Create A New Resource'); ?>
// TODO: Get rid of messageBoxes in favour of notifications </a>
echo $this->messageBox->render(); </p>
} <table class="action">
<thead>
?> <th><?= $this->translate('Resource'); ?></th>
<p><a href="<?= $this->href('/config/createresource') ?>"><?= $this->icon('create.png'); ?> Create A New Resource</a></p> <th style="width: 5em"><?= $this->translate('Remove'); ?></th>
</thead>
<table class="action"> <tbody>
<thead>
<th>Resource</th>
<th style="width: 5em">Remove</th>
</thead>
<tbody>
<?php foreach ($this->resources as $name => $resource): ?> <?php foreach ($this->resources as $name => $resource): ?>
<tr> <tr>
<td><a href="<?= $this->href('config/editresource', array('resource' => $name)) ?>"><?= $this->icon('edit.png') ?> <?= $this->escape($name); ?></td> <td>
<td style="text-align: center"><a href="<?= $this->href('config/removeresource', array('resource' => $name)) ?>"><?= $this->icon('remove.png'); ?></a></td> <a href="<?= $this->href('config/editresource', array('resource' => $name)); ?>">
</tr> <?= $this->icon('edit.png'); ?> <?= $this->escape($name); ?>
</a>
</td>
<td style="text-align: center">
<a href="<?= $this->href('config/removeresource', array('resource' => $name)); ?>">
<?= $this->icon('remove.png'); ?>
</a>
</td>
</tr>
<?php endforeach; ?> <?php endforeach; ?>
</table> </tbody>
</div> </table>
</div>

View File

@ -1,14 +1,6 @@
<h4> <div class="controls">
<i class="icinga-icon-create"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Create New Resource </div>
</h4> <h4><?= $this->translate('Create A New Resource'); ?></h4>
<p><?= $this->translate('Resources are entities that provide data to Icinga Web 2.'); ?></p>
<?php if (isset($this->messageBox)): ?> <?= $form; ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<p>
Resources are entities that provide data to Icingaweb.
</p>
<?= $this->form ?>

View File

@ -1,18 +1,5 @@
<h4> <div class="controls">
<i class="icinga-icon-edit"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Edit Resource "<?= $this->escape($this->name); ?>"
</h4>
<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<?php if ($this->form->getErrorMessages()): ?>
<div>
<?php foreach ($this->form->getErrorMessages() as $error): ?>
<?= $this->escape($error); ?><br/>
<?php endforeach; ?>
</div> </div>
<?php endif ?> <h4><?= $this->translate('Edit Existing Resource'); ?></h4>
<?= $form; ?>
<?= $this->form ?>

View File

@ -1,10 +1,5 @@
<h4> <div class="controls">
<i class="icinga-icon-remove"></i> <?= $this->tabs->showOnlyCloseButton() ?>
Remove Resource "<?= $this->escape($this->name); ?>" </div>
</h4> <h4><?= $this->translate('Remove Existing Resource'); ?></h4>
<?= $form; ?>
<?php if (isset($this->messageBox)): ?>
<?= $this->messageBox->render() ?>
<?php endif ?>
<?= $this->form ?>

View File

@ -1,31 +0,0 @@
<?= $this->tabs->render($this); ?>
<br/>
<div>
<h4><i>WARNING ICON</i>Saving "<?= $this->escape($this->file); ?>.ini" Failed</h4>
<br/>
<p>
Your <?= $this->escape($this->file); ?> configuration couldn't be stored (error: "<?= $this->exceptionMessage; ?>").<br/>
This could have one or more of the following reasons:
</p>
<ul>
<li>You don't have file-system permissions to write to the <?= $this->escape($this->file); ?>.ini file</li>
<li>Something went wrong while writing the file</li>
<li>There's an application error preventing you from persisting the configuration</li>
</ul>
</div>
<p>
Details can be seen in your application log (if you don't have access to this file, call your administrator in this case).
<br/>
In case you can access the configuration file (config/<?= $this->escape($this->file); ?>.ini) by yourself, you can open it and
insert the config manually:
</p>
<p>
<pre>
<code>
<?= $this->escape($this->iniConfigurationString); ?>
</code>
</pre>
</p>

View File

@ -2,6 +2,11 @@
<?= $this->tabs ?> <?= $this->tabs ?>
</div> </div>
<div class="content" > <div class="content">
<?= $this->form ?> <h1><?= $this->escape($this->translate('This feature is deactivated at the moment.')); ?></h1>
</div> <p>
<?=
$this->escape($this->translate('Please have a little patience, we are hard working on it, take a look at icingaweb2 issues.'));
?>
</p>
</div>

View File

@ -7,16 +7,10 @@
</div> </div>
<?php else: ?> <?php else: ?>
<div class="content"> <div class="content">
<h1>No dashboard configuration found!</h1> <h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1>
<p> <p><?= sprintf(
<?= $this->escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')),
$this->translate('We tried to load a dashboard configuration with no success.' $this->qlink($this->translate('modules'), 'config/modules')
. ' Please have look that the configuration does exist:'); ) ?></p>
?>
<code>
<?= $this->escape($this->configPath) ?>.ini
</code>
</p>
</div> </div>
<?php endif; ?> <?php endif ?>

View File

@ -11,7 +11,4 @@
<hr /> <hr />
<pre><?= $this->escape($stackTrace) ?></pre> <pre><?= $this->escape($stackTrace) ?></pre>
<?php endif ?> <?php endif ?>
<?php if (isset($this->messageBox)) : ?>
<?= $this->messageBox->render(); ?>
<? endif ?>
</div> </div>

View File

@ -0,0 +1,40 @@
<form id="<?= $form->getName(); ?>" name="<?= $form->getName(); ?>" enctype="<?= $form->getEncType(); ?>" method="<?= $form->getMethod(); ?>">
<table class="action">
<thead>
<th>Backend</th>
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
<th style="width: 5em"><?= $this->translate('Order'); ?></th>
</thead>
<tbody>
<?php $backendNames = $form->getBackendOrder(); ?>
<?php for ($i = 0; $i < count($backendNames); $i++): ?>
<tr>
<td class="action">
<a href="<?= $this->href('config/editAuthenticationBackend', array('auth_backend' => $backendNames[$i])); ?>">
<?= $this->icon('edit.png'); ?> <?= $this->escape($backendNames[$i]); ?>
</a>
</td>
<td>
<a href="<?= $this->href('config/removeAuthenticationBackend', array('auth_backend' => $backendNames[$i])); ?>">
<?= $this->icon('remove.png', $this->translate('Remove')); ?>
</a>
</td>
<td>
<?php if ($i > 0): ?>
<button type="submit" name="backend_newpos" value="<?= sprintf('%s|%s', $backendNames[$i], $i - 1); ?>">
<?= $this->icon('up.png', $this->translate('Move up in authentication order')); ?>
</button>
<?php endif; ?>
<?php if ($i + 1 < count($backendNames)): ?>
<button type="submit" name="backend_newpos" value="<?= sprintf('%s|%s', $backendNames[$i], $i + 1); ?>">
<?= $this->icon('down.png', $this->translate('Move down in authentication order')); ?>
</button>
<?php endif; ?>
</td>
</tr>
<?php endfor; ?>
</tbody>
</table>
<?= $form->getElement($form->getTokenElementName()); ?>
<?= $form->getElement($form->getUidElementName()); ?>
</form>

View File

@ -1,40 +0,0 @@
<div class="wizard">
<div class="header">
<img src="<?= $this->baseUrl('img/logo_icinga-inv.png'); ?>">
<h1><?= $wizard->getTitle(); ?></h1>
</div>
<div class="sidebar">
<ul>
<?php foreach ($wizard->getPages() as $page): ?>
<li class="<?= $wizard->isCompletedPage($page) ? 'complete' : (
$wizard->isCurrentPage($page) ? 'active' : 'pending'
); ?>">
<?= $page->getTitle(); ?>
<?php if ($wizard->isWizard($page) && $wizard->isCurrentPage($page) && !$wizard->isCompletedPage($page)): ?>
<ul>
<?php foreach ($page->getPages() as $subPage): ?>
<?php if ($page->isCurrentPage($subPage)): ?>
<li class="child active">
<?php else: ?>
<li class="child">
<?php endif ?>
<?= $subPage->getTitle(); ?>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
</li>
<?php endforeach ?>
<li class="install<?= $wizard->isFinished() ? ' active' : ''; ?>">
<?= $this->translate('Installation'); ?>
</li>
</ul>
</div>
<div class="panel">
<?php if ($wizard->isFinished()): ?>
<?= $this->partial('install/index/installog.phtml', array('installer' => $installer)); ?>
<?php else: ?>
<?= $wizard; ?>
<?php endif ?>
</div>
</div>

View File

@ -1 +0,0 @@
<?= $installer; ?>

View File

@ -1,39 +1,13 @@
<ul> <?php
<?php foreach ($items as $item): ?> use Icinga\Web\Widget\SearchDashboard;
<?php ?>
$itemClass = '';
if ($sub) { <? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
// $itemClass .= 'submenu '; <form action="<?= $this->href('search') ?>" method="get" role="search">
} <input
if ($this->href($url) === $this->href($item->getUrl())) { type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>"
$itemClass .= 'active '; autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
} />
?> </form>
<li <?php if (!empty($itemClass)): ?>class="<?= $itemClass ?>"<?php endif ?>> <? endif; ?>
<?php if($item->getUrl()): ?> <?= $menuRenderer; ?>
<a href="<?= $this->href($item->getUrl()); ?>" <?php foreach($item->getAttribs() as $attrib => $value): ?> <?= $attrib ?>="<?= $value ?>"<?php endforeach?>>
<?php endif; ?>
<?php
if ($icon = $item->getIcon()) {
echo $this->img($icon, array('height' => 16, 'width' => 16));
}
?>
<?php if ($iconClass = $item->getIconClass()): ?>
<i class="<?= $iconClass ?>"></i>
<?php endif ?>
<?= $item->getTitle();?>
<?php if($item->getUrl()): ?>
</a>
<?php endif; ?>
<?php
if($item->hasChildren()) {
echo $this->partial(
'layout/menu.phtml',
'default',
array('items' => $item->getChildren(), 'sub' => true, 'url' => $this->url)
);
}
?>
</li>
<?php endforeach ?>
</ul>

View File

@ -5,6 +5,7 @@
</div> </div>
<div class="content"> <div class="content">
<?php if ($this->logData !== null): ?>
<table class="action"> <table class="action">
<tbody> <tbody>
<?php foreach ($this->logData as $value): ?> <?php foreach ($this->logData as $value): ?>
@ -21,4 +22,5 @@
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> <?php endif; ?>
</div>

View File

@ -1,7 +1,7 @@
<div class="controls"> <div class="controls">
<?= $this->tabs->render($this); ?> <?= $tabs; ?>
</div> </div>
<div class="content"> <div class="content">
<?= $this->form ?> <?= $form; ?>
</div> </div>

View File

@ -1,12 +1,8 @@
<div class="controls">
<?= $this->tabs ?>
</div>
<div class="content"> <div class="content">
<h1><?= $this->translate("I'm ready to search, waiting for your input") ?></h1> <h1><?= $this->translate("I'm ready to search, waiting for your input") ?></h1>
<p><strong><?= $this->translate('Hint') ?>: </strong><?= $this->translate( <p><strong><?= $this->translate('Hint') ?>: </strong><?= $this->translate(
'Please use the asterisk (*) as a placeholder for wildcard searches.' 'Please use the asterisk (*) as a placeholder for wildcard searches.'
. " For convenience I'll always add a wildcard after the last character" . " For convenience I'll always add a wildcard in front and after your"
. ' you typed.' . ' search string.'
) ?></p> ) ?></p>
</div> </div>

View File

@ -1,5 +1,5 @@
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->dashboard->getTabs() ?>
</div> </div>
<div class="content dashboard"> <div class="content dashboard">

View File

@ -0,0 +1,28 @@
<div>
<h4><?= $this->translate('Saving Configuration Failed'); ?></h4>
<br>
<p>
<?= sprintf(
$this->translate('The file %s couldn\'t be stored. (Error: "%s")'),
$this->escape($filePath),
$this->escape($errorMessage)
); ?>
<br>
<?= $this->translate('This could have one or more of the following reasons:'); ?>
</p>
<ul>
<li><?= $this->translate('You don\'t have file-system permissions to write to the file'); ?></li>
<li><?= $this->translate('Something went wrong while writing the file'); ?></li>
<li><?= $this->translate('There\'s an application error preventing you from persisting the configuration'); ?></li>
</ul>
</div>
<p>
<?= $this->translate('Details can be found in the application log. (If you don\'t have access to this log, call your administrator in this case)'); ?>
<br>
<?= $this->translate('In case you can access the file by yourself, you can open it and insert the config manually:'); ?>
</p>
<p>
<pre>
<code><?= $this->escape($configString); ?></code>
</pre>
</p>

View File

@ -1,29 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# {{{ICINGA_LICENSE_HEADER}}} # {{{ICINGA_LICENSE_HEADER}}}
# This file is part of Icinga Web 2.
#
# Icinga Web 2 - Head for multiple monitoring backends.
# Copyright (C) 2013 Icinga Development Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# @copyright 2013 Icinga Development Team <info@icinga.org>
# @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
# @author Icinga Development Team <info@icinga.org>
#
# {{{ICINGA_LICENSE_HEADER}}} # {{{ICINGA_LICENSE_HEADER}}}
import sys import sys
@ -191,6 +168,9 @@ def get_license(type):
try: try:
return __LICENSE_STORE[type] return __LICENSE_STORE[type]
except(KeyError): except(KeyError):
if not LICENSE_DATA:
__LICENSE_STORE[type] = ''
return ''
config = FILE_TYPE_CONFIG[type] config = FILE_TYPE_CONFIG[type]
license_data = [] license_data = []
license_data.extend([''] * config['linesBefore']) license_data.extend([''] * config['linesBefore'])
@ -239,8 +219,9 @@ def replace_text(org_data, license_data):
test = True test = True
elif SECTION_MARKER.search(line) and test == True: elif SECTION_MARKER.search(line) and test == True:
test = False test = False
out += license_data if license_data:
out += '\n' out += license_data
out += '\n'
elif test == True: elif test == True:
continue continue

View File

@ -1,7 +1,7 @@
; authentication.ini ; authentication.ini
; ;
; Each section listed in this configuration represents a backend used to authenticate users. The backend configurations ; Each section listed in this configuration represents a backend used to authenticate users. The backend configurations
: must define a resource referring to a configured database or LDAP connection in the INI file resources.ini. ; must define a resource referring to a configured database or LDAP connection in the INI file resources.ini.
; ;
; The backends will be processed from top to bottom using the first backend for authentication which reports that ; The backends will be processed from top to bottom using the first backend for authentication which reports that
; the user trying to log in is available. ; the user trying to log in is available.
@ -18,6 +18,10 @@ backend = ldap
resource = internal_ldap resource = internal_ldap
user_class = @ldap_user_objectclass@ user_class = @ldap_user_objectclass@
user_name_attribute = @ldap_attribute_username@ user_name_attribute = @ldap_attribute_username@
group_base_dn = @ldap_group_base_dn@
group_attribute = @ldap_group_attribute@
group_member_attribute = @ldap_group_member_attribute@
group_class = @ldap_group_class@
[internal_db_authentication] [internal_db_authentication]
@internal_auth_disabled@ @internal_auth_disabled@

View File

@ -1,7 +1,5 @@
[global] [global]
timezone = "Europe/Berlin" timezone = "Europe/Berlin"
dateFormat = "d/m/Y"
timeFormat = "g:i A"
; Contains the directories that will be searched for available modules. Modules that ; Contains the directories that will be searched for available modules. Modules that
; don't exist in these directories can still be symlinked in the module folder, but ; don't exist in these directories can still be symlinked in the module folder, but

View File

@ -1,35 +0,0 @@
[Incidents]
title = "Current incidents"
[Incidents.Service Problems]
url = "monitoring/list/services"
service_problem = 1
limit = 10
sort = service_severity
[Incidents.Recently Recovered Services]
url = "monitoring/list/services"
sort = "service_last_state_change"
service_state = 0
limit = 10
dir = "desc"
[Incidents.Host Problems]
url = "monitoring/list/hosts"
host_problem = 1
sort = host_severity
[Landing]
title = "Landing page"
[Landing.Hostgroups]
url = "monitoring/chart/hostgroup?height=400&width=500"
[Landing.Servicegroups]
url = "monitoring/chart/servicegroup?height=360&width=450"
[Landing.Unhandled Problem Services]
url = "monitoring/list/services?service_handled=0&service_problem=1"
[Landing.Unhandled Problem Hosts]
url = "monitoring/list/hosts?host_handled=0&host_problem=1"

View File

@ -1,29 +0,0 @@
[Dashboard]
title = "Dashboard"
url = "dashboard"
icon = "img/icons/dashboard.png"
priority = 10
[System]
icon = img/icons/configuration.png
priority = 200
[System.Preferences]
title = "Preferences"
url = "preference"
priority = 200
[System.Configuration]
title = "Configuration"
url = "config"
priority = 300
[System.ApplicationLog]
title = "Application log"
url = "list/applicationlog"
priority = 400
[Logout]
url = "authentication/logout"
icon = img/icons/logout.png
priority = 300

View File

@ -0,0 +1,2 @@
[security]
protected_customvars = "*pw*,*pass*,community"

Some files were not shown because too many files have changed in this diff Show More