/** * Loads the core Home Tabs. * * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $translator = $this->container->get('translator'); $infoName = $translator->trans('informations', array(), 'platform'); $desktopHomeTab = new HomeTab(); $desktopHomeTab->setType('admin_desktop'); $desktopHomeTab->setName($infoName); $manager->persist($desktopHomeTab); $desktopHomeTabConfig = new HomeTabConfig(); $desktopHomeTabConfig->setHomeTab($desktopHomeTab); $desktopHomeTabConfig->setType('admin_desktop'); $desktopHomeTabConfig->setVisible(true); $desktopHomeTabConfig->setLocked(false); $desktopHomeTabConfig->setTabOrder(1); $manager->persist($desktopHomeTabConfig); $workspaceHomeTab = new HomeTab(); $workspaceHomeTab->setType('admin_workspace'); $workspaceHomeTab->setName($infoName); $manager->persist($workspaceHomeTab); $workspaceHomeTabConfig = new HomeTabConfig(); $workspaceHomeTabConfig->setHomeTab($workspaceHomeTab); $workspaceHomeTabConfig->setType('admin_workspace'); $workspaceHomeTabConfig->setVisible(true); $workspaceHomeTabConfig->setLocked(false); $workspaceHomeTabConfig->setTabOrder(1); $manager->persist($workspaceHomeTabConfig); }
public function load(ObjectManager $manager) { $repository = $manager->getRepository('Claroline\\CoreBundle\\Entity\\ContentTranslation'); //mails $frTitle = 'Inscription à %platform_name%'; $frContent = "<div>Votre nom d'utilisateur est %username%</div></br>"; $frContent .= "<div>Votre mot de passe est %password%</div>"; $frContent .= "<div>%validation_mail%</div>"; $enTitle = 'Registration to %platform_name%'; $enContent = "<div>You username is %username%</div></br>"; $enContent .= "<div>Your password is %password%</div>"; $enContent .= "<div>%validation_mail%</div>"; $type = 'claro_mail_registration'; $content = new Content(); $content->setTitle($enTitle); $content->setContent($enContent); $content->setType($type); $repository->translate($content, 'title', 'fr', $frTitle); $repository->translate($content, 'content', 'fr', $frContent); $manager->persist($content); //layout $frLayout = '<div></div>%content%<div></hr>Powered by %platform_name%</div>'; $enLayout = '<div></div>%content%<div></hr>Powered by %platform_name%</div>'; $layout = new Content(); $layout->setContent($enLayout); $layout->setType('claro_mail_layout'); $repository->translate($layout, 'content', 'fr', $frLayout); $manager->persist($layout); $manager->flush(); }
/** * @param string $name * * @return Role */ public function role($name) { $role = new Role(); $role->setName($name); $role->setTranslationKey($name); $this->om->persist($role); return $role; }
/** * Returns the contents of a hint and records a log asserting that the hint * has been consulted for a given paper. * * @param Paper $paper * @param Hint $hint * * @return string */ public function viewHint(Paper $paper, Hint $hint) { $log = $this->om->getRepository('UJMExoBundle:LinkHintPaper')->findOneBy(['paper' => $paper, 'hint' => $hint]); if (!$log) { $log = new LinkHintPaper($hint, $paper); $this->om->persist($log); $this->om->flush(); } return $hint->getValue(); }
public function chapter($title, $text, $lesson, $root) { $chapter = new Chapter(); $chapter->setTitle($title); $chapter->setText($text); $chapter->setLesson($lesson); $this->om->persist($chapter); $this->om->flush(); return $chapter; }
/** * Subscribes a Use to an Exercise. * * @param Exercise $exercise * @param User $user * @param bool $flush * * @return SubscriptionManager */ public function subscribe(Exercise $exercise, User $user, $flush = false) { $subscription = new Subscription(); $subscription->setUser($user); $subscription->setExercise($exercise); $subscription->setAdmin(true); $subscription->setCreator(true); $this->om->persist($subscription); if ($flush) { $this->om->flush(); } return $this; }
public function updateIcons() { $this->log('updating icons...'); $mimetypes = array('application/illustrator', 'application/ai'); foreach ($mimetypes as $mimetype) { $icon = new ResourceIcon(); $icon->setRelativeUrl('bundles/clarolinecore/images/resources/icons/res_vector.png'); $icon->setMimeType($mimetype); $icon->setShortcut(false); $this->om->persist($icon); $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon); } }
public function postUpdate() { $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/"; $images = array(array('res_mspowerpoint.png', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'), array('res_msword.png', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')); $this->log('Adding new resource icons...'); foreach ($images as $image) { $rimg = new ResourceIcon(); $rimg->setRelativeUrl($coreIconWebDirRelativePath . $image[0]); $rimg->setMimeType($image[1]); $rimg->setShortcut(false); $this->objectManager->persist($rimg); $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg); } $this->objectManager->flush(); }
public function deactivatePersonalWorkspaceRightsPerm(Role $role) { $access = $this->getPwsRightsManagementAccess($role); $access->setIsAccessible(false); $this->om->persist($access); $this->om->flush(); }
public function postUpdate() { $installedBundles = $this->container->getParameter('kernel.bundles'); if (isset($installedBundles['IcapPortfolioBundle'])) { $icapPortfolioPlugin = $this->om->getRepository('ClarolineCoreBundle:Plugin')->findOneByBundleFQCN($installedBundles['IcapPortfolioBundle']); if (null === $icapPortfolioPlugin) { $this->log(' Creation of Portfolio plugin in database.'); $icapPortfolioPlugin = new Plugin(); $icapPortfolioPlugin->setVendorName('Icap'); $icapPortfolioPlugin->setBundleName('PortfolioBundle'); $icapPortfolioPlugin->setHasOptions(false); $this->om->persist($icapPortfolioPlugin); $this->om->flush(); } } }
/** * Update the Exercise metadata. * * @param Exercise $exercise * @param \stdClass $metadata * * @throws ValidationException */ public function updateMetadata(Exercise $exercise, \stdClass $metadata) { $errors = $this->validator->validateExerciseMetadata($metadata); if (count($errors) > 0) { throw new ValidationException('Exercise metadata are not valid', $errors); } // Update ResourceNode $node = $exercise->getResourceNode(); $node->setName($metadata->title); // Update Exercise $exercise->setDescription($metadata->description); $exercise->setType($metadata->type); $exercise->setPickSteps($metadata->pick ? $metadata->pick : 0); $exercise->setShuffle($metadata->random); $exercise->setKeepSteps($metadata->keepSteps); $exercise->setMaxAttempts($metadata->maxAttempts); $exercise->setLockAttempt($metadata->lockAttempt); $exercise->setDispButtonInterrupt($metadata->dispButtonInterrupt); $exercise->setMetadataVisible($metadata->metadataVisible); $exercise->setMarkMode($metadata->markMode); $exercise->setCorrectionMode($metadata->correctionMode); $exercise->setAnonymous($metadata->anonymous); $exercise->setDuration($metadata->duration); $exercise->setStatistics($metadata->statistics ? true : false); $exercise->setMinimalCorrection($metadata->minimalCorrection ? true : false); $correctionDate = null; if (!empty($metadata->correctionDate) && CorrectionMode::AFTER_DATE === $metadata->correctionMode) { $correctionDate = \DateTime::createFromFormat('Y-m-d\\TH:i:s', $metadata->correctionDate); } $exercise->setDateCorrection($correctionDate); // Save to DB $this->om->persist($exercise); $this->om->flush(); }
public function setHomepage(Website $website, WebsitePage $page) { $website->setHomePage($page); $page->setIsHomepage(true); $this->objectManager->persist($page); $this->objectManager->persist($website); $this->objectManager->flush(); }
public function refresh(ResourceIcon $icon) { $shortcut = $icon->getShortcutIcon(); $newUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl()); $shortcut->setRelativeUrl($newUrl); $this->om->persist($shortcut); $this->om->flush(); }
public function load(ObjectManager $manager) { $themes = $this->container->get('claroline.manager.theme_manager')->listStockThemeNames(); foreach ($themes as $name) { $theme = new Theme(); $theme->setName($name); $manager->persist($theme); } }
public function hint(Question $question, $text, $penalty = 1) { $hint = new Hint(); $hint->setValue($text); $hint->setPenalty($penalty); $hint->setQuestion($question); $this->om->persist($hint); return $hint; }
public function load(ObjectManager $manager) { $names = array('header', 'left', 'content', 'right', 'footer'); foreach ($names as $name) { $region = new Region(); $region->setName($name); $manager->persist($region); } }
public function load(ObjectManager $manager) { $fixtures = array('home', 'menu'); foreach ($fixtures as $i => $fixture) { $types[$i] = new Type(); $types[$i]->setName($fixture); $types[$i]->setPublish(true); $manager->persist($types[$i]); } }
public function load(ObjectManager $manager) { $themes = array('Claroline' => 'ClarolineCoreBundle:less:claroline/theme.html.twig', 'Claroline Orange' => 'ClarolineCoreBundle:less:claroline-orange/theme.html.twig', 'Claroline Mint' => 'ClarolineCoreBundle:less:claroline-mint/theme.html.twig', 'Claroline Gold' => 'ClarolineCoreBundle:less:claroline-gold/theme.html.twig', 'Claroline Ruby' => 'ClarolineCoreBundle:less:claroline-ruby/theme.html.twig', 'Claroline Black' => 'ClarolineCoreBundle:less:claroline-black/theme.html.twig', 'Claroline Dark' => 'ClarolineCoreBundle:less:claroline-dark/theme.html.twig', 'Bootstrap Default' => 'ClarolineCoreBundle:less:bootstrap-default/theme.html.twig'); foreach ($themes as $name => $path) { $theme[$name] = new Theme(); $theme[$name]->setName($name); $theme[$name]->setPath($path); $manager->persist($theme[$name]); } }
public function load(ObjectManager $manager) { $tools = array(array('platform_parameters', 'cog'), array('user_management', 'user'), array('workspace_management', 'book'), array('registration_to_workspace', 'book'), array('platform_packages', 'wrench'), array('desktop_and_home', 'home'), array('desktop_tools', 'pencil'), array('platform_logs', 'bars'), array('platform_analytics', 'bar-chart-o'), array('roles_management', 'users'), array('widgets_management', 'list-alt')); foreach ($tools as $tool) { $entity = new AdminTool(); $entity->setName($tool[0]); $entity->setClass($tool[1]); $manager->persist($entity); } $manager->flush(); }
public function load(ObjectManager $manager) { $tools = array(array('platform_parameters', 'cog'), array('user_management', 'user'), array('workspace_management', 'book'), array('registration_to_workspace', 'book'), array('desktop_and_home', 'home'), array('platform_logs', 'bars'), array('platform_analytics', 'bar-chart-o'), array('roles_management', 'users'), array('widgets_management', 'list-alt'), array('organization_management', 'institution')); foreach ($tools as $tool) { $entity = new AdminTool(); $entity->setName($tool[0]); $entity->setClass($tool[1]); $manager->persist($entity); } $manager->flush(); $this->container->get('claroline.manager.administration_manager')->addDefaultAdditionalActions(); }
public function postUpdate() { $this->log('Updating cache...'); $this->container->get('claroline.manager.cache_manager')->refresh(); $this->log('Removing old cache...'); if (file_exists($this->oldCachePath)) { unlink($this->oldCachePath); } $this->log('Creating admin tools...'); $tools = array(array('platform_parameters', 'icon-cog'), array('user_management', 'icon-user'), array('workspace_management', 'icon-book'), array('badges_management', 'icon-trophy'), array('registration_to_workspace', 'icon-book'), array('platform_plugins', 'icon-wrench'), array('home_tabs', 'icon-th-large'), array('desktop_tools', 'icon-pencil'), array('platform_logs', 'icon-reorder'), array('platform_analytics', 'icon-bar-chart'), array('roles_management', 'icon-group')); $existingTools = $this->objectManager->getRepository('ClarolineCoreBundle:Tool\\AdminTool')->findAll(); if (count($existingTools) === 0) { foreach ($tools as $tool) { $entity = new AdminTool(); $entity->setName($tool[0]); $entity->setClass($tool[1]); $this->objectManager->persist($entity); } } $this->objectManager->flush(); }
private function websitePlugin() { $plugin = $this->om->getRepository('ClarolineCoreBundle:Plugin')->findOneByBundleName('WebsiteBundle'); if (!$plugin) { $plugin = new Plugin(); $plugin->setVendorName('Icap'); $plugin->setBundleName('WebsiteBundle'); $plugin->setHasOptions(false); $this->om->persist($plugin); } return $plugin; }
/** * Update a content translation. * * @param Content $content A content entity * @param array $translation array('content' => 'foo', 'title' => 'foo') * @param string $locale A string with a locale value as 'en' or 'fr' * @param bool $reset A boolean in case of you whant to reset the values of the translation */ private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle($reset ? null : $translation['title']); } if (isset($translation['content'])) { $content->setContent($reset ? null : $translation['content']); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }
/** * @param ObjectManager $manager */ public function load(ObjectManager $manager) { $coreIconWebDirRelativePath = 'bundles/clarolinecore/images/resources/icons/'; $resourceImages = $this->container->get('claroline.manager.icon_manager')->getDefaultIconMap(); foreach ($resourceImages as $resourceImage) { $rimg = new ResourceIcon(); $rimg->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]); $rimg->setMimeType($resourceImage[1]); $rimg->setShortcut(false); $manager->persist($rimg); $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg); } }
private function showTermOfServices(GetResponseEvent $event) { if ($event->isMasterRequest() && ($user = $this->getUser($event->getRequest())) && !$user->hasAcceptedTerms() && !$this->isImpersonated() && ($content = $this->termsOfService->getTermsOfService(false))) { if (($termsOfService = $event->getRequest()->get('accept_terms_of_service_form')) && isset($termsOfService['terms_of_service'])) { $user->setAcceptedTerms(true); $this->manager->persist($user); $this->manager->flush(); } else { $form = $this->formFactory->create(new TermsOfServiceType(), $content); $response = $this->templating->render('ClarolineCoreBundle:Authentication:termsOfService.html.twig', ['form' => $form->createView()]); $event->setResponse(new Response($response)); } } }
private function updateWorkspace(ResourceNode $node, Workspace $workspace) { $this->om->startFlushSuite(); $node->setWorkspace($workspace); $this->om->persist($node); if ($node->getResourceType()->getName() === 'directory') { $children = $this->resourceNodeRepo->getChildren($node); foreach ($children as $child) { $child->setWorkspace($workspace); $this->om->persist($child); } } $this->om->endFlushSuite(); }
public function updateIcons() { $this->log('updating icons...'); $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/"; $resourceImages = array(array('res_vector.png', 'application/postscript'), array('res_vector.png', 'image/svg+xml'), array('res_zip.png', 'application/zip'), array('res_zip.png', 'application/x-rar-compressed'), array('res_archive.png', 'application/x-gtar'), array('res_archive.png', 'application/x-7z-compressed')); foreach ($resourceImages as $resourceImage) { $icon = new ResourceIcon(); $icon->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]); $icon->setMimeType($resourceImage[1]); $icon->setShortcut(false); $this->om->persist($icon); $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon); } }
/** * @param Question $question * @param Paper $paper * @param int $score */ public function recordScore(Question $question, Paper $paper, $score) { /** @var Response $response */ $response = $this->om->getRepository('UJMExoBundle:Response')->findOneBy(['paper' => $paper, 'question' => $question]); $response->setMark($score); // Apply penalties to the score $this->applyPenalties($paper, $question, $response); $scorePaper = $paper->getScore(); $scoreExercise = $scorePaper + $response->getMark(); $paper->setScore($scoreExercise); $this->om->persist($paper); $this->om->persist($response); $this->om->flush(); $this->checkPaperEvaluated($paper); }
/** * create the exercise. * * @param array $step - properties of the step * @param Exercise $exercise * * @return Step */ private function createStep(array $step, Exercise $exercise) { $newStep = new Step(); $newStep->setText($step['text']); $newStep->setOrder($step['order']); $newStep->setShuffle($step['shuffle']); $newStep->setNbQuestion($step['nbQuestion']); $newStep->setKeepSameQuestion($step['keepSameQuestion']); $newStep->setDuration($step['duration']); $newStep->setMaxAttempts($step['maxAttempts']); $newStep->setExercise($exercise); $this->om->persist($newStep); $this->om->flush(); return $newStep; }
/** * @param UploadedFile $file * @param BlogOptions $options */ public function updateBanner(UploadedFile $file = null, BlogOptions $options) { $ds = DIRECTORY_SEPARATOR; if (file_exists($this->uploadDir . $ds . $options->getBannerBackgroundImage()) || $file === null) { @unlink($this->uploadDir . $ds . $options->getBannerBackgroundImage()); } if ($file) { $uniqid = uniqid(); $options->setBannerBackgroundImage($uniqid); $file->move($this->uploadDir, $uniqid); } else { $options->setBannerBackgroundImage(null); } $this->objectManager->persist($options); $this->objectManager->flush(); }