Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param array $values
- * @final
- * @throws DibiDriverException
- */
- final public function registration($values)
- {
- unset($values['passwordAgain']);
- unset($values['agree']);
- $values['hash'] = $this->genHash(32,15);
- $values['registered'] = new DateTime;
- try {
- return (bool)$this->db->insert(self::usersTable, $values)->execute();
- } catch(DibiDriverException $e) {
- if ($e === \DibiMySqlDriver::ERROR_DUPLICATE_ENTRY) {
- throw new MyApp\NonUniqueRowException($e->getMessage(), 0, $e);
- } else {
- throw new MyApp\SqlException($e->getMessage(), 0, $e)
- }
- }
- }
- ##########################
- /**
- * @param string $name
- */
- protected function createComponentRegistration($name)
- {
- $form = new UsersRegistrationForm($this,$name);
- $form->onSuccess[] = array($this, 'registrationSubmited');
- }
- /**
- * @param Form $form
- */
- public function registrationSubmited($form)
- {
- if($form['register']->isSubmittedBy()) {
- $values = $form->getValues();
- $values['ip'] = $this->context->httpRequest->getRemoteAddress();
- $values['password'] = $this->context->authenticator->calculateHash($values['password']);
- try {
- $this->db->registration($values);
- $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.');
- $this->redirect('this');
- } catch (MyApp\NonUniqueRowException $e) {
- $form->addError('Such a name or email address already in use by someone else.');
- } catch (MyApp\SqlException $e) {
- $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.');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment