Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezvoucheremail.php
Go to the documentation of this file.
1 <?
3 //
4 // $Id: ezvoucheremail.php 7071 2001-09-07 09:54:45Z ce $
5 //
6 // eZVoucherEMail class
7 //
8 // Christoffer A. Elo <ce@ez.no>
9 // Created on: <19-Jun-2001 17:41:06 ce>
10 //
11 // This source file is part of Exponential Basic, publishing software.
12 // Copyright (C) 1999-2001 eZ systems as
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
48 // include_once( "eztrade/classes/ezvoucher.php" );
49 // include_once( "eztrade/classes/ezpreorder.php" );
50
51 // include_once( "ezaddress/classes/ezonline.php" );
52
53 class eZVoucherEMail
54 {
55
62 function __construct( $id=-1 )
63 {
64 if ( is_array( $id ) )
65 {
66 $this->fill( $id );
67 }
68 else if ( $id != -1 )
69 {
70 $this->ID = $id;
71 $this->get( $this->ID );
72 }
73 }
74
78 function store()
79 {
80 $db =& eZDB::globalDatabase();
81 $db->begin();
82
83 $description =& addslashes( $this->Description );
84
85 if ( !isset( $this->ID ) )
86 {
87 $db->lock( "eZTrade_VoucherEMail" );
88 $nextID = $db->nextID( "eZTrade_VoucherEMail", "ID" );
89 $timeStamp =& (new eZDateTime())->timeStamp( true );
90 $password = md5( $this->Password );
91
92 $res = $db->query( "INSERT INTO eZTrade_VoucherEMail
93 ( ID, VoucherID, OnlineID, Description, PreOrderID )
94 VALUES
95 ( '$nextID',
96 '$this->VoucherID',
97 '$this->OnlineID',
98 '$description',
99 '$this->PreOrderID'
100 )
101 " );
102
103 $this->ID = $nextID;
104 }
105 elseif ( is_numeric( $this->ID ) )
106 {
107 $res = $db->query( "UPDATE eZTrade_VoucherEMail SET
108 VoucherID='$this->VoucherID',
109 OnlineID=$this->OnlineID,
110 Description='$this->Description',
111 PreOrderID='$this->PreOrderID'
112 WHERE ID='$this->ID" );
113 }
114 $db->unlock();
115
116 if ( $res == false )
117 $db->rollback( );
118 else
119 $db->commit();
120
121 return true;
122 }
123
127 function delete( $catID=-1 )
128 {
129 if ( $catID == -1 )
130 $catID = $this->ID;
131
132 $db =& eZDB::globalDatabase();
133 $db->begin();
134
135 $res = $db->query( "DELETE FROM eZTrade_VoucherEMail WHERE ID='$this->ID'" );
136
137 if ( $ret == false )
138 $db->rollback( );
139 else
140 $db->commit();
141 }
142
148 function get( $id=-1 )
149 {
150 $db =& eZDB::globalDatabase();
151
152 $ret = false;
153 if ( $id != "" )
154 {
155 $db->array_query( $quizArray, "SELECT * FROM eZTrade_VoucherEMail WHERE ID='$id'",
156 0, 1 );
157 if( count( $quizArray ) == 1 )
158 {
159 $this->fill( $quizArray[0] );
160 $ret = true;
161 }
162 elseif( count( $quizArray ) == 1 )
163 {
164 $this->ID = 0;
165 }
166 }
167 return $ret;
168 }
169
173 function fill( &$value )
174 {
175 $this->ID =& $value[ "ID" ];
176 $this->Description =& $value[ "Description" ];
177 $this->OnlineID =& $value[ "OnlineID" ];
178 $this->VoucherID =& $value[ "VoucherID" ];
179 $this->PreOrderID =& $value[ "PreOrderID" ];
180 }
181
187 function &getAll( $offset=0, $limit=20 )
188 {
189 $db =& eZDB::globalDatabase();
190
191 $returnArray = array();
192 $quizArray = array();
193
194 if ( $limit == false )
195 {
196 $db->array_query( $quizArray, "SELECT ID
197 FROM eZTrade_VoucherEMail
198 ORDER BY StartDate DESC
199 " );
200
201 }
202 else
203 {
204 $db->array_query( $quizArray, "SELECT ID
205 FROM eZTrade_VoucherEMail
206 ORDER BY StartDate DESC
207 LIMIT $offset, $limit" );
208 }
209
210 for ( $i=0; $i < count($quizArray); $i++ )
211 {
212 $returnArray[$i] = new eZVoucherEMail( $quizArray[$i][$db->fieldName( "ID" )] );
213 }
214
215 return $returnArray;
216 }
217
221 function count()
222 {
223 $db =& eZDB::globalDatabase();
224 $ret = false;
225
226 $db->query_single( $result, "SELECT COUNT(ID) as Count
227 FROM eZTrade_VoucherEMail" );
228 $ret = $result[$db->fieldName( "Count" )];
229 return $ret;
230 }
231
235 function id()
236 {
237 return $this->ID;
238 }
239
243 function &description()
244 {
245 return htmlspecialchars( $this->Description );
246 }
247
251 function setDescription( &$value )
252 {
253 $this->Description = $value;
254 }
255
259 function setEmail( &$value )
260 {
261 if ( is_a ( $value, "eZOnline" ) )
262 $this->OnlineID = $value->id();
263 else
264 $this->OnlineID = $value;
265 }
266
270 function setVoucher( &$value )
271 {
272 if ( is_a ( $value, "eZVoucher" ) )
273 $this->VoucherID = $value->id();
274 else
275 $this->VoucherID = $value;
276 }
277
281 function setPreOrder( &$value )
282 {
283 if ( is_a ( $value, "eZPreOrder" ) )
284 $this->PreOrderID = $value->id();
285 else
286 $this->PreOrderID = $value;
287 }
288
292 function email( $asObject=true )
293 {
294 if ( $asObject )
295 $ret = new eZOnline( $this->OnlineID );
296 else
297 $ret = $this->OnlineID;
298
299 return $ret;
300 }
301
305 function voucher( $asObject=true )
306 {
307 if ( $asObject )
308 return eZVoucher( $this->VoucherID );
309 else
310 return $this->VoucherID;
311 }
312
316 function preOrderID( $asObject=true )
317 {
318 if ( $asObject )
319 return eZPreOrderID( $this->PreOrderID );
320 else
321 return $this->PreOrderID;
322 }
323
324
325 var $ID;
326 var $Description;
327 var $PreOrderID;
328 var $OnlineID;
329 var $VoucherID;
330 }
331
332 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZVoucherEMail
Definition: ezvoucheremail.php:54
eZVoucherEMail\setEmail
setEmail(&$value)
Definition: ezvoucheremail.php:259
eZVoucherEMail\$OnlineID
$OnlineID
Definition: ezvoucheremail.php:328
eZVoucherEMail\store
store()
Definition: ezvoucheremail.php:78
eZVoucherEMail\$PreOrderID
$PreOrderID
Definition: ezvoucheremail.php:327
eZVoucherEMail\id
id()
Definition: ezvoucheremail.php:235
eZVoucherEMail\$ID
$ID
Definition: ezvoucheremail.php:325
eZVoucherEMail\__construct
__construct( $id=-1)
Definition: ezvoucheremail.php:62
eZVoucherEMail\setVoucher
setVoucher(&$value)
Definition: ezvoucheremail.php:270
eZVoucherEMail\description
& description()
Definition: ezvoucheremail.php:243
eZVoucherEMail\fill
fill(&$value)
Definition: ezvoucheremail.php:173
eZVoucherEMail\voucher
voucher( $asObject=true)
Definition: ezvoucheremail.php:305
eZVoucherEMail\preOrderID
preOrderID( $asObject=true)
Definition: ezvoucheremail.php:316
eZVoucherEMail\getAll
& getAll( $offset=0, $limit=20)
Definition: ezvoucheremail.php:187
eZVoucherEMail\count
count()
Definition: ezvoucheremail.php:221
eZVoucherEMail\$VoucherID
$VoucherID
Definition: ezvoucheremail.php:329
eZVoucherEMail\setDescription
setDescription(&$value)
Definition: ezvoucheremail.php:251
eZVoucherEMail\setPreOrder
setPreOrder(&$value)
Definition: ezvoucheremail.php:281
eZVoucherEMail\email
email( $asObject=true)
Definition: ezvoucheremail.php:292
eZVoucherEMail\$Description
$Description
Definition: ezvoucheremail.php:326
eZVoucher
Definition: ezvoucher.php:54
$result
$result
Definition: companysearch.php:94
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
Password
</td ></tr >< tr >< td style="color:<?= isset( $error['password1'] ) ?> Password
Definition: step1.php:146
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.