Gets user teams in a workspace.

@param User      $user
@param Workspace $workspace

@return array
325539
public function getTeamsByUserAndWorkspace(User $user, Workspace $workspace)
    {
        return $this->teamRepo->findTeamsByUserAndWorkspace($user, $workspace);
    }
136912
public function getUserWorkstations()
    {
        $workstations = $this->getFirstAttribute($this->schema->userWorkstations());

        return array_filter(explode(',', $workstations));
    }
1339531
public CollectionRequest<User> findByWorkspace(String workspace) {
    
        String path = String.format("/workspaces/%s/users", workspace);
        return new CollectionRequest<User>(this, User.class, path, "GET");
    }
969475
public function organizeWorkspaceTagAction(User $currentUser)
    {
        $tagsHierarchy = $this->tagManager->getAllHierarchiesByUser($currentUser);
        $rootTags = $this->tagManager->getRootTags($currentUser);
        $hierarchy = array();

        foreach ($tagsHierarchy as $tagHierarchy) {

            if ($tagHierarchy->getLevel() === 1) {

                if (!isset($hierarchy[$tagHierarchy->getParent()->getId()]) ||
                    !is_array($hierarchy[$tagHierarchy->getParent()->getId()])) {

                    $hierarchy[$tagHierarchy->getParent()->getId()] = array();
                }
                $hierarchy[$tagHierarchy->getParent()->getId()][] = $tagHierarchy->getTag();
            }
        }

        return array(
            'hierarchy' => $hierarchy,
            'rootTags' => $rootTags
        );
    }
310868
private function getMeta(Workspace $workspace, array $options)
    {
        $data = [
            'lang' => $workspace->getLang(),
            'forceLang' => (bool) $workspace->getLang(),
            'slug' => $workspace->getSlug(),
            'model' => $workspace->isModel(),
            'personal' => $workspace->isPersonal(),
            'description' => $workspace->getDescription(),
            'created' => DateNormalizer::normalize($workspace->getCreated()),
            'updated' => DateNormalizer::normalize($workspace->getCreated()), // todo implement
            'creator' => $workspace->getCreator() ? $this->userSerializer->serialize($workspace->getCreator(), [Options::SERIALIZE_MINIMAL]) : null,
        ];

        if (!in_array(Options::SERIALIZE_LIST, $options)) {
            // this query is very slow
            $data['totalUsers'] = $this->finder->fetch(
              User::class,
              ['workspace' => $workspace->getUuid()],
              null,
              0,
              -1,
              true
            );
            $data['totalResources'] = $this->workspaceManager->countResources($workspace);
            $data['usedStorage'] = $this->workspaceManager->getUsedStorage($workspace);
        }

        return $data;
    }
1366313
public function listWorkspacesByUserAction()
    {
        $this->assertIsGranted('ROLE_USER');
        $token = $this->tokenStorage->getToken();
        $user = $token->getUser();
        $roles = $this->utils->getRoles($token);

        $data = $this->tagManager->getDatasForWorkspaceListByUser($user, $roles);
        $favouriteWorkspaces = $this->workspaceManager
            ->getFavouriteWorkspacesByUser($user);
        $favourites = array();

        foreach ($data['workspaces'] as $workspace) {
            if (isset($favouriteWorkspaces[$workspace->getId()])) {
                $favourites[$workspace->getId()] = $workspace;
            }
        }

        $data['user'] = $user;
        $data['favourites'] = $favourites;

        return $data;
    }
775616
protected function getAllRoles(User $user)
    {
        $roles = [
            'Neos.Flow:Everybody' => $this->policyService->getRole('Neos.Flow:Everybody'),
            'Neos.Flow:AuthenticatedUser' => $this->policyService->getRole('Neos.Flow:AuthenticatedUser')
        ];

        /** @var Account $account */
        foreach ($user->getAccounts() as $account) {
            $accountRoles = $account->getRoles();
            /** @var $currentRole Role */
            foreach ($accountRoles as $currentRole) {
                if (!in_array($currentRole, $roles)) {
                    $roles[$currentRole->getIdentifier()] = $currentRole;
                }
                /** @var $currentParentRole Role */
                foreach ($currentRole->getAllParentRoles() as $currentParentRole) {
                    if (!in_array($currentParentRole, $roles)) {
                        $roles[$currentParentRole->getIdentifier()] = $currentParentRole;
                    }
                }
            }
        }

        return $roles;
    }
1055231
public function userPendingItems(Member $user)
    {
        // Don't restrict anything for ADMIN users
        $userInstances = DataList::create(WorkflowInstance::class)
            ->where('"WorkflowStatus" != \'Complete\'')
            ->sort('LastEdited DESC');

        if (Permission::checkMember($user, 'ADMIN')) {
            return $userInstances;
        }
        $instances = new ArrayList();
        foreach ($userInstances as $inst) {
            $instToArray = $inst->getAssignedMembers();
            if (!count($instToArray)>0 || !in_array($user->ID, $instToArray->column())) {
                continue;
            }
            $instances->push($inst);
        }

        return $instances;
    }
644788
public function userSubmittedItems(Member $user)
    {
        $userInstances = DataList::create(WorkflowInstance::class)
            ->where('"WorkflowStatus" != \'Complete\'')
            ->sort('LastEdited DESC');

        // Restrict the user if they're not an ADMIN.
        if (!Permission::checkMember($user, 'ADMIN')) {
            $userInstances = $userInstances->filter('InitiatorID:ExactMatch', $user->ID);
        }

        return $userInstances;
    }
1313438
public function showTeamMemberView(User $user)
    {
        return View::make('dashboard.team.edit')
            ->withPageTitle(trans('dashboard.team.edit.title').' - '.trans('dashboard.dashboard'))
            ->withUser($user);
    }
215051
public function addUserAction(Workspace $workspace, User $user)
    {
        $role = $workspace->getDefaultRole();
        $this->roleManager->associateRole($user, $role);
        $this->dispatcher->dispatch(
            'claroline_workspace_register_user',
            'WorkspaceAddUser',
            [$role, $user]
        );

        if ($user->getUuid() === $this->container->get('security.token_storage')->getToken()->getUser()->getUuid()) {
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->container->get('security.token_storage')->setToken($token);
        }

        return $user;
    }
153680
public function findParentsFromTag(User $user, WorkspaceTag $tag)
    {
        $dql = '
            SELECT DISTINCT t
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t
            WHERE t.user = :user
            AND EXISTS (
                SELECT h
                FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
                WHERE h.user = :user
                AND h.tag = :tag
                AND h.parent = t
            )
            ORDER BY t.name
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);
        $query->setParameter('tag', $tag);

        return $query->getResult();
    }
1342917
public function whereInUserWorkspace(User $user)
    {
        $eol = PHP_EOL;
        $clause =
            "node.workspace IN{$eol}" .
            "({$eol}" .
            "    SELECT aw FROM Claroline\CoreBundle\Entity\Workspace\Workspace aw{$eol}" .
            "    JOIN aw.roles r{$eol}" .
            "    WHERE r IN (SELECT r2 FROM Claroline\CoreBundle\Entity\Role r2 {$eol}".
            "       LEFT JOIN r2.users u {$eol}" .
            "       LEFT JOIN r2.groups g {$eol}" .
            "       LEFT JOIN g.users u2 {$eol}" .
            "       WHERE u.id = :user_id OR u2.id = :user_id {$eol}" .
            "   ) {$eol}" .
            ") {$eol}";
        $this->addWhereClause($clause);
        $this->parameters[':user_id'] = $user->getId();

        return $this;
    }
941496
public function findWorkspaceRolesByUser(User $user, $executeQuery = true)
    {
        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.users u
            WHERE u = :user
            AND r.type = :type
            AND r.workspace IS NOT NULL
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('type', Role::WS_ROLE);
        $query->setParameter('user', $user);

        return $executeQuery ? $query->getResult() : $query;
    }
855880
public function findHierarchiesByParent(
        User $user,
        WorkspaceTag $workspaceTag
    )
    {
        $dql = '
            SELECT h
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
            WHERE h.user = :user
            AND h.parent = :workspaceTag
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);
        $query->setParameter('workspaceTag', $workspaceTag);

        return $query->getResult();
    }
752122
public function getArrayRolesByWorkspace(Workspace $workspace)
    {
        $workspaceRoles = [];
        $uow = $this->om->getUnitOfWork();
        $wRoles = $this->roleManager->getRolesByWorkspace($workspace);
        $scheduledForInsert = $uow->getScheduledEntityInsertions();

        foreach ($scheduledForInsert as $entity) {
            if ('Claroline\CoreBundle\Entity\Role' === get_class($entity)) {
                if ($entity->getWorkspace()) {
                    if ($entity->getWorkspace()->getGuid() === $workspace->getGuid()) {
                        $wRoles[] = $entity;
                    }
                }
            }
        }
        //now we build the array
        foreach ($wRoles as $wRole) {
            $workspaceRoles[$wRole->getTranslationKey()] = $wRole;
        }

        return $workspaceRoles;
    }
36864
public function findWorkspaceRootsByUser(User $user)
    {
        $builder = new ResourceQueryBuilder();
        $dql = $builder->selectAsArray()
            ->whereParentIsNull()
            ->whereInUserWorkspace($user)
            ->orderByPath()
            ->getDql();
        $query = $this->_em->createQuery($dql);
        $query->setParameters($builder->getParameters());

        return $this->executeQuery($query);
    }