Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r7635 -r7702 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 7635) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 7702) @@ -497,6 +497,7 @@ $cs_helper->CheckStateField($event, 'State', 'Country'); $object =& $event->getObject( Array('skip_autoload' => true) ); + /* @var $object kDBItem */ if ($this->Application->ConfigValue('User_Password_Auto')) { $pass = makepassword4(rand(5,8)); $object->SetField('Password', $pass); @@ -505,7 +506,6 @@ } parent::OnCreate($event); - $this->Application->SetVar('u.current_id', $object->getID() ); // for affil:OnRegisterAffiliate after hook $this->setNextTemplate($event); @@ -1121,6 +1121,55 @@ } } } + + /** + * Apply some special processing to + * object beeing recalled before using + * it in other events that call prepareObject + * + * @param Object $object + * @param kEvent $event + * @access protected + */ + function prepareObject(&$object, &$event) + { + parent::prepareObject($object, $event); + + if (!$this->Application->IsAdmin()) { + if ($this->Application->RecallVar('register_captcha_code')) return ; + $captcha_helper =& $this->Application->recallObject('CaptchaHelper'); + /* @var $captcha_helper kCaptchaHelper */ + $this->Application->StoreVar('register_captcha_code', $captcha_helper->GenerateCaptchaCode()); + } + } + + /** + * Apply custom processing to item + * + * @param kEvent $event + */ + function customProcessing(&$event, $type) + { + if ($event->Name == 'OnCreate' && $type == 'before') { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + // if auto password has not been set already - store real one - to be used in email events + if (!$this->Application->GetVar('user_password')) { + $this->Application->SetVar('user_password', $object->GetDirtyField('Password')); + $object->SetDBField('Password_plain', $object->GetDirtyField('Password')); + } + + // Validate captcha image if it's requried + if ($this->Application->ConfigValue('RegistrationCaptcha') && $object->GetDBField('Captcha') != $this->Application->RecallVar('register_captcha_code')) { + $object->SetError('Captcha', 'captcha_error', 'lu_captcha_error'); + $captcha_helper =& $this->Application->recallObject('CaptchaHelper'); + /* @var $captcha_helper kCaptchaHelper */ + $this->Application->StoreVar('register_captcha_code', $captcha_helper->GenerateCaptchaCode()); + } + + } + } } ?> \ No newline at end of file