array_push($friends_array, $add); } $friends = __wps__sub_val_sort($friends_array, 'last_activity', false); } else { $friends = false; } if ($friends) { foreach ($friends as $friend) { $time_now = time(); if ($friend['last_activity'] && $friend['status'] != 'offline') { $last_active_minutes = __wps__convert_datetime($friend['last_activity']); $last_active_minutes = floor(($time_now-$last_active_minutes)/60); } else { $last_active_minutes = 999999999; } if (!get_option(WPS_OPTIONS_PREFIX.'wps_panel_offline') && ($last_active_minutes >= $offline)) { // Don't include offline members, and this member is offline } else { $return .= "<div style='clear:both; margin-top:4px; overflow: auto;overflow-y:hidden;'>"; $return .= "<div style='float: left; width:15px; padding-left:4px;'>"; if ($last_active_minutes >= $offline) { $return .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/loggedout.gif' alt='Logged Out'>"; } else { $friends_online++;
array_push($comment_array, $add); } $comments = __wps__sub_val_sort($comment_array, 'lid', false); // Prepare to return comments in JSON format $return_arr = array(); // Loop through comments, adding to array if any exist if ($comments) { foreach ($comments as $comment) { // Work out if they are active or not $time_now = time(); if ($comment['last_activity'] && $comment['status'] != 'offline') { $last_active_minutes = __wps__convert_datetime($comment['last_activity']); $last_active_minutes = floor(($time_now-$last_active_minutes)/60); } else { $last_active_minutes = 999999999; } if ($last_active_minutes >= $offline) { $row_array['status'] = 'loggedout'; } else { if ($last_active_minutes >= $inactive) { $row_array['status'] = 'inactive'; } else { $row_array['status'] = 'online'; } } $row_array['lid'] = $comment['lid'];
if ($event->event_google_map == 'on') { $html .= "<div id='event_google_profile_map' style='float:right; margin-left:5px; width:128px; height:128px'>"; $html .= '<a target="_blank" href="http://maps.google.co.uk/maps?f=q&source=embed&hl=en&geocode=&q='.$event->event_location.'&ie=UTF8&hq=&hnear='.$event->event_location.'&output=embed&z=5" alt="Click on map to enlarge" title="Click on map to enlarge">'; $html .= '<img src="http://maps.google.com/maps/api/staticmap?center='.$event->event_location.'&zoom=5&size=128x128&maptype=roadmap&markers=color:blue|label: |'.$event->event_location.'&sensor=false" />'; $html .= "</a></div>"; } $html .= str_replace(PHP_EOL, '<br />',stripslashes($event->event_description)); $html .= '</div>'; $html .= '<div class="__wps__event_list_dates">'; if ($event->event_start != '0000-00-00 00:00:00') { $html .= date_i18n("D, d M Y", __wps__convert_datetime($event->event_start)); } if ($event->event_start != $event->event_end) { if ($event->event_end != '0000-00-00 00:00:00') { $html .= ' → '; $html .= date_i18n("D, d M Y", __wps__convert_datetime($event->event_end)); } } $html .= '</div>'; $html .= '<div class="__wps__event_list_times">'; if ($event->event_start_hours != 99) { $html .= __('Start: ', WPS_TEXT_DOMAIN).$event->event_start_hours.":".sprintf('%1$02d', $event->event_start_minutes); } if ($event->event_end_hours != 99) { $html .= ' '.__('End: ', WPS_TEXT_DOMAIN).$event->event_end_hours.":".sprintf('%1$02d', $event->event_end_minutes); } $html .= '</div>'; if ($event->event_more) { $content = stripslashes($event->event_more);
function __wps__events_main() { global $wpdb, $current_user; $html = '<div class="__wps__wrapper">'; // Content $include = get_option(WPS_OPTIONS_PREFIX."_events_global_list"); // get events $html .= '<div id="__wps__events_list" style="width:95%">'; if (get_option(WPS_OPTIONS_PREFIX."_events_hide_expired")) { $hide = "(event_start >= now() OR event_start = '0000-00-00 00:00:00') AND"; } else { $hide = ''; } if ($include) { $sql = "SELECT e.*, u.ID, u.display_name FROM ".$wpdb->base_prefix."symposium_events e LEFT JOIN ".$wpdb->base_prefix."users u ON event_owner = ID WHERE ".$hide." event_owner IN (".$include.") AND event_live = %s ORDER BY event_start"; } else { $sql = "SELECT e.*, u.ID, u.display_name FROM ".$wpdb->base_prefix."symposium_events e LEFT JOIN ".$wpdb->base_prefix."users u ON event_owner = ID WHERE ".$hide." event_live = %s ORDER BY event_start"; } if (get_option(WPS_OPTIONS_PREFIX."_events_sort_order")) $sql .= " DESC"; $events = $wpdb->get_results($wpdb->prepare($sql, 'on')); if (WPS_DEBUG) $html .= $wpdb->last_query; if ($events) { if (get_option(WPS_OPTIONS_PREFIX.'_events_calendar') == "calendar") { // Calendar view $html .= '<div id="__wps__events_calendar"></div>'; } else { // List view foreach ($events as $event) { $html .= '<div class="__wps__event_list_item row">'; if ($event->event_google_map == 'on') { $html .= "<div id='event_google_profile_map' style='float:right; margin-left:5px; width:128px; height:128px'>"; $html .= '<a target="_blank" href="http://maps.google.co.uk/maps?f=q&source=embed&hl=en&geocode=&q='.$event->event_location.'&ie=UTF8&hq=&hnear='.$event->event_location.'&output=embed&z=5" alt="Click on map to enlarge" title="Click on map to enlarge">'; $html .= '<img src="http://maps.google.com/maps/api/staticmap?center='.$event->event_location.'&zoom=5&size=128x128&maptype=roadmap&markers=color:blue|label: |'.$event->event_location.'&sensor=false" />'; $html .= "</a></div>"; } if ( ($event->event_owner == $current_user->ID) || (__wps__get_current_userlevel() == 5) ) { $html .= "<div class='__wps__event_list_item_icons'>"; if ($event->event_live != 'on') { $html .= '<div style="font-style:italic;float:right;">'.__('Edit to publish', WPS_TEXT_DOMAIN).'</div>'; } $html .= "<a href='javascript:void(0)' class='symposium_delete_event floatright link_cursor' style='display:none;margin-right: 5px' id='".$event->eid."'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' /></a>"; $html .= "<a href='javascript:void(0)' class='__wps__edit_event floatright link_cursor' style='display:none;margin-right: 5px' id='".$event->eid."'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/edit.png' /></a>"; $html .= "</div>"; } $html .= '<div class="__wps__event_list_owner">'.__("Added by", WPS_TEXT_DOMAIN)." ".__wps__profile_link($event->ID).'</div>'; $html .= '<div class="__wps__event_list_name">'.stripslashes($event->event_name).'</div>'; $html .= '<div class="__wps__event_list_location">'.stripslashes($event->event_location).'</div>'; if ($event->event_enable_places && $event->event_show_max) { $sql = "SELECT SUM(tickets) FROM ".$wpdb->base_prefix."symposium_events_bookings WHERE event_id = %d"; $taken = $wpdb->get_var($wpdb->prepare($sql, $event->eid)); $html .= '<div class="__wps__event_list_places">'; if ($event->event_max_places-$taken > 0) { $html .= __('Tickets left:', WPS_TEXT_DOMAIN).' '.($event->event_max_places-$taken); } else { $html .= __('Event full', WPS_TEXT_DOMAIN); } $html .= '</div>'; } if (isset($event->event_cost) && $event->event_cost !== null) { $html .= '<div class="symposium_event_cost">'.__('Cost per ticket:', WPS_TEXT_DOMAIN).' '.$event->event_cost.'</div>'; } $html .= '<div class="__wps__event_list_description">'; $html .= stripslashes($event->event_description); $html .= '</div>'; $html .= '<div class="__wps__event_list_dates">'; if ($event->event_start != '0000-00-00 00:00:00') { $html .= date_i18n("D, d M Y", __wps__convert_datetime($event->event_start)); } if ($event->event_start != $event->event_end) { if ($event->event_end != '0000-00-00 00:00:00') { $html .= ' → '; $html .= date_i18n("D, d M Y", __wps__convert_datetime($event->event_end)); } } $html .= '</div>'; $html .= '<div class="__wps__event_list_times">'; if ($event->event_start_hours != 99) { $html .= __('Start: ', WPS_TEXT_DOMAIN).$event->event_start_hours.":".sprintf('%1$02d', $event->event_start_minutes); } if ($event->event_end_hours != 99) { $html .= ' '.__('End: ', WPS_TEXT_DOMAIN).$event->event_end_hours.":".sprintf('%1$02d', $event->event_end_minutes); } $html .= '</div>'; $html .= '<div>'; if ($event->event_more) { $more = str_replace(chr(10), '<br />', stripslashes($event->event_more)); $html .= '<div id="symposium_more_'.$event->eid.'" title="'.stripslashes($event->event_name).'" class="__wps__dialog_content"><div style="text-align:left">'.$more.'</div></div>'; $html .= '<input type="submit" id="symposium_event_more" rel="symposium_more_'.$event->eid.'" class="symposium-dialog __wps__button" value="'.__("More info", WPS_TEXT_DOMAIN).'" />'; } if (is_user_logged_in() && $event->event_enable_places) { // check to see if already booked $sql = "select b.tickets, b.confirmed, b.bid, b.payment_processed, e.event_cost FROM ".$wpdb->base_prefix."symposium_events_bookings b LEFT JOIN ".$wpdb->base_prefix."symposium_events e ON b.event_id = e.eid WHERE event_id = %d AND uid = %d"; $ret = $wpdb->get_row($wpdb->prepare($sql, $event->eid, $current_user->ID)); if (!$ret || !$ret->tickets) { if ($event->event_max_places-$taken > 0) $html .= '<input type="submit" id="symposium_book_event" data-eid="'.$event->eid.'" data-max="'.$event->event_tickets_per_booking.'" class="__wps__button symposium_book_event_button" value="'.__("Book", WPS_TEXT_DOMAIN).'" />'; } else { $html .= '<input type="submit" id="symposium_cancel_event" data-eid="'.$event->eid.'" class="__wps__button symposium_cancel_event_button" value="'.__("Cancel", WPS_TEXT_DOMAIN).'" />'; } if ($ret && !$ret->confirmed && !$ret->payment_processed && $ret->tickets && $ret->event_cost) $html .= '<input type="submit" id="symposium_pay_event" data-bid="'.$ret->bid.'" style="margin-left:5px" class="__wps__button" value="'.__("Payment", WPS_TEXT_DOMAIN).'" />'; if ($ret && $ret->tickets ) { if ($ret->confirmed) { $html .= '<br />'.sprintf(_n('Confirmed by the event organiser for %d ticket.','Confirmed by the event organiser for %d tickets.', $ret->tickets, WPS_TEXT_DOMAIN), $ret->tickets); } else { $html .= '<br />'.sprintf(_n('Awaiting confirmation from the organiser for %d ticket.','Awaiting confirmation from the organiser for %d tickets.', $ret->tickets, WPS_TEXT_DOMAIN), $ret->tickets); } } } $html .= '</div>'; $html .= '</div>'; } } } else { $html .= __('No events yet.', WPS_TEXT_DOMAIN); } $html .= '</div>'; $html .= '</div>'; // This filter allows others to filter content $html = apply_filters ( '__wps__events_shortcode_filter', $html); // Send HTML return $html; }