public function search(Forum $forum, $content, $getQuery = true) { $dql = "SELECT m FROM Claroline\\ForumBundle\\Entity\\Message m\n JOIN m.subject s\n JOIN s.category c\n JOIN c.forum f\n WHERE m.content LIKE :content\n and f.id = {$forum->getId()}\n "; $query = $this->_em->createQuery($dql); $query->setParameter('content', '%' . $content . '%'); return $getQuery ? $query : $query->getResult(); }
public function load(ObjectManager $manager) { $creator = $this->getContainer()->get('claroline.manager.resource_manager'); $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $user = $em->getRepository('ClarolineCoreBundle:User')->findOneBy(array('username' => $this->username)); if ($this->parent == null) { $root = $em->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneBy(array('parent' => null, 'workspace' => $user->getPersonalWorkspace()->getId())); } else { $root = $this->parent; } $collaborators = $em->getRepository('ClarolineCoreBundle:User')->findByWorkspace($root->getWorkspace()); $maxOffset = count($collaborators); $this->log('collaborators found: ' . count($collaborators)); --$maxOffset; $forum = new Forum(); $forum->setName($this->forumName); $forum = $creator->create($forum, $manager->getRepository('ClarolineCoreBundle:Resource\\ResourceType')->findOneByName('claroline_forum'), $user, $root->getWorkspace(), $root); $forumManager = $this->getContainer()->get('claroline.manager.forum_manager'); $category = $forumManager->createCategory($forum, $this->forumName); $this->log("forum {$forum->getName()} created"); for ($i = 0; $i < $this->nbSubjects; ++$i) { $title = $this->container->get('claroline.utilities.lipsum_generator')->generateLipsum(5, false, 255); $user = $collaborators[rand(0, $maxOffset)]; $subject = new Subject(); $subject->setTitle($title); $subject->setCreator($user); $this->log("subject {$title} created"); $subject->setCategory($category); $manager->persist($subject); for ($j = 0; $j < $this->nbMessages; ++$j) { $sender = $collaborators[rand(0, $maxOffset)]; $message = new Message(); $message->setSubject($subject); $message->setCreator($sender); $lipsum = $this->container->get('claroline.utilities.lipsum_generator')->generateLipsum(150, true, 1023); $message->setContent($lipsum); $manager->persist($message); } $manager->flush(); } $manager->flush(); $this->addReference("forum/{$this->forumName}", $forum); }
public function disableGlobalNotifications(Forum $forum) { $this->om->startFlushSuite(); $forum->setActivateNotifications(false); $this->om->persist($forum); $notifications = $this->forumRepo->findNonSelfNotificationsByForum($forum); foreach ($notifications as $notification) { $this->removeNotification($forum, $notification); } $this->om->endFlushSuite(); }
/** * @param Forum $forum */ public function __construct(Forum $forum) { $details = array('forum' => array('id' => $forum->getId())); parent::__construct($forum->getResourceNode(), $details); }
/** * @EXT\Route( * "/{forum}/notifications/disable", * name="claro_forum_disable_global_notifications" * ) * * @param Forum $forum */ public function disableGlobalNotificationsAction(Forum $forum) { $collection = new ResourceCollection(array($forum->getResourceNode())); if (!$this->authorization->isGranted('MODERATE', $collection)) { throw new AccessDeniedException($collection->getErrorsForDisplay()); } $this->forumManager->disableGlobalNotifications($forum); return new RedirectResponse($this->generateUrl('claro_forum_categories', array('forum' => $forum->getId()))); }