Пример #1
0
 public function getWorkspaceWidgetList(WidgetInstance $instance)
 {
     $workspace = $instance->getWorkspace();
     if (!$this->isAllowedToViewLogs($workspace)) {
         return null;
     }
     $em = $this->container->get('doctrine.orm.entity_manager');
     /** @var \Claroline\CoreBundle\Repository\Log\LogRepository $repository */
     $repository = $em->getRepository('ClarolineCoreBundle:Log\\Log');
     $config = $this->getLogConfig($instance);
     if ($config === null) {
         $defaultConfig = $em->getRepository('ClarolineCoreBundle:Widget\\WidgetInstance')->findOneBy(array('isDesktop' => false, 'isAdmin' => true));
         $config = new LogWidgetConfig();
         if ($defaultConfig !== null) {
             $config->copy($this->getLogConfig($defaultConfig));
         }
         $config->setRestrictions($this->container->get('claroline.log.manager')->getDefaultWorkspaceConfigRestrictions());
         $widgetInstance = new WidgetInstance();
         $widgetInstance->setWorkspace($workspace);
         $config->setWidgetInstance($widgetInstance);
     }
     /** @var \Claroline\CoreBundle\Manager\EventManager $eventManager */
     $eventManager = $this->container->get('claroline.event.manager');
     if ($config->hasNoRestriction()) {
         return null;
     }
     $query = $repository->findLogsThroughConfigs(array($config), $config->getAmount());
     $logs = $query->getResult();
     $chartData = $repository->countByDayThroughConfigs(array($config), $this->getDefaultRange());
     //List item delegation
     $views = $this->renderLogs($logs);
     $workspaceEvents = $eventManager->getEvents(LogGenericEvent::DISPLAYED_WORKSPACE);
     if ($config->hasAllRestriction(count($workspaceEvents))) {
         $title = $this->container->get('translator')->trans('recent_all_workspace_activities_overview', array('%workspaceName%' => $workspace->getName()), 'platform');
     } else {
         $title = $this->container->get('translator')->trans('Overview of recent activities in %workspaceName%', array('%workspaceName%' => $workspace->getName()), 'platform');
     }
     return array('logs' => $logs, 'listItemViews' => $views, 'chartData' => $chartData, 'workspace' => $workspace, 'logAmount' => $config->getAmount(), 'title' => $title, 'isDesktop' => false);
 }
Пример #2
0
 /**
  * @DI\Observe("widget_core_resource_logger_configuration")
  *
  * @param ConfigureWidgetEvent $event
  */
 public function onConfigure(ConfigureWidgetEvent $event)
 {
     $instance = $event->getInstance();
     $config = $this->logManager->getLogConfig($instance);
     if ($config === null) {
         $config = new LogWidgetConfig();
         $config->setWidgetInstance($instance);
     }
     if ($instance->isDesktop()) {
         $workspaces = array();
         $workspacesVisibility = array();
         if (!$instance->isAdmin()) {
             $workspaces = $this->workspaceManager->getWorkspacesByUserAndRoleNames($instance->getUser(), array('ROLE_WS_COLLABORATOR', 'ROLE_WS_MANAGER'));
             $workspacesVisibility = $this->logManager->getWorkspaceVisibilityForDesktopWidget($instance->getUser(), $workspaces);
         }
         $workspacesVisibility['amount'] = $config->getAmount();
         $form = $this->formFactory->create(new LogDesktopWidgetConfigType(), $workspacesVisibility, array('workspaces' => $workspaces));
         $content = $this->twig->render('ClarolineCoreBundle:Log:config_desktop_widget_form.html.twig', array('form' => $form->createView(), 'instance' => $instance));
     } else {
         $form = $this->formFactory->create($this->logWorkspaceWidgetConfigForm, $config);
         $content = $this->twig->render('ClarolineCoreBundle:Log:config_workspace_widget_form.html.twig', array('form' => $form->createView(), 'instance' => $instance));
     }
     $event->setContent($content);
 }
Пример #3
0
 public function copy(LogWidgetConfig $source = null)
 {
     if ($source !== null) {
         $this->setRestrictions($source->getRestrictions());
         $this->setAmount($source->getAmount());
     }
 }