$cal_templates->set_var('event_endtime', ' - ' . $endtime); } $cal_templates->set_var('event_title_and_link', COM_createLink($A['title'], $_CONF['site_url'] . '/calendar/event.php?' . addMode($mode) . 'eid=' . $A['eid'])); // Provide delete event link if user has access $cal_templates->set_var('delete_imagelink', getDeleteImageLink($mode, $A, $token)); $cal_templates->parse('events_day' . $i, 'events', true); } if ($nrows == 0) { $cal_templates->set_var('event_starttime', ' '); $cal_templates->set_var('event_endtime', ''); $cal_templates->set_var('event_title_and_link', ''); $cal_templates->set_var('delete_imagelink', ''); $cal_templates->parse('events_day' . $i, 'events', true); } // Go to next day $thedate = CAL_getUserDateTimeFormat(mktime(0, 0, 0, $monthnum, $daynum + 1, $yearnum)); } $display .= $cal_templates->parse('output', 'week'); $display .= CALENDAR_siteFooter(); break; default: // month view // Load templates $cal_templates = new Template($_CONF['path'] . 'plugins/calendar/templates'); $cal_templates->set_file(array('calendar' => 'calendar.thtml', 'week' => 'calendarweek.thtml', 'day' => 'calendarday.thtml', 'event' => 'calendarevent.thtml', 'mastercal' => 'mastercalendaroption.thtml', 'personalcal' => 'personalcalendaroption.thtml', 'addevent' => 'addeventoption.thtml')); $cal_templates->set_var('layout_url', $_CONF['layout_url']); $cal_templates->set_var('mode', $mode); if ($mode == 'personal') { $cal_templates->set_var('start_block', COM_startBlock($LANG_CAL_2[12])); $cal_templates->set_var('end_block', COM_endBlock()); } else {
/** * Adds an event to the user's calendar * * The user has asked that an event be added to their personal * calendar. Show a confirmation screen. * * @param string $eid event ID to add to user's calendar * @return string HTML for confirmation form * */ function CALENDAR_addUserEvent($eid) { global $_CONF, $_USER, $_TABLES, $LANG_CAL_1; $retval = ''; $eventsql = "SELECT * FROM {$_TABLES['events']} WHERE eid='" . DB_escapeString($eid) . "'" . COM_getPermSql('AND'); $result = DB_query($eventsql); $nrows = DB_numRows($result); if ($nrows == 1) { $retval .= COM_startBlock(sprintf($LANG_CAL_1[11], COM_getDisplayName())); $A = DB_fetchArray($result); $cal_template = new Template($_CONF['path'] . 'plugins/calendar/templates/'); $cal_template->set_file(array('addevent' => 'addevent.thtml')); $cal_template->set_var('intro_msg', $LANG_CAL_1[8]); $cal_template->set_var('lang_event', $LANG_CAL_1[12]); $event_title = $A['title']; if (!empty($A['url']) && $A['url'] != 'http://') { $cal_template->set_var('event_url', $A['url']); $event_title = COM_createLink($event_title, $A['url']); } else { $cal_template->set_var('event_url', ''); } $cal_template->set_var('event_title', $event_title); $cal_template->set_var('lang_starts', $LANG_CAL_1[13]); $cal_template->set_var('lang_ends', $LANG_CAL_1[14]); $thestart = CAL_getUserDateTimeFormat($A['datestart'] . ' ' . $A['timestart']); $theend = CAL_getUserDateTimeFormat($A['dateend'] . ' ' . $A['timeend']); if ($A['allday'] == 0) { $cal_template->set_var('event_start', $thestart[0]); $cal_template->set_var('event_end', $theend[0]); } else { $cal_template->set_var('event_start', strftime('%x', $thestart[1])); $cal_template->set_var('event_end', strftime('%x', $theend[1])); } $cal_template->set_var('lang_where', $LANG_CAL_1[4]); $location = $A['location'] . '<br/>' . $A['address1'] . '<br/>' . $A['address2'] . '<br/>' . $A['city'] . ', ' . $A['state'] . ' ' . $A['zipcode']; /* this will eventually replace the above code // build well-formatted location html $location = ''; $keys = array('location','address1','address2','city','state','zipcode'); foreach($key as $keys) { if (!empty($A[$key])) { if ($key == 'zipcode') { $location .= $A[$key]; } else { $location .= stripslashes($A[$key]); } switch ($key) { case 'city': if (!empty($A['state']) || !empty($A['zip'])) { if (!empty($A['state'])) { $location .= ', '; } elseif (!empty($A['zipcode'])) { $location .= ' '; } } else { $location .= '<br/>'; } break; case 'state': if (!empty($A['zipcode'])) { $location .= ' '; } else { $location .= '<br/>'; } break; default: $location .= '<br/>'; break; } } } */ $cal_template->set_var('event_location', $location); $cal_template->set_var('lang_description', $LANG_CAL_1[5]); $description = $A['description']; if (empty($A['postmode']) || $A['postmode'] == 'plaintext') { $description = nl2br($description); } $cal_template->set_var('event_description', PLG_replaceTags($description, 'calendar', 'description')); $cal_template->set_var('event_id', $eid); $cal_template->set_var('lang_addtomycalendar', $LANG_CAL_1[9]); $cal_template->set_var('gltoken_name', CSRF_TOKEN); $cal_template->set_var('gltoken', SEC_createToken()); $cal_template->parse('output', 'addevent'); $retval .= $cal_template->finish($cal_template->get_var('output')); $retval .= COM_endBlock(); } else { $retval .= COM_showMessage(23); } return $retval; }