Пример #1
0
 /**
  * To share question with other users
  *
  * @access public
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function shareQuestionUserAction()
 {
     $request = $this->container->get('request');
     if ($request->isXmlHttpRequest()) {
         $questionID = $request->request->get('questionID');
         // Which question is shared
         $uid = $request->request->get('uid');
         $allowToModify = $request->request->get('allowToModify');
         $em = $this->getDoctrine()->getManager();
         $question = $em->getRepository('UJMExoBundle:Question')->findOneBy(array('id' => $questionID));
         $user = $em->getRepository('ClarolineCoreBundle:User')->find($uid);
         $share = $em->getRepository('UJMExoBundle:Share')->findOneBy(array('user' => $user, 'question' => $question));
         if (!$share) {
             $share = new Share($user, $question);
         }
         $share->setAllowToModify($allowToModify);
         $em->persist($share);
         $em->flush();
         return new \Symfony\Component\HttpFoundation\Response('no;' . $this->generateUrl('ujm_question_index'));
     }
 }