Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r8796 -r8842 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8796) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8842) @@ -633,13 +633,14 @@ * * @param kEvent $event */ - function OnRecommend(&$event){ - + function OnRecommend(&$event) + { $friend_email = $this->Application->GetVar('friend_email'); $friend_name = $this->Application->GetVar('friend_email'); // used for error reporting only -> rewrite code + theme (by Alex) $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too + /* @var $object UsersItem */ if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $friend_email)) { @@ -648,7 +649,7 @@ $send_params['to_name']=$friend_name; $user_id = $this->Application->RecallVar('user_id'); - $email_event = &$this->Application->EmailEventUser('SITE.SUGGEST', $user_id, $send_params); + $email_event =& $this->Application->EmailEventUser('SITE.SUGGEST', $user_id, $send_params); if ($email_event->status == erSUCCESS){ $event->redirect_params = array('opener' => 's', 'pass' => 'all'); @@ -658,14 +659,12 @@ // $event->redirect_params = array('opener' => 's', 'pass' => 'all'); // $event->redirect = $this->Application->GetVar('template_fail'); - $object->ErrorMsgs['send_error'] = $this->Application->Phrase('lu_email_send_error'); - $object->FieldErrors['Email']['pseudo'] = 'send_error'; + $object->SetError('Email', 'send_error', 'lu_email_send_error'); $event->status = erFAIL; } } else { - $object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail'); - $object->FieldErrors['Email']['pseudo'] = 'invalid_email'; + $object->SetError('Email', 'invalid_email', 'lu_InvalidEmail'); $event->status = erFAIL; } } @@ -720,8 +719,9 @@ else { // used for error reporting only -> rewrite code + theme (by Alex) $object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too - $object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail'); - $object->FieldErrors['SubscribeEmail']['pseudo'] = 'invalid_email'; + /* @var $object UsersItem */ + + $object->SetError('SubscribeEmail', 'invalid_email', 'lu_InvalidEmail'); $event->status = erFAIL; } } @@ -819,29 +819,32 @@ function OnForgotPassword(&$event) { - $user_object = &$this->Application->recallObject('u.forgot', null, Array('skip_autoload' => true)); + $user_object =& $this->Application->recallObject('u.forgot', null, Array('skip_autoload' => true)); + /* @var $user_object UsersItem */ // used for error reporting only -> rewrite code + theme (by Alex) $user_current_object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true)); // TODO: change theme too + /* @var $user_current_object UsersItem */ $username = $this->Application->GetVar('username'); $email = $this->Application->GetVar('email'); $found = false; $allow_reset = true; - if( strlen($username) ) - { - if( $user_object->Load(array('Login'=>$username)) ) - $found = ($user_object->GetDBField("Login")==$username && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password")); + if (strlen($username)) { + $user_object->Load($username, 'Login'); + if ($user_object->isLoaded()) { + $found = ($user_object->GetDBField("Login")==$username && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password")); + } } - else if( strlen($email) ) - { - if( $user_object->Load(array('Email'=>$email)) ) - $found = ($user_object->GetDBField("Email")==$email && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password")); + else if(strlen($email)) { + $user_object->Load($email, 'Email'); + if ($user_object->isLoaded()) { + $found = ($user_object->GetDBField("Email")==$email && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password")); + } } - if( $user_object->isLoaded() ) - { + if ($user_object->isLoaded()) { $PwResetConfirm = $user_object->GetDBField('PwResetConfirm'); $PwRequestTime = $user_object->GetDBField('PwRequestTime'); $PassResetTime = $user_object->GetDBField('PassResetTime'); @@ -853,43 +856,34 @@ adodb_mktime() > $PassResetTime + $MinPwResetDelay); } - if($found && $allow_reset) - { + if ($found && $allow_reset) { $this->Application->StoreVar('tmp_user_id', $user_object->GetDBField("PortalUserId")); $this->Application->StoreVar('tmp_email', $user_object->GetDBField("Email")); $this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId")); $event->redirect = $this->Application->GetVar('template_success'); } - else - { - if(!strlen($username) && !strlen($email)) - { - $user_current_object->ErrorMsgs['forgotpw_nodata'] = $this->Application->Phrase('lu_ferror_forgotpw_nodata'); - $user_current_object->FieldErrors['Login']['pseudo'] = 'forgotpw_nodata'; - $user_current_object->FieldErrors['Email']['pseudo'] = 'forgotpw_nodata'; + else { + if (!strlen($username) && !strlen($email)) { + $user_current_object->SetError('Login', 'forgotpw_nodata', 'lu_ferror_forgotpw_nodata'); + $user_current_object->SetError('Email', 'forgotpw_nodata', 'lu_ferror_forgotpw_nodata'); } - else - { - if($allow_reset) - { - if( strlen($username) ){ - $user_current_object->ErrorMsgs['unknown_username'] = $this->Application->Phrase('lu_ferror_unknown_username'); - $user_current_object->FieldErrors['Login']['pseudo']='unknown_username'; + else { + if ($allow_reset) { + if (strlen($username)) { + $user_current_object->SetError('Login', 'unknown_username', 'lu_ferror_unknown_username'); } - if( strlen($email) ){ - $user_current_object->ErrorMsgs['unknown_email'] = $this->Application->Phrase('lu_ferror_unknown_email'); - $user_current_object->FieldErrors['Email']['pseudo']='unknown_email'; + if (strlen($email)) { + $user_current_object->SetError('Email', 'unknown_email', 'lu_ferror_unknown_email'); } } - else - { - $user_current_object->ErrorMsgs['reset_denied'] = $this->Application->Phrase('lu_ferror_reset_denied'); - if( strlen($username) ){ - $user_current_object->FieldErrors['Login']['pseudo']='reset_denied'; + else { + if (strlen($username)) { + $user_current_object->SetError('Login', 'reset_denied', 'lu_ferror_reset_denied'); } - if( strlen($email) ){ - $user_current_object->FieldErrors['Email']['pseudo']='reset_denied'; + + if (strlen($email)) { + $user_current_object->SetError('Email', 'reset_denied', 'lu_ferror_reset_denied'); } } } @@ -898,7 +892,6 @@ $event->redirect = false; } } - } /** @@ -929,13 +922,13 @@ // used for error reporting only -> rewrite code + theme (by Alex) $user_current_object =& $this->Application->recallObject('u', null, Array('skip_autoload' => true));// TODO: change theme too + /* @var $user_current_object UsersItem */ if (strlen(trim($passed_key)) == 0) { $event->redirect_params = array('opener' => 's', 'pass' => 'all'); $event->redirect = false; - $user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid'); - $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid'; + $user_current_object->SetError('PwResetConfirm', 'code_is_not_valid', 'lu_code_is_not_valid'); } @@ -973,14 +966,12 @@ $user_object->Update(); } else { - $user_current_object->ErrorMsgs['code_expired'] = $this->Application->Phrase('lu_code_expired'); - $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_expired'; + $user_current_object->SetError('PwResetConfirm', 'code_expired', 'lu_code_expired'); $event->redirect = false; } } else { - $user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid'); - $user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid'; + $user_current_object->SetError('PwResetConfirm', 'code_is_not_valid', 'lu_code_is_not_valid'); $event->redirect = false; }