示例#1
0
function __wps__getTopic($topic_id, $group_id=0, $pagination=9999, $page=1) {

	global $wpdb, $current_user, $blog_id;	

	$html = '';
	
	$plugin = WP_CONTENT_URL.'/plugins/wp-symposium/';
	
	$previous_login = __wps__get_meta($current_user->ID, 'previous_login');

	$level = __wps__get_current_userlevel();

	// Check permissions
	$user = get_userdata( $current_user->ID );
	$can_view = false;
	$viewer = str_replace('_', '', str_replace(' ', '', strtolower(get_option(WPS_OPTIONS_PREFIX.'_viewer'))));
	if ($user) {
		$capabilities = $user->{$wpdb->prefix.'capabilities'};
	
		// Can view topic?
		if ($capabilities) {
			foreach ( $capabilities as $role => $name ) {
				if ($role) {
					$role = strtolower($role);
					$role = str_replace(' ', '', $role);
					$role = str_replace('_', '', $role);
					if (WPS_DEBUG) $html .= 'Checking view role '.$role.' against '.$viewer.'<br />';
					if (strpos($viewer, $role) !== FALSE) $can_view = true;
					if (WPS_DEBUG && $can_view) $html .= "CAN VIEW<br />";
				}
			}		 														
		}
	}
	$everyone = str_replace(' ', '', __('everyone', WPS_TEXT_DOMAIN)); // Handle some non-English translations of 'everyone'
	if (strpos($viewer, $everyone) !== FALSE) $can_view = true;
	
	// Can create topic?
	$can_edit = false;
	$viewer = str_replace('_', '', str_replace(' ', '', strtolower(get_option(WPS_OPTIONS_PREFIX.'_forum_editor'))));
	if ($user && $capabilities) {
		foreach ( $capabilities as $role => $name ) {
			if ($role) {
				$role = strtolower($role);
				$role = str_replace(' ', '', $role);
				$role = str_replace('_', '', $role);
				if (WPS_DEBUG) $html .= 'Checking create role '.$role.' against '.$viewer.'<br />';
				if (strpos($viewer, $role) !== FALSE) $can_edit = true;
				if (WPS_DEBUG && $can_edit) $html .= "CAN EDIT<br />";
			}
		}		 														
	}
	if (strpos($viewer, __('everyone', WPS_TEXT_DOMAIN)) !== FALSE) $can_edit = true;
	if ($group_id > 0) {
		$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_group_members WHERE group_id=%d AND valid='on' AND member_id=%d";
		$member_count = $wpdb->get_var($wpdb->prepare($sql, $group_id, $current_user->ID));
		if ($member_count == 0) { $can_edit = false; } else { $can_edit = true; }
	}

	// Can reply to a topic?
	$can_reply = false;
	$viewer = str_replace('_', '', str_replace(' ', '', strtolower(get_option(WPS_OPTIONS_PREFIX.'_forum_reply'))));
	if ($user && $capabilities) {
		foreach ( $capabilities as $role => $name ) {
			if ($role) {
				$role = strtolower($role);
				$role = str_replace(' ', '', $role);
				$role = str_replace('_', '', $role);
				if (WPS_DEBUG) $html .= 'Checking reply role '.$role.' against '.$viewer.'<br />';
				if (strpos($viewer, $role) !== FALSE) $can_reply = true;
				if (WPS_DEBUG && $can_reply) $html .= "CAN REPLY<br />";
			}
		}		 														
	}
	if (strpos($viewer, __('everyone', WPS_TEXT_DOMAIN)) !== FALSE) $can_reply = true;
	if ($group_id > 0) {
		$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_group_members WHERE group_id=%d AND valid='on' AND member_id=%d";
		$member_count = $wpdb->get_var($wpdb->prepare($sql, $group_id, $current_user->ID));
		if ($member_count == 0) { $can_reply = false; } else { $can_reply = true; }
	}
	// check for allow replies setting on forum
	$can_reply_switch = $wpdb->get_var($wpdb->prepare("SELECT allow_replies FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d", $topic_id));

	// Can add a comment to a reply?
	$can_comment = false;
	$viewer = str_replace('_', '', str_replace(' ', '', strtolower(get_option(WPS_OPTIONS_PREFIX.'_forum_reply_comment'))));
	if ($user && $capabilities) {
		foreach ( $capabilities as $role => $name ) {
			if ($role) {
				$role = strtolower($role);
				$role = str_replace(' ', '', $role);
				$role = str_replace('_', '', $role);
				if (WPS_DEBUG) $html .= 'Checking reply comment role '.$role.' against '.$viewer.'<br />';
				if (strpos($viewer, $role) !== FALSE) $can_comment = true;
				if (WPS_DEBUG && $can_comment) $html .= "CAN COMMENT<br />";
			}
		}		 														
	}
	if (strpos($viewer, __('everyone', WPS_TEXT_DOMAIN)) !== FALSE) $can_comment = true;
	if ($group_id > 0) {
		$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_group_members WHERE group_id=%d AND valid='on' AND member_id=%d";
		$member_count = $wpdb->get_var($wpdb->prepare($sql, $group_id, $current_user->ID));
		if ($member_count == 0) { $can_comment = false; } else { $can_comment = true; }
	}


	// Get list of roles for this user
	global $current_user;
    $user_roles = $current_user->roles;
    $user_role = strtolower(array_shift($user_roles));
    $user_role = str_replace('_', '', str_replace(' ', '', $user_role));
    if ($user_role == '') $user_role = 'NONE';

	// Get list of permitted roles from forum_cat and check allowed for this topic's category
	$sql = "SELECT topic_category FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d";
	$category = $wpdb->get_var($wpdb->prepare($sql, $topic_id));
	$sql = "SELECT level FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d";
	$level = $wpdb->get_var($wpdb->prepare($sql, $category));
	$cat_roles = unserialize($level);
    $cat_roles = str_replace('_', '', str_replace(' ', '', $cat_roles));

	if ($group_id > 0) {
		if (__wps__member_of($group_id) != "yes") $can_view = false;
	} else {
		if (strpos(strtolower($cat_roles), 'everyone,') !== FALSE || strpos(strtolower($cat_roles), $user_role.',') !== FALSE) {
			// can view
		} else {
			$can_view = false;
		}
	}

	if ( $can_view ) {

		// Get forum URL worked out
		$forum_url = __wps__get_url('forum');
		if (strpos($forum_url, '?') !== FALSE) {
			$q = "&";
		} else {
			$q = "?";
		}
		// Get group URL worked out
		if ($group_id > 0) {
			$forum_url = __wps__get_url('group');
			if (strpos($forum_url, '?') !== FALSE) {
				$q = "&gid=".$group_id."&";
			} else {
				$q = "?gid=".$group_id."&";
			}
		}
		
		$post = $wpdb->get_row($wpdb->prepare("
			SELECT tid, topic_subject, topic_approved, topic_category, topic_post, topic_started, display_name, topic_sticky, topic_owner, for_info 
			FROM ".$wpdb->prefix."symposium_topics t INNER JOIN ".$wpdb->base_prefix."users u ON t.topic_owner = u.ID 
			WHERE (t.topic_approved = 'on' OR t.topic_owner = %d) AND tid = %d", $current_user->ID, $topic_id));
		
		if ($post) {

			// Store removal limit for votes
			$html .= '<div id="symposium_forum_vote_remove" style="display:none">'.get_option(WPS_OPTIONS_PREFIX.'_use_votes_remove').'</div>';
			$html .= '<div id="symposium_forum_vote_remove_msg" style="display:none">'.__('This post has been voted off the forum', WPS_TEXT_DOMAIN).'</div>';
		

			$html .= '<div id="__wps__forum_topic_header">';

				// Breadcrumbs
				$cat_id = $post->topic_category;

				$breadcrumbs = $wpdb->get_row($wpdb->prepare("SELECT title, hide_breadcrumbs FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d", $cat_id));
				if ($breadcrumbs->hide_breadcrumbs == 'on') {

					$html .= '<div id="topic_breadcrumbs" class="breadcrumbs label">';

						$this_level = $wpdb->get_row($wpdb->prepare("SELECT cid, title, cat_parent, stub FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d", $cat_id));

						if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') { 
							$html .= '<a href="#cid='.$this_level->cid.'" class="category_title" title="'.$this_level->cid.'">'.__('Back to', WPS_TEXT_DOMAIN).' '.trim(stripslashes($this_level->title)).'</a>'; 
						} else { 
							if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
								$html .= '<a href="'.$forum_url.'/'.$this_level->stub.'" title="'.$this_level->cid.'">'.__('Back to', WPS_TEXT_DOMAIN).' '.trim(stripslashes($this_level->title)).'</a>'; 
							} else {
								$html .= '<a href="'.$forum_url.$q."cid=".$this_level->cid.'" title="'.$this_level->cid.'">'.__('Back to', WPS_TEXT_DOMAIN).' '.trim(stripslashes($this_level->title)).'</a>'; 
							}
						} 

					$html .= '</div>';

				} else {
						
					$html .= '<div id="topic_breadcrumbs" class="breadcrumbs label">';

						if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
							$this_level = $wpdb->get_row($wpdb->prepare("SELECT cid, title, cat_parent, stub FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d", $cat_id));
							if ($this_level) { 

								if ($this_level->cat_parent == 0) { 
									if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') { 
										$html .= '<a href="#cid=0" class="category_title" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
										$html .= '<a href="#cid='.$this_level->cid.'" class="category_title" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title)).'</a>'; 
									} else { 
										if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
											$html .= '<a href="'.$forum_url.'">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
											$html .= '<a href="'.$forum_url.'/'.$this_level->stub.'" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title)).'</a>'; 
										} else {
											$html .= '<a href="'.$forum_url.$q.'cid=0" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
											$html .= '<a href="'.$forum_url.$q."cid=".$this_level->cid.'" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title)).'</a>'; 
										}
									} 
								} else { 

									$parent_level = $wpdb->get_row($wpdb->prepare("SELECT cid, title, cat_parent, stub FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d", $this_level->cat_parent)); 

									if ($parent_level->cat_parent == 0) { 
										if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') { 
											$html .= '<a href="#cid=0" class="category_title" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
										} else { 
											if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
												$html .= '<a href="'.$forum_url.'" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
											} else {
												$html .= '<a href="'.$forum_url.$q.'cid=0" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; "; 
											}
										} 
									} else { 
										$parent_level_2 = $wpdb->get_row($wpdb->prepare("SELECT cid, title, cat_parent, stub FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d", $parent_level->cat_parent)); 
										if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') { 
											$html .= '<a href="#cid=0" class="category_title" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; " ; 
											$html .= '<a href="#cid='.$parent_level_2->cid.'" class="category_title" title="'.$parent_level_2->cid.'">'.trim(stripslashes($parent_level_2->title))."</a> &rarr; "; 
										} else { 
											if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
												$html .= '<a href="'.$forum_url.'" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; " ; 
												$html .= '<a href="'.$forum_url.'/'.$parent_level_2->stub.'" title="'.$parent_level_2->cid.'">'.trim(stripslashes($parent_level_2->title))."</a> &rarr; "; 
											} else {
												$html .= '<a href="'.$forum_url.$q.'cid=0" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; " ; 
												$html .= '<a href="'.$forum_url.$q."cid=".$parent_level_2->cid.'" title="'.$parent_level_2->cid.'">'.trim(stripslashes($parent_level_2->title))."</a> &rarr; "; 
											}
										} 
									} 
									if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') { 
										$html .= '<a href="#cid='.$parent_level->cid.'" class="category_title" title="'.$parent_level->cid.'">'.trim(stripslashes($parent_level->title))."</a> &rarr; " ; 
										$html .= '<a href="#cid='.$this_level->cid.'" class="category_title" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title))."</a>" ; 
									} else { 
										if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
											$html .= '<a href="'.$forum_url.'/'.$parent_level->stub.'" title="'.$parent_level->cid.'">'.trim(stripslashes($parent_level->title))."</a> &rarr; " ; 
											$html .= '<a href="'.$forum_url.'/'.$this_level->stub.'" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title))."</a>" ; 
										} else {
											$html .= '<a href="'.$forum_url.$q."cid=".$parent_level->cid.'" title="'.$parent_level->cid.'">'.trim(stripslashes($parent_level->title))."</a> &rarr; " ; 
											$html .= '<a href="'.$forum_url.$q."cid=".$this_level->cid.'" title="'.$this_level->cid.'">'.trim(stripslashes($this_level->title))."</a>" ; 
										}
									} 
								} 
							} else {
								if (get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') == 'on') {
									$html .= '&larr; <a href="#cid=0" class="category_title" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a>";
								} else {
									if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
										$html .= '&larr; <a href="'.$forum_url.'" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a>";
									} else {
										$html .= '&larr; <a href="'.$forum_url.$q.'cid=0" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a>";
									}
								}
							}

						} else {
							// Lite mode
							$html .= '<a href="#cid=0" class="category_title" title="0">'.__('Forum Home', WPS_TEXT_DOMAIN)."</a> &rarr; ";
							$html .= '<a href="#cid='.$post->topic_category.'" class="category_title" title="'.$post->topic_category.'">'.__('Topic list', WPS_TEXT_DOMAIN).'</a>';
						}
										
					$html .= '</div>';

				}
						
				// Quick jump, subscribe, Sticky and Allow Replies
				if (is_user_logged_in()) {
					$html .= "<div id='__wps__topic_options' class='label' style='width:95%;'>";

						$html .= '<div style="float:left; text-align:right;margin-bottom:6px;">';
							if (get_option(WPS_OPTIONS_PREFIX.'_suppress_forum_notify') != "on") {
								$forum_all = __wps__get_meta($current_user->ID, 'forum_all');
								$html .= "<input type='checkbox' title='".$post->tid."' id='subscribe' name='subscribe'";
								if ($forum_all == 'on') {
									$html .= " style='display:none;'";
								}
								$subscribed_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_subs WHERE tid = %d and uid = %d", $post->tid, $current_user->ID));
								if ($subscribed_count > 0) { $html .= ' checked'; } 
								$html .= "> ";
								if ($forum_all != 'on') {
									$html .= __("Tell me about replies", WPS_TEXT_DOMAIN)."&nbsp;&nbsp;&nbsp;";
								}
							}
							if (current_user_can('level_10')) {
								$html .= "<input type='checkbox' title='".$post->tid."' id='sticky' name='sticky'";
								if ($post->topic_sticky > 0) { $html .= ' checked'; }
								$html .= "> ".__("Sticky", WPS_TEXT_DOMAIN);
								$html .= "&nbsp;&nbsp;&nbsp;<input type='checkbox' title='".$post->tid."' id='replies' name='replies'";
								$allow_replies = $wpdb->get_var($wpdb->prepare("SELECT allow_replies FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d", $post->tid));
								if ($allow_replies == "on") { $html .= ' checked'; }
								$html .= "> ".__("Replies allowed", WPS_TEXT_DOMAIN);
							}
						$html .= '</div>';

						// Add Quickjump drop-down list
						if (get_option(WPS_OPTIONS_PREFIX.'_show_dropdown') && !$group_id)
							$html .= '<div style="float:right;">'.__wps__forum_dropdown($cat_id, $topic_id, $group_id).'</div>';				


					$html .= "</div>";
				}

				// Forum options
				$html .= "<div id='forum_options'>";

					$html .= "<a id='show_search' href='javascript:void(0)'>".__("Search", WPS_TEXT_DOMAIN)."</a>";
					$html .= "&nbsp;&nbsp;&nbsp;&nbsp;<a id='show_all_activity' href='javascript:void(0)'>".__("Activity", WPS_TEXT_DOMAIN)."</a>";
					$html .= "&nbsp;&nbsp;&nbsp;&nbsp;<a id='show_threads_activity' href='javascript:void(0)'>".__("Latest Topics", WPS_TEXT_DOMAIN)."</a>";

					if (is_user_logged_in()) {
						$html .= "&nbsp;&nbsp;&nbsp;&nbsp;<a id='show_activity' href='javascript:void(0)'>".__("My Activity", WPS_TEXT_DOMAIN)."</a>";
						$html .= "&nbsp;&nbsp;&nbsp;&nbsp;<a id='show_favs' href='javascript:void(0)'>".__("Favorites", WPS_TEXT_DOMAIN)."</a>";
					}

				$html .= "</div>";
				
				// Sharing icons
				if (get_option(WPS_OPTIONS_PREFIX.'_sharing') != '') {
					$html .= __wps__show_sharing_icons($cat_id, $post->tid, get_option(WPS_OPTIONS_PREFIX.'_sharing'), $group_id);
				}
			
				// Edit Form
				$html .= '<div id="edit-topic-div">';

					$html .= '<div class="new-topic-subject label">'.__("Topic Subject", WPS_TEXT_DOMAIN).'</div>';
					$html .= '<div id="'.$post->tid.'" class="edit-topic-tid"></div>';
					$html .= '<div id="" class="edit-topic-parent"></div>';
					$html .= '<input class="new-topic-subject-input" type="text" name="edit_topic_subject">';
					$html .= '<div class="new-topic-subject label">'.__("Topic Text", WPS_TEXT_DOMAIN).'</div>';
					$html .= __wps__bbcode_toolbar('edit_topic_text');
					$html .= '<textarea class="new-topic-subject-text" id="edit_topic_text" name="edit_topic_text"></textarea>';
					if ($group_id == 0) {
						$html .= '<div class="new-category-div" style="float:left;">'.__("Move Category", WPS_TEXT_DOMAIN).': <select name="new-category" class="new-category" style="width: 200px">';
						$html .= '<option value="">'.__("Select", WPS_TEXT_DOMAIN).'...</option>';
						$categories = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix.'symposium_cats ORDER BY listorder');			
						if ($categories) {
							foreach ($categories as $category) {
								if ($category->allow_new == "on" || current_user_can('level_10')) {
									$html .= '<option value='.$category->cid.'>'.stripslashes($category->title).'</option>';
								}
							}
						}
						$html .= '</select></div>';
					} else {
						// No categories for groups
						$html .= '<input name="new-category" type="hidden" value="0">';
					}

				$html .= '</div>';

			$html .= "</div>"; // __wps__forum_topic_header				

			// Topic starting post
			$html .= "<div id='starting-post'>";
		
				// Show topic header
				$html .= "<div id='top_of_first_post'>";
			
					$html .= "<div class='avatar' style='margin-bottom:0px; margin-top:6px;'>";
						$html .= get_avatar($post->topic_owner, 64);

						if (get_option(WPS_OPTIONS_PREFIX.'_forum_info')) {
						
							$html .= "<div class='forum_info'>";
							
								$sql = "SELECT count(*) FROM ".$wpdb->prefix."symposium_topics WHERE topic_owner = %d";
								$count = $wpdb->get_var($wpdb->prepare($sql, $post->topic_owner));
								$html .= __('Posts:', WPS_TEXT_DOMAIN).' ';
								$html .= '<span class="forum_info_numbers">'.$count.'</span>';

							$html .= "</div>";	
						
							if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on') {
								$html .= "<div class='forum_info'>";
									// Get widget settings (also used under Replies)
									$settings = get_option("widget_forumexperts-widget");
									if (isset($settings[2]['timescale'])) {
										if (WPS_DEBUG) $html .= 'Getting Widget settings<br />';
										$timescale = $settings[2]['timescale'];
										$w_cat_id = $settings[2]['cat_id'];
										$cat_id_exclude = $settings[2]['cat_id_exclude'];
										$groups = $settings[2]['groups'];
									} else {
										if (WPS_DEBUG) $html .= 'Using default settings<br />';
										$timescale = 7;
										$w_cat_id = '';
										$cat_id_exclude = '';
										$groups = '';
									}
									// Now get value of rating (how many answers during timescale)
									$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_topics WHERE topic_owner = %d AND topic_answer = 'on' ";
									$sql .= "AND topic_date >= ( CURDATE() - INTERVAL ".$timescale." DAY )";
									if ($w_cat_id != '' && $w_cat_id > 0) {
										$sql .= "AND topic_category IN (".$w_cat_id.") ";
									}
									if ($cat_id_exclude != '' && $cat_id_exclude > 0) {
										$sql .= "AND topic_category NOT IN (".$cat_id_exclude.") ";
									}
									if ($groups != 'on') {
										$sql .= "AND topic_group = 0 ";
									}								
									$count = $wpdb->get_var($wpdb->prepare($sql, $post->topic_owner));
									if ($count > 0) {
										$html .= __('Rating:', WPS_TEXT_DOMAIN).' ';
										$html .= '<span class="forum_info_numbers">'.$count.'</span>';
									}
									if (WPS_DEBUG) $html .= $wpdb->last_query;
								$html .= "</div>";
							}

							if ($post->topic_started > $previous_login && $post->topic_owner != $current_user->ID && is_user_logged_in() && get_option(WPS_OPTIONS_PREFIX.'_forum_stars')) {
								$html .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/new.gif' alt='New!' /> ";
							}
						}
						
					$html .= "</div>";
			
					$html .= "<div class='topic-post-header-with-fav'>";
			
						$html .= "<div class='topic-post-header'>";

							if (get_option(WPS_OPTIONS_PREFIX.'_allow_reports') == 'on') {
								$html .= "<a href='javascript:void(0)' title='forum_".$post->tid."' class='report label symposium_report' style='display:none; cursor:pointer'><div class='topic-edit-icon' style='margin-top:-5px;' ><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/warning.png' /></div></a>";
							}
							$reply_posted_time = strtotime($post->topic_started);
							$reply_posted_expire = $reply_posted_time + (get_option(WPS_OPTIONS_PREFIX.'_forum_lock') * 60);
							$now = time();
							$seconds_left = $reply_posted_expire - $now;
							if ($seconds_left > 0) {
								$title = __('Lock in', WPS_TEXT_DOMAIN).' '.gmdate("H:i:s", $seconds_left);
							} else {
								$title = __('Admin only', WPS_TEXT_DOMAIN);
							}
							if (get_option(WPS_OPTIONS_PREFIX.'_forum_lock') == 0) {
								$title = __('No lock time', WPS_TEXT_DOMAIN);
								$seconds_left = 1;
							}
							if ( ($post->topic_owner == $current_user->ID && $seconds_left > 0) || (can_manage_forum()) ) {
								$now = date('Y-m-d H:i:s', time() - get_option(WPS_OPTIONS_PREFIX.'_forum_lock') * 60);
								if ( (get_option(WPS_OPTIONS_PREFIX.'_forum_lock')==0) || ($post->topic_started > $now) || (can_manage_forum()) ) {
									$html .= "<a href='javascript:void(0)' title='".$post->tid."' id='edit-this-topic' class='edit_topic edit label' style='cursor:pointer'><div class='topic-edit-icon'><img title='".$title."' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/edit.png' /></div></a>";
								}
							}

							$post_text = stripslashes(__wps__bbcode_replace(stripslashes($post->topic_subject)));
							// Make any shortcodes safe
							$post_text = str_replace("[", "&#91;", $post_text);
							$post_text = str_replace("]", "&#93;", $post_text);
							$html .= $post_text;
							$topic_subject = $post_text;
			
							if ($post->topic_approved != 'on') { $html .= " <em>[".__("pending approval", WPS_TEXT_DOMAIN)."]</em>"; }

							// Favourites
							if (is_user_logged_in()) {
								if (strpos(__wps__get_meta($current_user->ID, 'forum_favs'), "[".$post->tid."]") === FALSE) { 
									$html .= "<img title='".$post->tid."' id='fav_link' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/fav-off.png' style='height:22px; width:22px; cursor:pointer;' alt='".__("Click to add to favorites", WPS_TEXT_DOMAIN)."' />";						
								} else {
									$html .= "<img title='".$post->tid."' id='fav_link' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/fav-on.png' style='height:22px; width:22px; cursor:pointer;' alt='".__("Click to remove to favorites", WPS_TEXT_DOMAIN)."' />";						
								}
							}

						$html .= "</div><div style='clear:both'></div>";
										
						$html .= "<div class='started-by' style='margin-top:10px'>";
						$html .= __("Started by", WPS_TEXT_DOMAIN);
						if ( substr(get_option(WPS_OPTIONS_PREFIX.'_forum_ranks'), 0, 2) == 'on' ) {
							$html .= " <span class='forum_rank'>".__wps__forum_rank($post->topic_owner)."</span>";
						}
						$html .= " ".__wps__profile_link($post->topic_owner);
						$html .= " ".__wps__time_ago($post->topic_started);
						$html .= "</div>";

						$post_text = stripslashes($post->topic_post);

						$has_code = (strpos($post_text, '&#91;code&#93;') !== FALSE || strpos($post_text, '[code]') !== FALSE) ? true : false;
						$has_code_end = (strpos($post_text, '&#91;/code&#93;') !== FALSE || strpos($post_text, '[/code]') !== FALSE) ? true : false;
						$post_text = __wps__make_url(stripslashes($post_text));
						$post_text = __wps__bbcode_replace($post_text);
						if (!$has_code) {
							$post_text = __wps__buffer($post_text);
						} else {
							$post_text = str_replace('&#91;code&#93;<br />', '&#91;code&#93;', $post_text);
							if ($has_code_end) {
								$post_text = str_replace('&#91;code&#93;', '<pre>', $post_text);
								$post_text = str_replace('&#91;/code&#93;', '</pre>', $post_text);
								$post_text = str_replace('[code]', '<pre>', $post_text);
								$post_text = str_replace('[/code]', '</pre>', $post_text);
							} else {
								$post_text .= '</pre>';
							}
						}
						if (get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') == '' || !get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') || get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') == 'bold,italic,|,fontselect,fontsizeselect,forecolor,backcolor,|,bullist,numlist,|,link,unlink,|,image,media,|,emotions') {
							$post_text = str_replace(chr(10), "<br />", $post_text);
							$post_text = str_replace(chr(13), "<br />", $post_text);
						}

						// Make any shortcodes safe
						$post_text = str_replace("[", "&#91;", $post_text);
						$post_text = str_replace("]", "&#93;", $post_text);

						// Tidy up <pre> gap
						$post_text = str_replace('<pre><br />', '<pre>', $post_text);
						$post_text = str_replace('</pre><br />', '</pre>', $post_text);

						$html .= "<div class='topic-post-post'>".$post_text."</div><br />";
						
						// Allow owner or site admin to mark topic for information only
						if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on') {
							if ($post->topic_owner == $current_user->ID || __wps__get_current_userlevel($current_user->ID) == 5) {
								$html .= '<input type="checkbox" id="symposium_for_info" title="'.$post->tid.'"';
								if ($post->for_info == 'on') { $html .= " CHECKED"; }
								$html .= ' /> ';
								$html .= '<em>'.__('This topic is for information only, no answer will be selected.', WPS_TEXT_DOMAIN).'</em>';
							} else {
								if ($post->for_info == 'on') { 
									$html .= '<em>'.__('This topic is for information only, no answer will be selected.', WPS_TEXT_DOMAIN).'</em>';
								}
							}
						}

						// show any uploaded files
						if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == 'on') {

							$cnt_cont = 1;

							// get list of uploaded files from database
							$sql = "SELECT tmpid, filename FROM ".$wpdb->prefix."symposium_topics_images WHERE tid = ".$post->tid." ORDER BY tmpid";
							$images = $wpdb->get_results($sql);
							foreach ($images as $file) {
								$html .= '<div>';
								$ext = explode('.', $file->filename);
								if ($ext[sizeof($ext)-1]=='gif' || $ext[sizeof($ext)-1]=='jpg' || $ext[sizeof($ext)-1]=='png' || $ext[sizeof($ext)-1]=='jpeg') {
									// Image
									$url = WP_CONTENT_URL."/plugins/wp-symposium/get_attachment.php?tid=".$post->tid."&filename=".$file->filename;
									$html .= "<a target='_blank' href='".$url."' rev='".$cnt_cont."' data-owner='".$post->topic_owner."' data-name='".stripslashes($post->topic_subject)."' data-iid='".$cnt_cont."' rel='symposium_gallery_photos_".$post->tid."' class='wps_gallery_album'>";
									$cnt_cont++;
									if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
										list($width, $height, $type, $attr) = getimagesize($url);
										//list($width, $height, $type, $attr) = getimagesize(parse_url(get_bloginfo('url'),PHP_URL_SCHEME)."://".parse_url(get_bloginfo('url'),PHP_URL_HOST).$url);
										$max_width = get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size');
										if ($width > $max_width) {
											$height = $height / ($width / $max_width);
											$width = $max_width;
										}
										$html .= '<img src="'.$url.'" rel="symposium_gallery_photos_'.$post->tid.'" style="width:'.$width.'px; height:'.$height.'px" />';
									} else {
										$html .= $file->filename;
									}
									$html .= "</a> ";
								} else {
									// Video
									if ($ext[sizeof($ext)-1]=='mp4' && get_option(WPS_OPTIONS_PREFIX.'_jwplayer') == "on") {
										$html .= "<a href='#' rel='jwplayer'>".$file->filename."</a>";
									} else {
										// Document
										global $blog_id;
										if ($blog_id > 1) {
											$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/'.$blog_id.'/forum/'.$post->tid.'/'.$file->filename;
										} else {
											$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/forum/'.$post->tid.'/'.$file->filename;
										}
										$url = WP_CONTENT_URL."/plugins/wp-symposium/get_attachment.php?tid=".$post->tid."&filename=".$file->filename;
										
										$html .= "<a href='".$url."' title='".$file->filename."'>".$url."</a><br>";	
										$html .= "<a href='".$url."' title='".$file->filename."' rel='mediaplayer'>".$file->filename."</a>";															
									}
								}
								if ($post->topic_owner == $current_user->ID || __wps__get_current_userlevel($current_user->ID) == 5) {
									$html .= '<img id="'.$post->tid.'" title="'.$file->filename.'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
								}
								$html .= '</div>';	
							}


						} else {

							// Filesystem
							if (isset($blog_id) && $blog_id > 1) {
								$targetPath = get_option(WPS_OPTIONS_PREFIX.'_img_path')."/".$blog_id."/forum/".$post->tid;
							} else {
								$targetPath = get_option(WPS_OPTIONS_PREFIX.'_img_path')."/forum/".$post->tid;
							}

							if (file_exists($targetPath)) {
								$handler = opendir($targetPath);
								$file_list = array();
								while ($file = readdir($handler)) {
									if ( ($file != "." && $file != ".." && $file != ".DS_Store") && (!is_dir($targetPath.'/'.$file)) ) {
										$file_list[] = array('name' => $file, 'size' => filesize($targetPath.'/'.$file), 'mtime' => filemtime($targetPath.'/'.$file));
									}
								}
								// sort by datetime file stamp
								usort($file_list, "__wps__cmp");
								$cnt = 0;
								$cnt_cont = 1;
								global $blog_id;
								foreach($file_list as $file) {
									$cnt++;

									$html .= '<div>';
									if ($blog_id > 1) {
										$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/'.$blog_id.'/forum/'.$post->tid.'/'.$file['name'];
									} else {
										$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/forum/'.$post->tid.'/'.$file['name'];
									}
									$ext = explode('.', $file['name']);
									if (strpos(get_option(WPS_OPTIONS_PREFIX.'_image_ext'), $ext[sizeof($ext)-1]) > 0) {
										// Image
										$html .= "<a target='_blank' href='".$url."' data-name='".stripslashes($post->topic_subject)."' data-iid='".$cnt_cont."' rel='symposium_gallery_photos_".$post->tid."'>";
										
										if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
											//list($width, $height, $type, $attr) = getimagesize($url);
											list($width, $height, $type, $attr) = @getimagesize(parse_url(get_bloginfo('url'),PHP_URL_SCHEME)."://".parse_url(get_bloginfo('url'),PHP_URL_HOST).$url);
											$max_width = get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size');
											if ($width > $max_width) {
												$height = $height / ($width / $max_width);
												$width = $max_width;
											}
											$html .= '<img src="'.$url.'" rev="'.$cnt_cont.'" rel="symposium_gallery_photos_'.$post->tid.'" class="wps_gallery_album" style="width:'.$width.'px; height:'.$height.'px" />';
											$cnt_cont++;

										} else {
											$html .= $file;
										}
										$html .= '</a> ';
									} else {
										// Video
										if (get_option(WPS_OPTIONS_PREFIX.'_jwplayer') == "on" && strpos(get_option(WPS_OPTIONS_PREFIX.'_video_ext'), $ext[sizeof($ext)-1]) > 0) {

											if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
												$html .= '<div id="mediaplayer_'.$cnt.'">JW Player goes here</div> ';
											} else {
												$html .= '<div style="display:none">';
												$html .= '<div id="mediaplayer_'.$cnt.'">JW Player goes here</div> ';
												$html .= '</div>';
												$html .= "<a href='".$url."' class='jwplayer' title='".$file['name']."' rel='mediaplayer'>".$file['name']."</a> ";															
											}

											$html .= '<script type="text/javascript"> ';
											$html .= '	jwplayer("mediaplayer_'.$cnt.'").setup({';
											$html .= '		flashplayer: "'.WPS_PLUGIN_URL.'/jwplayer/player.swf",';
											$html .= '		image: "'.WPS_PLUGIN_URL.'/jwplayer/preview.gif",';
											$html .= '		file: "'.$url.'",';
											$html .= '		width: "'.get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size').'px",';
											$html .= '		height: "250px"';
											$html .= '	});';
											$html .= '</script>';	

										} else {
											// Document
											$html .= "<a href='".$url."' title='".$file['name']."' rel='mediaplayer'>".$file['name']."</a>";															
										}
									}
									if ($post->topic_owner == $current_user->ID || __wps__get_current_userlevel($current_user->ID) == 5) {
										$html .= '<img id="'.$post->tid.'" title="'.$file['name'].'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
									}
									$html .= '</div>';
									
								}			
								closedir($handler);
							}
						}
						
						// Add Signature
						$signature = str_replace("\\", "", __wps__get_meta($post->topic_owner, 'signature'));
						if ($signature != '') {
							$html .= '<div class="sep_top"><em>'.__wps__make_url($signature).'</em></div>';
						}

										
					$html .= "</div><div style='clear:both'></div>";				
												
				$html .= "</div>";

				// Update views
				if (__wps__get_current_userlevel() == 5) {
					if (get_option(WPS_OPTIONS_PREFIX.'_include_admin') == "on") { 
						$wpdb->query( $wpdb->prepare("UPDATE ".$wpdb->prefix."symposium_topics SET topic_views = topic_views + 1 WHERE tid = %d", $post->tid) );
					}
				} else {
					$wpdb->query( $wpdb->prepare("UPDATE ".$wpdb->prefix."symposium_topics SET topic_views = topic_views + 1 WHERE tid = %d", $post->tid) );
				}
					
			$html .= "</div>";		

			// Advertising code +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

			if (get_option(WPS_OPTIONS_PREFIX.'_ad_forum_topic_start')) {
				$html .= "<div id='ad_forum_topic_start'>";
					$html .= stripslashes(get_option(WPS_OPTIONS_PREFIX.'_ad_forum_topic_start'));	
				$html .= "</div>";
			}

			// Replies ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
			
			$sql = "SELECT t.tid, (SELECT SUM(score) FROM ".$wpdb->prefix."symposium_topics_scores s WHERE s.tid = t.tid) AS score, topic_subject, topic_approved, topic_post, t.topic_started, t.topic_date, topic_owner, display_name, topic_answer, ID
				FROM ".$wpdb->prefix."symposium_topics t INNER JOIN ".$wpdb->base_prefix."users u ON t.topic_owner = u.ID 
				WHERE (t.topic_approved = 'on' OR t.topic_owner = %d) AND t.topic_parent = %d ORDER BY t.tid";
				
		
			if (get_option(WPS_OPTIONS_PREFIX.'_oldest_first') != "on") { $sql .= " DESC"; }
	
			$child_query = $wpdb->get_results($wpdb->prepare($sql, $current_user->ID, $post->tid));

			$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_topics t INNER JOIN ".$wpdb->base_prefix."users u ON t.topic_owner = u.ID WHERE (t.topic_approved = 'on' OR t.topic_owner = %d) AND t.topic_parent = %d ORDER BY t.tid";
			$child_count = $wpdb->get_var($wpdb->prepare($sql, $current_user->ID, $post->tid));

			$html .= "<div id='child-posts'>";

				if ($child_query) {

					// Pagination		
					if (get_option(WPS_OPTIONS_PREFIX.'_pagination') == "on" && get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') != 'on') {
						$pagination = get_option(WPS_OPTIONS_PREFIX.'_pagination_size') ? get_option(WPS_OPTIONS_PREFIX.'_pagination_size') : 10;
						$page_count = is_int($child_count/$pagination) ? floor($child_count/$pagination) : floor($child_count/$pagination)+1;
						if ($page_count > 1) {
							if ( get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') ) {
								$uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
								$pagination_url = $uri_parts[0];
								$url_parts = explode('/', $pagination_url);
								$part = get_option(WPS_OPTIONS_PREFIX.'_permalinks_cats') ? 4 : 3;
								$goto_page = $url_parts[$part];
								$page = is_numeric($goto_page) ? $goto_page : 1;
								if (get_option(WPS_OPTIONS_PREFIX.'_permalinks_cats')) {
									$pagination_url = '/'.$url_parts[1].'/'.$url_parts[2].'/'.$url_parts[3];
								} else {
									$pagination_url = '/'.$url_parts[1].'/'.$url_parts[2];
								}
							} else {
								$pagination_url = $forum_url.$q.'cid='.$post->topic_category.'&show='.$post->tid;
								$page = isset($_GET['view']) ? $_GET['view'] : 1;
							}
							if (get_option(WPS_OPTIONS_PREFIX.'_pagination_location') == 'both' || get_option(WPS_OPTIONS_PREFIX.'_pagination_location') == 'top' || !get_option(WPS_OPTIONS_PREFIX.'_pagination_location'))
								$html .= __wps__insert_pagination($page, $page_count, $group_id, $pagination_url);
	  					}
	  				}

					// Get current number of votes by this member to see if can vote
					$sql = "SELECT count(*) FROM ".$wpdb->prefix."symposium_topics WHERE topic_owner = %d";
					$post_count = $wpdb->get_var($wpdb->prepare($sql, $current_user->ID));

					// Div to show if can't vote yet
					$html .= '<div id="symposium_novote_dialog" style="display:none">';
					$html .= sprintf(__("Spam Protection", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_use_votes_min'));
					$html .= '</div>';
					$html .= '<div id="symposium_novote" style="display:none">';
					$html .= sprintf(__("Sorry, you can't vote until you have made %d posts.", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_use_votes_min'));
					$html .= '</div>';

					// For pagination
					$reply_count = 0;
					$start_reply = ($page-1)*$pagination+1;
					$end_reply = (($page-1)*$pagination)+$pagination;
					
					foreach ($child_query as $child) {
						
						$reply_count++;
						if ($reply_count >= $start_reply && $reply_count <= $end_reply) {
							$score = $child->score;
							if ($score == NULL) { $score = 0; }
							
							$reply_html = '';

							$reply_html .= "<div id='reply".$child->tid."' class='child-reply";
								$trusted = __wps__get_meta($child->topic_owner, 'trusted');
								if ($trusted == 'on') { $reply_html .= " trusted"; }
								$reply_html .= "'>";

								$reply_html .= "<div class='avatar'>";
									$reply_html .= get_avatar($child->ID, 64);
									
									if (get_option(WPS_OPTIONS_PREFIX.'_forum_info')) {
									
										$reply_html .= "<div class='forum_info'>";
										
											$sql = "SELECT count(*) FROM ".$wpdb->prefix."symposium_topics WHERE topic_owner = %d";
											$count = $wpdb->get_var($wpdb->prepare($sql, $child->topic_owner));
											$reply_html .= __('Posts:', WPS_TEXT_DOMAIN).' ';								
											$reply_html .= '<span class="forum_info_numbers">'.$count.'</span>';
											
										$reply_html .= "</div>";	

										if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on') {
											$reply_html .= "<div class='forum_info'>";
												$sql = "SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_topics WHERE topic_owner = %d AND topic_answer = 'on' ";
												$sql .= "AND topic_date >= ( CURDATE() - INTERVAL ".$timescale." DAY )";
												if ($w_cat_id != '' && $w_cat_id > 0) {
													$sql .= "AND topic_category IN (".$w_cat_id.") ";
												}
												if ($cat_id_exclude != '' && $cat_id_exclude > 0) {
													$sql .= "AND topic_category NOT IN (".$cat_id_exclude.") ";
												}
												if ($groups != 'on') {
													$sql .= "AND topic_group = 0 ";
												}								
												$count = $wpdb->get_var($wpdb->prepare($sql, $child->topic_owner));
												if ($count > 0) {
													$reply_html .= __('Rating:', WPS_TEXT_DOMAIN).' ';
													$reply_html .= '<span class="forum_info_numbers">'.$count.'</span>';
												}
												if (WPS_DEBUG) $reply_html .= $wpdb->last_query;
											$reply_html .= "</div>";	
										}	
										
									}

									if ($child->topic_date > $previous_login && $child->topic_owner != $current_user->ID && is_user_logged_in() && get_option(WPS_OPTIONS_PREFIX.'_forum_stars')) {
										$reply_html .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/new.gif' alt='New!' /> ";
									}

									
								$reply_html .= "</div>";	
														
								// Reply box
								$reply_html .= "<div class='__wps__reply_box'>";
								
									if ( (get_option(WPS_OPTIONS_PREFIX.'_use_votes_remove') == $score) && (__wps__get_current_userlevel() < 5) && ($score != 0) ) {
										$reply_html .= '<p>'.__('This post has been voted off the forum', WPS_TEXT_DOMAIN).'</p>';
									} else {
									
										if ( (get_option(WPS_OPTIONS_PREFIX.'_use_votes_remove') == $score) && ($score != 0) ) {
											$reply_html .= '<p>'.__('This post has been voted off the forum (only visible to site admins) with a score of', WPS_TEXT_DOMAIN).' '.$score.'.</p>';
										}
										// Votes (if being used)
										if (get_option(WPS_OPTIONS_PREFIX.'_use_votes') == 'on' && ($child->topic_owner != $current_user->ID || __wps__get_current_userlevel() == 5)) {
											$reply_html .= "<div class='floatright forum_post_score' style='width: 24px; text-align:center;'>";
												$reply_html .= "<div style='line-height:16px;'>";
													if ($post_count >= get_option(WPS_OPTIONS_PREFIX.'_use_votes_min')) {
														$reply_html .= "<img id='".$child->tid."' class='forum_post_score_change' title='plus' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' style='cursor:pointer;width:24px; height:24px;' />";
													} else {
														$reply_html .= "<img id='".$child->tid."' class='forum_post_score_change' title='novote' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' style='cursor:pointer;width:24px; height:24px;' />";
													}
												$reply_html .= "</div>";
												$reply_html .= "<div id='forum_score_".$child->tid."' style='margin-bottom:3px'>";
													if ($child->score > 0) { $reply_html .= '+'; }
													$reply_html .= $score;
												$reply_html .= "</div>";
												$reply_html .= "<div>";
													if ($post_count >= get_option(WPS_OPTIONS_PREFIX.'_use_votes_min')) {
														$reply_html .= "<img id='".$child->tid."' class='forum_post_score_change' title='minus' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' style='cursor:pointer;width:24px; height:24px;' />";
													} else {
														$reply_html .= "<img id='".$child->tid."' class='forum_post_score_change' title='novote' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' style='cursor:pointer;width:24px; height:24px;' />";
													}
												$reply_html .= "</div>";
											$reply_html .= "</div>";
										}
										// Answer feature (if being used)
										if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on') {
											$reply_html .= "<div class='floatright'>";
												if ($child->topic_answer == 'on') {
													$reply_html .= "<img id='symposium_accepted_answer' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/tick.png' style='cursor:pointer;margin-top:3px;width:20px; height:20px;' />";
												} else {
													if ($post->topic_owner == $current_user->ID || __wps__get_current_userlevel() == 5) {
														$reply_html .= "<a id=".$child->tid." class='forum_post_answer' href='javascript:void(0);' style='margin-right:10px;";
														if ($post->for_info == 'on') {
															$reply_html .= "display:none;";
														}
														$reply_html .= "'>".__('Accept answer', WPS_TEXT_DOMAIN)."</a>";
													}
												}
											$reply_html .= "</div>";
										}
										
										$reply_html .= "<div class='topic-edit-delete-icon'>";
											// Report warning (if being used)
											if (get_option(WPS_OPTIONS_PREFIX.'_allow_reports') == 'on') {
												$reply_html .= "<a href='javascript:void(0)' class='floatright link_cursor symposium_report' style='display:none' title='reply_".$child->tid."'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/warning.png' /></a>";
											}
											if ( ($child->topic_owner == $current_user->ID) || (can_manage_forum()) ) {
												$reply_posted_time = strtotime($child->topic_started);
												$reply_posted_expire = $reply_posted_time + (get_option(WPS_OPTIONS_PREFIX.'_forum_lock') * 60);
												$now = time();
												$seconds_left = $reply_posted_expire - $now;
												if ($seconds_left > 0) {
													$title = __('Locking reply in', WPS_TEXT_DOMAIN).' '.gmdate("H:i:s", $seconds_left);
													$ttitle = '<br /><em>'.$title.'</em>';
												} else {
													$title = __('Admin only', WPS_TEXT_DOMAIN);
													$ttitle = '';
												}
												if (get_option(WPS_OPTIONS_PREFIX.'_forum_lock') == 0) {
													$title = __('No lock time', WPS_TEXT_DOMAIN);
													$seconds_left = 1;
												}
												if ( ($child->topic_owner == $current_user->ID && $seconds_left > 0) || (can_manage_forum()) ) {
													$reply_html .= "<a href='javascript:void(0)' class='floatright link_cursor delete_forum_reply' style='display:none' id='".$child->tid."'><img title='".$title."' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' /></a>";
													$reply_html .= "<a href='javascript:void(0)' class='floatright link_cursor edit_forum_reply' style='display:none; margin-right: 5px' id='".$child->tid."'><img title='".$title."' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/edit.png' /></a>";
												} else {
													// $reply_html .= 'locked';
												}
											}
										$reply_html .= "</div>";
										$reply_html .= "<div class='started-by'>";
										if ( substr(get_option(WPS_OPTIONS_PREFIX.'_forum_ranks'), 0, 2) == 'on' ) {
											$reply_html .= "<span class='forum_rank'>".__wps__forum_rank($child->topic_owner)."</span> ";
										}
										$reply_html .= __wps__profile_link($child->topic_owner);
										$reply_html .= " ".__("replied", WPS_TEXT_DOMAIN)." ".__wps__time_ago($child->topic_date)."...";
										if (isset($ttitle)) $reply_html .= $ttitle;
										$reply_html .= "</div>";
										$reply_html .= "<div id='child_".$child->tid."' class='child-reply-post'>";

											$reply_text = __wps__make_url(stripslashes($child->topic_post));

											$has_code = (strpos($reply_text, '&#91;code&#93;') !== FALSE || strpos($reply_text, '[code]') !== FALSE) ? true : false;
											$has_code_end = (strpos($reply_text, '&#91;/code&#93;') !== FALSE || strpos($reply_text, '[/code]') !== FALSE) ? true : false;
											$reply_text = __wps__make_url(stripslashes($reply_text));
											$reply_text = __wps__bbcode_replace($reply_text);
											if (!$has_code) {
												$reply_text = __wps__buffer($reply_text);
											} else {
												$reply_text = str_replace('&#91;code&#93;<br />', '&#91;code&#93;', $reply_text);
												if ($has_code_end) {
													$reply_text = str_replace('&#91;code&#93;', '<pre>', $reply_text);
													$reply_text = str_replace('&#91;/code&#93;', '</pre>', $reply_text);
													$reply_text = str_replace('[code]', '<pre>', $reply_text);
													$reply_text = str_replace('[/code]', '</pre>', $reply_text);
												} else {
													$reply_text .= '</pre>';
												}
											}
											if (get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') == '' || !get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') || get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') == 'bold,italic,|,fontselect,fontsizeselect,forecolor,backcolor,|,bullist,numlist,|,link,unlink,|,image,media,|,emotions') {
												$reply_text = str_replace(chr(10), "<br />", $reply_text);
												$reply_text = str_replace(chr(13), "<br />", $reply_text);
											}

											// Make any shortcodes safe
											$reply_text = str_replace("[", "&#91;", $reply_text);
											$reply_text = str_replace("]", "&#93;", $reply_text);

											// Tidy up <pre> gap
											$reply_text = str_replace('<pre><br />', '<pre>', $reply_text);
											$reply_text = str_replace('</pre><br />', '</pre>', $reply_text);

											$reply_html .= "<p>".$reply_text;
											if ($child->topic_approved != 'on') { $reply_html .= " <em>[".__("pending approval", WPS_TEXT_DOMAIN)."]</em>"; }
											$reply_html .= "</p>";
		
										$reply_html .= "</div>";
																		
									}
		
									// show any uploaded files
									if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == 'on') {
		
										// get list of uploaded files from database
										$sql = "SELECT tmpid, filename FROM ".$wpdb->prefix."symposium_topics_images WHERE tid = ".$child->tid." ORDER BY tmpid";
										$images = $wpdb->get_results($sql);
										foreach ($images as $file) {

											$reply_html .= '<div>';
											$url = WP_CONTENT_URL."/plugins/wp-symposium/get_attachment.php?tid=".$child->tid."&filename=".$file->filename;

											$reply_html .= "<a target='_blank' href='".$url."' rev='".$cnt_cont."' data-owner='".$post->topic_owner."' data-name='".stripslashes($post->topic_subject)."' data-iid='".$cnt_cont."' class='wps_gallery_album' ";

											$ext = explode('.', $file->filename);
											if ($ext[sizeof($ext)-1]=='gif' || $ext[sizeof($ext)-1]=='jpg' || $ext[sizeof($ext)-1]=='png' || $ext[sizeof($ext)-1]=='jpeg') {
												$reply_html .= " rel='symposium_gallery_photos_".$post->tid."'";
											}
											$reply_html .= '>';

											if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
												list($width, $height, $type, $attr) = getimagesize($url);
												//list($width, $height, $type, $attr) = getimagesize(parse_url(get_bloginfo('url'),PHP_URL_SCHEME)."://".parse_url(get_bloginfo('url'),PHP_URL_HOST).$url);
												$max_width = get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size');
												if ($width > $max_width) {
													$height = $height / ($width / $max_width);
													$width = $max_width;
												}
												$reply_html .= '<img src="'.$url.'" rev="'.$cnt_cont.'" rel="symposium_gallery_photos_'.$post->tid.'" style="width:'.$width.'px; height:'.$height.'px" />';
											} else {
												$reply_html .= $file->filename;
											}
											$reply_html .= '</a> ';
											$reply_html .= '<img id="'.$child->tid.'" title="'.$file->filename.'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
											$reply_html .= '</div>';	
											$cnt_cont++;
										}
		
									} else {
										
										if (isset($blog_id) && $blog_id > 1) {
											$targetPath = get_option(WPS_OPTIONS_PREFIX.'_img_path')."/".$blog_id."/forum/".$post->tid.'/'.$child->tid;
										} else {
											$targetPath = get_option(WPS_OPTIONS_PREFIX.'_img_path')."/forum/".$post->tid.'/'.$child->tid;
										}

										if (file_exists($targetPath)) {

											$handler = opendir($targetPath);
											$file_list = array();
											while ($file = readdir($handler)) {
												if ( ($file != "." && $file != ".." && $file != ".DS_Store") && (!is_dir($targetPath.'/'.$file)) ) {
													$file_list[] = array('name' => $file, 'size' => filesize($targetPath.'/'.$file), 'mtime' => filemtime($targetPath.'/'.$file));
												}
											}
											// sort by datetime file stamp
											usort($file_list, "__wps__cmp");

											$cnt = 0;
											$handler = opendir($targetPath);
											foreach($file_list as $file) {
													
												$cnt++;

												$reply_html .= '<div style="overflow:auto;">';
												global $blog_id;
												if ($blog_id > 1) {
													$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/'.$blog_id.'/forum/'.$post->tid.'/'.$child->tid.'/'.$file['name'];
												} else {
													$url = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/forum/'.$post->tid.'/'.$child->tid.'/'.$file['name'];
												}
												$ext = explode('.', $file['name']);
												if (strpos(get_option(WPS_OPTIONS_PREFIX.'_image_ext'), $ext[sizeof($ext)-1]) > 0) {
													// Image
													$reply_html .= "<a target='_blank' href='".$url."' data-name='".stripslashes($post->topic_subject)."' data-iid='".$cnt_cont."' rel='symposium_gallery_photos_".$post->tid."'";
													$reply_html .= ' class="wps_gallery_album" title="'.$file['name'].'">';
													if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
														//list($width, $height, $type, $attr) = getimagesize(get_bloginfo('url').$url);
														list($width, $height, $type, $attr) = @getimagesize(parse_url(get_bloginfo('url'),PHP_URL_SCHEME)."://".parse_url(get_bloginfo('url'),PHP_URL_HOST).$url);
														$max_width = get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size');
														if ($width > $max_width) {
															$height = $height / ($width / $max_width);
															$width = $max_width;
														}
														$reply_html .= '<img src="'.$url.'" rev="'.$cnt_cont.'" rel="symposium_gallery_photos_'.$post->tid.'" class="wps_gallery_album" style="width:'.$width.'px; height:'.$height.'px" />';
														$cnt_cont++;
													} else {
														$reply_html .= $file['name'];
													}
													$reply_html .= '</a> ';
												} else {
													// Video
													if (get_option(WPS_OPTIONS_PREFIX.'_jwplayer') == "on" && strpos(get_option(WPS_OPTIONS_PREFIX.'_video_ext'), $ext[sizeof($ext)-1]) > 0) {
														
														$video_id = $child->tid.'_'.$cnt;
														
														if (get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs') == 'on') {
															$reply_html .= '<div id="mediaplayer'.$video_id.'">JW Player goes here</div> ';
														} else {
															$reply_html .= '<div style="display:none">';
															$reply_html .= '<div id="mediaplayer'.$video_id.'">JW Player goes here</div> ';
															$reply_html .= '</div>';
															$reply_html .= "<a href='#' class='jwplayer' title='".$file['name']."' rel='mediaplayer".$video_id."'>".$file['name']."</a> ";															
														}
														$reply_html .= '<script type="text/javascript"> ';
														$reply_html .= '	jwplayer("mediaplayer'.$video_id.'").setup({';
														$reply_html .= '		flashplayer: "'.WPS_PLUGIN_URL.'/jwplayer/player.swf",';
														$reply_html .= '		image: "'.WPS_PLUGIN_URL.'/jwplayer/preview.gif",';
														$reply_html .= '		file: "'.$url.'",';
														$reply_html .= '		width: "'.get_option(WPS_OPTIONS_PREFIX.'_forum_thumbs_size').'px",';
														$reply_html .= '		height: "250px"';
														$reply_html .= '	});';
														$reply_html .= '</script>';																																												
													} else {
														// Document
														$reply_html .= "<a target='_blank' href='".$url."'>".$file['name']."</a> ";		
													}
												}
												if ($child->topic_owner == $current_user->ID || __wps__get_current_userlevel($current_user->ID) == 5) {
													$reply_html .= '<img id="'.$post->tid.'/'.$child->tid.'" title="'.$file['name'].'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
												}
												$reply_html .= '</div>';
													
											}			
											closedir($handler);
										}
									}

								// Add Signature
								$signature = str_replace("\\", "", __wps__get_meta($child->topic_owner, 'signature'));
								if ($signature != '') {
									$reply_html .= '<div class="sep_top"><em>'.__wps__make_url($signature).'</em></div>';
								}
								
								// Check for any comments now for side image (then used below)
								$sql = "SELECT * FROM ".$wpdb->prefix."symposium_topics WHERE
										topic_parent = %d ORDER BY tid";
								$comments = $wpdb->get_results($wpdb->prepare($sql, $child->tid));
								if (WPS_DEBUG) $reply_html .= $wpdb->last_query;
								if ($comments)
									$reply_html .= "<div class='__wps__forum_comment_bubble'><img style='border:0;box-shadow:none;width:32px;height:32px;' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/comment.png' /></div>";

								$reply_html .= "</div>"; // End of reply box
								
								// Comments on the reply
								$reply_html .= "<div class='reply-comments'>";

									$reply_html .= "<div class='reply-comments-box'>";
									if ($comments) {
										foreach ($comments AS $comment) {
											$reply_html .= "<div id='comment".$comment->tid."' class='reply-comments-reply'>";
												$reply_html .= get_avatar($comment->topic_owner, 32);
												$reply_html .= "<div class='reply-comments-box-text'>";

													$reply_html .= "<div class='topic-edit-delete-icon'>";
														// Report warning (if being used) 
														if (get_option(WPS_OPTIONS_PREFIX.'_allow_reports') == 'on') {
															$reply_html .= "<a title='comment_".$comment->tid."' href='javascript:void(0);' style='padding:0px' class='report_post symposium_report reply_warning'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/warning.png' style='width:14px;height:14px' /></a>";
														}
														// Delete comment
														if ( ($comment->topic_owner == $current_user->ID && $seconds_left > 0) || (current_user_can('level_10')) ) {
															$reply_html .= "<a href='javascript:void(0)' class='floatright link_cursor delete_forum_reply' style='display:none' id='".$comment->tid."'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' /></a>";
														}
													$reply_html .= "</div>";


													$reply_html .= "<div class='started-by'>".__wps__profile_link($comment->topic_owner)." ".__('commented', WPS_TEXT_DOMAIN)." ".__wps__time_ago($comment->topic_date)."</div>";
													$reply_html .= __wps__buffer(stripslashes($comment->topic_post));
												$reply_html .= "</div>";
											$reply_html .= "</div>";
										}
									}
									$reply_html .= "</div>";
		
									$reply_html .= "<div class='quick-comment-box-sep'></div>";
								

								// Quick comment box (show link)
								if ($can_comment && $can_reply_switch) {
									$reply_html .= "<div class='quick-comment-box-show'>";
										$reply_html .= '<a class="quick-comment-box-show-link" href="javascript:void(0);">'.__('Add a quick comment...', WPS_TEXT_DOMAIN).'</a>';
									$reply_html .= "</div>";
								}
								
								// Quick comment box
								if (get_option(WPS_OPTIONS_PREFIX.'_elastic') == 'on') { $elastic = ' elastic'; } else { $elastic = ''; }					
								$reply_html .= "<div class='quick-comment-box'>";
									$reply_html .= "<textarea class='quick-comment-box-comment ".$elastic."'>";
									$reply_html .= "</textarea><br />";
									$reply_html .= '<input type="submit" rel="'.$child->tid.'" class="quick-comment-box-add __wps__button" value="'.__("Add Comment", WPS_TEXT_DOMAIN).'" />';
								$reply_html .= "</div>";
								
								$reply_html .= "</div>"; // End comments on the reply
								
							$reply_html .= "</div>";
							
							$reply_html = apply_filters( '__wps__forum_replies_filter', $reply_html );
							
							$html .= $reply_html;

	 						$html .= '<div class="sep __wps__child_reply_sep"></div>';


	 					} // End pagination check
 
					}

					if (!isset($page_count)) $page_count = 1;
					if ( ($page_count > 1) && (get_option(WPS_OPTIONS_PREFIX.'_pagination') == "on" && get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') != 'on') && (get_option(WPS_OPTIONS_PREFIX.'_pagination_location') == 'both' || get_option(WPS_OPTIONS_PREFIX.'_pagination_location') == 'bottom' || !get_option(WPS_OPTIONS_PREFIX.'_pagination_location')) )
						$html .= __wps__insert_pagination($page, $page_count, $group_id, $pagination_url);

			
			} else {
		
				$html .= "<div class='child-reply'>";
				$html .= __("No replies posted yet.", WPS_TEXT_DOMAIN);
				$html .= "</div>";
				$html .= "<div class='sep'></div>";						
		
			}			

			$html .= "</div>";

			// Quick Reply
			if ($can_reply) {
				
				if ($can_reply_switch) {
				
					$html .= '<div id="reply-topic-bottom" name="reply-topic-bottom" style="padding:0; width:100%;">';
	
						$html .= '<input type="hidden" id="__wps__reply_tid" value="'.$post->tid.'">';
						$html .= '<input type="hidden" id="__wps__reply_cid" value="'.$cat_id.'">';
											
						$html .= '<div class="reply-topic-subject label">'.__("Reply to this Topic", WPS_TEXT_DOMAIN).'</div>';
	
						if (get_option(WPS_OPTIONS_PREFIX.'_elastic') == 'on') { $elastic = ' elastic'; } else { $elastic = ''; }
	
						if (get_option(WPS_OPTIONS_PREFIX.'_use_wp_editor')) {
							// WordPress TinyMCE
							$settings = array(
							    'wpautop' => true,
							    'media_buttons' => false,
							    'tinymce' => array(
							        'theme_advanced_buttons1' => 'bold,example,italic,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,spellchecker,fullscreen,wp_adv',
							        'theme_advanced_buttons2' => 'fontselect,forecolor,backcolor,fontsizeselect,underline,|,charmap,|,outdent,indent',
							        'theme_advanced_buttons3' => '',
							        'theme_advanced_buttons4' => '',
							        'width' => '100%'
							    	),
							    'quicktags' => false,
							    'textarea_rows' => 10
							);					
							ob_start();
							wp_editor( '', 'wpstinymcereply', $settings );						
							$editor = ob_get_contents();
							ob_end_clean();
							$html .= $editor.'<br />';
						} else {
							$html .= '<div id="__wps__reply_text_parent" style="width:'.get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_width').';">';
							$html .= __wps__bbcode_toolbar('__wps__reply_text');
							$html .= '<textarea class="textarea_Editor reply-topic-text" id="__wps__reply_text" style="width:100%; height:'.get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_height').';" ></textarea></div>';
							$html .= '<div class="sep"></div>';
						}

						// For admin's only set this as the answer
						if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on' && __wps__get_current_userlevel() == 5) {
							$html .= '<br /><input type="checkbox" id="quick-reply-answer" /> '.__('Set this as the answer', WPS_TEXT_DOMAIN).'<br />';
						}
	
						if ( get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') ) $html .= '<br />';
						$html .= '<input type="submit" id="quick-reply-warning" class="__wps__button" style="float: left" value="'.__("Reply", WPS_TEXT_DOMAIN).'" />';
	
						// Upload
						if (get_option(WPS_OPTIONS_PREFIX.'_forum_uploads')) {
							
							// Attach an image...
							if (get_option(WPS_OPTIONS_PREFIX.'_forum_uploads')) {
								include_once('server/file_upload_include.php');
								$html .= show_upload_form(
									WP_CONTENT_DIR.'/wps-content/members/'.$current_user->ID.'/forum_upload/', 
									WP_CONTENT_URL.'/wps-content/members/'.$current_user->ID.'/forum_upload/',
									'forum',
									__('Attach file', WPS_TEXT_DOMAIN),
									$post->tid
								);							
							}
							$html .= '<div id="forum_file_list" style="clear:both;">';

								if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == 'on') {
									
									// get list of uploaded files from database
									$sql = "SELECT tmpid, filename FROM ".$wpdb->prefix."symposium_topics_images WHERE tid = 0 AND uid = ".$current_user->ID." ORDER BY tmpid";
									$images = $wpdb->get_results($sql);
									foreach ($images as $file) {
										$html .= '<div>';
										$html .= '<a href=""';
										$ext = explode('.', $file->filename);
										if ($ext[sizeof($ext)-1]=='gif' || $ext[sizeof($ext)-1]=='jpg' || $ext[sizeof($ext)-1]=='png' || $ext[sizeof($ext)-1]=='jpeg') {
											$html .= ' target="_blank" rel="symposium_forum_images-'.$post->tid.'"';
										} else {
											$html .= ' target="_blank"';
										}
										$html .= ' title="'.$file->filename.'">'.$file->filename.'</a> ';
										$html .= '<img id="0" title="'.$file->filename.'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
										$html .= '</div>';	
									}
									
								} else {
									
									// get list of uploaded files from file system
									$targetPath = get_option(WPS_OPTIONS_PREFIX.'_img_path')."/forum/".$post->tid.'_'.$current_user->ID.'_tmp/';
									if (file_exists($targetPath)) {
										$handler = opendir($targetPath);
										while ($file = readdir($handler)) {
											if ($file != "." && $file != ".." && $file != ".DS_Store") {
												$html .= '<div>';
												$html .= '<a href="'.get_option(WPS_OPTIONS_PREFIX.'_img_url').'/forum/'.$post->tid.'_'.$current_user->ID.'_tmp/'.$file.'"';
												$ext = explode('.', $file);
												if ($ext[sizeof($ext)-1]=='gif' || $ext[sizeof($ext)-1]=='jpg' || $ext[sizeof($ext)-1]=='png' || $ext[sizeof($ext)-1]=='jpeg') {
													$html .= ' target="_blank" rel="symposium_forum_images-'.$post->tid.'"';
												} else {
													$html .= ' target="_blank"';
												}
												$html .= ' title="'.$file.'">'.$file.'</a> ';
												$html .= '<img id="'.$post->tid.'_'.$current_user->ID.'_tmp" title="'.$file.'" class="remove_forum_post link_cursor" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" /> ';
												$html .= '</div>';
											}
										}			
										closedir($handler);
									}	
								}
								
							$html .= '</div>';	
							
						}

					$html .= '</div>';
				
				} else {
					$html .= "<p style='margin-top:10px'>".__("This topic is closed, no replies are allowed.", WPS_TEXT_DOMAIN);
				}				

				// Add page title at the start
				if ( get_option(WPS_OPTIONS_PREFIX.'_forum_ajax') ) {
					$html = $topic_subject.' | '.html_entity_decode(get_bloginfo('name'), ENT_QUOTES).'[|]'.$html;
				}

			} else {
				if ($group_id == 0) {
					$html .= "<p>".__("You are not permitted to reply on this forum.", WPS_TEXT_DOMAIN);
					if (__wps__get_current_userlevel() == 5) $html .= '<br />'.sprintf(__('Permissions are set via the WordPress admin dashboard->%s->Options->Forum.', WPS_TEXT_DOMAIN), WPS_WL_SHORT).'<br />';	
					
					// Show login form, and redirect back here
					if (get_option(WPS_OPTIONS_PREFIX.'_forum_login') && !is_user_logged_in()) {

						$html .= ' '.__wps__show_login_link(__("<a href='%s'>Login...</a>", WPS_TEXT_DOMAIN));
					}

					$html .= "</p>";

				}
			}
			
		
		} else {
			$html = __('Sorry, this topic is no longer available.', WPS_TEXT_DOMAIN);
		}
		
		
	} else {
		// Final check if it's just not there
		$sql = "SELECT tid FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d";
		if ($wpdb->get_var($wpdb->prepare($sql, $topic_id))) {
			if (is_user_logged_in()) {
				$html .= __("You do not have permission to view this topic, sorry.", WPS_TEXT_DOMAIN);
			} else {
				$html .= __wps__show_login_link(__("You do not have permission to view this topic, sorry. <a href='%s'>Log in...</a>", WPS_TEXT_DOMAIN), false);
			}
			if (__wps__get_current_userlevel() == 5) $html .= '<br /><br />'.sprintf(__('Permissions are set via the WordPress admin dashboard->%s->Options->Forum.', WPS_TEXT_DOMAIN), WPS_WL_SHORT);
		} else {
			$html = __('Sorry, this topic does not exist.', WPS_TEXT_DOMAIN);
		}
	}

	
	// Filter for profile header
	$html = apply_filters ( 'symposium_forum_topic_header_filter', $html, $topic_id );

	return $html;	
}
			if ($replies) {				
				foreach ($replies as $reply) {
				// Show avatar
					echo '<div class="my-forum-reply">';
						if ( ($reply->topic_owner == $current_user->ID || current_user_can('manage_options')) && (!$wps_forum->is_topic_locked($reply->tid)) ) {
							echo '<a href="'.$wps->get_forum_url().$wps->get_url_q($wps->get_forum_url()).'catid='.$catid.'&tid='.$tid.'&del_id='.$reply->tid.'" class="delete">Delete reply</a>';
						}
						echo '<div class="my-reply-avatar">';
							$wps_user = new wps_user($reply->topic_owner);
							echo $wps_user->get_avatar(60);
						echo '</div>';
						echo '<div class="my-reply-author">';
							echo 'Reply by '.$reply->display_name.' '.__wps__time_ago($reply->topic_started);
						echo '</div>';
						$post_text = __wps__make_url(stripslashes($reply->topic_post));
						$post_text = __wps__bbcode_replace($post_text);
						$post_text = str_replace(chr(13), "<br />", $post_text);
						echo '<div class="my-reply-text">';
							echo $post_text;
						echo '</div>';
					echo '</div>';
				}
			}
			
			// Reply field
			echo '<div style="margin-left:118px; margin-bottom:15px;">';
				echo '<strong>Add a reply:</strong><br />';
				echo $wps_ui->forum_reply('Reply', 'my-submit-button', 'my-reply-textarea', true);
			echo '</div>';
			
		} else {
示例#3
0
			if ($tray == 'in') {
				if ($mail->mail_to == $current_user->ID) {		
					$msg = str_replace("[reply_button]", '<input type="submit" id='.$mail->mail_from.' rel="'.stripslashes($mail->display_name).'" title='.$mail_mid.' class="message_reply __wps__button" value="'.__('Reply', WPS_TEXT_DOMAIN).'" />', $msg);
				} else {
					$msg = str_replace("[reply_button]", '', $msg);
				}
			} else {
				if ($mail->mail_from == $current_user->ID) {		
					$msg = str_replace("[reply_button]", '<input type="submit" id='.$mail->mail_to.' title='.$mail_mid.' rel="'.stripslashes($mail->display_name).'" class="message_reply __wps__button" value="'.__('Reply', WPS_TEXT_DOMAIN).'" />', $msg);
				} else {
					$msg = str_replace("[reply_button]", '', $msg);
				}
			}
	
			// Message
			$msg = str_replace("[message]", stripslashes(__wps__bbcode_replace($mail->mail_message)), $msg);
			
			// Emoticons
			$msg = __wps__buffer($msg);
			
			// Layout for HTML
			$msg = str_replace(chr(10), "<br />", $msg);
				
			// Mark as read
			if ($tray == "in") {
				$wpdb->query( $wpdb->prepare("UPDATE ".$wpdb->base_prefix."symposium_mail SET mail_read = 'on' WHERE mail_mid = %d AND mail_to = %d", $mail_mid, $current_user->ID) );
			}
	
			// Fetch new unread count
			$unread = "?!";
			if ($tray == "in") {