本文整理汇总了PHP中JController::setRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP JController::setRedirect方法的具体用法?PHP JController::setRedirect怎么用?PHP JController::setRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JController
的用法示例。
在下文中一共展示了JController::setRedirect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setRedirect
/**
* (non-PHPdoc) adds redirect url and message to session
* @see JController::setRedirect()
*/
function setRedirect($url, $msg = null, $type = 'message')
{
$session = JFactory::getSession();
$formdata = $session->get('com_fabrik.form.data');
$context = 'com_fabrik.form.' . $formdata['fabrik'] . '.redirect.';
//if the redirect plug-in has set a url use that in preference to the default url
$surl = $session->get($context . 'url', array($url));
if (!is_array($surl)) {
$surl = array($surl);
}
if (empty($surl)) {
$surl[] = $url;
}
$smsg = $session->get($context . 'msg', array($msg));
if (!is_array($smsg)) {
$smsg = array($smsg);
}
if (empty($smsg)) {
$smsg[] = $msg;
}
$url = array_shift($surl);
$msg = array_shift($smsg);
$app = JFactory::getApplication();
$q = $app->getMessageQueue();
$found = false;
foreach ($q as $m) {
//custom message already queued - unset default msg
if ($m['type'] == 'message' && trim($m['message']) !== '') {
$found = true;
break;
}
}
if ($found) {
$msg = null;
}
$session->set($context . 'url', $surl);
$session->set($context . 'msg', $smsg);
$showmsg = array_shift($session->get($context . 'showsystemmsg', array(true)));
$msg = $showmsg ? $msg : null;
parent::setRedirect($url, $msg, $type);
}
示例2: defined
* @license GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Load JAdERP Stylesheet
JHTML::stylesheet('jaderp.css', 'components/com_jaderp/css/');
// Require the base controller
$users =& JFactory::getUser();
$uid = $users->id;
//if ($uid == 0) die('Vous devez vous concterzrzrzer');
require_once JPATH_COMPONENT . DS . 'controller.php';
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'includes' . DS . 'jaderp_tools.php';
$JAdERPTool =& new JAdERPTools();
$row = $JAdERPTool->ReadTable('jaderp_users', '*', 'WHERE joomla_id=' . $uid, 'Assoc', true);
if ($row['forcepasschange']) {
//echo $row['forcepasschange'];
$msg = JText::_('YOU_MUST_CHANGE_PASSWORD');
JController::setRedirect(JRoute::_('index.php?option=com_user&view=login'), $msg, 'notice');
JController::redirect();
}
// Require specific controller if requested
if ($controller = JRequest::getWord('func')) {
require_once JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
}
// Create the controller
$classname = 'JaderpController' . $controller;
$controller = new $classname();
// Perform the Request task
$controller->execute(JRequest::getVar('task'));
// Redirect if set by the controller
$controller->redirect();
示例3: testSetRedirect
/**
* Test JController::setRedirect
*
* @covers JController::setRedirect
*/
public function testSetRedirect()
{
// Set the URL only
$this->class->setRedirect('index.php?option=com_foobar');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect.');
$this->assertAttributeEquals(null, 'message', $this->class, 'Checks the message.');
$this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type.');
// Set the URL and message
$this->class->setRedirect('index.php?option=com_foobar', 'Hello World');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (2).');
$this->assertAttributeEquals('Hello World', 'message', $this->class, 'Checks the message (2).');
$this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (2).');
// URL, message and message type
$this->class->setRedirect('index.php?option=com_foobar', 'Morning Universe', 'notice');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (3).');
$this->assertAttributeEquals('Morning Universe', 'message', $this->class, 'Checks the message (3).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (3).');
// With previously set message
// URL
$this->class->setMessage('Hi all');
$this->class->setRedirect('index.php?option=com_foobar');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (4).');
$this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (4).');
$this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (4).');
// URL and message
$this->class->setMessage('Hi all');
$this->class->setRedirect('index.php?option=com_foobar', 'Bye all');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (5).');
$this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (5).');
$this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (5).');
// URL, message and message type
$this->class->setMessage('Hi all');
$this->class->setRedirect('index.php?option=com_foobar', 'Bye all', 'notice');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (6).');
$this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (6).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (6).');
// URL and message type
$this->class->setMessage('Hi all');
$this->class->setRedirect('index.php?option=com_foobar', null, 'notice');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (7).');
$this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (7).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (7).');
// With previously set message and message type
// URL
$this->class->setMessage('Hello folks', 'notice');
$this->class->setRedirect('index.php?option=com_foobar');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (8).');
$this->assertAttributeEquals('Hello folks', 'message', $this->class, 'Checks the message (8).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (8).');
// URL and message
$this->class->setMessage('Hello folks', 'notice');
$this->class->setRedirect('index.php?option=com_foobar', 'Bye, Folks');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (9).');
$this->assertAttributeEquals('Bye, Folks', 'message', $this->class, 'Checks the message (9).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (9).');
// URL, message and message type
$this->class->setMessage('Hello folks', 'notice');
$this->class->setRedirect('index.php?option=com_foobar', 'Bye, folks', 'notice');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
$this->assertAttributeEquals('Bye, folks', 'message', $this->class, 'Checks the message (10).');
$this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (10).');
// URL and message type
$this->class->setMessage('Folks?', 'notice');
$this->class->setRedirect('index.php?option=com_foobar', null, 'question');
$this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
$this->assertAttributeEquals('Folks?', 'message', $this->class, 'Checks the message (10).');
$this->assertAttributeEquals('question', 'messageType', $this->class, 'Checks the message type (10).');
}
示例4: setRedirect
/**
* (non-PHPdoc) adds redirect url and message to session
* @see JController::setRedirect()
*/
function setRedirect($url, $msg = null, $type = 'message')
{
$session =& JFactory::getSession();
$formdata = $session->get('com_fabrik.form.data');
$context = 'com_fabrik.form.' . $formdata['fabrik'] . '.redirect.';
//if the redirect plug-in has set a url use that in preference to the default url
$surl = $session->get($context . 'url', array($url));
if (!is_array($surl)) {
$surl = array($surl);
}
if (empty($surl)) {
$surl[] = $url;
}
$smsg = $session->get($context . 'msg', array($msg));
if (!is_array($smsg)) {
$smsg = array($smsg);
}
if (empty($smsg)) {
$smsg[] = $msg;
}
// $$$ hugh - hmmm, array_shift re-orders array keys, which will screw up plugin ordering?
$url = array_shift($surl);
// $$$ hugh - something changed in the way the redirect plugin works, so we can't remove
// the msg any more.
// $$$ rob Was using array_shift to set $msg, not to really remove it from $smsg
// without the array_shift the custom message is never attached to the redirect page.
// use case 'redirct plugin with jump page pointing to a J page and thanks message selected.
$custommsg = JArrayHelper::getValue($smsg, array_shift(array_keys($smsg)));
if ($custommsg != '') {
$msg = $custommsg;
}
$app =& JFactory::getApplication();
$q = $app->getMessageQueue();
$found = false;
foreach ($q as $m) {
//custom message already queued - unset default msg
if ($m['type'] == 'message' && trim($m['message']) !== '') {
$found = true;
break;
}
}
if ($found) {
$msg = null;
}
$session->set($context . 'url', $surl);
$session->set($context . 'msg', $smsg);
$showmsg = array_shift($session->get($context . 'showsystemmsg', array(true)));
$msg = $showmsg == 1 ? $msg : null;
parent::setRedirect($url, $msg, $type);
}
示例5: setRedirectDefault
function setRedirectDefault($msg = null, $type = '', $args = null)
{
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
parent::setRedirect("index.php?option={$option}&view={$view}{$args}", $msg, $type);
}
示例6: setRedirect
/**
* Set a URL for browser redirection.
*
* @param mixed A string for URL to redirect to or a named array.
* @param string Message to display on redirect. Optional, defaults to
* value set internally by controller, if any.
* @param string Message type. Optional, defaults to 'message'.
* @param bool If true, URL will be run through JRoute::_
* @return void
*/
public function setRedirect($url = null, $msg = null, $type = 'message', $route = true)
{
if (is_array($url)) {
// convert to string
$url = $this->_buildURLFromArray($url);
} elseif ($url === null) {
$url = 'index.php?option=com_' . strtolower($this->getName());
}
if ($route === true) {
$url = JRoute::_($url, false);
}
parent::setRedirect($url, $msg, $type);
}
示例7: __construct
/** Constructor function **/
function __construct(&$subject, $config)
{
// Check if JSN Framework installed & enabled.
$jsnframework = JPluginHelper::getPlugin('system', 'jsnframework');
if (!$jsnframework || !file_exists(JPATH_ROOT . '/plugins/system/jsnframework')) {
return;
}
JSNFactory::import('plugins.system.jsnframework.libraries.joomlashine.config.helper', 'site');
JSNFactory::import('plugins.system.jsnframework.libraries.joomlashine.utils.xml', 'site');
$this->_params = JSNConfigHelper::get('com_poweradmin');
$this->_application = JFactory::getApplication();
$this->_user = JFactory::getUser();
$this->_session = JFactory::getSession();
$this->_preview = new JSNPowerAdminBarPreview();
$this->loadLanguage('plg_system_jsnpoweradmin');
$this->_removeAdminBarPlugin();
$app = JFactory::getApplication();
$input = $app->input;
$poweradmin = $input->getCmd('poweradmin', 0);
$showTemplatePosition = $input->getCmd('tp', 0);
if ($app->isAdmin()) {
$user = JFactory::getUser();
if ($input->getVar('view', '') == 'jsnrender' && $user->id == 0) {
jimport('joomla.application.component.controller');
JController::setRedirect(JSN_VISUALMODE_PAGE_URL);
JController::redirect();
}
}
if ($poweradmin == 1) {
/**
* Auto-enable Preview Module Positions of template setting
*/
if ($showTemplatePosition == 1) {
$PreviewModulePositionsIsEnabled = JComponentHelper::getParams('com_content')->get('template_positions_display', 0) == 1 ? true : false;
if (!$PreviewModulePositionsIsEnabled) {
/**
* Get config class
*/
JSNFactory::localimport('libraries.joomlashine.config');
JSNConfig::extension('com_templates', array('template_positions_display' => 1));
}
}
/** load JSNPOWERADMIN template library **/
$template = JSNFactory::getTemplate();
$this->_templateAuthor = $template->getAuthor();
/*if T3 Framework*/
if ($this->_templateAuthor == 'joomlart') {
//check folder jat3 exists
$t3FrameworkFolder = JPATH_ROOT . 'plugins/system/jat3';
if (is_dir($t3FrameworkFolder)) {
if (!class_exists('T3Common')) {
jimport('joomla.html.parameter');
JSNFactory::import('plugins.system.jat3.jat3.core.common', 'site');
}
if (!class_exists('T3Framework')) {
JSNFactory::import('plugins.system.jat3.jat3.core.framework', 'site');
$jt3Plg = JPluginHelper::getPlugin('system', 'jat3');
T3Framework::t3_init($jt3Plg->params);
}
JSNFactory::import('plugins.system.jsnpoweradmin.libraries.jsnjoomlart', 'site');
}
} else {
if ($this->_templateAuthor == 'yootheme') {
return;
} else {
if ($this->_templateAuthor == 'gavick') {
JSNFactory::import('libraries.joomla.environment.browser', 'site');
$browser = JBrowser::getInstance();
$browser->setBrowser('JSNPoweradmin');
} else {
if ($this->_templateAuthor == 'joomlaxtc') {
JSNFactory::import('plugins.system.jsnpoweradmin.libraries.jsnjoomlaxtc', 'site');
}
}
}
}
$this->_helper = JSNPLGHelper::getInstance();
}
parent::__construct($subject, $config);
}
示例8: display
function display($tpl = null)
{
global $mainframe;
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'includes' . DS . 'jaderp_tools.php';
$JAdERPTool =& new JAdERPTools();
$doc =& JFactory::getDocument();
$searchreq = '';
JHTML::script('datepicker.js', 'components/com_jaderp/js/', false);
JHTML::stylesheet('datepicker.css', 'components/com_jaderp/css/');
jimport('joomla.html.pagination');
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'));
//$limitstart = $mainframe->getUserStateFromRequest('com_jaderp.limitstart', 'limitstart', 0);
$limitstart = JRequest::getVar('limitstart', '0', '', 'int');
$limitreq = '';
if ($limit) {
$limitreq = " LIMIT " . $limitstart . "," . $limit;
}
$search = JRequest::getVar('search', '', '', 'string');
$search = JString::strtolower($search);
if ($search != '') {
$searchreq = '(m.firstname LIKE "%' . $search . '%" OR m.lastname LIKE "%' . $search . '%")';
}
$filter_order = JRequest::getVar('filter_order', 'm.id', '', 'cmd');
$filter_order_Dir = JRequest::getVar('filter_order_Dir', 'ASC', '', 'string');
$orderreq = " ORDER BY " . $filter_order . " " . $filter_order_Dir;
$filter_dep = JRequest::getVar('filter_dep', '0', '', 'int');
if ($filter_dep > 0) {
if ($searchreq == '') {
$searchreq = 'm.department = ' . $filter_dep;
} else {
$searchreq .= ' AND m.department =' . $filter_dep;
}
}
$filter_branch = JRequest::getVar('filter_branch', '0', '', 'int');
if ($filter_branch > 0) {
if ($searchreq == '') {
$searchreq = 'm.branch = ' . $filter_branch;
} else {
$searchreq .= ' AND m.branch =' . $filter_branch;
}
}
$filter_access = JRequest::getVar('filter_access', '0', '', 'int');
if ($filter_access > 0) {
if ($searchreq == '') {
$searchreq = 'm.canaccess = ' . ($filter_access - 1);
} else {
$searchreq .= ' AND m.canaccess =' . ($filter_access - 1);
}
}
$filter_presence = JRequest::getVar('filter_presence', '0', '', 'int');
if ($filter_presence > 0) {
if ($searchreq == '') {
$searchreq = 'm.present = ' . ($filter_presence - 1);
} else {
$searchreq .= ' AND m.present =' . ($filter_presence - 1);
}
}
$users = $JAdERPTool->ReadTable('jaderp_users', '*', '', 'Array');
if (!$users) {
$msg = JText::_('NO_USERS_IN_THE_BASE');
JController::setRedirect(JRoute::_('index.php?option=com_jaderp&view=desktop'), $msg, 'notice');
JController::redirect();
}
$total = count($users);
$page = new JPagination($total, $limitstart, $limit);
$this->assign('pagination', $page);
$branchs = $JAdERPTool->ReadTable('jaderp_branchs');
$this->assign('branchs', $branchs);
$departments = $JAdERPTool->ReadTable('jaderp_departments');
$this->assign('departments', $departments);
$req = "SELECT m.id as id,\n\t\t\t\tm.mat as matricule,\n\t\t\t\tm.firstname as firstname,\n\t\t\t\tm.lastname as lastname,\n\t\t\t\tm.checked_out,\n\t\t\t\tm.checked_out_time,\n\t\t\t\td.name as department,\n\t\t\t\tb.name as branch,\n\t\t\t\tm.position as position,\n\t\t\t\tm.email as email,\n\t\t\t\tm.present as presence,\n\t\t\t\tm.canaccess as access";
$req .= " FROM #__jaderp_users as m INNER JOIN #__jaderp_departments as d ON m.department = d.id \n\t\tINNER JOIN #__jaderp_branchs as b ON m.branch = b.id";
if ($searchreq != '') {
$req .= " WHERE " . $searchreq;
}
$req .= $orderreq . " " . $limitreq;
$db =& JFactory::getDBO();
$db->setQuery($req);
$rows = $db->loadAssocList();
//echo $req;
$this->assign('filter_dep', $filter_dep);
$this->assign('filter_branch', $filter_branch);
$this->assign('filter_access', $filter_access);
$this->assign('filter_presence', $filter_presence);
$this->assign('search', $search);
$this->assign('rows', $rows);
$this->assign('neworderdir', $filter_order_Dir);
$this->assign('neworder', $filter_order);
parent::display($tpl);
}
示例9: processSubscription
/**
* Public method to process subscription
*
* @param array $data
*/
public function processSubscription($data)
{
global $Itemid;
// Import help library
jimport('joomla.user.helper');
$siteUrl = JURI::root();
// Get configuration
$config = $this->getConfig();
// Get user
$user =& JFactory::getUser();
$data['transaction_id'] = strtoupper(JUserHelper::genRandomPassword());
$row = JTable::getInstance('subscr', 'JmsTable');
$row->bind($data);
// Get plan information
$plan = $this->getPlan($row->plan_id);
$row->user_id = $user->get('id');
// offset
$format = 'Y-m-d H:i:s';
$date = date($format);
$row->created = date($format, strtotime('-1 day' . $date));
// Get maximum of expired date
$maxExpDate = $this->_getMaxExpDate($row->plan_id, $row->user_id);
$row->expired = $this->_getExpiredDate($plan->period, $plan->period_type, $maxExpDate);
$row->number = 0;
$row->access_count = 0;
$row->access_limit = $plan->limit_time;
$paymentMethod = $data['payment_method'];
if ($paymentMethod == 'iwl_paypal') {
$row->payment_method = 'Paypal';
} elseif ($paymentMethod == 'iwl_moneybooker') {
$row->payment_method = 'MoneyBooker';
} elseif ($paymentMethod == 'iwl_authnet') {
$row->payment_method = 'Authorize.net';
}
$row->parent = 0;
$row->state = 0;
// Get coupon recurring information
$couponCode = JRequest::getVar('coupon');
if (!empty($couponCode)) {
$coupon = $this->getCoupon();
$recurring = $coupon->recurring;
$num_recurring = $coupon->num_recurring;
} else {
$recurring = 0;
}
if ($recurring) {
$row->subscription_type = 'R';
$row->r_times = $num_recurring;
} else {
$row->subscription_type = 'I';
$row->r_times = 0;
}
//
$row->payment_made = 0;
$row->subscr_id = '';
if ($row->price == 0.0) {
$row->transaction_id = time();
$row->state = 1;
}
$row->store();
if ($row->price == 0.0) {
// Send notification email
$this->_sendEmails($row, $config);
// Add user to autoresponder
if ($plan->autores_enable || $plan->crm_enable || $plan->plan_mc_enable) {
// Get user
$user =& JFactory::getUser();
if ($plan->autores_enable) {
require_once JPATH_COMPONENT . '/helpers/iwl_aweber.php';
$gateWay = new iwl_aweber();
$gateWay->autoresponder($plan, $user);
}
if ($plan->crm_enable) {
require_once JPATH_COMPONENT . '/helpers/iwl_crm.php';
$gateWay = new iwl_crm();
$gateWay->autoresponder($plan, $user);
}
if ($plan->plan_mc_enable) {
require_once JPATH_COMPONENT . '/helpers/iwl_mailchimp.php';
$gateWay = new iwl_mailchimp();
$gateWay->autoresponder($plan, $user);
// Display complete page
JController::setRedirect($siteUrl . 'index.php?option=com_jms&task=jms.complete&plan_id=' . $row->plan_id . '&Itemid=' . $Itemid);
JController::redirect();
}
} else {
// Display complete page
JController::setRedirect($siteUrl . 'index.php?option=com_jms&task=jms.complete&plan_id=' . $row->plan_id . '&Itemid=' . $Itemid);
JController::redirect();
}
} else {
$gatewayData = array();
// Require the payment method
switch ($paymentMethod) {
case 'iwl_moneybooker':
//.........这里部分代码省略.........
示例10: onAfterOrderConfirm
function onAfterOrderConfirm(&$order, &$methods, $method_id)
{
parent::onAfterOrderConfirm($order, $methods, $method_id);
if ($this->currency->currency_locale['int_frac_digits'] > 2) {
$this->currency->currency_locale['int_frac_digits'] = 2;
}
$notify_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=' . $this->name . '&tmpl=component&lang=' . $this->locale . $this->url_itemid;
$return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=' . $order->order_id . $this->url_itemid;
$cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $order->order_id . $this->url_itemid;
$cc_type = JRequest::getVar('cc_type', '');
$this->MerchantSecretKey = $this->payment_params->MerchantSecretKey;
$request["MerchantGuid"] = $this->MerchantGuid = $this->payment_params->MerchantGuid;
$request['SelectedPaySystemId'] = isset($cc_type) ? $cc_type : $this->GetMerchnatInfo(false, true);
$request['Currency'] = $this->currency->currency_code;
$request['Language'] = $this->locale;
$sum = $qty = 0;
foreach ($order->cart->products as $product) {
if ($product->order_product_option_parent_id) {
continue;
}
$request['Products'][] = array("ProductId" => $product->product_id, "ProductName" => substr(strip_tags($product->order_product_name), 0, 127), "ProductPrice" => round($product->order_product_price, (int) $this->currency->currency_locale['int_frac_digits']), "ProductItemsNum" => $product->order_product_quantity, "ImageUrl" => '');
$sum += round($product->order_product_price, (int) $this->currency->currency_locale['int_frac_digits']) * $product->order_product_quantity;
$qty += $product->order_product_quantity;
}
$amount = round($order->cart->full_total->prices[0]->price_value_with_tax, (int) $this->currency->currency_locale['int_frac_digits']);
if ($sum != $amount) {
$sum += $order_info_total = (int) ($amount - $sum);
$request['Products'][] = array("ProductId" => '1', "ProductName" => 'Delivery', "ProductPrice" => $order_info_total, "ProductItemsNum" => 1, "ImageUrl" => '');
$qty++;
}
$BuyerCountry = @$order->cart->shipping_address->address_state->zone_name;
$BuyerFirstname = @$order->cart->shipping_address->address_firstname;
$BuyerLastname = @$order->cart->shipping_address->address_lastname;
$BuyerStreet = $order->cart->shipping_address->address_street;
$BuyerCity = @$order->cart->shipping_address->address_city;
$request['PaymentDetails'] = array("MerchantInternalPaymentId" => $order->order_id, "MerchantInternalUserId" => $order->order_user_id, "EMail" => $this->user->user_email, "PhoneNumber" => $order->cart->shipping_address->address_telephone, "CustomMerchantInfo" => "", "StatusUrl" => "{$notify_url}", "ReturnUrl" => "{$return_url}", "BuyerCountry" => "{$BuyerCountry}", "BuyerFirstname" => "{$BuyerFirstname}", "BuyerPatronymic" => "", "BuyerLastname" => "{$BuyerLastname}", "BuyerStreet" => "{$BuyerStreet}", "BuyerZone" => "", "BuyerZip" => "", "BuyerCity" => "{$BuyerCity}", "DeliveryFirstname" => "{$BuyerFirstname}", "DeliveryLastname" => "{$BuyerLastname}", "DeliveryZip" => "", "DeliveryCountry" => "{$BuyerCountry}", "DeliveryPatronymic" => "", "DeliveryStreet" => "{$BuyerStreet}", "DeliveryCity" => "{$BuyerCity}", "DeliveryZone" => "");
$request["Signature"] = md5(strtoupper($request["MerchantGuid"]) . number_format($sum, 2, ".", "") . $request["SelectedPaySystemId"] . $request["PaymentDetails"]["EMail"] . $request["PaymentDetails"]["PhoneNumber"] . $request["PaymentDetails"]["MerchantInternalUserId"] . $request["PaymentDetails"]["MerchantInternalPaymentId"] . strtoupper($request["Language"]) . strtoupper($request["Currency"]) . strtoupper($this->MerchantSecretKey));
$response = $this->sendRequestKaznachey(json_encode($request), "CreatePaymentEx");
$result = json_decode($response, true);
if ($result['ErrorCode'] != 0) {
JController::setRedirect($fail_url, 'Ошибка транзакции');
JController::redirect();
} else {
print base64_decode($result["ExternalForm"]);
die;
}
return $this->showPage('end');
}
示例11: plgVmConfirmedOrder
function plgVmConfirmedOrder($cart, $order)
{
if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
return null;
// Another method was selected, do nothing
}
if (!$this->selectedThisElement($method->payment_element)) {
return false;
}
$lang = JFactory::getLanguage();
$filename = 'com_virtuemart';
$lang->load($filename, JPATH_ADMINISTRATOR);
$vendorId = 0;
$session = JFactory::getSession();
$return_context = $session->getId();
$this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
$html = "";
if (!class_exists('VirtueMartModelOrders')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
}
if (!$method->payment_currency) {
$this->getPaymentCurrency($method);
}
// END printing out HTML Form code (Payment Extra Info)
$q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
$db =& JFactory::getDBO();
$db->setQuery($q);
$currency = strtoupper($db->loadResult());
$amount = ceil($order['details']['BT']->order_total * 100) / 100;
$order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order['details']['BT']->order_number);
$desc = 'Оплата заказа №' . $order['details']['BT']->order_number;
$statusUrl = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=orders&layout=details&order_number=' . $order['details']['BT']->order_number . '&order_pass=' . $order['details']['BT']->order_pass);
$returnUrl = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&pelement=kaznachey&order_number=' . $order_id);
$fail_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id);
$this->_virtuemart_paymentmethod_id = $order['details']['BT']->virtuemart_paymentmethod_id;
$dbValues['payment_name'] = $this->renderPluginName($method);
$dbValues['order_number'] = $order['details']['BT']->order_number;
$dbValues['virtuemart_paymentmethod_id'] = $this->_virtuemart_paymentmethod_id;
$dbValues['payment_currency'] = $currency;
$dbValues['payment_order_total'] = $amount;
$this->storePSPluginInternalData($dbValues);
$user_email = $order['details']['BT']->email;
$phone_1 = $order['details']['BT']->phone_1;
$virtuemart_user_id = $order['details']['BT']->virtuemart_user_id;
$cc_type = JRequest::getVar('cc_type', '');
$request["MerchantGuid"] = $method->merchant_id;
$request['SelectedPaySystemId'] = isset($cc_type) ? $cc_type : $this->GetMerchnatInfo(false, true);
$request['Currency'] = $currency;
$request['Language'] = $this->payment_language;
$sum = $qty = 0;
foreach ($order['items'] as $key => $product) {
$request['Products'][] = array("ProductId" => $product->order_item_sku, "ProductName" => $product->order_item_name, "ProductPrice" => $product->product_final_price, "ProductItemsNum" => $product->product_quantity, "ImageUrl" => '');
$sum += $product->product_final_price * $product->product_quantity;
$qty += $product->product_quantity;
}
if ($sum != $amount) {
$sum += $order_info_total = (int) ($amount - $sum);
$request['Products'][] = array("ProductId" => '1', "ProductName" => 'Delivery', "ProductPrice" => $order_info_total, "ProductItemsNum" => 1, "ImageUrl" => '');
$qty++;
}
$BuyerCountry = $order['details']['BT']->virtuemart_country_id;
$BuyerFirstname = $order['details']['BT']->first_name;
$BuyerLastname = $order['details']['BT']->last_name;
$BuyerStreet = $order['details']['BT']->address_1;
$BuyerCity = $order['details']['BT']->city;
$request['PaymentDetails'] = array("MerchantInternalPaymentId" => "{$order_id}", "MerchantInternalUserId" => "{$virtuemart_user_id}", "EMail" => "{$user_email}", "PhoneNumber" => "{$phone_1}", "CustomMerchantInfo" => "", "StatusUrl" => "{$statusUrl}", "ReturnUrl" => "{$returnUrl}", "BuyerCountry" => "{$BuyerCountry}", "BuyerFirstname" => "{$BuyerFirstname}", "BuyerPatronymic" => "", "BuyerLastname" => "{$BuyerLastname}", "BuyerStreet" => "{$BuyerStreet}", "BuyerZone" => "", "BuyerZip" => "", "BuyerCity" => "{$BuyerCity}", "DeliveryFirstname" => "{$BuyerFirstname}", "DeliveryLastname" => "{$BuyerLastname}", "DeliveryZip" => "", "DeliveryCountry" => "{$BuyerCountry}", "DeliveryPatronymic" => "", "DeliveryStreet" => "{$BuyerStreet}", "DeliveryCity" => "{$BuyerCity}", "DeliveryZone" => "");
$request["Signature"] = md5(strtoupper($request["MerchantGuid"]) . number_format($sum, 2, ".", "") . $request["SelectedPaySystemId"] . $request["PaymentDetails"]["EMail"] . $request["PaymentDetails"]["PhoneNumber"] . $request["PaymentDetails"]["MerchantInternalUserId"] . $request["PaymentDetails"]["MerchantInternalPaymentId"] . strtoupper($request["Language"]) . strtoupper($request["Currency"]) . strtoupper($method->secret_key));
$response = $this->sendRequestKaznachey(json_encode($request), "CreatePaymentEx");
$result = json_decode($response, true);
if ($result['ErrorCode'] != 0) {
JController::setRedirect($fail_url, 'Ошибка транзакции');
JController::redirect();
} else {
$html = base64_decode($result["ExternalForm"]);
}
return $this->processConfirmedOrderPaymentResponse(true, $cart, $order, $html, $this->renderPluginName($method, $order), 'P');
}
示例12: plgVmConfirmedOrder
//.........这里部分代码省略.........
$db->setQuery($q);
$currency = strtoupper($db->loadResult());
$amount = ceil($order['details']['BT']->order_total * 100) / 100;
$order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order['details']['BT']->order_number);
$desc = 'Оплата заказа №' . $order['details']['BT']->order_number;
$success_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=orders&layout=details&order_number=' . $order['details']['BT']->order_number . '&order_pass=' . $order['details']['BT']->order_pass);
$fail_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id);
$result_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&pelement=kaznachey&order_number=' . $order_id);
$this->_virtuemart_paymentmethod_id = $order['details']['BT']->virtuemart_paymentmethod_id;
$dbValues['payment_name'] = $this->renderPluginName($method);
$dbValues['order_number'] = $order['details']['BT']->order_number;
$dbValues['virtuemart_paymentmethod_id'] = $this->_virtuemart_paymentmethod_id;
$dbValues['payment_currency'] = $currency;
$dbValues['payment_order_total'] = $amount;
$this->storePSPluginInternalData($dbValues);
$merchantGuid = $method->merchant_id;
$merchnatSecretKey = $method->secret_key;
$user_email = $order['details']['BT']->email;
$phone_1 = $order['details']['BT']->phone_1;
$virtuemart_user_id = $order['details']['BT']->virtuemart_user_id;
$selectedPaySystemId = JRequest::getVar('cc_type', '1');
$i = 0;
$amount2 = 0;
$product_count = 0;
foreach ($order['items'] as $key => $pr_item) {
$products[$i]['ProductItemsNum'] = number_format($pr_item->product_quantity, 2, '.', '');
$products[$i]['ProductName'] = $pr_item->order_item_name;
$products[$i]['ProductPrice'] = number_format($pr_item->product_final_price, 2, '.', '');
$products[$i]['ProductId'] = $pr_item->order_item_sku;
$amount2 += $pr_item->product_final_price * $pr_item->product_quantity;
$product_count += $pr_item->product_quantity;
$i++;
}
$amount2 = number_format($amount2, 2, '.', '');
if ($amount != $amount2) {
$tt = $amount - $amount2;
$products[$i]['ProductItemsNum'] = '1.00';
$products[$i]['ProductName'] = 'Доставка или скидка';
$products[$i]['ProductPrice'] = number_format($tt, 2, '.', '');
$products[$i]['ProductId'] = '00001';
$product_count += '1.00';
$amount2 = number_format($amount2 + $tt, 2, '.', '');
}
/* $gmi = $this->GetMerchnatInfo($selectedPaySystemId);
if($gmi['Fields']){
foreach ($gmi['Fields'] as $key=>$field)
{
$userEnteredFields[$key]['FieldTag'] = $field['FieldTag'];
switch ($field['FieldTag'])
{
case 'E-Mail':
$userEnteredFields[$key]['FieldValue'] = $user_email;
break;
case 'PhoneNumber':
$userEnteredFields[$key]['FieldValue'] = $phone_1;
break;
}
}
}else{
$userEnteredFields = Array(
Array(
"FieldTag"=>"E-Mail",
"FieldValue"=>$user_email
)
);
} */
$product_count = number_format($product_count, 2, '.', '');
$signature_u = md5(md5($merchantGuid . $merchnatSecretKey . "{$amount}" . $order_id));
$DeliveryFirstname = @$order['details']['BT']->first_name ? $order['details']['BT']->first_name : 1;
$DeliveryLastname = @$order['details']['BT']->last_name ? $order['details']['BT']->last_name : 1;
$DeliveryZip = @$order['details']['BT']->zip ? $order['details']['BT']->zip : 1;
$DeliveryCountry = @$order['details']['BT']->virtuemart_country_id ? $order['details']['BT']->virtuemart_country_id : 1;
$DeliveryPatronymic = '1';
$DeliveryStreet = @$order['details']['BT']->address_1 ? $order['details']['BT']->address_1 : 1;
$DeliveryCity = @$order['details']['BT']->city ? $order['details']['BT']->city : 1;
$DeliveryZone = 0;
$BuyerCountry = $DeliveryCountry;
$BuyerFirstname = $DeliveryFirstname;
$BuyerPatronymic = '1';
$BuyerLastname = $DeliveryLastname;
$BuyerStreet = @$order['details']['BT']->address_2 ? $order['details']['BT']->address_2 : $DeliveryStreet;
$BuyerZone = $DeliveryZone;
$BuyerZip = $DeliveryZip;
$BuyerCity = $DeliveryCity;
//Детали платежа
$paymentDetails = array("MerchantInternalPaymentId" => "{$order_id}", "MerchantInternalUserId" => "{$virtuemart_user_id}", "CustomMerchantInfo" => "{$signature_u}", "StatusUrl" => "{$result_url}", "ReturnUrl" => "{$success_url}", "BuyerCountry" => "{$BuyerCountry}", "BuyerFirstname" => "{$BuyerFirstname}", "BuyerPatronymic" => "{$BuyerPatronymic}", "BuyerLastname" => "{$BuyerLastname}", "BuyerStreet" => "{$BuyerStreet}", "BuyerZone" => "{$BuyerZone}", "BuyerZip" => "{$BuyerZip}", "BuyerCity" => "{$BuyerCity}", "DeliveryFirstname" => "{$DeliveryFirstname}", "DeliveryLastname" => "{$DeliveryLastname}", "DeliveryZip" => "{$DeliveryZip}", "DeliveryCountry" => "{$DeliveryCountry}", "DeliveryPatronymic" => "{$DeliveryPatronymic}", "DeliveryStreet" => "{$DeliveryStreet}", "DeliveryCity" => "{$DeliveryCity}", "DeliveryZone" => "{$DeliveryZone}");
$signature = md5($merchantGuid . "{$amount2}" . "{$product_count}" . $paymentDetails["MerchantInternalUserId"] . $paymentDetails["MerchantInternalPaymentId"] . $selectedPaySystemId . $merchnatSecretKey);
$request = array("SelectedPaySystemId" => $selectedPaySystemId, "Products" => $products, "PaymentDetails" => $paymentDetails, "Signature" => $signature, "MerchantGuid" => $merchantGuid);
$res = $this->sendRequestKaznachey($this->urlGetMerchantInfo, json_encode($request));
$result = json_decode($res, true);
if ($result['ErrorCode'] != 0) {
JController::setRedirect($fail_url, 'Ошибка транзакции');
JController::redirect();
} else {
$html = base64_decode($result["ExternalForm"]);
}
return $this->processConfirmedOrderPaymentResponse(true, $cart, $order, $html, $this->renderPluginName($method, $order), 'P');
}