Activity2 Integration
Scott Reynolds - June 18, 2009 - 17:58
| Project: | Flag |
| Version: | 6.x-2.x-dev |
| Component: | Actions integration |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Scott Reynolds |
| Status: | closed |
| Issue tags: | activity2-integration |
Description
This patch is postponed until #495524: Fix Flags Trigger implementation :-D lands because it provides the interesting the objects it needs for completion.
This patch provides recording of node and comment flags (user flags are complicated because of an issue surrounding 'user' vs 'account') into Activity2 streams.
It also provides Activity2 Access control for your flagged items. For instance, this access control implementation allows the following:
1.) See all activity of users you have flagged
2.) See all activity on nodes you have flagged
| Attachment | Size |
|---|---|
| flag.patch | 3.49 KB |

#1
Patch says it is malformed. Here is a re-roll that works.
#2
/me should stop rolling patches by hand...
#3
Hi folks
I've been away for a while but recently back into this and have installed the latest dev build and applied the above patches. I can configure individual flags but they aren't getting written to the activity table but there are writes to activity_access for the flagging events.
Any quick ideas on why this could be (or have I missed something?) before I go digging deeper?
Just noticed this is a Flag issue. I am referring to Activity module (latest dev build) with flag integration patches.
Thanks
Simon H
#4
goto admin/settings/activity/settings (we know bad url...but alias we wanted the template listing to be the landing page) and tell activity to log flag access.
#5
Hi Scott
I had set both my 2 flag types already and left bookmark and comments blank. I figured this bit was ok, otherwise it wouldnt be logging in activity_access?
Any other ideas? I'll try to figure it out as soon as I get the chance. I presume the latest CVS and the above two flag patches are all I need?
#6
Hi folks
I've done a bit of work and have discovered a few issues in acitivity module and activity patch for flag module:
1. activity_get_module_info(), line 26 needs changed to
require_once $info->path .'/'. $module .'.activity.inc';so the include path is correct, as per the location of flag.activity.inc.2. In activty_record():
$record->uid = (!empty($context[$type]->uid)) ? $context[$type]->uid : $user->uid;$context[$type]->uid didnt exist and $user wasnt a global.
Where the main failure is, is at activity_record_check(), or rather, flag_activity_type_check() in the flag acitivity patch:
function flag_activity_type_check($token_objects, $types) {return (in_array($token_objects['flag']->fid, $types));
}
$token_objects['flag'] doesn't seem to exist, and therefore, $token_objects['flag']->fid doesn't exist.
So, this is where I'm stuck. Can you suggest a suitable replacement for flag_activity_type_check() or how we get 'flag' into $token_objects if required?
Thanks
Simon
#7
Hi again
I also noticed that when flagging, activities get logged for each flag type, regardless. And if each node has multiple locations (Location module) I end up with the flag activity logging 4 times, 2 flag types, 2 locations, 1 node. Any ideas on this one?
Thanks again
Simon
#8
I have applied the #495524: Fix Flags Trigger implementation :-D patch as well as this patch and had a thought. I currently have a flag called 'favorite' which can apply to two different content types. Each content type appears at a different path that was created by pathauto. For example:
Content Type #1 - path is /type1/[nid]
Content Type #2 - path is /type2/[nid]
My flag action of 'favorite' can apply to BOTH content types. One of the challenges now is that the flag actions are not created as a 'trigger' of the node. So when I go to settings/activity/create and select flag, content has been flagged, I can do it but the public message now can't be linked back to the nodes because I could only provide a single path. I.E. I can only set the public message set to:
Person 1 flagged this
since the path will be correct for one node type but not the other.
One potential solution for my use case would be to move the flag action as a sub-type to the nodeapi. In that instance I would go to Create -> Node -> and one of the triggers would be "Flag". In this case I could then create a node flag trigger for each content type so I could correctly provide the two different paths.
Does that make sense?
#9
I agree with #6 - the include path in activity seems to be incomplete. Since the new flag include is in the modulepath/flag/includes/flag.activity.inc, activity.module should do something like this starting around line 20:
if (isset($info->api) && $info->api == 2.000) {// Set the defaults. Not all modules implement the full api
if (!isset($info->path)) {
$info->path = drupal_get_path('module', $module);
}
elseif (file_exists('./'. $info->path .'/'. $module .'.activity.inc')) {
require_once './'. $info->path .'/'. $module .'.activity.inc';
}
elseif (file_exists('./'. $info->path .'/includes/'. $module .'.activity.inc')) {
require_once './'. $info->path .'/includes/'. $module .'.activity.inc';
}
Whereby the last elseif is the addition.
Even with that fix, it still doesn't work for me despite being configured under settings for the activity access control and having a created activity to record the flag type and display some output. Not sure why, but I am out of time for now.
#10
Re: include path...
From the patch
$info->path = drupal_get_path('module', 'flag') . '/includes';So that is handled already. There isn't an error there
#11
Ok I have decided to combine these two patches. Makes my life a bit easier and no one else is really using Flags Trigger implementation
Attached it is a complete patch, including the fixes to flag_flag() function. Please remember that when reviewing this patch, patch -i flag_activity.patch will create a file flag.activity.inc in the ROOT of the flag folder. You must move that to flag/includes folder.
I have tested both flag and unflagged. There was a bug when an admin selected types that preventing recording that is now fixed. There was a bug with how flag fired its actions (namely, 'unflag') that is now fixed. And there was a bug with flag where it failed to declare an 'op' in the context array, that is now fixed.
#12
Re: #8 #495526-8: Activity2 Integration
#473946: Provide clean url tokens to node author profile has been committed with the fix so the urls will now work with pathauto. if you need help, or that commit doesn't fix it for you please take post on that issue, not here.
#13
Here's a reroll with the following nitpicks fixed:
- Fixed comments to be sentences, fixed line wrapping.
- Remove whitespace at end of lines.
- Clarified comments, fixed grammar.
- Changed the object keys to be all lower case in hook_activity_info(), since that's what activity module does. Should multiple words be separated with underscores instead of spaces?
A few questions:
// Currently, flagging a user cannot be recorded.if ($flag->content_type != 'user') {
$info->type_options[$flag->fid] = $flag->title;
}
Why can't user flags be recorded? Does this mean flags on taxonomy terms, files, or other datatypes aren't supported either? Maybe this should be hard-coded to only support node and comment rather than excluding only user.
When completed, this patch will only be applied to the 2.x version since it makes API changes and adds new functionality.
#14
Its because Token can't handle 'account' and 'user' together. We would have to create a pseudo hook_token implementation that grabs all tokens for 'user' and prefix them with flagged-user-. Then add the notable user object into the objects array. Sortof a huge mess.
Thats considerably larger undertaking
It is not reflective of the ability to handle other Drupal objects. User is difficult with token. Flag friend and others have to handle it differently as well.
#15
Well that's good news. Is there anything else that needs consideration here? I think things look good otherwise.
#16
Im really proud of this patch. I think it reflects a whole bunch of awesomeness. You can create a flag and follow someone. All activity (og, comments, flagging, node creation, status message updates) of the person you are following can be configured totally within a View. You can bookmark a node or comment and all activity happening on that node can be surfaced in an Activity View.
Its one of those things that makes you go "Wow I can build a View to do that?"
I would like to create a separate pass at user flagging as a follow up. I came up with pretty unique idea to handle it.
#17
Hi Scott and quicksketch, thanks for your work on this. I've tried installing the latest (sept. 23) activity 2.x-dev module and the flag 2.x-dev, applying the patch in #13 and I get the following error after applying a 'activity access = flag' filter:
warning: Invalid argument supplied for foreach() in /Users/thomascermak/Sites/londonfuse/sites/all/modules/activity/views/activity_views_handler_filter_access.inc on line 64.#18
Hi all,
What is the status of the patch for 2.x? I ask because I tried installing the latest versions of flag and activity (both 2.x-dev) and applying the patch in #13 but get the error:
"The patch seems outdated! The file line
}
and the patchline
$output .= theme('table', $header, $rows);
do not match!"
Any ideas?
Thanks in advance.
#19
As well as this, when using TortoiseMerge, I see two patches on the left. One is named flag.module, the other is "null" (please see the attached screenshot)...
#20
Hi Scott,
I know you're probably super busy. But any possible update on this? This type of feature could do wonders for one of my sites.
Thanks so much,
Thomas
#21
Would point out that the bug is probably because this patch adds a new file. And patch doesn't put that file in the right spot. Same for #19, that is why it is null, its a new file.
See: drupal.org/patch/create under the section Adding/Deleting Files Using the Diff Command
Just move flag.activity.inc form flag/ into flag/includes
#22
I feel stupid. Thanks Scott.
#23
this just made my day - really powerful stuff, wow! Big THANKS for the module to Scott, the patch to Scott & contribs!
#24
Sounds like this is working for you guys. So marking as RTBC.
If it isn't please mark as needs work and why it isn't working.
#25
Definitely working fine here. This should go in the dev.
#26
Erg. RTBC patches that DON'T APPLY drive me nuts. This patch has been broken for the last month since #397464: Action for executing a flag was committed. I assume the users confirming this works were either using an earlier 2.x version or the 1.x version.
Anyway, other than that I agree that this patch is ready to go. So after a reroll and adjusting for the changes to the trigger integration, this is committed. Thanks Scott Reynolds for your work on this feature.
Attached patch that was committed.
#27
mee -feed / you feed issue resolved, see here http://drupal.org/node/396960#comment-2227106
#28
Ya, I haven't tested on the latest dev.
#29
Automatically closed -- issue fixed for 2 weeks with no activity.