As discussed with quicksketch in the IRC that patch changes $flag->default_options to $flag->options().
I've also added the patch for #475366: Flag queue here. If you'd like that separate I can do it.

So next move, as discussed, would be creating a 2.x branch .

Comments

quicksketch’s picture

Status: Needs review » Needs work

Hey Amitaibu, looks pretty good. I'm concerned about this function:

+/**
+ * Get fcid from content ID.
+ */
+function flag_get_fcid_from_content_id($content_id) {
+  return db_result(db_query("SELECT fcid FROM {flag_content} WHERE content_id = %d", $content_id));
+}

This will not return the complete set of results, since a single piece of content may be flagged multiple times by different users (unless it's a "global" flag). So retrieving a single fcid is a bit misleading. Adding a second $uid parameter might make sense, but default it to NULL in the case that you're checking on a global flag.

Actually now that I think about it more, there's yet another parameter needed here, since the same user might flag both a node with nid "2" and a user with uid "2". So we need to either require a content_type parameter or a flag ID (fid), so that we get a unique result per type (since flags are tied to one type of content, either one will work.

I'm also a bit curious about flag_get_flag_counts, why would you want to use this rather than flag_get_counts() or $flag->get_counts(), which does the same thing?

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new4.49 KB

1) Fixed flag_get_fcid_from_content_id() to return all possible fcid values, and added $fid to the function's signature.
2) I've added static to flag_get_flag_counts() so it will be like flag_get_counts()

flag_get_counts - return all counts for a content ID.
flag_get_flag_counts - return counts for *all* the content IDs in that flag.

quicksketch’s picture

Title: Add branch2 related changes » Add hook_flag_options_alter() (create a 2.x branch).
Status: Needs review » Fixed
StatusFileSize
new2.26 KB

This patch seems to contain a variety of changes, but it's a good place to start with the 2.x version. I've added the drupal_alter('flag_options') hook to get started, let's move the API changes back into #475366: Flag queue, since I think these need some further revision.

I've created the 2.x branch with the attached changes.

quicksketch’s picture

quicksketch’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

Status: Fixed » Closed (fixed)

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

mooffie’s picture

Issue tags: +flag queue

Tagging.