本文整理汇总了PHP中RSMembershipHelper::parseParams方法的典型用法代码示例。如果您正苦于以下问题:PHP RSMembershipHelper::parseParams方法的具体用法?PHP RSMembershipHelper::parseParams怎么用?PHP RSMembershipHelper::parseParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSMembershipHelper
的用法示例。
在下文中一共展示了RSMembershipHelper::parseParams方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItem
public function getItem($pk = null)
{
$id = $pk ? $pk : $this->getState($this->getName() . '.id');
// $item = parent::getItem($id);
// if transaction is made and user is not created
$transaction = JTable::getInstance('Transaction', 'RSMembershipTable');
$transaction->load($id);
/// get the user data
$data = $transaction->user_data ? (object) unserialize($transaction->user_data) : (object) array();
if (!$transaction->user_id) {
$user = (object) array('id' => 0, 'username' => isset($data->username) && !empty($data->username) ? $data->username : JText::_('COM_RSMEMBERSHIP_SUBSCRIBERNAME_EMPTY'), 'name' => isset($data->name) ? $data->name : '', 'email' => $transaction->user_email);
} else {
$user = JFactory::getUser($transaction->user_id);
}
$params = RSMembershipHelper::parseParams($transaction->params);
$membership_id = 0;
if (isset($params['membership_id'])) {
$membership_id = $params['membership_id'];
}
if (isset($params['to_id'])) {
$membership_id = $params['to_id'];
}
$membership_info = array();
if ($membership_id) {
if ($membership_fields = RSMembership::getCustomMembershipFields($membership_id)) {
$selected = isset($data->membership_fields) ? $data->membership_fields : array();
foreach ($membership_fields as $field) {
$membership_info[] = RSMembershipHelper::showCustomField($field, $selected, false, false, 'membership');
}
}
}
$item = (object) array('user_id' => $user->id, 'username' => $user->username, 'email' => $user->email, 'name' => $user->name, 'transaction' => $id, 'transaction_data' => $transaction, 'membership_info' => $membership_info);
return $item;
}
示例2: confirm
<td align="center"><a class="delete-item" onclick="return confirm('<?php
echo JText::_('COM_RSMEMBERSHIP_CONFIRM_DELETE');
?>
')" href="<?php
echo JRoute::_('index.php?option=com_rsmembership&task=transactions.remove&cid[]=' . $row->id . '&' . JSession::getFormToken() . '=1&tabposition=2&user_id=' . $this->item->user_id);
?>
"><?php
echo JHTML::_('image', 'administrator/components/com_rsmembership/assets/images/remove.png', JText::_('Delete'));
?>
</a></td>
<td><?php
echo JText::_('COM_RSMEMBERSHIP_TRANSACTION_' . strtoupper($row->type));
?>
</td>
<td><?php
$params = RSMembershipHelper::parseParams($row->params);
switch ($row->type) {
case 'new':
if (!empty($params['membership_id'])) {
echo $this->cache->memberships[$params['membership_id']];
}
if (!empty($params['extras'])) {
foreach ($params['extras'] as $extra) {
if (!empty($extra)) {
echo '<br />- ' . $this->cache->extra_values[$extra];
}
}
}
break;
case 'upgrade':
if (!empty($params['from_id']) && !empty($params['to_id'])) {
示例3: getMembershipId
protected function getMembershipId($params, $type)
{
$params = RSMembershipHelper::parseParams($params);
switch ($type) {
case 'new':
case 'renew':
$membership_id = $params['membership_id'];
break;
case 'addextra':
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
// Verify if the subscription still exists
$current = JTable::getInstance('Membership_Subscriber', 'RSMembershipTable');
if (!$current->load($params['id'])) {
return false;
}
// Check if this membership still exists
$membership = JTable::getInstance('Membership', 'RSMembershipTable');
if (!$membership->load($current->membership_id)) {
return false;
}
$membership_id = $current->membership_id;
break;
case 'upgrade':
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
$membership = JTable::getInstance('Membership', 'RSMembershipTable');
if (!$membership->load($params['to_id'])) {
return false;
}
$membership_id = $membership->membership_id;
break;
}
return $membership_id;
}
示例4: onAfterRoute
function onAfterRoute()
{
$app =& JFactory::getApplication();
if ($app->isAdmin()) {
return;
}
if (JRequest::getVar('authorizepayment')) {
return $this->onPaymentNotification();
}
$option = JRequest::getVar('option');
$task = JRequest::getCmd('plugin_task');
$membership_id = JRequest::getInt('membership_id');
if ($option == 'com_rsmembership' && $task == 'authorize') {
@ob_end_clean();
$db =& JFactory::getDBO();
$db->setQuery("SELECT * FROM #__rsmembership_memberships WHERE `id`='" . $membership_id . "'");
$membership = $db->loadObject();
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsmembership' . DS . 'tables');
$row =& JTable::getInstance('RSMembership_Transactions', 'Table');
$transaction = $this->getDelayedTransaction();
if (empty($transaction)) {
$app->enqueueMessage('RSM_SESSION_EXPIRED', 'error');
echo 'RSM_SESSION_END';
die;
}
$row->bind($transaction);
$row->store();
$row->price += $this->_getTax($row->price);
$row->price = $this->_convertNumber($row->price);
$transaction['id'] = $row->id;
$this->delayTransactionStoring($transaction);
$description = $this->_params->get('message_type') ? $membership->name : JText::sprintf('RSM_MEMBERSHIP_PURCHASE_ON', date(RSMembershipHelper::getConfig('date_format'), $row->date));
$post_url = $this->_params->get('mode') ? "https://secure.authorize.net/gateway/transact.dll" : "https://test.authorize.net/gateway/transact.dll";
$is_recurring = $membership->recurring && $membership->period > 0 && $row->type == 'new';
$cc_number = JRequest::getCmd('cc_number', '', 'post');
$cc_expiration = substr(JRequest::getCmd('cc_exp_mm', '', 'post'), 0, 2) . '-' . JRequest::getInt('cc_exp_yy', 0, 'post');
$cc_fname = JRequest::getVar('cc_fname', '', 'post');
$cc_lname = JRequest::getVar('cc_lname', '', 'post');
$post_values = array("x_login" => $this->_params->get('x_login'), "x_tran_key" => $this->_params->get('x_tran_key'), "x_version" => "3.1", "x_delim_data" => "TRUE", "x_delim_char" => "|", "x_relay_response" => "FALSE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_card_num" => $cc_number, "x_exp_date" => $cc_expiration, "x_card_code" => JRequest::getVar('csc_number', '', 'post'), "x_amount" => $row->price, "x_currency_code" => RSMembershipHelper::getConfig('currency'), "x_invoice_num" => md5($row->id . ' ' . $this->_params->get('x_login') . ' ' . $this->_params->get('x_tran_key')), "x_description" => $description, "x_first_name" => $cc_fname, "x_last_name" => $cc_lname, "x_email" => $row->get('user_email'), "x_address" => '', "x_state" => '', "x_zip" => '');
$string = '';
foreach ($post_values as $key => $value) {
$string .= "{$key}=" . urlencode($value) . "&";
}
$string = rtrim($string, "& ");
unset($post_values);
if (!function_exists('curl_init')) {
echo JHTML::image('plugins/system/' . $this->joomla16prefix . 'rsmembershipauthorize/images/error.png', 'Error', array('id' => 'rsm_warning')) . ' ' . JText::_('RSM_AUTHORIZE_CURL_ERROR');
} else {
$request = curl_init($post_url);
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_POSTFIELDS, $string);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($request);
curl_close($request);
// close curl object
// This line takes the response and breaks it into an array using the specified delimiting character
$response = explode('|', $response);
if ($response[0] == 1) {
if (!$is_recurring) {
$this->emptyDelayedTransaction();
$row->hash = $response[6];
$row->store();
RSMembership::finalize($row->get('id'));
RSMembership::approve($row->get('id'));
} else {
list($length, $unit) = $this->_getAuthorizeLength($membership);
$date =& JFactory::getDate();
$startDate = date('Y-m-d', strtotime("+{$length} {$unit}", $date->toUnix()));
$extra_total = 0;
$params = RSMembershipHelper::parseParams($row->params);
if (!empty($params['extras'])) {
$db->setQuery("SELECT SUM(`price`) FROM #__rsmembership_extra_values WHERE `id` IN (" . implode(',', $params['extras']) . ")");
$extra_total = $db->loadResult();
}
$amount = $membership->use_renewal_price ? $membership->renewal_price : $membership->price;
$amount += $extra_total;
$amount += $this->_getTax($amount);
$trialOccurrences = $membership->use_trial_period ? 1 : 0;
$trialAmount = $membership->use_trial_period ? $membership->trial_price : 0;
$trialAmount += $extra_total;
$trialAmount += $this->_getTax($trialAmount);
$content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . "<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" . "<merchantAuthentication>" . "<name>" . $this->_params->get('x_login') . "</name>" . "<transactionKey>" . $this->_params->get('x_tran_key') . "</transactionKey>" . "</merchantAuthentication>" . "<refId>" . $row->id . "</refId>" . "<subscription>" . "<name>" . htmlentities($description, ENT_COMPAT, 'UTF-8') . "</name>" . "<paymentSchedule>" . "<interval>" . "<length>" . $length . "</length>" . "<unit>" . $unit . "</unit>" . "</interval>" . "<startDate>" . $startDate . "</startDate>" . "<totalOccurrences>9999</totalOccurrences>" . "<trialOccurrences>" . $trialOccurrences . "</trialOccurrences>" . "</paymentSchedule>" . "<amount>" . $amount . "</amount>" . "<trialAmount>" . $trialAmount . "</trialAmount>" . "<payment>" . "<creditCard>" . "<cardNumber>" . $cc_number . "</cardNumber>" . "<expirationDate>" . $cc_expiration . "</expirationDate>" . "</creditCard>" . "</payment>" . "<billTo>" . "<firstName>" . $cc_fname . "</firstName>" . "<lastName>" . $cc_lname . "</lastName>" . "</billTo>" . "</subscription>" . "</ARBCreateSubscriptionRequest>";
$post_url = $this->_params->get('mode') ? "https://api.authorize.net/xml/v1/request.api" : "https://apitest.authorize.net/xml/v1/request.api";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if ($response) {
list($refId, $resultCode, $code, $text, $subscriptionId) = $this->_parseReturn($response);
if ($resultCode == 1) {
$this->emptyDelayedTransaction();
$row->custom = $subscriptionId;
$row->store();
RSMembership::finalize($row->get('id'));
//.........这里部分代码省略.........
示例5: strtoupper
echo JText::_('COM_RSMEMBERSHIP_TYPE');
?>
</td>
<td><?php
echo JText::_('COM_RSMEMBERSHIP_TRANSACTION_' . strtoupper($this->item->transaction_data->type));
?>
</td>
</tr>
<tr>
<td width="200"><?php
echo JText::_('COM_RSMEMBERSHIP_DETAILS');
?>
</td>
<td>
<?php
$params = RSMembershipHelper::parseParams($this->item->transaction_data->params);
switch ($this->item->transaction_data->type) {
case 'new':
if (!empty($params['membership_id'])) {
echo isset($this->cache->memberships[$params['membership_id']]) ? $this->cache->memberships[$params['membership_id']] : JText::_('COM_RSMEMBERSHIP_COULD_NOT_FIND_MEMBERSHIP');
}
if (!empty($params['extras'])) {
foreach ($params['extras'] as $extra) {
if (!empty($extra)) {
echo '<br />- ' . $this->cache->extra_values[$extra];
}
}
}
break;
case 'upgrade':
if (!empty($params['from_id']) && !empty($params['to_id'])) {
示例6: deny
public static function deny($transaction_id, $force = false)
{
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Load the transaction
$query->select($db->qn('id'))->from($db->qn('#__rsmembership_transactions'))->where($db->qn('id') . '=' . $db->q($transaction_id));
if (!$force) {
$query->where($db->qn('status') . ' != ' . $db->q('denied'));
}
$db->setQuery($query);
if ($id = $db->loadResult()) {
$transaction = JTable::getInstance('Transaction', 'RSMembershipTable');
$transaction->load($id);
} else {
return false;
}
// Set the transaction to 'denied'
$updateTransaction = JTable::getInstance('Transaction', 'RSMembershipTable');
$updateTransaction->save(array('id' => $transaction->id, 'status' => 'denied'));
$params = RSMembershipHelper::parseParams($transaction->params);
$membership_id = false;
switch ($transaction->type) {
case 'renew':
case 'new':
if (!empty($params['membership_id'])) {
$membership_id = $params['membership_id'];
}
break;
case 'upgrade':
if (!empty($params['to_id'])) {
$membership_id = $params['to_id'];
}
break;
case 'addextra':
if (!empty($params['id'])) {
$query->clear();
$query->select($db->qn('membership_id'))->from($db->qn('#__rsmembership_membership_subscribers'))->where($db->qn('id') . ' = ' . $db->q((int) $params['id']));
$db->setQuery($query);
$membership_id = $db->loadResult();
}
break;
}
// start sending emails
if ($membership_id) {
$query->clear();
$query->select('*')->from($db->qn('#__rsmembership_memberships'))->where($db->qn('id') . ' = ' . $db->q((int) $membership_id) . ' AND ( ' . $db->qn('user_email_denied_subject') . ' != ' . $db->q('') . ' OR ' . $db->qn('admin_email_denied_subject') . ' != ' . $db->q('') . ' )');
$db->setQuery($query);
if ($membership = $db->loadObject()) {
$jconfig = JFactory::getConfig();
$membership->user_email_from_addr = $membership->user_email_use_global ? $jconfig->get('mailfrom') : $membership->user_email_from_addr;
$membership->user_email_from = $membership->user_email_use_global ? $jconfig->get('fromname') : $membership->user_email_from;
$userEmail = array('from' => '', 'fromName' => '', 'recipient' => '', 'subject' => '', 'body' => '', 'mode' => '', 'cc' => '', 'bcc' => '', 'attachments' => '', 'replyto' => '', 'replytoname' => '');
$adminEmail = array('from' => '', 'fromName' => '', 'recipient' => '', 'subject' => '', 'body' => '', 'mode' => '', 'cc' => '', 'bcc' => '', 'attachments' => '', 'replyto' => '', 'replytoname' => '');
// placeholders
$user_data = unserialize($transaction->user_data);
$user_email = $transaction->user_email;
$replacements = array('{membership}' => $membership->name, '{email}' => $user_email, '{name}' => $user_data->name, '{username}' => isset($user_data->username) ? $user_data->username : '', '{price}' => RSMembershipHelper::getPriceFormat($transaction->price), '{coupon}' => $transaction->coupon, '{payment}' => $transaction->gateway, '{transaction_id}' => $transaction->id);
$replace = array_keys($replacements);
$with = array_values($replacements);
$fields = RSMembership::getCustomFields();
$membership_fields = RSMembership::getCustomMembershipFields($membership_id);
$all_fields = array_merge($fields, $membership_fields);
foreach ($all_fields as $field) {
$name = $field->name;
$replace[] = '{' . $name . '}';
$object = isset($user_data->fields[$name]) ? 'fields' : 'membership_fields';
if (isset($user_data->fields[$name]) || isset($user_data->membership_fields[$name])) {
$with[] = is_array($user_data->{$object}[$name]) ? implode("\n", $user_data->{$object}[$name]) : $user_data->{$object}[$name];
} else {
$with[] = '';
}
}
// user emails
if (!empty($membership->user_email_from_addr) && $membership->user_email_denied_subject != '') {
// start sending emails
// from address
$userEmail['from'] = $membership->user_email_from_addr;
// from name
$userEmail['fromName'] = $membership->user_email_from;
// recipient
$userEmail['recipient'] = $user_email;
// user email
// subject
$userEmail['subject'] = str_replace($replace, $with, $membership->user_email_denied_subject);
// body
$userEmail['body'] = str_replace($replace, $with, $membership->user_email_denied_text);
// mode
$userEmail['mode'] = $membership->user_email_mode;
// cc
$userEmail['cc'] = null;
// bcc
$userEmail['bcc'] = null;
// attachments
$userEmail['attachments'] = null;
// reply to
$userEmail['replyto'] = $userEmail['from'];
// reply to name
$userEmail['replytoname'] = $userEmail['fromName'];
}
//.........这里部分代码省略.........
示例7: approve
function approve($transaction_id, $force = false)
{
$db =& JFactory::getDBO();
$db->setQuery("SELECT * FROM #__rsmembership_transactions WHERE `id`='" . (int) $transaction_id . "'" . ($force ? "" : " AND `status`!='completed'"));
$transaction = $db->loadObject();
if (empty($transaction->id)) {
return false;
}
$params = RSMembershipHelper::parseParams($transaction->params);
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsmembership' . DS . 'tables');
$row =& JTable::getInstance('RSMembership_Membership_Users', 'Table');
$row->user_id = $transaction->user_id;
if (!RSMembershipHelper::getConfig('create_user_instantly') || $row->user_id == 0) {
$row->user_id = RSMembership::createUser($transaction->user_email, unserialize($transaction->user_data));
$db->setQuery("UPDATE #__rsmembership_transactions SET `user_id`='" . $row->user_id . "' WHERE `id`='" . $transaction->id . "'");
$db->query();
}
$row->price = $transaction->price;
$row->currency = $transaction->currency;
$idev_enabled = RSMembershipHelper::getConfig('idev_enable');
$idev_track_renewals = RSMembershipHelper::getConfig('idev_track_renewals');
$update_gid = false;
$update_user = false;
$update_idev = false;
$update_rsmail = false;
$date = JFactory::getDate();
switch ($transaction->type) {
case 'new':
$row->membership_id = $params['membership_id'];
$db->setQuery("SELECT * FROM #__rsmembership_memberships WHERE `id`='" . (int) $row->membership_id . "'");
$membership = $db->loadObject();
if (empty($membership)) {
JError::raiseWarning(500, JText::_('RSM_COULD_NOT_APPROVE_TRANSACTION'));
return false;
}
if ($membership->gid_enable) {
$update_gid = true;
}
if ($membership->disable_expired_account) {
$update_user = true;
}
$row->membership_start = $date->toUnix();
if ($membership->use_trial_period) {
$membership->period = $membership->trial_period;
$membership->period_type = $membership->trial_period_type;
}
if ($membership->fixed_expiry) {
$row->membership_end = RSMembershipHelper::calculateFixedDate($membership);
} else {
if ($membership->period > 0) {
switch ($membership->period_type) {
case 'h':
$offset = $membership->period * 3600;
break;
case 'd':
$offset = $membership->period * 86400;
break;
case 'm':
$offset = strtotime('+' . $membership->period . ' months', $row->membership_start) - $row->membership_start;
break;
case 'y':
$offset = strtotime('+' . $membership->period . ' years', $row->membership_start) - $row->membership_start;
break;
}
$row->membership_end = $date->toUnix() + $offset;
} else {
$row->membership_end = 0;
}
}
if (!empty($params['extras'])) {
$row->extras = implode(',', $params['extras']);
}
$row->status = 0;
$row->from_transaction_id = $transaction->id;
$row->last_transaction_id = $transaction->id;
$row->store();
$return = $row->id;
// iDev Integration
if ($idev_enabled) {
$update_idev = true;
}
$update_rsmail = $membership->id;
break;
case 'addextra':
$db->setQuery("SELECT `extras` FROM #__rsmembership_membership_users WHERE `id`='" . (int) $params['id'] . "'");
$extras = $db->loadResult();
$extras = explode(',', $extras);
if (empty($extras[0])) {
$extras = $params['extras'];
} else {
$extras = array_merge($extras, $params['extras']);
}
$db->setQuery("UPDATE #__rsmembership_membership_users SET `extras`='" . implode(',', $extras) . "' WHERE `id`='" . (int) $params['id'] . "'");
$db->query();
$return = $params['id'];
break;
case 'upgrade':
// Get the upgraded membership
$db->setQuery("SELECT * FROM #__rsmembership_memberships WHERE `id`='" . (int) $params['to_id'] . "'");
$membership = $db->loadObject();
//.........这里部分代码省略.........