Extend Default ListView query but use default listview if filter/search is used

Good day guys. I have this situation wherein

  • I need to show records that has been created last 3 months and where status is Open (this is when I load the listView).
  • But if I use the filter, I need to show everything including records that has been created more than 3 months and records that is not open.

I already achieved the first situation using this function in view.list.php

How can I achieve the second situation where I will not mess up the first one?

Im using SuiteCRM v7.10.

I found a solution. Find this by checking this array $this->searchForm->searchColumns. If there are searches, this array will be filled with objects.