[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <04-Mar-2003 10:22:42 bf> 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 $http =& eZHTTPTool::instance(); 28 $module =& $Params["Module"]; 29 30 include_once ( 'kernel/common/template.php' ); 31 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 32 include_once ( 'kernel/classes/ezbasket.php' ); 33 include_once ( 'lib/ezxml/classes/ezxml.php' ); 34 include_once ( 'lib/ezutils/classes/ezmail.php' ); 35 36 $tpl =& templateInit(); 37 38 if ( $module->isCurrentAction( 'Cancel' ) ) 39 { 40 $module->redirectTo( '/shop/basket/' ); 41 return; 42 } 43 44 $user =& eZUser::currentUser(); 45 46 $firstName = ''; 47 $lastName = ''; 48 $email = ''; 49 if ( $user->isLoggedIn() ) 50 { 51 $userObject = $user->attribute( 'contentobject' ); 52 $userMap = $userObject->dataMap(); 53 $firstName = $userMap['first_name']->content(); 54 $lastName = $userMap['last_name']->content(); 55 $email = $user->attribute( 'email' ); 56 } 57 58 // Initialize variables 59 $street1 = $street2 = $zip = $place = $state = $country = $comment = ''; 60 61 62 // Check if user has an earlier order, copy order info from that one 63 $orderList = eZOrder::activeByUserID( $user->attribute( 'contentobject_id' ) ); 64 if ( count( $orderList ) > 0 and $user->isLoggedIn() ) 65 { 66 $accountInfo = $orderList[0]->accountInformation(); 67 $street1 = $accountInfo['street1']; 68 $street2 = $accountInfo['street2']; 69 $zip = $accountInfo['zip']; 70 $place = $accountInfo['place']; 71 $state = $accountInfo['state']; 72 $country = $accountInfo['country']; 73 } 74 75 $tpl->setVariable( "input_error", false ); 76 if ( $module->isCurrentAction( 'Store' ) ) 77 { 78 $inputIsValid = true; 79 $firstName = $http->postVariable( "FirstName" ); 80 if ( trim( $firstName ) == "" ) 81 $inputIsValid = false; 82 $lastName = $http->postVariable( "LastName" ); 83 if ( trim( $lastName ) == "" ) 84 $inputIsValid = false; 85 $email = $http->postVariable( "EMail" ); 86 if ( ! eZMail::validate( $email ) ) 87 $inputIsValid = false; 88 89 $street1 = $http->postVariable( "Street1" ); 90 $street2 = $http->postVariable( "Street2" ); 91 if ( trim( $street2 ) == "" ) 92 $inputIsValid = false; 93 94 $zip = $http->postVariable( "Zip" ); 95 if ( trim( $zip ) == "" ) 96 $inputIsValid = false; 97 $place = $http->postVariable( "Place" ); 98 if ( trim( $place ) == "" ) 99 $inputIsValid = false; 100 $state = $http->postVariable( "State" ); 101 $country = $http->postVariable( "Country" ); 102 if ( trim( $country ) == "" ) 103 $inputIsValid = false; 104 105 $comment = $http->postVariable( "Comment" ); 106 107 if ( $inputIsValid == true ) 108 { 109 // Check for validation 110 $basket =& eZBasket::currentBasket(); 111 112 $db =& eZDB::instance(); 113 $db->begin(); 114 $order = $basket->createOrder(); 115 116 $doc = new eZDOMDocument( 'account_information' ); 117 118 $root = $doc->createElementNode( "shop_account" ); 119 $doc->setRoot( $root ); 120 121 $firstNameNode = $doc->createElementNode( "first-name" ); 122 $firstNameNode->appendChild( $doc->createTextNode( $firstName ) ); 123 $root->appendChild( $firstNameNode ); 124 125 $lastNameNode = $doc->createElementNode( "last-name" ); 126 $lastNameNode->appendChild( $doc->createTextNode( $lastName ) ); 127 $root->appendChild( $lastNameNode ); 128 129 $emailNode = $doc->createElementNode( "email" ); 130 $emailNode->appendChild( $doc->createTextNode( $email ) ); 131 $root->appendChild( $emailNode ); 132 133 $street1Node = $doc->createElementNode( "street1" ); 134 $street1Node->appendChild( $doc->createTextNode( $street1 ) ); 135 $root->appendChild( $street1Node ); 136 137 $street2Node = $doc->createElementNode( "street2" ); 138 $street2Node->appendChild( $doc->createTextNode( $street2 ) ); 139 $root->appendChild( $street2Node ); 140 141 $zipNode = $doc->createElementNode( "zip" ); 142 $zipNode->appendChild( $doc->createTextNode( $zip ) ); 143 $root->appendChild( $zipNode ); 144 145 $placeNode = $doc->createElementNode( "place" ); 146 $placeNode->appendChild( $doc->createTextNode( $place ) ); 147 $root->appendChild( $placeNode ); 148 149 $stateNode = $doc->createElementNode( "state" ); 150 $stateNode->appendChild( $doc->createTextNode( $state ) ); 151 $root->appendChild( $stateNode ); 152 153 $countryNode = $doc->createElementNode( "country" ); 154 $countryNode->appendChild( $doc->createTextNode( $country ) ); 155 $root->appendChild( $countryNode ); 156 157 $commentNode = $doc->createElementNode( "comment" ); 158 $commentNode->appendChild( $doc->createTextNode( $comment ) ); 159 $root->appendChild( $commentNode ); 160 161 $order->setAttribute( 'data_text_1', $doc->toString() ); 162 $order->setAttribute( 'account_identifier', "ez" ); 163 164 $order->setAttribute( 'ignore_vat', 0 ); 165 166 $order->store(); 167 $db->commit(); 168 include_once ( 'kernel/shop/classes/ezshopfunctions.php' ); 169 eZShopFunctions::setPreferredUserCountry( $country ); 170 eZHTTPTool::setSessionVariable( 'MyTemporaryOrderID', $order->attribute( 'id' ) ); 171 172 $module->redirectTo( '/shop/confirmorder/' ); 173 return; 174 } 175 else 176 { 177 $tpl->setVariable( "input_error", true ); 178 } 179 } 180 181 $tpl->setVariable( "first_name", $firstName ); 182 $tpl->setVariable( "last_name", $lastName ); 183 $tpl->setVariable( "email", $email ); 184 185 $tpl->setVariable( "street1", $street1 ); 186 $tpl->setVariable( "street2", $street2 ); 187 $tpl->setVariable( "zip", $zip ); 188 $tpl->setVariable( "place", $place ); 189 $tpl->setVariable( "state", $state ); 190 $tpl->setVariable( "country", $country ); 191 $tpl->setVariable( "comment", $comment ); 192 193 $Result = array(); 194 $Result['content'] =& $tpl->fetch( "design:shop/userregister.tpl" ); 195 $Result['path'] = array( array( 'url' => false, 196 'text' => ezi18n( 'kernel/shop', 'Enter account information' ) ) ); 197 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |