Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezaddresstype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezaddresstype.php 6204 2001-07-19 12:06:56Z jakobn $
5 //
6 // Definition of eZAddressType class
7 //
8 // Created on: <26-Jun-2001 13:40:19 ce>
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
31
45 class eZAddressType
46 {
53 function __construct( $id = -1 )
54 {
55 if ( is_array( $id ) )
56 {
57 $this->fill( $id );
58 }
59 else if ( $id != -1 )
60 {
61 $this->ID = $id;
62 $this->get( $this->ID );
63 }
64 }
65
69 function store()
70 {
71 $db =& eZDB::globalDatabase();
72
73 $name = $db->escapeString( $this->Name );
74 $db->begin( );
75
76 if ( !isset( $this->ID ) )
77 {
78 $db->lock( "eZAddress_AddressType" );
79 $nextID = $db->nextID( "eZAddress_AddressType", "ID" );
80
81 $db->query_single( $qry, "SELECT ListOrder FROM eZAddress_AddressType ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
82 $listorder = $qry[$db->fieldName("ListOrder")] + 1;
83 $this->ListOrder = $listorder;
84
85 $result = $db->query( "INSERT INTO eZAddress_AddressType
86 ( ID, Name, ListOrder )
87 VALUES ( '$nextID',
88 '$name',
89 '$this->ListOrder') " );
90
91 $this->ID = $nextID;
92
93 }
94 else
95 {
96 $result = $db->query( "UPDATE eZAddress_AddressType set Name='$name', ListOrder='$this->ListOrder' WHERE ID='$this->ID'" );
97 }
98
99 $db->unlock();
100
101 if ( $result == false )
102 $db->rollback( );
103 else
104 $db->commit();
105
106 return $dbError;
107 }
108
109 /*
110 Deletes a eZAddressType object from the database.
111 */
112
113 function delete( $id = false )
114 {
115 $db =& eZDB::globalDatabase();
116 if ( !$id )
117 $id = $this->ID;
118
119 $db->begin( );
120 $res[] = $result = $db->query( "UPDATE eZAddress_AddressType SET Removed=1 WHERE ID='$id'" );
121 eZDB::finish( $res, $db );
122 }
123
124 /*
125 Fetches the eZAddressType object information from the database.
126
127 True is retuned if successful, false (0) if not.
128 */
129 function get( $id )
130 {
131 $db =& eZDB::globalDatabase();
132 if ( $id != "" )
133 {
134 $db->array_query( $address_type_array, "SELECT * FROM eZAddress_AddressType
135 WHERE ID='$id'",
136 0, 1 );
137 if ( count( $address_type_array ) == 1 )
138 {
139 $this->fill( $address_type_array[0] );
140 }
141 else
142 {
143 $this->ID = "";
144 }
145 }
146 }
147
151 function fill( &$address_type_array )
152 {
153 $db =& eZDB::globalDatabase();
154 $this->ID = $address_type_array[$db->fieldName("ID")];
155 $this->Name = $address_type_array[$db->fieldName("Name")];
156 $this->ListOrder = $address_type_array[$db->fieldName("ListOrder")];
157 }
158
159 /*
160 \static
161 Fetches the addresstype id from the database. And returns a array of eZAddressType objects.
162 */
163 static public function &getAll( $as_object = true )
164 {
165 $db =& eZDB::globalDatabase();
166 $online_type_array = 0;
167
168 $address_type_array = array();
169 $return_array = array();
170
171 if ( $as_object )
172 $select = "*";
173 else
174 $select = "ID";
175
176 $db->array_query( $address_type_array, "SELECT $select FROM eZAddress_AddressType
177 WHERE Removed=0
178 ORDER BY ListOrder" );
179
180 if ( $as_object )
181 {
182 foreach( $address_type_array as $addressTypeItem )
183 {
184 $return_array[] = new eZAddressType( $addressTypeItem );
185 }
186 }
187 else
188 {
189 foreach( $address_type_array as $addressTypeItem )
190 {
191 $return_array[] = $addressTypeItem[ $db->fieldName("ID")];
192 }
193 }
194
195 return $return_array;
196 }
197
201 function setName( $value )
202 {
203 $this->Name = $value;
204 }
205
209 function name( )
210 {
211 return $this->Name;
212 }
213
217 function id( )
218 {
219 return $this->ID;
220 }
221
226 function &count()
227 {
228 $db =& eZDB::globalDatabase();
229 $db->array_query( $qry, "SELECT COUNT( Ad.ID ) as Count
230 FROM eZAddress_Address AS Ad, eZAddress_AddressType AS AT
231 WHERE Ad.AddressTypeID = AT.ID AND AddressTypeID='$this->ID'" );
232 $cnt = 0;
233 if ( count( $qry ) > 0 )
234 $cnt += $qry[0][ $db->fieldName( "Count" ) ];
235 return $cnt;
236 }
237
242 function moveUp()
243 {
244
245 $db =& eZDB::globalDatabase();
246 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_AddressType
247 WHERE Removed=0 AND ListOrder<'$this->ListOrder' ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
248 $listorder = $qry[ $db->fieldName( "ListOrder" ) ];
249 $listid = $qry[ $db->fieldName( "ID" ) ];
250
251 $db->begin();
252 $res[] = $db->query( "UPDATE eZAddress_AddressType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
253 $res[] = $db->query( "UPDATE eZAddress_AddressType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
254 eZDB::finish( $res, $db );
255 }
256
261 function moveDown()
262 {
263 $db =& eZDB::globalDatabase();
264 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_AddressType
265 WHERE Removed=0 AND ListOrder>'$this->ListOrder' ORDER BY ListOrder ASC", array( "Limit" => "1" ) );
266 $listorder = $qry[$db->fieldName("ListOrder")];
267 $listid = $qry[$db->fieldName("ID")];
268
269 $db->begin();
270 $res[] = $db->query( "UPDATE eZAddress_AddressType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
271 $res[] = $db->query( "UPDATE eZAddress_AddressType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
272 eZDB::finish( $res, $db );
273 }
274
275 var $ID;
276 var $Name;
277 var $ListOrder;
278 }
279
280 ?>
eZAddressType
Definition: ezaddresstype.php:46
eZAddressType\store
store()
Definition: ezaddresstype.php:69
eZAddressType\$ID
$ID
Definition: ezaddresstype.php:275
eZAddressType\fill
fill(&$address_type_array)
Definition: ezaddresstype.php:151
eZAddressType\setName
setName( $value)
Definition: ezaddresstype.php:201
eZAddressType\__construct
__construct( $id=-1)
Definition: ezaddresstype.php:53
eZAddressType\$Name
$Name
Definition: ezaddresstype.php:276
eZAddressType\moveDown
moveDown()
Definition: ezaddresstype.php:261
eZAddressType\$ListOrder
$ListOrder
Definition: ezaddresstype.php:277
eZAddressType\id
id()
Definition: ezaddresstype.php:217
eZAddressType\getAll
static & getAll( $as_object=true)
Definition: ezaddresstype.php:163
eZAddressType\name
name()
Definition: ezaddresstype.php:209
eZAddressType\count
& count()
Definition: ezaddresstype.php:226
eZAddressType\moveUp
moveUp()
Definition: ezaddresstype.php:242
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$res
$res
Definition: ezstats/admin/cron.php:45
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+.