Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezoption.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezoption.php 6849 2001-09-03 11:13:38Z ce $
5 //
6 // Definition of eZOption class
7 //
8 // Created on: <12-Sep-2000 15:01:53 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
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
29
32
78 // include_once( "classes/ezdb.php" );
79 // include_once( "eztrade/classes/ezoptionvalue.php" );
80
81 class eZOption
82 {
87 function __construct( $id=-1 )
88 {
89 if ( $id != -1 )
90 {
91 $this->ID = $id;
92 $this->get( $this->ID );
93 }
94 }
95
99 function store()
100 {
101 $db =& eZDB::globalDatabase();
102 $db->begin();
103
104 $this->Name = $db->escapeString( $this->Name );
105 $this->Description = $db->escapeString( $this->Description );
106
107 if ( !is_numeric( $this->ID ) )
108 {
109 $db->lock( "eZTrade_Option" );
110 $nextID = $db->nextID( "eZTrade_Option", "ID" );
111 $res[] = $db->query( "INSERT INTO eZTrade_Option
112 ( ID,
113 Name,
114 Description,
115 RemoteID )
116 VALUES
117 ( '$nextID',
118 '$this->Name',
119 '$this->Description',
120 '$this->RemoteID')" );
121 $db->unlock();
122 $this->ID = $nextID;
123
124 }
125 else
126 {
127 $res[] = $db->query( "UPDATE eZTrade_Option SET
128 Name='$this->Name',
129 Description='$this->Description', RemoteID='$this->RemoteID' WHERE ID='$this->ID'" );
130 }
131
132 eZDB::finish( $res, $db );
133 return true;
134 }
135
139 function get( $id=-1 )
140 {
141 $db =& eZDB::globalDatabase();
142
143 if ( $id != -1 )
144 {
145 $db->array_query( $option_array, "SELECT * FROM eZTrade_Option WHERE ID='$id'" );
146
147 if ( count( $option_array ) > 1 )
148 {
149 die( "Error: Option's with the same ID was found in the database. This shouldent happen." );
150 }
151 else if( count( $option_array ) == 1 )
152 {
153 $this->ID =& $option_array[0][$db->fieldName( "ID" )];
154 $this->Name =& $option_array[0][$db->fieldName( "Name" )];
155 $this->Description =& $option_array[0][$db->fieldName( "Description" )];
156 $this->RemoteID =& $option_array[0][$db->fieldName( "RemoteID" )];
157 }
158 }
159 }
160
164 function &getAll()
165 {
166 $db =& eZDB::globalDatabase();
167
168 $return_array = array();
169 $option_array = array();
170
171 $db->array_query( $option_array, "SELECT ID FROM eZTrade_Option ORDER BY Name" );
172
173 for ( $i=0; $i < count($option_array); $i++ )
174 {
175 $return_array[$i] = new eZOption( $option_array[$i][$db->fieldName( "ID" )], 0 );
176 }
177
178 return $return_array;
179 }
180
184 function delete()
185 {
186 $db =& eZDB::globalDatabase();
187 $option_array = array();
188 $db->begin();
189
190 $db->array_query( $option_array, "SELECT ID FROM eZTrade_OptionValue WHERE OptionID='$this->ID'" );
191
192 foreach( $option_array as $option_value )
193 {
194 $option_id = $option_value[$db->fieldName( "ID" )];
195 $res[] = $db->query( "DELETE FROM eZTrade_OptionValueContent WHERE ValueID='$option_id'" );
196 }
197 $res[] = $db->query( "DELETE FROM eZTrade_OptionValue WHERE OptionID='$this->ID'" );
198 $res[] = $db->query( "DELETE FROM eZTrade_ProductOptionLink WHERE OptionID='$this->ID'" );
199 $res[] = $db->query( "DELETE FROM eZTrade_Option WHERE ID='$this->ID'" );
200 $res[] = $db->query( "DELETE FROM eZTrade_ProductPriceLink WHERE OptionID='$this->ID'" );
201 $res[] = $db->query( "DELETE FROM eZTrade_OptionValueHeader WHERE OptionID='$this->ID'" );
202
203 $db->commit();
204 eZDB::finish( $res, $db );
205 }
206
210 function id()
211 {
212 return $this->ID;
213 }
214
218 function name()
219 {
220 return $this->Name;
221 }
222
226 function description()
227 {
228 return $this->Description;
229 }
230
234 function remoteID()
235 {
236 return $this->RemoteID;
237 }
238
244 function &values( )
245 {
246 $value = new eZOptionValue();
247 return $value->getByOption( $this );
248 }
249
253 function setName( $value )
254 {
255 $this->Name = $value;
256 }
257
261 function setDescription( $value )
262 {
263 $this->Description = $value;
264 }
265
269 function setRemoteID( $value )
270 {
271 $this->RemoteID = $value;
272 }
273
274
275 function &descriptionHeaders( $id = false )
276 {
277 $db =& eZDB::globalDatabase();
278 if ( !$id )
279 $id = $this->ID;
280 $db->array_query( $qry_array,
281 "SELECT Name FROM eZTrade_OptionValueHeader
282 WHERE OptionID='$id' ORDER BY Placement ASC" );
283 $ret = array();
284 foreach( $qry_array as $row )
285 {
286 $ret[] = $row[$db->fieldName( "Name" )];
287 }
288 return $ret;
289 }
290
291 function removeHeaders( $id = false )
292 {
293 $db =& eZDB::globalDatabase();
294 $db->begin();
295
296 if ( !$id )
297 $id = $this->ID;
298 $res[] = $db->query( "DELETE FROM eZTrade_OptionValueHeader WHERE OptionID='$id'" );
299
300 eZDB::finish( $res, $db );
301 }
302
303 function addHeader( $header, $id = false )
304 {
305 $db =& eZDB::globalDatabase();
306 $db->begin();
307
308
309 if ( !$id )
310 $id = $this->ID;
311 if ( !is_array( $header ) )
312 $header = array( $header );
313
314 $db->array_query( $qry_array, "SELECT Placement FROM eZTrade_OptionValueHeader
315 WHERE OptionID='$id' ORDER BY Placement DESC",
316 array( "Limit" => 1, "Offset" => 0 ) );
317
318 $placement = count( $qry_array ) == 0 ? 1 : $qry_array[0][$db->fieldName( "Placement" )] + 1;
319
320 $db->lock( "eZTrade_OptionValueHeader" );
321
322 foreach( $header as $header_val )
323 {
324 $header_val = $db->escapeString( $header_val );
325 $nextID = $db->nextID( "eZTrade_OptionValueHeader", "ID" );
326 $res[] = $db->query( "INSERT INTO eZTrade_OptionValueHeader
327 ( ID,
328 Name,
329 OptionID,
330 Placement )
331 VALUES
332 ( '$nextID',
333 '$header_val',
334 '$id',
335 '$placement' )" );
336 $placement++;
337 }
338 $db->unlock();
339 eZDB::finish( $res, $db );
340 }
341
345 function removeValues( $id = false )
346 {
347 if ( !$id )
348 $id = $this->ID;
349 $db =& eZDB::globalDatabase();
350 $db->array_query( $qry_array, "SELECT ID FROM eZTrade_OptionValue WHERE OptionID='$id'" );
351 foreach( $qry_array as $row )
352 {
353 $row_id = $row[$db->fieldName( "ID" )];
354 $optionValue = new eZOptionValue( $row_id );
355 $optionValue->delete( $row_id );
356 }
357 }
358
362 function removeValue( $id )
363 {
364 if ( is_a( $id, "eZOptionValue" ) )
365 $id = $id->id();
366 eZOptionValue::delete( $id );
367 }
368
374 function addValue( &$value )
375 {
376 if ( is_a( $value, "eZOptionValue" ) )
377 {
378 $value->setOptionID( $this->ID );
379 $value->store();
380 }
381 }
382
383 function getByRemoteID( $id )
384 {
385 $db =& eZDB::globalDatabase();
386
387 $value = false;
388
389 $db->array_query( $res, "SELECT ID FROM
390 eZTrade_Option
391 WHERE RemoteID='$id'" );
392 if ( count( $res ) == 1 )
393 {
394 $value = new eZOption( $res[0][$db->fieldName("ID")] );
395 }
396
397 return $value;
398 }
399
400 var $ID;
401 var $Name;
402 var $Description;
403 var $RemoteID;
404
405 }
406
407 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZOptionValue
Definition: ezoptionvalue.php:54
eZOptionValue\delete
delete( $id=false)
Definition: ezoptionvalue.php:363
eZOption
Definition: ezoption.php:82
eZOption\remoteID
remoteID()
Definition: ezoption.php:234
eZOption\id
id()
Definition: ezoption.php:210
eZOption\getAll
& getAll()
Definition: ezoption.php:164
eZOption\addValue
addValue(&$value)
Definition: ezoption.php:374
eZOption\$Description
$Description
Definition: ezoption.php:402
eZOption\__construct
__construct( $id=-1)
Definition: ezoption.php:87
eZOption\name
name()
Definition: ezoption.php:218
eZOption\store
store()
Definition: ezoption.php:99
eZOption\setRemoteID
setRemoteID( $value)
Definition: ezoption.php:269
eZOption\setDescription
setDescription( $value)
Definition: ezoption.php:261
eZOption\$ID
$ID
Definition: ezoption.php:400
eZOption\values
& values()
Definition: ezoption.php:244
eZOption\setName
setName( $value)
Definition: ezoption.php:253
eZOption\$Name
$Name
Definition: ezoption.php:401
eZOption\removeHeaders
removeHeaders( $id=false)
Definition: ezoption.php:291
eZOption\description
description()
Definition: ezoption.php:226
eZOption\getByRemoteID
getByRemoteID( $id)
Definition: ezoption.php:383
eZOption\$RemoteID
$RemoteID
Definition: ezoption.php:403
eZOption\addHeader
addHeader( $header, $id=false)
Definition: ezoption.php:303
eZOption\descriptionHeaders
& descriptionHeaders( $id=false)
Definition: ezoption.php:275
eZOption\removeValue
removeValue( $id)
Definition: ezoption.php:362
eZOption\removeValues
removeValues( $id=false)
Definition: ezoption.php:345
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$row
$row
Definition: ezcalendar/user/dayview.php:403
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$header
$header
Definition: paypalnotify.php:141
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.