00001 <?php
00002
00016
00017
00018 import('classes.plugins.PaymethodPlugin');
00019
00020 class ManualPaymentPlugin extends PaymethodPlugin {
00021
00022 function getName() {
00023 return 'ManualPayment';
00024 }
00025
00026 function getDisplayName() {
00027 return __('plugins.paymethod.manual.displayName');
00028 }
00029
00030 function getDescription() {
00031 return __('plugins.paymethod.manual.description');
00032 }
00033
00034 function register($category, $path) {
00035 if (parent::register($category, $path)) {
00036 $this->addLocaleData();
00037 return true;
00038 }
00039 return false;
00040 }
00041
00042 function getSettingsFormFieldNames() {
00043 return array('manualInstructions');
00044 }
00045
00046 function isConfigured() {
00047 $schedConf =& Request::getSchedConf();
00048 if (!$schedConf) return false;
00049
00050
00051 foreach ($this->getSettingsFormFieldNames() as $settingName) {
00052 $setting = $this->getSetting($schedConf->getConferenceId(), $schedConf->getId(), $settingName);
00053 if (empty($setting)) return false;
00054 }
00055
00056 return true;
00057 }
00058
00059 function displayPaymentForm($queuedPaymentId, &$queuedPayment) {
00060 if (!$this->isConfigured()) return false;
00061 $schedConf =& Request::getSchedConf();
00062 $templateMgr =& TemplateManager::getManager();
00063 $user =& Request::getUser();
00064
00065 $templateMgr->assign('itemName', $queuedPayment->getName());
00066 $templateMgr->assign('itemDescription', $queuedPayment->getDescription());
00067 if ($queuedPayment->getAmount() > 0) {
00068 $templateMgr->assign('itemAmount', $queuedPayment->getAmount());
00069 $templateMgr->assign('itemCurrencyCode', $queuedPayment->getCurrencyCode());
00070 }
00071 $templateMgr->assign('manualInstructions', $this->getSetting($schedConf->getConferenceId(), $schedConf->getId(), 'manualInstructions'));
00072 $templateMgr->assign('queuedPaymentId', $queuedPaymentId);
00073
00074 $templateMgr->display($this->getTemplatePath() . 'paymentForm.tpl');
00075 }
00076
00080 function handle($args) {
00081 $conference =& Request::getConference();
00082 $schedConf =& Request::getSchedConf();
00083 $templateMgr =& TemplateManager::getManager();
00084 $user =& Request::getUser();
00085 $op = isset($args[0])?$args[0]:null;
00086 $queuedPaymentId = isset($args[1])?((int) $args[1]):0;
00087
00088 import('payment.ocs.OCSPaymentManager');
00089 $ocsPaymentManager =& OCSPaymentManager::getManager();
00090 $queuedPayment =& $ocsPaymentManager->getQueuedPayment($queuedPaymentId);
00091
00092 if ( !$queuedPayment ) Request::redirect(null, null, null, 'index');
00093
00094 switch ( $op ) {
00095 case 'notify':
00096 import('mail.MailTemplate');
00097 AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
00098 $contactName = $schedConf->getSetting('registrationName');
00099 $contactEmail = $schedConf->getSetting('registrationEmail');
00100 $mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION');
00101 $mail->setFrom($contactEmail, $contactName);
00102 $mail->addRecipient($contactEmail, $contactName);
00103 $mail->assignParams(array(
00104 'schedConfName' => $schedConf->getFullTitle(),
00105 'userFullName' => $user?$user->getFullName():('(' . __('common.none') . ')'),
00106 'userName' => $user?$user->getUsername():('(' . __('common.none') . ')'),
00107 'itemName' => $queuedPayment->getName(),
00108 'itemCost' => $queuedPayment->getAmount(),
00109 'itemCurrencyCode' => $queuedPayment->getCurrencyCode()
00110 ));
00111 $mail->send();
00112
00113 $templateMgr->assign(array(
00114 'currentUrl' => Request::url(null, null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)),
00115 'pageTitle' => 'plugins.paymethod.manual.paymentNotification',
00116 'message' => 'plugins.paymethod.manual.notificationSent',
00117 'backLink' => Request::url(null, null, 'index'),
00118 'backLinkLabel' => 'common.continue'
00119 ));
00120 $templateMgr->display('common/message.tpl');
00121 exit();
00122 break;
00123 }
00124 parent::handle($args);
00125 }
00126
00127 function getInstallEmailTemplatesFile() {
00128 return ($this->getPluginPath() . DIRECTORY_SEPARATOR . 'emailTemplates.xml');
00129 }
00130
00131 function getInstallEmailTemplateDataFile() {
00132 return ($this->getPluginPath() . '/locale/{$installedLocale}/emailTemplates.xml');
00133 }
00134 }
00135
00136 ?>