mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
Compare commits
4 Commits
c856dc2981
...
840a0db70c
Author | SHA1 | Date | |
---|---|---|---|
|
840a0db70c | ||
|
4b8f7586d2 | ||
|
4488096f6e | ||
|
f7ee5d7fe8 |
@ -11,7 +11,7 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
use SilverStripe\Control\HTTPResponse;
|
use SilverStripe\Control\HTTPResponse;
|
||||||
use SilverStripe\Control\HTTPResponse_Exception;
|
use SilverStripe\Control\HTTPResponse_Exception;
|
||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
use SilverStripe\ORM\ValidationResult;
|
use SilverStripe\Core\Validation\ValidationResult;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Core\Extension;
|
use SilverStripe\Core\Extension;
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@ use SilverStripe\Forms\ListboxField;
|
|||||||
use SilverStripe\Forms\LiteralField;
|
use SilverStripe\Forms\LiteralField;
|
||||||
use SilverStripe\Forms\OptionsetField;
|
use SilverStripe\Forms\OptionsetField;
|
||||||
use SilverStripe\Forms\ReadonlyField;
|
use SilverStripe\Forms\ReadonlyField;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\HasManyList;
|
use SilverStripe\ORM\HasManyList;
|
||||||
use SilverStripe\ORM\ManyManyList;
|
use SilverStripe\ORM\ManyManyList;
|
||||||
use SilverStripe\ORM\FieldType\DBDate;
|
use SilverStripe\ORM\FieldType\DBDate;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\Model\List\SS_List;
|
||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
|
@ -14,7 +14,7 @@ use SilverStripe\Forms\FormAction;
|
|||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\Forms\TextareaField;
|
use SilverStripe\Forms\TextareaField;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\Core\Validation\ValidationException;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
class ReviewContentHandler
|
class ReviewContentHandler
|
||||||
|
@ -13,7 +13,7 @@ use SilverStripe\Forms\CheckboxField;
|
|||||||
use SilverStripe\Forms\DateField;
|
use SilverStripe\Forms\DateField;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\Model\List\SS_List;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
|
@ -9,9 +9,9 @@ use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
|
|||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Forms\CheckboxField;
|
use SilverStripe\Forms\CheckboxField;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\Model\List\SS_List;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
|
@ -8,13 +8,13 @@ use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
|
|||||||
use SilverStripe\Control\Email\Email;
|
use SilverStripe\Control\Email\Email;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
use SilverStripe\Dev\BuildTask;
|
use SilverStripe\Dev\BuildTask;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\Model\List\SS_List;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\Model\ArrayData;
|
||||||
use SilverStripe\View\SSViewer;
|
use SilverStripe\View\SSViewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +30,7 @@ class ContentReviewEmails extends BuildTask
|
|||||||
*/
|
*/
|
||||||
public function run($request)
|
public function run($request)
|
||||||
{
|
{
|
||||||
if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
|
if (!Email::is_valid_address($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Provided sender email address is invalid: "%s".',
|
'Provided sender email address is invalid: "%s".',
|
||||||
@ -116,7 +116,7 @@ class ContentReviewEmails extends BuildTask
|
|||||||
$siteConfig = SiteConfig::current_site_config();
|
$siteConfig = SiteConfig::current_site_config();
|
||||||
$owner = Member::get()->byID($ownerID);
|
$owner = Member::get()->byID($ownerID);
|
||||||
|
|
||||||
if (!$this->isValidEmail($owner->Email)) {
|
if (!Email::is_valid_address($owner->Email)) {
|
||||||
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
|
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -188,12 +188,4 @@ class ContentReviewEmails extends BuildTask
|
|||||||
'ToEmail' => $recipient->Email,
|
'ToEmail' => $recipient->Email,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check validity of email
|
|
||||||
*/
|
|
||||||
protected function isValidEmail(?string $email): bool
|
|
||||||
{
|
|
||||||
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class ContentReviewOwnerMigrationTask extends BuildTask
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be removed without equivalent functionality to replace it',
|
'Will be removed without equivalent functionality to replace it',
|
||||||
|
@ -133,26 +133,6 @@ class ContentReviewNotificationTest extends SapphireTest
|
|||||||
DBDatetime::clear_mock_now();
|
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
|
* Deletes all pages except those passes in to the $ids parameter
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,7 @@ use SilverStripe\Forms\Form;
|
|||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\Forms\TextareaField;
|
use SilverStripe\Forms\TextareaField;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\Core\Validation\ValidationException;
|
||||||
|
|
||||||
class ReviewContentHandlerTest extends SapphireTest
|
class ReviewContentHandlerTest extends SapphireTest
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ use SilverStripe\Security\Group;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
use SilverStripe\Dev\FunctionalTest;
|
use SilverStripe\Dev\FunctionalTest;
|
||||||
use SilverStripe\ContentReview\Tests\SiteTreeContentReviewTestPage;
|
use SilverStripe\ContentReview\Tests\SiteTreeContentReviewTestPage;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ContentReview\Tests;
|
|||||||
|
|
||||||
use Page;
|
use Page;
|
||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock Page class with canReviewContent method to return false on first call
|
* Mock Page class with canReviewContent method to return false on first call
|
||||||
|
Loading…
Reference in New Issue
Block a user