| [ Index ] |
|
Code source de GeekLog 1.4.1 |
1 <?php 2 3 /* Reminder: always indent with 4 spaces (no tabs). */ 4 // +---------------------------------------------------------------------------+ 5 // | Calendar Plugin 1.0 | 6 // +---------------------------------------------------------------------------+ 7 // | event.php | 8 // | | 9 // | Shows details of an event or events | 10 // +---------------------------------------------------------------------------+ 11 // | Copyright (C) 2000-2006 by the following authors: | 12 // | | 13 // | Authors: Tony Bibbs - tony AT tonybibbs DOT com | 14 // | Mark Limburg - mlimburg AT users DOT sourceforge DOT net | 15 // | Jason Whittenburg - jwhitten AT securitygeeks DOT com | 16 // | Dirk Haun - dirk AT haun-online DOT de | 17 // +---------------------------------------------------------------------------+ 18 // | | 19 // | This program is free software; you can redistribute it and/or | 20 // | modify it under the terms of the GNU General Public License | 21 // | as published by the Free Software Foundation; either version 2 | 22 // | of the License, or (at your option) any later version. | 23 // | | 24 // | This program is distributed in the hope that it will be useful, | 25 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 26 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 27 // | GNU General Public License for more details. | 28 // | | 29 // | You should have received a copy of the GNU General Public License | 30 // | along with this program; if not, write to the Free Software Foundation, | 31 // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 32 // | | 33 // +---------------------------------------------------------------------------+ 34 // 35 // $Id: event.php,v 1.20 2006/12/11 13:25:31 dhaun Exp $ 36 37 require_once ('../lib-common.php'); 38 require_once ($_CONF['path_system'] . 'classes/calendar.class.php'); 39 40 /** 41 * Adds an event to the user's calendar 42 * 43 * The user has asked that an event be added to their personal 44 * calendar. Show a confirmation screen. 45 * 46 * @param string $eid event ID to add to user's calendar 47 * @return string HTML for confirmation form 48 * 49 */ 50 function adduserevent ($eid) 51 { 52 global $_CONF, $_TABLES, $LANG_CAL_1; 53 54 $retval = ''; 55 56 $eventsql = "SELECT * FROM {$_TABLES['events']} WHERE eid='$eid'" . COM_getPermSql ('AND'); 57 $result = DB_query($eventsql); 58 $nrows = DB_numRows($result); 59 if ($nrows == 1) { 60 $retval .= COM_startBlock (sprintf ($LANG_CAL_1[11], 61 COM_getDisplayName())); 62 $A = DB_fetchArray($result); 63 $cal_template = new Template($_CONF['path'] . 'plugins/calendar/templates/'); 64 $cal_template->set_file (array ('addevent' => 'addevent.thtml')); 65 $cal_template->set_var('site_url', $_CONF['site_url']); 66 $cal_template->set_var('site_admin_url', $_CONF['site_admin_url']); 67 $cal_template->set_var('layout_url', $_CONF['layout_url']); 68 $cal_template->set_var('intro_msg', $LANG_CAL_1[8]); 69 $cal_template->set_var('lang_event', $LANG_CAL_1[12]); 70 $cal_template->set_var('event_title',stripslashes($A['title'])); 71 72 if (!empty ($A['url']) && ($A['url'] != 'http://')) { 73 $cal_template->set_var ('event_url', $A['url']); 74 $cal_template->set_var ('event_begin_anchortag', 75 '<a href="' . $A['url'] . '">'); 76 $cal_template->set_var ('event_end_anchortag', '</a>'); 77 } else { 78 $cal_template->set_var ('event_url', ''); 79 $cal_template->set_var ('event_begin_anchortag', ''); 80 $cal_template->set_var ('event_end_anchortag', ''); 81 } 82 83 $cal_template->set_var('lang_starts', $LANG_CAL_1[13]); 84 $cal_template->set_var('lang_ends', $LANG_CAL_1[14]); 85 86 $thestart = COM_getUserDateTimeFormat($A['datestart'] . ' ' . $A['timestart']); 87 $theend = COM_getUserDateTimeFormat($A['dateend'] . ' ' . $A['timeend']); 88 if ($A['allday'] == 0) { 89 $cal_template->set_var('event_start', $thestart[0]); 90 $cal_template->set_var('event_end', $theend[0]); 91 } else { 92 $cal_template->set_var('event_start', strftime($_CONF['shortdate'], $thestart[1])); 93 $cal_template->set_var('event_end', strftime($_CONF['shortdate'], $theend[1])); 94 } 95 96 $cal_template->set_var('lang_where',$LANG_CAL_1[4]); 97 $location = stripslashes($A['location']) . '<br>' 98 . stripslashes ($A['address1']) . '<br>' 99 . stripslashes ($A['address2']) . '<br>' 100 . stripslashes ($A['city']) 101 . ', ' . $A['state'] . ' ' . $A['zipcode']; 102 $cal_template->set_var('event_location', $location); 103 $cal_template->set_var('lang_description', $LANG_CAL_1[5]); 104 $description = stripslashes ($A['description']); 105 if ($A['postmode'] == 'plaintext') { 106 $description = nl2br ($description); 107 } 108 $cal_template->set_var ('event_description', 109 PLG_replaceTags ($description)); 110 $cal_template->set_var('event_id', $eid); 111 $cal_template->set_var('lang_addtomycalendar', $LANG_CAL_1[9]); 112 $cal_template->parse('output','addevent'); 113 $retval .= $cal_template->finish($cal_template->get_var('output')); 114 $retval .= COM_endBlock (); 115 } else { 116 $retval .= COM_showMessage(23); 117 } 118 119 return $retval; 120 } 121 122 /** 123 * Save an event to user's personal calendar 124 * 125 * User has seen the confirmation screen and they still want to 126 * add this event to their calendar. Actually save it now. 127 * 128 * @param string $eid ID of event to save 129 * @return string HTML refresh 130 * 131 */ 132 function saveuserevent ($eid) 133 { 134 global $_CONF, $_TABLES, $_USER; 135 136 if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) { 137 138 // Try to delete the event first in case it has already been added 139 DB_query ("DELETE FROM {$_TABLES['personal_events']} WHERE uid={$_USER['uid']} AND eid='$eid'"); 140 141 $result = DB_query ("SELECT eid FROM {$_TABLES['events']} WHERE (eid = '$eid')" . COM_getPermSql ('AND')); 142 if (DB_numRows ($result) == 1) { 143 144 $savesql = "INSERT INTO {$_TABLES['personal_events']} " 145 . "(eid,uid,title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2,city,state," 146 . "zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon) SELECT eid," 147 . $_USER['uid'] . ",title,event_type,datestart,dateend,timestart,timeend,allday,location,address1,address2," 148 . "city,state,zipcode,url,description,group_id,owner_id,perm_owner,perm_group,perm_members,perm_anon FROM " 149 . "{$_TABLES['events']} WHERE eid = '{$eid}'"; 150 151 DB_query ($savesql); 152 153 return COM_refresh ($_CONF['site_url'] 154 . '/calendar/index.php?mode=personal&msg=24'); 155 } 156 } 157 158 return COM_refresh ($_CONF['site_url'] . '/index.php'); 159 } 160 161 /** 162 * Allows user to edit a personal calendar event 163 * 164 * @param array $A Record to display 165 * @return string HTML for event editor 166 * 167 */ 168 function editpersonalevent ($A) 169 { 170 global $_CONF, $_CA_CONF, $LANG_CAL_1; 171 172 $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/'); 173 $cal_templates->set_file('form','editpersonalevent.thtml'); 174 $cal_templates->set_var('site_url', $_CONF['site_url']); 175 $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); 176 $cal_templates->set_var('layout_url', $_CONF['layout_url']); 177 178 $cal_templates->set_var ('lang_title', $LANG_CAL_1[28]); 179 $title = stripslashes ($A['title']); 180 $title = str_replace ('{', '{', $title); 181 $title = str_replace ('}', '}', $title); 182 $title = str_replace ('"', '"', $title); 183 $cal_templates->set_var ('event_title', $title); 184 185 $cal_templates->set_var('lang_eventtype', $LANG_CAL_1[37]); 186 $etypes = explode (',', $_CA_CONF['event_types']); 187 $type_options = ''; 188 foreach ($etypes as $evtype) { 189 $type_options .= '<option value="' . $evtype . '"'; 190 if ($evtype == $A['event_type']) { 191 $type_options .= ' selected="selected"'; 192 } 193 $type_options .= '>' . $evtype . '</option>'; 194 } 195 $cal_templates->set_var ('type_options', $type_options); 196 197 // Handle start date/time 198 $cal_templates->set_var('lang_startdate', $LANG_CAL_1[21]); 199 $cal_templates->set_var('lang_starttime', $LANG_CAL_1[30]); 200 $A['startdate'] = $A['datestart'] . ' ' . $A['timestart']; 201 202 $start_month = date ('n', strtotime ($A['startdate'])); 203 $month_options = COM_getMonthFormOptions ($start_month); 204 $cal_templates->set_var ('startmonth_options', $month_options); 205 206 $start_day = date ('j', strtotime ($A['startdate'])); 207 $day_options = COM_getDayFormOptions ($start_day); 208 $cal_templates->set_var('startday_options', $day_options); 209 210 $start_year = date ('Y', strtotime ($A['startdate'])); 211 $year_options = COM_getYearFormOptions ($start_year); 212 $cal_templates->set_var('startyear_options', $year_options); 213 214 if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { 215 $start_hour = date ('H', strtotime ($A['startdate'])); 216 $hour_options = COM_getHourFormOptions ($start_hour, 24); 217 $cal_templates->set_var ('starthour_options', $hour_options); 218 } else { 219 $start_hour = date ('g', strtotime ($A['startdate'])); 220 $hour_options = COM_getHourFormOptions ($start_hour); 221 $cal_templates->set_var ('starthour_options', $hour_options); 222 } 223 224 $startmin = intval (date ('i', strtotime ($A['startdate'])) / 15) * 15; 225 $cal_templates->set_var ('startminute_options', 226 COM_getMinuteFormOptions ($startmin, 15)); 227 228 $ampm = date ('a', strtotime ($A['startdate'])); 229 $cal_templates->set_var ('startampm_selection', 230 COM_getAmPmFormSelection ('startampm_selection', $ampm)); 231 232 // Handle end date/time 233 $cal_templates->set_var('lang_enddate', $LANG_CAL_1[18]); 234 $cal_templates->set_var('lang_endtime', $LANG_CAL_1[29]); 235 $A['enddate'] = $A['dateend'] . ' ' . $A['timeend']; 236 237 $end_month = date ('n', strtotime ($A['enddate'])); 238 $month_options = COM_getMonthFormOptions ($end_month); 239 $cal_templates->set_var ('endmonth_options', $month_options); 240 241 $end_day = date ('j', strtotime ($A['enddate'])); 242 $day_options = COM_getDayFormOptions ($end_day); 243 $cal_templates->set_var ('endday_options', $day_options); 244 245 $end_year = date ('Y', strtotime ($A['enddate'])); 246 $year_options = COM_getYearFormOptions ($end_year); 247 $cal_templates->set_var ('endyear_options', $year_options); 248 249 if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { 250 $end_hour = date ('H', strtotime ($A['enddate'])); 251 $hour_options = COM_getHourFormOptions ($end_hour, 24); 252 $cal_templates->set_var ('endhour_options', $hour_options); 253 } else { 254 $end_hour = date ('g', strtotime ($A['enddate'])); 255 $hour_options = COM_getHourFormOptions ($end_hour); 256 $cal_templates->set_var ('endhour_options', $hour_options); 257 } 258 259 $endmin = intval (date ('i', strtotime ($A['enddate'])) / 15) * 15; 260 $cal_templates->set_var ('endminute_options', 261 COM_getMinuteFormOptions ($endmin, 15)); 262 263 $ampm = date ('a', strtotime ($A['enddate'])); 264 $cal_templates->set_var ('endampm_selection', 265 COM_getAmPmFormSelection ('endampm_selection', $ampm)); 266 267 $cal_templates->set_var ('lang_alldayevent', $LANG_CAL_1[31]); 268 if ($A['allday'] == 1) { 269 $cal_templates->set_var ('allday_checked', 'checked="checked"'); 270 } else { 271 $cal_templates->set_var ('allday_checked', ''); 272 } 273 274 $cal_templates->set_var('lang_location',$LANG_CAL_1[39]); 275 $cal_templates->set_var('event_location', stripslashes ($A['location'])); 276 277 $cal_templates->set_var('lang_addressline1', $LANG_CAL_1[32]); 278 $cal_templates->set_var('event_address1', stripslashes ($A['address1'])); 279 $cal_templates->set_var('lang_addressline2', $LANG_CAL_1[33]); 280 $cal_templates->set_var('event_address2', stripslashes ($A['address2'])); 281 282 $cal_templates->set_var('lang_city', $LANG_CAL_1[34]); 283 $cal_templates->set_var('event_city', stripslashes ($A['city'])); 284 285 $cal_templates->set_var('lang_state', $LANG_CAL_1[35]); 286 $cal_templates->set_var('state_options', CALENDAR_stateList ($A['state'])); 287 288 $cal_templates->set_var('lang_zipcode', $LANG_CAL_1[36]); 289 $cal_templates->set_var('event_zipcode', $A['zipcode']); 290 291 $cal_templates->set_var('lang_link', $LANG_CAL_1[43]); 292 $cal_templates->set_var('event_url', $A['url']); 293 294 $cal_templates->set_var('lang_description', $LANG_CAL_1[5]); 295 $cal_templates->set_var('event_description', 296 nl2br (stripslashes ($A['description']))); 297 298 $cal_templates->set_var('lang_htmlnotallowed', $LANG_CAL_1[44]); 299 $cal_templates->set_var('lang_submit', $LANG_CAL_1[45]); 300 $cal_templates->set_var('lang_delete', $LANG_CAL_1[51]); 301 $cal_templates->set_var('eid', $A['eid']); 302 $cal_templates->set_var('uid', $A['uid']); 303 if (isset ($_CA_CONF['hour_mode']) && ($_CA_CONF['hour_mode'] == 24)) { 304 $cal_templates->set_var ('hour_mode', 24); 305 } else { 306 $cal_templates->set_var ('hour_mode', 12); 307 } 308 309 return $cal_templates->parse ('output', 'form'); 310 } 311 312 /** 313 * Set localised day and month names. 314 * 315 * @param object $aCalendar reference(!) to a Calendar object 316 * 317 */ 318 function setCalendarLanguage (&$aCalendar) 319 { 320 global $LANG_WEEK, $LANG_MONTH, $LANG_CAL_2; 321 322 $lang_days = array ('sunday' => $LANG_WEEK[1], 323 'monday' => $LANG_WEEK[2], 324 'tuesday' => $LANG_WEEK[3], 325 'wednesday' => $LANG_WEEK[4], 326 'thursday' => $LANG_WEEK[5], 327 'friday' => $LANG_WEEK[6], 328 'saturday' => $LANG_WEEK[7]); 329 $lang_months = array ('january' => $LANG_MONTH[1], 330 'february' => $LANG_MONTH[2], 331 'march' => $LANG_MONTH[3], 332 'april' => $LANG_MONTH[4], 333 'may' => $LANG_MONTH[5], 334 'june' => $LANG_MONTH[6], 335 'july' => $LANG_MONTH[7], 336 'august' => $LANG_MONTH[8], 337 'september' => $LANG_MONTH[9], 338 'october' => $LANG_MONTH[10], 339 'november' => $LANG_MONTH[11], 340 'december' => $LANG_MONTH[12]); 341 $aCalendar->setLanguage ($lang_days, $lang_months); 342 } 343 344 345 // MAIN 346 347 $display = ''; 348 349 $action = ''; 350 if (isset ($_REQUEST['action'])) { 351 $action = COM_applyFilter ($_REQUEST['action']); 352 } 353 354 switch ($action) { 355 case 'addevent': 356 if (($_CA_CONF['personalcalendars'] == 1) && 357 isset ($_USER['uid']) && ($_USER['uid'] > 1)) { 358 $display .= COM_siteHeader (); 359 360 $eid = COM_applyFilter ($_GET['eid']); 361 if (!empty ($eid)) { 362 $display .= adduserevent ($eid); 363 } else { 364 $display .= COM_showMessage (23); 365 } 366 367 $display .= COM_siteFooter (); 368 } else { 369 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 370 } 371 break; 372 373 case 'saveuserevent': 374 if ($_CA_CONF['personalcalendars'] == 1) { 375 $eid = COM_applyFilter ($_POST['eid']); 376 if (!empty ($eid)) { 377 $display .= saveuserevent ($eid); 378 } else { 379 $display .= COM_siteHeader (); 380 $display .= COM_showMessage (23); 381 $display .= COM_siteFooter (); 382 } 383 } else { 384 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 385 } 386 break; 387 388 case $LANG_CAL_1[45]: // save edited personal event 389 if (!empty ($LANG_CAL_1[45]) && ($_CA_CONF['personalcalendars'] == 1) && 390 (!empty ($_USER['uid']) && ($_USER['uid'] > 1)) && 391 (isset ($_POST['calendar_type']) && 392 ($_POST['calendar_type'] == 'personal'))) { 393 $display = plugin_savesubmission_calendar ($_POST); 394 } else { 395 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 396 } 397 break; 398 399 case 'deleteevent': 400 case $LANG_CAL_1[51]: 401 if ($_CA_CONF['personalcalendars'] == 1) { 402 $eid = COM_applyFilter ($_REQUEST['eid']); 403 if (!empty ($eid) && (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { 404 DB_query ("DELETE FROM {$_TABLES['personal_events']} WHERE uid={$_USER['uid']} AND eid='$eid'"); 405 $display .= COM_refresh ($_CONF['site_url'] 406 . '/calendar/index.php?mode=personal&msg=26'); 407 } else { 408 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 409 } 410 } else { 411 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 412 } 413 break; 414 415 case 'edit': 416 if ($_CA_CONF['personalcalendars'] == 1) { 417 $eid = COM_applyFilter ($_GET['eid']); 418 if (!empty ($eid) && (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { 419 $result = DB_query ("SELECT * FROM {$_TABLES['personal_events']} WHERE (eid = '$eid') AND (uid = {$_USER['uid']})"); 420 if (DB_numRows ($result) == 1) { 421 $A = DB_fetchArray ($result); 422 $display .= COM_siteHeader ('menu', $LANG_CAL_2[38]) 423 . COM_startBlock ($LANG_CAL_2[38]) 424 . editpersonalevent ($A) 425 . COM_endBlock () 426 . COM_siteFooter (); 427 } else { 428 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 429 } 430 } else { 431 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 432 } 433 } else { 434 $display = COM_refresh ($_CONF['site_url'] . '/index.php'); 435 } 436 break; 437 438 default: 439 $mode = ''; 440 if (isset ($_GET['mode'])) { 441 $mode = COM_applyFilter ($_GET['mode']); 442 } 443 $eid = ''; 444 if (isset ($_GET['eid'])) { 445 $eid = COM_applyFilter ($_GET['eid']); 446 } 447 if (!empty ($eid)) { 448 if (($mode == 'personal') && ($_CA_CONF['personalcalendars'] == 1) && 449 (isset ($_USER['uid']) && ($_USER['uid'] > 1))) { 450 $datesql = "SELECT * FROM {$_TABLES['personal_events']} " 451 . "WHERE (eid = '$eid') AND (uid = {$_USER['uid']})"; 452 $pagetitle = $LANG_CAL_2[28] . ' ' . COM_getDisplayName(); 453 } else { 454 $datesql = "SELECT * FROM {$_TABLES['events']} WHERE eid = '$eid'"; 455 if (strpos ($LANG_CAL_2[9], '%') === false) { 456 $pagetitle = $LANG_CAL_2[9]; 457 } else { 458 $pagetitle = sprintf ($LANG_CAL_2[9], $_CONF['site_name']); 459 } 460 DB_query ("UPDATE {$_TABLES['events']} SET hits = hits + 1 WHERE eid = '$eid'"); 461 } 462 463 $display .= COM_siteHeader ('menu', $pagetitle); 464 $display .= COM_startBlock ($pagetitle); 465 466 } else { 467 $year = 0; 468 if (isset ($_GET['year'])) { 469 $year = COM_applyFilter ($_GET['year'], true); 470 } 471 $month = 0; 472 if (isset ($_GET['month'])) { 473 $month = COM_applyFilter ($_GET['month'], true); 474 } 475 $day = 0; 476 if (isset ($_GET['day'])) { 477 $day = COM_applyFilter ($_GET['day'], true); 478 } 479 if (($year == 0) || ($month == 0) || ($day == 0)) { 480 $year = date ('Y'); 481 $month = date ('n'); 482 $day = date ('j'); 483 } 484 485 $pagetitle = $LANG_CAL_2[10] . ' ' . strftime ($_CONF['shortdate'], 486 mktime (0, 0, 0, $month, $day, $year)); 487 $display .= COM_siteHeader ('menu', $pagetitle); 488 $display .= COM_startBlock ($pagetitle); 489 490 $thedate = sprintf ('%4d-%02d-%02d', $year, $month, $day); 491 $datesql = "SELECT * FROM {$_TABLES['events']} " 492 . "WHERE \"$thedate\" BETWEEN DATE_FORMAT(datestart,'%Y-%m-%d') " 493 . "and DATE_FORMAT(dateend,'%Y-%m-%d') " 494 . "ORDER BY datestart ASC,timestart ASC,title"; 495 } 496 $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/'); 497 $cal_templates->set_file (array ( 498 'events' => 'events.thtml', 499 'details' => 'eventdetails.thtml', 500 'addremove' => 'addremoveevent.thtml' 501 )); 502 503 $cal_templates->set_var ('lang_addevent', $LANG_CAL_1[6]); 504 $cal_templates->set_var ('lang_backtocalendar', $LANG_CAL_1[15]); 505 if ($mode == 'personal') { 506 $cal_templates->set_var ('calendar_mode', '&mode=personal'); 507 } else { 508 $cal_templates->set_var ('calendar_mode', ''); 509 } 510 511 $result = DB_query($datesql); 512 $nrows = DB_numRows($result); 513 if ($nrows == 0) { 514 $cal_templates->set_var('lang_month',''); 515 $cal_templates->set_var('event_year',''); 516 $cal_templates->set_var('event_details',''); 517 $cal_templates->set_var('site_url', $_CONF['site_url']); 518 $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); 519 $cal_templates->set_var('layout_url', $_CONF['layout_url']); 520 $cal_templates->parse('output','events'); 521 $display .= $cal_templates->finish($cal_templates->get_var('output')); 522 $display .= $LANG_CAL_1[2]; 523 } else { 524 $cal = new Calendar(); 525 setCalendarLanguage ($cal); 526 527 $currentmonth = ''; 528 for ($i = 1; $i <= $nrows; $i++) { 529 $A = DB_fetchArray($result); 530 if (SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'], 531 $A['perm_group'],$A['perm_members'],$A['perm_anon']) > 0) { 532 if (strftime('%B',strtotime($A['datestart'])) != $currentmonth) { 533 $str_month = $cal->getMonthName(strftime('%m',strtotime($A['datestart']))); 534 $cal_templates->set_var('lang_month', $str_month); 535 $cal_templates->set_var('event_year', strftime('%Y',strtotime($A['datestart']))); 536 $currentmonth = strftime('%B',strtotime($A['datestart'])); 537 } 538 $cal_templates->set_var('event_title', stripslashes($A['title'])); 539 $cal_templates->set_var('site_url', $_CONF['site_url']); 540 $cal_templates->set_var('site_admin_url', $_CONF['site_admin_url']); 541 $cal_templates->set_var('layout_url', $_CONF['layout_url']); 542 if (!empty($A['url'])) { 543 $cal_templates->set_var('event_begin_anchortag', '<a href="'.$A['url'].'">'); 544 $cal_templates->set_var('event_title', stripslashes($A['title'])); 545 $cal_templates->set_var('event_end_anchortag', '</a>'); 546 } else { 547 $cal_templates->set_var('event_begin_anchortag', ''); 548 $cal_templates->set_var('event_title', stripslashes($A['title'])); 549 $cal_templates->set_var('event_end_anchortag', ''); 550 } 551 552 if (!empty ($_USER['uid']) && ($_USER['uid'] > 1) && 553 ($_CA_CONF['personalcalendars'] == 1)) { 554 $tmpresult = DB_query("SELECT * FROM {$_TABLES['personal_events']} " 555 . "WHERE eid='{$A['eid']}' AND uid={$_USER['uid']}"); 556 $tmpnrows = DB_numRows($tmpresult); 557 if ($tmpnrows > 0) { 558 $cal_templates->set_var('addremove_begin_anchortag','<a href="' 559 . $_CONF['site_url'] . '/calendar/event.php?eid=' . $A['eid'] 560 . '&mode=personal&action=deleteevent">'); 561 $cal_templates->set_var('lang_addremovefromcal',$LANG_CAL_1[10]); 562 $cal_templates->set_var('addremove_end_anchortag', '</a>'); 563 } else { 564 $cal_templates->set_var('addremove_begin_anchortag','<a href="' 565 . $_CONF['site_url'] . '/calendar/event.php?eid=' . $A['eid'] 566 . '&mode=personal&action=addevent">'); 567 $cal_templates->set_var('lang_addremovefromcal',$LANG_CAL_1[9]); 568 $cal_templates->set_var('addremove_end_anchortag', '</a>'); 569 } 570 $cal_templates->parse('addremove_event','addremove'); 571 } 572 $cal_templates->set_var('lang_when', $LANG_CAL_1[3]); 573 if ($A['allday'] == 0) { 574 $thedatetime = COM_getUserDateTimeFormat ($A['datestart'] . 575 ' ' . $A['timestart']); 576 $cal_templates->set_var ('event_start', $thedatetime[0]); 577 578 if ($A['datestart'] == $A['dateend']) { 579 $thedatetime[0] = strftime ($_CONF['timeonly'], 580 strtotime ($A['dateend'] . ' ' . $A['timeend'])); 581 } else { 582 $thedatetime = COM_getUserDateTimeFormat ($A['dateend'] 583 . ' ' . $A['timeend']); 584 } 585 $cal_templates->set_var ('event_end', $thedatetime[0]); 586 } elseif ($A['allday'] == 1 AND $A['datestart'] <> $A['dateend']) { 587 $thedatetime1 = strftime ('%A, ' . $_CONF['shortdate'], 588 strtotime ($A['datestart'])); 589 $cal_templates->set_var ('event_start', $thedatetime1); 590 $thedatetime2 = strftime ('%A, ' . $_CONF['shortdate'], 591 strtotime ($A['dateend'])); 592 $cal_templates->set_var ('event_end', $thedatetime2 593 . ' ' . $LANG_CAL_2[26]); 594 } else { 595 $thedatetime = strftime ('%A, ' . $_CONF['shortdate'], 596 strtotime ($A['datestart'])); 597 $cal_templates->set_var ('event_start', $thedatetime); 598 $cal_templates->set_var ('event_end', $LANG_CAL_2[26]); 599 } 600 601 // set the location variables 602 $cal_templates->set_var ('lang_where', $LANG_CAL_1[4]); 603 $cal_templates->set_var ('event_location', 604 stripslashes ($A['location'])); 605 $cal_templates->set_var ('event_address1', 606 stripslashes ($A['address1'])); 607 $cal_templates->set_var ('event_address2', 608 stripslashes ($A['address2'])); 609 $cal_templates->set_var ('event_zip', $A['zipcode']); 610 $cal_templates->set_var ('event_city', 611 stripslashes ($A['city'])); 612 $cal_templates->set_var ('event_state_only', $A['state']); 613 if (empty ($A['state']) || ($A['state'] == '--')) { 614 $cal_templates->set_var ('event_state', ''); 615 $cal_templates->set_var ('event_state_name', ''); 616 $cal_templates->set_var ('event_state_name_only', ''); 617 } else { 618 $cal_templates->set_var ('event_state', ', ' . $A['state']); 619 $cal_templates->set_var ('event_state_name', 620 ', ' . $_STATES[$A['state']]); 621 $cal_templates->set_var ('event_state_name_only', 622 $_STATES[$A['state']]); 623 } 624 625 // now figure out which of the {brX} variables to set ... 626 $hasCityEtc = (!empty ($A['city']) || !empty ($A['zip']) || 627 !empty ($A['state'])); 628 if (empty ($A['location']) && empty ($A['address1']) && 629 empty ($A['address2']) && !$hasCityEtc) { 630 $cal_templates->set_var ('br0', ''); 631 $cal_templates->set_var ('br1', ''); 632 $cal_templates->set_var ('br2', ''); 633 } else { 634 if (empty ($A['location']) || (empty ($A['address1']) && 635 empty ($A['address2']) && !$hasCityEtc)) { 636 $cal_templates->set_var ('br0', ''); 637 } else { 638 $cal_templates->set_var ('br0', '<br>'); 639 } 640 if (empty ($A['address1']) || (empty ($A['address2']) && 641 !$hasCityEtc)) { 642 $cal_templates->set_var ('br1', ''); 643 } else { 644 $cal_templates->set_var ('br1', '<br>'); 645 } 646 if (empty ($A['address2']) || !$hasCityEtc) { 647 $cal_templates->set_var ('br2', ''); 648 } else { 649 $cal_templates->set_var ('br2', '<br>'); 650 } 651 } 652 653 $cal_templates->set_var ('lang_description', $LANG_CAL_1[5]); 654 $description = stripslashes ($A['description']); 655 if ($A['postmode'] == 'plaintext') { 656 $description = nl2br ($description); 657 } 658 $cal_templates->set_var ('event_description', 659 PLG_replaceTags ($description)); 660 $cal_templates->set_var ('lang_event_type', $LANG_CAL_1[37]); 661 $cal_templates->set_var ('event_type', $A['event_type']); 662 $cal_templates->parse ('event_details', 'details', true); 663 } 664 } 665 666 if ($mode == 'personal') { 667 $editurl = $_CONF['site_url'] . '/calendar/event.php?action=edit' 668 . '&eid=' . $eid; 669 $cal_templates->set_var ('event_edit', '<a href="' .$editurl . '">' 670 . $LANG01[4] . '</a>'); 671 $cal_templates->set_var ('edit_icon', '<a href="' . $editurl 672 . '"><img src="' . $_CONF['layout_url'] 673 . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] 674 . '" title="' . $LANG01[4] . '" border="0"></a>'); 675 } else if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], 676 $A['perm_owner'], $A['perm_group'], $A['perm_members'], 677 $A['perm_anon']) == 3) && SEC_hasRights ('calendar.edit')) { 678 $editurl = $_CONF['site_admin_url'] 679 . '/plugins/calendar/index.php?mode=edit&eid=' . $eid; 680 $cal_templates->set_var ('event_edit', '<a href="' .$editurl . '">' 681 . $LANG01[4] . '</a>'); 682 $cal_templates->set_var ('edit_icon', '<a href="' . $editurl 683 . '"><img src="' . $_CONF['layout_url'] 684 . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] 685 . '" title="' . $LANG01[4] . '" border="0"></a>'); 686 $cal_templates->set_var ('hits_admin', 687 COM_numberFormat ($A['hits'])); 688 $cal_templates->set_var ('lang_hits_admin', $LANG10[30]); 689 } else { 690 $cal_templates->set_var ('event_edit', ''); 691 $cal_templates->set_var ('edit_icon', ''); 692 } 693 if ($mode == 'personal') { 694 // personal events don't have a hits counter 695 $cal_templates->set_var ('lang_hits', ''); 696 $cal_templates->set_var ('hits', ''); 697 } else { 698 $cal_templates->set_var ('lang_hits', $LANG10[30]); 699 $cal_templates->set_var ('hits', COM_numberFormat ($A['hits'])); 700 } 701 702 $cal_templates->parse ('output', 'events'); 703 $display .= $cal_templates->finish ($cal_templates->get_var ('output')); 704 } 705 706 $display .= COM_endBlock() . COM_siteFooter(); 707 708 } // end switch 709 710 echo $display; 711 712 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
|