예제 #1
0
 /**
  * Save registration.
  */
 function execute()
 {
     $schedConf =& $this->request->getSchedConf();
     $user =& $this->request->getUser();
     $registrationOptionIds = (array) $this->getData('registrationOptionId');
     if (!$user) {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setSalutation($this->getData('salutation'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $user->setGender($this->getData('gender'));
         $user->setAffiliation($this->getData('affiliation'), null);
         // Localized
         $user->setSignature($this->getData('signature'), null);
         // Localized
         $user->setEmail($this->getData('email'));
         $user->setUrl($this->getData('userUrl'));
         $user->setPhone($this->getData('phone'));
         $user->setFax($this->getData('fax'));
         $user->setMailingAddress($this->getData('mailingAddress'));
         $user->setBillingAddress($this->getData('billingAddress'));
         $user->setBiography($this->getData('biography'), null);
         // Localized
         $user->setDateRegistered(Core::getCurrentDate());
         $user->setCountry($this->getData('country'));
         $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password')));
         $userDao = DAORegistry::getDAO('UserDAO');
         $userId = $userDao->insertObject($user);
         if (!$userId) {
             return REGISTRATION_FAILED;
         }
         $conference =& $this->request->getConference();
         $roleDao = DAORegistry::getDAO('RoleDAO');
         $role = new Role();
         $role->setRoleId(ROLE_ID_READER);
         $role->setSchedConfId($schedConf->getId());
         $role->setConferenceId($conference->getId());
         $role->setUserId($user->getId());
         $roleDao->insertRole($role);
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
         // Make sure subsequent requests to Request::getUser work
         Validation::login($this->getData('username'), $this->getData('password'), $reason);
         import('classes.user.form.CreateAccountForm');
         CreateAccountForm::sendConfirmationEmail($user, $this->getData('password'), true);
     }
     // Get the registration type
     $registrationDao = DAORegistry::getDAO('RegistrationDAO');
     $registrationTypeDao = DAORegistry::getDAO('RegistrationTypeDAO');
     $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('registrationTypeId'));
     if (!$registrationType || $registrationType->getSchedConfId() != $schedConf->getId()) {
         $this->request->redirect('index');
     }
     import('classes.payment.ocs.OCSPaymentManager');
     $paymentManager = new OCSPaymentManager($this->request);
     if (!$paymentManager->isConfigured()) {
         return REGISTRATION_NO_PAYMENT;
     }
     if ($this->_registration) {
         // An existing registration was already in place. Compare and notify someone.
         $oldRegistration =& $this->_registration;
         $oldRegistrationType =& $registrationTypeDao->getRegistrationType($oldRegistration->getTypeId());
         unset($this->_registration);
         import('mail.MailTemplate');
         $mail = new MailTemplate('USER_REGISTRATION_CHANGE');
         $mail->setFrom($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName'));
         $mail->addRecipient($schedConf->getSetting('registrationEmail'), $schedConf->getSetting('registrationName'));
         $optionsDiffer = '';
         $registrationOptionDao = DAORegistry::getDAO('RegistrationOptionDAO');
         $registrationOptionIterator =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
         $oldRegistrationOptionIds = $registrationOptionDao->getRegistrationOptions($oldRegistration->getRegistrationId());
         while ($registrationOption =& $registrationOptionIterator->next()) {
             $optionId = $registrationOption->getOptionId();
             $previouslyChosen = in_array($optionId, $oldRegistrationOptionIds);
             $newlyChosen = in_array($optionId, $registrationOptionIds);
             if ($previouslyChosen && !$newlyChosen) {
                 $optionsDiffer .= __('schedConf.registrationOptions.removed', array('option' => $registrationOption->getRegistrationOptionName())) . "\n";
             } elseif (!$previouslyChosen && $newlyChosen) {
                 $optionsDiffer .= __('schedConf.registrationOptions.added', array('option' => $registrationOption->getRegistrationOptionName())) . "\n";
             }
             unset($registrationOption);
         }
         $mail->assignParams(array('managerName' => $schedConf->getSetting('registrationName'), 'registrationId' => $oldRegistration->getRegistrationId(), 'registrantName' => $user->getFullName(), 'oldRegistrationType' => $oldRegistrationType->getSummaryString(), 'newRegistrationType' => $registrationType->getSummaryString(), 'differingOptions' => $optionsDiffer, 'username' => $user->getUsername(), 'registrationContactSignature' => $schedConf->getSetting('registrationName')));
         $mail->send();
         $registrationDao->deleteRegistrationById($oldRegistration->getRegistrationId());
     }
     import('classes.registration.Registration');
     $registration = new Registration();
     $registration->setSchedConfId($schedConf->getId());
     $registration->setUserId($user->getId());
     $registration->setTypeId($this->getData('registrationTypeId'));
     $registration->setSpecialRequests($this->getData('specialRequests') ? $this->getData('specialRequests') : null);
     $registration->setDateRegistered(time());
     $registrationId = $registrationDao->insertRegistration($registration);
     $registrationOptionDao = DAORegistry::getDAO('RegistrationOptionDAO');
     $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
     $cost = $registrationType->getCost();
     $registrationOptionCosts = $registrationTypeDao->getRegistrationOptionCosts($this->getData('registrationTypeId'));
     while ($registrationOption =& $registrationOptions->next()) {
         if (in_array($registrationOption->getOptionId(), $registrationOptionIds) && strtotime($registrationOption->getOpeningDate()) < time() && strtotime($registrationOption->getClosingDate()) > time() && $registrationOption->getPublic()) {
             $registrationOptionDao->insertRegistrationOptionAssoc($registrationId, $registrationOption->getOptionId());
             $cost += $registrationOptionCosts[$registrationOption->getOptionId()];
         }
         unset($registrationOption);
     }
     $queuedPayment =& $paymentManager->createQueuedPayment($schedConf->getConferenceId(), $schedConf->getId(), QUEUED_PAYMENT_TYPE_REGISTRATION, $user->getId(), $registrationId, $cost, $registrationType->getCurrencyCodeAlpha());
     $queuedPaymentId = $paymentManager->queuePayment($queuedPayment, time() + 60 * 60 * 24 * 30);
     // 30 days to complete
     if ($cost == 0) {
         $paymentManager->fulfillQueuedPayment($this->request, $queuedPaymentId, $queuedPayment);
         return REGISTRATION_FREE;
     } else {
         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
     }
     $this->_registration =& $registration;
     $this->_queuedPayment =& $queuedPayment;
     return REGISTRATION_SUCCESSFUL;
 }
예제 #2
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
  */
 function TemplateManager($request = null)
 {
     parent::PKPTemplateManager($request);
     // Retrieve the router
     $router =& $this->request->getRouter();
     assert(is_a($router, 'PKPRouter'));
     if (!defined('SESSION_DISABLE_INIT')) {
         /**
          * Kludge to make sure no code that tries to connect to
          * the database is executed (e.g., when loading
          * installer pages).
          */
         $conference =& $router->getContext($this->request, 1);
         $schedConf =& $router->getContext($this->request, 2);
         $site =& $this->request->getSite();
         $this->assign('siteTitle', $site->getLocalizedTitle());
         $publicFileManager = new PublicFileManager();
         $siteFilesDir = $this->request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath();
         $this->assign('sitePublicFilesDir', $siteFilesDir);
         $this->assign('homeContext', array('conference' => 'index', 'schedConf' => 'index'));
         $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
         if (file_exists($siteStyleFilename)) {
             $this->addStyleSheet($this->request->getBaseUrl() . '/' . $siteStyleFilename);
         }
         if (isset($conference)) {
             $schedConfDao = DAORegistry::getDAO('SchedConfDAO');
             $archivedSchedConfsExist = $schedConfDao->archivedSchedConfsExist($conference->getId());
             $currentSchedConfsExist = $schedConfDao->currentSchedConfsExist($conference->getId());
             $this->assign('archivedSchedConfsExist', $archivedSchedConfsExist);
             $this->assign('currentSchedConfsExist', $currentSchedConfsExist);
             $this->assign_by_ref('currentConference', $conference);
             $conferenceTitle = $conference->getLocalizedName();
             $this->assign('numPageLinks', $conference->getSetting('numPageLinks'));
             $this->assign('itemsPerPage', $conference->getSetting('itemsPerPage'));
             // Load and apply theme plugin, if chosen
             $themePluginPath = $conference->getSetting('conferenceTheme');
             if (!empty($themePluginPath)) {
                 // Load and activate the theme
                 $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
                 if ($themePlugin) {
                     $themePlugin->activate($this);
                 }
             }
             // Assign additional navigation bar items
             $navMenuItems =& $conference->getLocalizedSetting('navItems');
             $this->assign_by_ref('navMenuItems', $navMenuItems);
             $this->assign('publicFilesDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getConferenceFilesPath($conference->getId()));
             $this->assign('displayPageHeaderTitle', $conference->getPageHeaderTitle());
             $this->assign('displayPageHeaderLogo', $conference->getPageHeaderLogo());
             $this->assign('displayPageHeaderTitleAltText', $conference->getLocalizedSetting('pageHeaderTitleImageAltText'));
             $this->assign('displayPageHeaderLogoAltText', $conference->getLocalizedSetting('pageHeaderLogoImageAltText'));
             $this->assign('displayFavicon', $conference->getLocalizedFavicon());
             $this->assign('faviconDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getConferenceFilesPath($conference->getId()));
             $this->assign('alternatePageHeader', $conference->getLocalizedSetting('conferencePageHeader'));
             $this->assign('metaSearchDescription', $conference->getLocalizedSetting('searchDescription'));
             $this->assign('metaSearchKeywords', $conference->getLocalizedSetting('searchKeywords'));
             $this->assign('metaCustomHeaders', $conference->getLocalizedSetting('customHeaders'));
             $this->assign('enableAnnouncements', $conference->getSetting('enableAnnouncements'));
             $this->assign('pageFooter', $conference->getLocalizedSetting('conferencePageFooter'));
             $this->assign('displayCreativeCommons', $conference->getSetting('postCreativeCommons'));
             if (isset($schedConf)) {
                 // This will be needed if inheriting public conference files from the scheduled conference.
                 $this->assign('publicSchedConfFilesDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getSchedConfFilesPath($schedConf->getId()));
                 $this->assign('primaryLocale', $conference->getSetting('primaryLocale'));
                 $this->assign('alternateLocales', $conference->getPrimaryLocale());
                 $this->assign_by_ref('currentSchedConf', $schedConf);
                 // Assign common sched conf vars:
                 $currentTime = time();
                 $submissionsCloseDate = $schedConf->getSetting('submissionsCloseDate');
                 $this->assign('submissionsCloseDate', $submissionsCloseDate);
                 $this->assign('schedConfPostTimeline', $schedConf->getSetting('postTimeline'));
                 $this->assign('schedConfPostOverview', $schedConf->getSetting('postOverview'));
                 $this->assign('schedConfPostTrackPolicies', $schedConf->getSetting('postTrackPolicies'));
                 $this->assign('schedConfPostPresentations', $schedConf->getSetting('postPresentations'));
                 $this->assign('schedConfPostAccommodation', $schedConf->getSetting('postAccommodation'));
                 $this->assign('schedConfPostSupporters', $schedConf->getSetting('postSupporters'));
                 $this->assign('schedConfPostPayment', $schedConf->getSetting('postPayment'));
                 // CFP displayed
                 $showCFPDate = $schedConf->getSetting('showCFPDate');
                 $postCFP = $schedConf->getSetting('postCFP');
                 if ($postCFP && $showCFPDate && $submissionsCloseDate && $currentTime > $showCFPDate && $currentTime < $submissionsCloseDate) {
                     $this->assign('schedConfShowCFP', true);
                 }
                 // Schedule displayed
                 $postScheduleDate = $schedConf->getSetting('postScheduleDate');
                 if ($postScheduleDate && $currentTime > $postScheduleDate && $schedConf->getSetting('postSchedule')) {
                     $this->assign('schedConfPostSchedule', true);
                 }
                 // Program
                 if ($schedConf->getSetting('postProgram') && ($schedConf->getSetting('program') || $schedConf->getSetting('programFile'))) {
                     $this->assign('schedConfShowProgram', true);
                 }
                 // Submissions open
                 $submissionsOpenDate = $schedConf->getSetting('submissionsOpenDate');
                 $postSubmission = $schedConf->getSetting('postProposalSubmission');
                 $this->assign('submissionsOpenDate', $submissionsOpenDate);
                 import('classes.payment.ocs.OCSPaymentManager');
                 $paymentManager = new OCSPaymentManager($this->request);
                 $this->assign('schedConfPaymentsEnabled', $paymentManager->isConfigured());
             }
             // Assign conference stylesheet and footer
             $conferenceStyleSheet = $conference->getSetting('conferenceStyleSheet');
             if ($conferenceStyleSheet) {
                 $this->addStyleSheet($this->request->getBaseUrl() . '/' . $publicFileManager->getConferenceFilesPath($conference->getId()) . '/' . $conferenceStyleSheet['uploadName']);
             }
             // Assign scheduled conference stylesheet and footer (after conference stylesheet!)
             if ($schedConf) {
                 $schedConfStyleSheet = $schedConf->getSetting('schedConfStyleSheet');
                 if ($schedConfStyleSheet) {
                     $this->addStyleSheet($this->request->getBaseUrl() . '/' . $publicFileManager->getSchedConfFilesPath($schedConf->getId()) . '/' . $schedConfStyleSheet['uploadName']);
                 }
             }
         } else {
             // Not within conference context
             // Add the site-wide logo, if set for this locale or the primary locale
             $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle();
             $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle);
             if (isset($displayPageHeaderTitle['altText'])) {
                 $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']);
             }
             $this->assign('publicFilesDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath());
             // Load and apply theme plugin, if chosen
             $themePluginPath = $site->getSetting('siteTheme');
             if (!empty($themePluginPath)) {
                 // Load and activate the theme
                 $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
                 if ($themePlugin) {
                     $themePlugin->activate($this);
                 }
             }
         }
     }
 }
예제 #3
0
 /**
  * Handle submission of the user registration form
  * @param $args array
  * @param $request PKPRequest
  */
 function register($args, &$request)
 {
     $this->addCheck(new HandlerValidatorSchedConf($this));
     $this->validate();
     $conference =& $request->getConference();
     $schedConf =& $request->getSchedConf();
     $paymentManager = new OCSPaymentManager($request);
     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->getLocalizedName(), true), array($request->url(null, null, 'index'), $schedConf->getLocalizedName(), true)));
     $this->setupTemplate($request, $conference, $schedConf);
     import('classes.registration.form.UserRegistrationForm');
     $typeId = (int) $request->getUserVar('registrationTypeId');
     $form = new UserRegistrationForm($typeId, $registration, $request);
     $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();
     }
 }