First of all, Flag has been a great module. I hope to implement it publicly very soon.

I'm wanting to create a list of nodes that have been flagged by a group of people...in this case, my friends through the User Relationships Module.

To test it, I tried to pass a list of UIDs to the view through the argument handling code:

$args[0] = "1+2+3+4"; // UIDs of my Friends
return $args;

However, the argument for "Flags 'x' for UID" is only accepting the first UID, #1.

Is there a way to fetch the flags of multiple users using views?

Comments

ipllc’s picture

Version: 5.x-1.0-beta5 » 5.x-1.0-beta4
Category: feature » support

I've been working on this with no further solution for over a week now. I would be much appreciative if someone could help me out.

Example:

I have three friends: Friend A, Friend B, and Friend C. Each have flagged two unique stories. So, I'd like to see all of the stories my friends have flagged. This would result in a view displaying 6 flags.

I'm not looking nodes they've authored, but rather nodes they've flagged.

Can you provide any further insight on how to display a view of multiple users' flags (per-user flags)? I want to use the argument "This argument allows users to filter a view to nodes flagged with the 'x Finds' flag for the specified user." but I need "users" (plural), not "user" (singular).

Thanks!

quicksketch’s picture

Version: 5.x-1.0-beta4 » 5.x-1.0-beta5
Category: support » feature

As you've probably noticed, our Flag argument does not have support for multiple IDs (unlike the taxonomy argument handler). So what you've been trying to do isn't currently possible, the Views integration needs to be enhanced to support such functionality. So I'm changing this to a feature request.

Erm. I just noticed that this is a Drupal 5 installation. It's unlikely that the Drupal 5 version will receive further updates to its Views integration. I'll leave this open though, we should at least ensure that this is possible in Drupal 6 with Views 2.

ipllc’s picture

Thanks, Quicksketch.

Would this be possible with a custom query to the DB in the view?

Alternatively, would it be possible to fast track this feature request as if it were contract work? I guess my only stipulation would be that it would need to work for D5 since that's what we're using. It could be contributed to the module for future use by everyone...

ipllc’s picture

Okay, I took a stab at this but I'll probably need someone else to clean it up a bit.

The query function in views_query.inc is set to receive multiple values for the uid if you send it an array. Right now, in flag.views.inc on line 294 you have:

$uid = intval($arg);

This limits the ability to pass a string of comma-delimited uids like "1,2,456,982".

What I did was comment out the line above and replace the following line:

$joininfo['extra']['uid'] = $arg;

with:

if (!is_numeric($arg)) {  	
  $joininfo['extra']['uid'] =explode(",", $arg);
} else {
  $joininfo['extra']['uid'] =  intval($arg);
}

This is working well for me, allowing me to pass a string of uids as an argument like this: http://mydomain.com/flags_of_users_view/1,2,456,982/ which lists the flags of multiple users.

Thoughts? I'm not a pro so I couldn't apply a patch...but hopefully this will help with someone else who's trying to pass multiple uids as an argument.

mitchell’s picture

Version: 5.x-1.0-beta4 » 6.x-1.x-dev
Category: support » feature
Status: Active » Needs review
mitchell’s picture

Component: Miscellaneous » Views integration
quicksketch’s picture

Title: Display Flags of Multiple Users Using Views » Display Flags of Multiple Users Using Views (uid+uid+uid arguments/filters)
Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Active

Any changes will only happen to the 2.x version, where any new features are being added. This code isn't in any way applicable to Drupal 6 Views, so I'm removing the needs review status.

jday’s picture

I need to create a feed of all users and their flagged content, I take it this is not possible at the moment. I've read other posts that talk about exposing the flag table, would that make creating a view like this possible?

mooffie’s picture

Status: Active » Closed (fixed)

This issues was originally filed against Views 1.x.

I'll assume nowadays constructing this view is already possible, so I'm closing this.

(Anybody: re-open if I'm wrong.)