public function getVisibleAnnouncementsByWorkspace(Workspace $workspace, array $roles)
 {
     if (in_array('ROLE_ADMIN', $roles) || in_array("ROLE_WS_MANAGER_{$workspace->getGuid()}", $roles)) {
         return $this->announcementRepo->findVisibleByWorkspace($workspace);
     }
     return $this->announcementRepo->findVisibleByWorkspaceAndRoles($workspace, $roles);
 }
Example #2
0
 /**
  * @param string $name
  *
  * @return Workspace
  */
 public function workspace($name, User $creator)
 {
     $workspace = new Workspace();
     $workspace->setName($name);
     $workspace->setCode($name);
     $workspace->setCreator($creator);
     $template = new SfFile($this->container->getParameter('claroline.param.default_template'));
     //optimize this later
     $this->container->get('claroline.manager.workspace_manager')->create($workspace, $template);
     return $workspace;
 }
Example #3
0
 /**
  * @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;
 }
Example #4
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();
 }
 /**
  * @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())));
 }
Example #6
0
 /**
  * @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;
 }
Example #7
0
 public function user($username)
 {
     $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 = new Role();
         $this->userRole->setName('ROLE_USER');
         $this->userRole->setTranslationKey('user');
         $this->om->persist($this->userRole);
     }
     $user->addRole($this->userRole);
     $workspace = new Workspace();
     $workspace->setName($username);
     $workspace->setCreator($user);
     $workspace->setCode($username);
     $workspace->setGuid($username);
     $this->om->persist($workspace);
     $user->setPersonalWorkspace($workspace);
     $this->om->flush();
     return $user;
 }
Example #8
0
 public function associateWorkspaceRolesByImport(Workspace $workspace, array $datas)
 {
     $this->om->startFlushSuite();
     $i = 1;
     foreach ($datas as $data) {
         $username = $data[0];
         $roleName = $data[1];
         $user = $this->userRepo->findOneUserByUsername($username);
         $roles = $this->roleRepo->findRolesByWorkspaceCodeAndTranslationKey($workspace->getCode(), $roleName);
         if (!is_null($user) && count($roles) > 0) {
             $this->associateRoles($user, $roles);
         }
         if ($i % 100 === 0) {
             $this->om->forceFlush();
         }
         $i++;
     }
     $this->om->endFlushSuite();
 }
 /**
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $source
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
  * @param \Claroline\CoreBundle\Entity\User $user
  */
 private function duplicateRootDirectory(Workspace $source, Workspace $workspace, User $user)
 {
     $rootDirectory = new Directory();
     $rootDirectory->setName($workspace->getName());
     $directoryType = $this->resourceManager->getResourceTypeByName('directory');
     $resource = $this->resourceManager->create($rootDirectory, $directoryType, $user, $workspace, null, null, array());
     $workspaceRoles = $this->getArrayRolesByWorkspace($workspace);
     $root = $this->resourceManager->getWorkspaceRoot($source);
     $rights = $root->getRights();
     foreach ($rights as $right) {
         $role = $right->getRole();
         if ($role->getType() === 1) {
             $newRight = $this->rightsManager->getRightsFromIdentityMapOrScheduledForInsert($role->getName(), $resource->getResourceNode());
         } else {
             $newRight = new ResourceRights();
             $newRight->setResourceNode($resource->getResourceNode());
             if ($role->getWorkspace() === $source) {
                 $key = $role->getTranslationKey();
                 if (isset($workspaceRoles[$key]) && !empty($workspaceRoles[$key])) {
                     $newRight->setRole($workspaceRoles[$key]);
                 }
             } else {
                 $newRight->setRole($role);
             }
         }
         $newRight->setMask($right->getMask());
         $newRight->setCreatableResourceTypes($right->getCreatableResourceTypes()->toArray());
         $this->om->persist($newRight);
     }
     $this->om->flush();
     return $resource;
 }
Example #10
0
 public function isWorkspaceManager(Workspace $workspace, TokenInterface $token)
 {
     $managerRoleName = 'ROLE_WS_MANAGER_' . $workspace->getGuid();
     return in_array($managerRoleName, $this->ut->getRoles($token)) ? true : false;
 }
Example #11
0
 /**
  * @View(serializerGroups={"api"})
  * @ApiDoc(
  *     description="Update a workspace owner",
  *     views = {"workspace"}
  * )
  * @ParamConverter("user", class="ClarolineCoreBundle:User", options={"repository_method" = "findForApi"})
  */
 public function putWorkspaceOwnerAction(Workspace $workspace, User $user)
 {
     $currentCreator = $workspace->getCreator();
     if ($currentCreator->getId() !== $user->getId()) {
         $this->om->startFlushSuite();
         $role = $this->roleManager->getManagerRole($workspace);
         $this->roleManager->associateRole($user, $role);
         $this->roleManager->dissociateRole($currentCreator, $role);
         $workspace->setCreator($user);
         $this->workspaceManager->editWorkspace($workspace);
         $this->om->endFlushSuite();
     }
     return $workspace;
 }
Example #12
0
 /**
  * @param Configuration $configuration
  * @param User $owner
  * @param bool $isValidated
  *
  * @throws InvalidConfigurationException
  * @return SimpleWorkbolspace
  *
  * The template doesn't need to be validated anymore if
  *  - it comes from the self::import() function
  *  - we want to create a user from the default template (it should work no matter what)
  */
 public function createWorkspace(Configuration $configuration, User $owner, $isValidated = false)
 {
     $configuration->setOwner($owner);
     $data = $configuration->getData();
     $this->data = $data;
     $this->om->startFlushSuite();
     $this->setImporters($configuration, $data);
     if (!$isValidated) {
         $this->validate($data, false);
         $isValidated = true;
     }
     $workspace = new Workspace();
     $workspace->setName($configuration->getWorkspaceName());
     $workspace->setCode($configuration->getWorkspaceCode());
     $workspace->setDescription($configuration->getWorkspaceDescription());
     $workspace->setGuid($this->container->get('claroline.utilities.misc')->generateGuid());
     $workspace->setDisplayable($configuration->isDisplayable());
     $workspace->setSelfRegistration($configuration->getSelfRegistration());
     $workspace->setRegistrationValidation($configuration->getRegistrationValidation());
     $workspace->setSelfUnregistration($configuration->getSelfUnregistration());
     $date = new \Datetime(date('d-m-Y H:i'));
     $workspace->setCreationDate($date->getTimestamp());
     $this->om->persist($workspace);
     $this->om->flush();
     $this->log('Base workspace created...');
     //load roles
     $this->log('Importing roles...');
     $entityRoles = $this->getImporterByName('roles')->import($data['roles'], $workspace);
     //The manager role is required for every workspace
     $entityRoles['ROLE_WS_MANAGER'] = $this->container->get('claroline.manager.role_manager')->createWorkspaceRole("ROLE_WS_MANAGER_{$workspace->getGuid()}", 'manager', $workspace, true);
     $defaultZip = $this->container->getParameter('claroline.param.templates_directory') . 'default.zip';
     //batch import with default template shouldn't be flushed
     if ($configuration->getArchive() !== $defaultZip) {
         $this->om->forceFlush();
     }
     $this->log('Roles imported...');
     $owner->addRole($entityRoles['ROLE_WS_MANAGER']);
     $this->om->persist($owner);
     //add base roles to the role array
     $pfRoles = $this->om->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles();
     foreach ($pfRoles as $pfRole) {
         $entityRoles[$pfRole->getName()] = $pfRole;
     }
     $entityRoles['ROLE_ANONYMOUS'] = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_ANONYMOUS');
     $entityRoles['ROLE_USER'] = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneByName('ROLE_USER');
     $dir = new Directory();
     $dir->setName($workspace->getName());
     $dir->setIsUploadDestination(true);
     $root = $this->container->get('claroline.manager.resource_manager')->create($dir, $this->om->getRepository('Claroline\\CoreBundle\\Entity\\Resource\\ResourceType')->findOneByName('directory'), $owner, $workspace, null, null, array());
     $this->log('Populating the workspace...');
     $this->populateWorkspace($workspace, $configuration, $root, $entityRoles, true, false);
     $this->container->get('claroline.manager.workspace_manager')->createWorkspace($workspace);
     if ($owner) {
         $this->log('Set the owner...');
         $workspace->setCreator($owner);
     }
     $this->om->endFlushSuite();
     $fs = new FileSystem();
     return $workspace;
 }
Example #13
0
 public function findOneBaseWorkspaceRole($roleType, Workspace $workspace)
 {
     $dql = "\n            SELECT r FROM Claroline\\CoreBundle\\Entity\\Role r\n            WHERE r.name = 'ROLE_WS_{$roleType}_{$workspace->getGuid()}'\n        ";
     $query = $this->_em->createQuery($dql);
     return $query->getOneOrNullResult();
 }
Example #14
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]);
 }
Example #15
0
 public function createWidgetInstance($name, Widget $widget, HomeTab $homeTab, Workspace $workspace = null, $isAdmin = false, $isLocked = false)
 {
     $this->log("Create widget {$name} in {$workspace->getCode()}");
     $widgetInstance = new WidgetInstance();
     $widgetHomeTabConfig = new WidgetHomeTabConfig();
     if ($workspace) {
         $type = 'workspace';
         $isDesktop = false;
     } else {
         $type = 'user';
         $isDesktop = true;
     }
     $widgetInstance->setWorkspace($workspace);
     $widgetInstance->setName($name);
     $widgetInstance->setIsAdmin($isAdmin);
     $widgetInstance->setIsDesktop($isDesktop);
     $widgetInstance->setWidget($widget);
     $widgetHomeTabConfig->setHomeTab($homeTab);
     $widgetHomeTabConfig->setWidgetInstance($widgetInstance);
     $widgetHomeTabConfig->setWorkspace($workspace);
     $widgetHomeTabConfig->setLocked($isLocked);
     $widgetHomeTabConfig->setWidgetOrder(1);
     $widgetHomeTabConfig->setType($type);
     $this->om->persist($widgetInstance);
     $this->om->persist($widgetHomeTabConfig);
     return $widgetInstance;
 }
Example #16
0
 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;
 }
 /**
  * Full workspace export.
  */
 public function export(Workspace $workspace)
 {
     $this->log("Exporting {$workspace->getCode()}...");
     foreach ($this->listImporters as $importer) {
         $importer->setListImporters($this->listImporters);
     }
     $data = [];
     $files = [];
     $data['parameters']['code'] = $workspace->getCode();
     $data['parameters']['name'] = $workspace->getName();
     $data['roles'] = $this->getImporterByName('roles')->export($workspace, $files, null);
     $data['tools'] = $this->getImporterByName('tools')->export($workspace, $files, null);
     $_resManagerData = [];
     foreach ($data['tools'] as &$_tool) {
         if ($_tool['tool']['type'] === 'resource_manager') {
             $_resManagerData =& $_tool['tool'];
         }
     }
     //then we parse and replace the text, we also add missing files in $resManagerData
     $files = $this->container->get('claroline.importer.rich_text_formatter')->setPlaceHolders($files, $_resManagerData);
     //throw new \Exception();
     //generate the archive in a temp dir
     $content = Yaml::dump($data, 10);
     //zip and returns the archive
     $archDir = $this->container->get('claroline.config.platform_config_handler')->getParameter('tmp_dir') . DIRECTORY_SEPARATOR . uniqid();
     $archPath = $archDir . DIRECTORY_SEPARATOR . 'archive.zip';
     mkdir($archDir);
     $manifestPath = $archDir . DIRECTORY_SEPARATOR . 'manifest.yml';
     file_put_contents($manifestPath, $content);
     $archive = new \ZipArchive();
     $success = $archive->open($archPath, \ZipArchive::CREATE);
     if ($success === true) {
         $archive->addFile($manifestPath, 'manifest.yml');
         foreach ($files as $uid => $file) {
             $archive->addFile($file, $uid);
         }
         $archive->close();
     } else {
         throw new \Exception('Unable to create archive . ' . $archPath . ' (error ' . $success . ')');
     }
     $this->container->get('claroline.core_bundle.listener.kernel_terminate_listener')->addElementToRemove($archPath);
     return $archPath;
 }
Example #18
0
 public function displayEvents(Workspace $workspace, $allDay = false)
 {
     $events = $this->om->getRepository('ClarolineAgendaBundle:Event')->findByWorkspaceId($workspace->getId());
     return $this->convertEventsToArray($events);
 }
Example #19
0
 /**
  * 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();
 }
Example #20
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;
 }
Example #21
0
 /**
  * @EXT\Route(
  *     "/{workspaceId}/open",
  *     name="claro_workspace_open",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter(
  *      "workspace",
  *      class="ClarolineCoreBundle:Workspace\Workspace",
  *      options={"id" = "workspaceId", "strictId" = true}
  * )
  * @SEC\PreAuthorize("canAccessWorkspace('OPEN')")
  *
  * Open the first tool of a workspace.
  *
  * @param Workspace $workspace
  * @throws AccessDeniedException
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function openAction(Workspace $workspace)
 {
     $options = $workspace->getOptions();
     if (!is_null($options)) {
         $details = $options->getDetails();
         if (isset($details['use_workspace_opening_resource']) && $details['use_workspace_opening_resource'] && isset($details['workspace_opening_resource']) && !empty($details['workspace_opening_resource'])) {
             $resourceNode = $this->resourceManager->getById($details['workspace_opening_resource']);
             if (!is_null($resourceNode)) {
                 $this->session->set('isDesktop', false);
                 $route = $this->router->generate('claro_resource_open', array('node' => $resourceNode->getId(), 'resourceType' => $resourceNode->getResourceType()->getName()));
                 return new RedirectResponse($route);
             }
         }
     }
     $roles = $this->utils->getRoles($this->tokenStorage->getToken());
     $tool = $this->workspaceManager->getFirstOpenableTool($workspace);
     if ($tool) {
         $route = $this->router->generate('claro_workspace_open_tool', array('workspaceId' => $workspace->getId(), 'toolName' => $tool->getName()));
         return new RedirectResponse($route);
     }
     $this->throwWorkspaceDeniedException($workspace);
 }
 protected static function createDisplayableWorkspace($name, $selfRegistration)
 {
     $workspace = new Workspace();
     $workspace->setName($name);
     $workspace->setCode($name . 'Code');
     $workspace->setDisplayable(true);
     $workspace->setSelfRegistration($selfRegistration);
     $workspace->setGuid(self::$client->getContainer()->get('claroline.utilities.misc')->generateGuid());
     self::create($name, $workspace);
 }
Example #23
0
 /**
  * Search a ResourceNode wich is persisted but not flushed yet
  *
  * @param Workspace $workspace
  * @param $name
  * @param ResourceNode $parent
  *
  * @return ResourceNode
  */
 public function getNodeScheduledForInsert(Workspace $workspace, $name, $parent = null)
 {
     $scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions();
     $res = null;
     foreach ($scheduledForInsert as $entity) {
         if (get_class($entity) === 'Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode') {
             if ($entity->getWorkspace()->getCode() === $workspace->getCode() && $entity->getName() === $name && $entity->getParent() == $parent) {
                 return $entity;
             }
         }
     }
     return $res;
 }
 private function isWorkspaceManager(Workspace $workspace, array $roleNames)
 {
     $isWorkspaceManager = false;
     $managerRole = 'ROLE_WS_MANAGER_' . $workspace->getGuid();
     if (in_array('ROLE_ADMIN', $roleNames) || in_array($managerRole, $roleNames)) {
         $isWorkspaceManager = true;
     }
     return $isWorkspaceManager;
 }
Example #25
0
 /**
  * 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;
 }
Example #26
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();
 }
 /**
  * @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();
 }
Example #28
0
 /**
  * @param string[]                                                 $roles
  * @param \Claroline\CoreBundle\Entity\Workspace\Workspace $workspace
  *
  * @return \Claroline\CoreBundle\Entity\Tool\OrderedTool[]
  */
 public function getOrderedToolsByWorkspaceAndRoles(Workspace $workspace, array $roles, $type = 0)
 {
     if ($workspace->isPersonal()) {
         return $this->orderedToolRepo->findPersonalDisplayableByWorkspaceAndRoles($workspace, $roles, $type);
     }
     return $this->orderedToolRepo->findByWorkspaceAndRoles($workspace, $roles, $type);
 }
 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();
 }
 /**
  * @EXT\Route("/dashboards/preview/{workspaceId}/times", name="get_dashboard_spent_times_by_workspace")
  * @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
  * @EXT\ParamConverter("workspace", class="ClarolineCoreBundle:Workspace\Workspace", options={"mapping": {"workspaceId": "id"}})
  * @EXT\Method("GET")
  */
 public function getDashboardWorkspaceSpentTimesByWorkspace(User $user, Workspace $workspace)
 {
     $all = $user->getId() === $workspace->getCreator()->getId();
     $data = $this->dashboardManager->getDashboardWorkspaceSpentTimes($workspace, $user, $all);
     return new JsonResponse($data);
 }