Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezappointment.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezappointment.php 7215 2001-09-14 12:21:35Z jhe $
5 //
6 // Definition of eZAppointment class
7 //
8 // Created on: <03-Jan-2001 16:05:37 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
38 // include_once( "classes/ezdb.php" );
39 // include_once( "classes/ezdatetime.php" );
40 // include_once( "classes/eztime.php" );
41
42 class eZAppointment
43 {
50 function __construct( $id = -1 )
51 {
52 $this->AllDay = 0;
53 $this->EMailNotice = 0;
54
55 if ( $id != -1 )
56 {
57 $this->ID = $id;
58 $this->get( $this->ID );
59 }
60 }
61
65 function store()
66 {
67 $db =& eZDB::globalDatabase();
68 $db->begin();
69
70 if ( !isset( $this->ID ) )
71 {
72 $db->lock( "eZCalendar_Appointment" );
73 $this->ID = $db->nextID( "eZCalendar_Appointment", "ID" );
74 $query = "INSERT INTO eZCalendar_Appointment
75 (ID,
76 UserID,
77 Name,
78 Description,
79 Date,
80 Duration,
81 EMailNotice,
82 IsPrivate,
83 Priority,
84 AppointmentTypeID,
85 AllDay)
86 VALUES
87 ('$this->ID',
88 '$this->UserID',
89 '$this->Name',
90 '$this->Description',
91 '$this->Date',
92 '$this->Duration',
93 '$this->EMailNotice',
94 '$this->IsPrivate',
95 '$this->Priority',
96 '$this->AppointmentTypeID',
97 '$this->AllDay')";
98 $res[] = $db->query( $query );
99 $db->unlock();
100 }
101 else
102 {
103 $res[] = $db->query( "UPDATE eZCalendar_Appointment SET
104 UserID='$this->UserID',
105 Name='$this->Name',
106 Description='$this->Description',
107 Date='$this->Date',
108 Duration='$this->Duration',
109 EMailNotice='$this->EMailNotice',
110 IsPrivate='$this->IsPrivate',
111 Priority='$this->Priority',
112 AppointmentTypeID='$this->AppointmentTypeID',
113 AllDay='$this->AllDay'
114 WHERE ID='$this->ID'" );
115 }
116 eZDB::finish( $res, $db );
117 return true;
118 }
119
124 function delete()
125 {
126 $db =& eZDB::globalDatabase();
127 $db->begin();
128
129 if ( isset( $this->ID ) )
130 {
131 $res[] = $db->query( "DELETE FROM eZCalendar_Appointment WHERE ID='$this->ID'" );
132 }
133 eZDB::finish( $res, $db );
134 return true;
135 }
136
140 function get( $id = -1 )
141 {
142 $db =& eZDB::globalDatabase();
143
144 if ( $id != "" )
145 {
146 $db->array_query( $appointment_array, "SELECT * FROM eZCalendar_Appointment WHERE ID='$id'" );
147 if ( count( $appointment_array ) > 1 )
148 {
149 die( "Error: Appointment's with the same ID was found in the database. This shouldent happen." );
150 }
151 else if ( count( $appointment_array ) == 1 )
152 {
153 $this->ID =& $appointment_array[0][$db->fieldName( "ID" )];
154 $this->Name =& $appointment_array[0][$db->fieldName( "Name" )];
155 $this->Description =& $appointment_array[0][$db->fieldName( "Description" )];
156 $this->AppointmentTypeID =& $appointment_array[0][$db->fieldName( "AppointmentTypeID" )];
157 $this->Date =& $appointment_array[0][$db->fieldName( "Date" )];
158 $this->Duration =& $appointment_array[0][$db->fieldName( "Duration" )];
159 $this->IsPrivate =& $appointment_array[0][$db->fieldName( "IsPrivate" )];
160 $this->UserID =& $appointment_array[0][$db->fieldName( "UserID" )];
161 $this->Priority =& $appointment_array[0][$db->fieldName( "Priority" )];
162 $this->AllDay =& $appointment_array[0][$db->fieldName( "AllDay" )];
163 }
164 }
165 }
166
172 function &getAll()
173 {
174 $db =& eZDB::globalDatabase();
175
176 $return_array = array();
177 $appointment_array = array();
178
179 $db->array_query( $appointment_array, "SELECT ID FROM eZCalendar_Appointment" );
180
181 for ( $i = 0; $i < count( $appointment_array ); $i++ )
182 {
183 $return_array[$i] = new eZAppointment( $appointment_array[$i][$db->fieldName( "ID" )], 0 );
184 }
185
186 return $return_array;
187 }
188
194 function &getAllByOthers()
195 {
196 $db =& eZDB::globalDatabase();
197
198 $return_array = array();
199 $appointment_array = array();
200
201 $db->array_query( $appointment_array,
202 "SELECT ID FROM eZCalendar_Appointment WHERE ID='$id' AND IsPrivate='0'" );
203
204 for ( $i = 0; $i < count( $appointment_array ); $i++ )
205 {
206 $return_array[$i] = new eZAppointment( $appointment_array[$i][$db->fieldName( "ID" )], 0 );
207 }
208
209 return $return_array;
210 }
211
212
218 function &getByDate( $date, $user, $showPrivate = false )
219 {
220 $ret = array();
221
222 if ( is_a( $date, "eZDate" ) && is_a( $user, "eZUser" ) )
223 {
224 $db =& eZDB::globalDatabase();
225 $userID = $user->ID();
226 $return_array = array();
227 $appointment_array = array();
228
229 $endDate = new eZDateTime();
230 $endDate->setTimeStamp( strtotime('+1 day', $date->timeStamp() ) );
231
232 if ( $showPrivate == true )
233 {
234 $query = "SELECT ID FROM eZCalendar_Appointment
235 WHERE Date>='" . $date->timeStamp() . "'
236 AND Date<'" . $endDate->timeStamp() . "'
237 AND IsPrivate='0' AND UserID='$userID' ORDER BY Date ASC";
238 $db->array_query( $appointment_array, $query, true );
239 }
240 else
241 {
242 $query = "SELECT ID FROM eZCalendar_Appointment
243 WHERE Date>='" . $date->timeStamp() . "'
244 AND Date<'" . $endDate->timeStamp() . "'
245 AND UserID='$userID' ORDER BY Date ASC";
246
247 $db->array_query( $appointment_array, $query );
248 }
249
250 for ( $i = 0; $i < count( $appointment_array ); $i++ )
251 {
252 $return_array[] = new eZAppointment( $appointment_array[$i][$db->fieldName( "ID" )], 0 );
253 }
254
255 $ret =& $return_array;
256 }
257
258 return $ret;
259 }
260
266 function &getByUser( $user, $showPrivate=false )
267 {
268 $ret = array();
269
270 if ( is_a( $user, "eZUser" ) )
271 {
272 $db =& eZDB::globalDatabase();
273
274 $return_array = array();
275 $appointment_array = array();
276
277 $userID = $user->id();
278
279 if ( $showPrivate == false )
280 {
281 $db->array_query( $appointment_array,
282 "SELECT ID FROM eZCalendar_Appointment
283 WHERE IsPrivate='0' AND UserID='$userID' ORDER BY Date ASC", true );
284 }
285 else
286 {
287 $db->array_query( $appointment_array,
288 "SELECT ID FROM eZCalendar_Appointment
289 WHERE UserID='$userID' ORDER BY Date ASC" );
290 }
291
292 for ( $i = 0; $i < count( $appointment_array ); $i++ )
293 {
294 $return_array[] = new eZAppointment( $appointment_array[$i][$db->fieldName( "ID" )], 0 );
295 }
296
297 $ret =& $return_array;
298 }
299 return $ret;
300 }
301
302
306 function id()
307 {
308 return $this->ID;
309 }
310
311
315 function name( $htmlchars=true )
316 {
317 if ( $htmlchars == true )
318 {
319 return htmlspecialchars( $this->Name );
320 }
321 else
322 {
323 return $this->Name;
324 }
325 }
326
330 function description( $htmlchars = true )
331 {
332 if ( $htmlchars == true )
333 {
334 return htmlspecialchars( $this->Description );
335 }
336 else
337 {
338 return $this->Description;
339 }
340 }
341
345 function dateTime()
346 {
347 $date = new eZDateTime();
348 $date->setTimeStamp( $this->Date );
349
350 return $date;
351 }
352
356 function duration()
357 {
358 return $this->Duration;
359 }
360
364 function &startTime()
365 {
366 $date = new eZDateTime();
367 $date->setTimeStamp( $this->Date );
368
369 $time = new eZTime();
370 $time->setHour( $date->hour() );
371 $time->setMinute( $date->minute() );
372 $time->setSecond( 0 );
373
374 return $time;
375 }
376
380 function &stopTime()
381 {
382 $date = new eZDateTime();
383 $date->setTimeStamp( $this->Date );
384
385 $start = $this->startTime();
386 $time = $start->add( $this->duration() );
387
388 return $time;
389 }
390
394 function allDay()
395 {
396 return $this->AllDay;
397 }
398
402 function setAllDay( $value )
403 {
404 if ( is_bool( $value ) && $value == true )
405 $value = 1;
406
407 if ( is_bool( $value ) && $value == false )
408 $value = 0;
409
410 $this->AllDay = $value;
411 }
412
416 function priority()
417 {
418 return $this->Priority;
419 }
420
424 function type()
425 {
426 $type = new eZAppointmentType( $this->AppointmentTypeID );
427 return $type;
428 }
429
433 function &isPrivate()
434 {
435 if ( $this->IsPrivate == 0 )
436 $ret = false;
437 else
438 $ret = true;
439
440 return $ret;
441 }
442
446 function setName( $value )
447 {
448 $this->Name = $value;
449 }
450
451
455 function setDescription( $value )
456 {
457 $this->Description = $value;
458 }
459
463 function setPriority( $value )
464 {
465 $this->Priority = $value;
466 }
467
472 function setDateTime( $dateTime )
473 {
474 if ( is_a( $dateTime, "eZDateTime" ) )
475 {
476 $this->Date = $dateTime->timeStamp();
477 }
478 else
479 {
480 echo "Error: The Parameter Passed is not of eZDateTime type!";
481 }
482 }
483
487 function setType( $type )
488 {
489 if ( is_a( $type, "eZAppointmentType" ) )
490 {
491 $this->AppointmentTypeID = $type->id();
492 }
493 }
494
498 function setOwner( $user )
499 {
500 if ( is_a( $user, "eZUser" ) )
501 {
502 $this->UserID = $user->id();
503 }
504 }
505
509 function userID()
510 {
511 return $this->UserID;
512 }
513
517 function setIsPrivate( $value )
518 {
519 if ( $value == true )
520 {
521 $this->IsPrivate = 1;
522 }
523 else
524 {
525 $this->IsPrivate = 0;
526 }
527 }
528
532 function setDuration( $time )
533 {
534 if ( is_numeric( $time ) )
535 {
536 $this->Duration = $time;
537 }
538 }
539
540 var $ID;
541 var $Name;
542 var $Description;
543 var $AllDay;
544 var $UserID;
545 var $Date;
546 var $Duration;
547 var $AppointmentTypeID;
548 var $EMailNotice;
549
551 var $IsPrivate;
552
554 var $Priority;
555 }
556
557 ?>
$i
$i
Definition: admin/adlist.php:91
$userID
else $userID
Definition: appointmentedit.php:121
$dateTime
$dateTime
Definition: authorview.php:77
$date
$date
Definition: bugpreview.php:66
eZAppointmentType
Definition: ezappointmenttype.php:42
eZAppointment
Definition: ezappointment.php:43
eZAppointment\getAllByOthers
& getAllByOthers()
Definition: ezappointment.php:194
eZAppointment\setType
setType( $type)
Definition: ezappointment.php:487
eZAppointment\setDateTime
setDateTime( $dateTime)
Definition: ezappointment.php:472
eZAppointment\getByDate
& getByDate( $date, $user, $showPrivate=false)
Definition: ezappointment.php:218
eZAppointment\$Description
$Description
Definition: ezappointment.php:542
eZAppointment\type
type()
Definition: ezappointment.php:424
eZAppointment\priority
priority()
Definition: ezappointment.php:416
eZAppointment\setName
setName( $value)
Definition: ezappointment.php:446
eZAppointment\setOwner
setOwner( $user)
Definition: ezappointment.php:498
eZAppointment\$ID
$ID
Definition: ezappointment.php:540
eZAppointment\startTime
& startTime()
Definition: ezappointment.php:364
eZAppointment\stopTime
& stopTime()
Definition: ezappointment.php:380
eZAppointment\$IsPrivate
$IsPrivate
boolean stored as an int
Definition: ezappointment.php:551
eZAppointment\setIsPrivate
setIsPrivate( $value)
Definition: ezappointment.php:517
eZAppointment\id
id()
Definition: ezappointment.php:306
eZAppointment\$Date
$Date
Definition: ezappointment.php:545
eZAppointment\$EMailNotice
$EMailNotice
Definition: ezappointment.php:548
eZAppointment\getByUser
& getByUser( $user, $showPrivate=false)
Definition: ezappointment.php:266
eZAppointment\setAllDay
setAllDay( $value)
Definition: ezappointment.php:402
eZAppointment\setDescription
setDescription( $value)
Definition: ezappointment.php:455
eZAppointment\$Name
$Name
Definition: ezappointment.php:541
eZAppointment\isPrivate
& isPrivate()
Definition: ezappointment.php:433
eZAppointment\$Priority
$Priority
The priority of the appointment, values can be 0, 1, 2 where 1 is normal.
Definition: ezappointment.php:554
eZAppointment\$Duration
$Duration
Definition: ezappointment.php:546
eZAppointment\setDuration
setDuration( $time)
Definition: ezappointment.php:532
eZAppointment\setPriority
setPriority( $value)
Definition: ezappointment.php:463
eZAppointment\store
store()
Definition: ezappointment.php:65
eZAppointment\$UserID
$UserID
Definition: ezappointment.php:544
eZAppointment\description
description( $htmlchars=true)
Definition: ezappointment.php:330
eZAppointment\dateTime
dateTime()
Definition: ezappointment.php:345
eZAppointment\userID
userID()
Definition: ezappointment.php:509
eZAppointment\getAll
& getAll()
Definition: ezappointment.php:172
eZAppointment\$AppointmentTypeID
$AppointmentTypeID
Definition: ezappointment.php:547
eZAppointment\$AllDay
$AllDay
Definition: ezappointment.php:543
eZAppointment\__construct
__construct( $id=-1)
Definition: ezappointment.php:50
eZAppointment\name
name( $htmlchars=true)
Definition: ezappointment.php:315
eZAppointment\duration
duration()
Definition: ezappointment.php:356
eZAppointment\allDay
allDay()
Definition: ezappointment.php:394
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZTime
Definition: eztime.php:38
$type
$type
Definition: classes/admin/linkselect.php:220
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$showPrivate
$showPrivate
Definition: eventview.php:106
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$time
$time
Definition: homepage.php:327
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
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.