I'm having trouble trying to add and argument to the activity_comments module. I'd like to be able to add a comment author argument so that activity items (ie, other peoples activity) that you have commented on will appear in your feed also. I've tried adding the below code to activity_comments.views.inc but nothing appears in the view admin panel.
$data['activity_comments_user']['table']['join'] = array(
'activity' => array(
'left_field' => 'aid',
'field' => 'aid',
),
);
$data['activity_comments_user']['uid'] = array(
'title' => t('User'),
'help' => t("The user which commented."),
'relationship' => array(
'base' => 'users',
'field' => 'uid',
'handler' => 'views_handler_relationship',
'label' => t('The user which has commented.'),
),
'argument' => array(
'handler' => 'views_handler_argument_user_uid',
)
);
Could someone point out what is wrong with this please?
Thanks
Comments
Comment #1
Scott Reynolds commentedYour approach won't ever work, but I think this is something we need to look into implementing. I think, my approach would be the following
That will give us the Activity Access filter. So give this a try
1.) add that code to the activity_comments.module
2.) Rebuild access records by visiting: /admin/settings/activity and clicking the Rebuild Access Table button
3.) Profit?
Comment #2
oxford-dev commentedI'm not using Activity Access in my view though.
I have it set up so that it uses 2 arguments (OR'd using views_or module); user id and user_relationships(requestee user).
I have it set up so that when i view my profile it shows mine and my friends activity but when i view a friends profile, it shows just theirs. My intention was to add another OR'd argument comment uid to also list activity that I had commented on.
Comment #3
oxford-dev commentedTurns out the problem wasn't that the activity wasn't appearing in your feed when you comment on it, it will have been there but could have 'dropped off the bottom' so you did not see it and you expect to see it appear at the top of the feed as its a new activity.
My solution to this is to order feeds by 'created' field and then update this value to the current time when ever a comment is added to it. A bit of a hack as it is a 'created' field and not an 'updated' field.
To achieve this I had to hack activity_comments.module and add
db_query("UPDATE {activity} SET created = %d WHERE aid = %d", time(), $form['aid']['#value']);
at line 210.
I have 2 questions now, how can I hook into this from a custom module so I can take that line out of activity module.
I tried creating function MY_MODULE_activity_comments_form_submit($form, &$form_state) {
but it never fires.
I also though hook_submit was no longer used for D6?
Comment #4
Scott Reynolds commentedComment #5
pribeh commentedHey Oxford-dev, how did you get your hack to work? I've tried using your hack by entering
db_query("UPDATE {activity} SET created = %d WHERE aid = %d", time(), $form['aid']['#value']);into activity_comments.module at like 210 but to no avail. The creation date of the activity does not appear to be changing. Am I correct in assuming that your line of code is supposed to change the creation date of the activity?
[update] Nevermind, it's working now. Must have been some sort of cache effect.
Comment #6
Scott Reynolds commentedInstead of hacking the activity module, you should use the code i posted above.
Comment #7
pribeh commentedTotally. I've gone with using your code instead (as below).
Now the odd thing is though that it only seemed to work once. So only on one single comment did an activity's creation date change. For the rest it doesn't seem to be snagging.
Comment #8
pribeh commentedHey Oxford-dev, did you get this working with the alpha version?
Comment #9
pribeh commentedI figured out something. It looks like either oxford-dev's hack or Scott's module only work for comments of node-related activities. So if I comment on a node's activity then the activity creation date changes but if I comment on, say, a (FBSS) status' activity then the creation date remains unchanged.
Looking at the code this should work for any activity item. Scott, do you have any idea if there's something specific here about FBSS' integration with Activity that might be an obstacle here?
Comment #10
pribeh commentedNevermind my bantering, it seems to be working perfectly now. I can't tell you what the intermittent issues were but they did exist ;)
Comment #11
pribeh commentedOk, so here's hopefully my last request here. So for me I've finally realized that this code works on the first activity comment posted. So for every first activity comment submitted the creation date of the activity is altered to reflect the time the comment was submitted. Is this the expected behaviour according of this code snippet? And if so, is there any way to allow any activity comment to change the creation date of the corresponding activity?
Comment #12
oxford-dev commentedi havnt tested whether it works for subsequent comments yet, should really.
I'm not using alpha, im still using a dev version from around march i think. All releases since then havn't worked for me including the lastest alpha, as as the saying goes, if its not broken, don't fix it.
I should really make an effort to get newer versions working really.
Comment #13
pribeh commented@oxford-dev, I could really use another function as well:
I'd like to change the Activity creation date when a user flags the activity as well (using the activity flag module you helped complete http://drupal.org/node/791524).
Let me know if you have any time to work on something like this oxford-dev. I would be willing to pitch in.
Comment #14
oxford-dev commentedOk, now that you mention is that would be useful to me too.
When I get a bit of time I will look into it. It may be simple to set up a rule for this.
Comment #15
_shyD6 reached its EOL back in February 2016, and there is no active release for D6 for this module anymore.
Development or support is not planned for D6. All D6-related issues are marked as outdated in a bunch.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.
Thanks!