Look for an drafted Document of a given user

@param $user
@return CvEntity|null
428215
public function findDraft($user)
    {
        if ($user instanceof UserInterface) {
            $user = $user->getId();
        }

        return $this->findOneDraftBy(['user' => $user]);
    }
233355
public function getUserEntity($user)
    {
        if (is_numeric($user)) {
            $userEntity = $this->entityTypeManager
                ->getStorage('user')
                ->load($user);
        } else {
            $userEntities = $this->entityTypeManager
                ->getStorage('user')
                ->loadByProperties(['name' => $user]);
            $userEntity = reset($userEntities);
        }

        return $userEntity;
    }
937406
public function findByUserWithAccessToken(User $user, $executeQuery = true)
    {
        $query = $this->getEntityManager()
            ->createQuery(
                'SELECT c, at
                FROM ClarolineCoreBundle:Oauth\Client c
                JOIN c.accessTokens at
                WHERE at.user = :userId'
            )
            ->setParameter('userId', $user->getId());

        return $executeQuery ? $query->getResult() : $query;
    }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
470491
private function resolveProfilePictureField(ApiUser $user): ?Field
    {
        $contentType = $user->getContentType();
        foreach ($user->getFields() as $field) {
            $fieldDef = $contentType->getFieldDefinition($field->fieldDefIdentifier);

            if ('ezimage' === $fieldDef->fieldTypeIdentifier) {
                return $field;
            }
        }

        return null;
    }
208858
public function whereIsAccessible($user)
    {
        $currentDate = new \DateTime();
        $clause = '(
            creator.id = :creatorId
            OR (
                node.published = true
                AND (node.accessibleFrom IS NULL OR node.accessibleFrom <= :currentdate)
                AND (node.accessibleUntil IS NULL OR node.accessibleUntil >= :currentdate)
            )
        )';
        $this->addWhereClause($clause);
        $this->parameters[':creatorId'] = ($user === 'anon.') ? -1 : $user->getId();
        $this->parameters[':currentdate'] = $currentDate->format('Y-m-d H:i:s');

        return $this;
    }
657978
public function &user($user = null)
    {
        if($user) {
            $_SESSION[$this->params['session_key']] = $user;
        }
        else {
            if(!$this->check()) {
                throw new UserException('Not logged in', 403);
            }
        }


        return $_SESSION[$this->params['session_key']];
    }
1048807
public function get(User $user)
    {
        if (null !== $acl = $this->fetchFromCache($user)) {
            return $acl;
        }

        return $this->fetch($user);
    }
127061
public function findSent(User $user, $executeQuery = true)
    {
        $dql = "
            SELECT um, m, u
            FROM Claroline\MessageBundle\Entity\UserMessage um
            JOIN um.user u
            JOIN um.message m
            WHERE u.id = {$user->getId()}
            AND um.isRemoved = false
            AND um.isSent = true
            ORDER BY m.date DESC
        ";
        $query = $this->_em->createQuery($dql);

        return $executeQuery ? $query->getResult() : $query;
    }
24272
static function generateUserIdentifier( &$user )
    {
        if ( !$user )
        {
            $user = eZUser::currentUser();
        }
        $userIdentifierBase = false;
        if ( $user->attribute( 'is_logged_in' ) )
        {
            $userIdentifierBase = 'ezuser-' . $user->attribute( 'contentobject_id' );
            $userIdentifier = md5( $userIdentifierBase );
        }
        else
        {
            $userIdentifier = session_id();
            //$userIdentifierBase = 'ezuser-anonymous-' . eZSys::clientIP();
        }
        return $userIdentifier;
    }
193132
public function getUserMainDomain(User $user) {
    if($this->domainEnabled) {
      $groups = Group::getUserGroup($user);
      if (is_array($groups)) {
        foreach ($groups as $group) {
          if ($domaine = $group->getDomain()) {
            if ($domaine->status()) {
              return $domaine;
            }
          }
        }
      }
    }
    return NULL;
  }
1138497
public function findUserRoleByUser(User $user, $executeQuery = true)
    {
        $username = $user->getUsername();
        $roleName = 'ROLE_USER_' . strtoupper($username);

        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            WHERE r.type = :type
            AND r.name = :name
            AND r.translationKey = :key
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('type', Role::USER_ROLE);
        $query->setParameter('name', $roleName);
        $query->setParameter('key', $username);

        return $executeQuery ? $query->getOneOrNullResult() : $query;
    }
20388
protected function getVosForRegistration($user)
    {
        $vos = array();
        $members = array();
        $vosIdForRegistration = array();
        $vosForRegistration = array();

        $vos = $this->getVosByFacilityVoShortNames();
        foreach ($vos as $vo) {
            Logger::debug("Vo:" . print_r($vo, true));
            try {
                $member = $this->rpcAdapter->getMemberByUser($user, $vo);
                Logger::debug("Member:" . print_r($member, true));
                array_push($members, $member);
            } catch (\Exception $exception) {
                array_push($vosForRegistration, $vo);
                Logger::warning("perun:PerunIdentity: " . $exception);
            }
        }

        foreach ($members as $member) {
            if ($member->getStatus() === Member::VALID ||
                $member->getStatus() === Member::EXPIRED) {
                array_push($vosIdForRegistration, $member->getVoId());
            }
        }

        foreach ($vos as $vo) {
            if (in_array($vo->getId(), $vosIdForRegistration)) {
                array_push($vosForRegistration, $vo);
            }
        }
        Logger::debug("VOs for registration:  " . print_r($vosForRegistration, true));
        return $vosForRegistration;
    }
914801
public function user($user = null)
    {
        if ($user !== null) {
            $this->user = $user;
        }

        return $this->user;
    }
392209
public function getWorkspaceIdentifier(User $user = null)
    {
        return md5($user ? $user->id : Auth::id());
    }
476560
public function create(User $user)
    {
        /* handle encode */
        $user = $this->encode($user);

        $this->getEm()->persist($user);
        $this->getEm()->flush();

        return $user;
    }
436880
private function serializePicture(User $user)
    {
        if (!empty($user->getPicture())) {
            /** @var PublicFile $file */
            $file = $this->om
                ->getRepository(PublicFile::class)
                ->findOneBy(['url' => $user->getPicture()]);

            if ($file) {
                return $this->fileSerializer->serialize($file);
            }
        }

        return null;
    }