Пример #1
0
 public function ajouterPhotoUAction($id)
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     if ($id != 0) {
         $user = $em->getRepository('fsmUserBundle:user')->find($id);
     }
     $photo = new Photo();
     $photo->setUser($user);
     $liste_photo = $this->getDoctrine()->getManager()->getRepository('fsmUserBundle:user')->getUserPhotoP($id);
     //        var_dump($liste_photo);
     //Attribution automatique de la valeur principale ou non d'une photo
     $test = $this->isPrincipale($user);
     $photo->setPrincipal($test);
     $form = $this->createForm(new PhotoType(), $photo);
     $em = $this->getDoctrine()->getManager();
     $formHandler = new FormHandler($form, $this->get('request'), $em);
     if ($formHandler->process()) {
         if ($user->getHabilite() == FALSE) {
             return $this->render('fsmUserBundle:Default:habilite.html.twig');
             $objetmail = 'user à habilite';
             $destinataire = '*****@*****.**';
             $texte = 'les globs attaquent la plage';
             $message = \Swift_Message::newInstance()->setSubject($objetmail)->setFrom('*****@*****.**')->setTo($destinataire)->setBody($this->renderView('fsmUserBundle:Default:mailuser.html.twig', array('textemail' => $texte)));
             $mailer = $this->get('mailer');
             $type = $message->getHeaders()->get('Content-Type');
             $type->setValue('text/html');
             $type->setParameter('charset', 'utf-8');
             $result = $mailer->send($message);
         }
         return $this->redirect($this->generateUrl('fos_user_profile_edit'));
     }
     return $this->render('fsmEchangeBundle:Photos:ajouter.html.twig', array('form' => $form->createView(), 'objetphotos' => $liste_photo));
 }
Пример #2
0
 /**
  * @Route("/updateObjet{id}", name="fsm_objet_update") 
  */
 public function updateObjetAction($id)
 {
     $autorisation = $this->container->get('fsm_Echange.habilitation')->Autorisation();
     if ($autorisation === 'OK') {
         $em = $this->getDoctrine()->getManager();
         $Objet = $em->getRepository('fsmEchangeBundle:Objet')->find($id);
         $form = $this->createForm(new ObjetType(), $Objet);
         $formHandler = new FormHandler($form, $this->get('request'), $em);
         if ($formHandler->process()) {
             return $this->redirect($this->generateUrl('fsm_photo_ajout_O', array('id' => $Objet->getId())));
         }
         return $this->render('fsmEchangeBundle:Objets:ajouter.html.twig', array('form' => $form->createView()));
     } else {
         return $this->render('fsmEchangeBundle:Default:habilite.html.twig');
     }
 }
Пример #3
0
 public function ajouterPhotoUAction($id)
 {
     //        $user = new User();
     $user = $this->getDoctrine()->getManager()->getRepository("fsmUserBundle:User")->find($id);
     $photo = new Photo($user);
     $photo->setUser($user);
     $liste_photo = $this->getDoctrine()->getManager()->getRepository('fsmEchangeBundle:Photo')->getPhotoByUser($user);
     //Attribution automatique de la valeur principale ou non d'une photo
     $test = $this->isPrincipale($user);
     $photo->setPrincipal($test);
     $form = $this->createForm(new PhotoType(), $photo);
     $em = $this->getDoctrine()->getManager();
     $formHandler = new FormHandler($form, $this->get('request'), $em);
     if ($formHandler->process()) {
         return $this->redirect($this->generateUrl('fos_user_profile_edit'));
     }
     return $this->render('fsmEchangeBundle:Photos:ajouter.html.twig', array('form' => $form->createView(), 'objetphotos' => $liste_photo));
 }