Skip to content
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