I tried to implement a simple visibility clause according to this page in the developer guide for all bean queries to check that team_id of the bean is equal to the team_id of the current user.
The code below does nothing at all. Even if I add global fatal log messages to __construct() and addVisibilityQuery() they never appear in the log.
class TeamSelectorFilter extends SugarVisibility
public function __construct(SugarBean $bean, $params = null)
// Get the current user's team_id.
$this->user_team_id = $current_user->team_id;
public function addVisibilityQuery(SugarQuery $query)
// The bean's team_id must be the same as the user's team_id.
It makes sense that it just inserts another WHERE clause into the running SugarQuery and passes it along, but why does it not work at all?