예제 #1
0
 /**
  * @Route("/add/user")
  * @Method("POST")
  */
 public function addUserAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $user = new \Club\UserBundle\Entity\User();
     $user->setMemberNumber($em->getRepository('ClubUserBundle:User')->findNextMemberNumber());
     $user->setPassword(1234);
     $em->persist($user);
     $em->flush();
     $profile = new \Club\UserBundle\Entity\Profile();
     $profile->setUser($user);
     $profile->setFirstName($this->getRequest()->get('first_name'));
     $profile->setLastName($this->getRequest()->get('last_name'));
     $profile->setGender($this->getRequest()->get('gender'));
     $profile->setDayOfBirth(new \DateTime($this->getRequest()->get('day_of_birth')));
     $em->persist($profile);
     $address = new \Club\UserBundle\Entity\ProfileAddress();
     $address->setProfile($profile);
     $address->setContactType('home');
     $address->setIsDefault(1);
     $address->setStreet($this->getRequest()->get('street'));
     $address->setPostalCode($this->getRequest()->get('postal_code'));
     $address->setCity($this->getRequest()->get('city'));
     $country = $em->getRepository('ClubUserBundle:Country')->findOneByCountry($this->getRequest()->get('country'));
     $address->setCountry($country);
     $em->persist($address);
     $user->setProfile($profile);
     $em->persist($user);
     $em->flush();
     return ($r = $this->hasErrors($user)) ? $r : $this->renderJSon($user->toArray());
 }
예제 #2
0
 /**
  * @Route("/installer/step/1")
  * @Template()
  */
 public function administratorAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     if ($this->get('session')->get('installer_user_id')) {
         $user = $em->find('ClubUserBundle:User', $this->get('session')->get('installer_user_id'));
     } else {
         $user = new \Club\UserBundle\Entity\User();
         $user->setMemberNumber($em->getRepository('ClubUserBundle:User')->findNextMemberNumber());
         $profile = new \Club\UserBundle\Entity\Profile();
         $user->setProfile($profile);
         $profile->setUser($user);
         $email = new \Club\UserBundle\Entity\ProfileEmail();
         $email->setContactType('home');
         $email->setProfile($profile);
         $profile->setProfileEmail($email);
     }
     $form = $this->createForm(new \Club\InstallerBundle\Form\AdministratorStep(), $user);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bindRequest($this->getRequest());
         if ($form->isValid()) {
             $group = $em->getRepository('ClubUserBundle:Group')->findOneBy(array('group_name' => 'Super Administrators'));
             $group->addUsers($user);
             $em->persist($user);
             $em->flush();
             $this->get('session')->set('installer_user_id', $user->getId());
             return $this->redirect($this->generateUrl('club_installer_installer_location'));
         }
     }
     return array('form' => $form->createView());
 }
예제 #3
0
 /**
  * @Route("/auth/register")
  * @Template()
  */
 public function registerAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $user = new \Club\UserBundle\Entity\User();
     $profile = new \Club\UserBundle\Entity\Profile();
     $user->setProfile($profile);
     $profile->setUser($user);
     $user = $this->getUser($user);
     $user->setMemberNumber($em->getRepository('ClubUserBundle:User')->findNextMemberNumber());
     $form = $this->createForm(new \Club\UserBundle\Form\User(), $user);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bindRequest($this->getRequest());
         if ($form->isValid()) {
             $em->persist($user);
             $em->flush();
             $this->get('session')->setFlash('notice', $this->get('translator')->trans('Your account has been created.'));
             $event = new \Club\UserBundle\Event\FilterUserEvent($user);
             $this->get('event_dispatcher')->dispatch(\Club\UserBundle\Event\Events::onUserNew, $event);
             return $this->redirect($this->generateUrl('homepage'));
         }
     }
     return array('form' => $form->createView());
 }
예제 #4
0
 protected function initUser()
 {
     $em = $this->getDoctrine()->getEntityManager();
     $user = new \Club\UserBundle\Entity\User();
     $user->setMemberNumber($em->getRepository('ClubUserBundle:User')->findNextMemberNumber());
     $profile = new \Club\UserBundle\Entity\Profile();
     $user->setProfile($profile);
     $profile->setUser($user);
     return $this->getUser($user);
 }
예제 #5
0
 /**
  * Remove users
  *
  * @param Club\UserBundle\Entity\User $users
  */
 public function removeUser(\Club\UserBundle\Entity\User $users)
 {
     $this->users->removeElement($users);
 }