Compare commits

...

26 Commits

Author SHA1 Message Date
github-actions 9b79699dcc Merge branch '4.7' into 4 2024-02-11 11:32:58 +00:00
Guy Sartorelli bb3eec1160
TLN Update translations (#223) 2024-02-07 16:03:34 +13:00
github-actions 5f04e466d2 Merge branch '4.7' into 4 2023-08-27 11:32:16 +00:00
Guy Sartorelli 20d61d7d87
ENH Update translations (#208) 2023-08-21 12:13:52 +12:00
Michal Kleiner b6ce505e12 Merge branch '4.7' into 4 2023-06-16 12:09:26 +12:00
Michal Kleiner 9fe83e948d
Merge pull request #201 from silverstripe/pulls/200-use-injector-for-task
MNT Use ::create to allow Injector to replace content review emails sending task
2023-06-16 12:02:44 +12:00
Michal Kleiner 2e22bd4900 MNT Use ::create to allow Injector to replace content review emails sending task 2023-06-16 11:46:30 +12:00
Michal Kleiner 32e7929f01 Merge branch '4.7' into 4 2023-06-16 11:10:50 +12:00
Michal Kleiner 27e0f8f517
Merge pull request #183 from sunnysideup/patch-1
MNT Add additional keywords to composer.json
2023-06-16 10:48:01 +12:00
Guy Sartorelli 72e4321696
Merge pull request #199 from creative-commoners/pulls/4.7/tx-1686724607
ENH Update translations
2023-06-15 10:06:32 +12:00
Steve Boyd b6e00e9528 ENH Update translations 2023-06-14 18:36:47 +12:00
Guy Sartorelli d13bebf999
Merge branch '4.7' into 4 2023-04-26 12:46:27 +12:00
Guy Sartorelli ad33d32066
Merge pull request #195 from creative-commoners/pulls/4.7/fix-broken-job-on-wrong-email
FIX Notification job marked as broken
2023-04-14 12:30:53 +12:00
Sabina Talipova c39e588306 FIX Notification job marked as broken 2023-04-14 12:22:23 +12:00
Guy Sartorelli f9dc2e537d
Merge pull request #192 from creative-commoners/pulls/4/fix-broken-job-on-wrong-email
FIX Notification job marked as broken
2023-04-14 09:40:47 +12:00
Sabina Talipova 36d3718581 ENH Add Exception with list of invilid emails 2023-04-13 10:13:08 +12:00
Sabina Talipova 24766e4e5a FIX Notification job marked as broken 2023-04-12 08:56:49 +12:00
Guy Sartorelli 77bb69f74c
MNT Revert erroneous dependency changes (#191) 2023-03-28 17:06:01 +13:00
Maxime Rainville b5e468a266
Merge pull request #190 from creative-commoners/pulls/4/dispatch-ci
MNT Use gha-dispatch-ci
2023-03-23 14:10:27 +13:00
Steve Boyd f1f6abca67 MNT Use gha-dispatch-ci 2023-03-21 12:23:51 +13:00
Nicolaas / Sunny Side Up 4324836cb7 MNT Add additional keywords to composer.json 2023-03-20 23:21:46 +13:00
Guy Sartorelli 47769763db
MNT Update development dependencies 2023-03-10 16:33:34 +13:00
Guy Sartorelli 884a846167
MNT Update release dependencies 2023-03-10 16:33:31 +13:00
Guy Sartorelli ff723b58ef
MNT Update development dependencies 2023-03-10 12:21:29 +13:00
Guy Sartorelli 18828ed094
Merge pull request #187 from creative-commoners/pulls/4/tx-1678079773
ENH Update translations
2023-03-08 10:25:08 +13:00
Steve Boyd e8a41d96e5 ENH Update translations 2023-03-06 18:16:13 +13:00
12 changed files with 201 additions and 15 deletions

View File

@ -4,13 +4,8 @@ on:
push:
pull_request:
workflow_dispatch:
# Every Wednesday at 11:30am UTC
schedule:
- cron: '30 11 * * 3'
jobs:
ci:
name: CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1

16
.github/workflows/dispatch-ci.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Dispatch CI
on:
# At 11:30 AM UTC, only on Wednesday and Thursday
schedule:
- cron: '30 11 * * 3,4'
jobs:
dispatch-ci:
name: Dispatch CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Dispatch CI
uses: silverstripe/gha-dispatch-ci@v1

View File

@ -1,14 +1,15 @@
[main]
host = https://www.transifex.com
[silverstripe-contentreview.master]
[o:silverstripe:p:silverstripe-contentreview:r:master]
file_filter = lang/<lang>.yml
source_file = lang/en.yml
source_lang = en
type = YML
type = YML
[silverstripe-contentreview.master-js]
[o:silverstripe:p:silverstripe-contentreview:r:master-js]
file_filter = client/lang/src/<lang>.json
source_file = client/lang/src/en.json
source_lang = en
type = KEYVALUEJSON
type = KEYVALUEJSON

View File

@ -1,5 +1,5 @@
// This file was generated by silverstripe/cow from client/lang/src/en.json.
// See https://github.com/silverstripe/cow for details
// This file was generated by silverstripe/tx-translator from client/lang/src/en.json.
// See https://github.com/silverstripe/silverstripe-tx-translator for details
if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
if (typeof(console) !== 'undefined') { // eslint-disable-line no-console
console.error('Class ss.i18n not defined'); // eslint-disable-line no-console

11
client/lang/sk.js Normal file
View File

@ -0,0 +1,11 @@
// This file was generated by silverstripe/tx-translator from client/lang/src/sk.json.
// See https://github.com/silverstripe/silverstripe-tx-translator for details
if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
if (typeof(console) !== 'undefined') { // eslint-disable-line no-console
console.error('Class ss.i18n not defined'); // eslint-disable-line no-console
}
} else {
ss.i18n.addDictionary('sk', {
"ContentReview.CONTENT_DUE_FOR_REVIEW": "Obsah určený na kontrolu"
});
}

3
client/lang/src/sk.json Normal file
View File

@ -0,0 +1,3 @@
{
"ContentReview.CONTENT_DUE_FOR_REVIEW": "Obsah určený na kontrolu"
}

View File

@ -7,7 +7,10 @@
"keywords": [
"silverstripe",
"cms",
"workflow"
"workflow",
"content review",
"review",
"permissions"
],
"authors": [
{
@ -49,4 +52,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

View File

@ -15,6 +15,14 @@ en:
PAGEOWNERUSERS: Users
REVIEWFREQUENCY: 'Review frequency'
REVIEWFREQUENCYDESCRIPTION: 'The review date will be set to this far in the future, whenever the page is published.'
db_ReviewBody: 'Review body'
db_ReviewFrom: 'Review from'
db_ReviewPeriodDays: 'Review period days'
db_ReviewSubject: 'Review subject'
many_many_ContentReviewGroups: 'Content review groups'
many_many_ContentReviewUsers: 'Content review users'
SilverStripe\ContentReview\Extensions\ContentReviewOwner:
many_many_SiteTreeContentReview: 'Site tree content review'
SilverStripe\ContentReview\Extensions\SiteTreeContentReview:
ADDGROUP: 'Add groups'
ADDUSERS: 'Add users'
@ -34,6 +42,14 @@ en:
REVIEWFREQUENCYDESCRIPTION: 'The review date will be set to this far in the future whenever the page is published'
REVIEWHEADER: 'Content review'
SETTINGSFROM: 'Options are'
belongs_many_many_ContentReviewGroups: 'Content review groups'
belongs_many_many_ContentReviewUsers: 'Content review users'
db_ContentReviewType: 'Content review type'
db_LastEditedByName: 'Last edited by name'
db_NextReviewDate: 'Next review date'
db_OwnerNames: 'Owner names'
db_ReviewPeriodDays: 'Review period days'
has_many_ReviewLogs: 'Review logs'
SilverStripe\ContentReview\Forms\ReviewContentHandler:
ErrorReviewPermissionDenied: 'It seems you don''t have the necessary permissions to submit a content review'
MarkAsReviewedAction: 'Mark as reviewed'
@ -46,6 +62,9 @@ en:
one: 'A Content Review Log'
other: '{count} Content Review Logs'
SINGULARNAME: 'Content Review Log'
db_Note: Note
has_one_Reviewer: Reviewer
has_one_SiteTree: 'Site tree'
SilverStripe\ContentReview\Reports\PagesDueForReviewReport:
ONLYMYPAGES: 'Only Show pages assigned to me'
REVIEWDATEAFTER: 'Review date after or on'

80
lang/sk.yml Normal file
View File

@ -0,0 +1,80 @@
sk:
SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension:
ErrorItemPermissionDenied: 'Zdá sa, že nemáte potrebné oprávnenia na kontrolu tohto obsahu'
SilverStripe\ContentReview\Extensions\ContentReviewDefaultSettings:
ADDGROUP: 'Pridať skupiny'
ADDUSERS: 'Pridať používateľov'
DEFAULTSETTINGSHELP: 'Tieto nastavenia sa použijú na všetky stránky, ktoré nemajú špecifický plán kontroly obsahu.'
EMAILFROM: 'Z e-mailovej adresy'
EMAILFROM_RIGHTTITLE: 'napr.: do-not-reply@site.com'
EMAILSUBJECT: Predmet
EMAILTEMPLATE: 'Šablóna e-mailu'
OWNERGROUPSDESCRIPTION: 'Vlastníci stránok, ktorí sú zodpovední za kontrolu'
OWNERUSERSDESCRIPTION: 'Vlastníci stránok, ktorí sú zodpovední za kontrolu'
PAGEOWNERGROUPS: Skupiny
PAGEOWNERUSERS: Používatelia
REVIEWFREQUENCY: 'Frekvencia kontroly'
REVIEWFREQUENCYDESCRIPTION: 'Dátum kontroly bude nastavený na tento dátum v budúcnosti, bez ohľadu na to, kedy bude stránka zverejnená.'
db_ReviewBody: 'Revízny orgán'
db_ReviewFrom: 'Kontrola od'
db_ReviewPeriodDays: 'Dni periódy kontroly'
db_ReviewSubject: 'Predmet kontroly'
many_many_ContentReviewGroups: 'Skupiny kontroly obsahu'
many_many_ContentReviewUsers: 'Používatelia kontroly obsahu'
SilverStripe\ContentReview\Extensions\ContentReviewOwner:
many_many_SiteTreeContentReview: 'Kontrola obsahu stromu stránok'
SilverStripe\ContentReview\Extensions\SiteTreeContentReview:
ADDGROUP: 'Pridať skupiny'
ADDUSERS: 'Pridať používateľov'
CONTENTOWNERS: 'Vlastníci obsahu'
CONTENTREVIEW: 'Obsah určený na kontrolu'
CUSTOM: 'Vlastné nastavenia'
DISABLE: 'Zakázať kontrolu obsahu'
INHERIT: 'Zdediť z nadradenej stránky'
NEXTREVIEWDATADESCRIPTION: 'Ak nechcete vyplniť kontrolu, ponechajte pole prázdne'
NEXTREVIEWDATE: 'Dátum ďalšej kontroly'
OPTIONS: Možnosti
OWNERGROUPSDESCRIPTION: 'Vlastníci stránok, ktorí sú zodpovední za kontrolu'
OWNERUSERSDESCRIPTION: 'Vlastníci stránok, ktorí sú zodpovední za kontrolu'
PAGEOWNERGROUPS: Skupiny
PAGEOWNERUSERS: Používatelia
REVIEWFREQUENCY: 'Frekvencia kontroly'
REVIEWFREQUENCYDESCRIPTION: 'Dátum kontroly bude nastavený na tento dátum v budúcnosti, bez ohľadu na to, kedy bude stránka zverejnená.'
REVIEWHEADER: 'Kontrola obsahu'
SETTINGSFROM: 'Možnosti sú'
belongs_many_many_ContentReviewGroups: 'Skupiny kontroly obsahu'
belongs_many_many_ContentReviewUsers: 'Používatelia kontroly obsahu'
db_ContentReviewType: 'Typ kontroly obsahu'
db_LastEditedByName: 'Naposledy upravené podľa mena'
db_NextReviewDate: 'Dátum ďalšej kontroly'
db_OwnerNames: 'Mená vlastníkov'
db_ReviewPeriodDays: 'Dni periódy kontroly'
has_many_ReviewLogs: 'Záznamy z kontroly'
SilverStripe\ContentReview\Forms\ReviewContentHandler:
ErrorReviewPermissionDenied: 'Zdá sa, že nemáte potrebné oprávnenia na odoslanie kontroly obsahu'
MarkAsReviewedAction: 'Označiť ako skontrolované'
NoComments: '(bez komentára)'
Placeholder: 'Pridať komentáre (voliteľné)'
Success: 'Kontrola bola úspešne pridaná'
SilverStripe\ContentReview\Models\ContentReviewLog:
PLURALNAME: 'Záznamy z kontroly obsahu'
PLURALS:
few: '{count} záznamy z kontroly obsahu'
many: '{count} záznamov z kontroly obsahu'
one: 'Záznam z kontroly obsahu'
other: '{count} záznamov z kontroly obsahu'
SINGULARNAME: 'Záznam z kontroly obsahu'
db_Note: Poznámka
has_one_Reviewer: Kontrolór
has_one_SiteTree: 'Strom stránok'
SilverStripe\ContentReview\Reports\PagesDueForReviewReport:
ONLYMYPAGES: 'Zobraziť iba mne priradené stránky'
REVIEWDATEAFTER: 'Dátum kontroly po'
REVIEWDATEBEFORE: 'Dátum kontroly pred'
SHOWVIRTUALPAGES: 'Zobraziť virtuálne stránky'
TITLE: 'Stránky určené na kontrolu'
SilverStripe\ContentReview\Reports\PagesWithoutReviewScheduleReport:
TITLE: 'Stránky bez naplánovanej kontroly.'
SilverStripe\ContentReview\Tasks\ContentReviewEmails:
REVIEWPAGELINK: 'Skontrolujte stránku v CMS'
VIEWPUBLISHEDLINK: 'Pozrite si túto stránku na webe'

View File

@ -93,7 +93,7 @@ class ContentReviewNotificationJob extends AbstractQueuedJob implements QueuedJo
{
$this->queueNextRun();
$task = new ContentReviewEmails();
$task = ContentReviewEmails::create();
$task->run(new HTTPRequest("GET", "/dev/tasks/ContentReviewEmails"));
$this->currentStep = 1;

View File

@ -3,6 +3,7 @@
namespace SilverStripe\ContentReview\Tasks;
use Page;
use RuntimeException;
use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\Control\Email\Email;
use SilverStripe\Control\HTTPRequest;
@ -15,18 +16,29 @@ use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
use SilverStripe\ContentReview\Models\ContentReviewLog;
/**
* Daily task to send emails to the owners of content items when the review date rolls around.
*/
class ContentReviewEmails extends BuildTask
{
private array $invalid_emails = [];
/**
* @param HTTPRequest $request
* @throws RuntimeException
*/
public function run($request)
{
if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
throw new RuntimeException(
sprintf(
'Provided sender email address is invalid: "%s".',
$senderEmail
)
);
}
$compatibility = ContentReviewCompatability::start();
// First grab all the pages with a custom setting
@ -42,6 +54,16 @@ class ContentReviewEmails extends BuildTask
}
ContentReviewCompatability::done($compatibility);
if (is_array($this->invalid_emails) && count($this->invalid_emails) > 0) {
$plural = count($this->invalid_emails) > 1 ? 's are' : ' is';
throw new RuntimeException(
sprintf(
'Provided email' . $plural . ' invalid: "%s".',
implode(', ', $this->invalid_emails)
)
);
}
}
/**
@ -93,6 +115,13 @@ class ContentReviewEmails extends BuildTask
// Prepare variables
$siteConfig = SiteConfig::current_site_config();
$owner = Member::get()->byID($ownerID);
if (!$this->isValidEmail($owner->Email)) {
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
return;
}
$templateVariables = $this->getTemplateVariables($owner, $siteConfig, $pages);
// Build email
@ -159,4 +188,12 @@ class ContentReviewEmails extends BuildTask
'ToEmail' => $recipient->Email,
];
}
/**
* Check validity of email
*/
protected function isValidEmail(?string $email): bool
{
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
}
}

View File

@ -3,6 +3,7 @@
namespace SilverStripe\ContentReview\Tests;
use Page;
use ReflectionClass;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\ContentReview\Extensions\ContentReviewCMSExtension;
@ -132,6 +133,26 @@ class ContentReviewNotificationTest extends SapphireTest
DBDatetime::clear_mock_now();
}
/**
* Test that provided email is valid
*/
public function testIsValidEmail()
{
$class = new ReflectionClass(ContentReviewEmails::class);
$method = $class->getMethod('isValidEmail');
$method->setAccessible(true);
$member = $this->objFromFixture(Member::class, 'author');
$task = new ContentReviewEmails();
$this->assertTrue($method->invokeArgs($task, [$member->Email]));
$this->assertTrue($method->invokeArgs($task, ['correct.email@example.com']));
$this->assertFalse($method->invokeArgs($task, [null]));
$this->assertFalse($method->invokeArgs($task, ['broken.email']));
$this->assertFalse($method->invokeArgs($task, ['broken@email']));
}
/**
* Deletes all pages except those passes in to the $ids parameter
*