protected function fetchUserGroups($userId)
{
$query = $this->handler->createSelectQuery();
$query->select($this->handler->quoteColumn('path_string', 'ezcontentobject_tree'))->from($this->handler->quoteTable('ezcontentobject_tree'))->where($query->expr->eq($this->handler->quoteColumn('contentobject_id', 'ezcontentobject_tree'), $query->bindValue($userId)));
$statement = $query->prepare();
$statement->execute();
$paths = $statement->fetchAll(\PDO::FETCH_COLUMN);
$nodeIDs = array_unique(array_reduce(array_map(function ($pathString) {
return array_filter(explode('/', $pathString));
}, $paths), 'array_merge_recursive', array()));
if (empty($nodeIDs)) {
return array();
}
$query = $this->handler->createSelectQuery();
$query->select($this->handler->quoteColumn('id', 'ezcontentobject'))->from($this->handler->quoteTable('ezcontentobject_tree'))->innerJoin($this->handler->quoteTable('ezcontentobject'), $query->expr->eq($this->handler->quoteColumn('id', 'ezcontentobject'), $this->handler->quoteColumn('contentobject_id', 'ezcontentobject_tree')))->where($query->expr->in($this->handler->quoteColumn('node_id', 'ezcontentobject_tree'), $nodeIDs));
$statement = $query->prepare();
$statement->execute();
return $statement->fetchAll(\PDO::FETCH_COLUMN);
}