Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eventview.php
Go to the documentation of this file.
1 <?
3 //
4 // $Id: eventview.php,v 1.10 2001/02/01 11:25:55 gl Exp $
5 //
6 // Adam Fallert <FallertA@umsystem.edu>
7 // Created on: <3-Oct-2001 14:36:00>
8 //
9 // This source file is part of Exponential Basic, publishing software.
10 // Copyright (C) 1999-2001 eZ systems as
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
27
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlog.php" );
31 // include_once( "classes/ezdatetime.php" );
32 // include_once( "classes/ezdate.php" );
33 // include_once( "classes/eztime.php" );
34 // include_once( "classes/ezlocale.php" );
35
36 // include_once( "ezuser/classes/ezpermission.php" );
37
38 // include_once( "ezgroupeventcalendar/classes/ezgroupevent.php" );
39 // include_once( "ezgroupeventcalendar/classes/ezgroupeventtype.php" );
40 // include_once( "ezgroupeventcalendar/classes/ezgroupeditor.php" );
41
42 // include_once( "ezgroupeventcalendar/classes/ezgroupeventcategory.php" );
43
44 // include_once( "ezforum/classes/ezforum.php" );
45 // include_once( "ezforum/classes/ezforumcategory.php" );
46
47 $ini =& eZINI::instance( 'site.ini' );
48
49 $SiteDesign = $ini->variable( "site", "SiteDesign" );
50 $Language = $ini->variable( "eZGroupEventCalendarMain", "Language" );
51 $locale = new eZLocale( $Language );
52
53 $t = new eZTemplate( "kernel/ezgroupeventcalendar/user/" . $ini->variable( "eZGroupEventCalendarMain", "TemplateDir" ),
54 "kernel/ezgroupeventcalendar/user/intl/", $Language, "eventview.php" );
55
56 $t->set_file( "event_view_tpl", "eventview.tpl" );
57
58 $t->setAllStrings();
59
60 $t->set_block( "event_view_tpl", "error_tpl", "error" );
61 $t->set_block( "event_view_tpl", "view_tpl", "view" );
62 $t->set_block( "event_view_tpl", "group_name_print_tpl", "group_name_print" );
63 $t->set_block( "event_view_tpl", "group_event_print_tpl", "group_event_print" );
64 $t->set_block( "view_tpl", "public_tpl", "public" );
65 $t->set_block( "view_tpl", "private_tpl", "private" );
66
67 $t->set_block( "view_tpl", "lowest_tpl", "lowest" );
68 $t->set_block( "view_tpl", "low_tpl", "low" );
69 $t->set_block( "view_tpl", "normal_tpl", "normal" );
70 $t->set_block( "view_tpl", "medium_tpl", "medium" );
71 $t->set_block( "view_tpl", "high_tpl", "high" );
72 $t->set_block( "view_tpl", "highest_tpl", "highest" );
73
74 $t->set_block( "view_tpl", "tentative_tpl", "tentative" );
75 $t->set_block( "view_tpl", "confirmed_tpl", "confirmed" );
76 $t->set_block( "view_tpl", "cancelled_tpl", "cancelled" );
77
78 $t->set_block( "view_tpl", "valid_editor_tpl", "valid_editor" );
79
80 $t->set_block( "view_tpl", "attached_file_list_tpl", "attached_file_list" );
81 $t->set_block( "attached_file_list_tpl", "attached_file_tpl", "attached_file" );
82 $t->set_block( "attached_file_list_tpl", "attached_image_tpl", "attached_image" );
83
84 $t->set_block( "view_tpl", "recurring_event_tpl", "recurring_event");
85 $t->set_block( "recurring_event_tpl", "recurring_days_week_tpl", "recurring_days_week");
86 $t->set_block( "recurring_days_week_tpl", "recurring_days_tpl", "recurring_days");
87 $t->set_block( "recurring_event_tpl", "recurring_monthly_type_tpl", "recurring_monthly_type");
88 $t->set_block( "recurring_event_tpl", "recurring_exceptions_tpl", "recurring_exceptions");
89
90 $t->set_var( "sitedesign", $SiteDesign );
91
92 $curDate = new eZDate();
93 $t->set_var("day_cur", $curDate->day());
94 $t->set_var("month_cur", $curDate->month());
95 $t->set_var("year_cur", $curDate->year());
96
97 $user = eZUser::currentUser();
98 $session =& eZSession::globalSession();
99 $session->fetch();
100
101 $tmpGroup = new eZUserGroup( $session->variable( "ShowOtherCalenderGroups" ) );
102
103 // k: die ("test g:" . $session->variable( "ShowOtherCalenderGroups") );
104
105 $groupsList = "-1";
106 $showPrivate = false;
107 $editor = false;
108
109 // Determin the users group membership and access
110 if( $user )
111 {
112 // if the user has root access, then the user has access to all groups
113 if( $user->hasRootAccess() == true || eZPermission::checkPermission( $user, "eZGroupEventCalendar", "WriteToRoot" ) )
114 {
115 $groups = new eZUserGroup();
116 $groupsList = $groups->getAll( true );
117 $rootAccess = true;
118 }
119 else
120 {
121 $groupsList = $user->groups();
122 }
123 }
124
125
126 $t->set_var( "group_event_print", "" );
127
128 // find the event and determin the permissions
129 $event = new eZGroupEvent($EventID);
130
131 if( $event )
132 {
133 $editor = false;
134 $groupMember = false;
135
136 // if a groupsList exists then it is assumed that a user is loged in
137 if( $groupsList != "-1" )
138 {
139 $permission = new eZGroupEditor();
140
141 // Determin if has edit permissions, if so, then they are a group member
142 if( $permission->hasEditPermission( $user->id(), $event->groupID() ) == true || isset( $rootAccess ) && $rootAccess == true )
143 {
144 $editor = true;
145 $groupMember = true;
146 }
147 else
148 {
149 foreach( $groupsList as $groups )
150 {
151 if( $permission->groupHasEditor( $groups->id() ) == false && $groups->id() == $event->groupID() )
152 {
153 $editor = true;
154 $groupMember = true;
155 break;
156 }
157 elseif( $groups->id() == $event->groupID() )
158 {
159 $groupMember = true;
160 break;
161 }
162 }
163 }
164 }
165
166 // does the user have privilleges to view the event or not
167 if ( $event->isPrivate() == true && $groupMember != true && !eZPermission::checkPermission( $user, "eZGroupEventCalendar", "Read" ) )
168 $showEvent = false;
169 elseif( $event->isPrivate() == false || ( $event->isPrivate() == true && eZPermission::checkPermission( $user, "eZGroupEventCalendar", "Read" ) ) )
170 $showEvent = true;
171
172
173 // Determine editing permissions
174
175 if( $session->variable( "ShowOtherCalenderGroups" ) != 0 && $tmpGroup->id() == $event->groupID() )
176 {
177 $t->set_var( "group_print_id", $tmpGroup->id() );
178 $t->set_var( "group_print_name", $tmpGroup->name() );
179 $t->parse( "group_name_print", "group_name_print_tpl" );
180 }
181 else
182 $t->set_var( "group_name_print", "" );
183 }
184
185
186 // print the correct display based on the above proccesses
187 if ( $showEvent == false )
188 {
189 $error = true;
190 $t->set_var( "event_title", "" );
191 $t->set_var( "view", "" );
192 $t->parse( "error", "error_tpl" );
193 }
194 else
195 {
196 $event = new eZGroupEvent( $EventID );
197 $eventType = $event->type();
198 $eventCategory = $event->category();
199
200 $datetime = $event->dateTime();
201 $t->set_var( "the_month", $datetime->month());
202 $t->set_var( "the_year", $datetime->year());
203 $t->set_var( "the_day", $datetime->day());
204 $t->set_var( "event_id", $event->id() );
205 $t->set_var( "event_title", stripslashes($event->name()) );
206
207 $t->set_var( "event_url", $event->url() );
208 $t->set_var( "event_location", $event->location() );
209 $t->set_var( "event_category", $eventCategory->name() );
210
211 $t->set_var( "event_type", $eventType->name() );
212 $t->set_var( "event_date", $locale->format( $datetime->date() ) );
213 $t->set_var( "event_starttime", $locale->format( $event->startTime(), true ) );
214 $t->set_var( "event_stoptime", $locale->format( $event->stopTime(), true ) );
215 $t->set_var( "event_description", stripslashes($event->description(false)) );
216
217 // recurring stuff here
218 /*
219 we need the following stuff
220 recur frequency (recur_freq)
221 recurrance type (recur_type)
222 if type is weekly, what days of week (recur_days_week)
223 if type is monthly, what type of month recurrance - every 26th of the month, First Friday of the month, Last Wednesday of month (recur_monthly_type)
224 repeat type (repeat_type)
225 if until date is set, (until_date)
226 if number of times is set, (num_times)
227 recur exceptions (recur_exception)
228
229 */
230
231 if ($event->isRecurring()) {
232 $t->set_var( "recur_freq", $event->recurFreq() );
233 $t->set_var( "recur_type", $event->recurType() );
234 if ($event->recurType() == 'week') {
235 foreach ($event->recurDay() as $r_d_w )
236 {
237 $t->set_var( "recur_days_week", $r_d_w);
238 $t->parse("recurring_days", "recurring_days_tpl", true);
239 }
240 $t->parse("recurring_days_week", "recurring_days_week_tpl");
241 } else {
242 $t->set_var( "recur_days_week", '');
243 $t->set_var( "recurring_days_week", '');
244 }
245 if ($event->recurType() == 'month') {
246 if ($event->recurMonthlyType() == 'numdayname')
247 {
248 $t->set_var( "recur_monthly_type", $event->recurMonthlyTypeInfo() . ' ' . $datetime->dayName(true) . ' of the month.' );
249 $t->parse( "recurring_monthly_type", "recurring_monthly_type_tpl" );
250 } elseif ($event->recurMonthlyType() == 'strdayname')
251 {
252 $t->set_var( "recur_monthly_type", 'Last ' . $datetime->dayName(true) . ' of the month.' );
253 $t->parse( "recurring_monthly_type", "recurring_monthly_type_tpl" );
254 } else {
255 $t->set_var( "recur_monthly_type", 'Every ' . $datetime->day() . ' of the month.' );
256 $t->parse( "recurring_monthly_type", "recurring_monthly_type_tpl" );
257 }
258 }
259 else {
260 $t->set_var( "recur_monthly_type", '' );
261 $t->set_var( "recurring_monthly_type", '');
262 }
263
264 if ( $event->repeatTimes() )
265 {
266 $t->set_var( "repeat_type", "Repeat Number of Times" );
267 $t->set_var( "repeat_message", $event->repeatTimes() );
268 }
269 elseif ( $event->repeatUntilDate() )
270 {
271 $t->set_var( "repeat_type", "Repeat Until Date" );
272 $t->set_var( "repeat_message", $event->repeatUntilDate() );
273 }
274 else {
275 $t->set_var( "repeat_type", "Repeat Forever" );
276 $t->set_var( "repeat_message", '' );
277 }
278 if ( is_array($event->recurExceptions() ) )
279 {
280 foreach ( $event->recurExceptions() as $ex)
281 {
282 $t->set_var( "recur_exception", $ex );
283 $t->parse( "recurring_exceptions", "recurring_exceptions_tpl", true);
284 }
285 } else {
286 $t->set_var( "recur_exception", '');
287 $t->parse( "recurring_exceptions", "recurring_exceptions_tpl" );
288 }
289 $t->parse( "recurring_event", "recurring_event_tpl" );
290 } else { // end of recurring_event stuff if isrecurring
291 $t->set_var( "recur_freq", "" );
292 $t->set_var( "recur_type", "" ); // day month week or year
293 $t->set_var( "recur_days_week", "" );
294 $t->set_var( "recur_monthly_type", "" );
295 $t->set_var( "repeat_type", "" );
296 $t->set_var( "until_date", "" );
297 $t->set_var( "num_times", "" );
298 $t->set_var( "recur_exception", "" );
299 $t->set_var( "recurring_event", '');
300 }
301 $groupID = $event->groupID();
302
303 /*
304 if ( $groupID == false ) {
305 die( " Group ID: " . $groupID );
306 }
307 */
308
309 // seems the bellow statement treats groupID = 0 as false instead of a numarical
310 // if ( $groupID != false )
311
312 if ( $groupID != "" )
313 {
314 // if event->groupID() == 0 then it's an all groups event. new
315 if ( $groupID != 0 ){
316 $group = new eZUserGroup( $groupID );
317 $t->set_var( "event_owner", $group->name() );
318 } else {
319 $t->set_var( "event_owner", "All Groups" );
320 }
321
322 }
323 else
324 $t->set_var( "event_owner", "unknown user" );
325
326 if ( $event->isPrivate() == true )
327 {
328 $t->parse( "private", "private_tpl" );
329 $t->set_var( "public", "" );
330 }
331 else
332 {
333 $t->parse( "public", "public_tpl" );
334 $t->set_var( "private", "" );
335 }
336
337 switch( $event->priority() )
338 {
339 case 0:
340 {
341 $t->parse( "lowest", "lowest_tpl" );
342
343 $t->set_var( "low", "" );
344 $t->set_var( "normal", "" );
345 $t->set_var( "medium", "" );
346 $t->set_var( "high", "" );
347 $t->set_var( "highest", "" );
348 }
349 break;
350 case 1:
351 {
352 $t->parse( "low", "low_tpl" );
353
354 $t->set_var( "lowest", "" );
355 $t->set_var( "normal", "" );
356 $t->set_var( "medium", "" );
357 $t->set_var( "high", "" );
358 $t->set_var( "highest", "" );
359
360 }
361 break;
362 case 2:
363 {
364 $t->parse( "normal", "normal_tpl" );
365
366 $t->set_var( "low", "" );
367 $t->set_var( "lowest", "" );
368 $t->set_var( "medium", "" );
369 $t->set_var( "high", "" );
370 $t->set_var( "highest", "" );
371
372 }
373 break;
374 case 3:
375 {
376 $t->parse( "medium", "medium_tpl" );
377
378 $t->set_var( "low", "" );
379 $t->set_var( "lowest", "" );
380 $t->set_var( "normal", "" );
381 $t->set_var( "high", "" );
382 $t->set_var( "highest", "" );
383 }
384 break;
385 case 4:
386 {
387 $t->parse( "high", "high_tpl" );
388
389 $t->set_var( "low", "" );
390 $t->set_var( "lowest", "" );
391 $t->set_var( "normal", "" );
392 $t->set_var( "medium", "" );
393 $t->set_var( "highest", "" );
394 }
395 break;
396 case 5:
397 {
398 $t->parse( "highest", "high_tpl" );
399
400 $t->set_var( "low", "" );
401 $t->set_var( "lowest", "" );
402 $t->set_var( "normal", "" );
403 $t->set_var( "medium", "" );
404 $t->set_var( "high", "" );
405
406 }
407 break;
408 }
409
410 switch( $event->status() )
411 {
412 case 0:
413 {
414 $t->parse( "tentative", "tentative_tpl" );
415
416 $t->set_var( "confirmed", "" );
417 $t->set_var( "cancelled", "" );
418 }
419 break;
420 case 1:
421 {
422 $t->parse( "confirmed", "confirmed_tpl" );
423
424 $t->set_var( "tentative", "" );
425 $t->set_var( "cancelled", "" );
426 }
427 break;
428 case 2:
429 {
430 $t->parse( "cancelled", "cancelled_tpl" );
431
432 $t->set_var( "confirmed", "" );
433 $t->set_var( "tentative", "" );
434 }
435 break;
436 }
437
438
439 // files
440 $files = $event->files();
441
442 if ( count( $files ) > 0 )
443 {
444 $i=0;
445 foreach ( $files as $file )
446 {
447 if ( ( $i % 2 ) == 0 )
448 {
449 $t->set_var( "td_class", "bglight" );
450 }
451 else
452 {
453 $t->set_var( "td_class", "bgdark" );
454 }
455
456 $image_types = array("png", "jpg", "gif", "bmp", "jpeg");
457 $image_condition = false;
458
459 $fn = $file->name();
460 $atype = explode(".", $fn);
461 $atype = $atype[1];
462
463 if( in_array($atype, $image_types ) ) {
464 $image_condition = true;
465 }
466
467 if ($image_condition) {
468 $t->set_var( "image_id", $file->id() );
469 $t->set_var( "image_name", $file->name() );
470 $t->set_var( "image_description", $file->description() );
471
472 $t->parse( "attached_image", "attached_image_tpl", true );
473 $t->set_var( "attached_file", "" );
474 } else {
475
476 $t->set_var( "file_id", $file->id() );
477 $t->set_var( "original_file_name", $file->fileName() );
478 $t->set_var( "file_name", $file->name() );
479 $t->set_var( "file_url", $file->name() );
480 $t->set_var( "file_description", $file->description() );
481
482 $t->parse( "attached_file", "attached_file_tpl", true );
483 $t->set_var( "attached_image", "" );
484 }
485
486 $size = $file->siFileSize();
487 $t->set_var( "file_size", $size["size-string"] );
488 $t->set_var( "file_unit", $size["unit"] );
489
490 $i++;
491 }
492 $t->parse( "attached_file_list", "attached_file_list_tpl" );
493 }
494 else
495 $t->set_var( "attached_file_list", "" );
496
497
498
499 $t->set_var( "error", "" );
500 $t->parse( "group_event_print", "group_event_print_tpl" );
501
502 //print or suppress the edit event button
503 if( isset( $editor ) && $editor == true )
504 $t->parse( "valid_editor", "valid_editor_tpl", true );
505 else
506 $t->set_var( "valid_editor", "" );
507
508 // suppress the event view template if error is encountered
509 if ( isset( $error ) && $error == true )
510 $t->set_var( "view", "" );
511 else
512 $t->parse( "view", "view_tpl" );
513 }
514
515 $t->pparse( "output", "event_view_tpl" );
516
517 ?>
$i
$i
Definition: admin/adlist.php:91
$group
$group
Definition: admin/articleedit.php:799
eZDate
Definition: ezdate.php:46
eZGroupEditor
Definition: ezgroupeditor.php:33
eZGroupEvent
Definition: ezgroupevent.php:85
eZLocale
Definition: ezlocale.php:119
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
eZUserGroup
Definition: ezusergroup.php:66
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$permission
$permission
Definition: eventedit.php:315
$eventCategory
$eventCategory
Definition: eventview.php:198
$datetime
$datetime
Definition: eventview.php:200
$groupID
$groupID
Definition: eventview.php:301
$locale
$locale
Definition: eventview.php:51
$t
$t
Definition: eventview.php:53
$showPrivate
$showPrivate
Definition: eventview.php:106
$groupsList
$groupsList
Definition: eventview.php:105
$user
$user
Definition: eventview.php:97
$event
$event
Definition: eventview.php:129
$Language
$Language
Definition: eventview.php:50
$ini
$ini
Definition: eventview.php:47
$files
switch( $event->priority()) switch( $event->status()) $files
Definition: eventview.php:440
$eventType
$eventType
Definition: eventview.php:197
$tmpGroup
$tmpGroup
Definition: eventview.php:101
$curDate
$curDate
Definition: eventview.php:92
$session
$session
Definition: eventview.php:98
$SiteDesign
$SiteDesign
Definition: eventview.php:49
$editor
$editor
Definition: eventview.php:107
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$groups
if( $CategoryID !=0) $groups
Definition: ezbulkmail/admin/categoryedit.php:108
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$rootAccess
$rootAccess
Definition: ezgroupeventcalendar/user/dayview.php:190
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.