eZ Publish  [4.0]
ezdefaultshopaccounthandler.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZDefaultShopAccountHandler class
00004 //
00005 // Created on: <13-Feb-2003 08:58:14 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 eZDefaultShopAccountHandler
00032 {
00033     /*!
00034     */
00035     function eZDefaultShopAccountHandler()
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         // Check login
00047         $user = eZUser::currentUser();
00048         if ( !$user->isLoggedIn() )
00049             return false;
00050         else
00051             return true;
00052     }
00053 
00054     /*!
00055      Redirectes to the user registration page.
00056     */
00057     function email( $order = false )
00058     {
00059         if ( $order === false )
00060             $user = eZUser::currentUser();
00061         else
00062             $user = $order->attribute( 'user' );
00063 
00064         if ( is_object( $user ) )
00065             return $user->attribute( 'email' );
00066         else
00067             return null;
00068     }
00069 
00070     /*!
00071      \return the custom name for the given order
00072     */
00073     function accountName( $order = false )
00074     {
00075         if ( $order === false )
00076             $user = eZUser::currentUser();
00077         else
00078             $user = $order->attribute( 'user' );
00079 
00080         if ( is_object( $user ) )
00081         {
00082             $userObject = $user->attribute( 'contentobject' );
00083             $accountName = $userObject->attribute( 'name' );
00084         }
00085         else
00086             $accountName = null;
00087         return $accountName;
00088     }
00089 
00090     function fetchAccountInformation( &$module )
00091     {
00092         $http = eZHTTPTool::instance();
00093         $http->setSessionVariable( 'RedirectAfterLogin', '/shop/basket/' );
00094         $http->setSessionVariable( 'DoCheckoutAutomatically', true );
00095         $module->redirectTo( '/user/login/' );
00096     }
00097 
00098     function accountInformation( $order )
00099     {
00100         $user = $order->user();
00101         $userObject = $user->attribute( "contentobject" );
00102         $dataMap = $userObject->dataMap();
00103 
00104         return array( 'first_name' => $dataMap['first_name']->content(),
00105                       'last_name' => $dataMap['last_name']->content(),
00106                       'email' => $user->attribute( "email" ) );
00107     }
00108 }
00109 
00110 ?>