コード例 #1
0
ファイル: User.php プロジェクト: NguyenQuiDuong/Funixtest
 /**
  * @param \User\Model\User $user
  */
 public function signup(\User\Model\User $user)
 {
     $user->setSalt(substr(md5(time() . rand(2000, 5000)), 0, 20));
     $user->setCreatedDate(DateBase::getCurrentDate());
     $user->setCreatedDateTime(DateBase::getCurrentDateTime());
     $user->setPassword(md5($user->getSalt() . $user->getPassword()));
     $user->setRegisteredDate(date('Y-m-d'));
     $user->setRegisteredFrom(str_replace('www.', '', strtolower($_SERVER['HTTP_HOST'])));
     $user->setActiveKey(md5($user->getUsername() . $user->getPassword() . time()));
     $user->setActiveLink('http://' . $_SERVER['HTTP_HOST'] . '/user/active?u=' . $user->getUsername() . '&c=' . $user->getActiveKey());
     $user->setRole(\User\Model\User::ROLE_MEMBER);
     $sl = $this->getServiceLocator();
     $translator = $this->getServiceLocator()->get('translator');
     /** @var $mapper \User\Model\UserMapper */
     $mapper = $sl->get('User\\Model\\Usermapper');
     $mapper->save($user);
 }