eZ Publish  [4.0]
ezusershopaccounthandler.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZUserShopAccountHandler class
00004 //
00005 // Created on: <04-Mar-2003 09:40:49 bf>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 class eZUserShopAccountHandler
00032 {
00033     /*!
00034     */
00035     function eZUserShopAccountHandler()
00036     {
00037 
00038     }
00039 
00040     /*!
00041      Will verify that the user has supplied the correct user information.
00042      Returns true if we have all the information needed about the user.
00043     */
00044     function verifyAccountInformation()
00045     {
00046         return false;
00047     }
00048 
00049     /*!
00050      Redirectes to the user registration page.
00051     */
00052     function fetchAccountInformation( &$module )
00053     {
00054         $module->redirectTo( '/shop/userregister/' );
00055     }
00056 
00057     /*!
00058      \return the account information for the given order
00059     */
00060     function email( $order )
00061     {
00062         $email = false;
00063         $xmlString = $order->attribute( 'data_text_1' );
00064         if ( $xmlString != null )
00065         {
00066             $dom = new DOMDocument( '1.0', 'utf-8' );
00067             $success = $dom->loadXML( $xmlString );
00068             $emailNode = $dom->getElementsByTagName( 'email' )->item( 0 );
00069             if ( $emailNode )
00070             {
00071                 $email = $emailNode->textContent;
00072             }
00073         }
00074 
00075         return $email;
00076     }
00077 
00078     /*!
00079      \return the account information for the given order
00080     */
00081     function accountName( $order )
00082     {
00083         $accountName = '';
00084         $xmlString = $order->attribute( 'data_text_1' );
00085         if ( $xmlString != null )
00086         {
00087             $dom = new DOMDocument( '1.0', 'utf-8' );
00088             $success = $dom->loadXML( $xmlString );
00089             $firstNameNode = $dom->getElementsByTagName( 'first-name' )->item( 0 );
00090             $lastNameNode = $dom->getElementsByTagName( 'last-name' )->item( 0 );
00091             $accountName = $firstNameNode->textContent . ' ' . $lastNameNode->textContent;
00092         }
00093 
00094         return $accountName;
00095     }
00096 
00097     function accountInformation( $order )
00098     {
00099         $firstName = '';
00100         $lastName = '';
00101         $email = '';
00102         $street1 = '';
00103         $street2 = '';
00104         $zip = '';
00105         $place = '';
00106         $country = '';
00107         $comment = '';
00108         $state = '';
00109 
00110         $dom = new DOMDocument( '1.0', 'utf-8' );
00111         $xmlString = $order->attribute( 'data_text_1' );
00112         if ( $xmlString != null )
00113         {
00114             $dom = new DOMDocument( '1.0', 'utf-8' );
00115             $success = $dom->loadXML( $xmlString );
00116 
00117             $firstNameNode = $dom->getElementsByTagName( 'first-name' )->item( 0 );
00118             if ( $firstNameNode )
00119             {
00120                 $firstName = $firstNameNode->textContent;
00121             }
00122 
00123             $lastNameNode = $dom->getElementsByTagName( 'last-name' )->item( 0 );
00124             if ( $lastNameNode )
00125             {
00126                 $lastName = $lastNameNode->textContent;
00127             }
00128 
00129             $emailNode = $dom->getElementsByTagName( 'email' )->item( 0 );
00130             if ( $emailNode )
00131             {
00132                 $email = $emailNode->textContent;
00133             }
00134 
00135             $street1Node = $dom->getElementsByTagName( 'street1' )->item( 0 );
00136             if ( $street1Node )
00137             {
00138                 $street1 = $street1Node->textContent;
00139             }
00140 
00141             $street2Node = $dom->getElementsByTagName( 'street2' )->item( 0 );
00142             if ( $street2Node )
00143             {
00144                 $street2 = $street2Node->textContent;
00145             }
00146 
00147             $zipNode = $dom->getElementsByTagName( 'zip' )->item( 0 );
00148             if ( $zipNode )
00149             {
00150                 $zip = $zipNode->textContent;
00151             }
00152 
00153             $placeNode = $dom->getElementsByTagName( 'place' )->item( 0 );
00154             if ( $placeNode )
00155             {
00156                 $place = $placeNode->textContent;
00157             }
00158 
00159             $stateNode = $dom->getElementsByTagName( 'state' )->item( 0 );
00160             if ( $stateNode )
00161             {
00162                 $state = $stateNode->textContent;
00163             }
00164 
00165             $countryNode = $dom->getElementsByTagName( 'country' )->item( 0 );
00166             if ( $countryNode )
00167             {
00168                 $country = $countryNode->textContent;
00169             }
00170 
00171             $commentNode = $dom->getElementsByTagName( 'comment' )->item( 0 );
00172             if ( $commentNode )
00173             {
00174                 $comment = $commentNode->textContent;
00175             }
00176         }
00177 
00178         return array( 'first_name' => $firstName,
00179                       'last_name' => $lastName,
00180                       'email' => $email,
00181                       'street1' => $street1,
00182                       'street2' => $street2,
00183                       'zip' => $zip,
00184                       'place' => $place,
00185                       'state' => $state,
00186                       'country' => $country,
00187                       'comment' => $comment,
00188                       );
00189     }
00190 }
00191 
00192 ?>