Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

appointmentedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: appointmentedit.php 7511 2001-09-27 11:07:25Z jhe $
5 //
6 // Created on: <03-Jan-2001 12:47:22 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26 // include_once( "classes/ezhttptool.php" );
27
28 if ( isset( $DeleteAppointments ) )
29 {
30 $Action = "DeleteAppointment";
31 }
32
33 if ( isset( $GoDay ) )
34 {
35 // include_once( "classes/ezdate.php" );
36
37 $session =& eZSession::globalSession();
38 $session->fetch();
39
40 $year = $session->variable( "Year" );
41 $month = $session->variable( "Month" );
42 $day = $session->variable( "Day" );
43
44 $date = new eZDate( $year, $month, $day );
45 if ( $date->daysInMonth() < $day )
46 $day = $date->daysInMonth();
47
48 eZHTTPTool::header( "Location: /calendar/dayview/$year/$month/$day" );
49 exit();
50 }
51 else if ( isset( $GoMonth ) )
52 {
53 $session =& eZSession::globalSession();
54 $session->fetch();
55
56 $year = $session->variable( "Year" );
57 $month = $session->variable( "Month" );
58
59 eZHTTPTool::header( "Location: /calendar/monthview/$year/$month" );
60 exit();
61 }
62 else if ( isset( $GoYear ) )
63 {
64 $session =& eZSession::globalSession();
65 $session->fetch();
66
67 $year = $session->variable( "Year" );
68
69 eZHTTPTool::header( "Location: /calendar/yearview/$year" );
70 exit();
71 }
72 else if ( isset( $GoToday ) )
73 {
74 $today = new eZDate();
75
76 $year = addZero( $today->year() );
77 $month = addZero( $today->month() );
78 $day = addZero( $today->day() );
79
80 eZHTTPTool::header( "Location: /calendar/dayview/$year/$month/$day" );
81 exit();
82 }
83
84 // include_once( "classes/INIFile.php" );
85 // include_once( "classes/eztemplate.php" );
86 // include_once( "classes/ezlog.php" );
87 // include_once( "classes/ezlocale.php" );
88 // include_once( "classes/ezdatetime.php" );
89 // include_once( "classes/ezdate.php" );
90 // include_once( "classes/eztime.php" );
91
92 // include_once( "ezcalendar/classes/ezappointment.php" );
93 // include_once( "ezcalendar/classes/ezappointmenttype.php" );
94
95 $ini =& eZINI::instance( 'site.ini' );
96
97 $Language = $ini->variable( "eZCalendarMain", "Language" );
98 $StartTimeStr = $ini->variable( "eZCalendarMain", "DayStartTime" );
99 $StopTimeStr = $ini->variable( "eZCalendarMain", "DayStopTime" );
100
101 $Locale = new eZLocale( $Language );
102
103 $TitleError = false;
104 $StartTimeError = false;
105 $StopTimeError = false;
106 $DateError = false;
107
108 if ( isset( $TrusteeUser ) )
109 {
110 $trusteelist = array();
111 foreach ( $TrusteeUser as $trusted )
112 {
113 $trusteelist[] = new eZUser( $trusted );
114 }
115 }
116
117 $user =& eZUser::currentUser();
118 if ( $user == false )
119 $userID = false;
120 else
121 $userID = $user->id();
122
123 if ( $userID == false )
124 $app = false;
125 elseif ( $Action == "New" || $Action == "Insert" )
126 $app = new eZAppointment();
127 else
128 $app = new eZAppointment( $AppointmentID );
129
130 if ( isset( $TrusteeUser ) && count( $TrusteeUser ) > 0 )
131 $session->setVariable( "ShowOtherCalendarUsers", $TrusteeUser[0] );
132
133 $t = new eZTemplate( "kernel/ezcalendar/user/" . $ini->variable( "eZCalendarMain", "TemplateDir" ),
134 "kernel/ezcalendar/user/intl/", $Language, "appointmentedit.php" );
135
136 $t->set_file( "appointment_edit_tpl", "appointmentedit.tpl" );
137
138 $t->setAllStrings();
139
140 $t->set_block( "appointment_edit_tpl", "user_error_tpl", "user_error" );
141 $t->set_block( "user_error_tpl", "no_user_error_tpl", "no_user_error" );
142 $t->set_block( "user_error_tpl", "wrong_user_error_tpl", "wrong_user_error" );
143
144 $t->set_block( "appointment_edit_tpl", "multiple_view_tpl", "multiple_view" );
145 $t->set_block( "appointment_edit_tpl", "no_error_tpl", "no_error" );
146 $t->set_block( "no_error_tpl", "title_error_tpl", "title_error" );
147 $t->set_block( "no_error_tpl", "start_time_error_tpl", "start_time_error" );
148 $t->set_block( "no_error_tpl", "stop_time_error_tpl", "stop_time_error" );
149 $t->set_block( "no_error_tpl", "date_error_tpl", "date_error" );
150 $t->set_block( "no_error_tpl", "trustee_user_name_tpl", "trustee_user_name" );
151 $t->set_block( "no_error_tpl", "value_tpl", "value" );
152 $t->set_block( "no_error_tpl", "month_tpl", "month" );
153 $t->set_block( "no_error_tpl", "day_tpl", "day" );
154
155 if ( isset( $ChangeView ) || isset( $ViewType ) && $ViewType == "multiple" )
156 {
157 //$typeID = $TypeID;
158 $t->set_var( "select_multiple", "multiple" );
159 $t->set_var( "multiple_view", "" );
160 $t->set_var( "view_type", "multiple" );
161 }
162 else
163 {
164 //$typeID = $TypeID;
165 $t->set_var( "select_multiple", "" );
166 if ( is_a( $user, "eZUser" ) && count( $user->trustees() ) > 0 )
167 $t->parse( "multiple_view", "multiple_view_tpl" );
168 else
169 $t->set_var( "multiple_view", "" );
170 $t->set_var( "view_type", "single" );
171 }
172
173 // no user logged on
174 if ( !is_a( $app, "eZAppointment" ) )
175 {
176 $t->set_var( "no_error", "" );
177 $t->set_var( "wrong_user_error", "" );
178 $t->parse( "no_user_error", "no_user_error_tpl" );
179 $t->parse( "user_error", "user_error_tpl" );
180 $t->pparse( "output", "appointment_edit_tpl" );
181 $UserError = true;
182 }
183
184 if ( $Action == "Edit" && $app != false )
185 {
186 $trusteesAlt = new eZUser();
187 $trusteesAlt = $trusteesAlt->trustees( $app->userID() );
188 }
189
190 // only the appointment owner or a trustee is allowed to edit or delete an appointment
191 if ( $Action == "Edit" && $app != false &&
192 ( !in_array( $userID, $trusteesAlt ) &&
193 $app->userID() != $userID ) )
194 {
195 $t->set_var( "no_error", "" );
196 $t->set_var( "no_user_error", "" );
197
198 $t->parse( "wrong_user_error", "wrong_user_error_tpl" );
199 $t->parse( "user_error", "user_error_tpl" );
200 $t->pparse( "output", "appointment_edit_tpl" );
201
202 $UserError = true;
203 }
204
205 if ( $Action == "DeleteAppointment" )
206 {
207 if ( count( $AppointmentArrayID ) != 0 )
208 {
209 foreach ( $AppointmentArrayID as $ID )
210 {
211 $appointment = new eZAppointment( $ID );
212 $appUser = new eZUser( $appointment->userID() );
213 if ( ( $appUser->ID() == $userID ) ||
214 in_array( $userID, $appUser->getByTrustee() ) )
215 {
216 $datetime = $appointment->dateTime();
217 $appointment->delete();
218
219 $year = addZero( $datetime->year() );
220 $month = addZero( $datetime->month() );
221 $day = addZero( $datetime->day() );
222 deleteCache( "default", $Language, $year, $month, $day, $appointment->userID() );
223 }
224 else
225 {
226 $t->set_var( "no_error", "" );
227 $t->set_var( "no_user_error", "" );
228
229 $t->parse( "wrong_user_error", "wrong_user_error_tpl" );
230 $t->parse( "user_error", "user_error_tpl" );
231 $t->pparse( "output", "appointment_edit_tpl" );
232
233 $UserError = true;
234 }
235 }
236 }
237
238 eZHTTPTool::header( "Location: /calendar/dayview/$year/$month/$day/" );
239 exit();
240 }
241
242 // Allowed format for start and stop time:
243 // 14 14:30 14:0 1430
244 // the : can be replaced with any non number character
245 if ( $Action == "Insert" || $Action == "Update" )
246 {
247 if ( isset( $Cancel ) )
248 {
249 if ( is_numeric( $AppointmentID ) )
250 {
251 $app = new eZAppointment( $AppointmentID );
252 $dt = $app->dateTime();
253 $Year = $dt->year();
254 $Month = $dt->month();
255 $Day = $dt->day();
256 }
257
258 eZHTTPTool::header( "Location: /calendar/dayview/$Year/$Month/$Day" );
259 exit();
260 }
261
262 $datetime = new eZDateTime( $Year, $Month, 1 );
263 if ( $datetime->daysInMonth() < $Day )
264 {
265 $DateError = true;
266 }
267 $datetime->setDay( $Day );
268 if ( !is_numeric( $Year ) )
269 {
270 $DateError = true;
271 }
272
273 if ( !isset( $trusteelist ) )
274 {
275 $trusteelist = array();
276 foreach ( $TrusteeUser as $trusted )
277 {
278 $trusteelist[] = new eZUser( $trusted );
279 }
280 }
281 if ( !isset( $user ) )
282 $user =& eZUser::currentUser();
283
284 foreach ( $trusteelist as $trusteduser )
285 {
286 if ( $user->ID() == $trusteduser->ID() ||
287 in_array( $user->ID(), $trusteduser->getByTrustee() ) )
288 {
289 $type = new eZAppointmentType( $TypeID );
290
291 if ( $Action == "Update" )
292 {
293 $appointment = new eZAppointment( $AppointmentID );
294 $beginDate = $appointment->dateTime();
295 }
296 else
297 {
298 $appointment = new eZAppointment();
299 $beginDate = false;
300 }
301
302 $appointment->setDescription( $Description );
303 $appointment->setType( $type );
304 $appointment->setOwner( $trusteduser );
305 $appointment->setPriority( $Priority );
306
307 if ( isset( $IsPrivate ) && $IsPrivate == "on" )
308 $appointment->setIsPrivate( true );
309 else
310 $appointment->setIsPrivate( false );
311
312 if ( isset( $Name ) && $Name != "" )
313 $appointment->setName( $Name );
314 else
315 $TitleError = true;
316
317 // start/stop time for the day
318 $dayStartTime = new eZDateTime( $Year, $Month, $Day );
319 $dayStopTime = new eZDateTime( $Year, $Month, $Day );
320
321 if ( preg_match( "#(^([0-9]{1,2})[^0-9]{0,1}([0-9]{0,2})$)#", $StartTimeStr, $dayStartArray ) )
322 {
323 $hour = $dayStartArray[2];
324 $dayStartTime->setHour( $hour );
325
326 $min = $dayStartArray[3];
327 $dayStartTime->setMinute( $min );
328
329 $dayStartTime->setSecond( 0 );
330 }
331
332 if ( preg_match( "#(^([0-9]{1,2})[^0-9]{0,1}([0-9]{0,2})$)#", $StopTimeStr, $dayStopArray ) )
333 {
334 $hour = $dayStopArray[2];
335 $dayStopTime->setHour( $hour );
336
337 $min = $dayStopArray[3];
338 $dayStopTime->setMinute( $min );
339
340 $dayStopTime->setSecond( 0 );
341 }
342
343 // start/stop time for the appointment
344 $startTimestamp = strtotime( $Start );
345 $stopTimestamp = strtotime( $Stop );
346
347 $startTime = new eZDateTime( $Year, $Month, $Day, date('H', $startTimestamp), date('i', $startTimestamp) );
348 $stopTime = new eZDateTime( $Year, $Month, $Day, date('H', $stopTimestamp), date('i', $stopTimestamp) );
349
350 $startTime->setSecond( 0 );
351 $stopTime->setSecond( 0 );
352
353 if ( preg_match( "#(^([0-9]{1,2})[^0-9]{0,1}([0-9]{0,2})$)#", $Start, $startArray ) ) {
354 $hour = $startArray[2];
355 settype($hour, "integer");
356 $startTime->setHour($hour);
357 $min = $startArray[3];
358 settype($min, "integer");
359
360 $startTime->setMinute($min);
361 if (isset($AllDay) && $AllDay == "on") {
362 $appointment->setAllDay(true);
363 } else {
364 $appointment->setAllDay(false);
365 }
366 }
367 else
368 {
369 $StartTimeError = true;
370 }
371
372 // if ( isset( $AllDay ) && $AllDay == "on" )
373 // {
374 // $appointment->setAllDay( true );
375 // }
376 // else
377 if ( !preg_match( "#(^([0-9]{1,2})[^0-9]{0,1}([0-9]{0,2})$)#", $Stop, $stopArray ) )
378 {
379 $StopTimeError = true;
380 }
381
382 $datetime->setSecondsElapsedHMS( $startTime->hour(), $startTime->minute(), 0 );
383
384 $appointment->setDateTime( $datetime );
385 //$datetime = new eZDateTime( $Year, $Month, $Day, $startTime->hour(), $startTime->minute() );
386 // echo "<hr>";
387 // echo $startTime->hour();
388 // echo "<hr>";
389 // echo $datetime->day();
390 // echo "<hr>";
391 // $appointment->setDateTime( $datetime );
392 // echo "<hr>";
393 // echo $datetime->Time->hour() ;
394 // echo "<hr>";
395 // echo $appointment->Date;
396
397
398 if ( $stopTime->isGreater( $startTime, true ) && $AllDay != "on" )
399 {
400 $StopTimeError = true;
401 }
402 else
403 {
404 // $duration = new eZDateTime();
405 // $duration->setTimeStamp( $stopTime->timeStamp() - $startTime->timeStamp() );
406 // $duration->setTimeStamp( $stopTime->timestamp() );
407 // $appointment->setDuration( $AllDay == "on" ? 0 : $duration->timeStamp() );
408
409 $appointment->setDuration( isset( $AllDay ) && $AllDay == "on" ? 0 : $stopTimestamp - $startTimestamp );
410 }
411
412 if ( isset( $TitleError ) && $TitleError == false && isset( $StartTimeError ) && $StartTimeError == false &&
413 isset( $StopTimeError ) && $StopTimeError == false && isset( $DateError ) && $DateError == false )
414 {
415 $appointment->store();
416 // die('Stored! All is saved but, simply not always as expected.');
417
418 $year = addZero( $datetime->year() );
419 $month = addZero( $datetime->month() );
420 $day = addZero( $datetime->day() );
421 deleteCache( "default", $Language, $year, $month, $day, $trusteduser->id() );
422 if ( $beginDate )
423 {
424 deleteCache( "default", $Language, addZero( $beginDate->year() ),
425 addZero( $beginDate->month() ),
426 addZero( $beginDate->day() ), $trusteduser->id() );
427 }
428 }
429 else
430 {
431 break;
432 }
433 }
434 }
435
436 if ( $TitleError == false && $StartTimeError == false &&
437 $StopTimeError == false && $DateError == false )
438 {
439 eZHTTPTool::header( "Location: /calendar/dayview/$year/$month/$day/" );
440 exit();
441 }
442 else
443 {
444 $user =& eZUser::currentUser();
445 $userID = $user->ID();
446 $t->set_var( "name_value", $appointment->name() );
447 $t->set_var( "description_value", $appointment->description() );
448
449 if ( $appointment->isPrivate() )
450 $t->set_var( "is_private", "checked" );
451 else
452 $t->set_var( "is_private", "" );
453
454 $appStartTime =& $appointment->startTime();
455 $appStopTime =& $appointment->stopTime();
456
457
458 if ( $appStartTime )
459 {
460 $t->set_var( "start_value", addZero( $appStartTime->hour() ) . addZero( $appStartTime->minute() ) );
461 }
462 else
463 {
464 $t->set_var( "start_value", "" );
465 }
466
467 if ( $appStartTime && !$appointment->allDay() )
468 {
469 $t->set_var( "all_day_selected", "" );
470 }
471 else
472 {
473 //$t->set_var( "start_value", "" );
474 $t->set_var( "all_day_selected", "checked" );
475 }
476
477 if ( $appStopTime )
478 $t->set_var( "stop_value", addZero( $appStopTime->hour() ) . addZero( $appStopTime->minute() ) );
479 else
480 $t->set_var( "stop_value", "" );
481
482 if ( in_array( $userID, $TrusteeUser ) )
483 $t->set_var( "own_selected", "selected" );
484 else
485 $t->set_var( "own_selected", "" );
486
487 $t->set_var( "own_user_id", $userID );
488 $t->set_var( "own_user_name", $user->name() );
489 $t->set_var( "trustee_user_name", "" );
490 $t->set_var( "action_value", $Action );
491 $t->set_var( "appointment_id", $AppointmentID );
492
493 $trusteeArray = $user->getByTrustee( -1, true );
494 foreach ( $trusteeArray as $trustee )
495 {
496 $t->set_var( "user_id", $trustee->ID() );
497 $t->set_var( "user_name", $trustee->name() );
498
499 if ( in_array( $trustee->id(), $TrusteeUser ) )
500 $t->set_var( "selected", "selected" );
501 else
502 $t->set_var( "selected", "" );
503 $t->parse( "trustee_user_name", "trustee_user_name_tpl", true );
504 }
505 }
506 }
507
508 $t->set_var( "user_error", "" );
509
510 if ( $Action == "Edit" )
511 {
512 $t->set_var( "0_selected", "" );
513 $t->set_var( "1_selected", "" );
514 $t->set_var( "2_selected", "" );
515
516 if ( isset( $Priority ) && $Priority == 0 )
517 $t->set_var( "0_selected", "selected" );
518 else if ( isset( $Priority ) && $Priority == 1 )
519 $t->set_var( "1_selected", "selected" );
520 else if ( isset( $Priority ) && $Priority == 2 )
521 $t->set_var( "2_selected", "selected" );
522
523 if ( isset( $IsPrivate ) && $IsPrivate == "on" )
524 $t->set_var( "is_private", "checked" );
525 else
526 $t->set_var( "is_private", "" );
527
528 $t->set_var( "action_value", $Action );
529 $t->set_var( "appointment_id", $AppointmentID );
530
531 if ( $app != false && $userID == $app->userID() )
532 $t->set_var( "own_selected", "selected" );
533 else
534 $t->set_var( "own_selected", "" );
535
536 $t->set_var( "own_user_id", $userID );
537 if( $user != false )
538 $t->set_var( "own_user_name", $user->name() );
539 $t->set_var( "user_name", "" );
540
541 if( $user != false )
542 {
543 $trusteeArray = $user->getByTrustee( -1, true );
544 foreach ( $trusteeArray as $trustee )
545 {
546 $t->set_var( "user_id", $trustee->ID() );
547 $t->set_var( "user_name", $trustee->name() );
548
549 if ( $app->userID() == $trustee->ID() )
550 $t->set_var( "selected", "selected" );
551 else
552 $t->set_var( "selected", "" );
553 $t->parse( "trustee_user_name", "trustee_user_name_tpl", true );
554 }
555 }
556 }
557
558 if ( $Action == "Edit" )
559 {
560 $appointment = new eZAppointment( $AppointmentID );
561 $t->set_var( "name_value", $appointment->name() );
562 $t->set_var( "appointment_id", $appointment->id() );
563 $t->set_var( "description_value", $appointment->description() );
564
565 $type = $appointment->type();
566 $typeID = $type->id();
567 $startTime =& $appointment->startTime();
568 $startHour = addZero( $startTime->hour() );
569 $startMinute = addZero( $startTime->minute() );
570
571 $stopTime =& $appointment->stopTime();
572 $stopHour = addZero( $stopTime->hour() );
573 $stopMinute = addZero( $stopTime->minute() );
574
575 if ( $appointment->allDay() )
576 {
577 $t->set_var( "start_value", $startHour . $startMinute );
578 $t->set_var( "stop_value", $stopHour . $stopMinute );
579 $t->set_var( "all_day_selected", "checked" );
580 }
581 else
582 {
583 $t->set_var( "all_day_selected", "" );
584 $t->set_var( "start_value", $startHour . $startMinute );
585 $t->set_var( "stop_value", $stopHour . $stopMinute );
586 }
587
588 $t->set_var( "0_selected", "" );
589 $t->set_var( "1_selected", "" );
590 $t->set_var( "2_selected", "" );
591
592 if ( $appointment->priority() == 0 )
593 $t->set_var( "0_selected", "selected" );
594 else if ( $appointment->priority() == 1 )
595 $t->set_var( "1_selected", "selected" );
596 else if ( $appointment->priority() == 2 )
597 $t->set_var( "2_selected", "selected" );
598
599 $dt =& $appointment->dateTime();
600
601 $t->set_var( "year_value", $dt->year() );
602
603 if ( $appointment->isPrivate() )
604 $t->set_var( "is_private", "checked" );
605 else
606 $t->set_var( "is_private", "" );
607
608 $t->set_var( "action_value", "update" );
609 }
610
611
612 // print out error messages
613 if ( isset( $TitleError ) && $TitleError == true )
614 $t->parse( "title_error", "title_error_tpl" );
615 else
616 $t->set_var( "title_error", "" );
617
618 if ( isset( $StartTimeError ) && $StartTimeError )
619 {
620 $t->parse( "start_time_error", "start_time_error_tpl" );
621 $t->set_var( "action_value", "insert" );
622 $t->set_var( "appointment_id", "new" );
623 }
624 else
625 {
626 $t->set_var( "start_time_error", "" );
627 }
628
629 if ( isset( $StopTimeError ) && $StopTimeError )
630 {
631 $t->parse( "stop_time_error", "stop_time_error_tpl" );
632 $t->set_var( "action_value", "insert" );
633 $t->set_var( "appointment_id", "new" );
634 }
635 else
636 {
637 $t->set_var( "stop_time_error", "" );
638 }
639
640 if ( isset( $DateError ) && $DateError )
641 {
642 $t->parse( "date_error", "date_error_tpl" );
643 $t->set_var( "action_value", "insert" );
644 $t->set_var( "appointment_id", "new" );
645 }
646 else
647 {
648 $t->set_var( "date_error", "" );
649 }
650
651 $today = new eZDate();
652 if ( isset( $Year ) && $Year != 0 )
653 $year = $Year;
654 else
655 $year = $today->year();
656
657 if ( isset( $Month ) && $Month != 0 )
658 $month = $Month;
659 else
660 $month = $today->month();
661
662 if ( isset( $day ) && $Day != 0 )
663 $day = $Day;
664 else
665 $day = $today->day();
666
667 $tmpdate = new eZDate( $year, $month, $day );
668 // $tmpdate = new eZDate( $Year, $Month, $Day );
669
670 if ( $Action == "New" )
671 {
672 $t->set_var( "action_value", "insert" );
673 $t->set_var( "appointment_id", "new" );
674
675
676 if ( isset( $ChangeView ) )
677 {
678 $t->set_var( "name_value", $Name );
679 $t->set_var( "description_value", $Description );
680 $t->set_var( "is_private", $IsPrivate == "on" ? "checked" : "" );
681 $t->set_var( "all_day_selected", $AllDay == "on" ? "checked" : "" );
682 $t->set_var( "start_value", $Start );
683 $t->set_var( "stop_value", $Stop );
684
685 $t->set_var( "0_selected", "" );
686 $t->set_var( "1_selected", "" );
687 $t->set_var( "2_selected", "" );
688 if ( $Priority == 0 )
689 $t->set_var( "0_selected", "selected" );
690 if ( $Priority == 1 )
691 $t->set_var( "1_selected", "selected" );
692 if ( $Priority == 2 )
693 $t->set_var( "2_selected", "selected" );
694
695 $tmpdate = new eZDate( $Year, $Month, $Day );
696
697 $t->set_var( "own_user_id", $userID );
698 $t->set_var( "own_user_name", $user->name() );
699 if ( in_array( $userID, $TrusteeUser ) )
700 $t->set_var( "own_selected", "selected" );
701 else
702 $t->set_var( "own_selected", "" );
703 $t->set_var( "user_name", "" );
704
705 $trusteeArray = $user->getByTrustee( -1, true );
706
707 foreach ( $trusteeArray as $trustee )
708 {
709 $t->set_var( "user_id", $trustee->ID() );
710 $t->set_var( "user_name", $trustee->name() );
711 if ( in_array( $trustee->ID(), $TrusteeUser ) )
712 $t->set_var( "selected", "selected" );
713 else
714 $t->set_var( "selected", "" );
715 $t->parse( "trustee_user_name", "trustee_user_name_tpl", true );
716 }
717 }
718 else
719 {
720 $t->set_var( "name_value", "" );
721 $t->set_var( "description_value", "" );
722 $t->set_var( "is_private", "" );
723 $t->set_var( "start_value", "" );
724 $t->set_var( "stop_value", "" );
725 $t->set_var( "all_day_selected", "" );
726
727 $t->set_var( "0_selected", "" );
728 $t->set_var( "1_selected", "" );
729 $t->set_var( "2_selected", "" );
730
731 if ( $Year != 0 )
732 $year = $Year;
733 else
734 $year = $today->year();
735
736 if ( $Month != 0 )
737 $month = $Month;
738 else
739 $month = $today->month();
740
741 if ( $Day != 0 )
742 $day = $Day;
743 else
744 $day = $today->day();
745
746 $tmpdate = new eZDate( $year, $month, $day );
747
748 if ( $StartTime != 0 )
749 $t->set_var( "start_value", $StartTime );
750
751 if ( $user )
752 {
753 $t->set_var( "own_user_id", $userID );
754 $t->set_var( "own_user_name", $user->name() );
755 $t->set_var( "own_selected", "" );
756 $t->set_var( "user_name", "" );
757 $sessionUser = $session->variable( "ShowOtherCalendarUsers" );
758 $trusteeArray = $user->getByTrustee( -1, true );
759
760 foreach ( $trusteeArray as $trustee )
761 {
762 $t->set_var( "user_id", $trustee->ID() );
763 $t->set_var( "user_name", $trustee->name() );
764 if ( $sessionUser == $trustee->id() )
765 $t->set_var( "selected", "selected" );
766 else
767 $t->set_var( "selected", "" );
768 $t->parse( "trustee_user_name", "trustee_user_name_tpl", true );
769 }
770 }
771 }
772 }
773
774 // print the appointment types
775 $type = new eZAppointmentType();
776 $typeList =& $type->getTree();
777
778 foreach ( $typeList as $type )
779 {
780 $typeID = $type[0]->id();
781 if ( $type[1] > 1 )
782 $t->set_var( "option_level", str_repeat( "&nbsp;&nbsp;", $type[1] - 1 ) );
783 else
784 $t->set_var( "option_level", "" );
785
786 if ( $typeID )
787 {
788 if ( $typeID == $type[0]->id() )
789 {
790 $t->set_var( "selected", "selected" );
791 }
792 else
793 {
794 $t->set_var( "selected", "" );
795 }
796 }
797
798 $t->set_var( "option_name", $type[0]->name() );
799 $t->set_var( "option_value", $type[0]->id() );
800
801 $t->parse( "value", "value_tpl", true );
802 }
803
804 // set day combobox
805 for ( $i = 1; $i <= 31; $i++ )
806 {
807 if ( $tmpdate->day() == $i )
808 $t->set_var( "selected", "selected" );
809 else
810 $t->set_var( "selected", "" );
811
812 if ( $Action == "Edit" )
813 {
814 if ( $dt->day() == $i )
815 {
816 $t->set_var( "selected", "selected" );
817 }
818 else
819 {
820 $t->set_var( "selected", "" );
821 }
822 }
823 else if ( isset( $DateError ) && $DateError )
824 {
825 if ( $Day == $i )
826 {
827 $t->set_var( "selected", "selected" );
828 }
829 else
830 {
831 $t->set_var( "selected", "" );
832 }
833 }
834
835 $t->set_var( "day_id", $i );
836 $t->set_var( "day_name", $i );
837
838 $t->parse( "day", "day_tpl", true );
839 }
840
841 // set month combobox
842 $month = $tmpdate->month();
843 for ( $i = 1; $i <= 12; $i++ )
844 {
845 if ( $month == $i ) // don't use $tmpdate->month() since it gets changed
846 $t->set_var( "selected", "selected" );
847 else
848 $t->set_var( "selected", "" );
849
850 if ( $Action == "Edit" )
851 {
852 if ( $i == $dt->month() )
853 {
854 $t->set_var( "selected", "selected" );
855 }
856 else
857 {
858 $t->set_var( "selected", "" );
859 }
860 }
861 else if ( isset( $DateError ) && $DateError )
862 {
863 if ( $i == $Month )
864 {
865 $t->set_var( "selected", "selected" );
866 }
867 else
868 {
869 $t->set_var( "selected", "" );
870 }
871 }
872
873 $tmpdate->setMonth( $i );
874 $t->set_var( "month_id", $i );
875 $t->set_var( "month_name", $Locale->monthName( $tmpdate->monthName() ) );
876
877 $t->parse( "month", "month_tpl", true );
878 }
879
880 if ( $Action != "Edit" )
881 {
882 if ( isset( $DateError ) && $DateError )
883 $t->set_var( "year_value", $Year );
884 else
885 $t->set_var( "year_value", $tmpdate->year() );
886 }
887
888 //if ( !isset( $DateError ) )
889 //{
890
891 $t->parse("no_error", "no_error_tpl");
892 $t->pparse("output", "appointment_edit_tpl");
893
894 //}
895
896 // deletes the dayview cache file for a given day
897 function deleteCache( $SiteDesign, $language, $year, $month, $day, $userID )
898 {
899 @eZPBFile::unlink( "kernel/ezcalendar/user/cache/dayview.tpl-$SiteDesign-$language-$year-$month-$day-$userID.cache" );
900 @eZPBFile::unlink( "kernel/ezcalendar/user/cache/monthview.tpl-$SiteDesign-$language-$year-$month-$userID.cache" );
901 @eZPBFile::unlink( "kernel/ezcalendar/user/cache/dayview.tpl-$SiteDesign-$language-$year-$month-$day-$userID-private.cache" );
902 @eZPBFile::unlink( "kernel/ezcalendar/user/cache/monthview.tpl-$SiteDesign-$language-$year-$month-$userID-private.cache" );
903 }
904
905 //Adds a "0" in front of the value if it's below 10.
906 function addZero( $value )
907 {
908 settype( $value, "integer" );
909 $ret = $value;
910 if ( $ret < 10 )
911 {
912 $ret = "0". $ret;
913 }
914 return $ret;
915 }
916
917 ?>
$i
$i
Definition: admin/adlist.php:91
$session
$session
Definition: admin/articlelist.php:44
$tmpdate
$tmpdate
Definition: appointmentedit.php:667
$day
else $day
Definition: appointmentedit.php:665
$StartTimeError
$StartTimeError
Definition: appointmentedit.php:104
$type
if( $Action=="New") $type
Definition: appointmentedit.php:775
$year
else $year
Definition: appointmentedit.php:655
$StopTimeError
$StopTimeError
Definition: appointmentedit.php:105
$app
else $app
Definition: appointmentedit.php:128
$t
$t
Definition: appointmentedit.php:133
$TitleError
$TitleError
Definition: appointmentedit.php:103
$typeList
$typeList
Definition: appointmentedit.php:776
$user
if(isset( $TrusteeUser)) $user
Definition: appointmentedit.php:117
$ini
if(isset( $DeleteAppointments)) if(isset( $GoDay)) else if(isset( $GoMonth)) else if(isset( $GoYear)) else if(isset( $GoToday)) $ini
Definition: appointmentedit.php:95
$Locale
$Locale
Definition: appointmentedit.php:101
$StopTimeStr
$StopTimeStr
Definition: appointmentedit.php:99
$Language
$Language
Definition: appointmentedit.php:97
addZero
addZero( $value)
Definition: appointmentedit.php:906
$userID
else $userID
Definition: appointmentedit.php:121
$DateError
$DateError
Definition: appointmentedit.php:106
deleteCache
deleteCache( $SiteDesign, $language, $year, $month, $day, $userID)
Definition: appointmentedit.php:897
else
if(isset( $ChangeView)||isset( $ViewType) && $ViewType=="multiple") else
Definition: appointmentedit.php:163
$StartTimeStr
$StartTimeStr
Definition: appointmentedit.php:98
$today
$today
Definition: appointmentedit.php:651
$month
else $month
Definition: appointmentedit.php:660
$datetime
$datetime
Definition: appointmentview.php:108
$appointment
$appointment
Definition: appointmentview.php:89
$Description
$Description
Definition: articlelistrss.php:38
$date
$date
Definition: bugpreview.php:66
eZAppointmentType
Definition: ezappointmenttype.php:42
eZAppointment
Definition: ezappointment.php:43
eZDateTime
Definition: ezdatetime.php:55
eZDate
Definition: ezdate.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Action
$Action
Definition: companysearch.php:80
$hour
$hour
Definition: export_froogle.php:310
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$startTime
$startTime
Definition: ezcalendar/user/dayview.php:139
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$stopTime
$stopTime
Definition: ezcalendar/user/dayview.php:140
$Day
$Day
Definition: ezcalendar/user/dayview.php:79
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
exit
exit
Definition: folder.php:81
$language
$language
Definition: messageform.php:32
kernel
$Name
$Name
Definition: polledit.php:250
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.