[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/shop/ -> add.php (source)

   1  <?php
   2  //
   3  // Created on: <04-Mar-2005 13:45:19 jhe>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  include_once ( "kernel/classes/ezbasket.php" );
  28  include_once ( 'lib/ezutils/classes/ezoperationhandler.php' );
  29  
  30  $http = eZHttpTool::instance();
  31  $basket = eZBasket::currentBasket();
  32  $module =& $Params["Module"];
  33  
  34  // Verify the ObjectID input
  35  if ( !is_numeric( $ObjectID ) )
  36      return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  37  
  38  // Check if the object exists on disc
  39  if ( !eZContentObject::exists( $ObjectID ) )
  40      return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  41  
  42  // Check if the user can read the object
  43  $object =& eZContentObject::fetch( $ObjectID );
  44  if ( !$object->canRead() )
  45      return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $object->accessList( 'read' ) ) );
  46  
  47  // Check if the object has a price datatype, if not it cannot be used in the basket
  48  $error = $basket->canAddProduct( $object );
  49  if ( $error !== EZ_ERROR_SHOP_OK )
  50      return $Module->handleError( $error, 'shop' );
  51  
  52  $OptionList = $http->sessionVariable( "AddToBasket_OptionList_" . $ObjectID );
  53  
  54  $operationResult = eZOperationHandler::execute( 'shop', 'addtobasket', array( 'basket_id' => $basket->attribute( 'id' ),
  55                                                                                'object_id' => $ObjectID,
  56                                                                                'option_list' => $OptionList ) );
  57  
  58  switch( $operationResult['status'] )
  59  {
  60      case EZ_MODULE_OPERATION_HALTED:
  61      {
  62          if ( isset( $operationResult['redirect_url'] ) )
  63          {
  64              $module->redirectTo( $operationResult['redirect_url'] );
  65              return;
  66          }
  67          else if ( isset( $operationResult['result'] ) )
  68          {
  69              $result =& $operationResult['result'];
  70              $resultContent = false;
  71              if ( is_array( $result ) )
  72              {
  73                  if ( isset( $result['content'] ) )
  74                      $resultContent = $result['content'];
  75                  if ( isset( $result['path'] ) )
  76                      $Result['path'] = $result['path'];
  77              }
  78              else
  79                  $resultContent =& $result;
  80              $Result['content'] =& $resultContent;
  81              return $Result;
  82         }
  83      }break;
  84  }
  85  
  86  
  87  $ini = eZINI::instance();
  88  if ( $ini->variable( 'ShopSettings', 'RedirectAfterAddToBasket' ) == 'reload' )
  89      $module->redirectTo( $http->sessionVariable( "FromPage" ) );
  90  else
  91      $module->redirectTo( "/shop/basket/" );
  92  
  93  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7