コード例 #1
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');
     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();
     }
 }
コード例 #2
0
 /**
  * Handle incoming requests/notifications
  */
 function handle($args)
 {
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     $templateMgr =& TemplateManager::getManager();
     $user =& Request::getUser();
     $op = isset($args[0]) ? $args[0] : null;
     $queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0;
     import('payment.ocs.OCSPaymentManager');
     $ocsPaymentManager =& OCSPaymentManager::getManager();
     $queuedPayment =& $ocsPaymentManager->getQueuedPayment($queuedPaymentId);
     // if the queued payment doesn't exist, redirect away from payments
     if (!$queuedPayment) {
         Request::redirect(null, null, null, 'index');
     }
     switch ($op) {
         case 'notify':
             import('mail.MailTemplate');
             Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
             $contactName = $schedConf->getSetting('registrationName');
             $contactEmail = $schedConf->getSetting('registrationEmail');
             $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION');
             $mail->setFrom($contactEmail, $contactName);
             $mail->addRecipient($contactEmail, $contactName);
             $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'userFullName' => $user ? $user->getFullName() : '(' . Locale::translate('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . Locale::translate('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode()));
             $mail->send();
             $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)), 'pageTitle' => 'plugins.paymethod.manual.paymentNotification', 'message' => 'plugins.paymethod.manual.notificationSent', 'backLink' => $queuedPayment->getRequestUrl(), 'backLinkLabel' => 'common.continue'));
             $templateMgr->display('common/message.tpl');
             exit;
             break;
     }
     parent::handle($args);
     // Don't know what to do with it
 }
コード例 #3
0
ファイル: Notification.inc.php プロジェクト: sedici/ocs
 /**
  * Returns an array of information on the conference's subscription settings
  * @return array
  */
 function getSubscriptionSettings()
 {
     $conference = Request::getConference();
     import('payment.ocs.OCSPaymentManager');
     $paymentManager =& OCSPaymentManager::getManager();
     $settings = array('allowRegReviewer' => $conference->getSetting('allowRegReviewer'), 'allowRegAuthor' => $conference->getSetting('allowRegAuthor'));
     return $settings;
 }
コード例 #4
0
 /**
  * Handle incoming requests/notifications
  */
 function handle($args)
 {
     $templateMgr =& TemplateManager::getManager();
     $schedConf =& Request::getSchedConf();
     if (!$schedConf) {
         return parent::handle($args);
     }
     // Just in case we need to contact someone
     import('mail.MailTemplate');
     $contactName = $schedConf->getSetting('contactName');
     $contactEmail = $schedConf->getSetting('contactEmail');
     $mail =& new MailTemplate('CREDIT_INVESTIGATE_PAYMENT');
     $mail->setFrom($contactEmail, $contactName);
     $mail->addRecipient($contactEmail, $contactName);
     $paymentStatus = Request::getUserVar('payment_status');
     switch (array_shift($args)) {
         case 'ipn':
             // Build a confirmation transaction.
             $req = 'cmd=_notify-validate';
             foreach ($_POST as $key => $value) {
                 $req .= '&' . urlencode($key) . '=' . urlencode($value);
             }
             // Create POST response
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $this->getSetting($schedConf->getConferenceId(), $schedConf->getSchedConfId(), 'crediturl'));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($req)));
             curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
             $ret = curl_exec($ch);
             curl_close($ch);
             // Check the confirmation response and handle as necessary.
             if (strcmp($ret, 'VERIFIED') == 0) {
                 switch ($paymentStatus) {
                     case 'Completed':
                         $CreditDao =& DAORegistry::getDAO('CreditDAO');
                         $transactionId = Request::getUserVar('txn_id');
                         if ($CreditDao->transactionExists($transactionId)) {
                             // A duplicate transaction was received; notify someone.
                             $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true)));
                             $mail->send();
                             exit;
                         } else {
                             // New transaction succeeded. Record it.
                             $CreditDao->insertTransaction($transactionId, Request::getUserVar('txn_type'), Request::getUserVar('payer_email'), Request::getUserVar('item_number'), Request::getUserVar('payment_date'), Request::getUserVar('payer_id'), Request::getUserVar('receiver_id'));
                             $queuedPaymentId = Request::getUserVar('custom');
                             import('payment.ocs.OCSPaymentManager');
                             $ocsPaymentManager =& OCSPaymentManager::getManager();
                             // Verify the cost and user details as per PayPal spec.
                             $queuedPayment =& $ocsPaymentManager->getQueuedPayment($queuedPaymentId);
                             if (!$queuedPayment) {
                                 // The queued payment entry is missing. Complain.
                                 $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true)));
                                 $mail->send();
                                 exit;
                             }
                             if (($queuedAmount = $queuedPayment->getAmount()) != ($grantedAmount = Request::getUserVar('mc_gross')) || ($queuedCurrency = $queuedPayment->getCurrencyCode()) != ($grantedCurrency = Request::getUserVar('mc_currency'))) {
                                 // The integrity checks for the transaction failed. Complain.
                                 $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to Credit account: {$grantedEmail}\n" . "Configured Credit account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true)));
                                 $mail->send();
                                 exit;
                             }
                             // Fulfill the queued payment.
                             if ($ocsPaymentManager->fulfillQueuedPayment($queuedPaymentId, $queuedPayment)) {
                                 exit;
                             }
                             // If we're still here, it means the payment couldn't be fulfilled.
                             $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Queued payment ID {$queuedPaymentId} could not be fulfilled.", 'serverVars' => print_r($_SERVER, true)));
                             $mail->send();
                         }
                         exit;
                     case 'Pending':
                         // Ignore.
                         exit;
                     default:
                         // An unhandled payment status was received; notify someone.
                         $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Payment status: {$paymentStatus}", 'serverVars' => print_r($_SERVER, true)));
                         $mail->send();
                         exit;
                 }
             } else {
                 // An unknown confirmation response was received; notify someone.
                 $mail->assignParams(array('schedConfName' => $schedConf->getFullTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Confirmation return: {$ret}", 'serverVars' => print_r($_SERVER, true)));
                 $mail->send();
                 exit;
             }
             break;
         case 'cancel':
             $templateMgr->assign(array('currentUrl' => Request::url(null, null, 'index'), 'pageTitle' => 'plugins.paymethod.pagseguro.purchase.cancelled.title', 'message' => 'plugins.paymethod.pagseguro.purchase.cancelled'));
             $templateMgr->display('common/message.tpl');
             exit;
             break;
         case 'return':
             Request::redirect(null, null, 'index');
             break;
     }
     parent::handle($args);
     // Don't know what to do with it
 }
コード例 #5
0
 /**
  * Save registration.
  */
 function execute()
 {
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     if (!$user) {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $user->setFirstName($this->getData('firstName'));
         $user->setMiddleName($this->getData('middleName'));
         $user->setInitials($this->getData('initials'));
         $user->setLastName($this->getData('lastName'));
         $user->setAffiliation($this->getData('affiliation'));
         $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->setBiography($this->getData('biography'), null);
         // Localized
         $user->setInterests($this->getData('interests'), 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->insertUser($user);
         if (!$userId) {
             return REGISTRATION_FAILED;
         }
         $conference =& 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('user.form.CreateAccountForm');
         CreateAccountForm::sendConfirmationEmail($user, $this->getData('password'), true);
     }
     // Get the registration type
     $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
     $registrationType =& $registrationTypeDao->getRegistrationType($this->getData('registrationTypeId'));
     if (!$registrationType || $registrationType->getSchedConfId() != $schedConf->getId()) {
         Request::redirect('index');
     }
     import('payment.ocs.OCSPaymentManager');
     $paymentManager =& OCSPaymentManager::getManager();
     if (!$paymentManager->isConfigured()) {
         return REGISTRATION_NO_PAYMENT;
     }
     import('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());
     $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
     $registrationId = $registrationDao->insertRegistration($registration);
     $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
     $registrationOptions =& $registrationOptionDao->getRegistrationOptionsBySchedConfId($schedConf->getId());
     $registrationOptionIds = (array) $this->getData('registrationOptionId');
     $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($queuedPaymentId, $queuedPayment);
         return REGISTRATION_FREE;
     } else {
         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
     }
     return REGISTRATION_SUCCESSFUL;
 }
コード例 #6
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)
 {
     // FIXME: for backwards compatibility only - remove
     if (!isset($request)) {
         // FIXME: Trigger a deprecation warning when enough instances of this
         // call have been fixed to not clutter the error log.
         $request =& Registry::get('request');
     }
     assert(is_a($request, 'PKPRequest'));
     parent::PKPTemplateManager($request);
     // Retrieve the router
     $router =& $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($request, 1);
         $schedConf =& $router->getContext($request, 2);
         $site =& $request->getSite();
         $this->assign('siteTitle', $site->getLocalizedTitle());
         $siteFilesDir = $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($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->getConferenceTitle();
             $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', $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', $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', $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 =& OCSPaymentManager::getManager();
                 $this->assign('schedConfPaymentsEnabled', $paymentManager->isConfigured());
             }
             // Assign conference stylesheet and footer
             $conferenceStyleSheet = $conference->getSetting('conferenceStyleSheet');
             if ($conferenceStyleSheet) {
                 $this->addStyleSheet($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($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', $request->getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath());
         }
         // Add java script for notifications
         $user =& $request->getUser();
         if ($user) {
             $this->addJavaScript('lib/pkp/js/lib/jquery/plugins/jquery.pnotify.js');
         }
     }
 }
コード例 #7
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();
     }
 }
コード例 #8
0
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  */
 function TemplateManager()
 {
     parent::PKPTemplateManager();
     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 =& Request::getConference();
         $schedConf =& Request::getSchedConf();
         $site =& Request::getSite();
         if (isset($schedConf)) {
             $this->assign('schedConfAcronym', $schedConf->getLocalizedSetting('acronym'));
         }
         $this->assign('siteTitle', $site->getLocalizedTitle());
         $siteFilesDir = 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(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->getConferenceTitle();
             $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', Request::getBaseUrl() . '/' . PublicFileManager::getConferenceFilesPath($conference->getId()));
             $this->assign('displayPageHeaderTitle', $conference->getPageHeaderTitle());
             $this->assign('displayPageHeaderSubTitle', $conference->getLocalizedSetting('homeHeaderSubTitle'));
             $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', 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'));
             $this->assign('analyticsTrackingID', $conference->getSetting('analyticsTrackingID'));
             $this->assign('currentConferenceHome', Request::url(null, $conference->getSetting("path"), 'index'));
             if (isset($schedConf)) {
                 // This will be needed if inheriting public conference files from the scheduled conference.
                 $this->assign('publicSchedConfFilesDir', 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);
                 // ------------------------------------
                 $navMenuItemOrder = array();
                 $navMenuItemNavOrder = array();
                 $this->assign('schedConfPostOverview', $schedConf->getSetting('postOverview'));
                 $this->assign('schedConfPostOverviewOrder', $schedConf->getSetting('postOverviewOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Overview');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Overview');
                 $this->assign('schedConfPostAnnouncement', $schedConf->getSetting('postAnnouncement'));
                 $this->assign('schedConfPostAnnouncementOrder', $schedConf->getSetting('postAnnouncementOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Announcement');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Announcement');
                 $this->assign('schedConfPostTimeline', $schedConf->getSetting('postTimeline'));
                 $this->assign('schedConfPostTimelineOrder', $schedConf->getSetting('postTimelineOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Timeline');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Timeline');
                 // CFP displayed
                 $showCFPDate = $schedConf->getSetting('showCFPDate');
                 $postCFP = $schedConf->getSetting('postCFP');
                 if ($postCFP && $showCFPDate && $submissionsCloseDate && $currentTime > $showCFPDate && $currentTime < $submissionsCloseDate) {
                     $this->assign('schedConfShowCFP', true);
                     $this->assign('schedConfShowCFPOrder', $schedConf->getSetting('postCFPOrder'));
                     $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'CFP');
                     $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'CFP');
                 }
                 $this->assign('schedConfPostPayment', $schedConf->getSetting('postPayment'));
                 $this->assign('schedConfPostPaymentOrder', $schedConf->getSetting('postPaymentOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Payment');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Payment');
                 $this->assign('schedConfPostTrackPolicies', $schedConf->getSetting('postTrackPolicies'));
                 $this->assign('schedConfPostTrackPoliciesOrder', $schedConf->getSetting('postTrackPoliciesOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'TrackPolicies');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'TrackPolicies');
                 $this->assign('schedConfPostPresentations', $schedConf->getSetting('postPresentations'));
                 $this->assign('schedConfPostPresentationsOrder', $schedConf->getSetting('postPresentationsOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Presentations');
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Presentations');
                 $this->assign('schedConfPostLocation', $schedConf->getSetting('postLocation'));
                 $this->assign('schedConfPostLocationOrder', $schedConf->getSetting('postLocationOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Location');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Location');
                 $this->assign('schedConfPostAccommodation', $schedConf->getSetting('postAccommodation'));
                 $this->assign('schedConfPostAccommodationOrder', $schedConf->getSetting('postAccommodationOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Accommodation');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Accommodation');
                 $this->assign('schedConfPostSupporters', $schedConf->getSetting('postSupporters'));
                 $this->assign('schedConfPostSupportersOrder', $schedConf->getSetting('postSupportersOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Supporters');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Supporters');
                 // 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);
                 $this->assign('schedConfShowProgramOrder', $schedConf->getSetting('postProgramOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Program');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Program');
                 //}
                 // Contact & Contact Email
                 if ($schedConf->getSetting('postContact') && ($schedConf->getSetting('postContact') || $schedConf->getSetting('postContact'))) {
                     $this->assign('schedConfShowContact', true);
                     $this->assign('schedConfShowContactOrder', $schedConf->getSetting('postContactOrder'));
                     $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'Contact');
                     $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'Contact');
                 }
                 if ($schedConf->getSetting('contactEmail') && ($schedConf->getSetting('contactEmail') || $schedConf->getSetting('contactEmail'))) {
                     $this->assign('schedConfContactEmail', $schedConf->getSetting('contactEmail'));
                 }
                 // Submissions open
                 $submissionsOpenDate = $schedConf->getSetting('submissionsOpenDate');
                 $postSubmission = $schedConf->getSetting('postProposalSubmission');
                 $this->assign('submissionsOpenDate', $submissionsOpenDate);
                 $this->assign('schedConfShowProposalSubmissionOrder', $schedConf->getSetting('postProposalSubmissionOrder'));
                 $this->_addNavMenuItemOrder($schedConf, $navMenuItemOrder, 'ProposalSubmission');
                 $this->_addNavMenuItemNavOrder($schedConf, $navMenuItemNavOrder, 'ProposalSubmission');
                 import('payment.ocs.OCSPaymentManager');
                 $paymentManager =& OCSPaymentManager::getManager();
                 $this->assign('schedConfPaymentsEnabled', $paymentManager->isConfigured());
                 // 再加入 $navMenuItems
                 foreach ($navMenuItems as $navItemId => $navItem) {
                     $navItemOrder = 90;
                     if (isset($navItem["order"]) && trim($navItem["order"]) !== "") {
                         $navItemOrder = trim($navItem["order"]);
                     }
                     if (isset($navMenuItemOrder[$navItemOrder]) === FALSE || is_array($navMenuItemOrder[$navItemOrder]) === FALSE) {
                         $navMenuItemOrder[$navItemOrder] = array();
                     }
                     $navMenuItemOrder[$navItemOrder][] = 'schedConfNavItem' . $navItemId;
                     if (isset($navItem["navOrder"]) && trim($navItem["navOrder"]) !== "" && trim($navItem["navOrder"]) !== "0") {
                         $navItemOrder = trim($navItem["order"]);
                         if (isset($navMenuItemNavOrder[$navItemOrder]) === FALSE || is_array($navMenuItemNavOrder[$navItemOrder]) === FALSE) {
                             $navMenuItemNavOrder[$navItemOrder] = array();
                         }
                         $navMenuItemNavOrder[$navItemOrder][] = 'schedConfNavItem' . $navItemId;
                     }
                 }
                 ksort($navMenuItemOrder);
                 $this->assign('schedConfNavMenuItemOrder', $navMenuItemOrder);
                 ksort($navMenuItemNavOrder);
                 $this->assign('schedConfNavMenuItemNavOrder', $navMenuItemNavOrder);
                 //print_r($navMenuItemOrder);
             }
             //if (isset($schedConf)) {
             // Assign conference stylesheet and footer
             $conferenceStyleSheet = $conference->getSetting('conferenceStyleSheet');
             if ($conferenceStyleSheet) {
                 $this->addStyleSheet(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(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', Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath());
         }
     }
 }
コード例 #9
0
 /**
  * Save registration.
  */
 function execute()
 {
     $schedConf =& Request::getSchedConf();
     $user =& Request::getUser();
     $registrationOptionIds = (array) $this->getData('registrationOptionId');
     if (!$user) {
         // New user
         $user = new User();
         $user->setUsername($this->getData('username'));
         $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->insertUser($user);
         if (!$userId) {
             return REGISTRATION_FAILED;
         }
         $conference =& 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()) {
         Request::redirect('index');
     }
     import('classes.payment.ocs.OCSPaymentManager');
     $paymentManager =& OCSPaymentManager::getManager();
     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 .= Locale::translate('schedConf.registrationOptions.removed', array('option' => $registrationOption->getRegistrationOptionName())) . "\n";
             } elseif (!$previouslyChosen && $newlyChosen) {
                 $optionsDiffer .= Locale::translate('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($queuedPaymentId, $queuedPayment);
         return REGISTRATION_FREE;
     } else {
         $paymentManager->displayPaymentForm($queuedPaymentId, $queuedPayment);
     }
     $this->_registration =& $registration;
     $this->_queuedPayment =& $queuedPayment;
     // Add reviewing interests to interests table
     $interestDao =& DAORegistry::getDAO('InterestDAO');
     $interests = Request::getUserVar('interestsKeywords');
     $interests = array_map('urldecode', $interests);
     // The interests are coming in encoded -- Decode them for DB storage
     $interestTextOnly = Request::getUserVar('interests');
     if (!empty($interestsTextOnly)) {
         // If JS is disabled, this will be the input to read
         $interestsTextOnly = explode(",", $interestTextOnly);
     } else {
         $interestsTextOnly = null;
     }
     if ($interestsTextOnly && !isset($interests)) {
         $interests = $interestsTextOnly;
     } elseif (isset($interests) && !is_array($interests)) {
         $interests = array($interests);
     }
     $interestDao->insertInterests($interests, $user->getId(), true);
     return REGISTRATION_SUCCESSFUL;
 }
コード例 #10
0
ファイル: PayPalPlugin.inc.php プロジェクト: artkuo/ocs
 /**
  * Handle incoming requests/notifications
  * @param $request PKPRequest
  */
 function handle($args, &$request)
 {
     $templateMgr =& TemplateManager::getManager();
     $schedConf =& $request->getSchedConf();
     if (!$schedConf) {
         return parent::handle($args);
     }
     // Just in case we need to contact someone
     import('classes.mail.MailTemplate');
     // Prefer technical support contact
     $contactName = $schedConf->getSetting('supportName');
     $contactEmail = $schedConf->getSetting('supportEmail');
     if (!$contactEmail) {
         // Fall back on primary contact
         $contactName = $schedConf->getSetting('contactName');
         $contactEmail = $schedConf->getSetting('contactEmail');
     }
     $mail = new MailTemplate('PAYPAL_INVESTIGATE_PAYMENT');
     $mail->setFrom($contactEmail, $contactName);
     $mail->addRecipient($contactEmail, $contactName);
     $paymentStatus = $request->getUserVar('payment_status');
     switch (array_shift($args)) {
         case 'ipn':
             // Build a confirmation transaction.
             $req = 'cmd=_notify-validate';
             if (get_magic_quotes_gpc()) {
                 foreach ($_POST as $key => $value) {
                     $req .= '&' . urlencode(stripslashes($key)) . '=' . urlencode(stripslashes($value));
                 }
             } else {
                 foreach ($_POST as $key => $value) {
                     $req .= '&' . urlencode($key) . '=' . urlencode($value);
                 }
             }
             // Create POST response
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $this->getSetting($schedConf->getConferenceId(), $schedConf->getId(), 'paypalurl'));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($req)));
             curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
             $ret = curl_exec($ch);
             $curlError = curl_error($ch);
             curl_close($ch);
             // Check the confirmation response and handle as necessary.
             if (strcmp($ret, 'VERIFIED') == 0) {
                 switch ($paymentStatus) {
                     case 'Completed':
                         $payPalDao = DAORegistry::getDAO('PayPalDAO');
                         $transactionId = $request->getUserVar('txn_id');
                         if ($payPalDao->transactionExists($transactionId)) {
                             // A duplicate transaction was received; notify someone.
                             $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true)));
                             $mail->send();
                             exit;
                         } else {
                             // New transaction succeeded. Record it.
                             $payPalDao->insertTransaction($transactionId, $request->getUserVar('txn_type'), $request->getUserVar('payer_email'), $request->getUserVar('receiver_email'), $request->getUserVar('item_number'), $request->getUserVar('payment_date'), $request->getUserVar('payer_id'), $request->getUserVar('receiver_id'));
                             $queuedPaymentId = $request->getUserVar('custom');
                             import('classes.payment.ocs.OCSPaymentManager');
                             $ocsPaymentManager = new OCSPaymentManager($request);
                             // Verify the cost and user details as per PayPal spec.
                             $queuedPayment =& $ocsPaymentManager->getQueuedPayment($queuedPaymentId);
                             if (!$queuedPayment) {
                                 // The queued payment entry is missing. Complain.
                                 $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true)));
                                 $mail->send();
                                 exit;
                             }
                             if (($queuedAmount = $queuedPayment->getAmount()) != ($grantedAmount = $request->getUserVar('mc_gross')) || ($queuedCurrency = $queuedPayment->getCurrencyCode()) != ($grantedCurrency = $request->getUserVar('mc_currency')) || ($grantedEmail = $request->getUserVar('receiver_email')) != ($queuedEmail = $this->getSetting($schedConf->getConferenceId(), $schedConf->getId(), 'selleraccount'))) {
                                 // The integrity checks for the transaction failed. Complain.
                                 $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to PayPal account: {$grantedEmail}\n" . "Configured PayPal account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true)));
                                 $mail->send();
                                 exit;
                             }
                             // Fulfill the queued payment.
                             if ($ocsPaymentManager->fulfillQueuedPayment($request, $queuedPaymentId, $queuedPayment)) {
                                 // Send the registrant a notification that their payment was received
                                 $schedConfSettingsDao = DAORegistry::getDAO('SchedConfSettingsDAO');
                                 // Get registrant name and email
                                 $userDao = DAORegistry::getDAO('UserDAO');
                                 $user =& $userDao->getById($queuedPayment->getUserId());
                                 $registrantName = $user->getFullName();
                                 $registrantEmail = $user->getEmail();
                                 // Get conference contact details
                                 $schedConfId = $schedConf->getId();
                                 $registrationName = $schedConfSettingsDao->getSetting($schedConfId, 'registrationName');
                                 $registrationEmail = $schedConfSettingsDao->getSetting($schedConfId, 'registrationEmail');
                                 $registrationPhone = $schedConfSettingsDao->getSetting($schedConfId, 'registrationPhone');
                                 $registrationFax = $schedConfSettingsDao->getSetting($schedConfId, 'registrationFax');
                                 $registrationMailingAddress = $schedConfSettingsDao->getSetting($schedConfId, 'registrationMailingAddress');
                                 $registrationContactSignature = $registrationName;
                                 if ($registrationMailingAddress != '') {
                                     $registrationContactSignature .= "\n" . $registrationMailingAddress;
                                 }
                                 if ($registrationPhone != '') {
                                     $registrationContactSignature .= "\n" . AppLocale::Translate('user.phone') . ': ' . $registrationPhone;
                                 }
                                 if ($registrationFax != '') {
                                     $registrationContactSignature .= "\n" . AppLocale::Translate('user.fax') . ': ' . $registrationFax;
                                 }
                                 $registrationContactSignature .= "\n" . AppLocale::Translate('user.email') . ': ' . $registrationEmail;
                                 $paramArray = array('registrantName' => $registrantName, 'conferenceName' => $schedConf->getLocalizedName(), 'invoiceId' => $queuedPayment->getInvoiceId(), 'registrationContactSignature' => $registrationContactSignature);
                                 import('classes.mail.MailTemplate');
                                 $mail = new MailTemplate('PAYPAL_PAYMENT_RECEIVED');
                                 $mail->setFrom($registrationEmail, $registrationName);
                                 $mail->assignParams($paramArray);
                                 $mail->addRecipient($registrantEmail, $registrantName);
                                 $mail->send();
                                 exit;
                             }
                             // If we're still here, it means the payment couldn't be fulfilled.
                             $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Queued payment ID {$queuedPaymentId} could not be fulfilled.", 'serverVars' => print_r($_SERVER, true)));
                             $mail->send();
                         }
                         exit;
                     case 'Pending':
                         // Ignore.
                         exit;
                     default:
                         // An unhandled payment status was received; notify someone.
                         $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Payment status: {$paymentStatus}", 'serverVars' => print_r($_SERVER, true)));
                         $mail->send();
                         exit;
                 }
             } else {
                 // An unknown confirmation response was received; notify someone.
                 $mail->assignParams(array('schedConfName' => $schedConf->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Confirmation return: {$ret}\nCURL error: {$curlError}", 'serverVars' => print_r($_SERVER, true)));
                 $mail->send();
                 exit;
             }
             break;
         case 'cancel':
             Handler::setupTemplate($request);
             $templateMgr->assign(array('currentUrl' => $request->url(null, null, 'index'), 'pageTitle' => 'plugins.paymethod.paypal.purchase.cancelled.title', 'message' => 'plugins.paymethod.paypal.purchase.cancelled'));
             $templateMgr->display('common/message.tpl');
             exit;
     }
     parent::handle($args, $request);
     // Don't know what to do with it
 }