Hi,

we have a main biblio page with all publications of our chair. Additionally, our research assistants include snippets like biblio_db_search('author', 'my own name') to present a list of publications on their personal page.

Now if someone goes to the main biblio page and sets the filter to "author = someone", and then goes to the personal pages of the resarch assistants, he won't see any publications anymore.

That's because in biblio_build_query you find this:

  foreach ($session as $filter) {
    $arg_list = array_merge($arg_list, $filter);
  }

Thus, when you filter by "author = someone" on the main list, and "someone" internally has aid = 1, and then execute the biblio_db_search('author', 'my own name') on a users personal page, the clause WHERE aid = 1 will be added. So you finally search for publications where "author rlike my_own_name AND aid = 1". Of course this fails if "someone" is not "my_own_name".
The same happens on the drupal profile pages, i.e., user/xxx/biblio.

The attached patch prevents adding filter values when biblio_db_search is called with "inline" or "profile".

cu,
Frank

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Frank Steiner’s picture

Status: Active » Needs review
Frank Steiner’s picture

Sorry for bumping :-) I'd just like to ask if there's a chance to getting this fixed in the module itself. If you don't consider this a bug (or the patch not a solution) we will try to work around it otherwise.

rjerome’s picture

Hi Frank,

I see your problem, but I'm not sure your solution is quite correct. I suspect there are times when you would want filters in the "inline" mode, but I think the underlying problem is how and when to clear the 'biblio_filter' SESSION variable (maybe I need to find some why to avoid it completely, if I recall it was sort of a lazy mans hack anyway).

Frank Steiner’s picture

Ok, thanks for the feedback!
What do you think about an additional keyword like 'ignore_filters' as possible parameter for biblio_db_search? That would keep the original behaviour while allowing to disable filters manually. If you feel comfortable with such an approach, I can write a patch.

rjerome’s picture

OK, I think I found the solution using the "exit" hook... Could you try adding this code to your module (and removing your other related patches) and see if it fixes the problem.

function biblio_exit($destination=NULL) {
  if(!$destination){
  unset ($_SESSION['biblio_filter']);
  }
}
Frank Steiner’s picture

It works in that the entries on the user pages now are fine! But if you still have the global publication page open the filter is removed there also, so that when you see "where author is xx" and click e.g. on one of the sort options, the filter disappears. I think this could be confusing if a filter vanishes "magically" ;-)

I think it would be better to keep the filters until explicitely deleted by the user and have a parameter for biblio_db_search to chose if filters should be considered or not.

rjerome’s picture

Yes, I discovered that little problem after I posted that code :-(

I guess your right, the easiest solution is some kind of switch.

Frank Steiner’s picture

Version: 6.x-1.0-beta8 » 6.x-1.x-dev
FileSize
709 bytes

What about this one?

rjerome’s picture

If it works for you, it works for me :-)

Ron.

rjerome’s picture

Status: Needs review » Fixed

committed to CVS

Frank Steiner’s picture

> If it works for you, it works for me :-)

Oh, cool! How often can I apply this before it expires?

Thanks :-)

rjerome’s picture

That was a Christmas present!

Now you have just 360 more sleeps until the next one :-)

Status: Fixed » Closed (fixed)

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