All the cool modules provide alter hooks for the default definitions, flag should totally get on the bandwagon.

(I can provide more reasons if necessary).

Files: 
CommentFileSizeAuthor
#3 flag-default-flags-alter-hook-2027091-03.patch2.85 KBjhedstrom
PASSED: [[SimpleTest]]: [MySQL] 266 pass(es).
[ View ]
#1 2027091-flag_hook_flag_default_flags_alter-1.patch2.59 KBhefox
PASSED: [[SimpleTest]]: [MySQL] 254 pass(es).
[ View ]
flag_hook_flag_default_flags_alter.patch2.13 KBhefox
PASSED: [[SimpleTest]]: [MySQL] 254 pass(es).
[ View ]

Comments

hefox’s picture

StatusFileSize
new2.59 KB
PASSED: [[SimpleTest]]: [MySQL] 254 pass(es).
[ View ]

adding api entry cause those are cool

joachim’s picture

Status:Needs review» Needs work

Seems reasonable enough -- allows things like altering Features, or flags provided by modules.

+++ b/flag.api.php
@@ -54,6 +54,15 @@ function hook_flag_default_flags() {
+ * Alter the defination of default flags.

Typo: 'definition'.

+++ b/flag.api.php
@@ -54,6 +54,15 @@ function hook_flag_default_flags() {
+function hook_flag_default_flags_alter(&$flags) {

Needs a @param.

+++ b/flag.module
@@ -1420,32 +1420,37 @@ function flag_get_default_flags($include_disabled = FALSE) {
+      $default_flags_info[$flag_name] = $flag_info += array(

That += can just be a + as we're not doing anything else with $flag_info.

+++ b/flag.module
@@ -1420,32 +1420,37 @@ function flag_get_default_flags($include_disabled = FALSE) {
+  drupal_alter('flag_default_flags', $default_flags_info);

Comment please -- helps find where hooks are invoked.

jhedstrom’s picture

Status:Needs work» Needs review
StatusFileSize
new2.85 KB
PASSED: [[SimpleTest]]: [MySQL] 266 pass(es).
[ View ]

Here's the patch with feedback from #2 incorporated.

jojonaloha’s picture

Issue summary:View changes
Status:Needs review» Reviewed & tested by the community

I'm going to be bold and mark this as RTBC. The patch in #3 still applies. I looked at the diff between the two patches and #3 fixes everything as suggested in #2, which is primarily comments. I've applied and tested the patch and it is working.

  • Commit 482afa8 on 7.x-3.x authored by hefox, committed by joachim:
    Issue #2027091 by hefox, jhedstrom: Added hook_flag_default_flags_alter...
joachim’s picture

Status:Reviewed & tested by the community» Fixed

Committed. Thanks to everyone who worked on this.

Status:Fixed» Closed (fixed)

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

japerry’s picture

Version:7.x-3.x-dev» 7.x-2.x-dev
Status:Closed (fixed)» Patch (to be ported)

We need to make a patch to be ported back to the 2.x branch, since this patch with the recent version of flag 2.2 causes #2283113: Default flags in most recent version causes notification page to fail on install.

joachim’s picture

How does a 3.x patch cause a bug in Flag 2.2???