コード例 #1
0
 /**
  * Get all Paths of a Workspace
  * @param  Workspace $workspace
  * @param  bool      $toPublish If false, returns all paths, if true returns only paths which need publishing
  * @return array
  */
 public function findWorkspacePaths(Workspace $workspace, $toPublish = false)
 {
     $builder = $this->createQueryBuilder('p');
     // Join with resourceNode
     $builder->join('p.resourceNode', 'r', 'WITH', 'r.workspace = ' . $workspace->getId());
     // Get only Paths which need publishing
     if ($toPublish) {
         $this->whereToPublish($builder);
     }
     return $builder->getQuery()->getResult();
 }
コード例 #2
0
 /**
  * @Route("/my_badges/claim/{badge_id}", name="icap_badge_workspace_tool_claim_badge")
  * @ParamConverter(
  *     "workspace",
  *     class="ClarolineCoreBundle:Workspace\Workspace",
  *     options={"id" = "workspaceId"}
  * )
  * @ParamConverter("user", options={"authenticatedUser" = true})
  * @ParamConverter("badge", class="IcapBadgeBundle:Badge", options={"id" = "badge_id"})
  * @Template()
  */
 public function claimAction(Workspace $workspace, User $user, Badge $badge)
 {
     $badgeClaim = new BadgeClaim();
     $badgeClaim->setUser($user);
     try {
         $flashBag = $this->get('session')->getFlashBag();
         $translator = $this->get('translator');
         /** @var \Icap\BadgeBundle\Manager\BadgeManager $badgeManager */
         $badgeManager = $this->get('icap_badge.manager.badge');
         $badgeManager->makeClaim($badge, $user);
         $flashBag->add('success', $translator->trans('badge_claim_success_message', array(), 'icap_badge'));
     } catch (\Exception $exception) {
         $flashBag->add('error', $translator->trans($exception->getMessage(), array(), 'icap_badge'));
     }
     return $this->redirect($this->generateUrl('icap_badge_workspace_tool_my_badges', array('workspaceId' => $workspace->getId())));
 }
コード例 #3
0
 public function workspaceWidgetTask(Workspace $workspace)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $listWorkspaceTasks = $em->getRepository('ClarolineAgendaBundle:Event')->findLastEventsOrTasksByWorkspaceId($workspace->getId(), true);
     $editableWorkspaces = [$workspace->getId() => $this->authorization->isGranted(['agenda_', 'edit'], $workspace)];
     return $this->templating->render('ClarolineAgendaBundle:Widget:task_widget.html.twig', ['listTasks' => $listWorkspaceTasks, 'editableWorkspaces' => $editableWorkspaces, 'isDesktop' => false]);
 }
コード例 #4
0
ファイル: HomeController.php プロジェクト: ChMat/CoreBundle
 private function hasWorkspaceAccessToWidgetInstance(WidgetInstance $widgetInstance, Workspace $workspace)
 {
     $widgetWorkspace = $widgetInstance->getWorkspace();
     if (is_null($widgetWorkspace) || $widgetWorkspace->getId() !== $workspace->getId()) {
         return false;
     }
     return true;
 }
コード例 #5
0
 /**
  * @param Workspace $workspace
  *
  * @return int
  */
 public function countByWorkspace(Workspace $workspace)
 {
     $query = $this->getEntityManager()->createQuery('SELECT COUNT(b.id)
             FROM IcapBadgeBundle:Badge b
             WHERE b.workspace = :workspaceId')->setParameter('workspaceId', $workspace->getId());
     return $query->getSingleScalarResult();
 }
コード例 #6
0
ファイル: ToolRepository.php プロジェクト: ngydat/CoreBundle
 /**
  * Returns the number of tools visible in a workspace.
  *
  * @param Workspace $workspace
  *
  * @return integer
  */
 public function countDisplayedToolsByWorkspace(Workspace $workspace, $orderedToolType = 0)
 {
     $dql = "\n            SELECT count(tool)\n            FROM Claroline\\CoreBundle\\Entity\\Tool\\Tool tool\n            JOIN tool.orderedTools ot\n            JOIN ot.workspace ws\n            WHERE ws.id = {$workspace->getId()}\n            AND ot.type = :type\n        ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('type', $orderedToolType);
     return $query->getSingleScalarResult();
 }
コード例 #7
0
ファイル: WorkspaceManager.php プロジェクト: ChMat/CoreBundle
 public function toArray(Workspace $workspace)
 {
     $data = array();
     $data['id'] = $workspace->getId();
     $data['name'] = $workspace->getName();
     $data['code'] = $workspace->getCode();
     $data['expiration_date'] = $workspace->getEndDate()->getTimeStamp();
     return $data;
 }
コード例 #8
0
 public function findDefaultUploadDirectories(Workspace $workspace)
 {
     $dql = "SELECT directory FROM Claroline\\CoreBundle\\Entity\\Resource\\Directory directory\n            JOIN directory.resourceNode node\n            JOIN node.workspace workspace\n            WHERE workspace.id = {$workspace->getId()}\n            AND directory.isUploadDestination = true\n        ";
     $query = $this->_em->createQuery($dql);
     return $query->getResult();
 }
コード例 #9
0
 /**
  * Returns the number of tools visible in a workspace.
  *
  * @param Workspace $workspace
  *
  * @return int
  */
 public function countDisplayedToolsByWorkspace(Workspace $workspace, $orderedToolType = 0)
 {
     $dql = "\n            SELECT count(tool)\n            FROM Claroline\\CoreBundle\\Entity\\Tool\\Tool tool\n            JOIN tool.orderedTools ot\n            JOIN ot.workspace ws\n            LEFT JOIN tool.plugin p\n            WHERE ws.id = {$workspace->getId()}\n            AND ot.type = :type\n            AND (\n                CONCAT(p.vendorName, p.bundleName) IN (:bundles)\n                OR tool.plugin is NULL\n            )\n        ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('type', $orderedToolType);
     $query->setParameter('bundles', $this->bundles);
     return $query->getSingleScalarResult();
 }
コード例 #10
0
 public function findAllByWorkspaceAndUser(Workspace $workspace, User $user)
 {
     $dql = '
         SELECT rwt, t
         FROM Claroline\\CoreBundle\\Entity\\Workspace\\RelWorkspaceTag rwt
         JOIN rwt.workspace w
         JOIN rwt.tag t
         WHERE w.id = :workspaceId
         AND t.user = :user
     ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('workspaceId', $workspace->getId());
     $query->setParameter('user', $user);
     return $query->getResult();
 }
コード例 #11
0
ファイル: UserRepository.php プロジェクト: ChMat/CoreBundle
 public function findAllWithFacetsByWorkspace(Workspace $workspace)
 {
     $dql = "\n            SELECT u, ff\n            FROM Claroline\\CoreBundle\\Entity\\User u\n            JOIN u.roles ur\n            LEFT JOIN u.fieldsFacetValue ff\n            LEFT JOIN u.groups g\n            LEFT JOIN g.roles gr\n            LEFT JOIN gr.workspace grws\n            LEFT JOIN ur.workspace uws\n            WHERE (uws.id = :wsId\n            OR grws.id = :wsId)\n            AND u.isEnabled = true\n        ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('wsId', $workspace->getId());
     return $query->getResult();
 }
コード例 #12
0
 /**
  * Get all ids from users related to a given workspace.
  */
 private function getWorkspaceUsersIds(Workspace $workspace)
 {
     // Select all user(s) belonging to the target workspace (manager and collaborators)...
     $selectUsersIds = 'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr.id = cur.role_id  WHERE cr.workspace_id = :wid';
     $idStmt = $this->em->getConnection()->prepare($selectUsersIds);
     $idStmt->bindValue('wid', $workspace->getId());
     $idStmt->execute();
     $idResults = $idStmt->fetchAll();
     foreach ($idResults as $result) {
         $ids[] = $result['user_id'];
     }
     return $ids;
 }
コード例 #13
0
 /**
  * @EXT\Route(
  *     "/{workspace}/open/tool/home/tab/{tabId}",
  *     name="claro_display_workspace_home_tab",
  *     options = {"expose"=true}
  * )
  *
  * Displays the workspace home tab.
  *
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
  * @param int                                              $tabId
  */
 public function displayWorkspaceHomeTabAction(Workspace $workspace, $tabId)
 {
     return $this->redirectToRoute('claro_workspace_home_display', ['workspace' => $workspace->getId(), 'tabId' => $tabId]);
 }
コード例 #14
0
 public function displayEvents(Workspace $workspace, $allDay = false)
 {
     $events = $this->om->getRepository('ClarolineAgendaBundle:Event')->findByWorkspaceId($workspace->getId());
     return $this->convertEventsToArray($events);
 }
コード例 #15
0
 /**
  * Filters nodes belonging to a given workspace.
  *
  * @param Workspace $workspace
  *
  * @return ResourceQueryBuilder
  */
 public function whereInWorkspace(Workspace $workspace)
 {
     $this->addWhereClause('node.workspace = :workspace_id');
     $this->parameters[':workspace_id'] = $workspace->getId();
     return $this;
 }
コード例 #16
0
 /**
  * @param Workspace $workspace
  *
  * @return array
  */
 public function findByWorkspaceWithUsersFromGroup(Workspace $workspace)
 {
     $dql = '
         SELECT u
         FROM Claroline\\CoreBundle\\Entity\\User u
         JOIN u.roles ur
         LEFT JOIN u.groups g
         LEFT JOIN g.roles gr
         LEFT JOIN gr.workspace grws
         LEFT JOIN ur.workspace uws
         WHERE (uws.id = :wsId
         OR grws.id = :wsId)
         AND u.isRemoved = false
      ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('wsId', $workspace->getId());
     $res = $query->getResult();
     return $res;
 }
コード例 #17
0
 /**
  * Retrieve analytics for workspace: chartData and resource statistics
  */
 public function getWorkspaceAnalytics(Workspace $workspace)
 {
     $range = $this->getDefaultRange();
     $action = 'workspace-enter';
     $workspaceIds = array($workspace->getId());
     $chartData = $this->getDailyActionNumberForDateRange($range, $action, false, $workspaceIds);
     $resourcesByType = $this->resourceTypeRepo->countResourcesByType($workspace);
     return array('chartData' => $chartData, 'resourceCount' => $resourcesByType, 'workspace' => $workspace);
 }
コード例 #18
0
ファイル: ToolManager.php プロジェクト: ngydat/CoreBundle
 /**
  * @param \Claroline\CoreBundle\Entity\Tool\Tool                   $tool
  * @param integer                                                  $position
  * @param string                                                   $name
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
  *
  * @return \Claroline\CoreBundle\Entity\Tool\OrderedTool
  *
  * @throws ToolPositionAlreadyOccupiedException
  */
 public function addWorkspaceTool(Tool $tool, $position, $name, Workspace $workspace, $orderedToolType = 0)
 {
     $switchTool = null;
     // At the workspace creation, the workspace id is still null because we only flush once at the very end.
     if ($workspace->getId() !== null) {
         $switchTool = $this->orderedToolRepo->findOneBy(array('workspace' => $workspace, 'order' => $position, 'type' => $orderedToolType));
     }
     while (!is_null($switchTool)) {
         $position++;
         $switchTool = $this->orderedToolRepo->findOneBy(array('workspace' => $workspace, 'order' => $position, 'type' => $orderedToolType));
     }
     $orderedTool = $this->om->factory('Claroline\\CoreBundle\\Entity\\Tool\\OrderedTool');
     $orderedTool->setWorkspace($workspace);
     $orderedTool->setName($name);
     $orderedTool->setOrder($position);
     $orderedTool->setTool($tool);
     $orderedTool->setType($orderedToolType);
     $this->om->persist($orderedTool);
     $this->om->flush();
     return $orderedTool;
 }
コード例 #19
0
 /**
  * @EXT\Route(
  *     "/{workspace}/subscription/url/generate",
  *     name="claro_workspace_subscription_url_generate"
  * )
  *
  * @EXT\Template("ClarolineCoreBundle:Tool\workspace\parameters:generate_url_subscription.html.twig")
  *
  * @param Workspace $workspace
  *
  * @return Response
  */
 public function urlSubscriptionGenerateAction(Workspace $workspace)
 {
     $user = $this->tokenStorage->getToken()->getUser();
     if ($user === 'anon.') {
         return $this->redirect($this->generateUrl('claro_workspace_subscription_url_generate_anonymous', array('workspace' => $workspace->getId(), 'toolName' => 'home')));
     }
     $this->workspaceManager->addUserAction($workspace, $user);
     return $this->redirect($this->generateUrl('claro_workspace_open_tool', array('workspaceId' => $workspace->getId(), 'toolName' => 'home')));
 }
コード例 #20
0
ファイル: RoleRepository.php プロジェクト: ngydat/CoreBundle
 public function findByGroupAndWorkspace(Group $group, Workspace $workspace)
 {
     $dql = "\n            SELECT r FROM Claroline\\CoreBundle\\Entity\\Role r\n            JOIN r.groups g\n            JOIN r.workspace w\n            WHERE g.id = :groupId AND w.id = :workspaceId\n            ";
     $query = $this->_em->createQuery($dql);
     $query->setParameter('groupId', $group->getId());
     $query->setParameter('workspaceId', $workspace->getId());
     return $query->getResult();
 }
コード例 #21
0
 /**
  * @EXT\Route(
  *     "/form/workspace/{workspace}",
  *     name="claro_message_form_for_workspace"
  * )
  *
  * Displays the message form with the "to" field filled with users of a workspace.
  *
  * @param Workspace $workspace
  *
  * @return Response
  */
 public function formForWorkspaceAction(Workspace $workspace)
 {
     $url = $this->router->generate('claro_message_show', ['message' => 0]) . '?wsIds[]=' . $workspace->getId();
     return new RedirectResponse($url);
 }
コード例 #22
0
ファイル: GroupRepository.php プロジェクト: ChMat/CoreBundle
 /**
  * Returns the groups which are member of a workspace, filtered by a search on
  * their name.
  *
  * @param Workspace $workspace
  * @param string            $search
  * @param boolean           $executeQuery
  *
  * @return array[Group]|Query
  */
 public function findByWorkspaceAndName(Workspace $workspace, $search, $executeQuery = true)
 {
     $dql = '
         SELECT g, r FROM Claroline\\CoreBundle\\Entity\\Group g
         LEFT JOIN g.roles r
         WHERE UPPER(g.name) LIKE :search
         AND g IN
         (
             SELECT gr FROM Claroline\\CoreBundle\\Entity\\Group gr
             JOIN gr.roles wr WITH wr IN (
                 SELECT pr from Claroline\\CoreBundle\\Entity\\Role pr WHERE pr.type = :type
             )
             JOIN wr.workspace w
             WHERE w.id = :id
         )
         ORDER BY g.id
     ';
     $search = strtoupper($search);
     $query = $this->_em->createQuery($dql);
     $query->setParameter('id', $workspace->getId());
     $query->setParameter('search', "%{$search}%");
     $query->setParameter('type', Role::WS_ROLE);
     return $executeQuery ? $query->getResult() : $query;
 }
コード例 #23
0
 /**
  * @param \Claroline\CoreBundle\Entity\Tool\Tool           $tool
  * @param int                                              $position
  * @param string                                           $name
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
  *
  * @return \Claroline\CoreBundle\Entity\Tool\OrderedTool
  *
  * @throws ToolPositionAlreadyOccupiedException
  */
 public function setWorkspaceTool(Tool $tool, $position, $name, Workspace $workspace, $orderedToolType = 0)
 {
     $switchTool = null;
     $orderedTool = $this->orderedToolRepo->findOneBy(['workspace' => $workspace, 'tool' => $tool]);
     if (!$orderedTool) {
         $orderedTool = new OrderedTool();
     }
     // At the workspace creation, the workspace id is still null because we only flush once at the very end.
     if ($workspace->getId() !== null) {
         $switchTool = $this->orderedToolRepo->findOneBy(['workspace' => $workspace, 'order' => $position, 'type' => $orderedToolType]);
     }
     while (!is_null($switchTool)) {
         ++$position;
         $switchTool = $this->orderedToolRepo->findOneBy(['workspace' => $workspace, 'order' => $position, 'type' => $orderedToolType]);
     }
     $orderedTool->setWorkspace($workspace);
     $orderedTool->setName($name);
     $orderedTool->setOrder($position);
     $orderedTool->setTool($tool);
     $orderedTool->setType($orderedToolType);
     $this->om->persist($orderedTool);
     $this->om->flush();
     return $orderedTool;
 }
コード例 #24
0
 public function findPersonalDisplayable(Workspace $workspace, $type = 0)
 {
     $dql = 'SELECT ot
         FROM Claroline\\CoreBundle\\Entity\\Tool\\OrderedTool ot
         JOIN ot.tool t
         JOIN t.pwsToolConfig ptc
         JOIN ot.workspace workspace
         WHERE BIT_AND(ptc.mask, 1) = 1
         AND workspace.id = :workspaceId
         AND ot.type = :type
         ORDER BY ot.order
     ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('workspaceId', $workspace->getId());
     $query->setParameter('type', $type);
     return $query->getResult();
 }
コード例 #25
0
 /**
  * @param Workspace $workspace
  *
  * @return Badge[]
  */
 public function countBadgesPerUser(Workspace $workspace)
 {
     $sql = 'SELECT qr1.nb_badge AS nb_badge, COUNT(qr1.id) AS nb_user
             FROM (SELECT userBadge.user_id AS id, COUNT(userBadge.id) AS nb_badge
             FROM claro_user_badge AS userBadge
             LEFT JOIN claro_badge AS badge ON userBadge.badge_id = badge.id
             WHERE badge.workspace_id = :workspaceId
             GROUP BY userBadge.user_id) AS qr1
             GROUP BY qr1.nb_badge
             ORDER BY qr1.nb_badge';
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('nb_user', 'nb_user')->addScalarResult('nb_badge', 'nb_badge');
     $query = $this->getEntityManager()->createNativeQuery($sql, $rsm)->setParameter('workspaceId', $workspace->getId());
     return $query->getResult('PairHydrator');
 }