diff --git a/application/clicommands/CleanupCommand.php b/application/clicommands/CleanupCommand.php index f0041c8..d20cf13 100644 --- a/application/clicommands/CleanupCommand.php +++ b/application/clicommands/CleanupCommand.php @@ -59,7 +59,8 @@ class CleanupCommand extends Command continue; } - if (Module::exists('icingadb') + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); diff --git a/application/clicommands/ProcessCommand.php b/application/clicommands/ProcessCommand.php index 2090b63..c343c38 100644 --- a/application/clicommands/ProcessCommand.php +++ b/application/clicommands/ProcessCommand.php @@ -136,7 +136,8 @@ class ProcessCommand extends Command try { /** @var BpNode $node */ $node = $bp->getNode($nodeName); - if (Module::exists('icingadb') + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); diff --git a/application/controllers/NodeController.php b/application/controllers/NodeController.php index e5c657f..5cc305c 100644 --- a/application/controllers/NodeController.php +++ b/application/controllers/NodeController.php @@ -95,7 +95,8 @@ class NodeController extends Controller continue; } - if (Module::exists('icingadb') && + if ( + Module::exists('icingadb') && (! $config->getBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($config); diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 406bce2..329b258 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -94,7 +94,8 @@ class ProcessController extends Controller $bp = $this->loadModifiedBpConfig(); $node = $this->getNode($bp); - if (Module::exists('icingadb') && + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); @@ -704,7 +705,7 @@ class ProcessController extends Controller $tabs = $this->tabs()->add('config', array( 'label' => $this->translate('Process Configuration'), - 'url' =>Url::fromPath('businessprocess/process/config', $params) + 'url' => Url::fromPath('businessprocess/process/config', $params) )); if ($this->params->get('showDiff')) { @@ -713,7 +714,7 @@ class ProcessController extends Controller $tabs->add('source', array( 'label' => $this->translate('Source'), - 'url' =>Url::fromPath('businessprocess/process/source', $params) + 'url' => Url::fromPath('businessprocess/process/source', $params) )); return $tabs; diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 671d00c..15d3f71 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -56,7 +56,7 @@ class ServiceController extends Controller } else { $hostName = $this->params->get('host'); $serviceName = $this->params->get('service'); - + $query = $this->backend->select() ->from('servicestatus', array('service_description')) ->where('host_name', $hostName) diff --git a/application/controllers/SuggestionsController.php b/application/controllers/SuggestionsController.php index b98755b..c26a74c 100644 --- a/application/controllers/SuggestionsController.php +++ b/application/controllers/SuggestionsController.php @@ -84,7 +84,8 @@ class SuggestionsController extends Controller $search = "@$config:$search"; } - if (in_array($search, $suggestions->getExcludeTerms(), true) + if ( + in_array($search, $suggestions->getExcludeTerms(), true) || isset($ignoreList[$search]) || ($forParent ? $forParent->hasChild($search) @@ -94,7 +95,8 @@ class SuggestionsController extends Controller continue; } - if ($suggestions->matchSearch($bpNode->getName()) + if ( + $suggestions->matchSearch($bpNode->getName()) || (! $bpNode->hasAlias() || $suggestions->matchSearch($bpNode->getAlias())) || $bpNode->getName() === $suggestions->getOriginalSearchValue() || $bpNode->getAlias() === $suggestions->getOriginalSearchValue() diff --git a/application/forms/BpConfigForm.php b/application/forms/BpConfigForm.php index 1abd987..0e9a5b3 100644 --- a/application/forms/BpConfigForm.php +++ b/application/forms/BpConfigForm.php @@ -204,8 +204,10 @@ class BpConfigForm extends BpConfigBaseForm } $meta = $config->getMetadata(); foreach ($this->getValues() as $key => $value) { - if (! in_array($key, ['Title', 'Description', 'Backend'], true) - && ($value === null || $value === '')) { + if ( + ! in_array($key, ['Title', 'Description', 'Backend'], true) + && ($value === null || $value === '') + ) { continue; } diff --git a/application/views/helpers/RenderStateBadges.php b/application/views/helpers/RenderStateBadges.php index f0c8e79..7d5f9b3 100644 --- a/application/views/helpers/RenderStateBadges.php +++ b/application/views/helpers/RenderStateBadges.php @@ -10,7 +10,8 @@ class Zend_View_Helper_RenderStateBadges extends Zend_View_Helper_Abstract // ph $html = ''; foreach ($summary as $state => $cnt) { - if ($cnt === 0 + if ( + $cnt === 0 || $state === 'OK' || $state === 'UP' ) { diff --git a/library/Businessprocess/BpConfig.php b/library/Businessprocess/BpConfig.php index c9e70fd..f0b3584 100644 --- a/library/Businessprocess/BpConfig.php +++ b/library/Businessprocess/BpConfig.php @@ -15,9 +15,9 @@ use ipl\Sql\Connection as IcingaDbConnection; class BpConfig { - const SOFT_STATE = 0; + public const SOFT_STATE = 0; - const HARD_STATE = 1; + public const HARD_STATE = 1; /** * Name of the configured monitoring backend @@ -295,8 +295,10 @@ class BpConfig public function getBackend() { if ($this->backend === null) { - if (Module::exists('icingadb') - && (! $this->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())) { + if ( + Module::exists('icingadb') + && (! $this->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) + ) { $this->backend = IcingaDbObject::fetchDb(); } else { $this->backend = MonitoringBackend::instance( diff --git a/library/Businessprocess/BpNode.php b/library/Businessprocess/BpNode.php index 7ac4073..98039ac 100644 --- a/library/Businessprocess/BpNode.php +++ b/library/Businessprocess/BpNode.php @@ -9,11 +9,11 @@ use ipl\Web\Widget\Icon; class BpNode extends Node { - const OP_AND = '&'; - const OP_OR = '|'; - const OP_XOR = '^'; - const OP_NOT = '!'; - const OP_DEGRADED = '%'; + public const OP_AND = '&'; + public const OP_OR = '|'; + public const OP_XOR = '^'; + public const OP_NOT = '!'; + public const OP_DEGRADED = '%'; protected $operator = '&'; @@ -261,7 +261,7 @@ class BpNode extends Node if ($child instanceof MonitoredNode) { $empty = false; break; - } elseif (!$child->isEmpty()) { + } elseif (! $child->isEmpty()) { $empty = false; } } @@ -561,7 +561,7 @@ class BpNode extends Node public function hasChildren($filter = null) { $childNames = $this->getChildNames(); - return !empty($childNames); + return ! empty($childNames); } public function getChildNames() diff --git a/library/Businessprocess/Common/Sort.php b/library/Businessprocess/Common/Sort.php index 0dfc248..3d2f824 100644 --- a/library/Businessprocess/Common/Sort.php +++ b/library/Businessprocess/Common/Sort.php @@ -1,4 +1,5 @@ applyRestrictions($query); return $object; @@ -88,7 +88,7 @@ class IcingaDbObject public static function fetchDb() { - $object = new self; + $object = new self(); return $object->getDb(); } } diff --git a/library/Businessprocess/Modification/NodeCreateAction.php b/library/Businessprocess/Modification/NodeCreateAction.php index 167d3bc..a307f7a 100644 --- a/library/Businessprocess/Modification/NodeCreateAction.php +++ b/library/Businessprocess/Modification/NodeCreateAction.php @@ -78,7 +78,7 @@ class NodeCreateAction extends NodeAction } $parent = $this->getParentName(); - if ($parent !== null && !$config->hasBpNode($parent)) { + if ($parent !== null && ! $config->hasBpNode($parent)) { $this->error('Parent process "%s" missing', $parent); } diff --git a/library/Businessprocess/Modification/NodeRemoveAction.php b/library/Businessprocess/Modification/NodeRemoveAction.php index 6100146..db8fff0 100644 --- a/library/Businessprocess/Modification/NodeRemoveAction.php +++ b/library/Businessprocess/Modification/NodeRemoveAction.php @@ -45,7 +45,7 @@ class NodeRemoveAction extends NodeAction $name = $this->getNodeName(); $parent = $this->getParentName(); if ($parent === null) { - if (!$config->hasNode($name)) { + if (! $config->hasNode($name)) { $this->error('Toplevel process "%s" not found', $name); } } else { diff --git a/library/Businessprocess/Monitoring/Backend/Ido/Query/CustomVarJoinTemplateOverride.php b/library/Businessprocess/Monitoring/Backend/Ido/Query/CustomVarJoinTemplateOverride.php index 385ca59..7a40bf8 100644 --- a/library/Businessprocess/Monitoring/Backend/Ido/Query/CustomVarJoinTemplateOverride.php +++ b/library/Businessprocess/Monitoring/Backend/Ido/Query/CustomVarJoinTemplateOverride.php @@ -35,7 +35,8 @@ trait CustomVarJoinTemplateOverride $this->customVars[strtolower($customvar)] = $alias; if ($type === 'host') { - if ($this instanceof ServicecommentQuery + if ( + $this instanceof ServicecommentQuery || $this instanceof ServicedowntimeQuery || $this instanceof ServicecommenthistoryQuery || $this instanceof ServicedowntimestarthistoryQuery diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index 2f95ceb..1b899a7 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -8,21 +8,21 @@ use ipl\Web\Widget\Icon; abstract class Node { - const FLAG_DOWNTIME = 1; - const FLAG_ACK = 2; - const FLAG_MISSING = 4; - const FLAG_NONE = 8; - const SHIFT_FLAGS = 4; + public const FLAG_DOWNTIME = 1; + public const FLAG_ACK = 2; + public const FLAG_MISSING = 4; + public const FLAG_NONE = 8; + public const SHIFT_FLAGS = 4; - const ICINGA_OK = 0; - const ICINGA_WARNING = 1; - const ICINGA_CRITICAL = 2; - const ICINGA_UNKNOWN = 3; - const ICINGA_UP = 0; - const ICINGA_DOWN = 1; - const ICINGA_UNREACHABLE = 2; - const ICINGA_PENDING = 99; - const NODE_EMPTY = 128; + public const ICINGA_OK = 0; + public const ICINGA_WARNING = 1; + public const ICINGA_CRITICAL = 2; + public const ICINGA_UNKNOWN = 3; + public const ICINGA_UP = 0; + public const ICINGA_DOWN = 1; + public const ICINGA_UNREACHABLE = 2; + public const ICINGA_PENDING = 99; + public const NODE_EMPTY = 128; /** @var bool Whether to treat acknowledged hosts/services always as UP/OK */ protected static $ackIsOk = false; diff --git a/library/Businessprocess/ProvidedHook/Icingadb/IcingadbSupport.php b/library/Businessprocess/ProvidedHook/Icingadb/IcingadbSupport.php index 1ff37d3..22b6572 100644 --- a/library/Businessprocess/ProvidedHook/Icingadb/IcingadbSupport.php +++ b/library/Businessprocess/ProvidedHook/Icingadb/IcingadbSupport.php @@ -6,5 +6,4 @@ use Icinga\Module\Icingadb\Hook\IcingadbSupportHook; class IcingadbSupport extends IcingadbSupportHook { - } diff --git a/library/Businessprocess/ProvidedHook/Icingadb/ServiceDetailExtension.php b/library/Businessprocess/ProvidedHook/Icingadb/ServiceDetailExtension.php index 746b2bf..1c15941 100644 --- a/library/Businessprocess/ProvidedHook/Icingadb/ServiceDetailExtension.php +++ b/library/Businessprocess/ProvidedHook/Icingadb/ServiceDetailExtension.php @@ -64,7 +64,8 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook public function getHtmlForObject(Service $service): ValidHtml { - if (! isset($this->storage) + if ( + ! isset($this->storage) || $service->checkcommand_name !== $this->commandName ) { return HtmlString::create(''); diff --git a/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php b/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php index f4871ea..fb5e7ba 100644 --- a/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php +++ b/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php @@ -69,7 +69,8 @@ class DetailviewExtension extends DetailviewExtensionHook */ public function getHtmlForObject(MonitoredObject $object) { - if (! isset($this->storage) + if ( + ! isset($this->storage) || ! $object instanceof Service || $object->check_command !== $this->commandName ) { diff --git a/library/Businessprocess/Renderer/Breadcrumb.php b/library/Businessprocess/Renderer/Breadcrumb.php index 4272b76..d89b77a 100644 --- a/library/Businessprocess/Renderer/Breadcrumb.php +++ b/library/Businessprocess/Renderer/Breadcrumb.php @@ -25,7 +25,7 @@ class Breadcrumb extends BaseHtmlElement public static function create(Renderer $renderer) { $bp = $renderer->getBusinessProcess(); - $breadcrumb = new static; + $breadcrumb = new static(); $bpUrl = $renderer->getBaseUrl(); if ($bpUrl->getParam('action') === 'delete') { $bpUrl->remove('action'); diff --git a/library/Businessprocess/Renderer/Renderer.php b/library/Businessprocess/Renderer/Renderer.php index 6a5d624..d7551ab 100644 --- a/library/Businessprocess/Renderer/Renderer.php +++ b/library/Businessprocess/Renderer/Renderer.php @@ -191,7 +191,7 @@ abstract class Renderer extends HtmlDocument $this->createBadge($summary, 'PENDING') ]); - if (!empty($elements)) { + if (! empty($elements)) { $container = Html::tag('ul', ['class' => 'state-badges']); $container->add($itemCount); foreach ($elements as $element) { diff --git a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php index b58a69d..8373c39 100644 --- a/library/Businessprocess/Renderer/TileRenderer/NodeTile.php +++ b/library/Businessprocess/Renderer/TileRenderer/NodeTile.php @@ -107,7 +107,8 @@ class NodeTile extends BaseHtmlElement $this->add(new Link($node->getAlias(), $this->getMainNodeUrl($node)->getAbsoluteUrl())); } - if ($this->renderer->rendersSubNode() + if ( + $this->renderer->rendersSubNode() && $this->renderer->getParentNode()->getChildState($node) !== $node->getState() ) { $this->add( @@ -122,7 +123,7 @@ class NodeTile extends BaseHtmlElement ); } - if ($node instanceof BpNode && !$renderer->isBreadcrumb()) { + if ($node instanceof BpNode && ! $renderer->isBreadcrumb()) { $this->add($renderer->renderStateBadges($node->getStateSummary(), $node->countChildren())); } @@ -144,7 +145,8 @@ class NodeTile extends BaseHtmlElement $url = $this->renderer->getBaseUrl(); $p = $url->getParams(); - if ($node instanceof ImportedNode + if ( + $node instanceof ImportedNode && $this->renderer->getBusinessProcess()->getName() === $node->getBpConfig()->getName() ) { $p->set('node', $node->getNodeName()); @@ -304,7 +306,8 @@ class NodeTile extends BaseHtmlElement )); } - if ($this->renderer->getBusinessProcess()->getMetadata()->canModify() + if ( + $this->renderer->getBusinessProcess()->getMetadata()->canModify() && $this->node->getBpConfig()->getName() === $this->renderer->getBusinessProcess()->getName() && $this->node->getName() !== '__unbound__' ) { diff --git a/library/Businessprocess/Renderer/TreeRenderer.php b/library/Businessprocess/Renderer/TreeRenderer.php index 6fa4c5c..ed25e00 100644 --- a/library/Businessprocess/Renderer/TreeRenderer.php +++ b/library/Businessprocess/Renderer/TreeRenderer.php @@ -18,7 +18,7 @@ use ipl\Web\Widget\StateBall; class TreeRenderer extends Renderer { - const NEW_COLLAPSIBLE_IMPLEMENTATION_SINCE = '2.11.2'; + public const NEW_COLLAPSIBLE_IMPLEMENTATION_SINCE = '2.11.2'; public function assemble() { @@ -229,7 +229,7 @@ class TreeRenderer extends Renderer } $differentConfig = $node->getBpConfig()->getName() !== $this->getBusinessProcess()->getName(); - if (! $this->isLocked() && !$differentConfig) { + if (! $this->isLocked() && ! $differentConfig) { $summary->add($this->getActionIcons($bp, $node)); } elseif ($differentConfig) { $summary->add($this->actionIcon( diff --git a/library/Businessprocess/Simulation.php b/library/Businessprocess/Simulation.php index 1bc9d1d..90559a5 100644 --- a/library/Businessprocess/Simulation.php +++ b/library/Businessprocess/Simulation.php @@ -7,7 +7,7 @@ use Icinga\Web\Session\SessionNamespace; class Simulation { - const DEFAULT_SESSION_KEY = 'bp-simulations'; + public const DEFAULT_SESSION_KEY = 'bp-simulations'; /** * @var SessionNamespace diff --git a/library/Businessprocess/Web/Component/Dashboard.php b/library/Businessprocess/Web/Component/Dashboard.php index d211772..0c6d6fa 100644 --- a/library/Businessprocess/Web/Component/Dashboard.php +++ b/library/Businessprocess/Web/Component/Dashboard.php @@ -109,7 +109,8 @@ class Dashboard extends BaseHtmlElement continue; } - if (Module::exists('icingadb') && + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); diff --git a/library/Businessprocess/Web/Component/DashboardFullscreen.php b/library/Businessprocess/Web/Component/DashboardFullscreen.php index 95e6ec7..2288dc0 100644 --- a/library/Businessprocess/Web/Component/DashboardFullscreen.php +++ b/library/Businessprocess/Web/Component/DashboardFullscreen.php @@ -66,7 +66,8 @@ class DashboardFullscreen extends BaseHtmlElement continue; } - if (Module::exists('icingadb') && + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); diff --git a/library/Businessprocess/Web/Form/CsrfToken.php b/library/Businessprocess/Web/Form/CsrfToken.php index 9eb24ef..2cf9879 100644 --- a/library/Businessprocess/Web/Form/CsrfToken.php +++ b/library/Businessprocess/Web/Form/CsrfToken.php @@ -19,7 +19,7 @@ class CsrfToken list($seed, $token) = explode('|', $token); - if (!is_numeric($seed)) { + if (! is_numeric($seed)) { return false; } diff --git a/library/Businessprocess/Web/Form/Element/Checkbox.php b/library/Businessprocess/Web/Form/Element/Checkbox.php index 7975b82..c4cafee 100644 --- a/library/Businessprocess/Web/Form/Element/Checkbox.php +++ b/library/Businessprocess/Web/Form/Element/Checkbox.php @@ -4,5 +4,4 @@ namespace Icinga\Module\Businessprocess\Web\Form\Element; class Checkbox extends \Icinga\Web\Form\Element\Checkbox { - } diff --git a/library/Businessprocess/Web/Form/QuickBaseForm.php b/library/Businessprocess/Web/Form/QuickBaseForm.php index 2eb0db8..6a60d69 100644 --- a/library/Businessprocess/Web/Form/QuickBaseForm.php +++ b/library/Businessprocess/Web/Form/QuickBaseForm.php @@ -82,7 +82,7 @@ abstract class QuickBaseForm extends Zend_Form implements ValidHtml $this->setDefault($name, $value); $el->setValue($value); } - + return $this; } diff --git a/library/Businessprocess/Web/Form/QuickForm.php b/library/Businessprocess/Web/Form/QuickForm.php index cb4d287..5326da3 100644 --- a/library/Businessprocess/Web/Form/QuickForm.php +++ b/library/Businessprocess/Web/Form/QuickForm.php @@ -16,9 +16,9 @@ use Exception; */ abstract class QuickForm extends QuickBaseForm { - const ID = '__FORM_NAME'; + public const ID = '__FORM_NAME'; - const CSRF = '__FORM_CSRF'; + public const CSRF = '__FORM_CSRF'; /** * The name of this form diff --git a/library/Businessprocess/Web/Navigation/Renderer/ProcessProblemsBadge.php b/library/Businessprocess/Web/Navigation/Renderer/ProcessProblemsBadge.php index c3e8e77..524aa10 100644 --- a/library/Businessprocess/Web/Navigation/Renderer/ProcessProblemsBadge.php +++ b/library/Businessprocess/Web/Navigation/Renderer/ProcessProblemsBadge.php @@ -48,7 +48,8 @@ class ProcessProblemsBadge extends BadgeNavigationItemRenderer $bp = $storage->loadProcess($this->getBpConfigName()); foreach ($bp->getRootNodes() as $rootNode) { $nodeState = $rootNode->getState(); - if (! $rootNode->isEmpty() && + if ( + ! $rootNode->isEmpty() && ! in_array($nodeState, [Node::ICINGA_OK, Node::ICINGA_PENDING], true) ) { if ($nodeState === $state) { diff --git a/library/Businessprocess/Web/Navigation/Renderer/ProcessesProblemsBadge.php b/library/Businessprocess/Web/Navigation/Renderer/ProcessesProblemsBadge.php index af2c63b..da3441c 100644 --- a/library/Businessprocess/Web/Navigation/Renderer/ProcessesProblemsBadge.php +++ b/library/Businessprocess/Web/Navigation/Renderer/ProcessesProblemsBadge.php @@ -32,7 +32,8 @@ class ProcessesProblemsBadge extends BadgeNavigationItemRenderer foreach ($storage->listProcessNames() as $processName) { $bp = $storage->loadProcess($processName); - if (Module::exists('icingadb') && + if ( + Module::exists('icingadb') && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); @@ -42,7 +43,8 @@ class ProcessesProblemsBadge extends BadgeNavigationItemRenderer foreach ($bp->getRootNodes() as $rootNode) { $nodeState = $rootNode->getState(); - if (! $rootNode->isEmpty() && + if ( + ! $rootNode->isEmpty() && ! in_array($nodeState, [Node::ICINGA_OK, Node::ICINGA_PENDING], true) ) { if ($nodeState === $state) {