IBX-10854: Added ability to hide content item drafts#667
IBX-10854: Added ability to hide content item drafts#667
Conversation
| // If content is in draft state, mainLocationId is yet not set | ||
| if ($contentInfo->mainLocationId !== null) { |
There was a problem hiding this comment.
If this is true, then a dedicated ContentInfo method should probably be introduced.
There was a problem hiding this comment.
@Steveb-p
Okay, so I first thought about adding function like this:
+ public function isInitialDraft(): bool
+ {
+ return $this->status === self::STATUS_DRAFT && $this->currentVersionNo === 1;
+ }
However, then I realized that this is not needed for ContentInfo as existing ContentInfo::isDraft() will do just fine. This method will only return true if Content in question has never been published. Once Content is published, ContentInfo::isDraft() will still return false when you create new drafts for that content.
Fixed in acbb2d8
alongosz
left a comment
There was a problem hiding this comment.
AFAIR this is by-design. There's no purpose to hiding content drafts because content drafts can be read by people with versionread policy, the same as hidden content can be accessed. Are you trying to fix some fatal error or enable hiding drafts? TL;DR;.
yes, it is. If you don't want content to be visible at time of publishing.
@alongosz edited.... |
|
There was a problem hiding this comment.
Doesn't this mean, with this change, that for drafts every user has ability to hide & reveal?
Because we won't be checking permission resolver for drafts.
|
@vidarl please make sure #667 (comment) is addressed, PR is rebased and the CI lits green. |
acbb2d8 to
ca2b306
Compare
@konradoboza |
…to hide content draft" This reverts commit 0de3f32.
Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
Co-authored-by: Konrad Oboza <konrad.oboza@ibexa.co>
e6a3f58 to
6671254
Compare
b5d7eaa to
91fd72c
Compare
91fd72c to
af81e00
Compare
|
|
@alongosz, @konradoboza, @Steveb-p : Can you have a new look on this one. I think all review comments has been addressed |
| $locationTarget = !$contentInfo->isDraft() | ||
| ? [new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo)] | ||
| : []; |
There was a problem hiding this comment.
When you have the option, prefer a condition without a negation, if both paths are valid.
| $locationTarget = !$contentInfo->isDraft() | |
| ? [new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo)] | |
| : []; | |
| $locationTarget = $contentInfo->isDraft() | |
| ? [] | |
| : [new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo)]; |
Alternatively, for readability
| $locationTarget = !$contentInfo->isDraft() | |
| ? [new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo)] | |
| : []; | |
| $locationTarget = []; | |
| if ($contentInfo->isDraft() === false) { | |
| $locationTarget[] = new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo); | |
| } |
| * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException | ||
| * @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException | ||
| */ | ||
| private function createContentForHideRevealDraftTests(bool $revel): Content |
There was a problem hiding this comment.
| private function createContentForHideRevealDraftTests(bool $revel): Content | |
| private function createContentForHideRevealDraftTests(bool $reveal): Content |
|
|
||
| $draftContentInfo = $draft->getContentInfo(); | ||
| $this->contentService->hideContent($draftContentInfo); | ||
| if ($revel) { |
There was a problem hiding this comment.
| if ($revel) { | |
| if ($reveal) { |
| $locationTarget = !$contentInfo->isDraft() | ||
| ? [new DestinationLocationTarget($contentInfo->getMainLocationId(), $contentInfo)] | ||
| : []; | ||
| if (!$this->permissionResolver->canUser( | ||
| 'content', | ||
| 'hide', | ||
| $contentInfo, | ||
| [$locationTarget] | ||
| $locationTarget |
There was a problem hiding this comment.
What if user is working on already published item, but doesn't have content/hide permission on a given subtree?
The scenario I'm thinking is that he's creating a draft, hides it, and publishes it as hidden. That would bypass his inability to hide in a given subtree (only if he has permission to hide in another subtree).



It is not possible to publish content in hidden state
For QA:
Note
Edited by @alongosz
Requires security testing, e.g., if user who doesn't have hide/reveal permissions is now able to do it.
Documentation: