HosipLan

Untitled

Apr 26th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1.  
  2.     /**
  3.      * @param array $values
  4.      * @final
  5.      * @throws DibiDriverException
  6.      */
  7.     final public function registration($values)
  8.     {
  9.        
  10.         unset($values['passwordAgain']);
  11.         unset($values['agree']);
  12.  
  13.         $values['hash'] = $this->genHash(32,15);
  14.         $values['registered'] = new DateTime;
  15.  
  16.         try {
  17.             return (bool)$this->db->insert(self::usersTable, $values)->execute();
  18.         } catch(DibiDriverException $e) {
  19.             throw new MyApp\NonUniqueRowException(NULL, 0, $e);
  20.         }
  21.     }
  22.  
  23.  
  24. ##########################
  25.  
  26.  
  27.  
  28.     /**
  29.      * @param string $name
  30.      */
  31.     protected function createComponentRegistration($name)
  32.     {
  33.         $form = new UsersRegistrationForm($this,$name);
  34.         $form->onSuccess[] = array($this, 'registrationSubmited');
  35.     }
  36.    
  37.      /**
  38.      * @param Form $form
  39.      */
  40.     public function registrationSubmited($form)
  41.     {  
  42.         if($form['register']->isSubmittedBy()) {
  43.             $values = $form->getValues();
  44.             $values['ip'] = $this->context->httpRequest->getRemoteAddress();
  45.             $values['password'] = $this->context->authenticator->calculateHash($values['password']);
  46.  
  47.         try {
  48.                 $this->db->registration($values);
  49.         $this->flashMessage('Registration successful to your email (' . $values['email'] . ') will be sent an authorization request, please confirm it. In the event of difficulties please contact us.');
  50.                 $this->redirect('this');
  51.  
  52.         } catch (MyApp\NonUniqueRowException $e)  {
  53.                 $form->addError('Such a name or email address already in use by someone else.');
  54.         } catch (Exception $e) {
  55.         $form->addError('What went wrong somewhere. Please try again repeated again after recording this event please contact us and we will solve the subsequent error.');
  56.         }
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment