Is there anyone who has a organic groups group activity view for version 7 and can share this with us?

A view which shows the recent activity in the group (group content creations and their commentations) and allows for heartbeat comments.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Stalski’s picture

Hey,
Well that's next on the TODO list for heartbeat development.

I was planning on having (as in drupal6) an integration module that comes with OG streams:
- A stream for all groups (only activity within group context)
- A stream within a group (group itself or the posts)
- Memberactivity within a group (all members of the group or group post parent group)

The goal here will be the have a ready-to-go submodule, even more integrated than drupal6.

Any idea's are welcome.

However, it should already be possible to create activity streams by using views. Arguments and/or filters will be your friends.

Stalski’s picture

Status: Active » Needs work
Stalski’s picture

Due to a performance issue on the D6 version, this will be postponed untill that problem is cleared out. It will be probably be ported immediately.
The change is to add a field to the heartbeat table indicating if a record is related to a group or not. The extra join on og_ancestry can be avoided resulting in a huge performance boost when fetching activity within a group.

Stalski’s picture

Status: Needs work » Needs review

Basic og integration is added. This can be found by enabling the "og" heartbeat plugin.
As in drupal6, a couple of streams were added:

  • Groups activity: all activity related to groups
  • Group activity: Organic group context found a group, all activity is shown related to this group
  • Members activity: Organic group context found a group, all activity is shown from the members of that group (not necessarily within that group)

You can enable those three streams and from that point, they are available on the stream admin page to configure them, provide blocks, pages whatever.

Also included some minor bug fixes.

You still need to create message templates and create rules for it yourself (or log via code).
The added streams are fine as they are I think.

Further roadmap:
- Make sure the views query alter works as well.
- Check if there are some other checks that need to be done related to group access.

goekhanc’s picture

I activated the og plugin and blocks were added. but when I open the group page, no activity is shown, although I created group content nodes.

You still need to create message templates and create rules for it yourself (or log via code).
The added streams are fine as they are I think.

Do I have to do this before the anything is working?

Stalski’s picture

Yes. So the plugin will provide organic streams, but you still need to indicate which messages have a group.
example1: !username posted !title in !group [where nid=grouppost and nid_target=group]
example2: !username joined !group [where nid=group]

Automatically a in_group variable will be logged as well in the heartbeat_activity table and the streams should work from there. If they are not, file a new issue for that as I think there will come more. That way I can get overview of smaller parts.

goekhanc’s picture

I really would appreciate a more detailed description of the steps. I am not familiar with the Rules module. I hope anyone has time for this.

Thanks in advance.

goekhanc’s picture

Before I create a rule for logging any activity, I just created a group and added a group content. Then I checked the heartbeat_activity table in the database. The creation of those two nodes are logged, but the in_group value is set to 0 in both cases. This shouldnt be the case, right?

Stalski’s picture

indeed, that shouldn't be the case. the ingroup parameter should be logged as 1.
You can look if you want, I'll check this later but currently don't have the time

goekhanc’s picture

I looked at it, but couldn't find a solution.

chaps2’s picture

It looks like the insert in HeartbeatActivity->_save() is missing the in_group column. Perhaps it should test for the existence of a !group variable and set the flag accordingly.

BTW this statement if ($key[0] != "@" || $key[0] != "!") { in HeartbeatActivity->rebuild_arguments() will always evaluate to FALSE.

Stalski’s picture

Status: Needs review » Needs work

@gokhanc: there is a lot of documentation on the rules module at drupal.org documentation (you can find them on the project page of rules). Heartbeat does nothing extra fancy or hackisch things, so you should be able to work with them. Besides there are built-in rules as well to check out.

@chaps2: thx for the report. I'll check it asap.

I see no patch here, so "needs work"

chaps2’s picture

I meant HeartbeatActivity->log_message() not _save().

goekhanc’s picture

I made a change in the log_message() function in heartbeatactivity.inc.


481 $in_group = 0;
482 if ($og_context = og_context()) {
483
484 $in_group = $og_context->etid;
485 }

486
487 $last_id = db_insert('heartbeat_activity')
488 ->fields(array('message_id', 'nid', 'uid', 'nid_target', 'uid_target', 'cid', 'access', 'timestamp', 'language', 'in_group', 'variables'))
489 ->values(array(
490 'message_id' => $this->message_id,
491 'nid' => $this->nid,
492 'uid' => $this->uid,
493 'nid_target' => $in_group,
494 'uid_target' => $this->uid_target,
495 'cid' => $this->cid,
496 'access' => $this->access,
497 'timestamp' => $this->timestamp,
498 'language' => $lang,
499 'in_group' => $in_group,
500 'variables' => heartbeat_encode_message_variables($this->variables)))->execute();

This is just a hint for the developers. I hope there will be a better solution soon.

Stalski’s picture

So you are suggesting the in_group variable IS the group nid, while my first thought was to just have it as a boolean. So I think it could help to trigger the in_group , so we always can match the nid or nid_target to this variable to see which one is the group (if we need that).
Thx for the feedback.

mototribe’s picture

subscribe

Sylense’s picture

sub

muschpusch’s picture

Hey! I don't know why but hook_update_N() isn't called. Which results in an unknown column error! I will do some more testing of the functionality because i need to use this on a site! Thanks a lot for the good start!

meanwhile solution: download devel and execute php directly:


if (!db_field_exists('heartbeat_activity', 'in_group')) {
      db_add_field('heartbeat_activity', 'in_group', array(
        'type' => 'int',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Indicates whether the activity is related to a group.'),
        'default' => 0,
      ));
    }
    db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid IN (SELECT DISTINCT etid FROM {og})");
    db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid_target IN (SELECT DISTINCT etid FROM {og})");

   db_add_index('heartbeat_activity', 'group_language_timestamp', array('in_group', 'language', 'timestamp'));

muschpusch’s picture

Ok this is giving me really a hard time :/ I created a custom message template at admin/structure/heartbeat/templates

I copied all settings from the heartbeat_add_node template and adjusted only the single message to:

!username posted !title in !group [where nid=grouppost and nid_target=group]

I adjusted heartbeatactivity.inc like chaps2 said but kept it as an boolean value (sorry the patch is huge because I also deleted the windows line breaks).

Now i created a rule:

Event: After saving new content
Condition: Content is published & entity is group content
Action: Log activity for og_posted (new stream template)

In the log activity action: I can access the data selector node:group:gid but it's always empty :( . The good part when using a hardcoded value the stream block appears on my group page! Any idea what i'm doing wrong?

olevelo’s picture

Has anyone had any luck with this? I was trying to get this working with the non-dev version as well by setting node target to node:group:gid, but it never gets set. Same thing with the dev version, and now in_group also doesn't work. So basically none of this functionality works! Thanks for any assistance...

muschpusch’s picture

Status: Needs work » Needs review

@Olevolo: you have to download the development version of heartbeat and apply the patch from this queue, There are indeed problems with token support of og [#1088538#comment-5150882].

@Stalski: settings this to needs review as this works and the last problem is og token support

olevelo’s picture

I must be missing something then, because I've installed dev and the patch and it makes no difference. in_group is never set no matter the type of content. Rules doesn't seem to recognize [node:group:gid] for the node target.

muschpusch’s picture

Sorry this is kind of off topic:

@olevo: That's correct! OG has no proper token support. It should deliver tokens with entity token but it doesn't work. Have a look at the following issues:

#1320916: token support for organic groups
#1088538: OG (Organic Groups) tokens missing.

If I have the time tomorrow i will post a a small module delivering the gid token if not you can use the workaround described in one the issues. If you have a budget (i would participate) we could ask fago to have a look at the entity token problem regarding OG.

olevelo’s picture

Thanks. I read through each of those posts, but I didn't really see any "workaround" that could be used to get any further than I have. But I'm pretty new to OG and Rules and Tokens so I could very well be overlooking something. I look forward to some resolution to get one of the last pieces of my site working properly!

muschpusch’s picture

Title: Group Activity View » Heartbeat and OG 7.x integration

Changing the title since this isn't only views related.... Could someone else could test this patch that we can change the status to 'reviewed and tested by the community'?

Stalski’s picture

So the real issue here is that node:group:gid, node:group:title and so on is not recognized. Munchpush indicated the missing tokens support is not the issue, but it is. We need the gid.
For this we follow the issues provided by muschpush:

For the rest everything should work as forseen. Ofcourse leaving us with a very important lacking part: The group nid we need as target. This is the way activity later on can be recognized within a context.

As a side issue: the in_group will be refactored so it's 0 or a numeric value of an existing group. Some extra logic (when groups are deleted, posts moved from group to group ... things to think about) will need to be written.

- Edit: the patch is not very usefull with the total removal and adding again. I don't work on windows so I don't saw a difference in the type in your patch.

Stalski’s picture

Status: Needs review » Closed (won't fix)

Hey all,

It seems for now there is not enough token support, but I seem to have enough most of the time with the group:etid property.

I just finished a project with heartbeat in it and I logged by using the Heartbeat API as that is very easy as well and allows to create more advanced messages.

I will provide documentation for this later. That said, this bug stays valid but I'd like to close it as providing the tokens should not be the responsibility of heartbeat. Og could do it or a module like token provides tokens for the entity HeartbeatActivity.

ruess’s picture

Hey Stalski,

Do you have any updates regarding documentation for this integration with Heartbeat API? Or has anyone else succeeded in this and could share a short tutorial?

Thanks so much!

ruess

muschpusch’s picture

Hey Ruess, you could try the 2.x branch of OG but there won't be an alpha until march otherwise you should use the heartbeat API to save the heartbeat activity because the 1.x branch of OG doesn't support tokens / rules.

Stalski’s picture

That is correct I am afraid

Stalski’s picture

Issue summary: View changes

added organic groups