コード例 #1
0
 /**
  * При попытке зарегистрироваться, проверяются данные и шлётся мыло
  */
 protected function tryRegister()
 {
     $item = $this->_verifyInputData($this->getCurrentUser());
     if ($this->request('change')) {
         $this->setVar('change', true);
     }
     if ($item) {
         $this->setVar('item', $item);
         $modelCaptcha = new model_coresession_captcha(SITE_ALIAS);
         if (!$modelCaptcha->check(trim($this->request('captcha')))) {
             $this->setVar('captcha_error', $this->lang('wrongcaptcha.session.error'));
             $this->setVar('action');
         } else {
             $model = rad_instances::get('model_core_users');
             $model->setState('u_email', $item->u_email)->setState('u_active', 1);
             $tmp = $model->getItems(1);
             if (!empty($tmp[0]->u_id)) {
                 if ($this->request('change') and $tmp[0]->u_active) {
                     $model->updateItem($item);
                     rad_session::setUser($item);
                     $this->setVar('item', $item);
                     $this->setVar('message', $this->lang('yourdatesuccupdated.session.message'));
                 } elseif ($tmp[0]->u_active and $tmp[0]->u_email_confirmed) {
                     //RESEND EMAIL
                     $this->setVar('message', $this->lang($this->config('registration.mail_already_registred_text')));
                 } else {
                     $this->sendActivationCode($item);
                     $this->setVar('message', $this->lang($this->config('registration.mail_regsended_text')));
                     $this->setVar('onlymessage', true);
                 }
             } else {
                 //REGISTER!
                 $item->u_group = $this->_treestart;
                 $this->register($item);
                 $this->redirect($this->makeURL('a=success'));
             }
         }
     } else {
         $this->setVar('item', new struct_core_users($this->getAllRequest()));
     }
 }