Block not Refreshing properly with User Activity

pribeh - April 23, 2009 - 22:02
Project:Block Refresh
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi there,

Thanks for this excellent module. I'm trying to get this to work with a block that I've created for the activity module which shows the (displayed) user's recent activity. The block refresh appears to work with every block supplied by the module ("logged in user's" and "everyone's" recent activity). But for some reason I get a blank slate when the (displayed) user's activity block tries to refresh.

The code for the block has been inserted into the module. Here is the code for the "all activity" block that does refresh:

case 'all':
          if (user_access('view public activity')) {
            $activity =  activity_get_activity(ACTIVITY_ALL, NULL, variable_get('activity_block_'. $delta, 5) + 1);
            if ($count = count($activity)) {
              drupal_add_css(drupal_get_path('module', 'activity') .'/activity.css');
              if ($count > variable_get('activity_block_'. $delta, 5)) {
                $more_link = theme('activity_more_link', 'activity');
                array_pop($activity);
              }
              $activities = array();
              foreach ($activity as $item) {
                $activities[] = theme('activity', activity_token_replace($item), $item) . activity_delete_link($item);
              }
              return array(
                'subject' => t('Recent activity'),
                'content' => theme('activity_block', $activities)
              );
            }
          }
          break;

And here is the code for the user block that does not refresh:

case 'user':
            if (user_access('view public activity') && arg(0) == "user" && is_numeric(arg(1))) {
              $uid = arg(1);
              $author = activity_user_load($uid);
              $activity =  activity_get_activity($uid, NULL, variable_get('activity_block_'. $delta, 5) + 1);
              if ($count = count($activity)) {
                drupal_add_css(drupal_get_path('module', 'activity') .'/activity.css');
                if ($count > variable_get('activity_block_'. $delta, 5)) {
                  $more_link = theme('activity_more_link', 'activity');
                  array_pop($activity);
                }
                $activities = array();
                foreach ($activity as $item) {
                  $item['delete-link'] = activity_delete_link($item);
                  $activities[] = theme('activity', activity_token_replace($item), $item);
                }
                return array(
                  'subject' => t("@username's activity", array('@username' => $author->name)),
                  'content' => theme('activity_block', $activities)
                );
              }
            }
            break;

Any help is uber-appreciated.

#1

pribeh - April 24, 2009 - 14:34

K,

I realized that offering you a chance to look at the site might help. Go to http://lc3.figureandground.net/user/2 and look for "thomas cermak's activity" block toward the bottom left. Manual refresh is on.

 
 

Drupal is a registered trademark of Dries Buytaert.