From edb06ea8ea81c31e6ef876fa8b94e654efb984c1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 21 Aug 2013 11:02:53 +0200 Subject: [PATCH] CS: Fix viloations for touched files in branch feature/backend-configuration-ui-3776 refs #3776 --- application/controllers/ConfigController.php | 21 ++++--- .../Config/Authentication/BaseBackendForm.php | 27 ++++----- .../Config/Authentication/DbBackendForm.php | 45 +++++++------- .../Config/Authentication/LdapBackendForm.php | 59 +++++++++---------- .../forms/Config/AuthenticationForm.php | 54 ++++++++--------- application/forms/Config/GeneralForm.php | 43 +++++++------- application/forms/Config/LoggingForm.php | 28 ++++----- application/forms/Preference/GeneralForm.php | 17 ++---- library/Icinga/Application/Web.php | 5 +- .../Commandpipe/Transport/SecureShell.php | 29 +++++---- .../Commandpipe/Transport/Transport.php | 9 +-- .../Web/Controller/ActionController.php | 48 +++------------ library/Icinga/Web/Form.php | 57 +++++++++++------- .../Web/Form/Decorator/ConditionalHidden.php | 18 +++--- .../Icinga/Web/Form/Decorator/HelpText.php | 8 +-- .../Form/Validator/DateFormatValidator.php | 24 ++++---- .../Form/Validator/TimeFormatValidator.php | 22 +++---- .../Form/Validator/WritablePathValidator.php | 25 ++++---- .../controllers/ConfigController.php | 37 +++++------- .../Config/Backend/CreateBackendForm.php | 12 ++-- .../forms/Config/Backend/EditBackendForm.php | 25 ++++---- .../forms/Config/ConfirmRemovalForm.php | 17 +++--- .../Config/Instance/CreateInstanceForm.php | 14 ++--- .../Config/Instance/EditInstanceForm.php | 7 +-- .../monitoring/library/Monitoring/Backend.php | 21 +++---- 25 files changed, 318 insertions(+), 354 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 80be01cf2..5e6269ce8 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -158,7 +158,6 @@ class ConfigController extends BaseConfigController /** * Action for creating a new authentication backend - * */ public function authenticationAction() { @@ -182,7 +181,6 @@ class ConfigController extends BaseConfigController /** * Action for creating a new authentication backend - * */ public function createauthenticationbackendAction() { @@ -208,15 +206,16 @@ class ConfigController extends BaseConfigController } /** - * Write changes to an authentication file. + * Write changes to an authentication file * * This uses the Zend_Config_Writer_Ini implementation for now, as the Preserving ini writer can't * handle ordering * - * @param array $config The configuration changes + * @param array $config The configuration changes * - * @return bool True when persisting succeeded, otherwise false - * @see writeConfigFile() + * @return bool True when persisting succeeded, otherwise false + * + * @see writeConfigFile() */ private function writeAuthenticationFile($config) { $writer = new Zend_Config_Writer_Ini( @@ -229,13 +228,13 @@ class ConfigController extends BaseConfigController } /** - * Write changes to a configuration file $file, using the supllied writer or PreservingIniWriter if none is set + * 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 + * @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 + * @return bool True when persisting succeeded, otherwise false */ private function writeConfigFile($config, $file, $writer = null) { diff --git a/application/forms/Config/Authentication/BaseBackendForm.php b/application/forms/Config/Authentication/BaseBackendForm.php index 1844d4d47..01b0acb43 100644 --- a/application/forms/Config/Authentication/BaseBackendForm.php +++ b/application/forms/Config/Authentication/BaseBackendForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -29,16 +29,15 @@ namespace Icinga\Form\Config\Authentication; +use \Zend_Config; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\Logger; use \Icinga\Application\DbAdapterFactory; use \Icinga\Web\Form; -use \Zend_Config; /** * Base form for authentication backend forms - * */ abstract class BaseBackendForm extends Form { @@ -49,26 +48,26 @@ abstract class BaseBackendForm extends Form * * @var string */ - private $backendName = ""; + private $backendName = ''; /** * The backend configuration as a Zend_Config object * * @var Zend_Config */ - private $backend = null; + private $backend; /** * The resources to use instead of the factory provided ones (use for testing) * * @var Zend_Config */ - private $resources = null; + private $resources; /** * Set the name of the currently displayed backend * - * @param string $name The name to be stored as the section when persisting + * @param string $name The name to be stored as the section when persisting */ public function setBackendName($name) { @@ -98,7 +97,7 @@ abstract class BaseBackendForm extends Form /** * Set the backend configuration for initial population * - * @param Zend_Config $backend The backend to display in this form + * @param Zend_Config $backend The backend to display in this form */ public function setBackend(Zend_Config $backend) { @@ -109,7 +108,7 @@ abstract class BaseBackendForm extends Form * 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 + * @param array $resources The resources to use for populating the db selection field */ public function setResources(array $resources) { @@ -132,7 +131,7 @@ abstract class BaseBackendForm extends Form /** * Return an array containing all sections defined by this form as the key and all settings - * as an keyvalue subarray + * as an key-value sub-array * * @return array */ diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 017d164b3..df9d241a6 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -29,22 +29,18 @@ namespace Icinga\Form\Config\Authentication; - +use \Zend_Config; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\Logger; use \Icinga\Application\DbAdapterFactory; - use \Icinga\Web\Form; -use \Zend_Config; /** * Form class for adding/modifying database authentication backends - * */ class DbBackendForm extends BaseBackendForm { - /** * Return a list of all database resource ready to be used as the multiOptions * attribute in a Zend_Form_Element_Select object @@ -64,10 +60,10 @@ class DbBackendForm extends BaseBackendForm } /** - * Create this form and add all required elements - * - * @see Form::create() - */ + * Create this form and add all required elements + * + * @see Form::create() + */ public function create() { $name = $this->filterName($this->getBackendName()); @@ -76,11 +72,11 @@ class DbBackendForm extends BaseBackendForm 'text', 'backend_' . $name . '_name', array( - 'required' => true, - 'allowEmpty'=> false, - 'label' => 'Backend Name', - 'helptext' => 'The name of this authentication provider', - 'value' => $this->getBackendName() + 'required' => true, + 'allowEmpty' => false, + 'label' => 'Backend Name', + 'helptext' => 'The name of this authentication provider', + 'value' => $this->getBackendName() ) ); @@ -103,8 +99,9 @@ class DbBackendForm extends BaseBackendForm /** * Return the datatbase authentication backend configuration for this form * - * @return array - * @see BaseBackendForm::getConfig + * @return array + * + * @see BaseBackendForm::getConfig() */ public function getConfig() { @@ -113,9 +110,9 @@ class DbBackendForm extends BaseBackendForm $section = $this->getValue($prefix . 'name'); $cfg = array( - 'backend' => 'db', - 'target' => 'user', - 'resource' => $this->getValue($prefix . 'resource'), + 'backend' => 'db', + 'target' => 'user', + 'resource' => $this->getValue($prefix . 'resource'), ); return array( $section => $cfg diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index 5b070025d..d186712f0 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -28,17 +28,15 @@ namespace Icinga\Form\Config\Authentication; +use \Zend_Config; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\Logger; use \Icinga\Application\DbAdapterFactory; - use \Icinga\Web\Form; -use \Zend_Config; /** * Form for adding or modifying LDAP authentication backends - * */ class LdapBackendForm extends BaseBackendForm { @@ -56,11 +54,11 @@ class LdapBackendForm extends BaseBackendForm 'text', 'backend_'.$name.'_name', array( - 'required' => true, - 'allowEmpty'=> false, - 'label' => 'Backend Name', - 'helptext' => 'The name of this authentication backend', - 'value' => $this->getBackendName() + 'required' => true, + 'allowEmpty' => false, + 'label' => 'Backend Name', + 'helptext' => 'The name of this authentication backend', + 'value' => $this->getBackendName() ) ); @@ -82,7 +80,7 @@ class LdapBackendForm extends BaseBackendForm array( 'label' => 'LDAP Root DN', 'value' => $backend->get('root_dn', 'ou=people,dc=icinga,dc=org'), - 'helptext' => 'The path where users can be found on the ldap server', + 'helptext' => 'The path where users can be found on the ldap server', 'required' => true ) ); @@ -93,7 +91,7 @@ class LdapBackendForm extends BaseBackendForm array( 'label' => 'LDAP Bind DN', 'value' => $backend->get('bind_dn', 'cn=admin,cn=config'), - 'helptext' => 'The user dn to use for querying the ldap server', + 'helptext' => 'The user dn to use for querying the ldap server', 'required' => true ) ); @@ -102,11 +100,11 @@ class LdapBackendForm extends BaseBackendForm 'password', 'backend_' . $name . '_bind_pw', array( - 'label' => 'LDAP Bind Password', - 'renderPassword' => true, - 'value' => $backend->get('bind_pw', 'admin'), - 'helptext' => 'The password to use for querying the ldap server', - 'required' => true + 'label' => 'LDAP Bind Password', + 'renderPassword' => true, + 'value' => $backend->get('bind_pw', 'admin'), + 'helptext' => 'The password to use for querying the ldap server', + 'required' => true ) ); @@ -138,8 +136,9 @@ class LdapBackendForm extends BaseBackendForm /** * Return the ldap authentication backend configuration for this form * - * @return array - * @see BaseBackendForm::getConfig + * @return array + * + * @see BaseBackendForm::getConfig() */ public function getConfig() { @@ -148,14 +147,14 @@ class LdapBackendForm extends BaseBackendForm $section = $this->getValue($prefix . 'name'); $cfg = array( - 'backend' => 'ldap', - 'target' => 'user', - 'hostname' => $this->getValue($prefix . 'hostname'), - 'root_dn' => $this->getValue($prefix . 'root_dn'), - 'bind_dn' => $this->getValue($prefix . 'bind_dn'), - 'bind_pw' => $this->getValue($prefix . 'bind_pw'), - 'user_class' => $this->getValue($prefix . 'user_class'), - 'user_name_attribute' => $this->getValue($prefix . 'user_name_attribute') + 'backend' => 'ldap', + 'target' => 'user', + 'hostname' => $this->getValue($prefix . 'hostname'), + 'root_dn' => $this->getValue($prefix . 'root_dn'), + 'bind_dn' => $this->getValue($prefix . 'bind_dn'), + 'bind_pw' => $this->getValue($prefix . 'bind_pw'), + 'user_class' => $this->getValue($prefix . 'user_class'), + 'user_name_attribute' => $this->getValue($prefix . 'user_name_attribute') ); return array( $section => $cfg diff --git a/application/forms/Config/AuthenticationForm.php b/application/forms/Config/AuthenticationForm.php index 68e0b3118..1ec5068a8 100644 --- a/application/forms/Config/AuthenticationForm.php +++ b/application/forms/Config/AuthenticationForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -28,15 +28,14 @@ namespace Icinga\Form\Config; +use \Zend_Config; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\Logger; use \Icinga\Application\DbAdapterFactory; - use \Icinga\Web\Form; use \Icinga\Web\Form\Element\Note; use \Icinga\Web\Form\Decorator\ConditionalHidden; -use \Zend_Config; /** * Form for modifying the authentication provider and order. @@ -71,7 +70,7 @@ class AuthenticationForm extends Form * 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 + * @param array $resources The resources to use for populating the db selection field */ public function setResources(array $resources) { @@ -93,9 +92,9 @@ class AuthenticationForm extends Form * * The button will have the name "backend_$name_remove" * - * @param string $name The backend to add this button for + * @param string $name The backend to add this button for * - * @return string The id of the added button + * @return string The id of the added button */ private function addRemoveHint($name) { @@ -103,10 +102,10 @@ class AuthenticationForm extends Form 'checkbox', 'backend_' . $name . '_remove', array( - 'name' => 'backend_' . $name . '_remove', - 'label' => 'Remove this authentication provider', - 'value' => $name, - 'checked' => $this->isMarkedForDeletion($name) + 'name' => 'backend_' . $name . '_remove', + 'label' => 'Remove this authentication provider', + 'value' => $name, + 'checked' => $this->isMarkedForDeletion($name) ) ); $this->enableAutoSubmit(array('backend_' . $name . '_remove')); @@ -123,8 +122,8 @@ class AuthenticationForm extends Form * the Zend validation logic (maybe our own validation logic breaks it), we now create the form, but add * all elements to this form explicitly. * - * @param string $name The name of the backend to add - * @param Zend_Config $backend The configuration of the backend + * @param string $name The name of the backend to add + * @param Zend_Config $backend The configuration of the backend */ private function addProviderForm($name, $backend) { @@ -159,10 +158,10 @@ class AuthenticationForm extends Form /** * Add the buttons for modifying authentication priorities * - * @param string $name The name of the backend to add the buttons for - * @param array $order The current order which will be used to determine the changed order + * @param string $name The name of the backend to add the buttons for + * @param array $order The current order which will be used to determine the changed order * - * @return array An array containing the newly added form element ids as strings + * @return array An array containing the newly added form element ids as strings */ public function addPriorityButtons($name, $order = array()) { @@ -204,24 +203,25 @@ class AuthenticationForm extends Form /** * Overwrite for Zend_Form::populate in order to preserve the modified priority of the backends * - * @param array $values The values to populate the form with + * @param array $values The values to populate the form with * - * @return void|\Zend_Form - * @see Zend_Form::populate + * @return self + * + * @see Zend_Form::populate() */ public function populate(array $values) { $last_priority = $this->getValue('current_priority'); parent::populate($values); $this->getElement('current_priority')->setValue($last_priority); - + return $this; } /** * Return an array containing all authentication providers in the order they should be used * - * @return array An array containing the identifiers (section names) of the authentication backend in - * the order they should be persisted + * @return array An array containing the identifiers (section names) of the authentication backend in + * the order they should be persisted */ private function getAuthenticationOrder() { @@ -243,9 +243,9 @@ class AuthenticationForm extends Form /** * Return true if the backend should be deleted when the changes are persisted * - * @param string $backendName The name of the backend to check for being in a 'delete' state + * @param string $backendName The name of the backend to check for being in a 'delete' state * - * @return bool Whether this backend will be deleted on save + * @return bool Whether this backend will be deleted on save */ private function isMarkedForDeletion($backendName) { diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index b5dbc00fe..cd30a3b8f 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -28,6 +28,10 @@ namespace Icinga\Form\Config; +use \DateTimeZone; +use \Zend_Config; +use \Zend_Form_Element_Text; +use \Zend_Form_Element_Select; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\DbAdapterFactory; @@ -37,11 +41,6 @@ use \Icinga\Web\Form\Validator\TimeFormatValidator; use \Icinga\Web\Form\Validator\DateFormatValidator; use \Icinga\Web\Form\Decorator\ConditionalHidden; -use \DateTimeZone; -use \Zend_Config; -use \Zend_Form_Element_Text; -use \Zend_Form_Element_Select; - /** * Configuration form for general, application-wide settings * @@ -93,8 +92,9 @@ class GeneralForm extends Form /** * Return the config path set for this form or the application wide config path if none is set * - * @return string - * @see IcingaConfig::configDir + * @return string + * + * @see IcingaConfig::configDir */ public function getConfigDir() { @@ -105,7 +105,7 @@ class GeneralForm extends Form * 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 + * @param array $resources The resources to use for populating the db selection field */ public function setResources(array $resources) { @@ -129,7 +129,7 @@ class GeneralForm extends Form /** * Add the checkbox for using the development environment to this form * - * @param Zend_Config $cfg The "global" section of the config.ini + * @param Zend_Config $cfg The "global" section of the config.ini */ private function addDevelopmentCheckbox(Zend_Config $cfg) { @@ -140,9 +140,8 @@ class GeneralForm extends Form array( 'label' => 'Development Mode', 'required' => true, - 'helptext' => 'Set true to show more detailed errors ' - . 'and disable certain optimizations ' - . 'in order to make debugging easier.', + 'helptext' => 'Set true to show more detailed errors and disable certain optimizations in order to ' + . 'make debugging easier.', 'tooltip' => 'More verbose output', 'value' => $env === 'development' ) @@ -155,7 +154,7 @@ class GeneralForm extends Form * * Possible values are determined by DateTimeZone::listIdentifiers * - * @param Zend_Config $cfg The "global" section of the config.ini + * @param Zend_Config $cfg The "global" section of the config.ini */ private function addTimezoneSelection(Zend_Config $cfg) { @@ -182,7 +181,7 @@ class GeneralForm extends Form /** * Add configuration settings for module paths * - * @param Zend_Config $cfg The "global" section of the config.ini + * @param Zend_Config $cfg The "global" section of the config.ini */ private function addModuleSettings(Zend_Config $cfg) { @@ -201,12 +200,12 @@ class GeneralForm extends Form /** * Add text fields for the date and time format used in the application * - * @param Zend_Config $cfg The "global" section of the config.ini + * @param Zend_Config $cfg The "global" section of the config.ini */ private function addDateFormatSettings(Zend_Config $cfg) { $phpUrl = '' - . 'the official PHP documentation'; + . 'the official PHP documentation'; $txtDefaultDateFormat = new Zend_Form_Element_Text( array( @@ -236,7 +235,7 @@ class GeneralForm extends Form /** * Add form elements for setting the user preference storage backend * - * @param Zend_Config $cfg The Zend_config object of preference section + * @param Zend_Config $cfg The Zend_config object of preference section */ public function addUserPreferencesDialog(Zend_Config $cfg) { diff --git a/application/forms/Config/LoggingForm.php b/application/forms/Config/LoggingForm.php index 967c29155..bf426f342 100644 --- a/application/forms/Config/LoggingForm.php +++ b/application/forms/Config/LoggingForm.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -28,18 +28,16 @@ namespace Icinga\Form\Config; +use \Zend_Config; +use \Zend_Form_Element_Text; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Web\Form; -use \Icinga\Web\Form\Element\Note; use \Icinga\Web\Form\Validator\WritablePathValidator; use \Icinga\Web\Form\Decorator\ConditionalHidden; -use \Zend_Config; -use \Zend_Form_Element_Text; /** * Form class for setting the application wide logging configuration - * */ class LoggingForm extends Form { @@ -62,7 +60,7 @@ class LoggingForm extends Form * * If not called, default values are used instead * - * @param Zend_Config $cfg The config.ini to set with this form + * @param Zend_Config $cfg The config.ini to set with this form */ public function setConfiguration(Zend_Config $cfg) { @@ -72,7 +70,7 @@ class LoggingForm extends Form /** * Set a different base directory to use for default paths instead of the one provided by Icinga::app() * - * @param string $dir The new directory to use + * @param string $dir The new directory to use */ public function setBaseDir($dir) { @@ -102,9 +100,9 @@ class LoggingForm extends Form * and true or if it is not submitted, but the configuration for debug * logging is set to true * - * @param Zend_Config $config The debug section of the config.ini + * @param Zend_Config $config The debug section of the config.ini * - * @return bool Whether to display the debug path field or not + * @return bool Whether to display the debug path field or not */ private function shouldDisplayDebugLog(Zend_Config $config) { @@ -143,7 +141,7 @@ class LoggingForm extends Form 'name' => 'logging_app_target', 'label' => 'Application Log Path', 'helptext' => 'The logfile to write the icingaweb debug logs to.' - . 'The webserver must be able to write at this location', + . 'The webserver must be able to write at this location', 'required' => true, 'value' => $logging->get('target', '/var/log/icingaweb.log') ) @@ -198,7 +196,7 @@ class LoggingForm extends Form /** * Return a Zend_Config object containing the state defined in this form * - * @return Zend_Config The config defined in this form + * @return Zend_Config The config defined in this form */ public function getConfig() { diff --git a/application/forms/Preference/GeneralForm.php b/application/forms/Preference/GeneralForm.php index c51347821..306439a17 100644 --- a/application/forms/Preference/GeneralForm.php +++ b/application/forms/Preference/GeneralForm.php @@ -28,6 +28,10 @@ namespace Icinga\Form\Preference; +use \DateTimeZone; +use \Zend_Config; +use \Zend_Form_Element_Text; +use \Zend_Form_Element_Select; use \Icinga\Application\Config as IcingaConfig; use \Icinga\Application\Icinga; use \Icinga\Application\DbAdapterFactory; @@ -36,14 +40,8 @@ use \Icinga\Web\Form; use \Icinga\Web\Form\Validator\TimeFormatValidator; use \Icinga\Web\Form\Validator\DateFormatValidator; -use \DateTimeZone; -use \Zend_Config; -use \Zend_Form_Element_Text; -use \Zend_Form_Element_Select; - /** * General user preferences - * */ class GeneralForm extends Form { @@ -100,7 +98,7 @@ class GeneralForm extends Form * 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 valuse + * @param Zend_Config $cfg The "global" section of the config.ini to be used as default valuse */ private function addTimezoneSelection(Zend_Config $cfg) { @@ -143,7 +141,7 @@ class GeneralForm extends Form * * 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 values + * @param Zend_Config $cfg The "global" section of the config.ini to be used as default values */ private function addDateFormatSettings(Zend_Config $cfg) { @@ -205,8 +203,6 @@ class GeneralForm extends Form } $this->enableAutoSubmit(array('default_time_format', 'default_date_format')); - - } /** @@ -243,6 +239,5 @@ class GeneralForm extends Form 'app.dateFormat' => $values['date_format'], 'app.timeFormat' => $values['time_format'] ); - } } diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 570abb320..4ff92ede9 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -207,8 +207,9 @@ class Web extends ApplicationBootstrap /** * Create user object and inject preference interface * - * @throws ConfigurationError * @return User + * + * @throws ConfigurationError */ private function setupUser() { @@ -328,7 +329,7 @@ class Web extends ApplicationBootstrap /** * Configure pagination settings - + * * @return self */ private function setupPagination() diff --git a/library/Icinga/Protocol/Commandpipe/Transport/SecureShell.php b/library/Icinga/Protocol/Commandpipe/Transport/SecureShell.php index 3d03c4908..e90c89000 100644 --- a/library/Icinga/Protocol/Commandpipe/Transport/SecureShell.php +++ b/library/Icinga/Protocol/Commandpipe/Transport/SecureShell.php @@ -28,12 +28,14 @@ namespace Icinga\Protocol\Commandpipe\Transport; -use Icinga\Application\Logger; +use \RuntimeException; +use \Zend_Config; +use \Icinga\Application\Logger; /** - * Command pipe transport class that uses ssh for connecting to a remote filesystem with the icinga.cmd pipe - * The remote host must have KeyAuth enabled for this user + * Command pipe transport class that uses ssh for connecting to a remote filesystem with the icinga.cmd pipe * + * The remote host must have KeyAuth enabled for this user */ class SecureShell implements Transport { @@ -66,20 +68,27 @@ class SecureShell implements Transport private $user = null; /** - * @see Transport::setEndpoint() + * Overwrite the target file of this Transport class using the given config from instances.ini * + * @param Zend_Config $config + * + * @see Transport::setEndpoint() */ - public function setEndpoint(\Zend_Config $config) + public function setEndpoint(Zend_Config $config) { - $this->host = isset($config->host) ? $config->host : "localhost"; + $this->host = isset($config->host) ? $config->host : 'localhost'; $this->port = isset($config->port) ? $config->port : 22; $this->user = isset($config->user) ? $config->user : null; - $this->path = isset($config->path) ? $config->path : "/usr/local/icinga/var/rw/icinga.cmd"; + $this->path = isset($config->path) ? $config->path : '/usr/local/icinga/var/rw/icinga.cmd'; } /** - * @see Transport::send() + * Write the given external command to the command pipe * + * @param string $command + * + * @throws RuntimeException When the command could not be sent to the remote Icinga host + * @see Transport::send() */ public function send($command) { @@ -113,11 +122,11 @@ class SecureShell implements Transport Logger::debug("Return code %s: %s ", $retCode, $output); if ($retCode != 0) { - $msg = 'Could not send command to remote icinga host: ' + $msg = 'Could not send command to remote Icinga host: ' . implode(PHP_EOL, $output) . " (returncode $retCode)"; Logger::error($msg); - throw new \RuntimeException($msg); + throw new RuntimeException($msg); } } } diff --git a/library/Icinga/Protocol/Commandpipe/Transport/Transport.php b/library/Icinga/Protocol/Commandpipe/Transport/Transport.php index d249c86e0..c33190092 100644 --- a/library/Icinga/Protocol/Commandpipe/Transport/Transport.php +++ b/library/Icinga/Protocol/Commandpipe/Transport/Transport.php @@ -28,23 +28,24 @@ namespace Icinga\Protocol\Commandpipe\Transport; +use \Zend_Config; + /** * Interface for Transport classes handling the concrete access to the command pipe - * */ interface Transport { /** * Overwrite the target file of this Transport class using the given config from instances.ini * - * @param \Zend_Config $config A configuration file containing a 'path' setting + * @param Zend_Config $config A configuration file containing a 'path' setting */ - public function setEndpoint(\Zend_Config $config); + public function setEndpoint(Zend_Config $config); /** * Write the given external command to the command pipe * - * @param string $message The command to send, without the timestamp (this will be added here) + * @param string $message The command to send, without the timestamp (this will be added here) */ public function send($message); } diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 5698de2d0..9db898673 100755 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -28,26 +28,22 @@ namespace Icinga\Web\Controller; +use \Zend_Controller_Action as ZfController; +use \Zend_Controller_Request_Abstract as ZfRequest; +use \Zend_Controller_Response_Abstract as ZfResponse; +use \Zend_Controller_Action_HelperBroker as ZfActionHelper; +use \Zend_Layout as ZfLayout; use \Icinga\Authentication\Manager as AuthManager; use \Icinga\Application\Benchmark; use \Icinga\Exception; use \Icinga\Application\Config; use \Icinga\Web\Notification; use \Icinga\Web\Widget\Tabs; -use \Zend_Layout as ZfLayout; -use \Zend_Controller_Action as ZfController; -use \Zend_Controller_Request_Abstract as ZfRequest; -use \Zend_Controller_Response_Abstract as ZfResponse; -use \Zend_Controller_Action_HelperBroker as ZfActionHelper; /** * Base class for all core action controllers * * All Icinga Web core controllers should extend this class - * - * @copyright Copyright (c) 2013 Icinga-Web Team - * @author Icinga-Web Team - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License */ class ActionController extends ZfController { @@ -148,7 +144,7 @@ class ActionController extends ZfController /** * Return the tabs * - * @return \Icinga\Widget\Web\Tabs + * @return Tabs */ public function getTabs() { @@ -159,39 +155,15 @@ class ActionController extends ZfController /** * Translate the given string with the global translation catalog * - * @param string $string The string that should be translated + * @param string $string The string that should be translated * - * @return string + * @return string */ public function translate($string) { return t($string); } - /** - * Whether the current user has the given permission - * - * TODO: This has not been implemented yet (Feature #4111) - * - * @return bool - */ - final protected function hasPermission($uri) - { - return true; - } - - /** - * Assert the current user has the given permission - * - * TODO: This has not been implemented yet (Feature #4111) - * - * @return self - */ - final protected function assertPermission() - { - return $this; - } - private function redirectToLogin() { $this->_request->setModuleName('default') @@ -202,8 +174,6 @@ class ActionController extends ZfController /** * Prepare action execution by testing for correct permissions and setting shortcuts - * - * @return void */ public function preDispatch() { @@ -229,7 +199,7 @@ class ActionController extends ZfController /** * Redirect to a specific url, updating the browsers URL field * - * @param Url|string $url The target to redirect to + * @param Url|string $url The target to redirect to **/ public function redirectNow($url) { diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 14209a7c9..2b7bf738f 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -25,13 +25,13 @@ namespace Icinga\Web; -use \Icinga\Web\Form\Decorator\HelpText; use \Zend_Controller_Request_Abstract; +use \Zend_Form; use \Zend_Form_Element_Submit; use \Zend_Form_Element_Reset; use \Zend_View_Interface; -use \Zend_Form; use \Icinga\Exception\ProgrammingError; +use \Icinga\Web\Form\Decorator\HelpText; use \Icinga\Web\Form\InvalidCSRFTokenException; /** @@ -41,6 +41,7 @@ abstract class Form extends Zend_Form { /** * The form's request object + * * @var Zend_Controller_Request_Abstract */ private $request; @@ -49,24 +50,28 @@ abstract class Form extends Zend_Form * Whether this form should NOT add random generated "challenge" tokens that are associated with the user's current * session in order to prevent Cross-Site Request Forgery (CSRF). It is the form's responsibility to verify the * existence and correctness of this token + * * @var bool */ protected $tokenDisabled = false; /** * Name of the CSRF token element (used to create non-colliding hashes) + * * @var string */ private $tokenElementName = 'CSRFToken'; /** * Flag to indicate that form is already build + * * @var bool */ private $created = false; /** * Session id used for CSRF token generation + * * @var string */ private $sessionId; @@ -95,6 +100,7 @@ abstract class Form extends Zend_Form * If the ID has never been set, the ID from session_id() is returned * * @return string + * * @see session_id() * @see setSessionId() */ @@ -111,7 +117,7 @@ abstract class Form extends Zend_Form * * This method should be used for testing purposes only * - * @param string $sessionId + * @param string $sessionId */ public function setSessionId($sessionId) { @@ -121,7 +127,7 @@ abstract class Form extends Zend_Form /** * Return the HTML element name of the CSRF token field * - * @return string + * @return string */ public function getTokenElementName() { @@ -132,6 +138,7 @@ abstract class Form extends Zend_Form * Render the form to HTML * * @param Zend_View_Interface $view + * * @return string */ public function render(Zend_View_Interface $view = null) @@ -156,7 +163,7 @@ abstract class Form extends Zend_Form /** * Setter for the request * - * @param Zend_Controller_Request_Abstract $request + * @param Zend_Controller_Request_Abstract $request */ public function setRequest(Zend_Controller_Request_Abstract $request) { @@ -166,7 +173,7 @@ abstract class Form extends Zend_Form /** * Getter for the request * - * @return Zend_Controller_Request_Abstract + * @return Zend_Controller_Request_Abstract */ public function getRequest() { @@ -197,7 +204,7 @@ abstract class Form extends Zend_Form if (!$this->getAction() && $this->getRequest()) { $this->setAction($this->getRequest()->getRequestUri()); } - $this->enableAdditionalDecorators(); + $this->addElementDecorators(); $this->created = true; } } @@ -205,7 +212,7 @@ abstract class Form extends Zend_Form /** * Setter for the cancel label * - * @param string $cancelLabel + * @param string $cancelLabel */ public function setCancelLabel($cancelLabel) { @@ -230,7 +237,7 @@ abstract class Form extends Zend_Form /** * Setter for the submit label * - * @param string $submitLabel + * @param string $submitLabel */ public function setSubmitLabel($submitLabel) { @@ -257,8 +264,9 @@ abstract class Form extends Zend_Form * * Enables automatic submission of this form once the user edits specific elements * - * @param array $triggerElements The element names which should auto-submit the form - * @throws ProgrammingError When an element is found which does not yet exist + * @param array $triggerElements The element names which should auto-submit the form + * + * @throws ProgrammingError When an element is found which does not yet exist */ final public function enableAutoSubmit($triggerElements) { @@ -281,7 +289,7 @@ abstract class Form extends Zend_Form * Ensures that the current request method is POST, that the form was manually submitted and that the data provided * in the request is valid and gets repopulated in case its invalid. * - * @return bool + * @return bool */ public function isSubmittedAndValid() { @@ -309,13 +317,13 @@ abstract class Form extends Zend_Form } } - /** * Disable CSRF counter measure and remove its field if already added * * This method should be used for testing purposes only * - * @param bool $disabled + * @param bool $disabled + * * @see tokenDisabled */ final public function setTokenDisabled($disabled = true) @@ -347,8 +355,9 @@ abstract class Form extends Zend_Form /** * Test the submitted data for a correct CSRF token * - * @param array $checkData The POST data send by the user - * @throws InvalidCSRFTokenException When CSRF Validation fails + * @param array $checkData The POST data send by the user + * + * @throws InvalidCSRFTokenException When CSRF Validation fails */ final public function assertValidCsrfToken(array $checkData) { @@ -366,7 +375,8 @@ abstract class Form extends Zend_Form /** * Check whether the form's CSRF token-field has a valid value * - * @param string $elementValue Value from the form element + * @param string $elementValue Value from the form element + * * @return bool */ private function hasValidCsrfToken($elementValue) @@ -387,7 +397,14 @@ abstract class Form extends Zend_Form return $token === hash('sha256', $this->getSessionId() . $seed); } - public function enableAdditionalDecorators() + /** + * Add element decorators which apply to all elements + * + * Adds `HelpText` decorator + * + * @see HelpText + */ + private function addElementDecorators() { foreach ($this->getElements() as $element) { $element->addDecorator(new HelpText()); @@ -397,7 +414,7 @@ abstract class Form extends Zend_Form /** * Generate a new (seed, token) pair * - * @return array + * @return array */ final public function generateCsrfToken() { @@ -410,7 +427,7 @@ abstract class Form extends Zend_Form /** * Return the string representation of the CSRF seed/token pair * - * @return string + * @return string */ final public function generateCsrfTokenAsString() { diff --git a/library/Icinga/Web/Form/Decorator/ConditionalHidden.php b/library/Icinga/Web/Form/Decorator/ConditionalHidden.php index d39b2f157..40dac4a75 100644 --- a/library/Icinga/Web/Form/Decorator/ConditionalHidden.php +++ b/library/Icinga/Web/Form/Decorator/ConditionalHidden.php @@ -2,24 +2,24 @@ // {{{ICINGA_LICENSE_HEADER}}} /** * This file is part of Icinga 2 Web. - * + * * Icinga 2 Web - 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 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team @@ -44,13 +44,9 @@ class ConditionalHidden extends Zend_Form_Decorator_Abstract * Generate a field that will be wrapped in