Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as PHP by 222 ( 14 years ago )
<?php
class Module_User_Controller_FrontendRegistration extends Module_Common_Controller_Common
{
/**
* Объект пользователя, которого пытаемся зарегестрировать.
* @var Module_User_Model_User
*/
private $user;
/**
* User Mapper
* @var Module_User_Mapper_User
*/
private $Module_User_Mapper_User;
public function run()
{
parent::run();
if (!$this->current_user->isGuest())
{
$this->response->setHeader('Location', '/my/info/');
return;
}
$this->createView();
$this->view->loadI18n('common/controller/frontend_general',
'user/controller/registration');
$this->view->getHelper('Html_Title')->add( $this->view->lang->main_title );
$this->view->getHelper('Html_Title')->add( $this->view->lang->controller_title );
$this->Module_User_Mapper_User = new Module_User_Mapper_User();
if (!isset($this->user))
{
$this->user = $this->Module_User_Mapper_User->createNew();
}
if (Http_Request::isPost())
{
$this->post();
}
$this->view->user = $this->user;
}
private function post()
{
$this->user = $this->Module_User_Mapper_User->createFromCover($this->request->getPost()->user);
$validator = new Validator_Chain('common/general', 'user/registration');
$validator->add('user_login', new Module_Common_Validator_VarEmpty($this->user->user_login));
$validator->add('user_login', new Module_Common_Validator_CharPassword($this->user->user_login));
$validator->add('user_login', new Module_User_Validator_UserLoginExists($this->user->user_login, $this->user->id));
if (!$this->user->id)
{
$validator->add('user_password_2', new Module_Common_Validator_VarEmpty($this->user->user_password_2));
$validator->add('user_password_2', new Module_Common_Validator_CharPassword($this->user->user_password_2));
}
if (isset($this->user->user_password_1) &&
isset($this->user->user_password_2) &&
$this->user->user_password_1 !== $this->user->user_password_2
)
{
$validator->addError('user_password', 'INCORRECT_PASSWORDS');
}
$validator->add('user_mail', new Module_Common_Validator_VarEmpty($this->user->user_mail));
$validator->add('user_mail', new Module_Common_Validator_Email($this->user->user_mail));
$validator->add('user_mail', new Module_User_Validator_UserMailExists($this->user->user_mail, $this->user->id));
$validator->validate();
if ($this->view->err = $validator->getErrors())
{
$redirect = new Redirect_Redirect();
$redirect->setType('alert');
$redirect->setMessage('post_errors');
$this->view->setRedirect($redirect);
}
else
{
$this->user->user_group = 'user';
$this->user->user_active = 0;
$this->user_mapper->save($this->user);
$redirect = new Redirect_Redirect();
$redirect->setRedirectUrl('/my/');
$redirect->run();
}
}
}
?>
Revise this Paste
Parent: 18125