Skip to content

Commit

Permalink
✨ feat: add insecure and unsupported options
Browse files Browse the repository at this point in the history
  • Loading branch information
Cambis committed Jul 23, 2024
1 parent ad2df4a commit bcabbc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Model/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* @property bool $NoClose
* @property bool $NoMessage
* @property bool $NoPermanentHide
* @property bool $Insecure
* @property bool $Unsupported
* @method HasManyList<BrowserVersion> BrowserVersions()
*/
class Announcement extends DataObject implements BrowserUpdateInterface, PermissionProvider
Expand Down Expand Up @@ -64,6 +66,8 @@ class Announcement extends DataObject implements BrowserUpdateInterface, Permiss
'NoClose' => 'Boolean(0)',
'NoMessage' => 'Boolean(0)',
'NoPermanentHide' => 'Boolean(0)',
'Insecure' => 'Boolean(1)',
'Unsupported' => 'Boolean(1)',
];

/**
Expand Down Expand Up @@ -152,6 +156,19 @@ public function getCMSFields(): FieldList
->setDescription('Do not show a message if the browser is out of date'),
CheckboxField::create('NoPermanentHide', 'no_permanent_hide')
->setDescription('Do not give the user the option to permanently hide the notification'),
CheckboxField::create('Insecure', 'insecure')
->setDescription(
'The option "insecure: true" means that all browser that are severely insecure get notified. ' .
'"Severely insecure" means that the browser has security issues that allow remote code execution and similar stuff, ' .
'and that they are being actively exploited on the internet.'
),
CheckboxField::create('Unsupported', 'unsupported')
->setDescription(
'The option "unsupported: true" means that additionally to the browsers you set, ' .
'also all browser versions that are not supplied with updates by the vendor any more get notified. ' .
'Usually this is all but the latest version of the browser. ' .
'Exceptions are Internet Explorer 11 and Firefox Long term support releases, which are still supported but are not the latest version.'
),
]);

$this->extend('updateCMSFields', $fields);
Expand All @@ -177,6 +194,8 @@ public function getBrowserUpdateConfig(): array
'noclose' => $this->NoClose,
'no_permanent_hide' => $this->NoPermanentHide,
'api' => self::config()->get('browser_update_api_version'),
'insecure' => $this->Insecure,
'unsupported' => $this->Unsupported,
];

$text = $this->getMessageConfigArray();
Expand Down
2 changes: 1 addition & 1 deletion tests/php/View/TemplateProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testBrowserUpdate(): void
);

$this->assertStringContainsString(
'{"reminder":24,"reminderClosed":150,"test":0,"newwindow":1,"url":null,"noclose":0,"no_permanent_hide":0,"api":"2024.07","text":{"msg":"Your web browser ({brow_name}) is out of date.","msgmore":"Update your browser for more security, speed and the best experience on this site.","bupdate":"Update browser","bignore":"Ignore","remind":"You will be reminded in {days} days.","bnever":"Never show again"}}',
'{"reminder":24,"reminderClosed":150,"test":0,"newwindow":1,"url":null,"noclose":0,"no_permanent_hide":0,"api":"2024.07","insecure":1,"unsupported":1,"text":{"msg":"Your web browser ({brow_name}) is out of date.","msgmore":"Update your browser for more security, speed and the best experience on this site.","bupdate":"Update browser","bignore":"Ignore","remind":"You will be reminded in {days} days.","bnever":"Never show again"}}',
$template,
);
}
Expand Down

0 comments on commit bcabbc7

Please sign in to comment.