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();
 }
 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;
 }
Exemple #3
0
 public function getTaggedWorkspacesByRoles(User $user, $tag, $orderedBy = 'id', $order = 'ASC')
 {
     $roles = $user->getEntityRoles();
     return count($roles) > 0 ? $this->taggedObjectRepo->findTaggedWorkspacesByRoles($tag, $roles, $orderedBy, $order) : array();
 }
Exemple #4
0
 /**
  * @EXT\Route(
  *     "desktop/hometab/{homeTab}/widget/instance/create",
  *     name="claro_desktop_widget_instance_create",
  *     options = {"expose"=true}
  * )
  * @EXT\Method("POST")
  * @EXT\ParamConverter("user", options={"authenticatedUser" = true})
  * @EXT\Template("ClarolineCoreBundle:Tool\desktop\home:desktopWidgetInstanceCreateModalForm.html.twig")
  *
  * Creates a widget instance.
  *
  * @return Response
  */
 public function desktopWidgetInstanceCreateAction(User $user, HomeTab $homeTab)
 {
     $widgetInstance = new WidgetInstance();
     $widgetDisplayConfig = new WidgetDisplayConfig();
     $instanceForm = $this->formFactory->create(new WidgetInstanceType(true, true, $user->getEntityRoles()), $widgetInstance);
     $displayConfigForm = $this->formFactory->create(new WidgetDisplayConfigType(), $widgetDisplayConfig);
     $instanceForm->handleRequest($this->request);
     $displayConfigForm->handleRequest($this->request);
     if ($instanceForm->isValid() && $displayConfigForm->isValid()) {
         $widgetInstance->setUser($user);
         $widgetInstance->setIsAdmin(false);
         $widgetInstance->setIsDesktop(true);
         $widgetHomeTabConfig = new WidgetHomeTabConfig();
         $widgetHomeTabConfig->setHomeTab($homeTab);
         $widgetHomeTabConfig->setWidgetInstance($widgetInstance);
         $widgetHomeTabConfig->setUser($user);
         $widgetHomeTabConfig->setVisible(true);
         $widgetHomeTabConfig->setLocked(false);
         $widgetHomeTabConfig->setWidgetOrder(1);
         $widgetHomeTabConfig->setType('desktop');
         $widget = $widgetInstance->getWidget();
         $widgetDisplayConfig->setWidgetInstance($widgetInstance);
         $widgetDisplayConfig->setUser($user);
         $widgetDisplayConfig->setWidth($widget->getDefaultWidth());
         $widgetDisplayConfig->setHeight($widget->getDefaultHeight());
         $this->widgetManager->persistWidgetConfigs($widgetInstance, $widgetHomeTabConfig, $widgetDisplayConfig);
         return new JsonResponse(array('widgetInstanceId' => $widgetInstance->getId(), 'widgetHomeTabConfigId' => $widgetHomeTabConfig->getId(), 'widgetDisplayConfigId' => $widgetDisplayConfig->getId(), 'color' => $widgetDisplayConfig->getColor(), 'name' => $widgetInstance->getName(), 'configurable' => $widgetInstance->getWidget()->isConfigurable() ? 1 : 0, 'width' => $widget->getDefaultWidth(), 'height' => $widget->getDefaultHeight()), 200);
     } else {
         return array('homeTab' => $homeTab, 'instanceForm' => $instanceForm->createView(), 'displayConfigForm' => $displayConfigForm->createView());
     }
 }