本文整理汇总了PHP中Claroline\CoreBundle\Entity\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: findAncestors
/**
* Returns the ancestors of a message (the message itself is also returned).
*
* @param Message $message
*
* @return array[Message]
*/
public function findAncestors(Message $message, User $user)
{
$dql = "\n SELECT m\n FROM Claroline\\MessageBundle\\Entity\\Message m\n JOIN m.userMessages um\n JOIN um.user u\n WHERE m.lft BETWEEN m.lft AND m.rgt\n AND m.root = {$message->getRoot()}\n AND m.lvl <= {$message->getLvl()}\n AND (\n u.id = :userid\n OR m.user = :userid\n )\n ";
$query = $this->_em->createQuery($dql);
$query->setParameter('userid', $user->getId());
return $query->getResult();
}
开发者ID:claroline,项目名称:distribution,代码行数:14,代码来源:MessageRepository.php
示例2: registerUserToCursusHierarchy
public function registerUserToCursusHierarchy($platformName, User $user, $cursusId)
{
$targetPlatformUrl = $this->friendRepo->findOneByName($platformName);
$url = 'clarolinecursusbundle/api/users/' . $user->getId() . '/tos/' . $cursusId . '/cursus/hierarchy/add.json';
$serverOutput = $this->apiManager->url($targetPlatformUrl, $url);
return json_decode($serverOutput, true);
}
开发者ID:claroline,项目名称:distribution,代码行数:7,代码来源:CursusApiManager.php
示例3: regenerateRssUrlAction
/**
* @Route("/regenerate_rss", name="icap_notification_regenerate_rss_url")
* @Template("IcapNotificationBundle:Parameters:config.html.twig")
* @ParamConverter("user", options={"authenticatedUser" = true})
*/
public function regenerateRssUrlAction(User $user)
{
$parametersManager = $this->getParametersManager();
$parameters = $parametersManager->regenerateRssId($user->getId());
$types = $parametersManager->allTypesList($parameters);
return array('types' => $types, 'rssId' => $parameters->getRssId());
}
开发者ID:claroline,项目名称:distribution,代码行数:12,代码来源:NotificationUserParametersController.php
示例4: request
public function request($method, $uri, User $user = null, array $parameters = [])
{
if (!$this->client instanceof Client) {
throw new \Exception('This method requires a client property of type ' . 'Symfony\\Component\\BrowserKit\\Client');
}
$server = $user ? ['PHP_AUTH_USER' => $user->getUsername(), 'PHP_AUTH_PW' => $user->getPlainPassword()] : [];
return $this->client->request($method, $uri, $parameters, [], $server);
}
开发者ID:claroline,项目名称:distribution,代码行数:8,代码来源:RequestTrait.php
示例5: findByUser
public function findByUser(User $user, $showAll = false)
{
$qb = $this->createQueryBuilder('f')->leftJoin('f.panelFacets', 'pf')->leftJoin('pf.fieldsFacet', 'ff')->leftJoin('ff.fieldsFacetValue', 'ffv');
if (!$showAll) {
$qb->join('f.roles', 'frole')->join('pf.panelFacetsRole', 'pfr')->andWhere('frole in (:roles)')->andWhere('pfr.role in (:roles)')->andWhere('pfr.canOpen = true')->setParameter('roles', $user->getEntityRoles());
}
return $qb->getQuery()->getResult();
}
开发者ID:claroline,项目名称:distribution,代码行数:8,代码来源:FacetRepository.php
示例6: findByUserWithAccessToken
/**
* @param User $user
* @param bool $executeQuery
*
* @return Query|array
*/
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;
}
开发者ID:claroline,项目名称:distribution,代码行数:14,代码来源:ClientRepository.php
示例7: getUserKey
private function getUserKey(User $user)
{
if ($user === null) {
return 'anonymous';
} else {
return $user->getId();
}
}
开发者ID:ngodfraind,项目名称:DropZoneBundle,代码行数:8,代码来源:TemporaryAccessResourceManager.php
示例8: findByUser
/**
* @param User $user
* @param bool $getQuery
*
* @return Query|array
*/
public function findByUser(User $user, $getQuery = false)
{
$query = $this->getEntityManager()->createQuery('SELECT bc, b, bt
FROM IcapBadgeBundle:BadgeClaim bc
JOIN bc.badge b
JOIN b.translations bt
WHERE bc.user = :userId')->setParameter('userId', $user->getId());
return $getQuery ? $query : $query->getResult();
}
开发者ID:claroline,项目名称:distribution,代码行数:15,代码来源:BadgeClaimRepository.php
示例9: findByUser
/**
* @param User $user
* @param bool $executeQuery
*
* @return Query|array
*/
public function findByUser(User $user, $executeQuery = true)
{
$query = $this->getEntityManager()->createQuery('SELECT b, ub, bt
FROM IcapBadgeBundle:Badge b
JOIN b.userBadges ub
JOIN b.translations bt
WHERE ub.user = :userId')->setParameter('userId', $user->getId());
return $executeQuery ? $query->getResult() : $query;
}
开发者ID:claroline,项目名称:distribution,代码行数:15,代码来源:BadgeRepository.php
示例10: findByUser
/**
* @param User $user
* @param bool $executeQuery
*
* @return Query|array
*/
public function findByUser(User $user, $executeQuery = true)
{
$query = $this->getEntityManager()->createQuery('SELECT badgeCollection, userBadges
FROM IcapBadgeBundle:BadgeCollection badgeCollection
LEFT JOIN badgeCollection.userBadges userBadges
WHERE badgeCollection.user = :userId
ORDER BY badgeCollection.name ASC')->setParameter('userId', $user->getId());
return $executeQuery ? $query->getResult() : $query;
}
开发者ID:claroline,项目名称:distribution,代码行数:15,代码来源:BadgeCollectionRepository.php
示例11: adminOrNot
/**
* Admin or not
*
* @param User $user
* @return boolean
*/
public function adminOrNot(User $user)
{
$adminInnova = false;
// TODO : change service to @security.authorization_checker
if ($this->securityContext->isGranted('ROLE_ADMIN' === true) && $this->get('security.context')->getToken()->getUser()->getId() == $user->getId()) {
$adminInnova = true;
}
return $adminInnova;
}
开发者ID:arnaudbey,项目名称:CollecticielBundle,代码行数:15,代码来源:CollecticielManager.php
示例12: checkRights
public function checkRights(User $user, $theRight)
{
if ($this->authorization->isGranted('ROLE_ADMIN')) {
return true;
}
$roles = $user->getEntityRoles();
$rights = $this->rightsRepo->findPresenceRightsByRolesAndValue($roles, $theRight);
return count($rights) > 0;
}
开发者ID:claroline,项目名称:distribution,代码行数:9,代码来源:PresenceManager.php
示例13: workspaceUser
/**
* @param Workspace $workspace
* @param User $user
*
* @return User
*/
public function workspaceUser(Workspace $workspace, User $user)
{
$role = new Role();
$role->setName("ROLE_WS_{$workspace->getName()}_{$user->getUsername()}");
$role->setTranslationKey($role->getName());
$role->setWorkspace($workspace);
$user->addRole($role);
$this->om->persist($role);
$this->om->persist($user);
return $user;
}
开发者ID:claroline,项目名称:distribution,代码行数:17,代码来源:Persister.php
示例14: persistUser
protected function persistUser($username)
{
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
$this->om->persist($user);
return $user;
}
开发者ID:stefk,项目名称:CompetencyBundle,代码行数:11,代码来源:RepositoryTestCase.php
示例15: __construct
public function __construct(Cursus $cursus, User $user)
{
$details = [];
$details['username'] = $user->getUsername();
$details['firsName'] = $user->getFirstName();
$details['lastName'] = $user->getLastName();
$details['cursusId'] = $cursus->getId();
$details['cursusTitle'] = $cursus->getTitle();
$details['cursusCode'] = $cursus->getCode();
parent::__construct(self::ACTION, $details, $user);
}
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:LogCursusUserRegistrationEvent.php
示例16: buildSectionTree
/**
* @param Wiki $wiki
* @param bool $isAdmin
* @param User $user
*
* @return Tree $tree
*/
public function buildSectionTree(Wiki $wiki, $isAdmin, User $user = null)
{
$queryBuilder = $this->createQueryBuilder('section')->join('section.activeContribution', 'contribution')->select('section, contribution')->andWhere('section.root = :rootId')->orderBy('section.root, section.left', 'ASC')->setParameter('rootId', $wiki->getRoot()->getId());
$queryBuilder->andWhere($queryBuilder->expr()->orX('section.deleted = :deleted', $queryBuilder->expr()->isNull('section.deleted')))->setParameter('deleted', false);
if ($isAdmin === false) {
$queryBuilder->andWhere($queryBuilder->expr()->orX('section.visible = :visible', 'section.author = :userId'))->setParameter('visible', true)->setParameter('userId', $user->getId());
}
$options = ['decorate' => false];
$tree = $this->buildTree($queryBuilder->getQuery()->getArrayResult(), $options);
return $tree;
}
开发者ID:claroline,项目名称:distribution,代码行数:18,代码来源:SectionRepository.php
示例17: user
/**
* @param string $username
*
* @return User
*/
public function user($username, $withWorkspace = false)
{
$user = new User();
$user->setFirstName($username);
$user->setLastName($username);
$user->setUsername($username);
$user->setPassword($username);
$user->setMail($username . '@mail.com');
$user->setGuid($username);
$this->om->persist($user);
if (!$this->userRole) {
$this->userRole = $this->role('ROLE_USER');
$this->om->persist($this->userRole);
}
$user->addRole($this->userRole);
if ($withWorkspace) {
$workspace = new Workspace();
$workspace->setName($username);
$workspace->setCreator($user);
$workspace->setCode($username);
$workspace->setGuid($username);
$this->om->persist($workspace);
$user->setPersonalWorkspace($workspace);
}
return $user;
}
开发者ID:claroline,项目名称:distribution,代码行数:31,代码来源:Persister.php
示例18: createInwicastUserIfNotExists
public function createInwicastUserIfNotExists(User $user, $token, Mediacenter $mediacenter)
{
$connection = $this->connectionFactory->createConnection($mediacenter->getDatabaseParameters());
$qb = $connection->createQueryBuilder();
$qb->select('usr.username, usr.token')->from('mdcr_inwicast_user_tokens', 'usr')->where('usr.username = :username')->andWhere('usr.tokenapp = :platform')->setParameter("username", $user->getUsername())->setParameter("platform", $this->platformName);
$result = $qb->execute()->fetch();
if (!$result) {
//$qb_insert = $connection->createQueryBuilder();
$sql = "INSERT INTO mdcr_inwicast_user_tokens" . " (`username`, `firstname`, `lastname`, `email`, `userrole`, `token`, `tokendate`, `tokenapp`)" . " VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$query = $connection->prepare($sql);
$query->bindValue(1, $user->getUsername());
$query->bindValue(2, $user->getFirstName());
$query->bindValue(3, $user->getLastName());
$query->bindValue(4, $user->getMail());
$query->bindValue(5, $user->getPlatformRole()->getName());
$query->bindValue(6, $token);
$query->bindValue(7, date('Y-m-d H:i:s'));
$query->bindValue(8, $this->platformName);
$query->execute();
} else {
$qb_update = $connection->createQueryBuilder();
$qb_update->update('mdcr_inwicast_user_tokens')->set('token', '?')->set('tokendate', '?')->set('tokenapp', '?')->where('username = ?')->setParameter(0, $token)->setParameter(1, date('Y-m-d H:i:s'))->setParameter(2, $this->platformName)->setParameter(3, $user->getUsername());
$qb_update->execute();
}
return true;
}
开发者ID:inwicast,项目名称:claroline-plugin-bundle,代码行数:26,代码来源:MediacenterUserRepository.php
示例19: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $objectManager)
{
/** @var \Claroline\CoreBundle\Manager\UserManager $userCreator */
$userCreator = $this->container->get('claroline.manager.user_manager');
/** @var \Claroline\CoreBundle\Manager\RoleManager $roleManager */
$roleManager = $this->container->get('claroline.manager.role_manager');
/** @var \Claroline\CoreBundle\Repository\ResourceNodeRepository $resourceRepo */
$resourceRepo = $objectManager->getRepository('ClarolineCoreBundle:Resource\\ResourceNode');
foreach ($this->users as $names => $role) {
$namesArray = explode(' ', $names);
$firstName = $namesArray[0];
$lastName = isset($namesArray[1]) ? $namesArray[1] : '';
$username = $firstName . ucfirst($lastName);
$user = new User();
$user->setAdministrativeCode('UCL-' . $username . '-' . rand(0, 1000));
$user->setFirstName($firstName);
$lastName = $lastName == '' ? 'Doe' : $lastName;
$user->setLastName($lastName);
$user->setUserName($username);
$user->setPlainPassword($username);
$user->setMail('mail_' . uniqid() . '@claroline.net');
$objectManager->persist($user);
$roleManager->associateRole($user, $this->getReference("role/{$role}"));
if ($this->withWorkspace) {
$userCreator->createUser($user);
$this->addReference("workspace/{$names}", $user->getPersonalWorkspace());
$this->addReference("directory/{$names}", $resourceRepo->findWorkspaceRoot($user->getPersonalWorkspace()));
} else {
$objectManager->persist($user);
}
$this->addReference("user/{$names}", $user);
$objectManager->flush();
}
}
开发者ID:ngydat,项目名称:CoreBundle,代码行数:37,代码来源:LoadUserData.php
示例20: logClient
private function logClient(User $user, Client $client, $firewall = 'main')
{
$tokenStorage = $client->getContainer()->get('security.token_storage');
$token = new UsernamePasswordToken($user, $user->getPlainPassword(), $firewall, $user->getRoles());
$tokenStorage->setToken($token);
//now we generate the cookie !
//@see http://symfony.com/doc/current/cookbook/testing/simulating_authentication.html
$session = $client->getContainer()->get('session');
$session->set('_security_' . $firewall, serialize($token));
$session->save();
$cookie = new Cookie($session->getName(), $session->getId());
$client->getCookieJar()->set($cookie);
return $client;
}
开发者ID:claroline,项目名称:distribution,代码行数:14,代码来源:TransactionalTestCase.php
注:本文中的Claroline\CoreBundle\Entity\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论