mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-06-28 15:39:28 +02:00
1cf0f01a35
* Allow for optional can permission method for content review * Content Review permission logic With the new `canReviewContent()` permission checker we only need to check the permission is set for the user and `canBeReviewedBy()` will always check if the page object is due for review by its owner. Thus removed redundant logic in `canUseReviewContent()` and accordingly renamed the class filename for additional context. Co-authored-by: Jared Dreyer <jared.dreyer@silverstripe.com>
23 lines
617 B
PHP
23 lines
617 B
PHP
<?php
|
|
|
|
namespace SilverStripe\ContentReview\Traits;
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
|
use SilverStripe\ORM\DataObject;
|
|
use SilverStripe\Security\Member;
|
|
use SilverStripe\Security\Security;
|
|
|
|
trait PermissionChecker
|
|
{
|
|
/**
|
|
* Checks the user has been granted special permission to review the content of the page
|
|
* if not fallback to canEdit() permission.
|
|
*/
|
|
protected function isContentReviewable(DataObject $record, ?Member $user = null): bool
|
|
{
|
|
return $record->hasMethod('canReviewContent')
|
|
? $record->canReviewContent($user)
|
|
: $record->canEdit();
|
|
}
|
|
}
|