}

			}
						
		echo '</div>';				
	echo '</div>';		
	
	// The member's page "header"
	echo '<div id="my-header-div">';

		echo '<div id="my-display-name">'.$wps_user->get_display_name().'</div>';

		// Show latest activity post by the member, if permitted
		if ($wps_user->is_permitted()) { // defaults to activity permission, set to "personal" for personal info
			echo '<div>';
			echo $wps_user->get_latest_activity().' '.__wps__time_ago($wps_user->get_latest_activity_age());
			echo '</div>';	
		}
			
		// Insert activity post form elements if on own profile page
		if ($wps_user->get_id() == $current_user->ID) {
			$box = $wps_ui->whatsup("What's up?", "my-input-box");  // parameters are optional
			$button = $wps_ui->whatsup_button("Post", "my-submit-button");  // parameters are optional
			echo '<div style="float:left;margin-top:10px;margin-right:10px;">'.$box.'</div>';
			echo '<div style="float:left;margin-top:10px;">'.$button.'</div>';
			// Add Facebook Connect plugin (plugin needs to be activated)
			echo '<div style="clear:both;padding-top:5px;">'.$wps_ui->facebook_connect($current_user->ID).'</div>';
		}	
		
	echo '</div>';
	
Example #2
0
function __wps__do_Alerts_Widget($postcount) {
	
	global $wpdb,$current_user;

	if ( get_option(WPS_OPTIONS_PREFIX.'__wps__news_main_activated') || get_option(WPS_OPTIONS_PREFIX.'__wps__news_main_network_activated') ) {

		if (is_user_logged_in()) {

			$max_items = $postcount < 50 ? $postcount : 50;

			// Get new news items
			$sql = "SELECT nid, news, added, new_item
				FROM ".$wpdb->base_prefix."symposium_news 
				WHERE subject = %d 
				ORDER BY new_item desc, nid DESC LIMIT 0,%d";

			$items = $wpdb->get_results($wpdb->prepare($sql, $current_user->ID, $max_items));
		
			// Loop through comments, adding to array if any exist
			if ($items) {
				echo '<div class="__wps__alerts_widget_list">';
					foreach ($items as $item) {

						echo '<div class="__wps__alerts_widget_row">';
						echo stripslashes($item->news).' ';
						echo __wps__time_ago($item->added);
						echo '</div>';
						
					}	
					$sql = "SELECT ID FROM ".$wpdb->prefix."posts WHERE lower(post_content) LIKE '%[symposium-alerts]%' AND post_type = 'page' AND post_status = 'publish';";
					$pages = $wpdb->get_results($sql);	
					if ($pages) {
						$url = get_permalink($pages[0]->ID);
					}
					echo '<a id="__wps__alerts_widget_more" style="float:right" href="'.$url.'">'.__('more...', WPS_TEXT_DOMAIN).'</a>';
					
				echo '</div>';

			} 


		}
		
	} else {
		echo __('Alerts module not activated. You can activate it on the WP Symposium installation page.', WPS_TEXT_DOMAIN);
	}
	
}
		echo '</div>';
		$categories = $wps_forum->get_categories();
		foreach ($categories as $category) {
			echo '<div class="my-forum-row">';
				echo '<div class="my-forum-row-title">';
					echo stripslashes($category->title);
				echo '</div>';
				echo '<div class="my-forum-row-last-topic">';
					$last_topic = $wps_forum->get_topics($category->cid, 0, 1);
					if ($last_topic) {
						echo '<div class="my-forum-row-last-topic-avatar">';
							$wps_user = new wps_user($last_topic->topic_owner);
							echo '<a href="'.$wps->get_profile_url().'?uid='.$last_topic->topic_owner.'">';
							echo $wps_user->get_avatar(48);
							echo '</a>';
						echo '</div>';
						echo stripslashes($last_topic->topic_subject).'<br />';
						echo '<span class="my-forum-row-last-topic-owner">'.$last_topic->display_name.',</span> ';
						echo '<span class="my-forum-row-last-topic-started">'.__wps__time_ago($last_topic->topic_started).'</span>';
					}
				echo '</div>';
			echo '</div>';
		}
	echo '</div>';

	?>
				
	</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Example #4
0
function __wps__do_Gallery_Widget($albumcount) {
	
	global $wpdb, $current_user;
	
	$shown_aid = "";
	$shown_count = 0;

	// Get profile URL worked out
	$profile_url = __wps__get_url('profile');
	$q = __wps__string_query($profile_url);

	// Content of widget
	$sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_gallery g INNER JOIN ".$wpdb->base_prefix."users u ON g.owner = u.ID WHERE is_group != 'on' ORDER BY updated DESC LIMIT 0,50";
	$albums = $wpdb->get_results($sql);
		
	if ($albums) {

		echo "<div id='__wps__gallery_recent_activity'>";
			
			foreach ($albums as $album)
			{
				if ($shown_count < $albumcount) {

					if (strpos($shown_aid, $album->gid.",") === FALSE) { 

						if ( (is_user_logged_in() && strtolower($album->sharing) == 'everyone') || (strtolower($album->sharing) == 'public') || (strtolower($album->sharing) == 'friends only' && __wps__friend_of($album->owner, $current_user->ID)) ) {

							echo "<div class='__wps__gallery_recent_activity_row'>";		
								echo "<div class='__wps__gallery_recent_activity_row_avatar'>";
									echo get_avatar($album->owner, 32);
								echo "</div>";
								echo "<div class='__wps__gallery_recent_activity_row_post'>";
 									$text = __('added to ', WPS_TEXT_DOMAIN)." <a href='".$profile_url.$q."uid=".$album->owner."&embed=on&album_id=".$album->gid."'>".stripslashes($album->name)."</a>";
									echo "<a href='".$profile_url.$q."uid=".$album->owner."'>".$album->display_name."</a> ".$text." ".__wps__time_ago($album->updated);
								echo "</div>";
							echo "</div>";
						
							$shown_count++;
							$shown_aid .= $album->gid.",";							
						}
					}
				} else {
					break;
				}
			}

		echo "</div>";

	}
}
					$shown_heading_old = true;
				}
					
				if ($heading) {
					$html .= "<div class='topic-post-header' style='margin-bottom:10px'>";
						$html .= $heading;
					$html .= "</div>";
				}
				
				$html .= "<div class='__wps__news_history_row'>";
					$html .= "<div class='__wps__news_history_avatar'>";
					$html .= '<a href="'.$profile_url.$q.'uid='.$item->author.'">'.get_avatar($item->author, 40).'</a>';
					$html .= '</div>';
					$html .= "<div class='__wps__news_history_avatar'>";
					$html .= $item->news;
					$html .= "<br /><span class='__wps__news_history_ago'>".__wps__time_ago($item->added)."</span>";
					$html .= ' '.__('by', WPS_TEXT_DOMAIN).' <a href="'.$profile_url.$q.'uid='.$item->author.'">'.stripslashes($item->display_name).'</a>';
					$html .= "</div>";
				$html .= "</div>";
			}
		} else {

			$html .= __("Nothing to show yet.", WPS_TEXT_DOMAIN);

		}
		$html .= "</div>";
		// End Wrapper
	
		$html .= "<div style='clear: both'></div>";
	
		// Clear read news items
									$html .= $member['city'];
								}
								if (isset($country) && $country != '') {
									if ($city != '') {
										$html .= ', '.$member['country'];
									} else {
										$html .= $member['country'];
									}
								}								
							$html .= "</div>";
						}
	
						$html .= "<div class='members_avatar'>";
							$html .= get_avatar($member['ID'], 64);
						$html .= "</div>";
						$html .= __wps__profile_link($member['ID']).', '.__('last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($member['last_activity']).". ";
						if ($last_active_minutes >= $offline) {
							//$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/loggedout.gif">';
						} else {
							if ($last_active_minutes >= $inactive) {
								$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/inactive.gif">';
							} else {
								$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/online.gif">';
							}
						}
						if ($member['admin'] == "on") {
							$html .= "<br />[".__("group admin", WPS_TEXT_DOMAIN)."]";
						}
						
						// Requesting group membership...
						if ($member['valid'] != "on") {
					$msg = $avatar . get_avatar($uid, $avatar2) . $avatar3;				
				}
			}
	
			// Now the subject and sender
			$msg = str_replace("[mail_subject]", "<span style='font-weight:bold'>".stripslashes(__wps__bbcode_replace($mail->mail_subject))."</span>", $msg);						
			
			// Sender/recipient
			if ($tray == "in") {
				$msg = str_replace("[mail_recipient]", __('From', WPS_TEXT_DOMAIN)." ".stripslashes($mail->display_name), $msg);
			} else {
				$msg = str_replace("[mail_recipient]", __('To', WPS_TEXT_DOMAIN)." ".stripslashes($mail->display_name), $msg);
			}
	
			// Sent
			$msg = str_replace("[mail_sent]", __wps__time_ago($mail->mail_sent), $msg);
	
			// Delete button
			$msg = str_replace("[delete_button]", '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete2.png" id='.$mail_mid.' class="message_delete" />', $msg);
	
			// Reply button
			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 {
function __wps__profile_friends($uid, $limit_from) {

	global $wpdb, $current_user;
	wp_get_current_user();
	
	$limit_count = 10;

	$privacy = __wps__get_meta($uid, 'share');
	$is_friend = __wps__friend_of($uid, $current_user->ID);
	$html = "";	

	if ( ($uid == $current_user->ID) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && $is_friend) || __wps__get_current_userlevel() == 5) {

		$mailpage = __wps__get_url('mail');
		if ($mailpage[strlen($mailpage)-1] != '/') { $mailpage .= '/'; }
		$q = __wps__string_query($mailpage);		

		// Friend Requests
		if ($uid == $current_user->ID) {
			
			$sql = "SELECT u1.display_name, u1.ID, f.friend_timestamp, f.friend_message, f.friend_from 
					FROM ".$wpdb->base_prefix."symposium_friends f 
					LEFT JOIN ".$wpdb->base_prefix."users u1 ON f.friend_from = u1.ID 
					WHERE f.friend_to = %d AND f.friend_accepted != 'on' ORDER BY f.friend_timestamp DESC";
	
			$requests = $wpdb->get_results($wpdb->prepare($sql, $current_user->ID));
			if ($requests) {
				
				$html .= '<h2>'.sprintf(__('%s Requests', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'...</h2>';
				
				foreach ($requests as $request) {
				
					$html .= "<div id='request_".$request->friend_from."' style='clear:right; margin-top:8px; overflow: auto; margin-bottom: 15px; width:95%;'>";		
						$html .= "<div style='float: left; width:64px; margin-right: 15px'>";
							$html .= get_avatar($request->ID, 64);
						$html .= "</div>";
						$html .= "<div class='__wps__friend_request_info'>";
							$html .= __wps__profile_link($request->ID)."<br />";
							$html .= __wps__time_ago($request->friend_timestamp)."<br />";
							$html .= "<em>".stripslashes($request->friend_message)."</em>";
						$html .= "</div>";
						$html .= "<div style='clear: both; float:right;'>";
							$html .= '<input type="submit" title="'.$request->friend_from.'" id="rejectfriendrequest" class="__wps__button" style="'.__wps__get_extension_button_style().'" value="'.__('Reject', WPS_TEXT_DOMAIN).'" /> ';
						$html .= "</div>";
						$html .= "<div style='float:right;'>";
							$html .= '<input type="submit" title="'.$request->friend_from.'" id="acceptfriendrequest" class="__wps__button" style="'.__wps__get_extension_button_style().'" value="'.__('Accept', WPS_TEXT_DOMAIN).'" /> ';
						$html .= "</div>";
					$html .= "</div>";
				}

				$html .= '<hr />';
				
			}
		}
		
		// Friends
		$sql = "SELECT f.*, cast(m.meta_value as datetime) as last_activity 
				FROM ".$wpdb->base_prefix."symposium_friends f 
				LEFT JOIN ".$wpdb->base_prefix."usermeta m ON m.user_id = f.friend_to 
				WHERE f.friend_to > 0 AND f.friend_from = %d 
				AND m.meta_key = 'symposium_last_activity'
				AND f.friend_accepted = 'on'
				ORDER BY cast(m.meta_value as datetime) DESC LIMIT %d, %d";
		$friends = $wpdb->get_results($wpdb->prepare($sql, $uid, $limit_from, $limit_count));
		
		if ($friends) {
		
			if ($current_user->ID == $uid || __wps__get_current_userlevel() == 5) {
				$html .= '<input type="submit" id="removeAllFriends" name="Submit" class="__wps__button" style="'.__wps__get_extension_button_style().'; width:200px;" value="'.__('Remove all friends', WPS_TEXT_DOMAIN).'" />';
			}
		
			$count = 0;
		
			$inactive = get_option(WPS_OPTIONS_PREFIX.'_online');
			$offline = get_option(WPS_OPTIONS_PREFIX.'_offline');
			
			foreach ($friends as $friend) {
				
				$count++;
				
				$time_now = time();
				$last_active_minutes = strtotime($friend->last_activity);
				$last_active_minutes = floor(($time_now-$last_active_minutes)/60);
												
				$html .= "<div id='friend_".$friend->friend_to."' class='friend_div row_odd corners' style='clear:right; margin-top:8px; overflow: auto; margin-bottom: 15px; padding:6px; width:95%;'>";
				
					$html .= "<div style='width:64px; margin-right: 15px'>";
						$html .= get_avatar($friend->friend_to, 64);
					$html .= "</div>";

					// Send Mail and remove as friend
					$html .= "<div style='width:50px; height: 16px; float:right;'>";
					if ($friend->friend_accepted == 'on') {
						if ($uid == $current_user->ID) {

							$html .= "<div style='display:none;' class='friend_icons'>";
	
								$html .= "<div style='float:right;margin-left:5px;margin-right:5px;'>";
									$html .= '<img style="cursor:pointer" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/delete.png" title="'.$friend->friend_to.'" class="frienddelete">';
									$html .= '</form>';
								$html .= "</div>";
							
								if (function_exists('__wps__mail')) {
									$html .= "<div style='float:right;'>";
										$html .= '<img style="cursor:pointer" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/orange-tick.gif" onclick="document.location = \''.$mailpage.$q.'view=compose&to='.$friend->friend_to.'\';">';
									$html .= "</div>";
								}
								
							$html .= "</div>";
							
						}
					}
					$html .= '</div>';
										
					$html .= "<div style='padding-left:74px;'>";
						$html .= __wps__profile_link($friend->friend_to);
						$html .= "<br />";
						if ($last_active_minutes >= $offline) {
							$html .= __('Logged out', WPS_TEXT_DOMAIN).'. '.__('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend->last_activity).".";
						} else {
							if ($last_active_minutes >= $inactive) {
								$html .= __('Offline', WPS_TEXT_DOMAIN).'. '.__('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend->last_activity).".";
							} else {
								$html .= __('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend->last_activity).".";
							}
						}
						if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
							$html .= '<br />';
							// Show comment
							$sql = "SELECT cid, comment
								FROM ".$wpdb->base_prefix."symposium_comments
								WHERE author_uid = %d AND subject_uid = %d AND comment_parent = 0 AND type = 'post'
								ORDER BY cid DESC
								LIMIT 0,1";
							$comment = $wpdb->get_row($wpdb->prepare($sql, $friend->friend_to, $friend->friend_to));
							if ($comment) {
								$html .= '<div>'.__wps__buffer(__wps__make_url(stripslashes($comment->comment))).'</div>';
							}
							
							// Show latest non-status activity if applicable
							if (function_exists('__wps__forum')) {
								$sql = "SELECT cid, comment FROM ".$wpdb->base_prefix."symposium_comments
										WHERE author_uid = %d AND subject_uid = %d AND comment_parent = 0 AND type = 'forum' 
										ORDER BY cid DESC 
										LIMIT 0,1";
								$forum = $wpdb->get_row($wpdb->prepare($sql, $friend->friend_to, $friend->friend_to));
								if ($comment && $forum && $forum->cid != $comment->cid) {
									$html .= '<div>'.__wps__buffer(__wps__make_url(stripslashes($forum->comment))).'</div>';
								}
							}
							
							
						}
					$html .= "</div>";

					if ($friend->friend_accepted != 'on') {
						$html .= "<div style='float:left;'>";
							$html .= "<strong>".sprintf(__("%s request sent.", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend'))."</strong>";
						$html .= "</div>";
					}					

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

			if ($count == $limit_count) {
				$html .= "<a href='javascript:void(0)' id='friends' class='showmore_wall' title='".($limit_from+$limit_count)."'>".__("more...", WPS_TEXT_DOMAIN)."</a>";
			}
			
		} else {
			$html .= __("Nothing to show, sorry.", WPS_TEXT_DOMAIN);
		}
		
	} else {

		if (strtolower($privacy) == 'friends only') {
			$html .=  sprintf(__("Personal information only for %s.", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends'));
		}
		if (strtolower($privacy) == 'nobody') {
			$html .= __("Personal information is private.", WPS_TEXT_DOMAIN);
		}

	}						

	return $html;
	
}
Example #9
0
function symposium_forum_latestposts_showThreadChildren($count, $cat_id, $parent, $level, $use_answers) {
	
	global $wpdb, $current_user;

	$thispage = __wps__get_url('forum');
	if ($thispage[strlen($thispage)-1] != '/') { $thispage .= '/'; }
	$q = __wps__string_query($thispage);		

	$symposium_last_login = __wps__get_meta($current_user->ID, 'symposium_last_login');
	
	$html = "";
	
	$preview = 30;	
	if ($count != '') { 
		$postcount = $count; 
	} else {
		$postcount = get_option(WPS_OPTIONS_PREFIX.'_symposium_forumlatestposts_count');
	}
	
	if ($level == 0) {
		$avatar_size = 30;
		$margin_top = 10;
		$desc = "DESC";
	} else {
		$avatar_size = 20;
		$margin_top = 6;
		$desc = "DESC";
	}

	// All topics started
	$cat_sql = ($cat_id) ? " AND t.topic_category = ".$cat_id : '';
	$posts = $wpdb->get_results("
		SELECT t.tid, t.topic_subject, t.stub, p.stub as parent_stub, t.topic_owner, t.topic_post, t.topic_category, t.topic_started, u.display_name, t.topic_parent, t.topic_answer, t.topic_date, t.topic_approved 
		FROM ".$wpdb->prefix.'symposium_topics'." t INNER JOIN ".$wpdb->base_prefix.'users'." u ON t.topic_owner = u.ID 
		LEFT JOIN ".$wpdb->prefix.'symposium_topics'." p ON t.topic_parent = p.tid 
		WHERE t.topic_parent = ".$parent." AND t.topic_group = 0".$cat_sql." ORDER BY t.tid ".$desc." LIMIT 0,".$postcount); 

	if ($posts) {

		foreach ($posts as $post)
		{
			if ( ($post->topic_approved == 'on') || ($post->topic_approved != 'on' && ($post->topic_owner == $current_user->ID || current_user_can('level_10'))) ) {

				$padding_left = ($level == 0) ? 40 : 30;
				$html .= "<div class='__wps__latest_forum_row' style='padding-left: ".$padding_left."px; margin-left: ".($level*40)."px; margin-top:".$margin_top."px;'>";		
					$html .= "<div class='__wps__latest_forum_row_avatar'>";
						$html .= get_avatar($post->topic_owner, $avatar_size);
					$html .= "</div>";
					$html .= "<div style='float:left'>";
						if ($post->topic_parent > 0) {
							$text = strip_tags(stripslashes($post->topic_post));
							if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; }
							$reply_text = $level == 1 ? 'replied' : 'commented';
							$html .= __wps__profile_link($post->topic_owner)." ".__($reply_text, WPS_TEXT_DOMAIN)." ";
							if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure')) {
								$perma_cat = __wps__get_forum_category_part_url($post->topic_category);
								$html .= "<a title='".$text."' href='".$thispage.$perma_cat.$post->parent_stub."'>";
							} else {
								$html .= "<a title='".$text."' href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->topic_parent."'>";
							}
							$html .= $text."</a> ".__wps__time_ago($post->topic_started);
							if ($use_answers == 'on' && $post->topic_answer == 'on') {
								$html .= ' <img style="width:12px;height:12px" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/tick.png" alt="'.__('Answer Accepted', WPS_TEXT_DOMAIN).'" />';
							}
							$html .= "<br>";
						} else {
							$text = stripslashes($post->topic_subject);
							if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; }
							$html .= __wps__profile_link($post->topic_owner)." ".__('started', WPS_TEXT_DOMAIN);
							if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure')) {
								$perma_cat = __wps__get_forum_category_part_url($post->topic_category);
								$html .= " <a title='".$text."'  href='".$thispage.$perma_cat.$post->stub."'>".$text."</a> ";
							} else {
								$html .= " <a title='".$text."'  href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->tid."'>".$text."</a> ";
							}
							$html .= __wps__time_ago($post->topic_started).".<br>";
						}
					$html .= "</div>";
					if ($post->topic_date > $symposium_last_login && $post->topic_owner != $current_user->ID) {
						$html .= "<div style='float:left;'>";
							$html .= "&nbsp;<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/new.gif' alt='New!' />";
						$html .= "</div>";
					}		
					if ($post->topic_approved != 'on') {
						$html .= "&nbsp;<em>[".__("pending approval", WPS_TEXT_DOMAIN)."]</em>";
					}
				$html .= "</div>";
				
			}
			
			$html .= symposium_forum_latestposts_showThreadChildren($count, $cat_id, $post->tid, $level+1, $use_answers);
			
		}
	}	
	
	return $html;
}
				
				$html .= "<div class='groups_info'>";

					$html .= "<div class='groups_avatar'>";
						$html .= __wps__get_group_avatar($group->gid, 64);
					$html .= "</div>";

					$html .= "<div class='group_name'>";
					$name = stripslashes($group->name) != '' ? stripslashes($group->name) : __('[No name]', WPS_TEXT_DOMAIN);
					$html .= "<a class='row_link' href='".__wps__get_url('group').__wps__string_query($url)."gid=".$group->gid."'>".$name."</a>";
					$html .= "</div>";
					
					$html .= "<div class='group_member_count'>";
					$html .= __("Member Count:", WPS_TEXT_DOMAIN)." ".$group->member_count;
					if ($group->last_activity) {
						$html .= '<br /><em>'.__('last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($group->last_activity)."</em>";
					}
					$html .= "</div>";
				
					$html .= "<div class='group_description'>";
					$html .= stripslashes($group->description);
					$html .= "</div>";
					
				$html .= "</div>";
				
			$html .= "</div>";
			
		}
	} else {
		$html = __("No groups created yet....", WPS_TEXT_DOMAIN);
	}
		$sql = "SELECT c.*, u.display_name FROM ".$wpdb->base_prefix."symposium_comments c 
			LEFT JOIN ".$wpdb->base_prefix."users u ON c.author_uid = u.ID 
			WHERE c.comment_parent = 0 AND c.type = 'photo' AND c.subject_uid = %d ORDER BY c.cid DESC";
	
		$comments = $wpdb->get_results($wpdb->prepare($sql, $photo_id));	
		
		$comments_array = array();
		foreach ($comments as $comment) {
			$add = array (
				'ID' => $comment->cid,
				'author_id' => $comment->author_uid,
				'avatar' => get_avatar($comment->author_uid, 32),
				'display_name' => $comment->display_name,
				'display_name_link' => __wps__profile_link($comment->author_uid),
				'comment' => __wps__buffer(__wps__make_url(stripslashes($comment->comment))),
				'timestamp' => __wps__time_ago($comment->comment_timestamp)
			);
			array_push($comments_array, $add);
		}
		
		echo json_encode($comments_array);
	
		exit;
		
	}	
	
	// Delete comment from photo
	if ($_POST['action'] == '__wps__delete_gallery_comment') {
	
		global $wpdb, $current_user;
		
				if ($last_active_minutes >= $inactive) {
					$row_array['status'] = 'inactive';
				} else {
					$row_array['status'] = 'online';
				}
			}

			$row_array['lid'] = $comment['lid'];
			$row_array['comment'] = convert_smilies(stripslashes($comment['comment']));
			$row_array['author_id'] = $comment['author'];
			if ($comment['ID'] == $current_user->ID) {
				$row_array['author'] = 'You';
			} else {
				$row_array['author'] = $comment['display_name'];
			}
			$row_array['added'] = __wps__time_ago($comment['added']);
			array_push($return_arr, $row_array);
		}	
	} 
	
	
	echo json_encode($return_arr);
	exit;

}


// Add comment
if ($_POST['action'] == 'add_comment') {

	global $wpdb, $current_user;
function showThreadChildren($parent, $level, $gid, $symposium_last_login) {
	
	global $wpdb, $current_user;

	// Work out link to this page, dealing with permalinks or not
	if ($gid == 0) {
		$thispage = __wps__get_url('forum');
		if ($thispage[strlen($thispage)-1] != '/') { $thispage .= '/'; }
		if (strpos($thispage, "?") === FALSE) { 
			$q = "?";
		} else {
			// No Permalink
			$q = "&";
		}
	} else {
		$thispage = __wps__get_url('group');
		if ($thispage[strlen($thispage)-1] != '/') { $thispage .= '/'; }
		if (strpos($thispage, "?") === FALSE) { 
			$q = "?";
		} else {
			// No Permalink
			$q = "&";
		}
		$q .= "gid=".$gid."&";
	}
	
	$html = "";
	
	$preview = 50 - (10*$level);	
	if ($preview < 10) { $preview = 10; }
	$postcount = 20; // Tries to retrieve last 7 days, but this will be a maximum number of posts or replies
	
	if ($level == 0) {
		$avatar_size = 30;
		$margin_top = 10;
		$desc = "DESC";
	} else {
		$avatar_size = 20;
		$margin_top = 3;
		$desc = "DESC";
	}

	$include = strtotime("now") - (86400 * 280); // 4 weeks
	$include = date("Y-m-d H:i:s", $include);

	// All topics started
	$sql = "
		SELECT t.tid, t.topic_subject, t.topic_owner, t.topic_post, t.topic_category, t.topic_date, u.display_name, t.topic_parent, t.topic_answer, t.topic_started, p.topic_category as parent_category 
		FROM ".$wpdb->prefix.'symposium_topics'." t INNER JOIN ".$wpdb->base_prefix.'users'." u ON t.topic_owner = u.ID 
		LEFT JOIN ".$wpdb->prefix."symposium_topics p ON t.topic_parent = p.tid
		WHERE t.topic_approved = 'on' AND t.topic_parent = %d AND t.topic_group = %d AND t.topic_date > %s 
		AND (t.topic_parent = 0 || p.topic_parent = 0) 
		ORDER BY t.tid ".$desc." LIMIT 0,%d";
	$posts = $wpdb->get_results($wpdb->prepare($sql, $parent, $gid, $include, $postcount)); 

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

	if ($posts) {

		foreach ($posts as $post)
		{

			$sql = "SELECT level FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d";
			$cat_level = $wpdb->get_var($wpdb->prepare($sql, $post->topic_category));
			$cat_roles = unserialize($cat_level);
			if ($gid > 0 || strpos(strtolower($cat_roles), 'everyone,') !== FALSE || strpos(strtolower($cat_roles), $user_role.',') !== FALSE) {		

				$html .= "<div class='__wps__forum_activity_row' style='padding-left: ".($level*40)."px; margin-top:".$margin_top."px;min-height:".$avatar_size."px;'>";		
					$html .= "<div class='__wps__forum_activity_row_avatar' style='padding-left: ".($level*40)."px;'>";
						$html .= get_avatar($post->topic_owner, $avatar_size);
					$html .= "</div>";
					$move_over = ($level == 0) ? 40 : 30;
					$html .= "<div class='__wps__forum_activity_row_text' style='margin-left: ".$move_over."px;'>";
						if ($post->topic_parent > 0) {
							$text = strip_tags(stripslashes($post->topic_post));
							if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; }
							$html .= __wps__profile_link($post->topic_owner)." ".__('replied', WPS_TEXT_DOMAIN)." ";
						
							if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
								$stub = $wpdb->get_var($wpdb->prepare("SELECT stub FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d", $post->topic_parent));
								$perma_cat = __wps__get_forum_category_part_url($post->parent_category);
								$url = $thispage.$perma_cat.$stub;							
								$html .= "<a href='".$url."'>".$text."</a> ";
							} else {
								$html .= "<a href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->topic_parent."'>".$text."</a> ";
							}
					
							$html .= __wps__time_ago($post->topic_date);
							if (get_option(WPS_OPTIONS_PREFIX.'_use_answers') == 'on' && $post->topic_answer == 'on') {
								$html .= ' <img style="width:12px; height:12px" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/tick.png" alt="'.__('Answer Accepted', WPS_TEXT_DOMAIN).'" />';
							}
							$html .= "<br>";
						} else {
							$text = stripslashes($post->topic_subject);
							if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; }
							$html .= __wps__profile_link($post->topic_owner)." ".__('started', WPS_TEXT_DOMAIN)." ";

							if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && $group_id == 0) {
								$stub = $wpdb->get_var($wpdb->prepare("SELECT stub FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d", $post->tid));
								$perma_cat = __wps__get_forum_category_part_url($post->topic_category);
								$url = $thispage.$perma_cat.$stub;							
								$html .= "<a href='".$url."'>".$text."</a> ";
							} else {
								$html .= "<a href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->tid."'>".$text."</a> ";
							}
							
							$html .= __wps__time_ago($post->topic_started).".<br>";
						}
					$html .= "</div>";
					if ($post->topic_date > $symposium_last_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 .= showThreadChildren($post->tid, $level+1, $gid, $symposium_last_login);
			}			
							
		}
	}	
	
	return $html;
}
													$html .= "<div class='mail_icon' style='display:none;float:right; margin-right:5px;'>";
													$html .= '<img style="cursor:pointer" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/orange-tick.gif" onclick="document.location = \''.$mailpage.$q.'view=compose&to='.$member->uid.'\';">';
													$html .= "</div>";
												}
											}
										}
			
										$html .= __wps__profile_link($member->uid);
			
										if ($member->last_activity != '') {
											if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
												$html .= ', ';
											} else {
												$html .= '<br />';
											}
											$html .= __('last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($member->last_activity).". ";
											if ($last_active_minutes >= $offline) {
												//$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/loggedout.gif">';
											} else {
												if ($last_active_minutes >= $inactive) {
													$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/inactive.gif">';
												} else {
													$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/online.gif">';
												}
											}
										}
			
										// Distance
										if (function_exists('__wps__profile_plus') && is_user_logged_in() && $member->distance < 99999 && $member->uid != $current_user->ID) {
											// if privacy settings permit
											if ( (strtolower($share) == 'everyone') 
Example #15
0
function __wps__alerts_history($attr) {	

	global $wpdb, $current_user;
	$html = "";
	
	if (is_user_logged_in()) {

		// Get link to profile page
		$profile_url = __wps__get_url('profile');
		if (strpos($profile_url, '?') !== FALSE) {
			$q = "&";
		} else {
			$q = "?";
		}
		
		$limit = isset($attr['count']) ? $attr['count'] : 50;

	
		// Wrapper
		$html .= "<div class='__wps__wrapper'>";

		$sql = "SELECT n.*, u.display_name FROM ".$wpdb->base_prefix."symposium_news n 
			LEFT JOIN ".$wpdb->base_prefix."users u ON n.author = u.ID 
			WHERE subject = %d 
			ORDER BY added DESC LIMIT 0,%d";
		$news = $wpdb->get_results($wpdb->prepare($sql, $current_user->ID, $limit));

		$shown_heading_today = $shown_heading_yesterday = $shown_heading_recent = $shown_heading_lastweek = $shown_heading_thismonth = $shown_heading_lastmonth = $shown_heading_old = false;
		
		if ($news) {
			foreach ($news as $item) {

				$date = strtotime($item->added);
				$difference = (time() - $date) + 1;
				$days = floor($difference/86400);
				$months = floor($difference/2628000);
	
				$heading = '';
				if (!$shown_heading_today && $days == 0) {
					$heading = __('Today', WPS_TEXT_DOMAIN);
					$shown_heading_today = true;
				}
				if (!$shown_heading_yesterday && $days == 1) {
					$heading = __('Yesterday', WPS_TEXT_DOMAIN);
					$shown_heading_yesterday = true;
				}
				if (!$shown_heading_recent && $days >= 2 && $days <= 6) {
					$heading = __('Recently', WPS_TEXT_DOMAIN);
					$shown_heading_recent = true;
				}
				if (!$shown_heading_lastweek && $days >= 7 && $days <= 13) {
					$heading = __('Last week', WPS_TEXT_DOMAIN);
					$shown_heading_lastweek = true;
				}
				if (!$shown_heading_thismonth && $days >= 14 && $months == 0) {
					$heading = __('This month', WPS_TEXT_DOMAIN);
					$shown_heading_thismonth = true;
				}
				if (!$shown_heading_lastmonth && $months == 1) {
					$heading = __('Last month', WPS_TEXT_DOMAIN);
					$shown_heading_lastmonth = true;
				}
				if (!$shown_heading_old && $months > 1) {
					$heading = __('Old', WPS_TEXT_DOMAIN);
					$shown_heading_old = true;
				}
					
				if ($heading) {
					$html .= "<div class='topic-post-header' style='margin-bottom:10px'>";
						$html .= $heading;
					$html .= "</div>";
				}
				
				$html .= "<div class='__wps__news_history_row'>";
					$html .= "<div class='__wps__news_history_avatar'>";
					$html .= '<a href="'.$profile_url.$q.'uid='.$item->author.'">'.get_avatar($item->author, 40).'</a>';
					$html .= '</div>';
					$html .= "<div class='__wps__news_history_avatar'>";
					$html .= $item->news;
					$html .= "<br /><span class='__wps__news_history_ago'>".__wps__time_ago($item->added)."</span>";
					$html .= ' '.__('by', WPS_TEXT_DOMAIN).' <a href="'.$profile_url.$q.'uid='.$item->author.'">'.stripslashes($item->display_name).'</a>';
					$html .= "</div>";
				$html .= "</div>";
			}
		} else {

			$html .= __("Nothing to show yet.", WPS_TEXT_DOMAIN);

		}
		$html .= "</div>";
		// End Wrapper
	
		$html .= "<div style='clear: both'></div>";
	
		// Clear read news items
		$wpdb->query("UPDATE ".$wpdb->base_prefix."symposium_news SET new_item = '' WHERE subject = ".$current_user->ID);

	} else {
		
		$html .= __("Please login, thank you.", WPS_TEXT_DOMAIN);
		
	}

	// Send HTML
	return $html;

}
Example #16
0
function __wps__members($attr) {	

	global $wpdb, $current_user;
	wp_get_current_user();

	$plugin = WPS_PLUGIN_URL;
	$dbpage = $plugin.'/symposium_members_db.php';
	
	$roles = isset($attr['roles']) ? $attr['roles'] : '';
	if ($roles) {
		if (strpos($roles, ' ') !== FALSE) $roles = str_replace(' ', '', $roles);
		if (strpos($roles, '_') !== FALSE) $roles = str_replace('_', '', $roles);
	}
	
	$html = '<div class="__wps__wrapper">';

		if (!is_user_logged_in() && get_option(WPS_OPTIONS_PREFIX.'dir_hide_public') ) {

			echo __wps__show_login_link(__("You need to be <a href='%s'>logged in</a> to view the directory.", WPS_TEXT_DOMAIN));

		} else {

			// If 'term' is passed as a parameter, it will influence the results
			$me = $current_user->ID;
			$page = 1;

			// Now check against shortcode parameter (overrides global roles)
			if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles();													
			if ($roles) {
				$dir_levels = $roles;
			} else {
				// Get included global levels
				$dir_levels = strtolower(get_option(WPS_OPTIONS_PREFIX.'_dir_level'));
				if (strpos($dir_levels, ' ') !== FALSE) $dir_levels = str_replace(' ', '', $dir_levels);
				if (strpos($dir_levels, '_') !== FALSE) $dir_levels = str_replace('_', '', $dir_levels);
			}
			$html .= '<div id="__wps__directory_roles" style="display:none">'.$dir_levels.'</div>';
			
			// Stores start value for more
			$start = get_option(WPS_OPTIONS_PREFIX.'_dir_page_length')+1;
			$html .= '<div id="symposium_directory_start" style="display:none">'.$start.'</div>';
			$html .= '<div id="symposium_directory_page_length" style="display:none">'.get_option(WPS_OPTIONS_PREFIX.'_dir_page_length').'</div>';
			
			$term = "";
			if (isset($_POST['member'])) { $term .= strtolower($_POST['member']); }
			if (isset($_GET['term'])) { $term .= strtolower($_GET['term']); }
			
			$html .= "<div class='members_row' style='padding:0px'>";
				$html .= '<div style="float:right; padding:0px;padding-top:2px;">';
				$html .= '<input id="members_go_button" type="submit" class="__wps__button" value="'.__("Search", WPS_TEXT_DOMAIN).'" />';
				if (is_user_logged_in()) {
					$html .= '<div style="clear:both;"><input type="checkbox" id="symposium_member_friends" /> '.__('Only friends', WPS_TEXT_DOMAIN).'</div>';
				}
				$html .= '</div>';	
				$html .= '<input type="text" id="symposium_member" autocomplete="off" name="symposium_member" class="members_search_box" value="'.$term.'" />';
				if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite') && function_exists('__wps__profile_plus')) {
					$html .= '<div style="clear:both">';
					$html .= '<a href="javascript:void(0);" id="symposium_show_advanced" /> '.__('Advanced search', WPS_TEXT_DOMAIN).'</a>';
					$html .= '</div>';
				}
			$html .= "</div>";

			if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite') && function_exists('__wps__profile_plus')) {
				// Loop through extended fields and offer as a search options (if there are any)
				$extensions = $wpdb->get_results("SELECT * FROM ".$wpdb->base_prefix."symposium_extended WHERE search = 'on' ORDER BY extended_order, extended_name");

				if ($extensions) {

					$html .= "<div id='symposium_advanced_search' style='width:90%;padding:0px;display:none;'>";
					
					$html .= "<table style='border:0'>";	

					foreach ($extensions as $extension) {
										
						$html .= '<tr>';

							if ($extension->extended_type == 'Checkbox') {
								$html .= '<td id="__wps__ext_label_'.$extension->eid.'" style="border:0">';
								$html .= stripslashes($extension->extended_name);
								$html .= '</td><td id="__wps__ext_value_'.$extension->eid.'" style="border:0">';
								$html .= '<input rel="checkbox" id="'.$extension->eid.'" class="symposium_extended_search" type="checkbox" name="extended_value[]" />';
								$html .= '</td>';
							}
							if ($extension->extended_type == 'List') {
								$html .= '<td id="__wps__ext_label_'.$extension->eid.'" style="border:0">';
								$html .= stripslashes($extension->extended_name).':';
								$html .= '</td><td id="__wps__ext_value_'.$extension->eid.'" style="border:0">';
								$html .= '<select rel="list" id="'.$extension->eid.'" class="symposium_extended_search" name="extended_value[]">';
								$items = explode(',', $extension->extended_default);
								$html .= '<option value="'.__('Any', WPS_TEXT_DOMAIN).'">'.__('Any', WPS_TEXT_DOMAIN).'</option>';
								foreach ($items as $item) {
									$html .= '<option value="'.$item.'">'.$item.'</option>';
								}												
								$html .= '</select>';
								$html .= '</td>';
							}

						$html .= '</tr>';
					}
					
					$html .= "</table>";
					
					$html .= "</div>";					
				}
			}			
			
			// Sort by option
			$order = get_option(WPS_OPTIONS_PREFIX.'_dir_atoz_order');
			if ($order == 'surname') { $orderby = 'surname'; }
			if ($order == 'display_name') { $orderby = 'u.display_name'; }
			if ($order == 'distance') { $orderby = 'distance, u.display_name'; }
			if ($order == 'last_activity') { $orderby = 'cast(m4.meta_value as datetime) DESC'; }		

			$html .= '<br /><div id="symposium_members_orderby_div">';
				$html .= __('Sort by:', WPS_TEXT_DOMAIN).' ';
				$html .= '<select id="symposium_members_orderby">';
					$html .= '<option value="last_activity"';
						if ($order == 'last_activity') $html .= ' SELECTED';
						$html .= '>'.__('Last activity', WPS_TEXT_DOMAIN).'</option>';
					$html .= '<option value="display_name"';
						if ($order == 'display_name') $html .= ' SELECTED';
						$html .= '>'.__('Display name', WPS_TEXT_DOMAIN).'</option>';
					$html .= '<option value="surname"';
						if ($order == 'surname') $html .= ' SELECTED';
						$html .= '>'.__('Surname (if entered in display name)', WPS_TEXT_DOMAIN).'</option>';
					if (get_option(WPS_OPTIONS_PREFIX.'_use_distance') && function_exists('__wps__profile_plus') && !get_option(WPS_OPTIONS_PREFIX.'_hide_location')) {
						$html .= '<option value="distance"';
							if ($order == 'distance') $html .= ' SELECTED';
							$html .= '>'.__('Distance', WPS_TEXT_DOMAIN).'</option>';
					}
				$html .= '</select>';
			$html .= '</div>';
			
			// A to Z
			$html .= '<div id="symposium_members_atoz">';
				for ($i = 65; $i <= 90; $i++) { 
					if (chr($i) != strtoupper($term)) {
						// Get directory URL worked out
						$member_url = __wps__get_url('members');
						$q = __wps__string_query($member_url);
						$html .= '<a href="'.$member_url.$q.'term='.chr($i).'">'.chr($i).'</a>&nbsp;&nbsp;';
					} else {
						$html .= '<strong>'.chr($i).'</strong>&nbsp;&nbsp;';
					}
				}
			$html .= '</div>';

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

				$search_limit = 1000;
				$sql_ext = strlen($term) != 1 ? "OR (lower(u.display_name) LIKE '% %".$term."%')" : "";
				
				$lat = __wps__get_meta($current_user->ID, 'plus_lat');
				if (get_option(WPS_OPTIONS_PREFIX.'_use_distance') && $lat != 0 && is_user_logged_in() && function_exists('__wps__profile_plus')) {
					
					$long = __wps__get_meta($current_user->ID, 'plus_long');
					$measure = ($value = get_option(WPS_OPTIONS_PREFIX."_plus_lat_long")) ? $value : '';
					$show_alt = ($value = get_option(WPS_OPTIONS_PREFIX."_plus_show_alt")) ? $value : '';
					
					$sql = "SELECT u.ID as uid, u.display_name, cast(m4.meta_value as datetime) as last_activity, 
					CASE 
					  WHEN u.display_name LIKE '% %' THEN right(u.display_name, length(u.display_name)-locate(' ', u.display_name))
					  ELSE u.display_name
					END AS surname,
					CASE m7.meta_value
					  WHEN '0' THEN 99999
					  ELSE FLOOR(((ACOS(SIN(".$lat." * PI() / 180) * SIN(m7.meta_value * PI() / 180) + COS(".$lat." * PI() / 180) * COS(m7.meta_value * PI() / 180) * COS((".$long." - m8.meta_value) * PI() / 180)) * 180 / PI()) * 60 * 1.1515))
					END AS distance 
					FROM ".$wpdb->base_prefix."users u 
					LEFT JOIN ".$wpdb->base_prefix."usermeta m4 ON m4.user_id = u.ID
					LEFT JOIN ".$wpdb->base_prefix."usermeta m7 ON m7.user_id = u.ID
					LEFT JOIN ".$wpdb->base_prefix."usermeta m8 ON m8.user_id = u.ID
					WHERE 
					m4.meta_key = 'symposium_last_activity' AND 
					m7.meta_key = 'symposium_plus_lat' AND 
					m8.meta_key = 'symposium_plus_long' AND 
					(u.display_name IS NOT NULL) AND
					(
					       (lower(u.display_name) LIKE '".$term."%') 
					    ".$sql_ext." 
					)
					ORDER BY ".$orderby." 
					LIMIT 0,".$search_limit;

					$members = $wpdb->get_results($sql);							

				} else {

					$members = $wpdb->get_results("
					SELECT u.ID as uid, u.display_name, cast(m4.meta_value as datetime) as last_activity, 99999 as distance,
					CASE 
					  WHEN u.display_name LIKE '% %' THEN right(u.display_name, length(u.display_name)-locate(' ', u.display_name))
					  ELSE u.display_name
					END AS surname
					FROM ".$wpdb->base_prefix."users u 
					LEFT JOIN ".$wpdb->base_prefix."usermeta m4 ON u.ID = m4.user_id
					WHERE 
					m4.meta_key = 'symposium_last_activity' AND 
					(u.display_name IS NOT NULL) AND
					(
					       (lower(u.display_name) LIKE '".$term."%') 
					    ".$sql_ext." 
					)
					ORDER BY ".$orderby." 
					LIMIT 0,".$search_limit);	
					
				}		

				if (WPS_DEBUG) {
					$html .= $wpdb->last_query;
					$html .= '<p>Returned '.count($members).' records.</p>';
				} else {
					$html .= '<div style="display:none">'.$wpdb->last_query.'</div>';
				}

				if ($members) {

					if (WPS_DEBUG) $html .= '<p>Processing $members.</p>';
				
					$inactive = get_option(WPS_OPTIONS_PREFIX.'_online');
					$offline = get_option(WPS_OPTIONS_PREFIX.'_offline');
					$profile = __wps__get_url('profile');
					$mailpage = __wps__get_url('mail');
					$q = __wps__string_query($mailpage);
					$count = 0;

					$user_info = get_user_by('login', 'nobody');
					$nobody_id = $user_info ? $user_info->ID : 0;

					foreach ($members as $member) {
						
						if (WPS_DEBUG) $html .= 'Member: '.$member->display_name.'<br />';
						
						$user_info = get_userdata($member->uid);							

						// Check to see if this member is in the included list of roles
						if (WPS_DEBUG) $html .= 'Checking capabilities... ';
						$user = get_userdata( $member->uid );
						$capabilities = $user->{$wpdb->base_prefix.'capabilities'};
						
						$include = false;
						if ($capabilities) {
							
							foreach ( $capabilities as $role => $name ) {
								if ($role) {
									if (WPS_DEBUG) $html .= $role.'<br />';
									$role = strtolower($role);
									$role = str_replace(' ', '', $role);
									$role = str_replace('_', '', $role);
									if (WPS_DEBUG) $html .= 'Checking role '.$role.' against '.$dir_levels.'<br />';
									if (strpos($dir_levels, $role) !== FALSE) $include = true;
								} else {
									if (WPS_DEBUG) $html .= 'no role<br />';
								}
							}		 														
						
						} else {
							if (WPS_DEBUG) $html .= 'no capabilities.<br />';
							// No capabilities, so let's assume they should be included
							$include = true;
						}

						if ($include && ($member->uid != $nobody_id)) {

								if (WPS_DEBUG) $html .= 'Include!<br />';

								$city = __wps__get_meta($member->uid, 'extended_city');
								$country = __wps__get_meta($member->uid, 'extended_country');
								$share = __wps__get_meta($member->uid, 'share');
								$wall_share = __wps__get_meta($member->uid, 'wall_share');
		
								$count++;
								if ($count > get_option(WPS_OPTIONS_PREFIX.'_dir_page_length')) break;

								$time_now = time();
								$last_active_minutes = strtotime($member->last_activity);
								$last_active_minutes = floor(($time_now-$last_active_minutes)/60);
															
								$html .= "<div class='members_row";
									
									$is_friend = __wps__friend_of($member->uid, $current_user->ID);
									if ($is_friend || $member->uid == $me) {
										$html .= " row_odd corners";		
									} else {
										$html .= " row corners";		
									}
									$html .= "'>";

									$html .= "<div class='members_info'>";

										$html .= "<div class='members_avatar'>";
											$html .= get_avatar($member->uid, 64);
										$html .= "</div>";	

										$html .= "<div style='padding-left: 75px;'>";						

											if ( ($member->uid == $me) || (is_user_logged_in() && strtolower($share) == 'everyone') || (strtolower($share) == 'public') || (strtolower($share) == 'friends only' && $is_friend) ) {
												$html .= "<div class='members_location'>";
													if ($city != '') {
														$html .= $city;
													}
													if ($country != '') {
														if ($city != '') {
															$html .= ', '.$country;
														} else {
															$html .= $country;
														}
													}
												$html .= "</div>";
											}

											if (function_exists('__wps__mail') && !get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
												// Show Send Mail button
												if (get_option(WPS_OPTIONS_PREFIX.'_show_dir_buttons') && $member->uid != $current_user->ID) {
													if ($is_friend) {
														// A friend
														$html .= "<div class='mail_icon' style='display:none;float:right; margin-right:5px;'>";
														$html .= '<img style="cursor:pointer" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/orange-tick.gif" onclick="document.location = \''.$mailpage.$q.'view=compose&to='.$member->uid.'\';">';
														$html .= "</div>";
													}
												}
											}

											$html .= __wps__profile_link($member->uid);

											if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
												$html .= ', ';
											} else {
												$html .= '<br />';
											}
											$html .= __('last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($member->last_activity).". ";
											if ($last_active_minutes >= $offline) {
												//$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/loggedout.gif">';
											} else {
												if ($last_active_minutes >= $inactive) {
													$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/inactive.gif">';
												} else {
													$html .= '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/online.gif">';
												}
											}

											// Distance
											if (function_exists('__wps__profile_plus') && is_user_logged_in() && $member->distance < 99999 && $member->uid != $current_user->ID) {
												// if privacy settings permit
												if ( (strtolower($share) == 'everyone') 
													|| (strtolower($share) == 'public') 
													|| (strtolower($share) == 'friends only' && __wps__friend_of($member->uid, $current_user->ID)) 
													) {		
													if ($measure != 'on') { 
														$distance = intval(($member->distance/5)*8);
														$miles = __('km', WPS_TEXT_DOMAIN);
													} else {
														$distance = $member->distance;
														$miles = __('miles', WPS_TEXT_DOMAIN);
													}	
													$html .= '<br />'.__('Distance', WPS_TEXT_DOMAIN).': '.$distance.' '.$miles;
													if ($show_alt == 'on') {
														if ($measure != 'on') { 
															$html .= ' ('.intval(($distance/8)*5).' '.__('miles', WPS_TEXT_DOMAIN).')';
														} else {
															$html .= ' ('.intval(($distance/5)*8).' '.__('km', WPS_TEXT_DOMAIN).')';
														}
													}
												}
											}
											
											if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {

												// Show label if entered
												if ($label = __wps__get_meta($member->uid, 'profile_label'))
													$html .= '<div class="__wps__members_info_label">'.$label.'</div>';															

												// if privacy settings permit
												if ( (strtolower($wall_share) == 'everyone') 
													|| (strtolower($wall_share) == 'public') 
													|| (strtolower($wall_share) == 'friends only' && __wps__friend_of($member->uid, $current_user->ID)) 
													) {		
																								
													// Show comment
													$sql = "SELECT cid, comment, type FROM ".$wpdb->base_prefix."symposium_comments
															WHERE author_uid = %d AND comment_parent = 0 AND type = 'post'
															ORDER BY cid DESC 
															LIMIT 0,1";
													$comment = $wpdb->get_row($wpdb->prepare($sql, $member->uid));
													if ($comment) {
														$html .= '<div style="max-height:250px">'.__wps__buffer(__wps__make_url(stripslashes($comment->comment))).'</div>';
													}
													// Show latest non-status activity if applicable
													if (function_exists('__wps__forum')) {
														$sql = "SELECT cid, comment FROM ".$wpdb->base_prefix."symposium_comments
																WHERE author_uid = %d AND comment_parent = 0 AND type = 'forum' 
																ORDER BY cid DESC 
																LIMIT 0,1";
														$forum = $wpdb->get_row($wpdb->prepare($sql, $member->uid));
														if ($forum && (!$comment || $forum->cid != $comment->cid)) {
															$html .= '<div>'.__wps__buffer(__wps__make_url(stripslashes($forum->comment))).'</div>';
														}
													}
												}
											}
											
											// Show add as a friend
											if (is_user_logged_in() && get_option(WPS_OPTIONS_PREFIX.'_show_dir_buttons') && $member->uid != $current_user->ID) {
												if (__wps__pending_friendship($member->uid)) {
													// Pending
													$html .= sprintf(__('%s request sent.', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend'));
												} else {
													if (!$is_friend) {
														// Not a friend
														$html .= '<div id="addasfriend_done1_'.$member->uid.'">';
														$html .= '<input class="add_as_friend_message addfriend_text" title="'.$member->uid.'" id="addtext_'.$member->uid.'" type="text" onclick="this.value=\'\'" value="'.sprintf(__('Add as a %s...', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'">';
														$html .= '<input type="submit" title="'.$member->uid.'" class="addasfriend __wps__button" value="'.__('Add', WPS_TEXT_DOMAIN).'" /> ';						
														$html .= '</div>';
														$html .= '<div id="addasfriend_done2_'.$member->uid.'" class="hidden">'.sprintf(__('%s Request Sent', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'</div>';	
													}
												}
											}

											// Filter for individual member reults
											$html = apply_filters ( '__wps__directory_member_filter', $html, $member->uid);
																					
										$html .= "</div>";	
																				
									$html .= "</div>";	// members_info

								$html .= "</div>";	// members_row
																
														
						} // if ($include)
						
					} // foreach ($members as $member)

					$html .= "<div id='showmore_directory_div' style='text-align:center; width:100%'><a href='javascript:void(0)' id='showmore_directory'>".__("more...", WPS_TEXT_DOMAIN)."</a></div>";

				} else {
					$html .= '<br />'.__('No members found', WPS_TEXT_DOMAIN)."....";
				} // if ($members)

			}
			
		$html .= '</div>'; // __wps__members
		
	$html .= '</div>'; // __wps__wrapper

	// Filter for header
	$html = apply_filters ( 'symposium_member_header_filter', $html );

	// Send HTML
	return $html;

}
Example #17
0
function __wps__groups() {	
	
	
	global $wpdb, $current_user;
	
	// View (and set tabs)
	if (!isset($_GET['view']) || $_GET['term'] != '') {
		$browse_active = 'active';
		$create_active = 'inactive';
		$view = "browse";
	} 
	if ( isset($_GET['view']) && $_GET['view'] == "create") {
		$browse_active = 'inactive';
		$create_active = 'active';
		$view = "create";
	} 

	$thispage = get_permalink();
	if ($thispage[strlen($thispage)-1] != '/') { $thispage .= '/'; }

	$group_url = get_option(WPS_OPTIONS_PREFIX.'_group_url');
	$group_all_create = get_option(WPS_OPTIONS_PREFIX.'_group_all_create');

	if (isset($_GET['page_id']) && $_GET['page_id'] != '') {
		// No Permalink
		$thispage = $group_url;
		$q = "&";
	} else {
		$q = "?";
	}

	if (isset($_GET['term'])) {
		$term = $_GET['term'];
	} else {
		$term = '';
	}

	$html = '<div class="__wps__wrapper">';

		if ( (is_user_logged_in()) && ($group_all_create == "on" || __wps__get_current_userlevel() == 5) ) {

			$html .= "<input type='submit' id='show_create_group_button' class='__wps__button' value='".__("Create Group", WPS_TEXT_DOMAIN)."'>";

			$html .= "<div id='create_group_form' style='display:none'>";
				$html .= "<div>";
				$html .= "<strong>".__("Name of Group", WPS_TEXT_DOMAIN)."</strong><br />";
				$html .= "<input type='text' id='name_of_group' class='new-topic-subject-input' style='width: 98% !important;'>";
				$html .= "</div>";

				$html .= "<div>";
				$html .= "<strong>".__("Description", WPS_TEXT_DOMAIN)."</strong><br />";
				$html .= "<input type='text' id='description_of_group' style='width: 98% !important;'>";
				$html .= "</div>";

				$html .= "<div style='margin-top:10px'>";
				$html .= "<input type='submit' id='create_group_button' class='__wps__button' value='".__("Create", WPS_TEXT_DOMAIN)."'>";
				$html .= "<input type='submit' id='cancel_create_group_button' class='__wps__button' value='".__("Cancel", WPS_TEXT_DOMAIN)."'>";
				$html .= "</div>";
			$html .= "</div>";

		}
		
		$html .= "<div id='groups_results'>";
		
		if ( $term != '' ) {
	
			$me = $current_user->ID;
			$page = 1;
			$page_length = 25;
	
			$term = "";
			if (isset($_POST['group'])) { $term .= $_POST['group']; }
			if (isset($_GET['term'])) { $term .= $_GET['term']; }

			$html .= "<div style='padding:0px;'>";
			$html .= '<input type="text" id="group" name="group" autocomplete="off" class="groups_search_box" value="'.$term.'" style="margin-right:10px" />';
			$html .= '<input type="hidden" id="group_id" name="group_id" />';
			$html .= '<input id="groups_go_button" type="submit" class="__wps__button" value="'.__("Search", WPS_TEXT_DOMAIN).'" />';
			$html .= "</div>";	

	
			$sql = "SELECT g.*, (SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_group_members WHERE group_id = g.gid) AS member_count
			FROM ".$wpdb->prefix."symposium_groups g WHERE  
			( g.name LIKE '%".$term."%') OR 
			( g.description LIKE '%".$term."%' )
			ORDER BY group_order, last_activity DESC LIMIT 0,25";
			
			$groups = $wpdb->get_results($sql);


			if ($groups) {
				
				foreach ($groups as $group) {

					if (__wps__member_of($group->gid) == 'yes') { 
						$html .= "<div class='groups_row row_odd corners'>";
					} else {
						$html .= "<div class='groups_row row corners'>";
					}					
					
						$html .= "<div class='groups_avatar'>";
							$html .= __wps__get_group_avatar($group->gid, 64);
						$html .= "</div>";

						$html .= "<div class='group_name'>";
						$name = stripslashes($group->name) != '' ? stripslashes($group->name) : __('[No name]', WPS_TEXT_DOMAIN);
						$html .= "<a class='row_link' href='".__wps__get_url('group')."?gid=".$group->gid."'>".$name."</a>";
						$html .= "</div>";
						
						$html .= "<div class='group_member_count'>";
						$html .= __("Member Count:", WPS_TEXT_DOMAIN)." ".$group->member_count;
						if ($group->last_activity) {
							$html .= '<br /><em>'.__('last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($group->last_activity)."</em>";
						}
						$html .= "</div>";
					
						$html .= "<div class='group_description'>";
						$html .= $group->description;
						$html .= "</div>";
						
					$html .= "</div>";
					
				}
	
			}
			
		} else {
	
	
			$html .= "<div style='padding:0px;'>";
			$html .= '<input type="text" id="__wps__group" name="group" autocomplete="off" class="groups_search_box" value="'.$term.'" style="margin-right:10px" />';
			$html .= '<input type="hidden" id="group_id" name="group_id" />';
			$html .= '<input id="groups_go_button" type="submit" class="__wps__button" value="'.__("Search", WPS_TEXT_DOMAIN).'" />';
			$html .= "</div>";	
	
			
			$html .= "<div id='__wps__groups'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/busy.gif' /></div>";
			
		}
		
		$html .= "</div>"; // End of Groups Results
		
		if (isset($groups) && !$groups) 
				$html .= "<div style='clear:both'>".__("No group found....", WPS_TEXT_DOMAIN)."</div>";
		
	$html .= '</div>'; // End of Wrapper
	
	// Send HTML
	return $html;

}
Example #18
0
				$html .= "<div id='friend_".$id."' class='friend_div row_odd corners' style='clear:right; margin-top:8px; overflow: auto; margin-bottom: 15px; padding:6px; width:95%;'>";
				
					$html .= "<div style='width:64px; margin-right: 15px'>";
						$html .= get_avatar($id, 64);
					$html .= "</div>";
										
					$html .= "<div style='padding-left:74px;'>";
						$html .= __wps__profile_link($id);
						$html .= "<br />";
						if ($last_active_minutes >= $offline) {
							$html .= __('Logged out', WPS_TEXT_DOMAIN).'. '.__('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend['last_activity']).".";
						} else {
							if ($last_active_minutes >= $inactive) {
								$html .= __('Offline', WPS_TEXT_DOMAIN).'. '.__('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend['last_activity']).".";
							} else {
								$html .= __('Last active', WPS_TEXT_DOMAIN).' '.__wps__time_ago($friend['last_activity']).".";
							}
						}
						if (!get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) {
							$html .= '<br />';
							// Show comment
							$sql = "SELECT cid, comment
								FROM ".$wpdb->base_prefix."symposium_comments
								WHERE author_uid = %d AND subject_uid = %d AND comment_parent = 0 AND type = 'post'
								ORDER BY cid DESC
								LIMIT 0,1";
							$comment = $wpdb->get_row($wpdb->prepare($sql, $id, $id));
							if ($comment) {
								$html .= '<div>'.__wps__buffer(__wps__make_url(stripslashes($comment->comment))).'</div>';
							}