示例#1
0
 /**
  *   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
文件: index.php 项目: matrox66/evlist
     USES_evlist_class_category();
     $C = new evCategory($_GET['id']);
     $content .= $C->Edit();
     break;
 case 'editticket':
     if ($_EV_CONF['enable_rsvp']) {
         USES_evlist_class_tickettype();
         $Tic = new evTicketType($actionval);
         $content .= $Tic->Edit();
     }
     break;
 case 'rsvp':
     USES_evlist_functions();
     $rp_id = isset($_POST['rp_id']) && !empty($_POST['rp_id']) ? $_POST['rp_id'] : isset($_GET['rp_id']) && !empty($_GET['rp_id']) ? $_GET['rp_id'] : 0;
     if ($rp_id > 0) {
         $content .= EVLIST_adminRSVP($rp_id);
     }
     break;
 case 'import':
     $T = new Template(EVLIST_PI_PATH . '/templates/');
     $T->set_file('form', 'import_events.thtml');
     $T->parse('output', 'form');
     $content .= $T->finish($T->get_var('output'));
     break;
 case 'edit':
     USES_evlist_class_event();
     $Ev = new evEvent($_REQUEST['eid']);
     $Ev->AdminMode = $admin;
     $content .= $Ev->Edit('', $rp_id, 'save' . $actionval);
     break;
 default: