Permissions based on ownership of a comment's parent entity.

Enabling the "Permissions based on ownership of a comment's parent entity" option for a flag on a comment provides 4 permissions:

  1. Flag FlagType comments on own parent entities
  2. Flag FlagType on others' parent entities
  3. Unflag FlagType on others' parent entities
  4. Unflag FlagType on own parent entities

None of these permissions have any effect because the CommentFlagType class does not implement an actionAccess method.

Issue fork flag-3041609

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

noahott created an issue. See original summary.

noahott’s picture

Issue summary: View changes
noahott’s picture

Issue summary: View changes
noahott’s picture

StatusFileSize
new2.19 KB

This patch should fix the problem.

joachim’s picture

Status: Active » Needs work

Thanks for the patch!

Just a quick review:

+++ src/Plugin/Flag/CommentFlagType.php	(date 1553025385000)
@@ -68,5 +72,31 @@
+        if (($flaggable instanceof Comment) && ($this->hasExtraPermission('parent_owner'))) {

This is the comment flag type, so I don't think it's going to receive a flaggable that's not a comment.

Needs a bit of clean-up for Drupal coding standards too.

arno2mars’s picture

Hello,

First of all many thanks for this great module, looks very powerful and should help a lot to implement some functions I need on my website!

My scenario is quite common: I'm trying to use Flag in order to allow my users to report abusive comments to Admin. However, they should be able to only report comments posted on their own profile (they should not be able to act on comments posted on other Users profiles). And Flag looks perfectly designed for that.

This issue seems to be exactly what I'm looking for, however I can't get it working. As explained in the issue summary, after normal installation of the module, checking the checkboxes Flag FlagType comments on own parent entities & Unflag FlagType on own parent entities has no effect (as indeed the function is missing in CommentFlagType.php file.

The patch in #4 doesn't solve the issue for me. Worse, when applied, the patch makes all Flag types allocated to my comment type disappear (even if the flag types which do not have the checkboxes checked).
I understood from #5 that we should not be far to have a patch working, as only minor things should be reworked. I tried to play a bit with the code, but I'm not a programmer and I couldn't succeed to make it work.

Could please someone have a look at this to try closing this issue and propose a valid patch, or at least offer some guidance to make it work? I would bet that I am not alone in my case and many other site builders would be happy and thanksful to have that working.

I thank you in advance!!! :-)

ivnish’s picture

Assigned: noahott » Unassigned
Status: Needs work » Closed (outdated)

5 years without any activity. I think we can close it as outdated. Please reopen if needed.

ryangambito’s picture

Version: 8.x-4.x-dev » 8.x-4.0-beta6
Status: Closed (outdated) » Needs review
StatusFileSize
new1.93 KB

I've reopened the issue and created an updated patch that will be compatible with 8.x-4.0-beta6 and with the requested adjustments mentioned on #5.

ivnish’s picture

Version: 8.x-4.0-beta6 » 8.x-4.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs reroll to MR

ivnish’s picture

Issue tags: +Needs tests

Also needs tests

deaom made their first commit to this issue’s fork.

deaom changed the visibility of the branch 3041609--permissions-based to hidden.

deaom’s picture

Version: 8.x-4.x-dev » 5.x-dev

Applied the patch to the 5.x branch, test still needed.

deaom’s picture

Status: Needs work » Needs review

Added a Unit test that checks comments access, ready for review.

  • ivnish committed 358668e2 on 5.x authored by deaom
    fix: #3041609 Permissions based on ownership of a comment's parent...
ivnish’s picture

Status: Needs review » Fixed
Issue tags: -Needs reroll, -Needs tests

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.