Example #1
0
 public function index()
 {
     // support for enable/disable registration
     if (isset($this->layer['enableregistration']) && $this->layer['enableregistration'] == 1) {
         if (strlen($this->registry->core->getParam()) > 10) {
             $checkClient = $this->model->checkClientLink($this->registry->core->getParam());
             if (count($checkClient > 0)) {
                 $result = App::getModel('clientlogin')->authProccessConfirmation($checkClient['email'], $checkClient['password']);
                 if ($result != 0) {
                     Session::setActiveClientid($result);
                     App::getModel('clientlogin')->checkClientGroup();
                     $this->model->saveClientData();
                 }
                 if (($this->Cart = Session::getActiveCart()) != NULL) {
                     App::redirectUrl($this->registry->router->generate('frontend.cart', true));
                 } else {
                     App::redirectUrl($this->registry->router->generate('frontend.home', true));
                 }
             }
         }
         $form = App::getFormModel('registration')->initForm();
         if ($form->Validate()) {
             $formData = $form->getSubmitValues();
             $recurMail = $this->model->checkClientNewMail($formData);
             if ($recurMail == 0) {
                 $clientId = $this->model->addNewClient($formData);
                 if (isset($this->layer['confirmregistration']) && $this->layer['confirmregistration'] == 1) {
                     $link = $this->model->updateClientDisable($clientId, 1, sha1($formData['email'] . time()));
                     $this->registry->template->assign('activelink', $link);
                 }
                 $this->registry->template->assign('address', $formData);
                 App::getModel('mailer')->sendEmail(array('template' => 'addClient', 'email' => array($formData['email']), 'bcc' => false, 'subject' => _('TXT_REGISTRATION_NEW'), 'viewid' => Helper::getViewId()));
                 if (isset($this->layer['confirmregistration']) && $this->layer['confirmregistration'] == 1) {
                     Session::setVolatileActivationRequired(1, false);
                 } else {
                     Session::setVolatileRegistrationOk(1, false);
                     $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']);
                     if ($result > 0) {
                         Session::setActiveClientid($result);
                         App::getModel('clientlogin')->checkClientGroup();
                         $this->model->saveClientData();
                     }
                     if ($result < 0) {
                         Session::setVolatileActivationRequired(1, false);
                     } else {
                         Session::setVolatileRegistrationOk(1, false);
                         App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
                     }
                 }
             } else {
                 $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']);
                 if ($result != 0) {
                     Session::setActiveClientid($result);
                     App::getModel('clientlogin')->checkClientGroup();
                     $this->model->saveClientData();
                     Session::setVolatileRegistrationOk(1, false);
                     App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
                 } elseif ($result < 0) {
                     Session::setVolatileActivationRequired(1, false);
                 } else {
                     Session::setVolatileRecureMail(1, false);
                 }
             }
         }
         $this->registry->template->assign('form', $form->getForm());
         $activationrequired = Session::getVolatileActivationRequired();
         if ($activationrequired[0] == 1) {
             $this->registry->template->assign('error', _('TXT_ACTIVATION_REQUIRED'));
             $this->registry->template->assign('error_msg', _('TXT_ACTIVATION_REQUIRED_MSG'));
         }
         $recureMailError = Session::getVolatileRecureMail();
         if ($recureMailError[0] == 1) {
             $this->registry->template->assign('error', _('ERR_DUPLICATE_EMAIL'));
             $this->registry->template->assign('error', _('ERR_DUPLICATE_EMAIL_MSG'));
         }
         $forbiddenCode = Session::getVolatileForbiddenCode();
         if ($forbiddenCode[0] == 1) {
             $this->registry->template->assign('error', _('TXT_ERROR_FORBIDDEN_CODE'));
             $this->registry->template->assign('error', _('TXT_ERROR_FORBIDDEN_CODE_MSG'));
         }
         $passwdGenError = Session::getVolatilePasswordGenerateError();
         if ($passwdGenError[0] == 1) {
             $this->registry->template->assign('error', _('ERROR_PASSWORD_GENERATE'));
             $this->registry->template->assign('error', _('ERROR_PASSWORD_GENERATE_MSG'));
         }
         return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
     } else {
         $this->registry->template->assign('error', _('TXT_REGISTRATION_DISABLED_HELP'));
     }
 }