When I set my stream to show the "Older messages" link and click on it the data is appended in some sort of JS notation. See example below. This doesn't happen with 6.x-4.10.

{ "status": true, "data": "\x3cdiv class=\"heartbeat-message-block heartbeat_shout odd\"\x3e\n\n \x3cdiv class=\"beat-item \" id=\"beat-item-282\"\x3e\n\n \x3cdiv class=\"icon-left-margin\"\x3e\x3cspan class=\"avatar\"\x3e\x3ca href=\"/b2learn_3_dev/users/administrador\"\x3e\x3cimg src=\"http://daniel-madruga-de-aquinos-computer.local/b2learn_3_dev/sites/default/files/imagecache/user_picture_meta/pictures/picture-1.png\" alt=\"administrador\" title=\"administrador\" class=\"imagecache imagecache-user_picture_meta\" width=\"30\" height=\"30\" /\x3e\x3c/a\x3e\x3cspan class=\'user-pic-space\'\x3e\x3c/span\x3e\x3cimg src=\"/b2learn_3_dev/profiles/drupal_commons/modules/b2learn/b2learn/heartbeat_implementation/images/heartbeat_shout.png\" alt=\"\" title=\"\" width=\"30\" height=\"30\" /\x3e\x3c/span\x3e\x3c/div\x3e\x3cdiv 

(...)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Stalski’s picture

Status: Active » Postponed (maintainer needs more info)

I thought this was fixed too. Are you sure you are working on the dev branch? There were some bugs in version 10 that are solved already. I was planning a release soon.
This kind of bug keeps me from releasing ofcourse, since it is a major issue.

Can you test it with the dev version? You mentioned 10 but you reported the issue under -dev. So which is it ;)

dmadruga’s picture

Title: Clicking on "Older messages" shows data in JS notation » Clicking on "Older messages" doesn't work for streams that depend on the OG context

Hey Stalsky,

thanks for you prompt reply.

I restarted from scratch, downloaded the newest version from cvs and cleared every possible cache I could remember. Things got a little better. Actually I got back to the same point I was when using ver 6.x-4.10.

But the "Older messages" link still doesn't work for the stream OgHeartbeat (that's why I changed the title of the bug). And I figured out what's going on: this stream depends on the group context. When the JS call polls for messages it uses no reference to the group. I made a test changing the
private function setGroup($nid = 0)
to
private function setGroup($nid = 1)

1 is the nid of an organic group. Everything works like a charm!

The problem reported at http://drupal.org/node/1034224 doesn't happen anymore after this change.

To make a long story short: when the stream depends on the OG context neither the "Older messages" link nor the auto-append after a shout work.

I'm too tired to work on it now, but tomorrow I'll address it ftitm.

Rgds,
Daniel Madruga.

dmadruga’s picture

I've been working on it and came up with a patch that works for me. Find it attached.

I modified 3 files:

heartbeat.module --

  // Add a fifth paramter to indicate that there's a group context
  if( (module_exists('og')) && ($og_context = og_get_group_context()) && ((int) $og_context->nid > 0) ){
    $attributes['query']['gid'] = $og_context->nid;
  }

This code tests is there's a context and adds a GET query to the URL with the gid.
--

heartbeat.pages.inc --

  // If we're in a group context, let's make HB aware of it.
  if (module_exists('og') && is_numeric($og_nid = $_GET['gid']) && (int) $og_nid > 0) {
		$group_node = node_load($og_nid);
		og_set_group_context($group_node);
  }

If it finds the GID in the URL it sets the group context.
--

ogheartbeat.inc --

  public function construct() {
		$group_context = og_get_group_context();
		if( (int) $group_context->nid > 0){
			$nid = (int) $group_context->nid;
		}
		else{
			$nid = 0;
		}

    // Where the user id is a member of the group
    // and where the nid target is the group nid
    $this->setGroup($nid);

  }

I tested this patch with the the OgHeartbeat and Personal Heartbeat default streams and also with my customized streams. It all worked like a charm.

Stalski, could you please take a look at this patch and make some tests?

Rgds,
Daniel Madruga.

dmadruga’s picture

Ooops... I forgot to attache the patch.

Stalski’s picture

Status: Postponed (maintainer needs more info) » Needs review

But the "Older messages" link still doesn't work for the stream OgHeartbeat

This was fixed. That was a bug i spotted myself just a couple of hours ago.

As it is a lot less code an small change (the request group_nid was not used in ogheartbeat yet), would you test the dev version first? I don't have any problems with it anymore. So checkout latest dev of from cvs and you should be fine.

I would have done it with a patch, but as i said, i saw this bug myself.

Stalski’s picture

Status: Needs review » Closed (fixed)
jitse’s picture

I am still experiencing the problem with the OG-context sensitive streams (ogheartbeat) on the 6.x-4.x-dev from 2011-Jul-26.
Other (by default included) streams are fine, the OG context sensitive streams "display older messages" are not working.

paul_visser’s picture

Status: Closed (fixed) » Needs work

After looking thru the code with Jitse (6.x-4.x-dev from 2011-Jul-26) it looks like in ogheartbeat.inc's constructor the function $this.setGroup() is not setting anything. Which explains why after pressing the "Older messages" link there is nothing displayed. In the function $this.setGroup() the nid of an organic group should be included as a parameter to display older messages.

jitse’s picture

On the latest dev (1 august 2011) I see no code facilitating group context.
If I use dmadruga's code it still fixes the problem.

I did not alter the ogheartbeat.inc, but did apply patches on heartbeat.pages.inc and heartbeat.module

//------------------heartbeat.pages.inc-----------------

//Add this
  // If we're in a group context, let's make HB aware of it.
  if (module_exists('og') && is_numeric($og_nid = $_GET['gid']) && (int) $og_nid > 0) {
                $group_node = node_load($og_nid);
                og_set_group_context($group_node);
  }

//Before

  // Message streams for each access type
  $context = heartbeat_stream_view($access_type, $page, $offset_time, $ajax, $account);


//-------------heartbeat.module---------------

//Add this

    // Add a fifth paramter to indicate that there's a group context
    if( (module_exists('og')) && ($og_context = og_get_group_context()) && ((int) $og_context->nid > 0) ){
      $attributes['query']['gid'] = $og_context->nid;
    }

//After

    // Add a fourth parameter to indicate that where on a profile page.
    $account = -1;
    if (arg(0) == 'user' && is_numeric(arg(1)) && variable_get('heartbeat_show_user_profile_messages_' . $heartbeatAccess->getStream()->name, 1)) {
      $path .= '/' . arg(1);
      $account = arg(1);
    }
    elseif (isset($_REQUEST['account'])) {
      $path .= '/' . $_REQUEST['account'];
      $account = $_REQUEST['account'];
    }

Crom’s picture

#9 works for me. Thanks Jitse

Patrizio’s picture

FileSize
804 bytes

I have the same problem with 6.x-4.x-dev
Here is my patch

Stalski’s picture

Status: Needs work » Fixed

Pushed the last solution to git.

Status: Fixed » Closed (fixed)

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