Skip to content

Commit 8b6197b

Browse files
committed
qa: Improve code style with phpcs
1 parent 8a9f955 commit 8b6197b

File tree

13 files changed

+114
-50
lines changed

13 files changed

+114
-50
lines changed

application/controllers/EditController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,23 @@ public function indexAction()
4949
{
5050
$action = $this->getRequest()->getActionName();
5151
if ($action === 'add') {
52-
$this->view->title = sprintf('%s Top Level View',
52+
$this->view->title = sprintf(
53+
'%s Top Level View',
5354
$this->translate('Add')
5455
);
5556
$view = new ViewConfig();
5657
$view->setConfigDir();
57-
} else if ($action === 'clone') {
58+
} elseif ($action === 'clone') {
5859
$name = $this->params->getRequired('name');
59-
$this->view->title = sprintf('%s Top Level View',
60+
$this->view->title = sprintf(
61+
'%s Top Level View',
6062
$this->translate('Clone')
6163
);
6264
$view = clone ViewConfig::loadByName($name);
6365
} else {
6466
$this->view->name = $name = $this->params->getRequired('name');
65-
$this->view->title = sprintf('%s Top Level View: %s',
67+
$this->view->title = sprintf(
68+
'%s Top Level View: %s',
6669
$this->translate('Edit'),
6770
$this->params->getRequired('name')
6871
);

application/forms/EditForm.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function onSuccess()
5151
if ($this->getElement('btn_submit_save_file')->getValue() !== null) {
5252
$this->viewConfig->store();
5353
Notification::success($this->translate('Top Level View successfully saved'));
54-
} else if ($cancel !== null && $cancel->getValue() !== null) {
54+
} elseif ($cancel !== null && $cancel->getValue() !== null) {
5555
$this->viewConfig->clearSession();
5656
Notification::success($this->translate('Top Level View restored from disk'));
57-
} else if ($delete != null && $delete->getValue() !== null) {
57+
} elseif ($delete != null && $delete->getValue() !== null) {
5858
$this->viewConfig->delete();
5959
$this->setRedirectUrl('toplevelview');
6060
Notification::success($this->translate('Top Level View successfully deleted'));
@@ -100,7 +100,8 @@ public function createElements(array $formData)
100100
$this->translate(
101101
'This config is only stored in your session!'
102102
. ' Make sure to save it to disk once your work is complete!'
103-
), false
103+
),
104+
false
104105
);
105106
}
106107

application/views/helpers/Badges.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public function badges(TLVStatus $status, $problemsOnly = true, $showTotal = fal
2525
$values = false;
2626
$htm .= '<div class="badges">';
2727
foreach ($status->getProperties() as $key => $value) {
28-
if (
29-
$problemsOnly === true && ($key === 'ok' || $key === 'downtime_active')
28+
if ($problemsOnly === true && ($key === 'ok' || $key === 'downtime_active')
3029
|| ($key === 'total' && $showTotal !== true)
3130
) {
3231
continue;

application/views/helpers/Breadcrumb.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public function breadcrumb($breadcrumb, $config_name)
1818
$htm = '<ul class="breadcrumb">';
1919
foreach ($breadcrumb as $crumb) {
2020
$htm .= '<li>' . $this->view->qlink(
21-
$crumb->getTitle(),
22-
'toplevelview/show/tree',
23-
array(
21+
$crumb->getTitle(),
22+
'toplevelview/show/tree',
23+
array(
2424
'name' => $config_name,
2525
'id' => $crumb->getFullId()
2626
)
27-
) . '</li>';
27+
) . '</li>';
2828
}
2929
$htm .= '</ul>';
3030
return $htm;

application/views/helpers/Tree.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public function tree(TLVTreeNode $node, $classes = array(), $level = 0)
8989
$htm .= ' ' . $this->view->badges($status, false);
9090
$htm .= '</div>';
9191
} else {
92-
$htm .= "<div class=\"tlv-tree-node tlv-status-section collapsible $statusClass $cssClasses\" title=\"$title\">";
92+
$htm .= "<div class=\"tlv-tree-node tlv-status-section collapsible $statusClass $cssClasses\"";
93+
$htm .= " title=\"$title\">";
9394
$htm .= '<div class="tlv-tree-title">';
9495
$htm .= $this->view->badges($status, false, $level === 0 ? true : false);
9596
$htm .= '<i class="icon icon-bycss collapse-handle"></i> ';

configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
'label' => $viewConfig->getMeta('name'),
2727
'url' => Url::fromPath('toplevelview/show', array('name' => $name)),
2828
));
29-
3029
}
3130
}
3231
} catch (Exception $e) {

library/Toplevelview/Legacy/LegacyDbHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ protected function fetchDatabaseHierarchy($root_id)
6565
'hg.view_id = v.id',
6666
array('hg.hostgroup_object_id')
6767
)->where(
68-
'p.id = ?', $root_id
68+
'p.id = ?',
69+
$root_id
6970
)->group(array(
7071
'n.root_id',
7172
'n.lft',
@@ -160,8 +161,7 @@ protected function buildTree($root_id, $nodes, &$hosts, &$services, &$hostgroups
160161
unset($node->level);
161162
}
162163

163-
if (
164-
property_exists($node, 'host_object_id')
164+
if (property_exists($node, 'host_object_id')
165165
&& $node->host_object_id !== null
166166
&& $currentHostId !== $node->host_object_id
167167
) {

library/Toplevelview/Monitoring/HostgroupQuery.php

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,62 @@ public function init()
2929
'servicestatus' => array(
3030
'service_notifications_enabled' => 'ss.notifications_enabled',
3131
'service_is_flapping' => 'ss.is_flapping',
32-
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END',
33-
'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END',
34-
'service_handled_wo_host' => 'CASE WHEN ss.problem_has_been_acknowledged > 0 THEN 1 ELSE 0 END',
35-
'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
32+
'service_state' => '
33+
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL
34+
THEN 99
35+
ELSE CASE WHEN ss.state_type = 1
36+
THEN ss.current_state
37+
ELSE ss.last_hard_state
38+
END
39+
END',
40+
'service_handled' => '
41+
CASE WHEN (ss.problem_has_been_acknowledged + COALESCE(hs.current_state, 0)) > 0
42+
THEN 1
43+
ELSE 0
44+
END',
45+
'service_handled_wo_host' => '
46+
CASE WHEN ss.problem_has_been_acknowledged > 0
47+
THEN 1
48+
ELSE 0
49+
END',
50+
'service_in_downtime' => '
51+
CASE WHEN (ss.scheduled_downtime_depth = 0)
52+
THEN 0
53+
ELSE 1
54+
END',
3655
),
3756
'hoststatus' => array(
3857
'host_notifications_enabled' => 'hs.notifications_enabled',
3958
'host_is_flapping' => 'hs.is_flapping',
40-
'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE CASE WHEN hs.state_type = 1 THEN hs.current_state ELSE hs.last_hard_state END END',
41-
'host_handled' => 'CASE WHEN hs.problem_has_been_acknowledged > 0 THEN 1 ELSE 0 END',
42-
'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
59+
'host_state' => '
60+
CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL
61+
THEN 99
62+
ELSE CASE WHEN hs.state_type = 1
63+
THEN hs.current_state
64+
ELSE hs.last_hard_state
65+
END
66+
END',
67+
'host_handled' => '
68+
CASE WHEN hs.problem_has_been_acknowledged > 0
69+
THEN 1
70+
ELSE 0
71+
END',
72+
'host_in_downtime' => '
73+
CASE WHEN (hs.scheduled_downtime_depth = 0)
74+
THEN 0
75+
ELSE 1
76+
END',
4377
),
4478
'servicenotificationperiod' => array(
4579
'service_notification_period' => 'ntpo.name1',
46-
'service_in_notification_period' => 'CASE WHEN ntpo.object_id IS NULL THEN 1 ELSE CASE WHEN ntpr.timeperiod_id IS NOT NULL THEN 1 ELSE 0 END END',
80+
'service_in_notification_period' => '
81+
CASE WHEN ntpo.object_id IS NULL
82+
THEN 1
83+
ELSE CASE WHEN ntpr.timeperiod_id IS NOT NULL
84+
THEN 1
85+
ELSE 0
86+
END
87+
END',
4788
),
4889
);
4990

library/Toplevelview/Monitoring/HostgroupsummaryQuery.php

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public function __construct($ds, $columns = null, $options = null)
2323
public function init()
2424
{
2525
if ($this->getOption('notification_periods') === true) {
26-
$serviceOutDowntime = 'service_notifications_enabled = 1 AND service_in_downtime = 0 AND service_in_notification_period = 1';
27-
$serviceInDowntime = '(service_notifications_enabled = 0 OR service_in_downtime = 1 OR service_in_notification_period = 0)';
26+
$serviceOutDowntime =#
27+
'service_notifications_enabled = 1 AND service_in_downtime = 0 AND service_in_notification_period = 1';
28+
$serviceInDowntime =
29+
'(service_notifications_enabled = 0 OR service_in_downtime = 1 OR service_in_notification_period = 0)';
2830
} else {
2931
$serviceOutDowntime = 'service_notifications_enabled = 1 AND service_in_downtime = 0';
3032
$serviceInDowntime = '(service_notifications_enabled = 0 OR service_in_downtime = 1)';
@@ -46,20 +48,34 @@ public function init()
4648

4749
$patchedColumnMap = array(
4850
'hostgroupsummary' => array(
49-
'hosts_down_handled' => "SUM(CASE WHEN host_state = 1 AND $patchHostsHandled THEN 1 ELSE 0 END)",
50-
'hosts_down_unhandled' => "SUM(CASE WHEN host_state = 1 AND $patchHostsUnhandled THEN 1 ELSE 0 END)",
51-
'hosts_unreachable_handled' => "SUM(CASE WHEN host_state = 2 AND $patchHostsHandled THEN 1 ELSE 0 END)",
52-
'hosts_unreachable_unhandled' => "SUM(CASE WHEN host_state = 2 AND $patchHostsUnhandled THEN 1 ELSE 0 END)",
53-
'hosts_downtime_handled' => "SUM(CASE WHEN host_state != 0 AND $hostInDowntime THEN 1 ELSE 0 END)",
54-
'hosts_downtime_active' => "SUM(CASE WHEN $hostInDowntime THEN 1 ELSE 0 END)",
55-
'services_critical_handled' => "SUM(CASE WHEN service_state = 2 AND $patchServicesHandled THEN 1 ELSE 0 END)",
56-
'services_critical_unhandled' => "SUM(CASE WHEN service_state = 2 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
57-
'services_unknown_handled' => "SUM(CASE WHEN service_state = 3 AND $patchServicesHandled THEN 1 ELSE 0 END)",
58-
'services_unknown_unhandled' => "SUM(CASE WHEN service_state = 3 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
59-
'services_warning_handled' => "SUM(CASE WHEN service_state = 1 AND $patchServicesHandled THEN 1 ELSE 0 END)",
60-
'services_warning_unhandled' => "SUM(CASE WHEN service_state = 1 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
61-
'services_downtime_handled' => "SUM(CASE WHEN service_state != 0 AND $serviceInDowntime THEN 1 ELSE 0 END)",
62-
'services_downtime_active' => "SUM(CASE WHEN $serviceInDowntime THEN 1 ELSE 0 END)",
51+
'hosts_down_handled' =>
52+
"SUM(CASE WHEN host_state = 1 AND $patchHostsHandled THEN 1 ELSE 0 END)",
53+
'hosts_down_unhandled' =>
54+
"SUM(CASE WHEN host_state = 1 AND $patchHostsUnhandled THEN 1 ELSE 0 END)",
55+
'hosts_unreachable_handled' =>
56+
"SUM(CASE WHEN host_state = 2 AND $patchHostsHandled THEN 1 ELSE 0 END)",
57+
'hosts_unreachable_unhandled' =>
58+
"SUM(CASE WHEN host_state = 2 AND $patchHostsUnhandled THEN 1 ELSE 0 END)",
59+
'hosts_downtime_handled' =>
60+
"SUM(CASE WHEN host_state != 0 AND $hostInDowntime THEN 1 ELSE 0 END)",
61+
'hosts_downtime_active' =>
62+
"SUM(CASE WHEN $hostInDowntime THEN 1 ELSE 0 END)",
63+
'services_critical_handled' =>
64+
"SUM(CASE WHEN service_state = 2 AND $patchServicesHandled THEN 1 ELSE 0 END)",
65+
'services_critical_unhandled' =>
66+
"SUM(CASE WHEN service_state = 2 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
67+
'services_unknown_handled' =>
68+
"SUM(CASE WHEN service_state = 3 AND $patchServicesHandled THEN 1 ELSE 0 END)",
69+
'services_unknown_unhandled' =>
70+
"SUM(CASE WHEN service_state = 3 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
71+
'services_warning_handled' =>
72+
"SUM(CASE WHEN service_state = 1 AND $patchServicesHandled THEN 1 ELSE 0 END)",
73+
'services_warning_unhandled' =>
74+
"SUM(CASE WHEN service_state = 1 AND $patchServicesUnhandled THEN 1 ELSE 0 END)",
75+
'services_downtime_handled' =>
76+
"SUM(CASE WHEN service_state != 0 AND $serviceInDowntime THEN 1 ELSE 0 END)",
77+
'services_downtime_active' =>
78+
"SUM(CASE WHEN $serviceInDowntime THEN 1 ELSE 0 END)",
6379
)
6480
);
6581

library/Toplevelview/Monitoring/ServicestatusQuery.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ public function init()
2828
),
2929
'servicenotificationperiod' => array(
3030
'service_notification_period' => 'ntpo.name1',
31-
'service_in_notification_period' => 'CASE WHEN ntpo.name1 IS NULL THEN 1 ELSE CASE WHEN ntpr.timeperiod_id IS NOT NULL THEN 1 ELSE 0 END END',
31+
'service_in_notification_period' => '
32+
CASE WHEN ntpo.name1 IS NULL
33+
THEN 1
34+
ELSE CASE WHEN ntpr.timeperiod_id IS NOT NULL
35+
THEN 1
36+
ELSE 0
37+
END
38+
END',
3239
),
3340
);
3441

0 commit comments

Comments
 (0)