public function postPersist(Chapter $chapter, LifecycleEventArgs $event)
 {
     $userPicker = $chapter->getUserPicker();
     $lesson = $chapter->getLesson();
     if ($userPicker !== null && count($userPicker->getUserIds()) > 0 && $lesson->getResourceNode() !== null) {
         $details = array('chapter' => array('lesson' => $lesson->getId(), 'chapter' => $chapter->getId(), 'title' => $chapter->getTitle()), 'resource' => array('id' => $lesson->getId(), 'name' => $lesson->getResourceNode()->getName(), 'type' => $lesson->getResourceNode()->getResourceType()->getName()));
         $notification = $this->notificationManager->createNotification('resource-icap_lesson-user_tagged', 'lesson', $lesson->getResourceNode()->getId(), $details);
         $this->notificationManager->notifyUsers($notification, $userPicker->getUserIds());
     }
 }
Exemple #2
0
 /**
  * Copy chapter_org subchapters into provided chapter_copy
  * @param Chapter $chapter_org
  * @param Chapter $parent
  * @param boolean $copy_children
  * @param Lesson $copyName
  *
  * @return Chapter $chapter_copy
  */
 public function copyChapter(Chapter $chapter_org, Chapter $parent, $copy_children, $copyName = null)
 {
     $chapter_copy = new Chapter();
     if (!$copyName) {
         $copyName = $chapter_org->getTitle();
     }
     $chapter_copy->setTitle($copyName);
     $chapter_copy->setText($chapter_org->getText());
     $chapter_copy->setLesson($parent->getLesson());
     $this->insertChapter($chapter_copy, $parent);
     if ($copy_children) {
         $this->copyChildren($chapter_org, $chapter_copy, $copy_children);
     }
     return $chapter_copy;
 }
 /**
  * @param Lesson  $lesson
  * @param Chapter $chapter
  */
 public function __construct(Lesson $lesson, Chapter $chapter)
 {
     $this->lesson = $lesson;
     $this->details = array('chapter' => array('lesson' => $lesson->getId(), 'chapter' => $chapter->getId(), 'title' => $chapter->getTitle()));
     parent::__construct($lesson->getResourceNode(), $this->details);
 }
 /**
  * @param Lesson  $lesson
  * @param Chapter $chapter
  * @param Chapter $oldparent
  * @param Chapter $newparent
  */
 public function __construct(Lesson $lesson, Chapter $chapter, Chapter $oldparent, Chapter $newparent)
 {
     $details = array('chapter' => array('lesson' => $lesson->getId(), 'chapter' => $chapter->getId(), 'title' => $chapter->getTitle(), 'old_parent' => $oldparent->getTitle(), 'new_parent' => $newparent->getTitle()));
     parent::__construct($lesson->getResourceNode(), $details);
 }
 /**
  * @Delete("/chapters/{lesson}/{chapter}",
  *      requirements={"lesson" = "\d+"})
  * @ParamConverter("lesson", class="IcapLessonBundle:Lesson")
  * @ParamConverter("chapter", class="IcapLessonBundle:Chapter", options={"mapping": {"chapter": "slug"}})
  */
 public function deleteChapterAction(Lesson $lesson, Chapter $chapter)
 {
     // CHECK ACCESS
     $this->apiCheckAccess('EDIT', $lesson);
     $translator = $this->get('translator');
     $message = null;
     $chapterTitle = $chapter->getTitle();
     // DELETE request doesn't allow to send body params, so we have to rely on a query param instead
     $deleteChildren = $this->request->query->get('deleteChildren');
     $em = $this->getDoctrine()->getManager();
     $repo = $em->getRepository('IcapLessonBundle:Chapter');
     if ($deleteChildren == 'true') {
         $em->remove($chapter);
         $message = $translator->trans('Your chapter has been deleted', array(), 'icap_lesson');
     } else {
         $repo->removeFromTree($chapter);
         $message = $translator->trans('Your chapter has been deleted but no subchapter', array(), 'icap_lesson');
     }
     $em->flush();
     $this->dispatchChapterDeleteEvent($lesson, $chapterTitle);
     return array('message' => $message);
 }