本文整理汇总了PHP中CBPTXT类的典型用法代码示例。如果您正苦于以下问题:PHP CBPTXT类的具体用法?PHP CBPTXT怎么用?PHP CBPTXT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBPTXT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawUserSomethings
/**
* Draws the user profile tab "Subscriptions" (if enabled, user is the profile owner, and something to display.
*
* @param UserTable $user
* @param boolean $itsmyself
* @param string $htmlSubscribed
* @return string
*/
public function drawUserSomethings($user, $itsmyself, $htmlSubscribed)
{
global $_CB_framework, $ueConfig;
$this->htmlSubscribed = $htmlSubscribed;
$subscriptions = $this->_model;
if (count($subscriptions) == 1) {
$subTxt = CBPTXT::T(cbpaidApp::settingsParams()->get('subscription_name', 'subscription'));
} else {
$subTxt = CBPTXT::T(cbpaidApp::settingsParams()->get('subscriptions_name', 'subscriptions'));
}
if ($itsmyself) {
$userName = null;
} else {
$userName = getNameFormat($user->name, $user->username, $ueConfig['name_format']);
}
if ($_CB_framework->getUi() == 1) {
if ($itsmyself) {
$this->htmlTabTitle = sprintf(CBPTXT::Th("Your current %s"), $subTxt);
} else {
$this->htmlTabTitle = sprintf(CBPTXT::Th("%s's current %s"), $userName, $subTxt);
}
} else {
if ($itsmyself) {
$this->htmlTabTitle = sprintf(CBPTXT::Th("Your current and past %s"), $subTxt);
} else {
$this->htmlTabTitle = sprintf(CBPTXT::Th("%s's current and past %s"), $userName, $subTxt);
}
}
return $this->display();
}
示例2: buttonText
/**
* Returns text for button for upgrade, renewals, etc.
*
* @param string $type 'upgrade', 'pay', 'renew', 'reactivate', 'resubscribe', 'unsubscribe', 'delete', default is Apply
* @return string translated button text (without htmlspecialchars, it will be applied on the returned text.
*/
public function buttonText( $type ) {
switch ( $type ) {
case 'upgrade':
return CBPTXT::T("Buy");
case 'pay':
return CBPTXT::T("Buy Now");
default:
return parent::buttonText( $type );
}
}
示例3: drawUserUpgradePlans
/**
* Draws the plans upgrade proposals
*
* @param UserTable $user
* @param int $plansDisplayed
* @param string $htmlUpgrades
* @param string $htmlspecialcharedBaseUrl
* @param array $hiddenFlds
* @param array $buttonTexts
* @param string $buttonName
* @return string
*/
public function drawUserUpgradePlans($user, $plansDisplayed, $htmlUpgrades, $htmlspecialcharedBaseUrl, $hiddenFlds, $buttonTexts, $buttonName)
{
$this->htmlUpgrades = $htmlUpgrades;
$this->htmlspecialcharedBaseUrl = $htmlspecialcharedBaseUrl;
$this->hiddenFlds = $hiddenFlds;
$this->buttonName = $buttonName;
$this->buttonText = implode(' / ', $buttonTexts);
$subTxt = CBPTXT::T(cbpaidApp::settingsParams()->get('subscription_name', 'subscription'));
if ($plansDisplayed == 1) {
$this->htmlTitle = sprintf(CBPTXT::Th("Your current %s upgrade possibility:"), $subTxt);
} else {
$this->htmlTitle = sprintf(CBPTXT::Th("Your current %s upgrade possibilities:"), $subTxt);
}
return $this->display();
}
示例4: drawTab
/**
* Draws the user profile tab "Subscriptions" (if enabled, user is the profile owner, and something to display.
*
* @param string $htmlSubscriptionsAndUpgrades
* @param string $htmlInvoicesLink
* @param string $tabTitleText
* @param string $htmlTabDescription
* @return string
*/
public function drawTab($htmlSubscriptionsAndUpgrades, $htmlInvoicesLink, $tabTitleText, $htmlTabDescription)
{
global $ueConfig;
$this->htmlSubscriptionsAndUpgrades = $htmlSubscriptionsAndUpgrades;
$this->htmlInvoicesLink = $htmlInvoicesLink;
$this->htmlTabDescription = $htmlTabDescription;
$user = $this->_model;
$title = cbReplaceVars(CBPTXT::Th(cbUnHtmlspecialchars($tabTitleText)), $user);
if ($title) {
$name = getNameFormat($user->name, $user->username, $ueConfig['name_format']);
$title = sprintf($title, $name);
}
$this->htmlTabTitle = $title;
return $this->display();
}
示例5: sendMail
/**
* Builds and sends e-mail
*
* @param UserTable $user
* @param string $mailFrom_email
* @param string $mailFrom_name
* @param string $mailTo
* @param string $mailSubject
* @param string $mailBody
* @param string $mailHtml
* @param string $mailCC
* @param string $mailBCC
* @param string $mailAttachments
* @param string[] $extraStrings
* @return void
*/
protected function sendMail( $user, $mailFrom_email, $mailFrom_name, $mailTo, $mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments, $extraStrings ) {
global $_CB_framework;
cbimport( 'cb.tabs' );
$cbUser = CBuser::getInstance( $user->id );
if ( ! $cbUser ) {
return;
}
$mailFrom_email = trim( $cbUser->replaceUserVars( $mailFrom_email, false, false, array(), false ) );
$mailFrom_name = trim( $cbUser->replaceUserVars( $mailFrom_name, false, false, array(), false ) );
$mailTo = trim( $cbUser->replaceUserVars( $mailTo, false, false, array(), false ) );
$mailCC = trim( $cbUser->replaceUserVars( $mailCC, false, false, array(), false ) );
$mailBCC = trim( $cbUser->replaceUserVars( $mailBCC, false, false, array(), false ) );
$mailSubject = trim( $cbUser->replaceUserVars( CBPTXT::T( $mailSubject ), false, false, $extraStrings, false ) );
$mailBody = trim( $cbUser->replaceUserVars( CBPTXT::T( $mailBody ), false, false, $extraStrings, false ) );
$mailAttachments = trim( $mailAttachments );
if ( $mailTo != '' ) {
$mailTo = preg_split( '/ *, */', $mailTo );
} else {
return;
}
if ( $mailCC != '' ) {
$mailCC = preg_split( '/ *, */', $mailCC );
} else {
$mailCC = null;
}
if ( $mailBCC != '' ) {
$mailBCC = preg_split( '/ *, */', $mailBCC );
} else {
$mailBCC = null;
}
if ( $mailAttachments != '' ) {
$mailAttachments = preg_split( '/ *, */', $mailAttachments );
} else {
$mailAttachments = null;
}
if ( $mailTo && ( $mailSubject || $mailBody ) ) {
comprofilerMail( $mailFrom_email, $mailFrom_name, $mailTo, $_CB_framework->getCfg( 'sitename' ).' - '.$mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments );
}
}
示例6: canDelete
/**
* Check for whether dependancies exist for this object in the db schema
*
* @param int $oid Optional key index
* @return boolean TRUE: OK to delete, FALSE: not OK to delete, error in $this->_error
*/
public function canDelete($oid = null)
{
$k = $this->_tbl_key;
if ($oid) {
$this->{$k} = $oid;
}
$query = "SELECT COUNT(*)" . "\n FROM `#__cbsubs_subscriptions`" . "\n WHERE `plan_id` = " . (int) $this->{$k};
$this->_db->setQuery($query);
$obj = null;
$count = $this->_db->loadResult($obj);
if ($count > 0) {
$this->setError(CBPTXT::T("Subscriptions exist for this plan"));
return false;
}
return parent::canDelete($oid);
}
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:22,代码来源:cbpaidProductUsersubscription.php
示例7: renderCurrencySymbol
/**
* Renders the currency symbol according to global settings
*
* @param string|null $currency
* @param boolean $html
* @return string
*/
public function renderCurrencySymbol( $currency, $html ) {
$params = $this->params;
if ( $currency === null ) {
$currency = $params->get( 'currency_code', 'USD' );
}
$priceCurrencyFormat = $params->get('price_currency_format', '%2$s %1$s' );
if ( $html ) {
if ( strpos( $priceCurrencyFormat, '%3' ) !== false ) {
$currencySymbols = array ( 'EUR' => '€', 'USD' => '$', 'GBP' => '£', 'JPY' => '¥', 'CHF' => 'Fr.', 'CAD' => 'C$', 'AUD' => '$', 'BRL' => 'R$', 'CNY' => '¥', 'DKK' => 'KR', 'ZAR' => 'R', 'SEK' => 'KR' ); //TBD: move to currency table
$textHtmlSymbol = isset( $currencySymbols[$currency] ) ? $currencySymbols[$currency] : CBPTXT::Th( $currency );
} else {
$textHtmlSymbol = CBPTXT::Th( $currency );
}
$textHtmlSymbol = '<span class="cbregPcur">' . $textHtmlSymbol . '</span>';
} else {
$textHtmlSymbol = CBPTXT::T( $currency );
}
return $textHtmlSymbol;
}
示例8: renderColumn
/**
* Renders a $variable for an $output
*
* @param string $variable
* @param string $output
* @param boolean $rounded
* @return string|null
*/
public function renderColumn($variable, $output = 'html', $rounded = false)
{
$html = $output == 'html';
switch ($variable) {
case 'rate':
$ret = $this->renderItemRate($html);
break;
case 'discount_amount':
case 'tax_amount':
$ret = $this->renderJustItemRates($variable, $html, $rounded);
break;
case 'first_rate':
case 'first_discount_amount':
case 'first_tax_amount':
$ret = cbpaidMoney::getInstance()->renderPrice($this->{$variable}, $this->currency, $html, $rounded);
break;
case 'quantity':
// removes insignifiant zeros after ., as well as the . itself if no decimals:
$matches = null;
$matched = preg_match("/^(.+?)[.]?[0]*\$/", $this->get($variable), $matches);
$ret = $matched ? $matches[1] : null;
break;
case 'validity_period':
if ($this->start_date && $this->stop_date && $this->start_date != '0000-00-00 00:00:00' && $this->stop_date != '0000-00-00 00:00:00') {
$showTime = false;
$startDate = cbFormatDate($this->start_date, 1, $showTime);
$stopDate = cbFormatDate($this->stop_date, 1, $showTime);
$ret = htmlspecialchars($startDate);
if ($stopDate && $startDate != $stopDate) {
$ret .= ($html ? ' - ' : ' - ') . htmlspecialchars($stopDate);
}
if ($this->second_stop_date && $this->second_stop_date != '0000-00-00 00:00:00') {
$secondStartDate = cbFormatDate($this->_db->getUtcDateTime(cbpaidTimes::getInstance()->strToTime($this->stop_date) + 1), 1, $showTime);
$secondStopDate = cbFormatDate($this->second_stop_date, 1, $showTime);
$retsecond = htmlspecialchars($secondStartDate) . ($html ? ' - ' : ' - ') . htmlspecialchars($secondStopDate);
$ret = sprintf($html ? CBPTXT::Th("%s, then %s") : CBPTXT::T("%s, then %s"), $ret, $retsecond);
}
} else {
$ret = null;
}
break;
case 'tax_rule_id':
if ($this->tax_rule_id && is_callable(array('cbpaidTaxRule', 'getInstance'))) {
$ret = cbpaidTaxRule::getInstance((int) $this->tax_rule_id)->getShortCode();
} else {
$ret = null;
}
break;
case 'original_rate':
case 'first_original_rate':
$ret = null;
break;
case 'ordering':
case 'artnum':
case 'description':
case 'discount_text':
default:
$value = $this->get($variable);
if ($value !== null) {
$ret = htmlspecialchars($this->get($variable));
} else {
$ret = null;
}
break;
}
return $ret;
}
示例9: attemptScheduledTask
/**
* When triggered, before starting to make changes this method should be called
* Transition: -> E{$substate}
*
* @param string $substate
* @return boolean TRUE: got lock to perform scheduled task, FALSE: no scheduling needed here (and no transition made)
*/
public function attemptScheduledTask( $substate = '' ) {
if ( substr( $this->_baseObject->scheduler_state, 0, 1 ) == 'E' ) {
// It was Executing: check for iterations before resetting to 'S' (with error log).
if ( strlen( $this->_baseObject->scheduler_state ) == 1 ) {
// Backwards compatibility:
$this->_baseObject->scheduler_state .= '1';
}
$iteration = (int) $this->_baseObject->scheduler_state[1];
if ( ++$iteration <= $this->maxExecWaitIterations ) {
$this->_baseObject->scheduler_state[1] = (string) $iteration;
$this->_baseObject->store();
} else {
$this->_baseObject->scheduler_state = 'S';
cbpaidApp::setLogErrorMSG( 4, $this->_baseObject, CBPTXT::P("Scheduler for this basket has stayed in execution state for [NUMBER_OF_CRONS] cron cycles. Resetting execution state.", array( '[NUMBER_OF_CRONS]' => $this->maxExecWaitIterations ) ), null );
}
}
// Now normal case:
if ( $this->_baseObject->scheduler_state == 'S' ) {
// it was scheduled:
$this->_baseObject->scheduler_state = 'E1' . $substate; // Executing
return $this->_baseObject->store();
}
return false;
}
示例10: loadLang
/**
* Standard language loading method:
* @todo add to CB API
*
* @param string $interface 'admin' to force-load admin languages
*/
public static function loadLang($interface = null)
{
global $_CB_framework;
static $loaded = false;
static $adminLoaded = false;
if (!$loaded) {
$path = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/language';
$myLanguageFolder = '-' . strtolower($_CB_framework->getCfg('lang_tag'));
$myLanguageFile = 'language.php';
$file = $path . '/cbpaidsubscriptions' . $myLanguageFolder . '/' . $myLanguageFile;
if (!file_exists($file)) {
// Old method:
$myLanguageFolder = $_CB_framework->getCfg('lang');
$myLanguageFile = $myLanguageFolder . '.php';
$file = $path . '/cbpaidsubscriptions' . $myLanguageFolder . '/' . $myLanguageFile;
}
if (file_exists($file)) {
if (!$interface) {
$CBstrings = array();
/** @noinspection PhpIncludeInspection */
include_once $file;
// defines $CBstrings
CBPTXT::addStrings($CBstrings);
}
if ($_CB_framework->getUi() == 2 || $interface == 'admin') {
if (!$adminLoaded) {
$file = $path . '/cbpaidsubscriptions' . $myLanguageFolder . '/admin_' . $myLanguageFile;
if (file_exists($file)) {
$CBstrings = array();
/** @noinspection PhpIncludeInspection */
include_once $file;
// defines $CBstrings
CBPTXT::addStrings($CBstrings);
}
$adminLoaded = true;
}
}
}
$loaded = true;
}
}
示例11: store
/**
* store() function override, instead of storing it imports.
*
* @param boolean $updateNulls
* @return boolean
*/
public function store($updateNulls = false)
{
$return = '';
// Check if file uploads are enabled
if (!(bool) ini_get('file_uploads')) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("The importer can't continue before file uploads are enabled in PHP settings.");
return false;
}
if (!$this->import_type) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No import type selected");
return false;
}
$fromFile = cbStartOfStringMatch($this->import_type, 'file_');
if ($fromFile) {
$userfile = $_FILES['userfile'];
if (!$userfile || $userfile == null) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No file selected");
return false;
}
if (isset($userfile['error']) && $userfile['error']) {
$errors_array = array(1 => CBPTXT::T("The uploaded file exceeds the upload_max_filesize directive in php.ini."), 2 => CBPTXT::T("The uploaded file exceeds the maximum size allowed by this form."), 3 => CBPTXT::T("The uploaded file was only partially uploaded."), 4 => CBPTXT::T("No file was selected and uploaded."), 6 => CBPTXT::T("Missing a temporary folder in php.ini."), 7 => CBPTXT::T("Failed to write file to disk."), 8 => CBPTXT::T("File upload stopped by extension."));
if (in_array($userfile['error'], $errors_array)) {
$fileErrorTxt = $errors_array[$userfile['error']];
} else {
$fileErrorTxt = CBPTXT::T("File upload error number ") . htmlspecialchars($userfile['error']);
}
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . $fileErrorTxt;
return false;
}
if (!$userfile['tmp_name'] || !is_uploaded_file($userfile['tmp_name'])) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No temporary file name");
return false;
}
if ($userfile['size'] == 0) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("Empty file");
return false;
}
} else {
$userfile = null;
}
if ($this->import_type == 'cms_acl') {
if (!$this->usergroup) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No usergroup selected");
return false;
}
}
if ($this->import_type == 'subscription') {
if (!$this->from_plan) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription plan selected");
return false;
}
if (!$this->from_sub_status) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription status selected");
return false;
}
}
if ($this->import_type != 'file_uid_plan_exp') {
if (!$this->plan) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No plan selected");
return false;
}
if (!$this->state) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription state selected");
return false;
}
if (!$this->date) {
$this->_error = CBPTXT::T("Importer") . ' - ' . CBPTXT::T("error:") . ' ' . CBPTXT::T("No subscription date selected");
return false;
}
}
if ($fromFile) {
$tmpName = $userfile['tmp_name'];
$fileSize = (int) $userfile['size'];
// $fileType = $userfile['type'];
} else {
$tmpName = null;
$fileSize = null;
}
$planStateDate = array();
switch ($this->import_type) {
case 'file_uid':
$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
fclose($fp);
unlink($tmpName);
$userIdList = explode(',', trim($content));
break;
case 'file_uid_plan_exp':
$userIdList = array();
$fp = fopen($tmpName, 'r');
if ($fp) {
$n = 0;
while (!feof($fp)) {
$line = trim(str_replace('"', '', fgets($fp, 256)));
//.........这里部分代码省略.........
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:101,代码来源:cbpaidSubscriptionsImporter.php
示例12: _renderPeriodOfValiditiy
/**
* Returns formatted time period ( xxx weeks , or xxx years xxx months xxx days xxx hours xxx minutes xxx seconds
*
* @param string $varName 'validity' or 'fist_validity'
* @param int $occurrences [default: 1] multiply period by the occurrences before displaying
* @param boolean $displayOne [default: true] displays also if only 1 unit of something
* @param boolean $displayCalendarYearStart [default: true] displays start of calendar year if not January 1st
* @return string
*/
private function _renderPeriodOfValiditiy( $varName, $occurrences = 1, $displayOne = true, $displayCalendarYearStart = true ) {
// $ycdhmsArray = $this->_timedObject->getValidity( $varName );
// $prefix = ( $this->_timedObject->isCalendarValidity( $varName ) ? CBPTXT::T("calendar ") : '' );
// return $this->_timedObject->renderPeriod( $ycdhmsArray, $occurrences, $displayOne, $prefix );
$ycdhmsArray = $this->getValidity( $varName );
$prefix = ( $this->isCalendarValidity( $varName ) ? CBPTXT::T("calendar ") : '' );
$text = $this->renderPeriod( $ycdhmsArray, $occurrences, $displayOne, $prefix );
$calStart = $this->calendarYearStart( $varName );
if ( $prefix && ( $calStart != '01-01' ) && $displayCalendarYearStart ) {
list( $m, $d ) = explode( '-', $calStart );
$text .= ' ' . CBPTXT::T("starting") . ' ' . date( 'F j', mktime( 0, 0, 0, $m, $d, 2004 ) );
}
return $text;
}
示例13: renderTotalRate
/**
* Renders the rate of $this payment item
*
* @param string $variable
* @param boolean $output 'html', ...
* @param boolean $rounded
* @return string|null
*/
private function renderTotalRate($variable, $output, $rounded = false)
{
$renderedBasketPrice = null;
$params = cbpaidApp::settingsParams();
if ($params->get('totalizer_description_' . 'grandtotal') == '[AUTOMATIC]') {
list($recurring, , $period, $occurrences) = $this->_itemsProps($this->_paymentBasket->loadPaymentItems());
$renderedBasketPrice = $this->_paymentBasket->renderPrice(null, null, null, true);
if ($recurring && ($this->_paymentBasket->period1 && $this->_paymentBasket->mc_amount1 != $this->_paymentBasket->mc_amount3)) {
$then = $this->_paymentBasket->renderPrice($this->_paymentBasket->mc_amount3, $period, $occurrences, true);
$renderedBasketPrice = sprintf(CBPTXT::Th("%s, then %s"), $renderedBasketPrice, $then);
}
} else {
parent::renderColumn($variable, $output, $rounded);
}
return $renderedBasketPrice;
}
示例14: _file_path
/**
* Finds file and returns absolute file path
*
* @param string $layout one word name
* @param string $extension '.php' or '.css'
* @return string|null
*/
protected function _file_path( $layout, $extension ) {
global $_CB_framework;
$saneLayout = ( $layout ? preg_replace( '/\W/', '', strtolower( $layout ) ) : 'default' ) . $extension;
if ( $extension === '.php' ) {
$absPrefix = $_CB_framework->getCfg( 'absolute_path' );
$chkPrefix = '';
$saneLayout = $this->viewName . '/' . $saneLayout;
} else {
$absPrefix = '';
$chkPrefix = $_CB_framework->getCfg( 'absolute_path' );
}
$cmsTemplate = $this->_cmsCurrentTemplate();
$overrideFilePath = '/templates/' . $cmsTemplate . '/html/com_comprofiler/' . $this->_overrideSubFolder . '/';
if ( $cmsTemplate && file_exists( $chkPrefix . $absPrefix . $overrideFilePath . $saneLayout ) ) {
$this->_tmplUsedPath = $overrideFilePath;
return $absPrefix . $overrideFilePath . $saneLayout;
} else {
$internalFilePath = '/components/com_comprofiler/' . $this->_defaultTemplatePath . '/' . $this->templateToUse() . '/';
if ( file_exists( $chkPrefix . $absPrefix . $internalFilePath . $saneLayout ) ) {
$this->_tmplUsedPath = $internalFilePath;
return $absPrefix . $internalFilePath . $saneLayout;
} else {
$defaultInternalFilePath = '/components/com_comprofiler/' . $this->_defaultTemplatePath . '/' . 'default' . '/';
if ( ( $this->templateToUse() != 'default' ) && file_exists( $chkPrefix . $absPrefix . $defaultInternalFilePath . $saneLayout ) ) {
$this->_tmplUsedPath = $defaultInternalFilePath;
return $absPrefix . $defaultInternalFilePath . $saneLayout;
} else {
// $method = '_render' . $layout;
// if ( is_callable( array( $this, $method ) ) ) {
// $this->$method();
// } else {
trigger_error( sprintf( CBPTXT::T("CB View %s Layout %s has no rendering file %s."), $this->viewName, $saneLayout, $absPrefix . $internalFilePath . $saneLayout ), E_USER_NOTICE );
// }
}
}
}
return null;
}
示例15: store
/**
* If table key (id) is NULL : inserts a new row
* otherwise updates existing row in the database table
*
* Can be overridden or overloaded by the child class
*
* @param boolean $updateNulls TRUE: null object variables are also updated, FALSE: not.
* @return boolean TRUE if successful otherwise FALSE
*/
public function store($updateNulls = false)
{
if (!cbpaidApp::authoriseAction('cbsubs.refunds')) {
$this->setError(CBPTXT::T("Not authorized"));
return false;
}
// 1) check:
if (!in_array($this->payment_status, array('Completed', 'Pending', 'Partially-Refunded'))) {
$this->setError(CBPTXT::T("This payment is not completed, pending or partially refunded."));
return false;
}
if ($this->txn_id == '') {
$this->txn_id = 'None';
// needed for updatePayment to generate payment record.
}
$payment = new cbpaidPayment();
if (!$payment->load((int) $this->id)) {
$this->setError(CBPTXT::T("This payment does not exist."));
return false;
}
$paymentBasket = new cbpaidPaymentBasket();
if (!$paymentBasket->load($this->payment_basket_id)) {
$this->setError(CBPTXT::T("This payment has no associated payment basket and cannot be refunded from here. Maybe from your PSP online terminal ?"));
return false;
}
if (!$this->gateway_account) {
$this->setError(CBPTXT::T("This payment has no gateway associated so can not be refunded."));
return false;
}
$payAccount = cbpaidControllerPaychoices::getInstance()->getPayAccount($this->gateway_account);
if (!$payAccount) {
$this->setError(CBPTXT::T("This payment's payment basket's associated gateway account is not active, so can not be refunded from here."));
return false;
}
$payClass = $payAccount->getPayMean();
$returnText = null;
$amount = sprintf('%.2f', (double) $this->refund_gross);
if (is_callable(array($payClass, 'refundPayment'))) {
$success = $payClass->refundPayment($paymentBasket, $payment, null, $this->refund_is_last, $amount, $this->refund_reason, $returnText);
} else {
$success = false;
}
$user = CBuser::getUserDataInstance($paymentBasket->user_id);
$username = $user ? $user->username : '?';
$replacements = array('[REFUNDAMOUNT]' => $payment->mc_currency . ' ' . $amount, '[PAYMENTID]' => $payment->id, '[PAYMENTAMOUNT]' => $payment->mc_currency . ' ' . $payment->mc_gross, '[BASKETID]' => $paymentBasket->id, '[ORDERID]' => $paymentBasket->sale_id, '[FULLNAME]' => $paymentBasket->first_name . ' ' . $paymentBasket->last_name, '[USERNAME]' => $username, '[USERID]' => $paymentBasket->user_id, '[PAYMENTMETHOD]' => $payClass->getPayName(), '[TXNID]' => $payment->txn_id, '[AUTHID]' => $payment->auth_id, '[ERRORREASON]' => $paymentBasket->reason_code);
if ($success) {
// Success Message ?
// $returnText = CBPTXT::P("Refunded [REFUNDAMOUNT] for payment id [PAYMENTID] of [PAYMENTAMOUNT] for basket id [BASKETID], Order id [ORDERID] of [FULLNAME] (username [USERNAME] - user id [USERID]) using [PAYMENTMETHOD] with txn_id [TXNID] and auth_id [AUTHID].", $replacements );
} else {
$this->setError(CBPTXT::T($payClass->getErrorMSG()) . '. ' . CBPTXT::P("Refund request of [REFUNDAMOUNT] for payment id [PAYMENTID] of [PAYMENTAMOUNT] for basket id [BASKETID], Order id [ORDERID] of [FULLNAME] (username [USERNAME] - user id [USERID]) using [PAYMENTMETHOD] with txn_id [TXNID] and auth_id [AUTHID] failed for reason: [ERRORREASON].", $replacements));
return false;
}
return true;
}