silverstripe /
silverstripe-sharedraftcontent
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SilverStripe\ShareDraftContent\Extensions; |
||
| 4 | |||
| 5 | use SilverStripe\Core\Extension; |
||
| 6 | use SilverStripe\Security\Security; |
||
| 7 | |||
| 8 | class ShareDraftContentControllerExtension extends Extension |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | private static $allowed_actions = [ |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 14 | 'MakeShareDraftLink', |
||
| 15 | ]; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | public function MakeShareDraftLink() |
||
| 21 | { |
||
| 22 | if ($member = Security::getCurrentUser()) { |
||
| 23 | if ($this->owner->hasMethod('CurrentPage') && $this->owner->CurrentPage()->canView($member)) { |
||
| 24 | return $this->owner->CurrentPage()->ShareTokenLink(); |
||
| 25 | } |
||
| 26 | if ($this->owner->hasMethod('canView') && $this->owner->canView($member)) { |
||
| 27 | return $this->owner->ShareTokenLink(); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | return Security::permissionFailure(); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | public function getShareDraftLinkAction() |
||
| 38 | { |
||
| 39 | if ($this->owner->config()->get('url_segment')) { |
||
| 40 | return $this->owner->Link('MakeShareDraftLink'); |
||
| 41 | } |
||
| 42 | return ''; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |