Bug (with fix)

I had a really strange bug in a multisite environment. In a buddypress group, all media navigation tabs worked fine except for one: Albums.

Click on the albums tab would display albums from a number of groups, and in another blog!!!

It took a lot of head scratching but finally I found the solution:

In app/helper/RTMediaModel.php
On line 217:

  
$sql = "SELECT * FROM {$this->table_name} WHERE id IN(SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id = $group_id AND album_id IS NOT NULL AND media_type != 'album' AND context = 'group') OR (media_type = 'album' AND context_id = $group_id AND context = 'group')";  

I added

  
AND blog_id = ".get_current_blog_id()."  

So that line 217 now looks like this:

  
$sql = "SELECT * FROM {$this->table_name} WHERE id IN(SELECT DISTINCT (album_id) FROM {$this->table_name} WHERE context_id = $group_id AND album_id IS NOT NULL AND media_type != 'album' AND context = 'group' AND blog_id = ".get_current_blog_id().") OR (media_type = 'album' AND context_id = $group_id AND context = 'group')";  

Hi glyndavidson,

Thanks for reporting the bug. Just after the line 217, there is a condition that checks if its multisite environment and adds conditions for blog_id. The issue is on the line 217 with the OR condition, it should be AND. We have fixed this and will release it in next update of rtMedia.