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

Comments

sirkitree’s picture

StatusFileSize
new3.52 KB

Patch says it is malformed. Here is a re-roll that works.

Scott Reynolds’s picture

/me should stop rolling patches by hand...

simham_uk’s picture

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

Scott Reynolds’s picture

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.

simham_uk’s picture

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?

simham_uk’s picture

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

simham_uk’s picture

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

rjbrown99’s picture

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?

rjbrown99’s picture

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.

Scott Reynolds’s picture

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

Scott Reynolds’s picture

Status: Postponed » Needs review
StatusFileSize
new4.42 KB

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.

Scott Reynolds’s picture

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.

quicksketch’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Needs work
StatusFileSize
new4.31 KB

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.

Scott Reynolds’s picture

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.

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.

quicksketch’s picture

Status: Needs work » Needs review

It is not reflective of the ability to handle other Drupal objects.

Well that's good news. Is there anything else that needs consideration here? I think things look good otherwise.

Scott Reynolds’s picture

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.

pribeh’s picture

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.

marc.groth’s picture

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.

marc.groth’s picture

StatusFileSize
new16.05 KB

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)...

pribeh’s picture

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

Scott Reynolds’s picture

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

pribeh’s picture

I feel stupid. Thanks Scott.

nitram079’s picture

this just made my day - really powerful stuff, wow! Big THANKS for the module to Scott, the patch to Scott & contribs!

Scott Reynolds’s picture

Status: Needs review » Reviewed & tested by the community

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.

pribeh’s picture

Definitely working fine here. This should go in the dev.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new4.26 KB

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.

nitram079’s picture

mee -feed / you feed issue resolved, see here http://drupal.org/node/396960#comment-2227106

pribeh’s picture

Ya, I haven't tested on the latest dev.

Status: Fixed » Closed (fixed)

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

BenK’s picture

Subscribing...

pribeh’s picture

I just wanted to add in case BenK was interested that I've tested this thoroughly the latest devs of both flag and Activity 2.x and the integration works just as desired.

tallsimon’s picture

Great please roll in to latest dev for more to try out with more ease!

adam_c’s picture

Im not sure if your plans cover my issue, I would like to add flags to activity streams, just like with facebooks 'like'. It does not seem to be possible as activity feeds are not actually nodes.

liliplanet’s picture

Status: Closed (fixed) » Active

Yes subscribe, thx ..

Is it possible to 'flag' an activity .. so not node or user, but the activity itself, same as 'I Like' in Facebook .. or am I missing something here :) ?

quicksketch’s picture

Status: Active » Closed (fixed)

Liliplanet, that is an different request. Flag does not support flagging anything other than Users, Nodes, and Comments; though it's API allows the flagging of anything. No more types will be added directly to Flag module however, so flagging of activity items will need to be a separate module.

ocamp’s picture

Do I still need to apply this patch or is it in any releases?

ocamp’s picture

nvm got it working now.

Michsk’s picture

Status: Closed (fixed) » Needs work

This options doesn't seem to work with views3. New issue?

quicksketch’s picture

Status: Needs work » Closed (fixed)

Yes, new issue.