Comments

Scott Reynolds’s picture

First working pass. We are probably going to need to add another hook

/**
 * Implementation of hook_activity_access_info().
 * return an array, keyed by realm that has a friendly title
 */
function hook_activity_access_info() {
   return array(
     'friend' => array(
       'title' => t('Friend'),
     ),
  );
}

This then allows the Views filters to ask which realm in particular they care about or all realms that the module provides. Or maybe we just create the filters based on the realms returned from this. Remove the notion of module completely. I like the later approach best.

Scott Reynolds’s picture

StatusFileSize
new2.95 KB

forgot patch

sirkitree’s picture

Status: Active » Needs work

You may want to roll this from the module's root directory before submitting to them. Otherwise the new file appears in the wrong directory.

One thing I'm concerned about is basically requiring the other module to implement hook_init() and check for the Activity module in order to conditionally include the module.activity.inc file. Is there a better way to handle this? Maybe as a 'path' parameter in hook_activity_info() such as views does, and then we include the file through activity.module?

Also, once I go to add the user_relationships_api Activity Access filter, shouldn't I see a list of defined relationships in order to choose which relationship I'm filtering by? I'm just seeing:
Only local images are allowed.

Scott Reynolds’s picture

Thats not implemented yet but thats the plan. And then you can actually expose this as well, which is kindof cool.

The idea of removing the hook_init() i like as well. its a good extension.

Scott Reynolds’s picture

With this commit we achieve this
http://drupal.org/cvs?commit=205766

Scott Reynolds’s picture

StatusFileSize
new3.13 KB

And heres the patch to UR

Scott Reynolds’s picture

Status: Needs work » Needs review
sirkitree’s picture

Status: Needs review » Postponed

I guess the only other thing to add is the file scanning to activity to look for activity.inc files and then we can submit this to UR
#446482: Inclusion of $module.activity.inc files

sirkitree’s picture

Issue tags: +activity2-integration

tagging so we can point ppl to issues and patch on how to integrate.

Scott Reynolds’s picture

Status: Postponed » Needs work

we still need to fix the trigger implementation and the hook_activity_info().

likewhoa’s picture

subscribing.

andypost’s picture

So what is a status of issue?
All patches are landed. Is this still an issue?

Scott Reynolds’s picture

This patch works. It doesn't allow though "User A became friends with User B". Just need to wrap the trigger stuff.

Flag_friend module is fully integrated.

ajayg’s picture

jUSt checking if there is any progress on this? IS there anything needed from UR side?

jthomasbailey’s picture

subscribing

ajayg’s picture

@Scott Reynolds
is there any help you need to get this finished? Could you please describe what is still remaining to get this moving?

Scott Reynolds’s picture

See comment 13.

Again the patch works. Just missing trigger implementation for UR.

You can very easily create a View of all your Friend's activity

mariano.barcia’s picture

@Scott could you point us to the trigger code and/or what needs to be done/updated there?
I'm needing the "User A became friends with User B" feature, as per your comment in #13. Thanks!

Scott Reynolds’s picture

The first step would be implementing Triggers in UR

http://drupal.org/node/375833

mariano.barcia’s picture

I got it running for the "approve" operation of user_relationships_api. I can't get it to work properly with the tokens. Shall I post a patch or copy the source code here? It's not that much code.

ajayg’s picture

Please post it anyway so if someone has time they can build on it.

mariano.barcia’s picture

Ok, I got it running for the "approve" operation of user_relationships_api. However, I can't get it to work properly with the tokens.

Copy
ur.module.patch
ur.actions.patch
user_relationships_api.activity.inc_.txt
to user_relationships/user_relationships_api folder under your modules base folder. This file has the earlier patch in #6 already applied.

Apply the patches by running
patch -p0 < ur.module.patch
patch -p0 < ur.actions.patch

Rename user_relationships_api.activity.inc_.txt to user_relationships_api.activity.inc

Then create an activity at admin/settings/activity/create, choose "User relationships api" as the type. I have it configured as in the sshot attached.

Then request and approve a relationship, and see the activity is recorded (as in the last sshot attached).

Know issues:
- As you can see, the requester ("admin") is repeated, instead of displaying the requestee in the last place. Also, I cannot see the activity record when logged in as the requester.
- Haven't tested with more than one relationship type

I will be looking forward to your comments, thanks.

Scott Reynolds’s picture

Title: UR implementation for 2.x branch » Integrate with Activity2 Branch
Project: Activity » User Relationships
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Activity Contrib » Code
Assigned: Scott Reynolds » Unassigned

debug code in patch
+ dd($type, 'type in token values');
+ dd($r, 'data in token values');

Moving to User Relationships module.

mariano.barcia’s picture

Ok, today I got it running for the "approve" and "request" operations of user_relationships_api and fixed the token issues. Also removed the debug messages.

Copy
ur.module.2.patch
to user_relationships/user_relationships_api folder under your modules base folder.

reverse the ur.module.patch patch applied above, then,
apply the new patch by running
patch -p0 < ur.module.2.patch

You are now ready to create 2 activities at admin/settings/activity/create, choose "User relationships api" as the type, one for "approve" another for "request".

Then request and approve a relationship, and see both activity records being displayed (sshots attached). If you don't have a view, take a look at the activity* tables in the DB, as shown below.

mysql> select * from activity where op='approve' or op='request';

+-----+-----+---------+------------------------+------+------------+
| aid | uid | op      | type                   | nid  | created    |
+-----+-----+---------+------------------------+------+------------+
| 438 |  50 | approve | user_relationships_api | NULL | 1253801590 |
| 437 |   1 | request | user_relationships_api | NULL | 1253801436 |
+-----+-----+---------+------------------------+------+------------+
2 rows in set (0.02 sec)
mysql> select * from activity_messages am join activity_targets at on at.amid=am.amid where at.aid=437 or at.aid=438;
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----+-----+------+
| amid | message                                                                                                                                                   | aid | uid | amid |
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----+-----+------+
|  842 | <a href="/profile/admin" title="View user profile.">admin</a> requested connection to <a href="/profile/twiti" title="View user profile.">Twiti Jones</a> | 437 |   0 |  842 |
|  843 | <a href="/profile/admin" title="View user profile.">admin</a> and <a href="/profile/twiti" title="View user profile.">Twiti Jones</a> are now connected   | 438 |   0 |  843 |
+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+-----+-----+------+
2 rows in set (0.00 sec)

Know issues:
- Haven't tested with more than one relationship type
- cannot display the approve activity in the requester stream, as the activity has an owner but not a "related" user or something that could act as argument as well.
- Done for two-way relationships, with request/approve workflow.

I will be looking forward to your comments, thanks.

andypost’s picture

+    $info->objects = array('Requester' => 'requester', 'Requestee' => 'requestee
+', 'Relationship' => 'relationship');

Code format is wrong

+    $token_values = array(
+      'requestee' => theme('username', user_load(array('uid' => $r->requestee_id))),
+      'relationship-name' => theme('placeholder', $r->name),
+    );
+    // dd($token_values, 'token values return (relationship');

dd still here

mariano.barcia’s picture

ok thanks, those are details, I'd like to receive more "interesting" feedback about the feature.

I am using it now in a project, and I'll keep the thread updated. Thanks in advance.

dafeder’s picture

Coming late to this conversation, but very interested.

Mariano, I'm applying all your patches and will report on my results.

dafeder’s picture

I have applied your two patches and am not seeing "User relationships api" in my list of type I can add. Any idea what I'm doing wrong?

mariano.barcia’s picture

Daniel,

Thanks.
If you applied the ur.module.2.patch, you should be seeing this code inside user_relationships_api.module:

function user_relationships_api_activity_info() {
    $info = new stdClass();
    $info->api = 2;
    $info->name = 'user_relationships_api';
    $info->object_type = 'user_relationships_api';
    $info->objects = array('Requester' => 'requester', 'Requestee' => 'requestee
', 'Relationship' => 'relationship');
    $info->hooks = array('user_relationships_api' => array('approve', 'request'));
    return $info;
}

AFAIK, Activity scans all modules in search for that hook (activity_info) and finds it in the user_relationships_api.module and displays the new option in the activity template form. I remember having issues when discovering how Activity knew about the plugins, but all it needed was that hook in the .module file.

Not sure if this helps you, at least it confirms the hook implementation is everything. If, for some reason, Activity can't find the .module then it will not display anything different... Let me know if you can solve this or if you are still blocked. Thanks.
--m

marc.groth’s picture

Hi Mariano Barcia,

The patch didn't quite work for me (kept getting an error when trying to apply the patch using TortoiseSVN)... However, when I manually applied the changes it worked very well!! Congrats on the work so far :)

Any ideas on how we can get this information to display in the activity stream (i.e. at /activity/all)?

I checked the view and I'm assuming a Relationship is needed for User Relationships under "Relationships" (/admin/build/views/edit/all_activity)? I'm not entirely sure, but seems correct since the ones that are currently displaying (Node, User) have relationships setup. Any ideas on this? Are you currently working on this at all?

Any help is greatly appreciated.

Turns out creating a brand new view with the field "Activity: Message" (and no Filters - I think this is the key?) seems to bring back all the Activity... Now I just need to figure out why the Tokens in your patch don't seem to be available when creating the activity... Any ideas?

Many thanks once again,

Marc

dafeder’s picture

OK, I hadn't applied the patch correctly, and hadn't noticed. I'm a little confused about what version the patch is for, as my files look a little different from the lines in the patch. Anyway, applied module.2 "manually" and the options do show up in Activity. Do I still need to apply the actions patch as well? Confused because user_relationships_api_action_info() is commented out in my version (latest release).

vermario’s picture

ehm... subscribing

mariano.barcia’s picture

@Daniel,
You have to apply both patches (do #22 and then #24). the actions patch is needed.
BTW, to reverse a patch invoke the same as if you were to apply it. Then, the patch command is smart enough to detect that the patch had been applied before and asks for the confirmation of the rollback.

@Marc,
Thanks!
I have the activity configured like this
"[requestee] and [requester] are now connected" and it's working well so far. What's exactly the problem?

dafeder’s picture

All right, the actions patch did not work, but I added it manually, probably an issue of new dev releases since the patch was posted?

Anyway, I now have the ability to add a UR but the only tokens I am shown for to use in my messages are global tokens, which aren't too useful. I did some very quick debugging and it seems like user_relationships_api_token_list() isn't being called at all.

vermario’s picture

Hi!

same problem here, after applying patches manually, the token area shows just global ones.

Might this be related to the fact i am using the 5th october dev version of activity? It has some major changes in translation handling...

EDIT: no, the patch did not work correctly and I applied it manually but not completely.

marc.groth’s picture

StatusFileSize
new207.46 KB

Hi Mariano,

I tried putting in "[requestee] and [requester] are now connected" in the "configure" page for "User relationships api"... Which, when the activity is recorded, seems to do what it should (i.e. brings back the correct data). My only issue is that I don't seem to actually see those particular tokens available under "Available tokens"... Does it show up for you? I've supplied a screenshot of what I see when I click "Available tokens" >> "Global"

I've checked and the code is there, or so it seems...

/**
 * Implementation of hook_token_list().
 */
function user_relationships_api_token_list($type = 'all') {
  if ($type == 'user_relationships_api') {
    $tokens['user_relationships_api'] = array(
      'requester' => t('The user who issued the connection request.'),
      'requestee' => t('The user who approved the connnection request.'),
      'relationship-name' => t('The relationship name (singular form)'),
    );
    return $tokens;
  }
}

Any ideas?

Thanks again, it works perfectly otherwise!! :)

marc.groth’s picture

Hmm anyone else having issues with the template not being saved when you hit "Save"? The field "Requestee message:" always comes up blank, even though the others get saved as they should. Any ideas on this?

Where abouts in the code does this field get saved/retrieved?

EDIT: Never mind, I didn't patch the module quite correctly... In case anyone else gets this issue... Turns out it was because of a space after "requestee" in

$info->objects = array('Requester' => 'requester', 'Requestee' => 'requestee', 'Relationship' => 'relationship');

Which was copied over as:

$info->objects = array('Requester' => 'requester', 'Requestee' => 'requestee ', 'Relationship' => 'relationship');

ajayg’s picture

Since we have so many comments and moving parts, could someone please submit patch against latest dev UR and Activity 2 branch? So we can start with a common baseline and go from there to improve further.

dafeder’s picture

I think token list problem has something to do with the conditional ($type == 'user_relationships_api')

function user_relationships_api_token_list($type = 'all') {
  if ($type == 'user_relationships_api') {
    $tokens['user_relationships_api'] = array(
      'requester' => t('The user who issued the connection request.'),
      'requestee' => t('The user who approved the connnection request.'),
      'relationship-name' => t('The relationship name (singular form)'),
    );
    print_r($tokens);
    return $tokens;
  }
}

Debugging shows the $type being recieved is "requester".

And yes, I think this would be an appropriate time for a commit to the dev version. Won't break anything else and will make this all much easier :) .

drupallogic’s picture

may I kindly ask UR RC3 will have support for activity module?

wkmit’s picture

Marc,

Figured out that removing "Relationships Activity: Node" from the view makes the user relationship activities show up.
This makes sense as activity table rows, involving user relationship activities, have a nid of 'null'.

If you want to filter the view further, say you want to display only approved user relationship activities, just add 'Activity: Operation = approve used in: user_relationships_api' in the view.

Scott Reynolds’s picture

Figured out that removing "Relationships Activity: Node" from the view makes the user relationship activities show up.
This makes sense as activity table rows, involving user relationship activities, have a nid of 'null'.

You could have set this to not required and it would have worked as well. It will LEFT JOIN, allowing NULL values.

tayzlor’s picture

StatusFileSize
new1.04 KB

For the tokens to appear in the token list the hook_token_list() implementation needs to be -


/**
 * Implementation of hook_token_list().
 */
function user_relationships_api_token_list($type = 'all') {
  if ($type == 'requester') {
    $tokens['user_relationships_api'] = array(
      'requester' => t('The user who issued the connection request.'),
    );
  }else if ($type = 'relationship'){
	$tokens['user_relationships_api'] = array(      
	  'requestee' => t('The user who approved the connnection request.'),
      'relationship-name' => t('The relationship name (singular form)'),
    );
  }
  return $tokens;
}

Attaching patch for only the hook_token_list() but it may be easier to just copy / paste the above into your patch.

tayzlor’s picture

code in #43 takes care of token_list().
I discovered hook_token_values() was not working in all cases.
The below code should work across the board -

/**
 * Implementation of hook_token_values().
 */
function user_relationships_api_token_values($type, $data = NULL, $options = array()) {
  if ($type == 'requester') {
    $r = $data;
    $token_values = array(
      'requester' => theme('username', user_load(array('uid' => $r))),
    );
  }elseif ($type == 'requestee'){
  	$r = $data;
  	$token_values = array(
      'requestee' => theme('username', user_load(array('uid' => $r))),
    );
  }
  elseif ($type == 'relationship') {
    $r = $data;
    $r_type = user_relationships_type_load($r->rtid);
    
    $token_values = array(
      'requestee' => theme('username', user_load(array('uid' => $r->requestee_id))),
      'requester' => theme('username', user_load(array('uid' => $r->requester_id))),
      'relationship-name' => theme('placeholder', $r_type->name),
    );
  }
  
  return $token_values;
}

tayzlor’s picture

also, when i install the patches in #22 and #24 , i dont see any User Relationships Access filters in the View Filters area to choose from??

Scott Reynolds’s picture

You need to turn on the Access filters via admin/settings/activity

This is because we don't record it unless we need to, saves DB space.

tayzlor’s picture

StatusFileSize
new4.65 KB

re-rolled patch to fix token bugs + bug with the filter not showing up in views.

tayzlor’s picture

Status: Needs work » Needs review
tayzlor’s picture

StatusFileSize
new4.62 KB

forgot to remove line of debug in #47, re-uploading new patch.

alex.k’s picture

Would you like to see this patch in a RC? Should be rolling it in the next couple of days.

Also, it would be nice to see this as a conditional include file, so that it stays outside if activity is not enabled.

Scott Reynolds’s picture

Activity provides the mechism for conditional includes

// This will tell activity to include user_relationships_api/includes/user_relationships_api.activity.inc
// only when it needs it
$info->path = drupal_get_path('module', 'user_relationships_api') .'/includes';

And to create a patch with a new file:
http://drupal.org/patch/create where there is some good info on how to add a new file in a cvs patch with a link to a fakeadd.sh script that works wonderfully.

dafeder’s picture

Committed in an RC would be great, even if still buggy...

tayzlor’s picture

is this RTBC or what do we need? do we need a roll-up of all the patches into one single patch file?

alex.k’s picture

Status: Needs review » Active

Committed the various patches in http://drupal.org/cvs?commit=285542. I used user_relationships_api.module patch from #49, user_relationships_api.actions.inc and user_relationships_api.activity.inc from #22. After that there were two implementations of user_relationships_api_activity_grants() and user_relationships_api_activity_access_grants() - in .module and in .activity.inc. I removed the ones in .module. Please check that things fell into the right places as I may have missed something. Thanks!

mariano.barcia’s picture

@alex.k
Just did a quick double-check of the process you followed, and it looks fine ==> the files should be ready to be checked out and tested/reviewed. Thanks. I'll give it a try this week.

adam_c’s picture

I appologise for my noobness but this patch is exactly what I need but tortoise SVN is really not happy about applying it for some reason and so I need to manually create this patch with what is available on this page.

I gather that a directory needs to be created /activity/user_relationships/user_relationships_api

and within that 2 files are needed: user_relationships_api.module and user_relationships_api.actions.inc

I thought that the patch in #49 would have all the functionality required for this integration, although it seems to be missing some functions from earlier patches and seems to put them all into user_relationships_api.module whereas I believe some belong in user_relationships_api.actions.inc, am i correct so far?

So my current position is that I have the direcories as above and I have user_relationships_api.module with all the functions in patch #49 in it. Perhaps not surprisingly when i go to admin/settings/activity I do not see any reference to user relationships.

Can someone please advise as to where I am going wrong?

Thanks

adam_c’s picture

Iv just realised i've been an idiot trying to update activity when I should have been updating UR.

zuzu83’s picture

StatusFileSize
new64.4 KB

Hi,

I have a probleme with integration "Views". I want my friends activity in my profil "Panels".
Error with views "warning: Invalid argument supplied for foreach() in mysite/public_html/sites/all/modules/activity/views/activity_views_handler_filter_access.inc on line 64"

I would like to see the activities of my friends and myself in the same view. Is it possible?

Thx for your help !

Version activity2 6.x-2.x-dev (2009-nov.-06)
Version User Relationships 6.x-1.x-dev (2009-nov.-09)

zuzu83’s picture

StatusFileSize
new64.4 KB

sorry, my Panel version 6.x-3.2

Scott Reynolds’s picture

please create an issue in Activity. not here. and don't post a screen shot, post the exported view.

Scott Reynolds’s picture

ooh i take that back. that error means that it failed to include UR's .activity.inc

nitram079’s picture

Category: feature » bug

Scott,

I have the same problem: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/lbproduction/sites/all/modules/activity/views/activity_views_handler_filter_access.inc on line 64.

is there any hope to get that fixed?

Many thanks for the awesomenes!

alex.k’s picture

Category: bug » feature

Please leave as a feature request. The feature is not yet "ready".

ajayg’s picture

I have opened following issue against activity2 #636974: Default view does not show UR activity records since the UR activities are recorded in DB but somehow default all activity view is skipping it.

ajayg’s picture

I tried to poke around and found that atleast in activity_get_module_info (activity.module) it is getting the value
of $info->path as correct path to "user_relationships_api" module. But don't know how to debug further.

IS this correct module, it should be trying to include conditionally?

zuzu83’s picture

I dont understand ... UserRelationships and Activity2 does not show the activities of my friends. FlagFriends - 2.0 Flag and Activity2 does not show the activities of my friends ...
I may be zero! But all these modules are very big and important to create a community.
It's been a week that reported the bug to the support of all the modules.

Can you explain the solution please? Propose a view model to integrate with Panels!

I dont know, I want a solution ...

I know you have a lot of work and request, but this function is very important for the community.

Thank you for your help.

ajayg’s picture

I wanted to help debug this but don't know where I can go next. Already confirmed the path was correct atleast untill in activity_get_module_info (activity.module).

Any thoughts/hints/ideas?

ajayg’s picture

@tayzlor
Till your patch in #47, user_relationships_api_activity_access_grants had only one parameter, $account, but you have introduced three parameters $account, $object, $type; Why?

In activity_views_handler_filter_access_inc , activity_access_grants is being called without any parameter when it is expecting 3 $account, $object, $type and I think that is an issue.

tayzlor’s picture

i have this patch working on a version of my code here, allowing users to only see their 'friends' activities.
not sure whats gone wrong in between, will checkout the latest UR + activty and try and re-apply the patches.

ajayg’s picture

Hi tayzlor,
any updates on this? If you don't have time to figure out the difference, do you mind atleast posting your working code here so we can review that and try to see what is the difference.

tayzlor’s picture

StatusFileSize
new193.5 KB

@ajayg,
yep no problem, sorry i thought i was going to have time to come back to this but havent as yet.
uploaded patched UR + activity modules (these *should* work with views hopefully).

youkho’s picture

Subscribing

Bilmar’s picture

subcribing

Bilmar’s picture

subcribing

Scott Reynolds’s picture

Looks like this is causing the problem: #652906: Activity fails to include the file when path isn't set.

ajayg’s picture

@Scott Reynolds
Some progress.
tried #652906: Activity fails to include the file when path isn't set with latest activity 2. We no longer see " Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/lbproduction/sites/all/modules/activity/views/activity_views_handler_filter_access.inc on line 64."

However
1. the view mentioned in #631772: friends Activities with UR and views still does not work. Meaning showing activity of all users and not necessarily activity of only those having relationship with you. Basically it showing activity of everything to everybody.

2. User relationship content view that comes with UR RC3 still does not show your friends activity

rburgundy’s picture

+1 subscribing - this will be a great feature!

I'm currently able to create the below activities at http://example.com/admin/build/activity
Record an activity message when: user_relationships_api approve types All
Record an activity message when: user_relationships_api request types All

But would also appreciate if we could have 'disapproved' 'canceled' and 'expired' activities to be picked up as well.
Thanks for the great work

sagar ramgade’s picture

Hi,
I downloaded your file in comment #71 and found it that there is a extra module called ur_blocks, which gives blocks like mutual friends, people you might know, however when go to site configurations, i click on ur block settings, it kicks me to the main site configuration page.
Could please check whats wrong
Regards
Sagar

robby.smith’s picture

subscribing

ajayg’s picture

I tried to tackle this but could not. I must admit I couldn't spend enough time on this. So if someone wants to tackle this please go ahead.

BenK’s picture

Subscribing...

oxford-dev’s picture

So as it stands is there still no method of creating a view which displays the activity of a users friends (UR)?

I have the very latest, Activity 2 dev, UR and views and still cant manage it.

seehawk’s picture

Subscribing

oxford-dev’s picture

I have managed to create a view which appears to give all activity of a users friends.

The key is to have the 2 'user relationship' relationships (requestee user and requester user) related to user.

And then a single argument 'User relationship: requester user' and set 'requestee' as the relationship type.

Hope this helps

ajayg’s picture

DO you mind exporting your view and publishing it here for the benefit of others. Quite a few of us have tried and have been unsucessful so far (before your post arrived)

oxford-dev’s picture

sure,

$view = new view;
$view->name = 'activity_cutdown';
$view->description = 'All activity on a site.';
$view->tag = 'activity';
$view->view_php = '';
$view->base_table = 'activity';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'uid' => array(
'label' => 'User',
'required' => 0,
'id' => 'uid',
'table' => 'activity',
'field' => 'uid',
'relationship' => 'none',
),
'nid' => array(
'label' => 'Node',
'required' => 0,
'id' => 'nid',
'table' => 'activity',
'field' => 'nid',
'relationship' => 'none',
),
'requestee_id' => array(
'label' => 'requestee',
'required' => 0,
'id' => 'requestee_id',
'table' => 'user_relationships',
'field' => 'requestee_id',
'relationship' => 'uid',
),
'requester_id' => array(
'label' => 'requester',
'required' => 0,
'id' => 'requester_id',
'table' => 'user_relationships',
'field' => 'requester_id',
'relationship' => 'uid',
),
));
$handler->override_option('fields', array(
'message' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'exclude' => 0,
'id' => 'message',
'table' => 'activity_messages',
'field' => 'message',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'aid' => array(
'order' => 'DESC',
'id' => 'aid',
'table' => 'activity',
'field' => 'aid',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'requester_id' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'current_user',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'requester_id',
'table' => 'user_relationships',
'field' => 'requester_id',
'relationship' => 'requestee_id',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'3' => 0,
'5' => 0,
'6' => 0,
'7' => 0,
),
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_image_size' => '_original',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'webform' => 0,
'faq' => 0,
'image' => 0,
'product' => 0,
'goldmembership' => 0,
'platinummembership' => 0,
'panel' => 0,
'naughty_event' => 0,
'naughty_room' => 0,
'nice_event' => 0,
'nice_room' => 0,
'nodegift' => 0,
'owned_image' => 0,
'owned_vid' => 0,
'page' => 0,
'photo_album' => 0,
'post' => 0,
'profile' => 0,
'video' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'6' => 0,
'8' => 0,
'9' => 0,
'10' => 0,
'7' => 0,
'4' => 0,
'3' => 0,
'1' => 0,
'5' => 0,
'2' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_node_flag_name' => '*relationship*',
'validate_argument_node_flag_test' => 'flaggable',
'validate_argument_node_flag_id_type' => 'id',
'validate_argument_user_flag_name' => '*relationship*',
'validate_argument_user_flag_test' => 'flaggable',
'validate_argument_user_flag_id_type' => 'id',
'image_size' => array(
'_original' => '_original',
'thumbnail' => 'thumbnail',
'preview' => 'preview',
),
'validate_argument_is_member' => 0,
'validate_argument_signup_status' => 'any',
'validate_argument_signup_node_access' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('access', array(
'type' => 'role',
'role' => array(
'2' => 2,
),
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Activity Wall');
$handler->override_option('css_class', 'activity');
$handler->override_option('header', '

global $user;

if(arg(1) == $user->uid)
{

}

');
$handler->override_option('header_format', '3');
$handler->override_option('header_empty', 1);
$handler->override_option('footer', 'keep up-to-date.');
$handler->override_option('footer_format', '1');
$handler->override_option('footer_empty', 0);
$handler->override_option('empty', 'There are no feeds to view or you do not have access to view them.

Only friends can see a users activity.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', '1');
$handler->override_option('distinct', 1);
$handler->override_option('style_options', array(
'grouping' => '',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'activitywall/%/User');
$handler->override_option('menu', array(
'type' => 'none',
'title' => 'User',
'description' => '',
'weight' => '1',
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'tab',
'title' => 'All stuff',
'description' => '',
'weight' => '0',
'name' => 'navigation',
));

mcpuddin’s picture

Thanks @Oxford,

Worked for me! However I didn't find the need to have the "requester user" in the relationship.

James

vibram fivefingersq’s picture

Real nice! Very useful. I will bookmark! http://www.five-fingers-vibram.org

onlinetips’s picture

Such a great blog post. Thank you very much for sharing this blog post...
First Aid Kits

ajayg’s picture

Status: Active » Needs work

The views above in #86 seems to be working accept that it is public. So you are user 1, you can goto page that belong to user 2 (Activitywall/2/User) and see all his and his friends activity. IMHO the activity should be private to each user.

Scott Reynolds’s picture

Status: Needs work » Needs review

Privacy can be handled in the View by using the proper access argument. And should be tackled in a separate issue.

Nodes are though are properly protected. If you do not have access to the node, the node activities will not be shown.

ajayg’s picture

I don't recall correctly, but didn't integration with activity 1 took care of access correctly? Meaning only user 1 can see his activities of his/her friends. Others didn't have access.

Now with Activity 2, the river of activity is taken care of by views. But How would you make sure so that page shows only to the user whose profile has this tab? Any suggestions? The views 2 doesn't allow that by default.

Scott Reynolds’s picture

A Views Access plugin is how to solve this.

So you setup the access plugin with an option to specify the user id position in the url (a url like /user/%/activity would take an option of 1 which maps to arg(1)) and then that is used in the access_plugin::get_access_callback() which is called by views.module to setup the hook_menu.

I don't recall correctly, but didn't integration with activity 1 took care of access correctly?

It might have but that would have been a bad decision. Activity does not make assumptions on how it will be used anymore. For instance, I have used it for an internal analytics.

ajayg’s picture

Scott
Do you mind giving more details for the plugin? From your comments it looks it should be fairly simple. But however See this comment from MerlinofChaos

It turns out to be very difficult to write access plugins that deny access based upon an argument.

http://www.angrydonuts.com/views-3-x-roadmap

I have seen several authors mentioning it should be easy but yet to see actual code which does this. So do you mind enlightling us?

ajayg’s picture

Also the activity template per UR type is missing. It used to be working 1.x. So in Activity 2.x there is a no way currently to have a different template per UR type. If you have just one UR type then you won't be affected.If you have more than one UR type your customization choice for activity messages is no longer available.

See #870850: Differentiate activity based on relationship type no longer works in 6.x-2.x

ajayg’s picture

Here is interesting finding about access to the above view
You can view your friends activity and not everyone's. So there is some access control.

However if you are friend with A and A is friend with B and if there is activity between A and B (and even if you are NOt related to B) you can still see that.

ajayg’s picture

I took oxford-dev 's view and made following changes

1. Made the view a tab shown on user profile.
2. Added validation for views argument so only the current logged in user can see his/her activity. You can't see other person's activity. So now privacy is covered.
3. Because the view was pasted here directly there is some code jumbling in header and footer. So I didn't get that working so I removed completely header and footer.

Please review, test and if it is working mark as RTBC.

$view = new view;
$view->name = 'My_UR_activity';
$view->description = 'All activity on a site.';
$view->tag = 'activity';
$view->view_php = '';
$view->base_table = 'activity';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'uid' => array(
    'label' => 'User',
    'required' => 0,
    'id' => 'uid',
    'table' => 'activity',
    'field' => 'uid',
    'relationship' => 'none',
  ),
  'nid' => array(
    'label' => 'Node',
    'required' => 0,
    'id' => 'nid',
    'table' => 'activity',
    'field' => 'nid',
    'relationship' => 'none',
  ),
  'requestee_id' => array(
    'label' => 'requestee',
    'required' => 0,
    'id' => 'requestee_id',
    'table' => 'user_relationships',
    'field' => 'requestee_id',
    'relationship' => 'uid',
  ),
  'requester_id' => array(
    'label' => 'requester',
    'required' => 0,
    'id' => 'requester_id',
    'table' => 'user_relationships',
    'field' => 'requester_id',
    'relationship' => 'uid',
  ),
));
$handler->override_option('fields', array(
  'created' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'date_format' => 'medium',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'created',
    'table' => 'activity',
    'field' => 'created',
    'relationship' => 'none',
  ),
  'message' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'message',
    'table' => 'activity_messages',
    'field' => 'message',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'aid' => array(
    'order' => 'DESC',
    'id' => 'aid',
    'table' => 'activity',
    'field' => 'aid',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'requester_id' => array(
    'default_action' => 'not found',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'current_user',
    'default_argument' => '',
    'validate_type' => 'php',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'requester_id',
    'table' => 'user_relationships',
    'field' => 'requester_id',
    'relationship' => 'requestee_id',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
    ),
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_image_size' => '_original',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'image_size' => array(
      '_original' => '_original',
      'thumbnail' => 'thumbnail',
      'preview' => 'preview',
    ),
    'validate_argument_is_member' => 0,
    'validate_argument_signup_status' => 'any',
    'validate_argument_signup_node_access' => 0,
    'validate_argument_php' => 'global $user;
if ((  $user->uid == $argument) ||($user->uid == 1)) { 
return true;
} else {
return false;
}
',
  ),
));
$handler->override_option('access', array(
  'type' => 'role',
  'role' => array(
    '2' => 2,
  ),
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'ActivityWall');
$handler->override_option('css_class', 'activity');
$handler->override_option('header_format', '1');
$handler->override_option('header_empty', 0);
$handler->override_option('footer_format', '1');
$handler->override_option('footer_empty', 0);
$handler->override_option('empty', 'There are no feeds to view or you do not have access to view them.

Only friends can see a users activity.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', '1');
$handler->override_option('distinct', 1);
$handler->override_option('style_options', array(
  'grouping' => '',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'created' => 'created',
    'message' => 'message',
  ),
  'separator' => ' ',
  'hide_empty' => 0,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'user/%/activitywall');
$handler->override_option('menu', array(
  'type' => 'tab',
  'title' => 'Activitywall',
  'description' => '',
  'weight' => '1',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'tab',
  'title' => 'All stuff',
  'description' => '',
  'weight' => '0',
  'name' => 'navigation',
));

ajayg’s picture

can anyone please review and test this? If you think it is working please mark as RTBC.

light9’s picture

#97 works for me! Thank you so much!

ajayg’s picture

Status: Needs review » Reviewed & tested by the community
mrf’s picture

Closed #631772: friends Activities with UR and views as a duplicate of this issue.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, user_relationships_api_activity.patch, failed testing.

mrf’s picture

Title: Integrate with Activity2 Branch » Default view for activity2
Component: Code » Views
Status: Needs work » Postponed
Issue tags: -activity2-integration

I am postponing any 6.x feature requests that don't have a current applicable patch to help sort the large list of open features.

Please feel free to set to 'needs review' once a patch is included.