public function getEnvironments($filter = null, $orderByPriority = false)
{
$like = '';
if (isset($filter)) {
$like = " AND ce.name LIKE '%" . $this->db->escape($filter) . "%'";
}
$orderBy = '';
if ($orderByPriority) {
$orderBy = " ORDER BY ce.default_priority DESC";
}
if ($this->canManageAcl()) {
return $this->db->getAll("SELECT ce.id, ce.name, ce.default_priority FROM client_environments ce WHERE ce.client_id = ?" . $like . $orderBy, [$this->getAccountId()]);
} else {
$teams = array();
foreach ($this->getTeams() as $team) {
$teams[] = $team['id'];
}
if (count($teams)) {
return $this->db->getAll("\n SELECT ce.id, ce.name, ce.default_priority FROM client_environments ce\n JOIN account_team_envs te ON ce.id = te.env_id\n WHERE te.team_id IN (" . implode(',', $teams) . ")" . $like . "\n GROUP BY ce.id\n " . $orderBy);
}
}
return [];
}