コード例 #1
0
ファイル: evRepeat.class.php プロジェクト: NewRoute/evlist
 /**
  *   Display the detail page for the event occurrence.
  *
  *   @param  integer $rp_id  ID of the repeat to display
  *   @param  string  $query  Optional query string, for highlighting
  *   @param  string  $tpl    Optional template filename, e.g. 'event_print'
  *   @return string      HTML for the page.
  */
 public function Render($rp_id = 0, $query = '', $tpl = '')
 {
     global $_CONF, $_USER, $_EV_CONF, $_TABLES, $LANG_EVLIST, $LANG_WEEK, $_SYSTEM;
     $retval = '';
     $url = '';
     $location = '';
     $street = '';
     $city = '';
     $province = '';
     $country = '';
     $postal = '';
     $name = '';
     $email = '';
     $phone = '';
     if ($rp_id != 0) {
         $this->Read($rp_id);
     }
     if ($this->rp_id == 0) {
         return EVLIST_alertMessage($LANG_EVLIST['access_denied']);
     }
     //update hit count
     evlist_hit($this->ev_id);
     $template = 'event';
     if (!empty($tpl)) {
         $template .= '_' . $tpl;
     } else {
         $template .= $_SYSTEM['framework'] == 'uikit' ? '.uikit' : '';
     }
     $T = new Template(EVLIST_PI_PATH . '/templates/');
     $T->set_file(array('event' => $template . '.thtml', 'datetime' => 'date_time.thtml', 'address' => 'address.thtml', 'contact' => 'contact.thtml'));
     // If plain text then replace newlines with <br> tags
     if ($this->Event->postmode == '1') {
         //plaintext
         $this->Event->Detail->summary = nl2br($this->Event->Detail->summary);
         $this->Event->Detail->full_description = nl2br($this->Event->Detail->full_description);
         $this->Event->Detail->location = nl2br($this->Event->Detail->location);
     }
     $title = $this->Event->Detail->title;
     if ($this->postmode != 'plaintext') {
         $summary = PLG_replaceTags($this->Event->Detail->summary);
         $fulldescription = PLG_replaceTags($this->Event->Detail->full_description);
         $location = $this->Event->Detail->location != '' ? PLG_replaceTags($this->Event->Detail->location) : '';
     } else {
         $summary = $this->Event->Detail->summary;
         $fulldescription = $this->Event->Detail->full_description;
         $location = $this->Event->Detail->location;
     }
     if ($query != '') {
         $title = COM_highlightQuery($title, $query);
         if (!empty($summary)) {
             $summary = COM_highlightQuery($summary, $query);
         }
         if (!empty($fulldescription)) {
             $fulldescription = COM_highlightQuery($fulldescription, $query);
         }
         if (!empty($location)) {
             $location = COM_highlightQuery($location, $query);
         }
     }
     $date_start = EVLIST_formattedDate($this->date_start);
     if ($this->date_start != $this->date_end) {
         $date_end = EVLIST_formattedDate($this->date_end);
     } else {
         $date_end = '';
     }
     if ($this->Event->allday == '1') {
         $allday = '<br />' . $LANG_EVLIST['all_day_event'];
     } else {
         $allday = '';
         if ($this->time_start1 != '') {
             $time_start1 = EVLIST_formattedTime($this->time_start1);
             $time_end1 = EVLIST_formattedTime($this->time_end1);
         } else {
             $time_start1 = '';
             $time_end1 = '';
         }
         //$time_period = $time_start . $time_end;
         if ($this->Event->split == '1') {
             $time_start2 = EVLIST_formattedTime($this->time_start2);
             $time_end2 = EVLIST_formattedTime($this->time_end2);
         }
     }
     $url = $this->Event->Detail->url;
     $street = $this->Event->Detail->street;
     $city = $this->Event->Detail->city;
     $province = $this->Event->Detail->province;
     $postal = $this->Event->Detail->postal;
     $country = $this->Event->Detail->country;
     // Now get the text description of the recurring interval, if any
     if ($this->Event->recurring && $this->Event->rec_data['type'] < EV_RECUR_DATES) {
         $rec_data = $this->Event->rec_data;
         $rec_string = $LANG_EVLIST['recur_freq_txt'] . ' ' . $this->Event->RecurDescrip();
         switch ($rec_data['type']) {
             case EV_RECUR_WEEKLY:
                 // sequential days
                 $weekdays = array();
                 if (is_array($rec_data['listdays'])) {
                     foreach ($rec_data['listdays'] as $daynum) {
                         $weekdays[] = $LANG_WEEK[$daynum];
                     }
                     $days_text = implode(', ', $weekdays);
                 } else {
                     $days_text = '';
                 }
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_days'], $days_text);
                 break;
             case EV_RECUR_DOM:
                 $days = array();
                 foreach ($rec_data['interval'] as $key => $day) {
                     $days[] = $LANG_EVLIST['rec_intervals'][$day];
                 }
                 $days_text = implode(', ', $days) . ' ' . $LANG_WEEK[$rec_data['weekday']];
                 $rec_string .= ' ' . sprintf($LANG_EVLIST['on_the_days'], $days_text);
                 break;
         }
         if ($this->Event->rec_data['stop'] != '' && $this->Event->rec_data['stop'] < EV_MAX_DATE) {
             $rec_string .= ' ' . sprintf($LANG_EVLIST['recur_stop_desc'], EVLIST_formattedDate($this->Event->rec_data['stop']));
         }
     } else {
         $rec_string = '';
     }
     $T->set_var(array('pi_url' => EVLIST_URL, 'webcal_url' => preg_replace('/^https?/', 'webcal', EVLIST_URL), 'rp_id' => $this->rp_id, 'ev_id' => $this->ev_id, 'title' => $title, 'summary' => $summary, 'full_description' => $fulldescription, 'can_edit' => $this->isAdmin ? 'true' : '', 'start_time1' => $time_start1, 'end_time1' => $time_end1, 'start_time2' => $time_start2, 'end_time2' => $time_end2, 'start_date' => $date_start, 'end_date' => $date_end, 'start_datetime1' => $date_start . $time_start, 'end_datetime1' => $date_end . $time_end, 'allday_event' => $this->Event->allday == 1 ? 'true' : '', 'is_recurring' => $this->Event->recurring, 'can_subscribe' => $this->Event->Calendar->cal_ena_ical, 'recurring_event' => $rec_string, 'owner_id' => $this->Event->owner_id, 'cal_name' => $this->Event->Calendar->cal_name, 'cal_id' => $this->Event->cal_id, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'more_info_link' => sprintf($LANG_EVLIST['click_here'], $url)));
     if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) {
         if ($this->Event->options['rsvp_cutoff'] > 0) {
             $dt = new Date($this->event->date_start1 . ' ' . $this->Event->time_start1, $_CONF['timezone']);
             if (time() > $dt->toUnix() - $this->Event->options['rsvp_cutoff'] * 86400) {
                 $past_cutoff = false;
             } else {
                 $past_cutoff = true;
             }
         }
         if (COM_isAnonUser()) {
             // Just show a must-log-in message
             $T->set_var('login_to_register', 'true');
         } elseif (!$past_cutoff) {
             $num_free_tickets = $this->isRegistered(0, true);
             $total_tickets = $this->isRegistered(0, false);
             if ($num_free_tickets > 0) {
                 // If the user is already registered for any free tickets,
                 // show the cancel link
                 $T->set_var(array('unregister_link' => 'true', 'num_free_reg' => $num_free_tickets));
             }
             // Show the registration link
             if (($this->Event->options['max_rsvp'] == 0 || $this->Event->options['rsvp_waitlist'] == 1 || $this->Event->options['max_rsvp'] > $this->TotalRegistrations()) && ($this->Event->options['max_user_rsvp'] == 0 || $total_tickets < $this->Event->options['max_user_rsvp'])) {
                 USES_evlist_class_tickettype();
                 $Ticks = evTicketType::GetTicketTypes();
                 if ($this->Event->options['max_user_rsvp'] > 0) {
                     $T->set_block('event', 'tickCntBlk', 'tcBlk');
                     $T->set_var('register_multi', true);
                     //$rsvp_user_count = '';
                     $avail_tickets = $this->Event->options['max_user_rsvp'] - $total_tickets;
                     for ($i = 1; $i <= $avail_tickets; $i++) {
                         $T->set_var('tick_cnt', $i);
                         $T->parse('tcBlk', 'tickCntBlk', true);
                         //$rsvp_user_count .= '<option value="'.$i.'">'.$i.
                         //        '</option>'.LB;
                     }
                     //$T->set_var('register_multi', $rsvp_user_count);
                 } else {
                     // max_rsvp == 0 indicates openended registration
                     $T->set_var('register_unltd', 'true');
                 }
                 $T->set_block('event', 'tickTypeBlk', 'tBlk');
                 foreach ($this->Event->options['tickets'] as $tick_id => $data) {
                     /*$options .= '<option value="' . $tick_id . '">' .
                           $Ticks[$tick_id]->description;
                       if ($data['fee'] > 0) {
                           $options .= ' - ' . COM_numberFormat($data['fee'], 2);
                       }
                       $options .= '</option>' . LB;*/
                     $status = LGLIB_invokeService('paypal', 'formatAmount', array('amount' => $data['fee']), $pp_fmt_amt, $svc_msg);
                     $fmt_amt = $status == PLG_RET_OK ? $pp_fmt_amt : COM_numberFormat($data['fee'], 2);
                     $T->set_var(array('tick_type' => $tick_id, 'tick_descr' => $Ticks[$tick_id]->description, 'tick_fee' => $data['fee'] > 0 ? $fmt_amt : 'FREE'));
                     $T->parse('tBlk', 'tickTypeBlk', true);
                 }
                 $T->set_var(array('register_link' => 'true', 'ticket_options' => $options, 'ticket_types_multi' => count($this->Event->options['tickets']) > 1 ? 'true' : ''));
             }
         }
         // If ticket printing is enabled for this event, see if the
         // current user has any tickets to print.
         if ($this->Event->options['rsvp_print'] > 0) {
             $paid = $this->Event->options['rsvp_print'] == 1 ? 'paid' : '';
             USES_evlist_class_ticket();
             $tickets = evTicket::GetTickets($this->ev_id, '', $this->uid, $paid);
             if (count($tickets) > 0) {
                 $T->set_var('have_tickets', 'true');
             }
         }
     }
     // if enable_rsvp
     if (!empty($date_start) || !empty($date_end)) {
         $T->parse('datetime_info', 'datetime');
     }
     // Only process the location block if at least one element exists.
     // Don't want an empty block showing.
     if (!empty($location) || !empty($street) || !empty($city) || !empty($province) || !empty($postal)) {
         $T->set_var(array('location' => $location, 'street' => $street, 'city' => $city, 'province' => $province, 'country' => $country, 'postal' => $postal));
         $T->parse('address_info', 'address');
         // Get info from the Weather plugin, if configured and available
         // There has to be at least some location data for this to work.
         if ($_EV_CONF['use_weather']) {
             // The postal code works best, but not internationally.
             // Try the regular address first.
             $loc = '';
             if (!empty($city) && !empty($province)) {
                 $loc = $city . ', ' . $province . ' ' . $country;
             }
             if (!empty($postal)) {
                 $loc .= ' ' . $postal;
             }
             if (!empty($loc)) {
                 // Location info was found, get the weather
                 LGLIB_invokeService('weather', 'embed', array('loc' => $loc), $weather, $svc_msg);
                 if (!empty($weather)) {
                     // Weather info was found
                     $T->set_var('weather', $weather);
                 }
             }
         }
     }
     // Get a map from the Locator plugin, if configured and available
     if ($_EV_CONF['use_locator'] == 1 && $this->Event->Detail->lat != 0 && $this->Event->Detail->lng != 0) {
         $status = LGLIB_invokeService('locator', 'getMap', array('lat' => $this->Event->Detail->lat, 'lng' => $this->Event->Detail->lng), $map, $svc_msg);
         if ($status == PLG_RET_OK) {
             $T->set_var(array('map' => $map, 'lat' => number_format($this->Event->Detail->lat, 8, '.', ''), 'lng' => number_format($this->Event->Detail->lng, 8, '.', '')));
         }
     }
     //put contact info here: contact, email, phone#
     $name = $this->Event->Detail->contact != '' ? COM_applyFilter($this->Event->Detail->contact) : '';
     if ($this->Event->Detail->email != '') {
         $email = COM_applyFilter($this->Event->Detail->email);
         $email = EVLIST_obfuscate($email);
     } else {
         $email = '';
     }
     $phone = $this->Event->Detail->phone != '' ? COM_applyFilter($this->Event->Detail->phone) : '';
     if (!empty($name) || !empty($email) || !empty($phone)) {
         $T->set_var(array('name' => $name, 'email' => $email, 'phone' => $phone));
         $T->parse('contact_info', 'contact');
     }
     // TODO: Is the range needed?
     if (!empty($range)) {
         $andrange = '&amp;range=' . $range;
     } else {
         $andrange = '&amp;range=2';
     }
     if (!empty($cat)) {
         $andcat = '&amp;cat=' . $cat;
     } else {
         $andcat = '';
     }
     $cats = $this->Event->GetCategories();
     $catcount = count($cats);
     if ($catcount > 0) {
         $catlinks = array();
         for ($i = 0; $i < $catcount; $i++) {
             $catlinks[] = '<a href="' . COM_buildURL(EVLIST_URL . '/index.php?op=list' . $andrange . '&cat=' . $cats[$i]['id']) . '">' . $cats[$i]['name'] . '</a>&nbsp;';
         }
         $catlink = join('|&nbsp;', $catlinks);
         $T->set_var('category_link', $catlink, true);
     }
     //  reminders must be enabled globally first and then per event in
     //  order to be active
     if (!isset($_EV_CONF['reminder_days'])) {
         $_EV_CONF['reminder_days'] = 1;
     }
     $hasReminder = 0;
     if ($_EV_CONF['enable_reminders'] == '1' && $this->Event->enable_reminders == '1' && time() < strtotime("-" . $_EV_CONF['reminder_days'] . " days", strtotime($this->date_start))) {
         //form will not appear within XX days of scheduled event.
         $show_reminders = true;
         // Let's see if we have already asked for a reminder...
         if ($_USER['uid'] > 1) {
             $hasReminder = DB_count($_TABLES['evlist_remlookup'], array('eid', 'uid', 'rp_id'), array($this->ev_id, $_USER['uid'], $this->rp_id));
         }
     } else {
         $show_reminders = false;
     }
     if ($this->Event->options['contactlink'] == 1) {
         $ownerlink = $_CONF['site_url'] . '/profiles.php?uid=' . $this->Event->owner_id;
         $ownerlink = sprintf($LANG_EVLIST['contact_us'], $ownerlink);
     } else {
         $ownerlink = '';
     }
     $T->set_var(array('owner_link' => $ownerlink, 'reminder_set' => $hasReminder ? 'true' : 'false', 'reminder_email' => isset($_USER['email']) ? $_USER['email'] : '', 'notice' => 1, 'rp_id' => $this->rp_id, 'eid' => $this->ev_id, 'show_reminderform' => $show_reminders ? 'true' : ''));
     USES_evlist_class_tickettype();
     $tick_types = evTicketType::GetTicketTypes();
     $T->set_block('event', 'registerBlock', 'rBlock');
     if (is_array($this->Event->options['tickets'])) {
         foreach ($this->Event->options['tickets'] as $tic_type => $info) {
             $T->set_var(array('tic_description' => $tick_types[$tic_type]->description, 'tic_fee' => COM_numberFormat($info['fee'], 2)));
             $T->parse('rBlock', 'registerBlock', true);
         }
     }
     // Show the "manage reservations" link to the event owner
     if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) {
         if ($this->isAdmin) {
             $T->set_var('admin_rsvp', EVLIST_adminRSVP($this->rp_id));
         }
     }
     $T->parse('output', 'event');
     $retval .= $T->finish($T->get_var('output'));
     return $retval;
 }
コード例 #2
0
ファイル: evEvent.class.php プロジェクト: NewRoute/evlist
 /**
  *  Creates the edit form
  *  @param integer $id Optional ID, current record used if zero
  *  @return string HTML for edit form
  */
 public function Edit($eid = '', $rp_id = 0, $saveaction = '')
 {
     global $_CONF, $_EV_CONF, $_TABLES, $_USER, $LANG_EVLIST, $LANG_ADMIN, $_GROUPS, $LANG_ACCESS, $_SYSTEM;
     // If an eid is specified and this is an object, then read the
     // event data- UNLESS a repeat ID is given in which case we're
     // editing a repeat and already have the info we need.
     // This probably needs to change, since we should always read event
     // data during construction.
     if (!$this->isSubmitter) {
         // At least submit privilege required
         COM_404();
     } elseif ($eid != '' && $rp_id == 0 && is_object($this)) {
         // If an id is passed in, then read that record
         if (!$this->Read($eid)) {
             return 'Invalid object ID';
         }
     } elseif (isset($_POST['eid']) && !empty($_POST['eid'])) {
         // Returning to an existing form, probably due to errors
         $this->SetVars($_POST);
         // Make sure the current user has access to this event.
         if (!$this->hasAccess(3)) {
             COM_404();
         }
     }
     $T = new Template($_CONF['path'] . 'plugins/evlist/templates/');
     if ($_SYSTEM['disable_jquery_slimbox']) {
         $T->set_file('editor', 'editor.uikit.thtml');
     } else {
         $T->set_file('editor', 'editor.thtml');
     }
     // Basic tabs for editing both events and instances, show up on
     // all edit forms
     //$tabs = array('ev_info', 'ev_schedule', 'ev_location', 'ev_contact',);
     $tabs = array('ev_info', 'ev_location', 'ev_contact');
     $rp_id = (int) $rp_id;
     if ($rp_id > 0) {
         // Make sure the current user has access to this event.
         if (!$this->hasAccess(3)) {
             COM_404();
         }
         if ($saveaction == 'savefuturerepeat') {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_future'], 'warning');
         } else {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_instance'], 'info');
         }
         //$T->clear_var('contact_section');
         $T->clear_var('category_section');
         $T->clear_var('permissions_editor');
         // Set the static calendar name for the edit form.  Can't
         // change it for a single instance.
         $cal_name = DB_getItem($_TABLES['evlist_calendars'], 'cal_name', "cal_id='" . (int) $this->cal_id . "'");
         $T->set_var(array('contact_section' => 'true', 'is_repeat' => 'true', 'cal_name' => $cal_name));
         // Override our dates & times with those from the repeat.
         // $rp_id is passed when this is called from class evRepeat.
         // Maybe that should pass in the repeat's data instead to avoid
         // another DB lookup.  An array of values could be used.
         $Rep = DB_fetchArray(DB_query("SELECT * \n                    FROM {$_TABLES['evlist_repeat']}\n                    WHERE rp_id='{$rp_id}'"), false);
         if ($Rep) {
             $this->date_start1 = $Rep['rp_date_start'];
             $this->date_end1 = $Rep['rp_date_end'];
             $this->time_start1 = $Rep['rp_time_start1'];
             $this->time_end1 = $Rep['rp_time_end1'];
             $this->time_start2 = $Rep['rp_time_start2'];
             $this->time_end2 = $Rep['rp_time_end2'];
         }
     } else {
         // Editing the main event record
         if ($this->id != '' && $this->recurring == 1) {
             $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_series'], 'error');
         }
         if ($this->isAdmin) {
             $tabs[] = 'ev_perms';
             // Add permissions tab, event edit only
             $T->set_var('permissions_editor', 'true');
         }
         $T->set_var(array('contact_section' => 'true', 'category_section' => 'true', 'upcoming_chk' => $this->show_upcoming ? EVCHECKED : ''));
     }
     $action_url = EVLIST_URL . '/event.php';
     $delaction = 'delevent';
     if (isset($_GET['from']) && $_GET['from'] == 'admin') {
         $cancel_url = EVLIST_ADMIN_URL . '/index.php';
     } else {
         $cancel_url = EVLIST_URL . '/index.php';
     }
     switch ($saveaction) {
         case 'saverepeat':
         case 'savefuturerepeat':
         case 'saveevent':
             break;
         case 'moderate':
             // Approving a submission
             $saveaction = 'approve';
             $delaction = 'disapprove';
             $action_url = EVLIST_ADMIN_URL . '/index.php';
             $cancel_url = $_CONF['site_admin_url'] . '/moderation.php';
             break;
         default:
             $saveaction = 'saveevent';
             break;
     }
     $retval = '';
     //$recinterval = '';
     $recweekday = '';
     $ownerusername = DB_getItem($_TABLES['users'], 'username', "uid='{$this->owner_id}'");
     $retval .= COM_startBlock($LANG_EVLIST['event_editor']);
     $summary = $this->Detail->summary;
     $full_description = $this->Detail->full_description;
     $location = $this->Detail->location;
     if (($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) && $A['postmode'] == 'html') {
         $postmode = '2';
         //html
     } else {
         $postmode = '1';
         //plaintext
         $summary = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->summary)));
         $full_description = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->full_description)));
         $location = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->location)));
     }
     $starthour2 = '';
     $startminute2 = '';
     $endhour2 = '';
     $endminute2 = '';
     if ($this->date_end1 == '' || $this->date_end1 == '0000-00-00') {
         $this->date_end1 = $this->date_start1;
     }
     if ($this->date_start1 != '' && $this->date_start1 != '0000-00-00') {
         list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts($this->date_start1, $this->time_start1);
     } else {
         list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts(date('Y-m-d', time()), date('H:i:s', time()));
     }
     // The end date can't be before the start date
     if ($this->date_end1 >= $this->date_start1) {
         list($endmonth1, $endday1, $endyear1, $endhour1, $endminute1) = $this->DateParts($this->date_end1, $this->time_end1);
         $days_interval = Date_Calc::dateDiff($endday1, $endmonth1, $endyear1, $startday1, $startmonth1, $startyear1);
     } else {
         $days_interval = 0;
         $endmonth1 = $startmonth1;
         $endday1 = $startday1;
         $endyear1 = $startyear1;
         $endhour1 = $starthour1;
         $endminute1 = $startminute1;
     }
     if ($this->recurring != '1') {
         $T->set_var(array('recurring_show' => ' style="display:none;"', 'format_opt' => '0'));
         //for ($i = 1; $i <= 6; $i++) {
         //    $T->set_var('format' . $i . 'show', ' style="display:none;"');
         //}
     } else {
         $option = empty($this->rec_data['type']) ? '0' : (int) $this->rec_data['type'];
         $T->set_var(array('recurring_show' => '', 'recurring_checked' => EVCHECKED, 'format_opt' => $option));
     }
     if (isset($this->rec_data['stop']) && !empty($this->rec_data['stop'])) {
         $T->set_var(array('stopdate' => $this->rec_data['stop'], 'd_stopdate' => EVLIST_formattedDate($this->rec_data['stop'])));
     }
     if (!empty($this->rec_data['skip'])) {
         $T->set_var("skipnext{$this->rec_data['skip']}_checked", EVCHECKED);
     }
     if (!empty($this->rec_data['freq'])) {
         $freq = (int) $this->rec_data['freq'];
         if ($freq < 1) {
             $freq = 1;
         }
     } else {
         $freq = 1;
     }
     $T->set_var(array('freq_text' => $LANG_EVLIST['rec_periods'][$this->rec_data['type']] . '(s)', 'rec_freq' => $freq));
     foreach ($LANG_EVLIST['rec_intervals'] as $key => $str) {
         $T->set_var('dom_int_txt_' . $key, $str);
         if (is_array($this->rec_data['interval'])) {
             if (in_array($key, $this->rec_data['interval'])) {
                 $T->set_var('dom_int_chk_' . $key, EVCHECKED);
             }
         }
     }
     // Set up the recurring options needed for the current event
     switch ($option) {
         case 0:
             break;
         case EV_RECUR_MONTHLY:
             if (is_array($this->rec_data['listdays'])) {
                 foreach ($this->rec_data['listdays'] as $mday) {
                     $T->set_var('mdchk' . $mday, EVCHECKED);
                 }
             }
             break;
         case EV_RECUR_WEEKLY:
             $T->set_var('listdays_val', COM_stripslashes($rec_data[0]));
             if (is_array($this->rec_data['listdays']) && !empty($this->rec_data['listdays'])) {
                 foreach ($this->rec_data['listdays'] as $day) {
                     $day = (int) $day;
                     if ($day > 0 && $day < 8) {
                         $T->set_var('daychk' . $day, EVCHECKED);
                     }
                 }
             }
             break;
         case EV_RECUR_DOM:
             $recweekday = $this->rec_data['weekday'];
             break;
         case EV_RECUR_DATES:
             $T->set_var(array('stopshow' => 'style="display:none;"', 'custom_val' => implode(',', $this->rec_data['custom'])));
             break;
     }
     $start1 = EVLIST_TimeSelect('start1', $this->time_start1);
     $start2 = EVLIST_TimeSelect('start2', $this->time_start2);
     $end1 = EVLIST_TimeSelect('end1', $this->time_end1);
     $end2 = EVLIST_TimeSelect('end2', $this->time_end2);
     $cal_select = COM_optionList($_TABLES['evlist_calendars'], 'cal_id,cal_name', $this->cal_id, 1, 'cal_status = 1 ' . COM_getPermSQL('AND', 0, 2));
     USES_class_navbar();
     $navbar = new navbar();
     $cnt = 0;
     foreach ($tabs as $id) {
         $navbar->add_menuitem($LANG_EVLIST[$id], 'showhideEventDiv("' . $id . '",' . $cnt . ');return false;', true);
         $cnt++;
     }
     $navbar->set_selected($LANG_EVLIST['ev_info']);
     if ($this->AdminMode) {
         $action_url .= '?admin=true';
     }
     $T->set_var(array('action_url' => $action_url, 'navbar' => $navbar->generate(), 'alert_msg' => $alert_msg, 'cancel_url' => $cancel_url, 'eid' => $this->id, 'rp_id' => $rp_id, 'title' => $this->Detail->title, 'summary' => $summary, 'description' => $full_description, 'location' => $location, 'status_checked' => $this->status == 1 ? EVCHECKED : '', 'url' => $this->Detail->url, 'street' => $this->Detail->street, 'city' => $this->Detail->city, 'province' => $this->Detail->province, 'country' => $this->Detail->country, 'postal' => $this->Detail->postal, 'contact' => $this->Detail->contact, 'email' => $this->Detail->email, 'phone' => $this->Detail->phone, 'startdate1' => $this->date_start1, 'enddate1' => $this->date_end1, 'd_startdate1' => EVLIST_formattedDate($this->date_start1), 'd_enddate1' => EVLIST_formattedDate($this->date_end1), 'start_hour_options1' => $start1['hour'], 'start_minute_options1' => $start1['minute'], 'startdate1_ampm' => $start1['ampm'], 'end_hour_options1' => $end1['hour'], 'end_minute_options1' => $end1['minute'], 'enddate1_ampm' => $end1['ampm'], 'start_hour_options2' => $start2['hour'], 'start_minute_options2' => $start2['minute'], 'startdate2_ampm' => $start2['ampm'], 'end_hour_options2' => $end2['hour'], 'end_minute_options2' => $end2['minute'], 'enddate2_ampm' => $end2['ampm'], 'recurring_format_options' => EVLIST_GetOptions($LANG_EVLIST['rec_formats'], $option), 'recurring_weekday_options' => EVLIST_GetOptions(Date_Calc::getWeekDays(), $recweekday, 1), 'dailystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['day_by_date'], ''), 'monthlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'yearlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year'], $LANG_EVLIST['if_any']), 'listdays_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['days_of_week'], ''), 'listdaystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['date_l'], $LANG_EVLIST['if_any']), 'intervalstop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'custom_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['dates'], ''), 'datestart_note' => $LANG_EVLIST['datestart_note'], 'src' => isset($_GET['src']) && $_GET['src'] == 'a' ? '1' : '0', 'rem_status_checked' => $this->enable_reminders == 1 ? EVCHECKED : '', 'del_button' => $this->id == '' ? '' : 'true', 'saveaction' => $saveaction, 'delaction' => $delaction, 'owner_id' => $this->owner_id, 'enable_reminders' => $_EV_CONF['enable_reminders'], 'iso_lang' => EVLIST_getIsoLang(), 'hour_mode' => $_CONF['hour_mode'], 'days_interval' => $days_interval, 'display_format' => $_CONF['shortdate'], 'ts_start' => strtotime($this->date_start1), 'ts_end' => strtotime($this->date_end1), 'cal_select' => $cal_select, 'contactlink_chk' => $this->options['contactlink'] == 1 ? EVCHECKED : '', 'lat' => $this->Detail->lat, 'lng' => $this->Detail->lng, 'perm_msg' => $LANG_ACCESS['permmsg'], 'last' => $LANG_EVLIST['rec_intervals'][5], 'doc_url' => EVLIST_getDocURL('event.html'), 'mootools' => $_SYSTEM['disable_mootools'] ? '' : 'true'));
     if ($_EV_CONF['enable_rsvp']) {
         USES_evlist_class_tickettype();
         $TickTypes = evTicketType::GetTicketTypes();
         //$T->set_block('editor', 'Tickets', 'tTypes');
         $tick_opts = '';
         foreach ($TickTypes as $tick_id => $tick_obj) {
             // Check enabled tickets. Ticket type 1 enabled by default
             if (isset($this->options['tickets'][$tick_id]) || $tick_id == 1) {
                 $checked = 'checked="checked"';
                 $fee = (double) $this->options['tickets'][$tick_id]['fee'];
             } else {
                 $checked = '';
                 $fee = 0;
             }
             $tick_opts .= '<tr><td><input name="tickets[' . $tick_id . ']" type="checkbox" ' . $checked . ' value="' . $tick_id . '" /></td>' . '<td>' . $tick_obj->description . '</td>' . '<td><input type="text" name="tick_fees[' . $tick_id . ']" value="' . $fee . '" size="8" /></td></tr>' . LB;
             /*$T->set_var(array(
                   'tick_id' => $tic['id'],
                   'tick_desc' => $tic['description'],
                   'tick_fee' => $fee,
                   'tick_enabled' => $enabled ? 'checked="checked"' : '',
               ) ) ;
               //$T->parse('tTypes', 'Tickets', true);*/
         }
         if ($_EV_CONF['rsvp_print'] > 0) {
             $rsvp_print_chk = 'rsvp_print_chk' . $this->options['rsvp_print'];
             $rsvp_print = 'true';
         } else {
             $rsvp_print = '';
             $rsvp_print_chk = 'no_rsvp_print';
         }
         $T->set_var(array('enable_rsvp' => 'true', 'reg_chk' . $this->options['use_rsvp'] => EVCHECKED, 'rsvp_wait_chk' => $this->options['rsvp_waitlist'] == 1 ? EVCHECKED : '', 'max_rsvp' => $this->options['max_rsvp'], 'max_user_rsvp' => $this->options['max_user_rsvp'], 'rsvp_cutoff' => $this->options['rsvp_cutoff'], 'use_rsvp' => $this->options['use_rsvp'], 'rsvp_waitlist' => $this->options['rsvp_waitlist'], 'tick_opts' => $tick_opts, 'rsvp_print' => $rsvp_print, $rsvp_print_chk => 'checked="checked"'));
     }
     // if rsvp_enabled
     // Split & All-Day settings
     if ($this->allday == 1) {
         // allday, can't be split, no times
         $T->set_var(array('starttime1_show' => 'style="display:none;"', 'endtime1_show' => 'style="display:none;"', 'datetime2_show' => 'style="display:none;"', 'allday_checked' => EVCHECKED, 'split_checked' => '', 'split_show' => 'style="display:none;"'));
     } elseif ($this->split == '1') {
         $T->set_var(array('split_checked' => EVCHECKED, 'allday_checked' => '', 'allday_show' => 'style="display:none"'));
     } else {
         $T->set_var(array('datetime2_show' => 'style="display:none;"'));
     }
     // Category fields. If $_POST['categories'] is set, then this is a
     // form re-entry due to an error saving. Populate checkboxes from the
     // submitted form. Include the user-added category, if any.
     // If not from a form re-entry, get the checked categories from the
     // evlist_lookup table.
     if ($_EV_CONF['enable_categories'] == '1') {
         $cresult = DB_query("SELECT tc.id, tc.name\n                FROM {$_TABLES['evlist_categories']} tc \n                WHERE tc.status='1' ORDER BY tc.name");
         while ($A = DB_fetchArray($cresult, false)) {
             if (isset($_POST['categories']) && is_array($_POST['categories'])) {
                 // Coming from a form re-entry
                 $chk = in_array($A['id'], $_POST['categories']) ? EVCHECKED : '';
             } else {
                 $chk = in_array($A['id'], $this->categories) ? EVCHECKED : '';
             }
             $catlist .= '<input type="checkbox" name="categories[]" ' . 'value="' . $A['id'] . '" ' . $chk . ' />' . '&nbsp;' . $A['name'] . '&nbsp;&nbsp;';
         }
         $T->set_var('catlist', $catlist);
         if (isset($_POST['newcat'])) {
             $T->set_var('newcat', $_POST['newcat']);
         }
         if ($_USER['uid'] > 1 && $rp_id == 0) {
             $T->set_var('category_section', 'true');
             $T->set_var('add_cat_input', 'true');
         }
     }
     // Enable the post mode selector if we allow HTML and the user is
     // logged in, or if this user is an authorized editor
     if ($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) {
         $T->set_var(array('postmode_options' => EVLIST_GetOptions($LANG_EVLIST['postmodes'], $postmode), 'allowed_html' => COM_allowedHTML('evlist.submit')));
         if ($postmode == 'plaintext') {
             // plaintext, hide postmode selector
             $T->set_var('postmode_show', ' style="display:none"');
         }
         $T->parse('event_postmode', 'edit_postmode');
     }
     if ($this->isAdmin) {
         $T->set_var(array('owner_username' => COM_stripslashes($ownerusername), 'owner_dropdown' => COM_optionList($_TABLES['users'], 'uid,username', $this->owner_id, 1, "uid <> 1"), 'group_dropdown' => SEC_getGroupDropdown($this->group_id, 3)));
         if ($rp_id == 0) {
             // can only change permissions on main event
             $T->set_var('permissions_editor', SEC_getPermissionsHTML($this->perm_owner, $this->perm_group, $this->perm_members, $this->perm_anon));
         }
     } else {
         $T->set_var('group_id', $this->group_id);
     }
     // Latitude & Longitude part of location, if Location plugin is used
     if ($_EV_CONF['use_locator']) {
         $T->set_var(array('use_locator' => 'true', 'loc_selection' => GEO_optionList()));
     }
     $T->parse('output', 'editor');
     $retval .= $T->finish($T->get_var('output'));
     $retval .= COM_endBlock();
     return $retval;
 }