Skip to content

Fixed issue #3692 #4214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions extensions/tags/src/Access/DiscussionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ public function can(User $actor, string $ability, Discussion $discussion): ?stri
foreach ($tags as $tag) {
if ($tag->is_restricted) {
if (! $actor->hasPermission('tag'.$tag->id.'.discussion.'.$ability)) {
// This is where the original problem happens, since the renaming
// ability is not tag related. If there are any other permissions
// alike, their original check method should also be added here.
if ($ability == 'rename') {
if ($discussion->user_id == $actor->id && $actor->can('reply', $discussion)) {
$allowRenaming = $this->settings->get('allow_renaming');

if ($allowRenaming === '-1'
|| ($allowRenaming === 'reply' && $discussion->participant_count <= 1)
|| (is_numeric($allowRenaming) && $discussion->created_at->diffInMinutes(null, true) < $allowRenaming)) {
return $this->allow();
}
}
} elseif ($ability === 'hide') {
if ($discussion->user_id == $actor->id
&& $discussion->participant_count <= 1
&& (! $discussion->hidden_at || $discussion->hidden_user_id == $actor->id)
&& $actor->can('reply', $discussion)
) {
return $this->allow();
}
}

return $this->deny();
}

Expand Down