Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

sendwishlist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: sendwishlist.php 8850 2002-01-02 21:42:12Z kaid $
5 //
6 // Created on: <15-Jan-2001 14:17:36 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlocale.php" );
30 // include_once( "classes/ezcurrency.php" );
31
32 // include_once( "ezuser/classes/ezuser.php" );
33
34 $ini =& eZINI::instance( 'site.ini' );
35 $wwwDir = $ini->WWWDir;
36 $indexFile = $ini->Index;
37
38 $Language = $ini->variable( "eZTradeMain", "Language" );
39
40 // include_once( "eztrade/classes/ezwishlist.php" );
41 // include_once( "ezsession/classes/ezsession.php" );
42 // include_once( "ezmail/classes/ezmail.php" );
43
44
45 $wishlist = new eZWishList();
46 $session = new eZSession();
47
48 // if no session exist create one.
49 if ( !$session->fetch() )
50 {
51 $session->store();
52 }
53
54 $user =& eZUser::currentUser();
55
56 if ( !$user )
57 {
58 eZHTTPTool::header( "Location: /trade/customerlogin/?RedirectURL=/trade/wishlist/" );
59 exit();
60 }
61
62 $wishlist = $wishlist->getByUser( $user );
63
64 if ( !$wishlist )
65 {
66 print( "creating a wishlist" );
67 $wishlist = new eZWishList();
68 $wishlist->setUser( $user );
69
70 $wishlist->store();
71 eZHTTPTool::header( "Location: /trade/wishlist/" );
72 exit();
73 }
74
75 if ( isset( $Action ) && $Action == "SendWishlist" )
76 {
77 $SendToArray = explode( ",", $SendTo );
78
79 $correctEmails = true;
80 foreach ( $SendToArray as $toAddress )
81 {
82 if ( !eZMail::validate( trim( $toAddress ) ) )
83 {
84 $correctEmails = false;
85 }
86 }
87
88
89 if ( $correctEmails )
90 {
91 $mail = new eZMail();
92 $mailTemplate = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
93 "kernel/eztrade/user/intl/", $Language, "wishlistmail.php" );
94
95 $mailTemplate->setAllStrings();
96
97 $mailTemplate->set_file( array(
98 "wishlist_mail_tpl" => "wishlistmail.tpl"
99 ) );
100
101 $mailTemplate->set_block( "wishlist_mail_tpl", "subject_tpl", "subject" );
102 $mailTemplate->set_block( "wishlist_mail_tpl", "product_tpl", "product" );
103
104 $headersInfo = getallheaders();
105
106 $mail->setFrom( $user->email() );
107
108 $mailTemplate->set_var( "first_name", $user->firstName() );
109
110 $mailTemplate->set_var( "host_name", $headersInfo["Host"].$indexFile );
111 $mailTemplate->set_var( "user_id", $user->id() );
112
113 $subject = $mailTemplate->parse( "dummy", "subject_tpl" );
114 $mailTemplate->set_var( "subject", "" );
115
116 $mailTemplate->set_var( "message", $Message );
117
118
119 $items = $wishlist->items();
120
121 foreach ( $items as $item )
122 {
123 $mailTemplate->set_var( "host_name", $headersInfo["Host"].$indexFile );
124
125 $product =& $item->product();
126 $mailTemplate->set_var( "product_id", $product->id() );
127 $mailTemplate->set_var( "product_name", $product->name() );
128 $mailTemplate->parse( "product", "product_tpl", true );
129 }
130
131 $mail->setSubject( $subject );
132 $mail->setBody( $mailTemplate->parse( "dummy", "wishlist_mail_tpl" ) );
133
134
135 // send to multiplce recipients
136 foreach ( $SendToArray as $toAddress )
137 {
138 $mail->setTo( trim( $toAddress ) );
139 $mail->send();
140 }
141
142 eZHTTPTool::header( "Location: /trade/sendwishlist/success/" );
143 exit();
144 }
145 else
146 {
147 $EmailError = true;
148 print( "Email error" );
149
150 }
151
152 }
153
154
155 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
156 "kernel/eztrade/user/intl/", $Language, "sendwishlist.php" );
157
158 $t->setAllStrings();
159
160 $t->set_file( array(
161 "sendwishlist_page_tpl" => "sendwishlist.tpl"
162 ) );
163
164 $t->set_block( "sendwishlist_page_tpl", "wishlist_sendt_tpl", "wishlist_sendt" );
165 $t->set_block( "sendwishlist_page_tpl", "wishlist_empty_tpl", "wishlist_empty" );
166 $t->set_block( "sendwishlist_page_tpl", "wishlist_private_tpl", "wishlist_private" );
167 $t->set_block( "sendwishlist_page_tpl", "send_wishlist_tpl", "send_wishlist" );
168
169 if ( count( $wishlist->items() ) == 0 )
170 {
171 $t->parse( "wishlist_empty", "wishlist_empty_tpl" );
172
173 $t->set_var( "send_wishlist", "" );
174 $t->set_var( "wishlist_sendt", "" );
175 $t->set_var( "wishlist_private", "" );
176 }
177 else if ( $wishlist->isPublic() == false )
178 {
179 $t->parse( "wishlist_private", "wishlist_private_tpl" );
180
181 $t->set_var( "wishlist_empty", "" );
182 $t->set_var( "send_wishlist", "" );
183 $t->set_var( "wishlist_sendt", "" );
184
185 }
186 else
187 {
188 $t->set_var( "wishlist_private", "" );
189 $t->set_var( "wishlist_empty", "" );
190
191 if ( $url_array[3] == "success" )
192 {
193 $t->parse( "wishlist_sendt", "wishlist_sendt_tpl" );
194 $t->set_var( "send_wishlist", "" );
195 }
196 else
197 {
198 $t->set_var( "wishlist_sendt", "" );
199 $t->parse( "send_wishlist", "send_wishlist_tpl" );
200 }
201 }
202
203 $locale = new eZLocale( $Language );
204
205
206 $t->pparse( "output", "sendwishlist_page_tpl" );
207
208 ?>
$items
$items
Definition: admin/orderview.php:211
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZMail
Definition: ezmail.php:57
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZSession
Definition: lib/ezsession/classes/ezsession.php:65
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
eZWishList
Definition: ezwishlist.php:63
$item
$item
Definition: classes/admin/linklist.php:228
$Action
$Action
Definition: companysearch.php:80
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
$mail
$mail
Definition: ezbulkmail/admin/maillist.php:61
exit
exit
Definition: folder.php:81
$headersInfo
$headersInfo
Definition: forgot.php:32
$product
$product
Definition: homepage.php:202
$indexFile
$indexFile
Definition: sendwishlist.php:36
$wwwDir
$wwwDir
Definition: sendwishlist.php:35
$locale
$locale
Definition: sendwishlist.php:203
$Language
$Language
Definition: sendwishlist.php:38
$ini
$ini
Definition: sendwishlist.php:34
$user
if(! $session->fetch()) $user
Definition: sendwishlist.php:54
$session
$session
Definition: sendwishlist.php:46
$wishlist
$wishlist
Definition: sendwishlist.php:45
$t
if(! $wishlist) if(isset( $Action) && $Action=="SendWishlist") $t
Definition: sendwishlist.php:155
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.