Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental config updates #187

Merged
merged 34 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ee882e9
Models: Add `changed_at` and `deleted` columns and their `Behaviors`
sukhwinder33445 Apr 30, 2024
7dce156
Models: Add phpDoc for properties and return type to methods
sukhwinder33445 Apr 30, 2024
1059476
Controller: Add missing handeling for undefined `id`
sukhwinder33445 May 2, 2024
807f025
Consider new `deleted` and `changed_at` column
sukhwinder33445 May 2, 2024
7340323
Controller: Add `changed_at` as sortby column
sukhwinder33445 May 2, 2024
9abeb0f
Channel: Update only if changes exist
sukhwinder33445 May 6, 2024
58849c9
Contact: Update only if changes exist
sukhwinder33445 May 6, 2024
1508723
Source: Update only if changes exist
sukhwinder33445 May 6, 2024
6081f85
Timeperiod: Fix column name
sukhwinder33445 Jun 19, 2024
9973e68
Schedule: Update only if changes exist
sukhwinder33445 Jun 19, 2024
5b60660
Channel: Don't allow to delete channel if in use
sukhwinder33445 Jun 21, 2024
6ab3f5b
ObjectSuggestions: Consider `deleted` column for value suggestions
sukhwinder33445 Jun 21, 2024
4c9d263
RotationConfigForm: Update only if changes exist
sukhwinder33445 Jun 24, 2024
d5b9ad6
EventRuleConfig: Consider `changed_at`, `deleted` column
sukhwinder33445 Jul 1, 2024
e5b62d5
Fix codeSniffer errors
sukhwinder33445 Jul 1, 2024
f305919
Models: Fix phpDoc
sukhwinder33445 Jul 3, 2024
eefb79c
Rule: Remove column `is_active` and its usage
sukhwinder33445 Jul 3, 2024
feb9dd9
ContactGroupForm: Add missing filter and simplify code
sukhwinder33445 Jul 3, 2024
0b0c26f
SourcesController: Fix typo in success message
sukhwinder33445 Jul 4, 2024
23a0e9c
RuleEscalationRecipientBadge: Return earlier if not recipient found
sukhwinder33445 Jul 5, 2024
bb994ed
Contact|Schedule|Contactgroup: Cleanup refereces on deletion
sukhwinder33445 Jul 5, 2024
7ec2718
(EventRule|Schedule)ListItem: Respect new `deleted` flag
sukhwinder33445 Jul 5, 2024
477456b
Database: Use `ON_ASSEMBLE_SELECT` event to add `deleted` flag to que…
sukhwinder33445 Jul 8, 2024
6b5e71f
Rotation: Add `delete` method to remove rotation and all its refereces
sukhwinder33445 Jul 9, 2024
b3dbaa2
Use rotation::delete() to delete rotations and its references
sukhwinder33445 Jul 9, 2024
7ebd14e
Contact|Schedule|Contactgroup: Remove `rule_escalation` if the remove…
sukhwinder33445 Jul 9, 2024
f841484
ContactGroupController: Don't fetch deleted contactgroup_member
sukhwinder33445 Jul 10, 2024
81ad3c1
Forms: Do not update changed_at column of deleted entries again
sukhwinder33445 Jul 10, 2024
266487c
Allow to delete event rule
sukhwinder33445 Jul 10, 2024
2ebe803
SaveEventRuleForm: Fix Undefined array key `rule_escalation` error
sukhwinder33445 Jul 10, 2024
2bf142a
Contact(group)Form: Delete `timeperiod_entry` when the member is deleted
sukhwinder33445 Jul 11, 2024
54c6408
ChannelForm: Disable delete button if a contact has the channel as de…
sukhwinder33445 Jul 11, 2024
ebfc217
RotationConfigForm: Mark entries as deleted instead of actually delet…
sukhwinder33445 Jul 11, 2024
013a57d
Forms: Add `changed_at` column manualy on db::insert
sukhwinder33445 Jul 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions application/controllers/ChannelController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Cannot access property \$name on ipl\\Orm\\Model\|null\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Method Icinga\\Module\\Notifications\\Controllers\\ChannelController\:\:indexAction\(\) has no return type specified\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$values of method Icinga\\Module\\Notifications\\Forms\\ChannelForm\:\:populate\(\) expects iterable\<string, mixed\>, ipl\\Orm\\Model\|null given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$channelId of class Icinga\\Module\\Notifications\\Forms\\ChannelForm constructor expects int\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \$value of static method ipl\\Stdlib\\Filter\:\:equal\(\) expects array\|bool\|float\|int\|string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php was not matched in reported errors.

/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */

Expand All @@ -6,44 +6,30 @@

use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Forms\ChannelForm;
use Icinga\Module\Notifications\Model\Channel;
use Icinga\Web\Notification;
use ipl\Sql\Connection;
use ipl\Stdlib\Filter;
use ipl\Web\Compat\CompatController;

class ChannelController extends CompatController
{
/** @var Connection */
private $db;

public function init()
public function init(): void
{
$this->assertPermission('config/modules');

$this->db = Database::get();
}

public function indexAction()
public function indexAction(): void
{
$channel = Channel::on($this->db);
$channelId = $this->params->getRequired('id');

$channel->filter(Filter::equal('id', $channelId));

$channel = $channel->first();

$this->addTitleTab(sprintf(t('Channel: %s'), $channel->name));

$form = (new ChannelForm($this->db, $channelId))
->populate($channel)
$form = (new ChannelForm(Database::get()))
->loadChannel($channelId)

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.

Check failure on line 23 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $id of method Icinga\Module\Notifications\Forms\ChannelForm::loadChannel() expects int, mixed given.
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
if ($form->getPressedSubmitElement()->getName() === 'delete') {
$form->removeChannel();
Notification::success(sprintf(
t('Deleted channel "%s" successfully'),
$form->getValue('name')

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.

Check failure on line 29 in application/controllers/ChannelController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelController.php is expected to occur 3 times, but occurred only 2 times.
));
} else {
$form->editChannel();
Notification::success(sprintf(
t('Channel "%s" has successfully been saved'),
$form->getValue('name')
Expand All @@ -53,6 +39,8 @@
$this->redirectNow('__CLOSE__');
})->handleRequest($this->getServerRequest());

$this->addTitleTab(sprintf(t('Channel: %s'), $form->getChannelName()));

$this->addContent($form);
}
}
6 changes: 4 additions & 2 deletions application/controllers/ChannelsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

Check failure on line 1 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$name of method ipl\\Web\\Widget\\Tabs\:\:add\(\) expects string, mixed given\.$# in path /home/runner/work/icinga-notifications-web/icinga-notifications-web/application/controllers/ChannelsController.php was not matched in reported errors.

/* Icinga Notifications Web | (c) 2023 Icinga GmbH | GPLv2 */

Expand Down Expand Up @@ -52,8 +52,9 @@
$sortControl = $this->createSortControl(
$channels,
[
'name' => t('Name'),
'type' => t('Type')
'name' => t('Name'),
'type' => t('Type'),
'changed_at' => t('Changed At')
]
);

Expand Down Expand Up @@ -104,6 +105,7 @@
$this->addTitleTab(t('Add Channel'));
$form = (new ChannelForm($this->db))
->on(ChannelForm::ON_SUCCESS, function (ChannelForm $form) {
$form->addChannel();
Notification::success(
sprintf(
t('New channel %s has successfully been added'),
Expand Down Expand Up @@ -180,7 +182,7 @@
{
/** @var Tab $tab */
foreach ($tabs->getTabs() as $tab) {
$this->tabs->add($tab->getName(), $tab);

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.

Check failure on line 185 in application/controllers/ChannelsController.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Parameter #1 $name of method ipl\Web\Widget\Tabs::add() expects string, string|null given.
}
}
}
32 changes: 9 additions & 23 deletions application/controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,37 @@

class ContactController extends CompatController
{
/** @var Connection */
private $db;

public function init()
public function init(): void
{
$this->assertPermission('notifications/config/contacts');

$this->db = Database::get();
}

public function indexAction()
public function indexAction(): void
{
$contact = Contact::on($this->db);
$contactId = $this->params->getRequired('id');

$contact->filter(Filter::equal('id', $contactId));

$contact = $contact->first();

$this->addTitleTab(sprintf(t('Contact: %s'), $contact->full_name));

$form = (new ContactForm($this->db, $contactId))
->populate($contact)
$form = (new ContactForm(Database::get()))
->loadContact($contactId)
->on(ContactForm::ON_SUCCESS, function (ContactForm $form) {
$form->addOrUpdateContact();
/** @var FieldsetElement $contactElement */
$contactElement = $form->getElement('contact');
$form->editContact();
Notification::success(sprintf(
t('Contact "%s" has successfully been saved'),
$contactElement->getValue('full_name')
$form->getContactName()
));

$this->redirectNow('__CLOSE__');
})->on(ContactForm::ON_REMOVE, function (ContactForm $form) {
$form->removeContact();
/** @var FieldsetElement $contactElement */
$contactElement = $form->getElement('contact');
Notification::success(sprintf(
t('Deleted contact "%s" successfully'),
$contactElement->getValue('full_name')
$form->getContactName()
));

$this->redirectNow('__CLOSE__');
})->handleRequest($this->getServerRequest());

$this->addTitleTab(sprintf(t('Contact: %s'), $form->getContactName()));

$this->addContent($form);
}
}
23 changes: 15 additions & 8 deletions application/controllers/ContactGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Common\Links;
use Icinga\Module\Notifications\Forms\ContactGroupForm;
use Icinga\Module\Notifications\Model\Contact;
use Icinga\Module\Notifications\Model\Contactgroup;
use Icinga\Module\Notifications\Model\ContactgroupMember;
use Icinga\Module\Notifications\Widget\ItemList\ContactList;
use Icinga\Web\Notification;
use ipl\Html\Attributes;
Expand Down Expand Up @@ -44,7 +46,13 @@ public function indexAction(): void

$this->addControl(new HtmlElement('div', new Attributes(['class' => 'header']), Text::create($group->name)));

$this->addControl($this->createPaginationControl($group->contact));
$contacts = Contact::on(Database::get())
->filter(Filter::all(
Filter::equal('contactgroup_member.contactgroup_id', $groupId),
nilmerg marked this conversation as resolved.
Show resolved Hide resolved
Filter::equal('contactgroup_member.deleted', 'n')
));

$this->addControl($this->createPaginationControl($contacts));
$this->addControl($this->createLimitControl());

$this->addContent(
Expand All @@ -56,7 +64,7 @@ public function indexAction(): void
))->openInModal()
);

$this->addContent(new ContactList($group->contact));
$this->addContent(new ContactList($contacts));

$this->addTitleTab(t('Contact Group'));
$this->setTitle(sprintf(t('Contact Group: %s'), $group->name));
Expand Down Expand Up @@ -90,12 +98,11 @@ public function editAction(): void
}
})
->on(Form::ON_SUCCESS, function (ContactGroupForm $form) use ($groupId) {
if ($form->editGroup()) {
Notification::success(sprintf(
t('Successfully updated contact group %s'),
$form->getValue('group_name')
));
}
$form->editGroup();
Notification::success(sprintf(
t('Successfully updated contact group %s'),
$form->getValue('group_name')
));

$this->closeModalAndRefreshRemainingViews(Links::contactGroup($groupId));
})
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/ContactGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function indexAction(): void
$sortControl = $this->createSortControl(
$groups,
[
'name' => t('Group Name'),
'name' => t('Group Name'),
'changed_at' => t('Changed At')
]
);

Expand Down
9 changes: 5 additions & 4 deletions application/controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function indexAction()
$sortControl = $this->createSortControl(
$contacts,
[
'full_name' => t('Full Name'),
'full_name' => t('Full Name'),
'changed_at' => t('Changed At')
]
);

Expand Down Expand Up @@ -101,15 +102,15 @@ public function indexAction()
$this->getTabs()->activate('contacts');
}

public function addAction()
public function addAction(): void
{
$this->addTitleTab(t('Add Contact'));

$form = (new ContactForm($this->db))
->on(ContactForm::ON_SUCCESS, function (ContactForm $form) {
$form->addOrUpdateContact();
$form->addContact();
Notification::success(t('New contact has successfully been added'));
$this->redirectNow(Url::fromPath('notifications/contacts'));
$this->redirectNow(Links::contacts());
})->handleRequest($this->getServerRequest());

$this->addContent($form);
Expand Down
28 changes: 11 additions & 17 deletions application/controllers/EventRuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Icinga\Module\Notifications\Forms\EventRuleForm;
use Icinga\Module\Notifications\Forms\SaveEventRuleForm;
use Icinga\Module\Notifications\Model\Incident;
use Icinga\Module\Notifications\Model\ObjectExtraTag;
use Icinga\Module\Notifications\Model\Rule;
use Icinga\Module\Notifications\Web\Control\SearchBar\ExtraTagSuggestions;
use Icinga\Module\Notifications\Widget\EventRuleConfig;
Expand Down Expand Up @@ -62,21 +61,9 @@ public function indexAction(): void
);
}

$disableRemoveButton = false;
if (ctype_digit($ruleId)) {
$incidents = Incident::on(Database::get())
->with('rule')
->filter(Filter::equal('rule.id', $ruleId));

if ($incidents->count() > 0) {
$disableRemoveButton = true;
}
}

$saveForm = (new SaveEventRuleForm())
->setShowRemoveButton()
->setShowDismissChangesButton($cache !== null)
->setRemoveButtonDisabled($disableRemoveButton)
->setSubmitButtonDisabled($cache === null)
->setSubmitLabel($this->translate('Save Changes'))
->on(SaveEventRuleForm::ON_SUCCESS, function ($form) use ($ruleId, $eventRuleConfig) {
Expand Down Expand Up @@ -151,7 +138,7 @@ public function indexAction(): void
public function fromDb(int $ruleId): array
{
$query = Rule::on(Database::get())
->withoutColumns('timeperiod_id')
->columns(['id', 'name', 'object_filter'])
->filter(Filter::equal('id', $ruleId));

$rule = $query->first();
Expand All @@ -161,12 +148,20 @@ public function fromDb(int $ruleId): array

$config = iterator_to_array($rule);

foreach ($rule->rule_escalation as $re) {
$ruleEscalations = $rule
->rule_escalation
->withoutColumns(['changed_at', 'deleted']);

foreach ($ruleEscalations as $re) {
foreach ($re as $k => $v) {
$config[$re->getTableName()][$re->position][$k] = $v;
}

foreach ($re->rule_escalation_recipient as $recipient) {
$escalationRecipients = $re
->rule_escalation_recipient
->withoutColumns(['changed_at', 'deleted']);

foreach ($escalationRecipients as $recipient) {
$config[$re->getTableName()][$re->position]['recipient'][] = iterator_to_array($recipient);
}
}
Expand Down Expand Up @@ -248,7 +243,6 @@ public function editAction(): void
->setAction(Url::fromRequest()->getAbsoluteUrl())
->on(Form::ON_SUCCESS, function ($form) use ($ruleId, $cache, $config) {
$config['name'] = $form->getValue('name');
$config['is_active'] = $form->getValue('is_active');

if ($cache || $ruleId === '-1') {
$this->sessionNamespace->set($ruleId, $config);
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/EventRulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function indexAction(): void
$sortControl = $this->createSortControl(
$eventRules,
[
'name' => t('Name'),
'name' => t('Name'),
'changed_at' => t('Changed At')
]
);

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function settingsAction(): void
$this->setTitle($this->translate('Edit Schedule'));
$scheduleId = (int) $this->params->getRequired('id');

$form = new ScheduleForm();
$form = new ScheduleForm(Database::get());
$form->setShowRemoveButton();
$form->loadSchedule($scheduleId);
$form->setSubmitLabel($this->translate('Save Changes'));
Expand All @@ -95,7 +95,7 @@ public function settingsAction(): void
public function addAction(): void
{
$this->setTitle($this->translate('New Schedule'));
$form = (new ScheduleForm())
$form = (new ScheduleForm(Database::get()))
->setAction($this->getRequest()->getUrl()->getAbsoluteUrl())
->on(Form::ON_SUCCESS, function (ScheduleForm $form) {
$scheduleId = $form->addSchedule();
Expand Down
5 changes: 4 additions & 1 deletion application/controllers/SchedulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public function indexAction(): void
$limitControl = $this->createLimitControl();
$sortControl = $this->createSortControl(
$schedules,
['schedule.name' => t('Name')]
[
'schedule.name' => t('Name'),
'changed_at' => t('Changed At')
]
);

$paginationControl = $this->createPaginationControl($schedules);
Expand Down
25 changes: 8 additions & 17 deletions application/controllers/SourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class SourceController extends CompatController
{
public function init()
public function init(): void
{
$this->assertPermission('config/modules');
}
Expand All @@ -23,38 +23,29 @@ public function indexAction(): void
{
$sourceId = (int) $this->params->getRequired('id');

/** @var ?Source $source */
$source = Source::on(Database::get())
->filter(Filter::equal('id', $sourceId))
->first();
if ($source === null) {
$this->httpNotFound($this->translate('Source not found'));
}

$form = (new SourceForm(Database::get(), $sourceId))
->populate($source)
$form = (new SourceForm(Database::get()))
->loadSource($sourceId)
->on(SourceForm::ON_SUCCESS, function (SourceForm $form) {
/** @var string $sourceName */
$sourceName = $form->getValue('name');

/** @var FormSubmitElement $pressedButton */
$pressedButton = $form->getPressedSubmitElement();
if ($pressedButton->getName() === 'delete') {
$form->removeSource();
Notification::success(sprintf(
$this->translate('Deleted source "%s" successfully'),
$sourceName
$form->getSourceName()
));
} else {
$form->editSource();
Notification::success(sprintf(
$this->translate('Updated source "%s" successfully'),
$sourceName
$form->getSourceName()
));
}

$this->switchToSingleColumnLayout();
})->handleRequest($this->getServerRequest());

$this->addTitleTab(sprintf($this->translate('Source: %s'), $source->name));
$this->addTitleTab(sprintf($this->translate('Source: %s'), $form->getSourceName()));
$this->addContent($form);
}
}
Loading
Loading