Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/add-to-dash…
Browse files Browse the repository at this point in the history
…board-4537

Conflicts:
	application/controllers/DashboardController.php
	library/Icinga/Web/Form.php
	library/Icinga/Web/Widget/Dashboard.php
  • Loading branch information
mxhash committed Nov 18, 2014
2 parents 8087131 + f007663 commit 10cfecf
Show file tree
Hide file tree
Showing 119 changed files with 1,361 additions and 2,943 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,5 @@ var/log/*

# Exclude symlink you need for packaging
/debian

build/*
8 changes: 4 additions & 4 deletions .vagrant-puppet/manifests/default.pp
Expand Up @@ -602,14 +602,14 @@
}

exec { 'populate-icingaweb-mysql-db-tables':
unless => 'mysql -uicingaweb -picingaweb icingaweb -e "SELECT * FROM account;" &> /dev/null',
command => 'mysql -uicingaweb -picingaweb icingaweb < /vagrant/etc/schema/mysql.sql',
unless => 'mysql -uicingaweb -picingaweb icingaweb -e "SELECT * FROM icingaweb_group;" &> /dev/null',
command => 'mysql -uicingaweb -picingaweb icingaweb < /vagrant/etc/schema/mysql.schema.sql',
require => [ Exec['create-mysql-icingaweb-db'] ]
}

exec { 'populate-icingweba-pgsql-db-tables':
unless => 'psql -U icingaweb -d icingaweb -c "SELECT * FROM account;" &> /dev/null',
command => 'sudo -u postgres psql -U icingaweb -d icingaweb -f /vagrant/etc/schema/pgsql.sql',
unless => 'psql -U icingaweb -d icingaweb -c "SELECT * FROM icingaweb_group;" &> /dev/null',
command => 'sudo -u postgres psql -U icingaweb -d icingaweb -f /vagrant/etc/schema/pgsql.schema.sql',
require => [ Exec['create-pgsql-icingaweb-db'] ]
}

Expand Down
11 changes: 2 additions & 9 deletions application/controllers/AuthenticationController.php
Expand Up @@ -33,15 +33,8 @@ class AuthenticationController extends ActionController
*/
public function loginAction()
{
if (@file_exists(Config::$configDir . '/setup.token')) {
try {
$config = Config::app()->toArray();
if (empty($config)) {
$this->redirectNow(Url::fromPath('setup'));
}
} catch (NotReadableError $e) {
// Gets thrown in case of insufficient permission only
}
if (@file_exists(Config::resolvePath('setup.token')) && !@file_exists(Config::resolvePath('config.ini'))) {
$this->redirectNow(Url::fromPath('setup'));
}

$auth = $this->Auth();
Expand Down
14 changes: 7 additions & 7 deletions application/controllers/ConfigController.php
Expand Up @@ -177,10 +177,10 @@ public function editauthenticationbackendAction()
public function removeauthenticationbackendAction()
{
$form = new ConfirmRemovalForm(array(
'onSuccess' => function ($request) {
'onSuccess' => function ($form) {
$configForm = new AuthenticationBackendConfigForm();
$configForm->setIniConfig(Config::app('authentication'));
$authBackend = $request->getQuery('auth_backend');
$authBackend = $form->getRequest()->getQuery('auth_backend');

try {
$configForm->remove($authBackend);
Expand Down Expand Up @@ -212,7 +212,7 @@ public function removeauthenticationbackendAction()
*/
public function resourceAction()
{
$this->view->resources = Config::app('resources', true)->toArray();
$this->view->resources = Config::app('resources', true)->keys();
$this->view->tabs->activate('resources');
}

Expand Down Expand Up @@ -250,10 +250,10 @@ public function editresourceAction()
public function removeresourceAction()
{
$form = new ConfirmRemovalForm(array(
'onSuccess' => function ($request) {
'onSuccess' => function ($form) {
$configForm = new ResourceConfigForm();
$configForm->setIniConfig(Config::app('resources'));
$resource = $request->getQuery('resource');
$resource = $form->getRequest()->getQuery('resource');

try {
$configForm->remove($resource);
Expand All @@ -274,9 +274,9 @@ public function removeresourceAction()

// Check if selected resource is currently used for authentication
$resource = $this->getRequest()->getQuery('resource');
$authConfig = Config::app('authentication')->toArray();
$authConfig = Config::app('authentication');
foreach ($authConfig as $backendName => $config) {
if (array_key_exists('resource', $config) && $config['resource'] === $resource) {
if ($config->get('resource') === $resource) {
$form->addError(sprintf(
$this->translate(
'The resource "%s" is currently in use by the authentication backend "%s". ' .
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/ListController.php
Expand Up @@ -5,7 +5,7 @@
use Icinga\Module\Monitoring\Controller;
use Icinga\Web\Url;
use Icinga\Application\Logger;
use Icinga\Application\Config;
use Icinga\Data\ConfigObject;
use Icinga\Protocol\File\FileReader;
use \Zend_Controller_Action_Exception as ActionError;

Expand Down Expand Up @@ -48,7 +48,7 @@ public function applicationlogAction()
. ' - (?<message>.*)$/'; // message

$loggerWriter = Logger::getInstance()->getWriter();
$resource = new FileReader(new Config(array(
$resource = new FileReader(new ConfigObject(array(
'filename' => $loggerWriter->getPath(),
'fields' => $pattern
)));
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/PreferenceController.php
Expand Up @@ -39,8 +39,8 @@ public static function createProvidedTabs()
*/
public function indexAction()
{
$storeConfig = Config::app()->preferences;
if ($storeConfig === null) {
$storeConfig = Config::app()->getSection('preferences');
if ($storeConfig->isEmpty()) {
throw new ConfigurationError(t('You need to configure how to store preferences first.'));
}

Expand Down
Expand Up @@ -66,7 +66,7 @@ public function createElements(array $formData)
'hidden',
'backend',
array(
'required' => true,
'disabled' => true,
'value' => 'autologin'
)
);
Expand Down
6 changes: 3 additions & 3 deletions application/forms/Config/Authentication/DbBackendForm.php
Expand Up @@ -5,8 +5,8 @@
namespace Icinga\Forms\Config\Authentication;

use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;
use Icinga\Authentication\Backend\DbUserBackend;

Expand Down Expand Up @@ -75,7 +75,7 @@ public function createElements(array $formData)
'hidden',
'backend',
array(
'required' => true,
'disabled' => true,
'value' => 'db'
)
);
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function isValidAuthenticationBackend(Form $form)
/**
* Return the configuration for the chosen resource
*
* @return Config
* @return ConfigObject
*/
public function getResourceConfig()
{
Expand Down
6 changes: 3 additions & 3 deletions application/forms/Config/Authentication/LdapBackendForm.php
Expand Up @@ -5,8 +5,8 @@
namespace Icinga\Forms\Config\Authentication;

use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;
use Icinga\Exception\AuthenticationException;
use Icinga\Authentication\Backend\LdapUserBackend;
Expand Down Expand Up @@ -96,7 +96,7 @@ public function createElements(array $formData)
'hidden',
'backend',
array(
'required' => true,
'disabled' => true,
'value' => 'ldap'
)
);
Expand Down Expand Up @@ -156,7 +156,7 @@ public static function isValidAuthenticationBackend(Form $form)
/**
* Return the configuration for the chosen resource
*
* @return Config
* @return ConfigObject
*/
public function getResourceConfig()
{
Expand Down
33 changes: 18 additions & 15 deletions application/forms/Config/AuthenticationBackendConfigForm.php
Expand Up @@ -9,6 +9,7 @@
use Icinga\Web\Notification;
use Icinga\Application\Config;
use Icinga\Application\Platform;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;
use Icinga\Exception\ConfigurationError;
use Icinga\Forms\Config\Authentication\DbBackendForm;
Expand Down Expand Up @@ -91,12 +92,12 @@ 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) {
} elseif ($this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Authentication backend already exists'));
}

unset($values['name']);
$this->config->{$name} = $values;
$this->config->setSection($name, $values);
return $this;
}

Expand All @@ -116,18 +117,19 @@ public function edit($name, array $values)
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) {
} elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}

$backendConfig = $this->config->getSection($name);
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});
$this->config->removeSection($name);
}

unset($values['name']);
$this->config->{$newName} = array_merge($backendConfig->toArray(), $values);
return $this->config->{$newName};
$this->config->setSection($newName, $backendConfig->merge($values));
return $backendConfig;
}

/**
Expand All @@ -143,11 +145,12 @@ public function remove($name)
{
if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing'));
} elseif (($backendConfig = $this->config->get($name)) === null) {
} elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}

unset($this->config->{$name});
$backendConfig = $this->config->getSection($name);
$this->config->removeSection($name);
return $backendConfig;
}

Expand All @@ -165,7 +168,7 @@ public function move($name, $position)
{
if (! $name) {
throw new InvalidArgumentException(t('Authentication backend name missing'));
} elseif ($this->config->get($name) === null) {
} elseif (! $this->config->hasSection($name)) {
throw new InvalidArgumentException(t('Unknown authentication backend provided'));
}

Expand All @@ -175,10 +178,10 @@ public function move($name, $position)

$newConfig = array();
foreach ($backendOrder as $backendName) {
$newConfig[$backendName] = $this->config->get($backendName);
$newConfig[$backendName] = $this->config->getSection($backendName);
}

$config = new Config($newConfig);
$config = Config::fromArray($newConfig);
$this->config = $config->setConfigFile($this->config->getConfigFile());
return $this;
}
Expand Down Expand Up @@ -235,13 +238,13 @@ public function onRequest()
if ($authBackend !== null) {
if ($authBackend === '') {
throw new ConfigurationError(t('Authentication backend name missing'));
} elseif (false === isset($this->config->{$authBackend})) {
} elseif (! $this->config->hasSection($authBackend)) {
throw new ConfigurationError(t('Unknown authentication backend provided'));
} elseif (false === isset($this->config->{$authBackend}->backend)) {
} elseif ($this->config->getSection($authBackend)->backend === null) {
throw new ConfigurationError(sprintf(t('Backend "%s" has no `backend\' setting'), $authBackend));
}

$configValues = $this->config->{$authBackend}->toArray();
$configValues = $this->config->getSection($authBackend)->toArray();
$configValues['type'] = $configValues['backend'];
$configValues['name'] = $authBackend;
$this->populate($configValues);
Expand Down Expand Up @@ -332,7 +335,7 @@ function ($authBackendCfg) {
/**
* Return the configuration for the chosen resource
*
* @return Config
* @return ConfigObject
*/
public function getResourceConfig()
{
Expand Down
2 changes: 1 addition & 1 deletion application/forms/Config/GeneralConfigForm.php
Expand Up @@ -48,7 +48,7 @@ public function onSuccess()
$sections[$section][$property] = $value;
}
foreach ($sections as $section => $config) {
$this->config->{$section} = $config;
$this->config->setSection($section, $config);
}

if ($this->save()) {
Expand Down
4 changes: 2 additions & 2 deletions application/forms/Config/Resource/DbResourceForm.php
Expand Up @@ -5,8 +5,8 @@
namespace Icinga\Forms\Config\Resource;

use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;
use Icinga\Application\Platform;

Expand Down Expand Up @@ -129,7 +129,7 @@ public function onSuccess()
public static function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Config($form->getValues()));
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
$resource->getConnection()->getConnection();
} catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
Expand Down
4 changes: 2 additions & 2 deletions application/forms/Config/Resource/LdapResourceForm.php
Expand Up @@ -5,8 +5,8 @@
namespace Icinga\Forms\Config\Resource;

use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public function onSuccess()
public static function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Config($form->getValues()));
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
if (false === $resource->testCredentials(
$form->getElement('bind_dn')->getValue(),
$form->getElement('bind_pw')->getValue()
Expand Down
4 changes: 2 additions & 2 deletions application/forms/Config/Resource/LivestatusResourceForm.php
Expand Up @@ -5,9 +5,9 @@
namespace Icinga\Forms\Config\Resource;

use Exception;
use Icinga\Application\Config;
use Icinga\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Data\ConfigObject;
use Icinga\Data\ResourceFactory;

/**
Expand Down Expand Up @@ -73,7 +73,7 @@ public function onSuccess()
public static function isValidResource(Form $form)
{
try {
$resource = ResourceFactory::createResource(new Config($form->getValues()));
$resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
$resource->connect()->disconnect();
} catch (Exception $e) {
$form->addError(t('Connectivity validation failed, connection to the given resource not possible.'));
Expand Down

0 comments on commit 10cfecf

Please sign in to comment.