当前位置: 首页>>代码示例>>PHP>>正文


PHP modX::sendRedirect方法代码示例

本文整理汇总了PHP中modX::sendRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::sendRedirect方法的具体用法?PHP modX::sendRedirect怎么用?PHP modX::sendRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在modX的用法示例。


在下文中一共展示了modX::sendRedirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: redirectToFirst

 /**
  * Redirect user to the first page of pagination
  *
  * @return string
  */
 public function redirectToFirst()
 {
     unset($_GET[$this->pdoTools->config['pageVarKey']]);
     unset($_GET[$this->modx->getOption('request_param_alias', null, 'q')]);
     $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id, $this->modx->context->key, $_GET, 'full'));
     return '';
 }
开发者ID:Setest,项目名称:pdoTools,代码行数:12,代码来源:pdopage.class.php

示例2: redirectToFirst

 /**
  * Redirect user to the first page of pagination
  *
  * @param $isAjax
  *
  * @return string
  */
 public function redirectToFirst($isAjax = false)
 {
     unset($_GET[$this->pdoTools->config['pageVarKey']]);
     unset($_GET[$this->modx->getOption('request_param_alias', null, 'q')]);
     if (!$isAjax) {
         $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id, $this->modx->context->key, $_GET, 'full'));
         return '';
     } else {
         $_GET[$this->pdoTools->config['pageVarKey']] = 1;
         $_REQUEST = $_GET;
         return $this->modx->runSnippet('pdoPage', $this->pdoTools->config);
     }
 }
开发者ID:Jako,项目名称:pdoTools,代码行数:20,代码来源:pdopage.class.php

示例3: checkForRedirect

 /**
  * Check to see if the redirect URL was set; if so, redirect
  * @return void
  */
 public function checkForRedirect()
 {
     $url = $this->formit->postHooks->getRedirectUrl();
     if (!empty($url) && !$this->formit->inTestMode) {
         $this->modx->sendRedirect($url);
     }
 }
开发者ID:MobiTeam,项目名称:mirfoto,代码行数:11,代码来源:firequest.class.php

示例4: showList

 /**
  * Show the remembered list
  *
  * @param array $options Template options
  * @return string
  */
 public function showList($options)
 {
     $output = array();
     // Generate the list
     $list = array();
     foreach ($_SESSION['rememberThis'] as $element) {
         $list[] = $element['element']['identifier'];
     }
     $output['list'] = $list;
     // Generate the result
     if (!count($_SESSION['rememberThis'])) {
         if (!$this->getOption('notRememberRedirect')) {
             $output['result'] = $this->modx->getChunk($options['outerTpl'], array('wrapper' => $this->modx->getChunk($options['noResultsTpl']), 'count' => $this->getOption('showZeroCount') ? '0' : ''));
         } else {
             $this->modx->sendRedirect($this->modx->makeUrl($this->getOption('notRememberRedirect')));
         }
     } else {
         $output['result'] = $this->modx->getChunk($options['outerTpl'], array('wrapper' => $this->showElements($options['rowTpl']), 'count' => (string) count($_SESSION['rememberThis'])));
     }
     // Generate count
     $output['count'] = count($_SESSION['rememberThis']);
     // Generate debug informations
     if ($this->getOption('debug')) {
         $output['debug'] = '<pre>DEBUG: $_SESSION["rememberThis"] = ' . print_r($_SESSION['rememberThis'], TRUE) . '</pre>';
     }
     return $output;
 }
开发者ID:Vitaliz,项目名称:RememberThis,代码行数:33,代码来源:rememberthis.class.php

示例5: _cleanResourceIdentifier

 /**
  * Cleans the resource identifier from the request params.
  *
  * @param string $identifier The raw identifier.
  * @return string|integer The cleansed identifier.
  */
 public function _cleanResourceIdentifier($identifier)
 {
     if (empty($identifier)) {
         $identifier = $this->modx->getOption('site_start', null, 1);
         $this->modx->resourceMethod = 'id';
     } elseif ($this->modx->getOption('friendly_urls', null, false) && ($this->modx->resourceMethod = 'alias')) {
         $containerSuffix = trim($this->modx->getOption('container_suffix', null, ''));
         if (!isset($this->modx->aliasMap[$identifier])) {
             if (!empty($containerSuffix)) {
                 $suffixPos = strpos($identifier, $containerSuffix);
                 $suffixLen = strlen($containerSuffix);
                 $identifierLen = strlen($identifier);
                 if (substr($identifier, $identifierLen - $suffixLen) === $containerSuffix) {
                     $identifier = substr($identifier, 0, $identifierLen - $suffixLen);
                 } elseif (isset($this->modx->aliasMap["{$identifier}{$containerSuffix}"])) {
                     $identifier = "{$identifier}{$containerSuffix}";
                 }
                 if (isset($this->modx->aliasMap[$identifier])) {
                     $url = $this->modx->makeUrl($this->modx->aliasMap[$identifier], '', '', 'full');
                     $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
                 }
                 $this->modx->resourceMethod = 'alias';
             }
         } elseif ($this->modx->getOption('site_start', null, 1) == $this->modx->aliasMap[$identifier]) {
             $this->modx->sendRedirect($this->modx->getOption('site_url', null, MODX_SITE_URL), array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
         } else {
             $this->modx->resourceMethod = 'alias';
         }
     } else {
         $this->modx->resourceMethod = 'id';
     }
     return $identifier;
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:39,代码来源:modrequest.class.php

示例6: redirect

 /**
  * Redirect to a specified URL.
  *
  * Properties needed:
  * - redirectTo - the ID of the Resource to redirect to.
  *
  * @param array $fields An array of cleaned POST fields
  * @return boolean False if unsuccessful.
  */
 public function redirect(array $fields = array())
 {
     if (empty($this->login->config['redirectTo'])) {
         return false;
     }
     $url = $this->modx->makeUrl($this->login->config['redirectTo'], '', '', 'abs');
     return $this->modx->sendRedirect($url);
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:17,代码来源:loginhooks.class.php

示例7: _cleanResourceIdentifier

 /**
  * Cleans the resource identifier from the request params.
  *
  * @param string $identifier The raw identifier.
  * @return string|integer The cleansed identifier.
  */
 public function _cleanResourceIdentifier($identifier)
 {
     if (empty($identifier)) {
         if ($this->modx->getOption('base_url', null, MODX_BASE_URL) !== strtok($_SERVER["REQUEST_URI"], '?')) {
             $this->modx->sendRedirect($this->modx->getOption('site_url', null, MODX_SITE_URL), array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
         }
         $identifier = $this->modx->getOption('site_start', null, 1);
         $this->modx->resourceMethod = 'id';
     } elseif ($this->modx->getOption('friendly_urls', null, false) && $this->modx->resourceMethod == 'alias') {
         $containerSuffix = trim($this->modx->getOption('container_suffix', null, ''));
         $found = $this->modx->findResource($identifier);
         if ($found === false && !empty($containerSuffix)) {
             $suffixLen = strlen($containerSuffix);
             $identifierLen = strlen($identifier);
             if (substr($identifier, $identifierLen - $suffixLen) === $containerSuffix) {
                 $identifier = substr($identifier, 0, $identifierLen - $suffixLen);
                 $found = $this->modx->findResource($identifier);
             } else {
                 $identifier = "{$identifier}{$containerSuffix}";
                 $found = $this->modx->findResource("{$identifier}{$containerSuffix}");
             }
             if ($found) {
                 $parameters = $this->getParameters();
                 unset($parameters[$this->modx->getOption('request_param_alias')]);
                 $url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
                 $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
             }
             $this->modx->resourceMethod = 'alias';
         } elseif ((int) $this->modx->getOption('site_start', null, 1) === $found) {
             $parameters = $this->getParameters();
             unset($parameters[$this->modx->getOption('request_param_alias')]);
             $url = $this->modx->makeUrl($this->modx->getOption('site_start', null, 1), $this->modx->context->get('key'), $parameters, 'full');
             $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
         } else {
             if ($this->modx->getOption('friendly_urls_strict', null, false)) {
                 $requestUri = $_SERVER['REQUEST_URI'];
                 $qsPos = strpos($requestUri, '?');
                 if ($qsPos !== false) {
                     $requestUri = substr($requestUri, 0, $qsPos);
                 }
                 $fullId = $this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier;
                 $requestUri = urldecode($requestUri);
                 if ($fullId !== $requestUri && strpos($requestUri, $fullId) !== 0) {
                     $parameters = $this->getParameters();
                     unset($parameters[$this->modx->getOption('request_param_alias')]);
                     $url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
                     $this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
                 }
             }
             $this->modx->resourceMethod = 'alias';
         }
     } else {
         $this->modx->resourceMethod = 'id';
     }
     return $identifier;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:62,代码来源:modrequest.class.php

示例8: checkAuthentication

 /**
  * Checks authentication for the current MODX User / Session.
  * Sets hmRequest::authorized with a boolean value indicating authentication status.
  * Also processes logout and login.
  */
 public function checkAuthentication()
 {
     $this->authorized = $this->modx->user && $this->modx->user->hasSessionContext('mgr');
     /* If we are authorized, the $this->authorized variable will have a value
      ***/
     if ($this->authorized) {
         // Check if it needs to log out
         if ($_GET['hma'] == 'logout') {
             $return = $this->hm->runProcessor(array('action' => 'logout', 'location' => 'security'), $this->modx);
             if ($return['success'] == 1) {
                 $this->action = array('hma' => 'login', 'options' => array('message' => 'Successfully logged out.'));
                 $this->authorized = false;
                 // We redirect to make sure the session is available to other scripts.
                 return $this->modx->sendRedirect($this->hm->config['baseUrl']);
             } else {
                 $this->action = array('hma' => 'home', 'options' => array('message' => $return['message']));
             }
         } else {
             $this->action = $_GET['hma'] ? array('hma' => $_GET['hma'], 'options' => array('source' => 'get')) : array('hma' => 'home', 'options' => array('source' => 'default'));
         }
     } else {
         if (!$this->authorized) {
             // Check if there is a login attempt, and if so validate it
             if ($_POST['hm_action'] == 'login') {
                 $return = $this->hm->runProcessor(array('action' => 'login', 'location' => 'security'), $this->modx);
                 if ($return['success'] == 1) {
                     $this->action = array('hma' => 'home', 'options' => array('source' => 'login'));
                     // We redirect to make sure the session is available to other scripts.
                     return $this->modx->sendRedirect($this->hm->config['baseUrl']);
                 } else {
                     $msg = $return['message'];
                     $this->action = array('hma' => 'login', 'options' => array('message' => $msg));
                 }
                 // Show the "login" action -> a login form.
             } else {
                 $this->action = array('hma' => 'login', 'options' => array('source' => 'default'));
             }
         }
     }
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:45,代码来源:hmrequest.class.php

示例9: render

 /**
  * Render the controller.
  *
  * @return string
  */
 public function render()
 {
     if ($this->modx->getOption('discuss.debug', null, true)) {
         $this->modx->setLogTarget('ECHO');
         $this->startDebugTimer();
     }
     foreach ($this->config as $k => $v) {
         $this->setPlaceholder('controller.' . $k, $v);
     }
     foreach ($this->discuss->config as $k => $v) {
         $this->setPlaceholder('discuss.config.' . $k, $v);
     }
     $this->initialize();
     $allowed = $this->checkPermissions();
     if ($allowed !== true) {
         if (is_string($allowed)) {
             $this->modx->sendRedirect($allowed);
         } else {
             $this->discuss->sendUnauthorizedPage();
         }
     }
     $sessionPlace = $this->getSessionPlace();
     if (!empty($sessionPlace)) {
         $this->discuss->setSessionPlace($sessionPlace);
     }
     $this->handleActions();
     $this->process();
     if ($this->discuss->user->isLoggedIn) {
         $this->getUserTop();
     }
     if ($this->getOption('showStatistics', true)) {
         $this->getStatistics();
     }
     $title = $this->getPageTitle();
     if (!empty($title)) {
         $this->modx->setPlaceholder('discuss.pagetitle', $title);
     }
     $this->_renderBreadcrumbs();
     $this->_renderModules();
     $tpl = $this->getOption('pageTpl', false);
     $tpl = $tpl ? $this->discuss->config['pagesPath'] . $tpl . '.tpl' : $this->config['tpl'];
     $output = $this->_renderTemplate($tpl, $this->placeholders);
     $output = $this->afterRender($output);
     return $this->_output($output);
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:50,代码来源:discusscontroller.class.php

示例10: handleThreadViewActions

 /**
  * Handle actions on thread view
  *
  * @param array $scriptProperties
  * @return boolean
  */
 public function handleThreadViewActions(array $scriptProperties)
 {
     if (!$this->xpdo->discuss->user->isLoggedIn) {
         return false;
     }
     /* mark unread if user clicks mark unread */
     if (isset($scriptProperties['unread'])) {
         if ($this->unread($this->xpdo->discuss->user->get('id'))) {
             $this->xpdo->sendRedirect($this->xpdo->discuss->request->makeUrl('board', array('board' => $this->get('board'))));
         }
     }
     if (!empty($scriptProperties['sticky']) && $this->canStick()) {
         if ($this->stick()) {
             $this->xpdo->sendRedirect($this->xpdo->discuss->request->makeUrl('board', array('board' => $this->get('board'))));
         }
     }
     if (isset($scriptProperties['sticky']) && $scriptProperties['sticky'] == 0 && $this->canUnstick()) {
         if ($this->unstick()) {
             $this->xpdo->sendRedirect($this->xpdo->discuss->request->makeUrl('board', array('board' => $this->get('board'))));
         }
     }
     if (!empty($scriptProperties['lock']) && $this->canLock()) {
         if ($this->lock()) {
             $this->xpdo->sendRedirect($this->xpdo->discuss->request->makeUrl('board', array('board' => $this->get('board'))));
         }
     }
     if (isset($scriptProperties['lock']) && $scriptProperties['lock'] == 0 && $this->canUnlock()) {
         if ($this->unlock()) {
             $this->xpdo->sendRedirect($this->xpdo->discuss->request->makeUrl('board', array('board' => $this->get('board'))));
         }
     }
     if (!empty($scriptProperties['subscribe']) && $this->canSubscribe()) {
         if ($this->addSubscription($this->xpdo->discuss->user->get('id'))) {
             $this->xpdo->sendRedirect($this->getUrl());
         }
     }
     if (!empty($scriptProperties['unsubscribe']) && $this->canUnsubscribe()) {
         if ($this->removeSubscription($this->xpdo->discuss->user->get('id'))) {
             $this->xpdo->sendRedirect($this->getUrl());
         }
     }
     return true;
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:49,代码来源:disthread.class.php

示例11: redirect

 /**
  * Send a redirect.
  *
  * @param $action
  * @param array $params
  */
 public function redirect($action, array $params = array())
 {
     $params['action'] = $action;
     $url = $this->hm->url . 'index.php?' . http_build_query($params);
     $this->modx->sendRedirect($url);
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:12,代码来源:hmcontroller.class.php

示例12: sendRedirect

 /**
  * @param $url
  * @param bool|false $options
  * @param string $type
  * @param string $responseCode
  */
 public function sendRedirect($url, $options = false, $type = '', $responseCode = '')
 {
     $this->modx->sendRedirect($url, $options, $type, $responseCode);
 }
开发者ID:suasti,项目名称:pdoTools,代码行数:10,代码来源:_micromodx.php

示例13: createPayment

 /**
  * @param array $data
  *
  * @return array|string
  */
 public function createPayment(array $data)
 {
     if (!$this->modx->user->isAuthenticated($this->modx->context->key)) {
         return $this->ms2->error($this->modx->lexicon('ms2_profile_err_auth'));
     }
     // Call system event
     $response = $this->ms2->invokeEvent('msOnSubmitOrder', array('data' => $data, 'order' => $this->ms2->order));
     if (!$response['success']) {
         return $this->ms2->error($response['message']);
     }
     if (!empty($response['data']['data'])) {
         $data = array_merge($data, $response['data']['data']);
         $this->ms2->order->set($data);
     }
     // Check required fields
     $errors = array();
     if (empty($data['sum']) || $data['sum'] < $this->config['minSum']) {
         $errors['sum'] = $this->modx->lexicon('ms2_profile_err_min_sum', array('min_sum' => $this->config['minSum']));
     } elseif (!empty($maxSum) && $data['sum'] > $this->config['maxSum']) {
         $errors['sum'] = $this->modx->lexicon('ms2_profile_err_max_sum', array('max_sum' => $this->config['maxSum']));
     }
     if (empty($data['payment'])) {
         $errors['payment'] = $this->modx->lexicon('ms2_profile_err_payment', array('min_sum' => $this->config['minSum']));
     }
     if (!empty($errors)) {
         return $this->ms2->error($this->modx->lexicon('ms2_profile_err_form'), $errors);
     }
     // Create new order
     /** @var msOrder $order */
     $order = $this->modx->newObject('msOrder', array('user_id' => $this->modx->user->id, 'createdon' => date('Y-m-d H:i:s'), 'num' => $this->ms2->order->getnum(), 'delivery' => 0, 'payment' => $data['payment'], 'cart_cost' => $data['sum'], 'weight' => 0, 'delivery_cost' => 0, 'cost' => $data['sum'], 'status' => 0, 'context' => $this->ms2->config['ctx'], 'properties' => array('account_charge' => true)));
     $products = array($this->modx->newObject('msOrderProduct', array('product_id' => 0, 'name' => $this->modx->lexicon('ms2_profile_charge'), 'price' => $data['sum'], 'cost' => $data['sum'])));
     $order->addMany($products);
     $response = $this->ms2->invokeEvent('msOnBeforeCreateOrder', array('msOrder' => $order, 'order' => $this->ms2->order));
     if (!$response['success']) {
         return $this->ms2->error($response['message']);
     }
     if ($order->save()) {
         $response = $this->ms2->invokeEvent('msOnCreateOrder', array('msOrder' => $order, 'order' => $this->ms2->order));
         if (!$response['success']) {
             return $this->ms2->error($response['message']);
         }
         if (empty($_SESSION['minishop2']['orders'])) {
             $_SESSION['minishop2']['orders'] = array();
         }
         $_SESSION['minishop2']['orders'][] = $order->get('id');
         // Trying to set status "new"
         $response = $this->ms2->changeOrderStatus($order->get('id'), 1);
         if ($response !== true) {
             return $this->ms2->error($response, array('msorder' => $order->get('id')));
         } elseif ($payment = $this->modx->getObject('msPayment', array('id' => $order->get('payment'), 'active' => 1))) {
             $response = $payment->send($order);
             if (!empty($response['data']['redirect'])) {
                 $this->modx->sendRedirect($response['data']['redirect']);
             } elseif (!empty($response['data']['msorder'])) {
                 $this->modx->sendRedirect($this->modx->context->makeUrl($this->modx->resource->id, array('msorder' => $response['data']['msorder'])));
             } else {
                 $this->modx->sendRedirect($this->modx->context->makeUrl($this->modx->resource->id));
             }
         } else {
             $this->modx->sendRedirect($this->modx->context->makeUrl($this->modx->resource->id, array('msorder' => $response['data']['msorder'])));
         }
     }
 }
开发者ID:ASDAFF,项目名称:msProfile,代码行数:68,代码来源:msprofile.class.php

示例14: dirname

<?php

require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$snippet = $modx->getObject('modSnippet', array('name' => 'YandexMoney'));
$config = $snippet->getProperties();
$config['payStatusOut'] = $modx->getOption('yandexmoney.payStatusOut', null, 5);
if (!defined('YANDEXMONEY_PATH')) {
    define('YANDEXMONEY_PATH', MODX_CORE_PATH . "components/yandexmoney/");
}
if ($_GET['fail'] == 1) {
    if ($res = $modx->getObject('modResource', $config['fail_page_id'])) {
        $modx->sendRedirect($modx->makeUrl($config['fail_page_id'], '', '', 'full'));
    }
    exit;
} elseif ($_GET['success'] == 1) {
    if ($res = $modx->getObject('modResource', $config['success_page_id'])) {
        $modx->sendRedirect($modx->makeUrl($config['success_page_id'], '', '', 'full'));
    }
    exit;
}
require_once YANDEXMONEY_PATH . 'model/yandexmoney.class.php';
$ym = new Yandexmoney($modx, $config);
$order_id = $ym->ProcessResult();
if ($order_id) {
    $modx->addPackage('shopkeeper3', MODX_CORE_PATH . "components/shopkeeper3/model/");
    $order = $modx->getObject('shk_order', array('id' => $order_id));
    $order->set('status', $config['payStatusOut']);
开发者ID:andchir,项目名称:yandex-money-cms-modx,代码行数:31,代码来源:connector_result.php

示例15: submit

 /** @inheritdoc} */
 public function submit($data = array())
 {
     $response = $this->ms2->invokeEvent('msOnSubmitOrder', array('data' => $data, 'order' => $this));
     if (!$response['success']) {
         return $this->error($response['message']);
     }
     if (!empty($response['data']['data'])) {
         $this->set($response['data']['data']);
     }
     $response = $this->getDeliveryRequiresFields();
     if ($this->ms2->config['json_response']) {
         $response = $this->modx->fromJSON($response);
     }
     $requires = $response['data']['requires'];
     $errors = array();
     foreach ($requires as $v) {
         if (!empty($v) && empty($this->order[$v])) {
             $errors[] = $v;
         }
     }
     if (!empty($errors)) {
         return $this->error('ms2_order_err_requires', $errors);
     }
     $user_id = $this->ms2->getCustomerId();
     $cart_status = $this->ms2->cart->status();
     $delivery_cost = $this->getCost(false, true);
     $createdon = date('Y-m-d H:i:s');
     /* @var msOrder $order */
     $order = $this->modx->newObject('msOrder');
     $order->fromArray(array('user_id' => $user_id, 'createdon' => $createdon, 'num' => $this->getnum(), 'delivery' => $this->order['delivery'], 'payment' => $this->order['payment'], 'cart_cost' => $cart_status['total_cost'], 'weight' => $cart_status['total_weight'], 'delivery_cost' => $delivery_cost, 'cost' => $cart_status['total_cost'] + $delivery_cost, 'status' => 0, 'context' => $this->ms2->config['ctx']));
     // Adding address
     /* @var msOrderAddress $address */
     $address = $this->modx->newObject('msOrderAddress');
     $address->fromArray(array_merge($this->order, array('user_id' => $user_id, 'createdon' => $createdon)));
     $order->addOne($address);
     // Adding products
     $cart = $this->ms2->cart->get();
     $products = array();
     foreach ($cart as $v) {
         /* @var msOrderProduct $product */
         $product = $this->modx->newObject('msOrderProduct');
         $product->fromArray(array_merge($v, array('product_id' => $v['id'], 'cost' => $v['price'] * $v['count'])));
         $products[] = $product;
     }
     $order->addMany($products);
     $response = $this->ms2->invokeEvent('msOnBeforeCreateOrder', array('msOrder' => $order, 'order' => $this));
     if (!$response['success']) {
         return $this->error($response['message']);
     }
     if ($order->save()) {
         $response = $this->ms2->invokeEvent('msOnCreateOrder', array('msOrder' => $order, 'order' => $this));
         if (!$response['success']) {
             return $this->error($response['message']);
         }
         $this->ms2->cart->clean();
         $this->clean();
         if (empty($_SESSION['minishop2']['orders'])) {
             $_SESSION['minishop2']['orders'] = array();
         }
         $_SESSION['minishop2']['orders'][] = $order->get('id');
         // Trying to set status "new"
         $response = $this->ms2->changeOrderStatus($order->get('id'), 1);
         if ($response !== true) {
             return $this->error($response, array('msorder' => $order->get('id')));
         } elseif ($payment = $this->modx->getObject('msPayment', array('id' => $order->get('payment'), 'active' => 1))) {
             $response = $payment->send($order);
             if ($this->config['json_response']) {
                 @session_write_close();
                 exit(is_array($response) ? $this->modx->toJSON($response) : $response);
             } else {
                 if (!empty($response['data']['redirect'])) {
                     $this->modx->sendRedirect($response['data']['redirect']);
                     exit;
                 } elseif (!empty($response['data']['msorder'])) {
                     $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id), array('msorder' => $response['data']['msorder']));
                     exit;
                 } else {
                     $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id));
                     exit;
                 }
             }
         } else {
             if ($this->ms2->config['json_response']) {
                 return $this->success('', array('msorder' => $order->get('id')));
             } else {
                 $this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id), array('msorder' => $response['data']['msorder']));
                 exit;
             }
         }
     }
     return $this->error();
 }
开发者ID:bendasvadim,项目名称:miniShop2,代码行数:93,代码来源:msorderhandler.class.php


注:本文中的modX::sendRedirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。