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:
commit
2e24c53224
|
@ -0,0 +1 @@
|
|||
.git* export-ignore
|
|
@ -10,7 +10,8 @@
|
|||
!.gitkeep
|
||||
|
||||
build/
|
||||
test/js/npm-debug.log
|
||||
|
||||
development/
|
||||
|
||||
# ./configure output
|
||||
config.log
|
||||
|
@ -20,10 +21,9 @@ config.status
|
|||
Makefile
|
||||
|
||||
# cmd tester
|
||||
test/php/bin/extcmd_test
|
||||
modules/test/bin/extcmd_test
|
||||
|
||||
# misc test output
|
||||
test/frontend/static/public
|
||||
test/php/library/Icinga/Protocol/Statusdat/.cache
|
||||
|
||||
# Generated API documentation
|
||||
|
@ -38,6 +38,9 @@ config/preferences/*.ini
|
|||
# Application logfiles
|
||||
var/log/*.log
|
||||
|
||||
# Packaging
|
||||
/debian
|
||||
*.tar.gz
|
||||
*.komodoproject
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
object CheckCommand "dummy-host" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_hostcheck.pl" ]
|
||||
command = [ PluginDir + "/test_hostcheck.pl" ]
|
||||
arguments = {
|
||||
"--type" = "$check_type$"
|
||||
"--failchance" = "$check_failchance$"
|
||||
|
@ -18,7 +18,7 @@ object CheckCommand "dummy-host" {
|
|||
|
||||
object CheckCommand "dummy-service" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_servicecheck.pl" ]
|
||||
command = [ PluginDir + "/test_servicecheck.pl" ]
|
||||
arguments = {
|
||||
"--total-critical-on-host" = "$check_critical_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")
|
||||
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)) {
|
||||
createHost("ok", "ok", num, true)
|
||||
createHost("random", "random,flapping", num, true)
|
||||
createHost("down", "warning,critical", num, true)
|
||||
createHost("unreachable", "unknown", num, true)
|
||||
createHost("pending", "pending", num, false)
|
||||
createHost("flap", "flapping", num, true)
|
||||
createHost("ok", [ "ok" ], num, true)
|
||||
createHost("random", [ "random", "flapping" ], num, true)
|
||||
createHost("down", [ "warning", "critical" ], num, true)
|
||||
createHost("unreachable", [ "unknown" ], num, true)
|
||||
createHost("pending", [ "pending" ], num, false)
|
||||
createHost("flap", [ "flapping" ], num, true)
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
|
@ -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"
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
include '/vagrant/library/Icinga/Application/webrouter.php';
|
||||
|
|
|
@ -3,10 +3,14 @@ include mysql
|
|||
include pgsql
|
||||
include openldap
|
||||
|
||||
Exec { path => '/bin:/usr/bin:/sbin' }
|
||||
Exec { path => '/bin:/usr/bin:/sbin:/usr/sbin' }
|
||||
|
||||
$icingaVersion = '1.11.2'
|
||||
$icinga2Version = '2.0.0'
|
||||
$icingaVersion = '1.11.5'
|
||||
$icinga2Version = '2.0.1'
|
||||
$pluginVersion = '2.0'
|
||||
$livestatusVersion = '1.2.4p5'
|
||||
$phantomjsVersion = '1.9.1'
|
||||
$casperjsVersion = '1.0.2'
|
||||
|
||||
exec { 'create-mysql-icinga-db':
|
||||
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-cgiurl=/icinga-mysql/cgi-bin \
|
||||
--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',
|
||||
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']
|
||||
}
|
||||
|
||||
|
@ -98,10 +102,10 @@ cmmi { 'icinga-pgsql':
|
|||
--with-htmurl=/icinga-pgsql --with-httpd-conf-file=/etc/httpd/conf.d/icinga-pgsql.conf \
|
||||
--with-cgiurl=/icinga-pgsql/cgi-bin \
|
||||
--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',
|
||||
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']
|
||||
}
|
||||
|
||||
|
@ -202,24 +206,15 @@ exec { 'iptables-allow-http':
|
|||
|
||||
exec { 'icinga-htpasswd':
|
||||
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']
|
||||
}
|
||||
|
||||
cmmi { 'icinga-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']
|
||||
}
|
||||
include monitoring-plugins
|
||||
|
||||
cmmi { 'mk-livestatus':
|
||||
url => 'http://mathias-kettner.de/download/mk-livestatus-1.2.2p1.tar.gz',
|
||||
output => 'mk-livestatus-1.2.2p1.tar.gz',
|
||||
url => "http://mathias-kettner.de/download/mk-livestatus-${livestatusVersion}.tar.gz",
|
||||
output => "mk-livestatus-${livestatusVersion}.tar.gz",
|
||||
flags => '--prefix=/usr/local/icinga-mysql --exec-prefix=/usr/local/icinga-mysql',
|
||||
creates => '/usr/local/icinga-mysql/lib/mk-livestatus',
|
||||
make => 'make && make install',
|
||||
|
@ -262,14 +257,14 @@ exec { 'populate-openldap':
|
|||
}
|
||||
|
||||
class { 'phantomjs':
|
||||
url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2',
|
||||
output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2',
|
||||
url => "https://phantomjs.googlecode.com/files/phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2",
|
||||
output => "phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2",
|
||||
creates => '/usr/local/phantomjs'
|
||||
}
|
||||
|
||||
class { 'casperjs':
|
||||
url => 'https://github.com/n1k0/casperjs/tarball/1.0.2',
|
||||
output => 'casperjs-1.0.2.tar.gz',
|
||||
url => "https://github.com/n1k0/casperjs/tarball/${casperjsVersion}",
|
||||
output => "casperjs-${casperjsVersion}.tar.gz",
|
||||
creates => '/usr/local/casperjs'
|
||||
}
|
||||
|
||||
|
@ -421,11 +416,10 @@ package { 'icinga2-ido-mysql':
|
|||
|
||||
exec { 'populate-icinga2-mysql-db':
|
||||
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'] ]
|
||||
}
|
||||
|
||||
|
||||
file { '/etc/icinga2/features-available/ido-mysql.conf':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf',
|
||||
owner => 'icinga',
|
||||
|
@ -574,7 +568,7 @@ populate_monitoring_test_config { ['commands', 'contacts', 'dependencies',
|
|||
}
|
||||
|
||||
define populate_monitoring_test_config_plugins {
|
||||
file { "/usr/lib64/nagios/plugins/libexec/${name}":
|
||||
file { "/usr/lib64/nagios/plugins/${name}":
|
||||
owner => 'icinga',
|
||||
group => 'icinga',
|
||||
source => "/usr/local/share/misc/monitoring_test_config/plugins/${name}",
|
||||
|
@ -702,6 +696,13 @@ file { '/etc/icingaweb':
|
|||
group => 'apache'
|
||||
}
|
||||
|
||||
file { '/etc/icingaweb/preferences':
|
||||
ensure => 'directory',
|
||||
owner => 'apache',
|
||||
group => 'apache',
|
||||
require => File['/etc/icingaweb']
|
||||
}
|
||||
|
||||
file { '/etc/icingaweb/authentication.ini':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/authentication.ini',
|
||||
owner => 'apache',
|
||||
|
@ -715,13 +716,6 @@ file { '/etc/icingaweb/config.ini':
|
|||
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':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/resources.ini',
|
||||
owner => 'apache',
|
||||
|
@ -741,30 +735,18 @@ file { '/etc/icingaweb/modules/monitoring/backends.ini':
|
|||
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':
|
||||
source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icingaweb/modules/monitoring/instances.ini',
|
||||
owner => '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':
|
||||
# channel => 'pear.survivethedeepend.com'
|
||||
# }
|
||||
|
@ -791,4 +773,3 @@ file { '/etc/bash_completion.d/icingacli':
|
|||
mode => 755,
|
||||
require => Exec['install bash-completion']
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class casperjs(
|
|||
require => Class['wget']
|
||||
}
|
||||
|
||||
$tld = inline_template('<%= File.basename(output, ".tar.bz2") %>')
|
||||
$tld = inline_template('<%= File.basename(@output, ".tar.bz2") %>')
|
||||
$src = "${cwd}/casperjs"
|
||||
|
||||
exec { 'extract-casperjs':
|
||||
|
|
|
@ -51,7 +51,7 @@ define cmmi(
|
|||
require => Class['wget']
|
||||
}
|
||||
|
||||
$tld = inline_template('<%= File.basename(output, ".tar.gz") %>')
|
||||
$tld = inline_template('<%= File.basename(@output, ".tar.gz") %>')
|
||||
$src = "${cwd}/${name}/${tld}"
|
||||
|
||||
exec { "extract-${name}":
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class monitoring-plugins {
|
||||
include epel
|
||||
|
||||
# nagios plugins from epel
|
||||
package { 'nagios-plugins-all':
|
||||
ensure => installed,
|
||||
require => Class['epel']
|
||||
}
|
||||
}
|
|
@ -32,8 +32,8 @@ install: install-config install-basic ensure-writable-folders install-cli
|
|||
#
|
||||
|
||||
install-cli:
|
||||
$(INSTALL) -m 755 -d $(INSTALL_OPTS) $(bindir)
|
||||
$(INSTALL) -m 755 $(INSTALL_OPTS) "./bin/icingacli" $(bindir)/icingacli;
|
||||
$(INSTALL) -m 755 -d $(INSTALL_OPTS) $(bindir)
|
||||
$(INSTALL) -m 755 $(INSTALL_OPTS) "./bin/icingacli" $(bindir)/icingacli;
|
||||
|
||||
#
|
||||
# Installs the whole application w\o configuration
|
||||
|
|
69
README.md
69
README.md
|
@ -2,13 +2,59 @@
|
|||
|
||||
## 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
|
||||
|
||||
> **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.
|
||||
|
||||
### General
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
> **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
|
||||
> 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**:
|
||||
|
||||
* `/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
|
||||
|
||||
|
@ -196,12 +244,13 @@ code style issues.
|
|||
|
||||
#### 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**:
|
||||
|
||||
cd /usr/local/icinga2
|
||||
./sbin/icinga2 -c etc/icinga2/icinga2.conf.dist
|
||||
/etc/init.d/icinga2 (start|stop|restart|reload)
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
Have a look at [LDAP example data](#ldap example data) for more accounts.
|
||||
|
||||
Using MySQL as backend:
|
||||
|
||||
> **Username**: icingaadmin
|
||||
> **Password**: icinga
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Clicommands;
|
||||
|
||||
|
@ -118,4 +119,3 @@ class AutocompleteCommand extends Command
|
|||
}
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Clicommands;
|
||||
|
||||
|
@ -41,4 +42,3 @@ class HelpCommand extends Command
|
|||
);
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Clicommands;
|
||||
|
||||
|
@ -212,4 +213,3 @@ class ModuleCommand extends Command
|
|||
$this->fail("Not implemented yet");
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Clicommands;
|
||||
|
||||
use Icinga\Cli\Command;
|
||||
use Exception;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
||||
class WebCommand extends Command
|
||||
{
|
||||
|
@ -12,11 +13,11 @@ class WebCommand extends Command
|
|||
{
|
||||
$minVersion = '5.4.0';
|
||||
if (version_compare(PHP_VERSION, $minVersion) < 0) {
|
||||
throw new Exception(sprintf(
|
||||
throw new IcingaException(
|
||||
'You are running PHP %s, internal webserver requires %s.',
|
||||
PHP_VERSION,
|
||||
$minVersion
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
$fork = $this->params->get('daemonize');
|
||||
|
@ -26,12 +27,12 @@ class WebCommand extends Command
|
|||
// TODO: Sanity check!!
|
||||
if ($socket === null) {
|
||||
$socket = '0.0.0.0:80';
|
||||
// throw new Exception('Socket is required');
|
||||
// throw new IcingaException('Socket is required');
|
||||
}
|
||||
if ($basedir === null) {
|
||||
$basedir = dirname(ICINGAWEB_APPDIR) . '/public';
|
||||
if (! file_exists($basedir) || ! is_dir($basedir)) {
|
||||
throw new Exception('Basedir is required');
|
||||
throw new IcingaException('Basedir is required');
|
||||
}
|
||||
}
|
||||
$basedir = realpath($basedir);
|
||||
|
@ -67,7 +68,7 @@ class WebCommand extends Command
|
|||
{
|
||||
$pid = pcntl_fork();
|
||||
if ($pid == -1) {
|
||||
throw new Exception('Could not fork');
|
||||
throw new IcingaException('Could not fork');
|
||||
} else if ($pid) {
|
||||
echo $this->screen->colorize('[OK]')
|
||||
. " Icinga Web server forked successfully\n";
|
||||
|
@ -81,4 +82,3 @@ class WebCommand extends Command
|
|||
}
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,31 +1,5 @@
|
|||
<?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\Application\Controllers;
|
||||
|
@ -35,7 +9,7 @@ use Icinga\Web\Controller\ActionController;
|
|||
use Icinga\Form\Authentication\LoginForm;
|
||||
use Icinga\Authentication\AuthChain;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Logger\Logger;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
use Icinga\Exception\NotReadableError;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
@ -60,12 +34,16 @@ class AuthenticationController extends ActionController
|
|||
public function loginAction()
|
||||
{
|
||||
$auth = $this->Auth();
|
||||
$this->view->form = new LoginForm();
|
||||
$this->view->form->setRequest($this->_request);
|
||||
$this->view->form = $form = new LoginForm();
|
||||
$this->view->title = $this->translate('Icingaweb Login');
|
||||
|
||||
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()) {
|
||||
$this->rerenderLayout()->redirectNow($redirectUrl);
|
||||
|
@ -74,35 +52,29 @@ class AuthenticationController extends ActionController
|
|||
try {
|
||||
$config = Config::app('authentication');
|
||||
} catch (NotReadableError $e) {
|
||||
Logger::error(
|
||||
new Exception('Cannot load authentication configuration. An exception was thrown:', 0, $e)
|
||||
);
|
||||
throw new ConfigurationError(
|
||||
'No authentication methods available. It seems that none authentication method has been set'
|
||||
. ' up. Please check the system log or Icinga Web 2 log for more information'
|
||||
$this->translate('Could not read your authentiction.ini, no authentication methods are available.'),
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$chain = new AuthChain($config);
|
||||
|
||||
|
||||
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()) {
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost() && $this->view->form->isValid($request->getPost())) {
|
||||
$user = new User($this->view->form->getValue('username'));
|
||||
$password = $this->view->form->getValue('password');
|
||||
$backendsTried = 0;
|
||||
$backendsWithError = 0;
|
||||
|
||||
$redirectUrl = $form->getValue('redirect');
|
||||
|
||||
if ($redirectUrl) {
|
||||
$redirectUrl = Url::fromPath($redirectUrl);
|
||||
} else {
|
||||
$redirectUrl = Url::fromPath('dashboard');
|
||||
}
|
||||
|
||||
foreach ($chain as $backend) {
|
||||
if ($backend instanceof AutoLoginBackend) {
|
||||
continue;
|
||||
|
@ -120,23 +92,44 @@ class AuthenticationController extends ActionController
|
|||
$this->rerenderLayout()->redirectNow($redirectUrl);
|
||||
}
|
||||
}
|
||||
if ($backendsWithError === $backendsTried) {
|
||||
if ($backendsTried === 0) {
|
||||
throw new ConfigurationError(
|
||||
$this->translate(
|
||||
'No authentication methods available. It seems that all set up authentication methods have'
|
||||
. ' errors. Please check the system log or Icinga Web 2 log for more information'
|
||||
'No authentication methods available. Did you create'
|
||||
. ' 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) {
|
||||
$this->view->form->addNote(
|
||||
$this->view->form->getElement('username')->addError(
|
||||
$this->translate(
|
||||
'Note that not all authentication backends are available for authentication because they'
|
||||
. ' have errors. Please check the system log or Icinga Web 2 log for more information'
|
||||
'Please note that not all authentication methods were available.'
|
||||
. ' Check the system log or Icinga Web 2 log for more information.'
|
||||
)
|
||||
);
|
||||
}
|
||||
$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) {
|
||||
$this->view->errorInfo = $e->getMessage();
|
||||
|
@ -149,14 +142,15 @@ class AuthenticationController extends ActionController
|
|||
public function logoutAction()
|
||||
{
|
||||
$auth = $this->Auth();
|
||||
if (! $auth->isAuthenticated()) {
|
||||
$this->redirectToLogin();
|
||||
}
|
||||
$isRemoteUser = $auth->getUser()->isRemoteUser();
|
||||
$auth->removeAuthorization();
|
||||
|
||||
if ($auth->isAuthenticatedFromRemoteUser()) {
|
||||
$this->_helper->layout->setLayout('login');
|
||||
if ($isRemoteUser === true) {
|
||||
$this->_response->setHttpResponseCode(401);
|
||||
} else {
|
||||
$this->rerenderLayout()->redirectToLogin();
|
||||
$this->redirectToLogin();
|
||||
}
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,64 +1,26 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{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}}}
|
||||
|
||||
use Icinga\Web\Controller\BaseConfigController;
|
||||
use Icinga\Web\Widget\Tab;
|
||||
use Icinga\Web\Widget\AlertMessageBox;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget;
|
||||
use Icinga\Application\Icinga;
|
||||
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\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
|
||||
*/
|
||||
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()
|
||||
{
|
||||
$this->view->tabs = Widget::create('tabs')->add('index', array(
|
||||
|
@ -70,56 +32,25 @@ class ConfigController extends BaseConfigController
|
|||
))->add('resources', array(
|
||||
'title' => 'Resources',
|
||||
'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
|
||||
*/
|
||||
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');
|
||||
$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()
|
||||
{
|
||||
$this->view->tabs = Widget::create('tabs')->add('modules', array(
|
||||
'title' => 'Modules',
|
||||
'url' => 'config/modules'
|
||||
));
|
||||
|
||||
$this->view->tabs->activate('modules');
|
||||
$this->view->modules = Icinga::app()->getModuleManager()->select()
|
||||
->from('modules')
|
||||
|
@ -160,7 +96,7 @@ class ConfigController extends BaseConfigController
|
|||
try {
|
||||
$manager->enableModule($module);
|
||||
$manager->loadModule($module);
|
||||
Notification::success('Module "' . $module . '" enabled');
|
||||
Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
|
||||
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
|
||||
} catch (Exception $e) {
|
||||
$this->view->exceptionMesssage = $e->getMessage();
|
||||
|
@ -179,7 +115,7 @@ class ConfigController extends BaseConfigController
|
|||
$manager = Icinga::app()->getModuleManager();
|
||||
try {
|
||||
$manager->disableModule($module);
|
||||
Notification::success('Module "' . $module . '" disabled');
|
||||
Notification::success(sprintf($this->translate('Module "%s" disabled'), $module));
|
||||
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
|
||||
} catch (Exception $e) {
|
||||
$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()
|
||||
{
|
||||
$config = IcingaConfig::app('authentication', true);
|
||||
$form = new AuthenticationBackendReorderForm();
|
||||
$form->setIniConfig(IcingaConfig::app('authentication'));
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->tabs->activate('authentication');
|
||||
|
||||
$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;
|
||||
$this->render('authentication/reorder');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,317 +144,151 @@ class ConfigController extends BaseConfigController
|
|||
*/
|
||||
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->tabs->activate('authentication');
|
||||
$this->render('authentication/create');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Form for editing backends
|
||||
*
|
||||
* Mostly the same like the createAuthenticationBackendAction, but with additional checks for backend existence
|
||||
* and form population
|
||||
* Action for editing authentication backends
|
||||
*/
|
||||
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->tabs->activate('authentication');
|
||||
$this->render('authentication/modify');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for removing a backend from the authentication list.
|
||||
*
|
||||
* Redirects to the overview after removal is finished
|
||||
* Action for removing a backend from the authentication list
|
||||
*/
|
||||
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();
|
||||
$authBackend = $this->getParam('auth_backend');
|
||||
if (!isset($configArray[$authBackend])) {
|
||||
Notification::error('Can\'t perform removal: Unknown Authentication Backend Provided');
|
||||
$this->render('authentication/remove');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$configForm->remove($authBackend);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Notification::error($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$form = new ConfirmRemovalForm();
|
||||
$form->setRequest($this->getRequest());
|
||||
$form->setRemoveTarget('auth_backend', $authBackend);
|
||||
|
||||
if ($form->isSubmittedAndValid()) {
|
||||
unset($configArray[$authBackend]);
|
||||
if ($this->writeAuthenticationFile($configArray)) {
|
||||
Notification::success('Authentication Backend "' . $authBackend . '" Removed');
|
||||
$this->redirectNow("config/authentication");
|
||||
if ($configForm->save()) {
|
||||
Notification::success(sprintf(
|
||||
t('Authentication backend "%s" has been successfully removed'),
|
||||
$authBackend
|
||||
));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
));
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->name = $authBackend;
|
||||
$this->view->tabs->activate('authentication');
|
||||
$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->render('resource');
|
||||
$this->view->tabs->activate('resources');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a form to create a new resource
|
||||
*/
|
||||
public function createresourceAction()
|
||||
{
|
||||
$this->view->resourceTypes = $this->resourceTypes;
|
||||
$resources = IcingaConfig::app('resources', true);
|
||||
$form = new ResourceForm();
|
||||
$form->setRequest($this->_request);
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
$form = new ResourceConfigForm();
|
||||
$form->setIniConfig(IcingaConfig::app('resources'));
|
||||
$form->setRedirectUrl('config/resource');
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->messageBox = new AlertMessageBox(true);
|
||||
$this->view->messageBox->addForm($form);
|
||||
$this->view->form = $form;
|
||||
$this->render('resource/create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a form to edit a existing resource
|
||||
*/
|
||||
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->name = $name;
|
||||
$this->render('resource/modify');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a confirmation form to remove a resource
|
||||
*/
|
||||
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();
|
||||
$name = $this->getParam('resource');
|
||||
if (!isset($resources[$name])) {
|
||||
$this->addSuccessMessage('Can\'t remove: Unknown resource provided');
|
||||
$this->render('resource/remove');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$configForm->remove($resource);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Notification::error($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
$form = new ConfirmRemovalForm();
|
||||
$form->setRequest($this->getRequest());
|
||||
$form->setRemoveTarget('resource', $name);
|
||||
if ($configForm->save()) {
|
||||
Notification::success(sprintf(t('Resource "%s" has been successfully removed'), $resource));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
));
|
||||
$form->setRedirectUrl('config/resource');
|
||||
$form->handleRequest();
|
||||
|
||||
// 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) {
|
||||
if (array_key_exists('resource', $config) && $config['resource'] === $name) {
|
||||
$this->addErrorMessage(
|
||||
'Warning: The resource "' . $name . '" is currently used for user authentication by "' . $backendName . '". ' .
|
||||
' Deleting it could eventally make login impossible.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($form->isSubmittedAndValid()) {
|
||||
unset($resources[$name]);
|
||||
if ($this->writeConfigFile($resources, 'resources')) {
|
||||
$this->addSuccessMessage('Resource "' . $name . '" removed.');
|
||||
$this->redirectNow('config/resource');
|
||||
if (array_key_exists('resource', $config) && $config['resource'] === $resource) {
|
||||
$form->addError(sprintf(
|
||||
$this->translate(
|
||||
'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
|
||||
));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->name = $name;
|
||||
$this->view->form = $form;
|
||||
$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
|
||||
|
|
|
@ -1,43 +1,17 @@
|
|||
<?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}}}
|
||||
|
||||
use \Zend_Config;
|
||||
use Icinga\Web\Url;
|
||||
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\Application\Config;
|
||||
use Icinga\Application\Logger;
|
||||
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\Url;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
|
||||
/**
|
||||
* Handle creation, removal and displaying of dashboards, panes and components
|
||||
|
@ -62,13 +36,13 @@ class DashboardController extends ActionController
|
|||
{
|
||||
$dashboard = new Dashboard();
|
||||
try {
|
||||
$dashboardConfig = IcingaConfig::app($config);
|
||||
$dashboardConfig = Config::app($config);
|
||||
if (count($dashboardConfig) === 0) {
|
||||
return null;
|
||||
}
|
||||
$dashboard->readConfig($dashboardConfig);
|
||||
} 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 $dashboard;
|
||||
|
@ -108,25 +82,29 @@ class DashboardController extends ActionController
|
|||
)->activate('addurl');
|
||||
|
||||
$form = new AddUrlForm();
|
||||
$form->setRequest($this->getRequest());
|
||||
$form->setAction(Url::fromRequest()->setParams(array())->getAbsoluteUrl());
|
||||
$this->view->form = $form;
|
||||
$request = $this->getRequest();
|
||||
if ($request->isPost()) {
|
||||
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()) {
|
||||
$dashboard = $this->getDashboard();
|
||||
$dashboard->setComponentUrl(
|
||||
$form->getValue('pane'),
|
||||
$form->getValue('component'),
|
||||
ltrim($form->getValue('url'), '/')
|
||||
);
|
||||
|
||||
$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');
|
||||
$configFile = Config::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('showConfiguration');
|
||||
return;
|
||||
}
|
||||
}
|
||||
} 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()
|
||||
{
|
||||
$dashboard = $this->getDashboard();
|
||||
if ($this->_getParam('pane')) {
|
||||
$pane = $this->_getParam('pane');
|
||||
$dashboard->activate($pane);
|
||||
}
|
||||
$dashboard = Dashboard::load();
|
||||
|
||||
$this->view->configPath = IcingaConfig::resolvePath(self::DEFAULT_CONFIG);
|
||||
|
||||
if ($dashboard === null) {
|
||||
if (! $dashboard->hasPanes()) {
|
||||
$this->view->title = 'Dashboard';
|
||||
} else {
|
||||
$this->view->title = $dashboard->getActivePane()->getTitle() . ' :: Dashboard';
|
||||
$this->view->tabs = $dashboard->getTabs();
|
||||
if ($this->_getParam('pane')) {
|
||||
$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
|
||||
$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)
|
||||
{
|
||||
$writer = new PreservingIniWriter(array('config' => $config, 'filename' => $target));
|
||||
$writer = new IniWriter(array('config' => $config, 'filename' => $target));
|
||||
|
||||
try {
|
||||
$writer->write();
|
||||
} catch (Exception $e) {
|
||||
Logger::error(new ConfiguationError("Cannot write dashboard to $target", 0, $e));
|
||||
$this->view->iniConfigurationString = $writer->render();
|
||||
$this->view->exceptionMessage = $e->getMessage();
|
||||
$this->view->file = $target;
|
||||
$this->view->configString = $writer->render();
|
||||
$this->view->errorMessage = $e->getMessage();
|
||||
$this->view->filePath = $target;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,35 +1,10 @@
|
|||
<?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\Application\Controllers;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
|
@ -47,6 +22,10 @@ class ErrorController extends ActionController
|
|||
{
|
||||
$error = $this->_getParam('error_handler');
|
||||
$exception = $error->exception;
|
||||
|
||||
Logger::error($exception);
|
||||
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
|
||||
|
||||
switch ($error->type) {
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||
|
@ -78,4 +57,3 @@ class ErrorController extends ActionController
|
|||
$this->view->request = $error->request;
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
<?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}}}
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Filter\Filter;
|
||||
use Icinga\Logger\Logger;
|
||||
use Icinga\Application\Logger;
|
||||
|
||||
/**
|
||||
* Application wide interface for filtering
|
||||
|
@ -117,4 +91,3 @@ class FilterController extends ActionController
|
|||
}
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,31 +1,5 @@
|
|||
<?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\Application\Controllers;
|
||||
|
@ -45,7 +19,7 @@ class IndexController extends ActionController
|
|||
public function preDispatch()
|
||||
{
|
||||
if ($this->getRequest()->getActionName() !== 'welcome') {
|
||||
$this->redirectNow('dashboard');
|
||||
$this->redirectNow(Url::fromRequest()->setPath('dashboard'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,4 +30,3 @@ class IndexController extends ActionController
|
|||
{
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -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
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Web\MenuRenderer;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Web\Hook;
|
||||
use Icinga\Web\Menu;
|
||||
|
@ -18,9 +18,12 @@ class LayoutController extends ActionController
|
|||
*/
|
||||
public function menuAction()
|
||||
{
|
||||
$this->view->url = Url::fromRequest()->getRelativeUrl();
|
||||
$this->view->items = Menu::fromConfig()->getChildren();
|
||||
$this->view->sub = false;
|
||||
$this->setAutorefreshInterval(15);
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$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();
|
||||
|
||||
/** @var Hook\Layout\TopBar $hook */
|
||||
/** @var Hook\TopBarHook $hook */
|
||||
$hook = null;
|
||||
|
||||
foreach (Hook::all('TopBar') as $hook) {
|
||||
$topbarHtmlParts[] = $hook->getHtml($this->getRequest(), $this->view);
|
||||
$topbarHtmlParts[] = $hook->getHtml($this->getRequest());
|
||||
}
|
||||
|
||||
$this->view->topbarHtmlParts = $topbarHtmlParts;
|
||||
|
@ -43,4 +46,3 @@ class LayoutController extends ActionController
|
|||
$this->renderScript('parts/topbar.phtml');
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,38 +1,13 @@
|
|||
<?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}}}
|
||||
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Web\Hook;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
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
|
||||
|
@ -62,21 +37,21 @@ class ListController extends Controller
|
|||
*/
|
||||
public function applicationlogAction()
|
||||
{
|
||||
$this->addTitleTab('application log');
|
||||
$config_ini = IcingaConfig::app()->toArray();
|
||||
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;
|
||||
if (! Logger::writesToFile()) {
|
||||
throw new ActionError('Site not found', 404);
|
||||
}
|
||||
|
||||
$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
|
||||
|
|
|
@ -1,38 +1,14 @@
|
|||
<?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}}}
|
||||
|
||||
use Icinga\Web\Controller\BasePreferenceController;
|
||||
use Icinga\Web\Widget\Tab;
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
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
|
||||
|
@ -59,28 +35,22 @@ class PreferenceController extends BasePreferenceController
|
|||
}
|
||||
|
||||
/**
|
||||
* General settings for date and time
|
||||
* Show form to adjust user preferences
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$form = new GeneralForm();
|
||||
$this->getTabs()->activate('general');
|
||||
$form->setConfiguration(IcingaConfig::app())
|
||||
->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();
|
||||
}
|
||||
$storeConfig = Config::app()->preferences;
|
||||
if ($storeConfig === null) {
|
||||
throw new ConfigurationError(t('You need to configure how to store preferences first.'));
|
||||
}
|
||||
|
||||
$user = $this->getRequest()->getUser();
|
||||
$form = new PreferenceForm();
|
||||
$form->setPreferences($user->getPreferences());
|
||||
$form->setStore(PreferencesStore::create($storeConfig, $user));
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->getTabs()->activate('general');
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
// @codeCoverageIgnoreStart
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Widget;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\SearchDashboard;
|
||||
|
||||
/**
|
||||
* Search controller
|
||||
|
@ -13,48 +13,13 @@ class SearchController extends ActionController
|
|||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$search = $this->_request->getParam('q');
|
||||
if (! $search) {
|
||||
$this->view->tabs = Widget::create('tabs')->add(
|
||||
'search',
|
||||
array(
|
||||
'title' => $this->translate('Search'),
|
||||
'url' => '/search',
|
||||
)
|
||||
)->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();
|
||||
$this->view->dashboard = SearchDashboard::search($this->params->get('q'));
|
||||
|
||||
// NOTE: This renders the dashboard twice. Remove this once we can catch exceptions thrown in view scripts.
|
||||
$this->view->dashboard->render();
|
||||
}
|
||||
|
||||
public function hintAction()
|
||||
{
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,37 +1,12 @@
|
|||
<?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}}}
|
||||
|
||||
use \Zend_Controller_Action_Exception as ActionException;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
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
|
||||
|
@ -56,8 +31,25 @@ class StaticController extends ActionController
|
|||
|
||||
public function gravatarAction()
|
||||
{
|
||||
$img = file_get_contents('http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->_request->getParam('email')))) . '?s=200&d=mm');
|
||||
header('image/jpeg');
|
||||
$cache = FileCache::instance();
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -67,13 +59,12 @@ class StaticController extends ActionController
|
|||
public function imgAction()
|
||||
{
|
||||
$module = $this->_getParam('module_name');
|
||||
// TODO: This is more than dangerous, must be fixed!!
|
||||
$file = $this->_getParam('file');
|
||||
|
||||
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
|
||||
|
||||
$filePath = $basedir . '/public/img/' . $file;
|
||||
if (! file_exists($filePath)) {
|
||||
$filePath = realpath($basedir . '/public/img/' . $file);
|
||||
|
||||
if (! $filePath || strpos($filePath, $basedir) !== 0) {
|
||||
throw new ActionException(sprintf(
|
||||
'%s does not exist',
|
||||
$filePath
|
||||
|
@ -188,4 +179,3 @@ class StaticController extends ActionController
|
|||
$lessCompiler->printStack();
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Form\Authentication;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
/**
|
||||
* Class LoginForm
|
||||
|
@ -10,34 +13,45 @@ use Icinga\Web\Form;
|
|||
class LoginForm extends Form
|
||||
{
|
||||
/**
|
||||
* Disable CSRF protection
|
||||
* @var bool
|
||||
* Initialize this login form
|
||||
*/
|
||||
protected $tokenDisabled = true;
|
||||
|
||||
/**
|
||||
* Interface how the form should be created
|
||||
*/
|
||||
protected function create()
|
||||
public function init()
|
||||
{
|
||||
$this->setName('form_login');
|
||||
$this->addElement('text', 'username', array(
|
||||
'label' => t('Username'),
|
||||
'placeholder' => t('Please enter your username...'),
|
||||
'required' => true,
|
||||
));
|
||||
$this->setSubmitLabel(t('Login'));
|
||||
}
|
||||
|
||||
$this->addElement('password', 'password', array(
|
||||
'label' => t('Password'),
|
||||
'placeholder' => t('...and your password'),
|
||||
'required' => true
|
||||
));
|
||||
// TODO: We need a place to intercept filled forms before rendering
|
||||
if (isset($_POST['username'])) {
|
||||
$this->getElement('password')->setAttrib('class', 'autofocus');
|
||||
} else {
|
||||
$this->getElement('username')->setAttrib('class', 'autofocus');
|
||||
}
|
||||
$this->setSubmitLabel('Login');
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
$this->addElement(
|
||||
'text',
|
||||
'username',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('Username'),
|
||||
'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')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -1,151 +1,117 @@
|
|||
<?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 \Exception;
|
||||
use \Icinga\Authentication\Backend\DbUserBackend;
|
||||
use \Zend_Config;
|
||||
use Exception;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Authentication\UserBackend;
|
||||
use Icinga\Authentication\Backend\DbUserBackend;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$res = ResourceFactory::getResourceConfigs('db')->toArray();
|
||||
$this->setName('form_config_authbackend_db');
|
||||
}
|
||||
|
||||
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 {
|
||||
return $this->resources;
|
||||
/**
|
||||
* @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 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');
|
||||
$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()
|
||||
)
|
||||
);
|
||||
$element = $form->getElement('resource');
|
||||
|
||||
$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 {
|
||||
$testConnection = ResourceFactory::createResource(ResourceFactory::getResourceConfig(
|
||||
$this->getValue('backend_' . $this->filterName($this->getBackendName()) . '_resource')
|
||||
));
|
||||
$dbUserBackend = new DbUserBackend($testConnection);
|
||||
$dbUserBackend = new DbUserBackend(ResourceFactory::create($element->getValue()));
|
||||
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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,194 +1,138 @@
|
|||
<?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 \Exception;
|
||||
use \Zend_Config;
|
||||
use Exception;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
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) {
|
||||
$res = ResourceFactory::getResourceConfigs('ldap')->toArray();
|
||||
|
||||
foreach (array_keys($res) as $key) {
|
||||
$res[$key] = $key;
|
||||
}
|
||||
|
||||
return $res;
|
||||
} else {
|
||||
return $this->resources;
|
||||
}
|
||||
$this->setName('form_config_authbackend_ldap');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
$name = $this->filterName($this->getBackendName());
|
||||
$backend = $this->getBackend();
|
||||
$this->resources = $resources;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Form::createElements()
|
||||
*/
|
||||
public function createElements(array $formData)
|
||||
{
|
||||
$this->addElement(
|
||||
'text',
|
||||
'backend_' . $name . '_name',
|
||||
'name',
|
||||
array(
|
||||
'required' => true,
|
||||
'allowEmpty' => false,
|
||||
'label' => t('Backend Name'),
|
||||
'helptext' => t('The name of this authentication backend'),
|
||||
'value' => $this->getBackendName()
|
||||
'description' => t('The name of this authentication backend')
|
||||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'select',
|
||||
'backend_' . $name . '_resource',
|
||||
'resource',
|
||||
array(
|
||||
'required' => true,
|
||||
'allowEmpty' => false,
|
||||
'label' => t('LDAP Resource'),
|
||||
'helptext' => t('The resource to use for authenticating with this provider'),
|
||||
'value' => $this->getBackend()->get('resource'),
|
||||
'multiOptions' => $this->getResources()
|
||||
'description' => t('The resource to use for authenticating with this provider'),
|
||||
'multiOptions' => false === empty($this->resources)
|
||||
? array_combine($this->resources, $this->resources)
|
||||
: array()
|
||||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'text',
|
||||
'backend_' . $name . '_user_class',
|
||||
'user_class',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => t('LDAP User Object Class'),
|
||||
'helptext' => t('The object class used for storing users on the ldap server'),
|
||||
'value' => $backend->get('user_class', 'inetOrgPerson')
|
||||
'required' => true,
|
||||
'label' => t('LDAP User Object Class'),
|
||||
'description' => t('The object class used for storing users on the ldap server'),
|
||||
'value' => 'inetOrgPerson'
|
||||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
'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(
|
||||
'required' => true,
|
||||
'label' => t('LDAP User Name Attribute'),
|
||||
'helptext' => t('The attribute name used for storing the user name on the ldap server'),
|
||||
'value' => $backend->get('user_name_attribute', 'uid')
|
||||
'value' => 'ldap'
|
||||
)
|
||||
);
|
||||
|
||||
$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 $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ldap authentication backend configuration for this form
|
||||
* Validate that the selected resource is a valid ldap authentication backend
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @see BaseBackendForm::getConfig()
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function getConfig()
|
||||
public function onSuccess(Request $request)
|
||||
{
|
||||
$prefix = 'backend_' . $this->filterName($this->getBackendName()) . '_';
|
||||
$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.'));
|
||||
if (false === $this->isValidAuthenticationBackend($this)) {
|
||||
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 {
|
||||
$cfg = $this->getConfig();
|
||||
$backendName = 'backend_' . $this->filterName($this->getBackendName()) . '_name';
|
||||
$backendConfig = new Zend_Config($cfg[$this->getValue($backendName)]);
|
||||
$backend = ResourceFactory::createResource(ResourceFactory::getResourceConfig($backendConfig->resource));
|
||||
$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 = new LdapUserBackend(
|
||||
ResourceFactory::create($element->getValue()),
|
||||
$form->getElement('user_class')->getValue(),
|
||||
$form->getElement('user_name_attribute')->getValue()
|
||||
);
|
||||
$ldapUserBackend->assertAuthenticationPossible();
|
||||
} catch (Exception $e) {
|
||||
$element->addError(sprintf(t('Connection validation failed: %s'), $e->getMessage()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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'));
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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'));
|
||||
}
|
||||
}
|
|
@ -1,42 +1,12 @@
|
|||
<?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\Dashboard;
|
||||
|
||||
use Icinga\Application\Config as IcingaConfig;
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Widget\Dashboard;
|
||||
use Zend_Form_Element_Text;
|
||||
use Zend_Form_Element_Submit;
|
||||
use Zend_Form_Element_Hidden;
|
||||
use Zend_Form_Element_Select;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
* Form to add an url a dashboard pane
|
||||
|
@ -44,125 +14,103 @@ use Zend_Form_Element_Select;
|
|||
class AddUrlForm extends Form
|
||||
{
|
||||
/**
|
||||
* Add a selection box for different panes to the form
|
||||
*
|
||||
* @param Dashboard $dashboard The dashboard to retrieve the panes from
|
||||
* Initialize this form
|
||||
*/
|
||||
private function addPaneSelectionBox(Dashboard $dashboard)
|
||||
public function init()
|
||||
{
|
||||
$selectPane = new Zend_Form_Element_Select(
|
||||
'pane',
|
||||
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'));
|
||||
$this->setName('form_dashboard_addurl');
|
||||
$this->setSubmitLabel(t('Add To Dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(
|
||||
'text',
|
||||
'url',
|
||||
array(
|
||||
'label' => 'Url',
|
||||
'required' => true,
|
||||
'value' => htmlspecialchars_decode($this->getRequest()->getParam('url', ''))
|
||||
'required' => true,
|
||||
'label' => t('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
|
||||
($this->getRequest()->getPost('create_new_pane', '0') && // or when a new pane should be created (+ button)
|
||||
!$this->getRequest()->getPost('use_existing_dashboard', '0')) // and the user didn't click the 'use
|
||||
// existing' button
|
||||
$paneSelectionValues = $this->getDashboardPaneSelectionValues();
|
||||
if (empty($paneSelectionValues) ||
|
||||
((isset($formData['create_new_pane']) && $formData['create_new_pane'] != false) &&
|
||||
(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 {
|
||||
$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(
|
||||
'text',
|
||||
'component',
|
||||
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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ if ($notifications->hasMessages()) {
|
|||
</div>
|
||||
<?php endif ?>
|
||||
<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') ?>
|
||||
</div>
|
||||
<div id="col2" class="container">
|
||||
|
|
|
@ -29,21 +29,22 @@ $iframeClass = $isIframe ? ' iframe' : '';
|
|||
<title><?= $this->title ? $this->escape($this->title) : 'Icinga Web' ?></title>
|
||||
<!-- 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">
|
||||
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" />
|
||||
<? if ($isIframe): ?>
|
||||
<?php if ($isIframe): ?>
|
||||
<base target="_parent"/>
|
||||
<?php else: ?>
|
||||
<?php else: ?>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var html = document.getElementsByTagName('html')[0];
|
||||
html.className = html.className.replace(/no-js/, 'js');
|
||||
}());
|
||||
</script>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<link rel="stylesheet" href="<?= $this->href($cssfile) ?>" media="screen" type="text/css" />
|
||||
<!-- Respond.js IE8 support of media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="<?= $this->baseUrl('js/vendor/respond.min.js');?>"></script>
|
||||
<![endif]-->
|
||||
<link type="image/png" rel="shortcut icon" href="<?= $this->baseUrl('img/favicon.png') ?>" />
|
||||
|
||||
</head>
|
||||
<body id="body">
|
||||
|
@ -51,7 +52,6 @@ $iframeClass = $isIframe ? ' iframe' : '';
|
|||
<div id="layout" class="default-layout">
|
||||
<?= $this->render('body.phtml') ?>
|
||||
</div>
|
||||
<?php if (! $isIframe): ?>
|
||||
<!--[if IE 8]>
|
||||
<script type="text/javascript" src="<?= $this->href($ie8jsfile) ?>"></script>
|
||||
<![endif]-->
|
||||
|
@ -63,6 +63,5 @@ var icinga = new Icinga({
|
|||
baseUrl: '<?= $this->href('/') ?>'
|
||||
});
|
||||
</script>
|
||||
<?php endif ?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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>
|
|
@ -2,22 +2,24 @@
|
|||
|
||||
use Icinga\Web\Url;
|
||||
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
|
||||
if (! $this->auth()->isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Current url
|
||||
$url = Url::fromRequest()->getRelativeUrl();
|
||||
$menu = Menu::fromConfig();
|
||||
?>
|
||||
<div id="menu" data-base-target="_main">
|
||||
<form action="<?= $this->href('search') ?>" method="get" role="search">
|
||||
<input type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
|
||||
</form>
|
||||
<?= $this->partial('parts/menu.phtml', array(
|
||||
'items' => $menu->getChildren(),
|
||||
'url' => $url
|
||||
)) ?>
|
||||
<div
|
||||
id="menu" data-last-update="<?= (time() - 14) ?>000" data-base-target="_main" class="container" data-icinga-url="<?=$this->href('layout/menu');?>"
|
||||
data-icinga-refresh="15"
|
||||
>
|
||||
<? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
|
||||
<form action="<?= $this->href('search') ?>" method="get" role="search">
|
||||
<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>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -5,121 +5,191 @@
|
|||
#
|
||||
msgid ""
|
||||
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"
|
||||
"POT-Creation-Date: 2014-05-29 11:12+0000\n"
|
||||
"PO-Revision-Date: 2014-05-29 13:19+0100\n"
|
||||
"POT-Creation-Date: 2014-08-22 17:30+0200\n"
|
||||
"PO-Revision-Date: 2014-08-22 17:52+0100\n"
|
||||
"Last-Translator: Thomas Gelf <thomas@gelf.net>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\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
|
||||
#, php-format
|
||||
msgid "%s: %d to %d of %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"
|
||||
msgstr "Anwendungspräfix"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:78
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:80
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Menu.php:197
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
msgstr "Bind Kennwort"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:358
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:139
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:333
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:114
|
||||
msgid "Check this box to enforce changes without connectivity validation"
|
||||
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."
|
||||
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: "
|
||||
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."
|
||||
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:470
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:429
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:445
|
||||
msgid "Connectivity validation failed, the provided file does not exist."
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
msgstr "Standardsprache"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:62
|
||||
#: /usr/local/src/bugfix.master/application/controllers/ErrorController.php:36
|
||||
#, php-format
|
||||
msgid "Enabling the \"%s\" module might help!"
|
||||
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"
|
||||
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"
|
||||
msgstr "Facility"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:102
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:383
|
||||
#: /usr/local/src/bugfix.master/application/controllers/PreferenceController.php:55
|
||||
#, 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"
|
||||
msgstr "Datei"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:155
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:220
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:231
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:308
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:129
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:195
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:206
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:283
|
||||
msgid "Filepath"
|
||||
msgstr "Dateipfad"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:357
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/BaseBackendForm.php:138
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:90
|
||||
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"
|
||||
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
|
||||
msgid "Hint"
|
||||
msgstr "Hinweis"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:160
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:260
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:135
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:235
|
||||
msgid "Host"
|
||||
msgstr "Host"
|
||||
|
||||
|
@ -132,165 +202,183 @@ msgstr "Hosts"
|
|||
msgid "I'm ready to search, waiting for your input"
|
||||
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
|
||||
msgid "Icingaweb Login"
|
||||
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."
|
||||
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"
|
||||
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"
|
||||
msgstr "Information"
|
||||
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:337
|
||||
#: /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
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/LdapBackendForm.php:67
|
||||
msgid "LDAP Resource"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
msgstr "Pfad zur Datei status.dat von Icinga"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/controllers/InstallController.php:69
|
||||
msgid "Logging"
|
||||
msgstr "Logging"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:72
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/LoggingForm.php:46
|
||||
msgid "Logging Enabled"
|
||||
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"
|
||||
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"
|
||||
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..."
|
||||
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"
|
||||
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/library/Icinga/Web/Menu.php:202
|
||||
msgid "Logout"
|
||||
msgstr "Abmelden"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:64
|
||||
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
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/authentication/logout.phtml:43
|
||||
msgid "Logout successful!"
|
||||
msgstr "Abmelden erfolgreich!"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/ReorderForm.php:137
|
||||
msgid "Move down in authentication order"
|
||||
msgstr ""
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterEditor.php:235
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:95
|
||||
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"
|
||||
msgstr ""
|
||||
msgstr "In der Authentifizierungsreihenfolge nach oben schieben"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/pivottablePagination.phtml:16
|
||||
msgid "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/library/Icinga/Web/Wizard/Wizard.php:337
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:380
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:89
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Form/notyet_FormWizard.php:30
|
||||
msgid "Next"
|
||||
msgstr "Weiter"
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/Authentication/DbBackendForm.php:144
|
||||
msgid "No users found under the specified database backend"
|
||||
msgstr ""
|
||||
#: /usr/local/src/bugfix.master/application/controllers/AuthenticationController.php:110
|
||||
msgid "No authentication methods available. Did you create authentication.ini when installing Icinga Web 2?"
|
||||
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."
|
||||
msgstr "Seite nicht gefunden."
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:65
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:206
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/mixedPagination.phtml:12
|
||||
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"
|
||||
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"
|
||||
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."
|
||||
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
|
||||
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."
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:171
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:146
|
||||
msgid "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/library/Icinga/Web/Menu.php:185
|
||||
msgid "Preferences"
|
||||
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:51
|
||||
msgid "Prev"
|
||||
msgstr "Zurück"
|
||||
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:326
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Wizard/Wizard.php:367
|
||||
msgid "Previous"
|
||||
msgstr "Vorheriges"
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/FilterWidget.php:99
|
||||
msgid "Remove this filter"
|
||||
msgstr "Diesen Filter entfernen"
|
||||
|
||||
#: /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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
msgstr "SQL Datenbank"
|
||||
|
||||
|
@ -301,187 +389,241 @@ msgstr "SQL Datenbank"
|
|||
msgid "Search"
|
||||
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..."
|
||||
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."
|
||||
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/views/scripts/pivottablePagination.phtml:34
|
||||
msgid "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"
|
||||
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."
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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."
|
||||
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"
|
||||
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."
|
||||
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."
|
||||
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."
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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
|
||||
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"
|
||||
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"
|
||||
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."
|
||||
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."
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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."
|
||||
msgstr ""
|
||||
msgstr "Der zur Authentifizierung zu benutzende Benutzername."
|
||||
|
||||
#: /usr/local/src/bugfix.master/application/views/scripts/config/module.phtml:6
|
||||
msgid "There is no such module installed."
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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"
|
||||
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/Config/ResourceForm.php:194
|
||||
#: /usr/local/src/bugfix.master/application/forms/Authentication/LoginForm.php:24
|
||||
#: /usr/local/src/bugfix.master/application/forms/Config/ResourceForm.php:169
|
||||
msgid "Username"
|
||||
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."
|
||||
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
|
||||
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"
|
||||
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."
|
||||
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."
|
||||
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"
|
||||
msgstr "Deine aktuelle Sprache"
|
||||
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:108
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:114
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Web/Widget/Limiter.php:58
|
||||
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"
|
||||
msgstr "für"
|
||||
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:112
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:131
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:133
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:87
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:106
|
||||
#: /usr/local/src/bugfix.master/library/Icinga/Util/Format.php:108
|
||||
msgid "since"
|
||||
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"
|
||||
#~ msgstr "Icinga Benutzeranmeldung"
|
|
@ -1,36 +1,9 @@
|
|||
<?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}}}
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Util\DateTimeFactory;
|
||||
use Icinga\Web\Form\Validator\DateTimeValidator;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$dt = DateTimeFactory::create();
|
||||
if (DateTimeValidator::isUnixTimestamp($timestamp)) {
|
||||
if (DateTimeFactory::isUnixTimestamp($timestamp)) {
|
||||
$dt->setTimestamp($timestamp);
|
||||
} else {
|
||||
return $timestamp;
|
||||
|
@ -134,10 +107,8 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract
|
|||
*/
|
||||
public function getDateFormat()
|
||||
{
|
||||
return $this->request->getUser()->getPreferences()->get(
|
||||
'app.dateFormat',
|
||||
Config::app()->global !== null ? Config::app()->global->get('dateFormat', 'd/m/Y') : 'd/m/Y'
|
||||
);
|
||||
// TODO(mh): Missing localized format (#6077)
|
||||
return 'd/m/Y';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,10 +118,8 @@ class Zend_View_Helper_DateFormat extends Zend_View_Helper_Abstract
|
|||
*/
|
||||
public function getTimeFormat()
|
||||
{
|
||||
return $this->request->getUser()->getPreferences()->get(
|
||||
'app.timeFormat',
|
||||
Config::app()->global !== null ? Config::app()->global->get('timeFormat', 'g:i A') : 'g:i A'
|
||||
);
|
||||
// TODO(mh): Missing localized format (#6077)
|
||||
return 'g:i A';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,45 +1,31 @@
|
|||
<?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}}}
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* 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 int $value The default timestamp
|
||||
* @param DateTime $value The default timestamp
|
||||
* @param array $attribs Attributes for the element tag
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$info = $this->_getInfo($name, $value, $attribs);
|
||||
extract($info); // name, value, attribs, options, listsep, disable
|
||||
// Is it disabled?
|
||||
extract($info); // name, id, value, attribs, options, listsep, disable
|
||||
/** @var string $id */
|
||||
/** @var bool $disable */
|
||||
$disabled = '';
|
||||
if ($disabled) {
|
||||
if ($disable) {
|
||||
$disabled = ' disabled="disabled"';
|
||||
}
|
||||
|
||||
$jspicker = (isset($attribs['jspicker']) && $attribs['jspicker'] === true) ? true : false;
|
||||
|
||||
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 = '';
|
||||
if ($value instanceof DateTime) {
|
||||
// If value was valid, it's a DateTime object
|
||||
$value = $this->formatDate($value, $attribs['local']);
|
||||
}
|
||||
|
||||
// Build the element
|
||||
$xhtml = '<div class="datetime' . (($jspicker === true) ? ' input-group' : ''). '">';
|
||||
|
||||
$xhtml .= '<input type="text" name="' . $name . '"'
|
||||
. ' id="' . $name . '"'
|
||||
. $value
|
||||
. $disabled
|
||||
. $this->_htmlAttribs($attribs);
|
||||
|
||||
if ($jspicker === true) {
|
||||
$xhtml .= 'data-icinga-component="app/datetime"';
|
||||
$min = '';
|
||||
if (! empty($attribs['min'])) {
|
||||
$min = sprintf(' min="%s"', $this->formatDate($attribs['min'], $attribs['local']));
|
||||
}
|
||||
|
||||
$xhtml .= $this->getClosingBracket();
|
||||
|
||||
if ($jspicker === true) {
|
||||
$xhtml .= '<span class="input-group-addon">'
|
||||
. '<a href="#">'
|
||||
. '<i class="icinga-icon-reschedule"></i>'
|
||||
. '</a>'
|
||||
. '</span>';
|
||||
unset($attribs['min']); // Unset min to not render it again in $this->_htmlAttribs($attribs)
|
||||
$max = '';
|
||||
if (! empty($attribs['max'])) {
|
||||
$max = sprintf(' max="%s"', $this->formatDate($attribs['max'], $attribs['local']));
|
||||
}
|
||||
|
||||
$xhtml .= '</div>';
|
||||
|
||||
return $xhtml;
|
||||
unset($attribs['max']); // Unset max to not render it again in $this->_htmlAttribs($attribs)
|
||||
$type = $attribs['local'] === true ? 'datetime-local' : 'datetime';
|
||||
unset($attribs['local']); // Unset local to not render it again in $this->_htmlAttribs($attribs)
|
||||
$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
|
||||
|
|
|
@ -1,57 +1,80 @@
|
|||
<?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}}}
|
||||
|
||||
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.
|
||||
* @param string $value The default value.
|
||||
* @param array $attribs Attributes which should be added to the input tag.
|
||||
* @return string
|
||||
*/
|
||||
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)
|
||||
{
|
||||
return '<input type="number"'
|
||||
. ' name="' . $this->view->escape($name) . '"'
|
||||
. ' value="' . $this->view->escape($value) . '"'
|
||||
. ' id="' . $this->view->escape($name) . '"'
|
||||
. $this->_htmlAttribs($attribs)
|
||||
. $this->getClosingBracket();
|
||||
$info = $this->_getInfo($name, $value, $attribs);
|
||||
extract($info); // name, id, value, attribs, options, listsep, disable
|
||||
/** @var string $id */
|
||||
/** @var bool $disable */
|
||||
$disabled = '';
|
||||
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
|
||||
|
|
|
@ -1,31 +1,5 @@
|
|||
<?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}}}
|
||||
|
||||
use \Zend_View_Helper_FormElement;
|
||||
|
@ -63,4 +37,3 @@ class Zend_View_Helper_FormTriStateCheckbox extends Zend_View_Helper_FormElement
|
|||
return $xhtml . '</div>';
|
||||
}
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
|
|
@ -1,32 +1,5 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
// {{{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}}}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +64,9 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
|
|||
return date('H:i d.m.Y', $timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Not used. This is monitoring module stuff.
|
||||
*/
|
||||
public static function getHostStateClassName($state)
|
||||
{
|
||||
$class = 'unknown';
|
||||
|
@ -109,6 +85,9 @@ class Zend_View_Helper_Util extends Zend_View_Helper_Abstract
|
|||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Crap. This is monitoring module stuff.
|
||||
*/
|
||||
public static function getHostStateName($state)
|
||||
{
|
||||
$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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Crap. This is monitoring module stuff.
|
||||
*/
|
||||
public static function getServiceStateName($state)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStop
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
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.
|
||||
-->
|
||||
|
||||
<div class="row">
|
||||
<br/>
|
||||
<div class="md-offset-3 col-md-6 col-sm-6 col-sm-offset-3">
|
||||
<div class="content">
|
||||
<div class="alert alert-warning" id="logout-status">
|
||||
<b> <?= t('Logging out...'); ?> </b> <br />
|
||||
<?= t(
|
||||
|
@ -19,37 +16,19 @@
|
|||
'browser session.'
|
||||
); ?>
|
||||
</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" >
|
||||
<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>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/**
|
||||
* 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
|
||||
* request.
|
||||
*/
|
||||
window.onload = function () {
|
||||
function getXMLHttpRequest() {
|
||||
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');
|
||||
$(document).ready(function() {
|
||||
msg = $('#logout-status');
|
||||
try {
|
||||
if (navigator.userAgent.toLowerCase().indexOf('msie') !== -1) {
|
||||
document.execCommand('ClearAuthenticationCache');
|
||||
|
@ -60,13 +39,9 @@
|
|||
xhttp.abort();
|
||||
}
|
||||
} 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.setAttribute('class', 'alert alert-success');
|
||||
};
|
||||
msg.html('<?= t('Logout successful!'); ?>');
|
||||
msg.removeClass();
|
||||
msg.addClass('alert alert-success');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -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>
|
|
@ -1,15 +1,10 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-create"></i>
|
||||
Create New Authentication Backend
|
||||
</h4>
|
||||
|
||||
|
||||
<?php if (isset($this->messageBox)): ?>
|
||||
<?= $this->messageBox->render() ?>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<h4><?= $this->translate('Create New Authentication Backend'); ?></h4>
|
||||
<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>
|
||||
|
||||
<?= $this->form ?>
|
||||
<?= $form; ?>
|
|
@ -1,18 +1,5 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-edit"></i>
|
||||
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 class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $this->form ?>
|
||||
<h4><?= $this->translate('Edit Backend'); ?></h4>
|
||||
<?= $form; ?>
|
|
@ -1,10 +1,5 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-remove"></i>
|
||||
Remove Backend "<?= $this->escape($this->name); ?>"
|
||||
</h4>
|
||||
|
||||
<?php if (isset($this->messageBox)): ?>
|
||||
<?= $this->messageBox->render() ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->form ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<h4><?= $this->translate('Remove Backend'); ?></h4>
|
||||
<?= $form; ?>
|
|
@ -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>
|
|
@ -4,7 +4,7 @@
|
|||
<div class="content">
|
||||
<?php if (! $module): ?>
|
||||
<?= $this->translate('There is no such module installed.') ?>
|
||||
<? return; endif ?>
|
||||
<?php return; endif ?>
|
||||
<?php
|
||||
$dependencies = $module->getDependencies();
|
||||
$restrictions = $module->getProvidedRestrictions();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1>Installed Modules</h1>
|
||||
<h1><?= $this->translate('Installed Modules') ?></h1>
|
||||
<?= $this->paginationControl($modules) ?>
|
||||
</div>
|
||||
|
||||
|
@ -11,10 +11,10 @@
|
|||
<tr>
|
||||
<td>
|
||||
<?php if ($module->enabled): ?>
|
||||
<?= $this->icon('success.png', 'Module is enabled') ?>
|
||||
<?= $this->icon('success.png', $this->translate('Module is enabled')) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->icon('remove.png', 'Module is disabled') ?>
|
||||
<? endif ?>
|
||||
<?= $this->icon('remove.png', $this->translate('Module is disabled')) ?>
|
||||
<?php endif ?>
|
||||
<a href="<?= $this->url(
|
||||
'config/module/',
|
||||
array('name' => $module->name)
|
||||
|
@ -23,7 +23,7 @@
|
|||
?>)
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<?= $tabs; ?>
|
||||
</div>
|
||||
|
||||
<div class="content" data-base-target="_next">
|
||||
<?php
|
||||
|
||||
if (isset($this->messageBox)) {
|
||||
// TODO: Get rid of messageBoxes in favour of notifications
|
||||
echo $this->messageBox->render();
|
||||
}
|
||||
|
||||
?>
|
||||
<p><a href="<?= $this->href('/config/createresource') ?>"><?= $this->icon('create.png'); ?> Create A New Resource</a></p>
|
||||
|
||||
<table class="action">
|
||||
<thead>
|
||||
<th>Resource</th>
|
||||
<th style="width: 5em">Remove</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<p>
|
||||
<a href="<?= $this->href('/config/createresource'); ?>">
|
||||
<?= $this->icon('create.png'); ?> <?= $this->translate('Create A New Resource'); ?>
|
||||
</a>
|
||||
</p>
|
||||
<table class="action">
|
||||
<thead>
|
||||
<th><?= $this->translate('Resource'); ?></th>
|
||||
<th style="width: 5em"><?= $this->translate('Remove'); ?></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->resources as $name => $resource): ?>
|
||||
<tr>
|
||||
<td><a href="<?= $this->href('config/editresource', array('resource' => $name)) ?>"><?= $this->icon('edit.png') ?> <?= $this->escape($name); ?></td>
|
||||
<td style="text-align: center"><a href="<?= $this->href('config/removeresource', array('resource' => $name)) ?>"><?= $this->icon('remove.png'); ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?= $this->href('config/editresource', array('resource' => $name)); ?>">
|
||||
<?= $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; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -1,14 +1,6 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-create"></i>
|
||||
Create New Resource
|
||||
</h4>
|
||||
|
||||
<?php if (isset($this->messageBox)): ?>
|
||||
<?= $this->messageBox->render() ?>
|
||||
<?php endif ?>
|
||||
|
||||
<p>
|
||||
Resources are entities that provide data to Icingaweb.
|
||||
</p>
|
||||
|
||||
<?= $this->form ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<h4><?= $this->translate('Create A New Resource'); ?></h4>
|
||||
<p><?= $this->translate('Resources are entities that provide data to Icinga Web 2.'); ?></p>
|
||||
<?= $form; ?>
|
|
@ -1,18 +1,5 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-edit"></i>
|
||||
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 class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->form ?>
|
||||
<h4><?= $this->translate('Edit Existing Resource'); ?></h4>
|
||||
<?= $form; ?>
|
|
@ -1,10 +1,5 @@
|
|||
<h4>
|
||||
<i class="icinga-icon-remove"></i>
|
||||
Remove Resource "<?= $this->escape($this->name); ?>"
|
||||
</h4>
|
||||
|
||||
<?php if (isset($this->messageBox)): ?>
|
||||
<?= $this->messageBox->render() ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?= $this->form ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs->showOnlyCloseButton() ?>
|
||||
</div>
|
||||
<h4><?= $this->translate('Remove Existing Resource'); ?></h4>
|
||||
<?= $form; ?>
|
|
@ -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>
|
|
@ -2,6 +2,11 @@
|
|||
<?= $this->tabs ?>
|
||||
</div>
|
||||
|
||||
<div class="content" >
|
||||
<?= $this->form ?>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h1><?= $this->escape($this->translate('This feature is deactivated at the moment.')); ?></h1>
|
||||
<p>
|
||||
<?=
|
||||
$this->escape($this->translate('Please have a little patience, we are hard working on it, take a look at icingaweb2 issues.'));
|
||||
?>
|
||||
</p>
|
||||
</div>
|
|
@ -7,16 +7,10 @@
|
|||
</div>
|
||||
<?php else: ?>
|
||||
<div class="content">
|
||||
<h1>No dashboard configuration found!</h1>
|
||||
<p>
|
||||
<?=
|
||||
$this->translate('We tried to load a dashboard configuration with no success.'
|
||||
. ' Please have look that the configuration does exist:');
|
||||
?>
|
||||
|
||||
<code>
|
||||
<?= $this->escape($this->configPath) ?>.ini
|
||||
</code>
|
||||
</p>
|
||||
<h1><?= $this->escape($this->translate('Welcome to Icinga Web!')) ?></h1>
|
||||
<p><?= sprintf(
|
||||
$this->escape($this->translate('Currently there is no dashlet available. This might change once you enabled some of the available %s.')),
|
||||
$this->qlink($this->translate('modules'), 'config/modules')
|
||||
) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif ?>
|
|
@ -11,7 +11,4 @@
|
|||
<hr />
|
||||
<pre><?= $this->escape($stackTrace) ?></pre>
|
||||
<?php endif ?>
|
||||
<?php if (isset($this->messageBox)) : ?>
|
||||
<?= $this->messageBox->render(); ?>
|
||||
<? endif ?>
|
||||
</div>
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -1 +0,0 @@
|
|||
<?= $installer; ?>
|
|
@ -1,39 +1,13 @@
|
|||
<ul>
|
||||
<?php foreach ($items as $item): ?>
|
||||
<?php
|
||||
$itemClass = '';
|
||||
if ($sub) {
|
||||
// $itemClass .= 'submenu ';
|
||||
}
|
||||
if ($this->href($url) === $this->href($item->getUrl())) {
|
||||
$itemClass .= 'active ';
|
||||
}
|
||||
?>
|
||||
<li <?php if (!empty($itemClass)): ?>class="<?= $itemClass ?>"<?php endif ?>>
|
||||
<?php if($item->getUrl()): ?>
|
||||
<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>
|
||||
<?php
|
||||
use Icinga\Web\Widget\SearchDashboard;
|
||||
?>
|
||||
|
||||
<? if (SearchDashboard::search('dummy')->getPane('search')->hasComponents()): ?>
|
||||
<form action="<?= $this->href('search') ?>" method="get" role="search">
|
||||
<input
|
||||
type="text" name="q" class="search autofocus" placeholder="<?= $this->translate('Search...') ?>"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
/>
|
||||
</form>
|
||||
<? endif; ?>
|
||||
<?= $menuRenderer; ?>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?php if ($this->logData !== null): ?>
|
||||
<table class="action">
|
||||
<tbody>
|
||||
<?php foreach ($this->logData as $value): ?>
|
||||
|
@ -21,4 +22,5 @@
|
|||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs->render($this); ?>
|
||||
<?= $tabs; ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->form ?>
|
||||
</div>
|
||||
<?= $form; ?>
|
||||
</div>
|
|
@ -1,12 +1,8 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<h1><?= $this->translate("I'm ready to search, waiting for your input") ?></h1>
|
||||
<p><strong><?= $this->translate('Hint') ?>: </strong><?= $this->translate(
|
||||
'Please use the asterisk (*) as a placeholder for wildcard searches.'
|
||||
. " For convenience I'll always add a wildcard after the last character"
|
||||
. ' you typed.'
|
||||
. " For convenience I'll always add a wildcard in front and after your"
|
||||
. ' search string.'
|
||||
) ?></p>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<?= $this->dashboard->getTabs() ?>
|
||||
</div>
|
||||
|
||||
<div class="content dashboard">
|
||||
|
|
|
@ -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>
|
|
@ -1,29 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# {{{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}}}
|
||||
|
||||
import sys
|
||||
|
@ -191,6 +168,9 @@ def get_license(type):
|
|||
try:
|
||||
return __LICENSE_STORE[type]
|
||||
except(KeyError):
|
||||
if not LICENSE_DATA:
|
||||
__LICENSE_STORE[type] = ''
|
||||
return ''
|
||||
config = FILE_TYPE_CONFIG[type]
|
||||
license_data = []
|
||||
license_data.extend([''] * config['linesBefore'])
|
||||
|
@ -239,8 +219,9 @@ def replace_text(org_data, license_data):
|
|||
test = True
|
||||
elif SECTION_MARKER.search(line) and test == True:
|
||||
test = False
|
||||
out += license_data
|
||||
out += '\n'
|
||||
if license_data:
|
||||
out += license_data
|
||||
out += '\n'
|
||||
elif test == True:
|
||||
continue
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; authentication.ini
|
||||
;
|
||||
; 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 user trying to log in is available.
|
||||
|
@ -18,6 +18,10 @@ backend = ldap
|
|||
resource = internal_ldap
|
||||
user_class = @ldap_user_objectclass@
|
||||
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_auth_disabled@
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
[global]
|
||||
timezone = "Europe/Berlin"
|
||||
dateFormat = "d/m/Y"
|
||||
timeFormat = "g:i A"
|
||||
|
||||
; 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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
|
@ -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
Loading…
Reference in New Issue