diff --git a/src/ChangeSetItem.php b/src/ChangeSetItem.php index edbf1ca9..13e5848c 100644 --- a/src/ChangeSetItem.php +++ b/src/ChangeSetItem.php @@ -304,16 +304,21 @@ public function publish() case static::CHANGE_CREATED: { // Non-recursive publish $object = $this->getObjectInStage(Versioned::DRAFT); - $object->publishSingle(); - - // Point after version to the published version actually created, not the - // version copied from draft. - $this->VersionAfter = Versioned::get_versionnumber_by_stage( - $this->ObjectClass, - Versioned::LIVE, - $this->ObjectID, - false - ); + $member = Security::getCurrentUser(); + + // Check if object has canPublish set to true + if ($object->canPublish($member)) { + $object->publishSingle(); + + // Point after version to the published version actually created, not the + // version copied from draft. + $this->VersionAfter = Versioned::get_versionnumber_by_stage( + $this->ObjectClass, + Versioned::LIVE, + $this->ObjectID, + false + ); + } break; } default: @@ -524,8 +529,8 @@ public function getPreviewLinks() $live = $this->getObjectInStage(Versioned::LIVE); if ($live instanceof CMSPreviewable && $live->canView() && ($link = $live->PreviewLink())) { $links[Versioned::LIVE] = [ - 'href' => Controller::join_links($link, '?stage=' . Versioned::LIVE), - 'type' => $live->getMimeType(), + 'href' => Controller::join_links($link, '?stage=' . Versioned::LIVE), + 'type' => $live->getMimeType(), ]; } }