private function populateUserWithSubmitedDatas()
 {
     $this->newUser = new User();
     if (isset($this->submitDatas['enabled'])) {
         $this->newUser->setEnabled($this->submitDatas['enabled']);
     }
     $this->newUser->setNickname($this->submitDatas['first_name']);
     $this->newUser->setName($this->submitDatas['last_name']);
     $this->newUser->setEmail($this->submitDatas['email']);
     //
     $this->newUser->addRole($this->submitDatas['connexion']['role']);
     $this->newUser->setUsername($this->submitDatas['connexion']['username']);
     $this->newUser->setPlainPassword($this->submitDatas['connexion']['password']);
     if (isset($this->submitDatas['location'])) {
         $this->newUser->setAddress($this->submitDatas['location']['address']);
         $this->newUser->setZipCode($this->submitDatas['location']['cp']);
         $this->newUser->setCity($this->submitDatas['location']['city']);
         if (isset($this->submitDatas['location']['country'])) {
             $this->newUser->setCountry($this->submitDatas['location']['country']);
         }
     }
     if (isset($this->submitDatas['birthday'])) {
         $this->newUser->setBirthday($this->submitDatas['birthday']);
     }
     if (isset($this->submitDatas['global_optin'])) {
         $this->newUser->setGlobalOptIn($this->submitDatas['global_optin']);
     }
     if (isset($this->submitDatas['site_optin'])) {
         $this->newUser->setSiteOptIn($this->submitDatas['site_optin']);
     }
 }
Пример #2
0
 /**
  * Displays a form to create a new user entity.
  *
  * @Secure(roles="ROLE_EDITOR")
  * @return \Symfony\Component\HttpFoundation\Response
  * @access    public
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function newAction()
 {
     // we create entity
     $entity = new User();
     $entity->setPermissions(array('VIEW', 'EDIT', 'CREATE', 'DELETE'));
     // we set form
     $form = $this->createForm(new UsersNewFormType(), $entity);
     return $this->render(str_replace('::', ':', $this->container->getParameter('sfynx.auth.theme.login')) . 'Users:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'NoLayout' => $this->container->get('request')->query->get('NoLayout')));
 }
Пример #3
0
 /**
  * @return array
  */
 public function jsonSerialize()
 {
     $userInArray = array('isconnected' => $this->user->isConnected($this->expired), 'userid' => $this->user->getId(), 'enabled' => $this->user->getEnabled(), 'username' => $this->user->getUserName(), 'lastname' => $this->user->getName() ? $this->user->getName() : $this->user->getUserName(), 'firstname' => $this->user->getNickname(), 'email' => $this->user->getEmail(), 'address' => $this->user->getAddress(), 'cp' => $this->user->getZipCode(), 'city' => $this->user->getCity(), 'country' => $this->user->getCountry(), 'lang_code' => $this->user->getLangCode() instanceof Langue ? $this->user->getLangCode()->getId() : "", 'birthday' => $this->user->getBirthday(), 'global_optin' => $this->user->getGlobalOptIn(), 'site_optin' => $this->user->getSiteOptIn(), 'created_at' => $this->user->getCreatedAt(), 'updated_at' => $this->user->getUpdatedAt(), 'error' => $this->getError());
     return json_encode($userInArray);
 }
Пример #4
0
 public function testIsConnected()
 {
     $user = new User();
     $this->assertFalse($user->isConnected());
     $date = new \DateTime();
     $user->setLastLogin($date);
     $this->assertTrue($user->isConnected());
     $date->add(new \DateInterval('PT3600S'));
     $user->setLastLogin($date);
     $this->assertTrue($user->isConnected());
     $date->sub(new \DateInterval('PT7200S'));
     $user->setLastLogin($date);
     $this->assertFalse($user->isConnected());
 }