Currently 'Roles that may use this flag' is required.

A user might want to disallow a flag for all roles, for example, if the flag is only set via Rules.

Comments

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new751 bytes

I think this option was changed to required to avoid confusion, since many permissions systems default to "Allow access to all roles" when no options are checked. However I see the usefulness of this change, especially since it's helpful when testing a new flag as user 1 (which will always have permission). Committed the attached patch.

nick.dap’s picture

+1 on this

I have the following problem:

Writing a module that supplies a flag through the Flag API, I cannot set a role because I do not know the meaning of the roles on the target installation. The only common denominator is "authenticated user" role which is too permissive in my case. This is an admin module that comes with a flag that is only available to the admin.

nick.dap’s picture

quicksketch’s picture

nick.dap: Please open a separate support request for your question, which is only loosely related to this feature request.

nick.dap’s picture

Status: Fixed » Needs review

quicksketch:

The requested feature is exactly what I'm looking for. However, the patch you provided is not enough for the requested functionality. Namely "user might want to disallow a flag for all roles"

The patch makes the field not required on the form, but the flag will still show for all roles if the roles property is left empty.

I think the following change is needed. Please excuse the mercurial diff on my local repository.

diff -r 6e63f522ace1 httproot/sites/all/modules/flag/flag.inc
--- a/httproot/sites/all/modules/flag/flag.inc	Thu Oct 01 19:37:35 2009 -0400
+++ b/httproot/sites/all/modules/flag/flag.inc	Thu Oct 01 19:46:32 2009 -0400
@@ -345,7 +345,7 @@
       $account = $GLOBALS['user'];
     }
     $matched_roles = array_intersect($this->roles, array_keys($account->roles));
-    return !empty($matched_roles) || empty($this->roles) || $account->uid == 1;
+    return !empty($matched_roles) || $account->uid == 1;
   }
   /**

I am successfully using the combination of your patch and the proposed change to get the functionality.

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Thanks nick.dap, I noticed this anomaly in #271582: Allow anonymous users to flag content, which includes the same fix. I'll commit this fix separately, since it doesn't actually involve most of that other issue.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new601 bytes

Committed the attached fix.

Status: Fixed » Closed (fixed)

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