/**
  * Handle submission of the user registration form
  */
 function register()
 {
     $this->addCheck(new HandlerValidatorSchedConf($this));
     $this->validate();
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $paymentManager =& OCSPaymentManager::getManager();
     if (!$paymentManager->isConfigured()) {
         Request::redirect(null, null, 'index');
     }
     $user =& Request::getUser();
     $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
     if ($user && ($registrationId = $registrationDao->getRegistrationIdByUser($user->getId(), $schedConf->getId()))) {
         // This user has already registered.
         $registration =& $registrationDao->getRegistration($registrationId);
         $this->_updateRegistration($registrationDao, $registration);
         //                        $isUpdate = Request::getUserVar("update");
         if (!$registration || $registration->getDatePaid()) {
             // And they have already paid. Redirect to a message explaining.
             //                                $notifyEmail = Request::getUserVar("notifyEmail");
             //
             //                                if ($notifyEmail) {
             //                                    echo "有!";
             //                                    exit;
             //                                    //$this->notifyEmail($registration->getTypeId());
             //                                }
             //                                else {
             //                                    echo '沒有!!';
             //                                    exit;
             //                                }
             Request::redirect(null, null, null, 'registration');
         } else {
             // Allow them to resubmit the form to change type or pay again.
             $registrationDao->deleteRegistrationById($registrationId);
         }
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true), array(Request::url(null, null, 'index'), $schedConf->getSchedConfTitle(), true)));
     SchedConfHandler::setupTemplate($conference, $schedConf);
     import('registration.form.UserRegistrationForm');
     $typeId = (int) Request::getUserVar('registrationTypeId');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $form = new UserRegistrationForm($typeId);
     } else {
         $form =& new UserRegistrationForm($typeId);
     }
     $form->readInputData();
     if ($form->validate()) {
         if (($registrationError = $form->execute()) != REGISTRATION_SUCCESSFUL) {
             $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn());
             // In case a user was just created, make sure they appear logged in
             if ($registrationError == REGISTRATION_FAILED) {
                 // User not created
                 $templateMgr->assign('message', 'schedConf.registration.failed');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 $templateMgr->display('common/message.tpl');
             } elseif ($registrationError == REGISTRATION_NO_PAYMENT) {
                 // Automatic payment failed; display a generic
                 // "you will be contacted" message.
                 $templateMgr->assign('message', 'schedConf.registration.noPaymentMethodAvailable');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 $templateMgr->display('common/message.tpl');
             } elseif ($registrationError == REGISTRATION_FREE) {
                 // Registration successful; no payment required (free)
                 $templateMgr->assign('message', 'schedConf.registration.free');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 //$templateMgr->display('common/message.tpl');
                 //$registration =& $registrationDao->getRegistration($registrationId);
                 //$this->_registrationDisplay($registration);
                 //$this->_updateRegistration($registrationDao, $registration);
                 $notifyEmail = Request::getUserVar("notifyEmail");
                 $registrationTypeId = (int) Request::getUserVar("registrationTypeId");
                 if ($notifyEmail) {
                     $this->notifyEmail($registrationTypeId);
                 }
                 Request::redirect(null, null, null, 'registration');
                 return;
             }
         }
         // Otherwise, payment is handled for us.
     } else {
         $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn());
         // In case a user was just created, make sure they appear logged in
         $form->display();
     }
 }
Example #2
0
 /**
  * Handle submission of the user registration form
  */
 function register()
 {
     $this->addCheck(new HandlerValidatorSchedConf($this));
     $this->validate();
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $paymentManager =& OCSPaymentManager::getManager();
     if (!$paymentManager->isConfigured()) {
         Request::redirect(null, null, 'index');
     }
     $user =& Request::getUser();
     $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
     $registration = null;
     if ($user && ($registrationId = $registrationDao->getRegistrationIdByUser($user->getId(), $schedConf->getId()))) {
         // This user has already registered.
         $registration =& $registrationDao->getRegistration($registrationId);
         if (!$registration || $registration->getDatePaid()) {
             // And they have already paid. Redirect to a message explaining.
             Request::redirect(null, null, null, 'registration');
         }
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true), array(Request::url(null, null, 'index'), $schedConf->getLocalizedTitle(), true)));
     SchedConfHandler::setupTemplate($conference, $schedConf);
     import('classes.registration.form.UserRegistrationForm');
     $typeId = (int) Request::getUserVar('registrationTypeId');
     if (checkPhpVersion('5.0.0')) {
         // WARNING: This form needs $this in constructor
         $form = new UserRegistrationForm($typeId, $registration);
     } else {
         $form =& new UserRegistrationForm($typeId, $registration);
     }
     $form->readInputData();
     if ($form->validate()) {
         if (($registrationError = $form->execute()) == REGISTRATION_SUCCESSFUL) {
             $registration =& $form->getRegistration();
             $queuedPayment =& $form->getQueuedPayment();
             // Successful: Send an email.
             import('mail.MailTemplate');
             $mail = new MailTemplate('USER_REGISTRATION_NOTIFY');
             $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
             $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
             $registrationType =& $registrationTypeDao->getRegistrationType($typeId);
             // Determine the registration options for inclusion
             $registrationOptionText = '';
             $totalCost = $registrationType->getCost();
             $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
             $registrationOptionIterator =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
             $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($typeId);
             $registrationOptionIds = $registrationOptionDao->getRegistrationOptions($registration->getRegistrationId());
             while ($registrationOption =& $registrationOptionIterator->next()) {
                 if (in_array($registrationOption->getOptionId(), $registrationOptionIds)) {
                     $registrationOptionText .= $registrationOption->getRegistrationOptionName() . ' - ' . sprintf('%.2f', $registrationOptionCosts[$registrationOption->getOptionId()]) . ' ' . $registrationType->getCurrencyCodeAlpha() . "\n";
                     $totalCost += $registrationOptionCosts[$registrationOption->getOptionId()];
                 }
                 unset($registrationOption);
             }
             $mail->assignParams(array('registrantName' => $user->getFullName(), 'registrationType' => $registrationType->getSummaryString(), 'registrationOptions' => $registrationOptionText, 'totalCost' => sprintf('%.2f', $totalCost) . ' ' . $registrationType->getCurrencyCodeAlpha(), 'username' => $user->getUsername(), 'specialRequests' => $registration->getSpecialRequests(), 'invoiceId' => $queuedPayment->getInvoiceId(), 'registrationContactSignature' => $schedConf->getSetting('registrationName')));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
         } else {
             // Not successful
             $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn());
             // In case a user was just created, make sure they appear logged in
             if ($registrationError == REGISTRATION_FAILED) {
                 // User not created
                 $templateMgr->assign('message', 'schedConf.registration.failed');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 $templateMgr->display('common/message.tpl');
             } elseif ($registrationError == REGISTRATION_NO_PAYMENT) {
                 // Automatic payment failed; display a generic
                 // "you will be contacted" message.
                 $templateMgr->assign('message', 'schedConf.registration.noPaymentMethodAvailable');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 $templateMgr->display('common/message.tpl');
             } elseif ($registrationError == REGISTRATION_FREE) {
                 // Registration successful; no payment required (free)
                 $templateMgr->assign('message', 'schedConf.registration.free');
                 $templateMgr->assign('backLinkLabel', 'common.back');
                 $templateMgr->assign('backLink', Request::url(null, null, 'index'));
                 $templateMgr->display('common/message.tpl');
             }
         }
         // Otherwise, payment is handled for us.
     } else {
         $templateMgr->assign('isUserLoggedIn', Validation::isLoggedIn());
         // In case a user was just created, make sure they appear logged in
         $form->display();
     }
 }