Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezappointmenttype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezappointmenttype.php 7443 2001-09-25 08:17:19Z jhe $
5 //
6 // Definition of eZAppointmentType class
7 //
8 // Created on: <08-Jan-2001 09:47:13 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
31
39 // include_once( "classes/ezdb.php" );
40
41 class eZAppointmentType
42 {
49 function __construct( $id = -1 )
50 {
51 $db =& eZDB::globalDatabase();
52
53 if ( $id != -1 )
54 {
55 $this->ID = $id;
56 $this->get( $this->ID );
57 }
58 }
59
63 function store()
64 {
65 $db =& eZDB::globalDatabase();
66 $db->begin();
67
68 if ( !isset( $this->ID ) )
69 {
70 $db->lock( "eZCalendar_AppointmentType" );
71 $this->ID = $db->nextID( "eZCalendar_AppointmentType", "ID" );
72 $queryText = "INSERT INTO eZCalendar_AppointmentType
73 (ID, Name, Description, ParentID)
74 VALUES
75 ('$this->ID', '$this->Name', '$this->Description', '$this->ParentID')";
76 // var_dump( $queryText );
77 $res[] = $db->query( $queryText );
78 $db->unlock();
79 }
80 else
81 {
82 $res[] = $db->query( "UPDATE eZCalendar_AppointmentType SET
83 Name='$this->Name',
84 Description='$this->Description',
85 ParentID='$this->ParentID' WHERE ID='$this->ID'" );
86 }
87 eZDB::finish( $res, $db );
88 return true;
89 }
90
95 function delete()
96 {
97 $db =& eZDB::globalDatabase();
98 $db->begin();
99 if ( isset( $this->ID ) )
100 {
101 $res[] = $db->query( "DELETE FROM eZCalendar_AppointmentType WHERE ID='$this->ID'" );
102 }
103 eZDB::finish( $res, $db );
104 return true;
105 }
106
110 function get( $id = -1 )
111 {
112 $db =& eZDB::globalDatabase();
113
114 if ( $id != "" )
115 {
116 $db->array_query( $AppointmentType_array, "SELECT * FROM eZCalendar_AppointmentType WHERE ID='$id'" );
117 if ( count( $AppointmentType_array ) > 1 )
118 {
119 die( "Error: AppointmentType's with the same ID was found in the database. This shouldent happen." );
120 }
121 else if ( count( $AppointmentType_array ) == 1 )
122 {
123 $this->ID = $AppointmentType_array[0][ $db->fieldName( "ID" ) ];
124 $this->Name = $AppointmentType_array[0][ $db->fieldName( "Name" ) ];
125 $this->Description = $AppointmentType_array[0][ $db->fieldName( "Description" ) ];
126 $this->ParentID = $AppointmentType_array[0][ $db->fieldName( "ParentID" ) ];
127 $this->ExcludeFromSearch = $AppointmentType_array[0][ $db->fieldName( "ExcludeFromSearch" ) ];
128 }
129 }
130 }
131
137 function &getAll()
138 {
139 $db =& eZDB::globalDatabase();
140
141 $return_array = array();
142 $AppointmentType_array = array();
143
144 $db->array_query( $AppointmentType_array, "SELECT ID FROM eZCalendar_AppointmentType ORDER BY Name" );
145
146 for ( $i = 0; $i < count( $AppointmentType_array ); $i++ )
147 {
148 $return_array[$i] = new eZAppointmentType( $AppointmentType_array[$i][ $db->fieldName( "ID" ) ], 0 );
149 }
150
151 return $return_array;
152 }
153
162 function &getByParent( $parent, $showAll=false, $sortby="name" )
163 {
164 if ( is_a( $parent, "eZAppointmentType" ) )
165 {
166 $db =& eZDB::globalDatabase();
167
168 $return_array = array();
169 $appointmenttype_array = array();
170
171 $parentID = $parent->id();
172
173 if ( $showAll == true )
174 {
175 $db->array_query( $appointmenttype_array, "SELECT ID, Name FROM eZCalendar_AppointmentType
176 WHERE ParentID='$parentID'
177 ORDER BY Name" );
178 }
179 else
180 {
181 $db->array_query( $appointmenttype_array, "SELECT ID, Name FROM eZCalendar_AppointmentType
182 WHERE ParentID='$parentID' AND ExcludeFromSearch='false'
183 ORDER BY Name" );
184 }
185
186 for ( $i = 0; $i < count( $appointmenttype_array ); $i++ )
187 {
188 $return_array[$i] = new eZAppointmentType( $appointmenttype_array[$i][ $db->fieldName( "ID" ) ], 0 );
189 }
190 return $return_array;
191 }
192 else
193 {
194 return 0;
195 }
196 }
197
205 function path( $AppointmentTypeID=0 )
206 {
207 if ( $AppointmentTypeID == 0 )
208 {
209 $AppointmentTypeID = $this->ID;
210 }
211
212 $AppointmentType = new eZAppointmentType( $AppointmentTypeID );
213
214 $path = array();
215
216 $parent = $AppointmentType->parent();
217
218 if ( $parent != 0 )
219 {
220 $path = array_merge( $path, $this->path( $parent->id() ) );
221 }
222 else
223 {
224 // array_push( $path, $AppointmentType->name() );
225 }
226
227 if ( $AppointmentTypeID != 0 )
228 array_push( $path, array( $AppointmentType->id(), $AppointmentType->name() ) );
229
230 return $path;
231 }
232
236 function &getTree( $parentID=0, $level=0 )
237 {
238 $AppointmentType = new eZAppointmentType( $parentID );
239
240 $AppointmentTypeList =& $AppointmentType->getByParent( $AppointmentType, true );
241
242 $tree = array();
243 $level++;
244 foreach ( $AppointmentTypeList as $AppointmentType )
245 {
246 array_push( $tree, array( $return_array[] = new eZAppointmentType( $AppointmentType->id() ), $level ) );
247
248 if ( $AppointmentType != 0 )
249 {
250 $tree = array_merge( $tree, $this->getTree( $AppointmentType->id(), $level ) );
251 }
252 }
253
254 return $tree;
255 }
256
260 function id()
261 {
262 return $this->ID;
263 }
264
268 function name( $htmlchars=true )
269 {
270 if ( $htmlchars == true )
271 {
272 return htmlspecialchars( $this->Name );
273 }
274 else
275 {
276 return $this->Name;
277 }
278 }
279
283 function description( $htmlchars=true )
284 {
285 if ( $htmlchars == true )
286 {
287 return htmlspecialchars( $this->Description );
288 }
289 else
290 {
291 return $this->Description;
292 }
293 }
294
298 function parentID()
299 {
300 return $this->ParentID;
301 }
302
306 function parent()
307 {
308 if ( $this->ParentID != 0 )
309 {
310 return new eZAppointmentType( $this->ParentID );
311 }
312 else
313 {
314 return 0;
315 }
316 }
317
321 function setName( $value )
322 {
323 $this->Name = $value;
324 }
325
329 function setDescription( $value )
330 {
331 $this->Description = $value;
332 }
333
337 function setParent( $value )
338 {
339 if ( is_a( $value, "eZAppointmentType" ) )
340 {
341 $this->ParentID = $value->id();
342 }
343 else if ( is_numeric( $value ) )
344 {
345 $this->ParentID = $value;
346 }
347 }
348
349 var $ID;
350 var $Name;
351 var $ParentID;
352 var $Description;
353 var $ExcludeFromSearch;
354
355 }
356
357 ?>
$i
$i
Definition: admin/adlist.php:91
$level
$level
Definition: admin/message.php:106
eZAppointmentType
Definition: ezappointmenttype.php:42
eZAppointmentType\setDescription
setDescription( $value)
Definition: ezappointmenttype.php:329
eZAppointmentType\name
name( $htmlchars=true)
Definition: ezappointmenttype.php:268
eZAppointmentType\store
store()
Definition: ezappointmenttype.php:63
eZAppointmentType\$Description
$Description
Definition: ezappointmenttype.php:352
eZAppointmentType\getAll
& getAll()
Definition: ezappointmenttype.php:137
eZAppointmentType\id
id()
Definition: ezappointmenttype.php:260
eZAppointmentType\$Name
$Name
Definition: ezappointmenttype.php:350
eZAppointmentType\setName
setName( $value)
Definition: ezappointmenttype.php:321
eZAppointmentType\path
path( $AppointmentTypeID=0)
Definition: ezappointmenttype.php:205
eZAppointmentType\parent
parent()
Definition: ezappointmenttype.php:306
eZAppointmentType\$ParentID
$ParentID
Definition: ezappointmenttype.php:351
eZAppointmentType\__construct
__construct( $id=-1)
Definition: ezappointmenttype.php:49
eZAppointmentType\getTree
& getTree( $parentID=0, $level=0)
Definition: ezappointmenttype.php:236
eZAppointmentType\$ExcludeFromSearch
$ExcludeFromSearch
Definition: ezappointmenttype.php:353
eZAppointmentType\parentID
parentID()
Definition: ezappointmenttype.php:298
eZAppointmentType\description
description( $htmlchars=true)
Definition: ezappointmenttype.php:283
eZAppointmentType\getByParent
& getByParent( $parent, $showAll=false, $sortby="name")
Definition: ezappointmenttype.php:162
eZAppointmentType\$ID
$ID
Definition: ezappointmenttype.php:349
eZAppointmentType\setParent
setParent( $value)
Definition: ezappointmenttype.php:337
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$id
$id
Definition: companytypelist.php:193
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
$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+.