Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezphonetype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezphonetype.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 eZPhoneType
46 {
47 /*
48 Constructs a new eZPhoneType object.
49
50 If $id is set the object's values are fetched from the
51 database.
52 */
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 $db->begin();
73 $name = $db->escapeString( $this->Name );
74 if ( !isset( $this->ID ) )
75 {
76 $db->query_single( $qry, "SELECT ListOrder FROM eZAddress_PhoneType ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
77 $listorder = $qry[ $db->fieldName( "ListOrder" ) ] + 1;
78 $this->ListOrder = $listorder;
79
80 $db->lock( "eZAddress_PhoneType" );
81 $nextID = $db->nextID( "eZAddress_PhoneType", "ID" );
82
83 $result = $db->query( "INSERT INTO eZAddress_PhoneType
84 ( ID, Name, ListOrder )
85 VALUES ( '$nextID',
86 '$name',
87 '$this->ListOrder') " );
88
89 $db->unlock();
90 $this->ID = $nextID;
91
92 }
93 else
94 {
95 $result = $db->query( "UPDATE eZAddress_PhoneType set Name='$name', ListOrder='$this->ListOrder' WHERE ID='$this->ID'" );
96 }
97
98
99 if ( $result == false )
100 $db->rollback( );
101 else
102 $db->commit();
103 }
104
105 /*
106 Deletes the eZPhoneType object for the database,
107 */
108 function delete( $id = false )
109 {
110 $db =& eZDB::globalDatabase();
111 if ( !$id )
112 $id = $this->ID;
113
114 $db->begin();
115 $result = $db->query( "UPDATE eZAddress_PhoneType SET Removed=1 WHERE ID='$id'" );
116
117 if ( $result != true )
118 $db->rollback( );
119 else
120 $db->commit();
121 }
122
123 /*
124 Fetches the eZPhoneType object information from the database.
125
126 True is retuned if successful, false (0) if not.
127 */
128 function get( $id )
129 {
130 $db =& eZDB::globalDatabase();
131 if ( $id != "" )
132 {
133 $db->array_query( $phone_type_array, "SELECT * FROM eZAddress_PhoneType WHERE ID='$id'",
134 0, 1 );
135 if ( count( $phone_type_array ) == 1 )
136 {
137 $this->fill( $phone_type_array[0] );
138 }
139 else
140 {
141 $this->ID = "";
142 }
143 }
144 }
145
149 function fill( &$phone_type_array )
150 {
151 $db =& eZDB::globalDatabase();
152 $this->ID = $phone_type_array[$db->fieldName("ID")];
153 $this->Name = $phone_type_array[$db->fieldName("Name")];
154 $this->ListOrder = $phone_type_array[$db->fieldName("ListOrder")];
155 }
156
157 /*
158 \static
159 Fetches the addresstype id from the database. And returns a array of eZAddressType objects.
160 */
161 static public function getAllCount()
162 {
163 $db =& eZDB::globalDatabase();
164 $db->query_single( $phone_type_array,
165 "SELECT Count( ID ) AS Count FROM eZAddress_PhoneType" );
166 return $phone_type_array[$db->fieldName("Count")];
167 }
168
169 /*
170 \static
171 Fetches the phonetype id from the database. And returns a array of eZPhoneType objects.
172 */
173 static public function getAll( $as_object = true, $offset = 0, $max = -1 )
174 {
175 $db =& eZDB::globalDatabase();
176
177 $phone_type_edit = array();
178 $limit = array();
179 $return_array = array();
180
181 if ( $max >= 0 && is_numeric( $offset ) && is_numeric( $max ) )
182 {
183 $limit = array( "Limit" => $max,
184 "Offset" => $offset );
185 }
186
187 if ( $as_object )
188 $select = "*";
189 else
190 $select = "ID";
191
192 $db->array_query( $phone_type_array,
193 "SELECT $select FROM eZAddress_PhoneType
194 WHERE Removed=0
195 ORDER BY ListOrder", $limit
196 );
197
198 if ( $as_object )
199 {
200 foreach( $phone_type_array as $phoneTypeItem )
201 {
202 $return_array[] = new eZPhoneType( $phoneTypeItem );
203 }
204 }
205 else
206 {
207 foreach( $phone_type_array as $phoneTypeItem )
208 {
209 $return_array[] = $phoneTypeItem[ $db->fieldName( "ID" ) ];
210 }
211 }
212 return $return_array;
213 }
214
218 function setName( $value )
219 {
220 $this->Name = $value;
221 }
222
226 function name( )
227 {
228 return $this->Name;
229 }
230
234 function id( )
235 {
236 return $this->ID;
237 }
238
242 function &count()
243 {
244 $db =& eZDB::globalDatabase();
245 $db->array_query( $qry, "SELECT COUNT( Ph.ID ) as Count
246 FROM eZAddress_Phone AS Ph, eZAddress_PhoneType AS PT
247 WHERE Ph.PhoneTypeID = PT.ID AND PhoneTypeID='$this->ID'" );
248 $cnt = 0;
249 if ( count( $qry ) > 0 )
250 $cnt += $qry[0][ $db->fieldName( "Count" ) ];
251 return $cnt;
252 }
253
257 function moveUp()
258 {
259 $db =& eZDB::globalDatabase();
260 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_PhoneType
261 WHERE Removed=0 AND ListOrder<'$this->ListOrder' ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
262 $listorder = $qry[$db->fieldName("ListOrder")];
263 $listid = $qry[$db->fieldName("ID")];
264
265 $db->begin();
266 $res[] = $db->query( "UPDATE eZAddress_PhoneType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
267 $res[] = $db->query( "UPDATE eZAddress_PhoneType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
268 eZDB::finish( $res, $db );
269 }
270
275 function moveDown()
276 {
277 $db =& eZDB::globalDatabase();
278 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_PhoneType
279 WHERE Removed=0 AND ListOrder>'$this->ListOrder' ORDER BY ListOrder ASC", array( "Limit" => "1" ) );
280 $listorder = $qry[$db->fieldName("ListOrder")];
281 $listid = $qry[$db->fieldName("ID")];
282
283 $db->begin();
284 $res[] = $db->query( "UPDATE eZAddress_PhoneType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
285 $res[] = $db->query( "UPDATE eZAddress_PhoneType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
286 eZDB::finish( $res, $db );
287 }
288
289 var $ID;
290 var $Name;
291 var $ListOrder;
292 }
293
294 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZPhoneType
Definition: ezphonetype.php:46
eZPhoneType\count
& count()
Definition: ezphonetype.php:242
eZPhoneType\getAll
static getAll( $as_object=true, $offset=0, $max=-1)
Definition: ezphonetype.php:173
eZPhoneType\moveDown
moveDown()
Definition: ezphonetype.php:275
eZPhoneType\getAllCount
static getAllCount()
Definition: ezphonetype.php:161
eZPhoneType\$ListOrder
$ListOrder
Definition: ezphonetype.php:291
eZPhoneType\name
name()
Definition: ezphonetype.php:226
eZPhoneType\$ID
$ID
Definition: ezphonetype.php:289
eZPhoneType\id
id()
Definition: ezphonetype.php:234
eZPhoneType\store
store()
Definition: ezphonetype.php:69
eZPhoneType\setName
setName( $value)
Definition: ezphonetype.php:218
eZPhoneType\fill
fill(&$phone_type_array)
Definition: ezphonetype.php:149
eZPhoneType\__construct
__construct( $id=-1)
Definition: ezphonetype.php:53
eZPhoneType\moveUp
moveUp()
Definition: ezphonetype.php:257
eZPhoneType\$Name
$Name
Definition: ezphonetype.php:290
$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
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
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+.