コード例 #1
0
 /**
  * If question already shared with a given user
  *
  * @access public
  *
  * @param \UJM\ExoBundle\Entity\Share $toShare
  * @param Doctrine Entity Manager $em
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function alreadySharedAction($toShare, $em)
 {
     $alreadyShared = $em->getRepository('UJMExoBundle:Share')->findAll();
     $already = false;
     $end = count($alreadyShared);
     for ($i = 0; $i < $end; $i++) {
         if ($alreadyShared[$i]->getUser() == $toShare->getUser() && $alreadyShared[$i]->getQuestion() == $toShare->getQuestion()) {
             $already = true;
             break;
         }
     }
     if ($already == true) {
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
 /**
  * For an shared interaction whith me, know if it's linked with response and if I can modify it.
  *
  *
  * @param Doctrine EntityManager      $em
  * @param \UJM\ExoBundle\Entity\Share $shared
  *
  * @return array
  */
 public function getActionShared($shared)
 {
     $em = $this->doctrine->getEntityManager();
     $question = $shared->getQuestion();
     $sharedWithMe[$shared->getQuestion()->getId()] = $question;
     $shareRight[$question->getId()] = $shared->getAllowToModify();
     $response = $em->getRepository('UJMExoBundle:Response')->findOneByQuestion($question);
     if ($question) {
         $questionWithResponse[$question->getId()] = 1;
     } else {
         $questionWithResponse[$question->getId()] = 0;
     }
     $actionsS[0] = $sharedWithMe;
     $actionsS[1] = $shareRight;
     $actionsS[2] = $questionWithResponse;
     return $actionsS;
 }
コード例 #3
0
 /**
  * For an shared interaction whith me, know if it's linked with response and if I can modify it
  *
  * @access public
  *
  * @param Doctrine EntityManager $em
  * @param \UJM\ExoBundle\Entity\Share $shared
  *
  * @return array
  */
 public function getActionShared($em, $shared)
 {
     $inter = $em->getRepository('UJMExoBundle:Interaction')->findOneBy(array('question' => $shared->getQuestion()->getId()));
     $sharedWithMe[$shared->getQuestion()->getId()] = $inter;
     $shareRight[$inter->getId()] = $shared->getAllowToModify();
     $response = $em->getRepository('UJMExoBundle:Response')->findBy(array('interaction' => $inter->getId()));
     if (count($response) > 0) {
         $questionWithResponse[$inter->getId()] = 1;
     } else {
         $questionWithResponse[$inter->getId()] = 0;
     }
     $actionsS[0] = $sharedWithMe;
     $actionsS[1] = $shareRight;
     $actionsS[2] = $questionWithResponse;
     return $actionsS;
 }