Exemplo n.º 1
0
function __wps__show_gallery() {
	
	global $wpdb, $current_user;
		
	$html = '';
	$html .= "<div class='__wps__wrapper'>";

	$term = "";
	if (isset($_GET['term'])) { $term .= strtolower($_GET['term']); }	
		
	$html .= "<div style='padding:0px'>";
	$html .= '<input type="text" id="gallery_member" autocomplete="off" name="gallery_member" class="gallery_member_box" value="'.$term.'" style="margin-right:10px" />';
	$html .= '<input id="gallery_go_button" type="submit" class="__wps__button" value="'.__("Search", WPS_TEXT_DOMAIN).'" />';
	$html .= "</div>";	
	
	$sql = "SELECT g.*, u.display_name FROM ".$wpdb->base_prefix."symposium_gallery g
			INNER JOIN ".$wpdb->base_prefix."users u ON u.ID = g.owner
			WHERE g.name LIKE '%".$term."%' 
			   OR u.display_name LIKE '%".$term."%' 
			ORDER BY gid DESC 
			LIMIT 0,50";

	$albums = $wpdb->get_results($sql);
	
	$album_count = 0;	
	$total_count = 0;
	
	if ($albums) {
		
		$page_length = (get_option(WPS_OPTIONS_PREFIX."_gallery_page_length") != '') ? get_option(WPS_OPTIONS_PREFIX."_gallery_page_length") : 10;

		$html .= "<div id='symposium_gallery_albums'>";
		
		foreach ($albums AS $album) {

			$total_count++;				

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

				$sql = "SELECT COUNT(iid) FROM ".$wpdb->base_prefix."symposium_gallery_items WHERE gid = %d";
				$photo_count = $wpdb->get_var($wpdb->prepare($sql, $album->gid));	
				
				if ($photo_count > 0) {

					$sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_gallery_items WHERE gid = %d ORDER BY photo_order DESC";
					$photos = $wpdb->get_results($wpdb->prepare($sql, $album->gid));	
					
					// Check that at least one actually exists
					$tmpDir = get_option(WPS_OPTIONS_PREFIX.'_img_path');
					$img_exists = false;
					if ($photos && get_option(WPS_OPTIONS_PREFIX.'_img_db') != "on") {
						foreach ($photos as $photo) {
		                	$img_src = '/members/'.$album->owner.'/media/'.$album->gid.'/'.$photo->name;
		                	if (file_exists($tmpDir.$img_src)) {
		                	    $img_exists = true;
		                	    break;
		                	}
						}
					} else {
						$img_exists = true;
					}
					
					if ($img_exists) {
						
						$html .= "<div id='__wps__album_content' style='padding-bottom:30px;'>";
	
							$html .= "<div id='wps_gallery_album_name_".$album->gid."' class='topic-post-header'>".stripslashes($album->name)."</div>";
							$html .= "<p>".__wps__profile_link($album->owner)."</p>";
				
							if ($photos) {
								
								$album_count++;
								
								$cnt = 0;
			
								$thumbnail_size = (get_option(WPS_OPTIONS_PREFIX."_gallery_thumbnail_size") != '') ? get_option(WPS_OPTIONS_PREFIX."_gallery_thumbnail_size") : 75;
								$html .= '<div id="wps_comment_plus" style="width:98%;height:'.($thumbnail_size+10).'px;overflow:hidden; ">';
					
								$preview_count = (get_option(WPS_OPTIONS_PREFIX."_gallery_preview") != '') ? get_option(WPS_OPTIONS_PREFIX."_gallery_preview") : 5;
					       		foreach ($photos as $photo) {
					       		    
					       		    $cnt++;
					              					
									if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == "on") {
										
										$img_src = WP_CONTENT_URL."/plugins/wp-symposium/get_album_item.php?iid=".$photo->iid."&size=photo";
										$thumb_src = WP_CONTENT_URL."/plugins/wp-symposium/get_album_item.php?iid=".$photo->iid."&size=thumbnail";
										
									} else {

					                	$tmp_src = '/members/'.$album->owner.'/media/'.$album->gid.'/thumb_'.$photo->name;
              							if (file_exists($tmpDir.$tmp_src)) { 

											if (get_option(WPS_OPTIONS_PREFIX."_gallery_show_resized") == 'on') {
							                	$img_src = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/members/'.$album->owner.'/media/'.$album->gid.'/show_'.$photo->name;
											} else {
							                	$img_src = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/members/'.$album->owner.'/media/'.$album->gid.'/'.$photo->name;
											}
						        	        $thumb_src = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/members/'.$album->owner.'/media/'.$album->gid.'/thumb_'.$photo->name;
					        	        
              							} else {
              							    $img_src = __wps__siteURL().get_option(WPS_OPTIONS_PREFIX.'_images').'/broken_file_link.png';
						        	        $thumb_src = __wps__siteURL().get_option(WPS_OPTIONS_PREFIX.'_images').'/broken_file_link.png';
              							}              							    
              							
									}
					
					               	$html .= '<div class="__wps__photo_outer">';
					           			$html .= '<div class="__wps__photo_inner">';
					      						$html .= '<div class="__wps__photo_cover">';
												$html .= '<a class="__wps__photo_cover_action wps_gallery_album" data-owner="'.$album->owner.'" data-iid="'.$photo->iid.'" data-name="'.stripslashes($photo->title).'" href="'.$img_src.'" rev="'.$cnt.'" rel="symposium_gallery_photos_'.$album->gid.'" title="'.stripslashes($album->name).'">';
					        						$thumbnail_size = (get_option(WPS_OPTIONS_PREFIX."_gallery_thumbnail_size") != '') ? get_option(WPS_OPTIONS_PREFIX."_gallery_thumbnail_size") : 75;
					        						$html .= '<img class="__wps__photo_image" style="width:'.$thumbnail_size.'px; height:'.$thumbnail_size.'px;" src="'.$thumb_src.'" />';
					        					$html .= '</a>';
					     						$html .= '</div>';
					       					$html .= '</div>';
					     				$html .= '</div>';
			
						       		if (count($photos) > $preview_count && $cnt == $preview_count) {
						       		    $html .= '<div id="wps_gallery_comment_more" style="cursor:pointer">'.__('more...', WPS_TEXT_DOMAIN).'<div style="clear:both"></div></div>';
						       		}   		
					      				
					       		}
					       		
					       		$html .= '</div>';							
							
							} else {
							
						      	 $html .= __("No photos yet.", WPS_TEXT_DOMAIN);
						     
							}
			
						$html .= '</div>';	
					}
				}	
	
				if ($album_count == $page_length) { break; }
				
			}
		
		}
	
		$html .= "<div style='clear:both;text-align:center; margin-top:20px; width:100%'><a href='javascript:void(0)' id='showmore_gallery'>".__("more...", WPS_TEXT_DOMAIN)."</a></div>";
		
		$html .= '</div>';
		
		
	}

	// Stores start value for more
	$html .= '<div id="symposium_gallery_start" style="display:none">'.$total_count.'</div>';
	$html .= '<div id="symposium_gallery_page_length" style="display:none">'.$page_length.'</div>';


	$html .= '</div>';
	return $html;
}
Exemplo n.º 2
0
function __wps__do_Recentactivity_Widget($postcount,$preview,$forum) {
	
	global $wpdb, $current_user;
	
	$shown_uid = "";
	$shown_count = 0;	
	$html = '';
	// Work out link to profile page, dealing with permalinks or not
	$profile_url = __wps__get_url('profile');
	$q = __wps__string_query($profile_url);

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

	// Content of widget
	$sql = "SELECT cid, author_uid, comment, comment_timestamp, display_name, type 
	FROM ".$wpdb->base_prefix."symposium_comments c 
	INNER JOIN ".$wpdb->base_prefix."users u ON c.author_uid = u.ID 
	WHERE is_group != 'on' 
	  AND comment_parent = 0 
	  AND author_uid != %d AND subject_uid != %d 
	  AND author_uid = subject_uid ";
	if ($forum != 'on') { $sql .= "AND type != 'forum' "; }		  
	$sql .= "ORDER BY cid DESC LIMIT 0,250";
	
	$posts = $wpdb->get_results($wpdb->prepare($sql, $nobody_id, $nobody_id));
			
	if ($posts) {

		$html .= "<div id='__wps__recent_activity'>";
			
			foreach ($posts as $post)
			{
				if ($shown_count < $postcount) {

					if (strpos($shown_uid, $post->author_uid.",") === FALSE) { 

						$share = __wps__get_meta($post->author_uid, 'wall_share');
						$is_friend = __wps__friend_of($post->author_uid, $current_user->ID);

						if ( (is_user_logged_in() && strtolower($share) == 'everyone') || (strtolower($share) == 'public') || (strtolower($share) == 'friends only' && $is_friend) ) {

							$html .= "<div class='__wps__recent_activity_row'>";		
								$html .= "<div class='__wps__recent_activity_row_avatar'>";
									$html .= "<a href='".$profile_url.$q."uid=".$post->author_id."'>";
										$html .= get_avatar($post->author_uid, 32);
									$html .= "</a>";
								$html .= "</div>";
								$html .= "<div class='__wps__recent_activity_row_post'>";
									$text = stripslashes($post->comment);
									if ($post->type == 'post') {
										$text = stripslashes($post->comment);
										$text = strip_tags($text);
										if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; }
									}
									if (($x = strpos($text, 'wps_comment_plus')) !== FALSE) {
										$text = substr($text, 0, $x-9);
									}
									if ($post->type == 'gallery') {												
										if (strpos($text, '[]')) {
											$lib = explode('[]', $text);
											$text = $lib[0];
										} else {
											if (($x = strpos($text, 'wps_comment_plus')) !== FALSE) {
												$text = substr($text, 0, $x-9);
											}
										}
									}
									if (strpos($text, '__wps__photo_image')) {
										$text = strip_tags($text,'<img><a></a>');
										$text = str_replace("img", "img style='width:32px;height:32px;'", $text);
										$html .= __wps__time_ago($post->comment_timestamp)." <a href='".$profile_url.$q."uid=".$post->author_uid."&post=".$post->cid."'>".$post->display_name."</a> ".$text."<br>";
									} else {
										$html .= "<a href='".$profile_url.$q."uid=".$post->author_uid."&post=".$post->cid."'>".$post->display_name."</a> ".$text." ".__wps__time_ago($post->comment_timestamp).".<br>";
									}
								$html .= "</div>";
							$html .= "</div>";
						
							$shown_count++;
							$shown_uid .= $post->author_uid.",";							
						}
					}
				} else {
					break;
				}
			}

		$html .= "</div>";

	}
		
	echo $html;
}
Exemplo n.º 3
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;

}
Exemplo n.º 4
0
	function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false, $link = true ) {

		global $wpdb, $current_user;
							
		if ( false === $alt)
			$safe_alt = '';
		else
			$safe_alt = esc_attr( $alt );
	
		if ( !is_numeric($size) )
			$size = '96';
	
		$email = '';
		$display_name = '';
		if ( is_numeric($id_or_email) ) {
			$id = (int) $id_or_email;
			$user = get_userdata($id);
			if ( $user )
				$email = $user->user_email;
		} elseif ( is_object($id_or_email) ) {
			// No avatar for pingbacks or trackbacks
			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
				return false;
	
			if ( !empty($id_or_email->user_id) ) {
				$id = (int) $id_or_email->user_id;
				$user = get_userdata($id);
				if ( $user)
					$email = $user->user_email;
			} elseif ( !empty($id_or_email->comment_author_email) ) {
				$email = $id_or_email->comment_author_email;
			}
		} else {
			$id = $wpdb->get_var("select ID from ".$wpdb->base_prefix."users where user_email = '".$id_or_email."'");
		}
	
		if ( empty($default) ) {
			$avatar_default = get_option('avatar_default');
			if ( empty($avatar_default) )
				$default = 'mystery';
			else
				$default = $avatar_default;
		}
	
		if ( !empty($email) )
			$email_hash = md5( strtolower( $email ) );
	
		if ( is_ssl() ) {
			$host = 'https://secure.gravatar.com';
		} else {
			if ( !empty($email) )
				$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
			else
				$host = 'http://0.gravatar.com';
		}
	
		if ( 'mystery' == $default )
			$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('*****@*****.**')
		elseif ( 'blank' == $default )
			$default = includes_url('images/blank.gif');
		elseif ( !empty($email) && 'gravatar_default' == $default )
			$default = '';
		elseif ( 'gravatar_default' == $default )
			$default = "$host/avatar/s={$size}";
		elseif ( empty($email) )
			$default = "$host/avatar/?d=$default&amp;s={$size}";
		elseif ( strpos($default, 'http://') === 0 )
			$default = add_query_arg( 's', $size, $default );
			
		if ( !empty($email) ) {
			$out = "$host/avatar/";
			$out .= $email_hash;
			$out .= '?s='.$size;
			$out .= '&amp;d=' . urlencode( $default );
	
			$rating = get_option('avatar_rating');
			if ( !empty( $rating ) )
				$out .= "&amp;r={$rating}";
	
			$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
		} else {
			$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
		}
		
		$return = '';
		
		if (!isset($id)) { $id = 0; }
		if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == "on") {
		
			$profile_photo = __wps__get_meta($id, 'profile_avatar');
			$profile_avatars = get_option(WPS_OPTIONS_PREFIX.'_profile_avatars');
		
			if ($profile_photo == '' || $profile_photo == 'upload_failed' || $profile_avatars != 'on') {
				$return .= apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
			} else {
				$return .= "<img src='".WP_CONTENT_URL."/plugins/".WPS_DIR."/server/get_profile_avatar.php?uid=".$id."' style='width:".$size."px; height:".$size."px' class='avatar avatar-".$size." photo' />";
			}
			
		} else {

			$profile_photo = __wps__get_meta($id, 'profile_photo');
			$profile_avatars = get_option(WPS_OPTIONS_PREFIX.'_profile_avatars');

			if ($profile_photo == '' || $profile_photo == 'upload_failed' || $profile_avatars != 'on') {
				$return .= apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
			} else {
				$img_url = get_option(WPS_OPTIONS_PREFIX.'_img_url')."/members/".$id."/profile/";	
				$img_src = str_replace('//','/',$img_url) . $profile_photo;
				$return .= "<img src='".$img_src."' style='width:".$size."px; height:".$size."px' class='avatar avatar-".$size." photo' />";
			}
			
		}
		
		if (!get_option(WPS_OPTIONS_PREFIX.'_wps_use_gravatar') && strpos($return, 'gravatar')) {
			$return = "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/unknown.jpg' style='width:".$size."px; height:".$size."px' class='avatar avatar-".$size." photo' />";
		}

		// Get URL to profile
		if (function_exists('__wps__profile') && $id != '' ) {
			$profile_url = __wps__get_url('profile');
			$profile_url = $profile_url.__wps__string_query($profile_url).'uid='.$id;
			if ($link) {
				$p = " style='cursor:pointer' onclick='javascript:document.location=\"".$profile_url."\";' />";
			} else {
				$p = " style='cursor:pointer' />";
			}
	       	$return = str_replace("/>", $p, $return);                          
		}

		// Filter to allow changes
		$return = apply_filters('__wps__get_avatar_filter', $return, $id);

		// Add Profile Plus (hover box) if installed
		if (function_exists('__wps__profile_plus')) {
			if (get_option(WPS_OPTIONS_PREFIX.'_wps_show_hoverbox') == 'on') {
				if ($id != '') {
					$display_name = str_replace("'", "&apos;", $wpdb->get_var("select display_name from ".$wpdb->base_prefix."users where ID = '".$id."'"));
				} else {
					$display_name = '';
				}
				if (__wps__friend_of($id, $current_user->ID)) {
			       	$return = str_replace("class='", "rel='friend' title = '".$display_name."' id='".$id."' class='__wps__follow ", $return);
				} else {
					if (__wps__pending_friendship($id)) {
				       	$return = str_replace("class='", "rel='pending' title = '".$display_name."' id='".$id."' class='__wps__follow ", $return);
					} else {
				       	$return = str_replace("class='", "rel='' title = '".$display_name."' id='".$id."' class='__wps__follow ", $return);
					}
				}
				if (__wps__is_following($current_user->ID, $id)) {
					$return = str_replace("class='", "rev='following' class='", $return);
				} else {
					$return = str_replace("class='", "rev='' class='", $return);
				}
			}
		}

		return $return;

	}
Exemplo n.º 5
0
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;
	
}
Exemplo n.º 6
0
    function get_activity($uid1='', $version='wall', $limit_from, $limit_count) {
		
		// version = stream_activity, friends_activity, all_activity
		// uid1 = the user's page (which we are looking at)
		// uid2 = the current user
		// $limit_from (starting post)
		// $limit_count (how many to show)
		// $post (individual activity post ID if applicable)
		
		global $wpdb,$current_user;
		if ($uid1 == '') $uid1 = $current_user->ID;
		$uid2 = $current_user->ID;
		
		// Get privacy level for this member's activity
	
		$privacy = $uid1 > 0 ? __wps__get_meta($uid1, 'wall_share') : 'public';
	
		
		if (is_user_logged_in() || $privacy == 'public') {	
		
			$is_friend = ($uid1 > 0) ? __wps__friend_of($uid1, $current_user->ID) : false;	
			
			if ( ($uid1 == $uid2) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && $is_friend) || __wps__get_current_userlevel() == 5) {
	
					$post_cid = '';
	
					// Add groups join if in use
					if (function_exists('__wps__groups')) {
						$groups = "LEFT JOIN ".$wpdb->prefix."symposium_groups g ON c.subject_uid = g.gid";
						$group_field = ", g.content_private";
					} else {
						$groups = "";
						$group_field = ", 'on' as content_private";
					}
	
					if ($version == "all_activity" || $version == "stream_activity") {
						$sql = "SELECT c.*, u.display_name, u2.display_name AS subject_name" . $group_field . "   
						FROM ".$wpdb->base_prefix."symposium_comments c 
						LEFT JOIN ".$wpdb->base_prefix."users u ON c.author_uid = u.ID 
						LEFT JOIN ".$wpdb->base_prefix."users u2 ON c.subject_uid = u2.ID 
						" . $groups . "
						WHERE ( ".$post_cid." c.comment_parent = 0 
						  ) AND c.type != 'photo' 
						ORDER BY c.comment_timestamp DESC LIMIT %d,%d";					
						$comments = $wpdb->get_results($wpdb->prepare($sql, $limit_from, $limit_count));	
					}
				
					if ($version == "friends_activity") {
						$sql = "SELECT c.*, u.display_name, u2.display_name AS subject_name" . $group_field . " 
						FROM ".$wpdb->base_prefix."symposium_comments c 
						LEFT JOIN ".$wpdb->base_prefix."users u ON c.author_uid = u.ID 
						LEFT JOIN ".$wpdb->base_prefix."users u2 ON c.subject_uid = u2.ID 
						" . $groups . "
						WHERE ( ".$post_cid." (
						      ( (c.subject_uid = %d) OR (c.author_uid = %d) OR (c.subject_uid = %d) OR (c.author_uid = %d)  
						   OR ( c.author_uid IN (SELECT friend_to FROM ".$wpdb->base_prefix."symposium_friends WHERE friend_from = %d)) ) AND c.comment_parent = 0 
					   	   OR ( 
					   	   		%d IN (SELECT author_uid FROM ".$wpdb->base_prefix."symposium_comments WHERE comment_parent = c.cid ) 
								AND ( c.author_uid IN (SELECT friend_to FROM ".$wpdb->base_prefix."symposium_friends WHERE friend_from = %d)) 
					   	   	  ) )
						  ) AND c.type != 'photo' 
						ORDER BY c.comment_timestamp DESC LIMIT %d,%d";	
						$comments = $wpdb->get_results($wpdb->prepare($sql, $uid1, $uid1, $uid2, $uid2, $uid1, $uid1, $uid1, $limit_from, $limit_count));	
					}
				
					if ($version == "wall") {
						$sql = "SELECT c.*, u.display_name, u2.display_name AS subject_name" . $group_field . " 
								FROM ".$wpdb->base_prefix."symposium_comments c 
								LEFT JOIN ".$wpdb->base_prefix."users u ON c.author_uid = u.ID 
								LEFT JOIN ".$wpdb->base_prefix."users u2 ON c.subject_uid = u2.ID 
								" . $groups . "
								WHERE (".$post_cid." (
								      ( (c.subject_uid = %d OR c.author_uid = %d) AND c.comment_parent = 0 )
							   	   OR ( %d IN (SELECT author_uid FROM ".$wpdb->base_prefix."symposium_comments WHERE comment_parent = c.cid  ) )
								  ) ) AND c.type != 'photo' 
								ORDER BY c.comment_timestamp DESC LIMIT %d,%d";
						$comments = $wpdb->get_results($wpdb->prepare($sql, $uid1, $uid1, $uid1, $limit_from, $limit_count));	
						
					}
	
					return $comments;
				
			} else {			
				return false;
			}
			
		} else {
	
			return false;		
			
		}

    }        
Exemplo n.º 7
0
		}
	
	   	$html .= "<div id='__wps__album_covers'>";
	
	   	$sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_gallery WHERE owner = %d AND (parent_gid = %d OR parent_gid = 0) ORDER BY updated DESC";
	    $albums = $wpdb->get_results($wpdb->prepare($sql, $user_page, $album_id));	
	       
		// Show album covers
	   	if ($albums) {
	
			$html = apply_filters('__wps__gallery_header', $html);
	 
	       	foreach ($albums as $album) {
	
				// check for privacy
				if ( ($album->owner == $current_user->ID) || (strtolower($album->sharing) == 'public') || (is_user_logged_in() && strtolower($album->sharing) == 'everyone') || (strtolower($album->sharing) == 'friends only' && __wps__friend_of($album->owner, $current_user->ID)) || __wps__get_current_userlevel() == 5) {
	
					// Get cover image
			     	$sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_gallery_items WHERE gid = %d AND cover = 'on'";
					$cover = $wpdb->get_row($wpdb->prepare($sql, $album->gid));
					
					if ($cover) {
		
						if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == "on") {
							// Database
							$thumb_src = WP_CONTENT_URL."/plugins/wp-symposium/get_album_item.php?iid=".$cover->iid."&size=thumbnail";
						} else {
							// Filesystem
							if (file_exists(get_option(WPS_OPTIONS_PREFIX.'_img_path').'/members/'.$cover->owner.'/media/'.$album->gid.'/thumb_'.$cover->name)) {
				        	    $thumb_src = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/members/'.$cover->owner.'/media/'.$album->gid.'/thumb_'.$cover->name;
							} else {
Exemplo n.º 8
0
	exit;
	
}

// Start events content
if ($_POST['action'] == 'menu_events') {

	$html = "";

	global $current_user; 
	$uid1 = $current_user->ID; // Current user
	$uid2 = $_POST['uid1']; // Which member's page is this?
	
	$privacy = __wps__get_meta($uid2, 'wall_share');		
	
	$is_friend = __wps__friend_of($uid2, $current_user->ID);
	
	if ( ($uid1 == $uid2) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && $is_friend) || __wps__get_current_userlevel() == 5) {

		$html .= "<p class='__wps__profile_heading'>".__('Events', WPS_TEXT_DOMAIN)."</p>";

		// Create events form
		if ($uid1 == $uid2) {		

			$html .= '<input type="submit" id="__wps__create_event_button" class="__wps__button" value="'.__('Create Event', WPS_TEXT_DOMAIN).'">';
		
			$html .= '<div id="__wps__create_event_form" style="display:none">';

				$html .= '<div class="new-topic-subject label">'.__("Event Name", WPS_TEXT_DOMAIN).'</div>';
				$html .= '<input id="__wps__create_event_name" class="new-topic-subject-input" type="text" value="">';
Exemplo n.º 9
0
												$html .= '<br />'.__('Location is set to private', WPS_TEXT_DOMAIN);
											}
										} else {
											// No distance recorded for member
										}
										
										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>'.__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' 
Exemplo n.º 10
0
function __wps__show_profile_menu_tabs($uid1, $uid2) {
        	
	global $wpdb, $current_user;

		$menu = '';
		$share = __wps__get_meta($uid1, 'share');		
		$privacy = __wps__get_meta($uid1, 'wall_share');		
		$is_friend = __wps__friend_of($uid1, $current_user->ID);
		if ( $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM ".$wpdb->base_prefix."usermeta WHERE user_ID = %d AND meta_key LIKE '%symposium_extended_%' AND meta_value != ''", $uid1) ) > 0 ) { $extended = "on"; } else { $extended = ""; }
		
		if ($uid1 == $uid2) {
			$structure = get_option(WPS_OPTIONS_PREFIX."_profile_menu_structure");
		} else {
			$structure = get_option(WPS_OPTIONS_PREFIX."_profile_menu_structure_other");
		}
		$str_arr = explode(chr(10), $structure);
		
		if ( ($uid1 == $uid2) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && $is_friend) ) {
			
			// Filter for additional menu items 
			$menu .= '<div style="float:right;text-align:right;">'.apply_filters ( '__wps__profile_menu_filter_tabs', $menu, $uid1, $uid2, $privacy, $is_friend, $extended, $share, '' ).'</div>';

			$menu .= '<ul class="__wps__dropdown">';

			// Note pending friends
			$pending_friends = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_friends f WHERE f.friend_to = %d AND f.friend_accepted != 'on'", $uid1));		
			if ( ($pending_friends > 0) && ($uid1 == $uid2) ) {
				$pending_friends = " (".$pending_friends.")";
			} else {
				$pending_friends = "";
			}	
			
			// Build menu		
			$started_top_level = false;
			foreach($str_arr as $item) {
				
				// Top level menu items
				if (strpos($item, '[') !== false) {
					$item = str_replace('[', '', $item);
					$item = str_replace(']', '', $item);
					if ($started_top_level) {
						$menu .= '</ul></li>';
					}
					$started_top_level = true;
					$item = str_replace('%f', $pending_friends, $item);
					$menu .= '<li class="__wps__top_menu">'.$item;
					$menu .= '<ul class="__wps__sub_menu">';
				}
				
				// Child item
				if (strpos($item, '=') !== false) {
					list($title,$value) = explode('=', $item);
					$value = str_replace(chr(13), '', $value);
					$i = '';

					$menu = apply_filters ( '__wps__profile_menu_tabs_filter', $menu, $title, $value, $uid1, $uid2, $privacy, $is_friend, $extended, $share );
	
					switch ($value) {
					case 'viewprofile' :
						if ( (is_user_logged_in() && strtolower($share) == 'everyone') || (strtolower($share) == 'public') || (strtolower($share) == 'friends only' && $is_friend) || ($uid1 == $uid2)) {
							$i = '<li id="menu_extended" class="__wps__profile_menu">'.$title.'</li>';
						}
						break;
					case 'details' :
						if ($uid1 == $uid2)
							$i = '<li id="menu_settings" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						break;
					case 'settings':
						if ($uid1 == $uid2)
							$i = '<li id="menu_personal" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						break;
					case 'avatar' :
						if ( ($uid1 == $uid2) && (get_option(WPS_OPTIONS_PREFIX.'_profile_avatars') == "on") )
							$i = '<li id="menu_avatar" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						break;				
					case 'activitymy' :
						$i = '<li id="menu_wall" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						break;
					case 'activityfriends' :
						if (strtolower($share) == 'public' && !(is_user_logged_in())) {
							// don't show friends activity to public
						} else {
							$i = '<li id="menu_activity" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						}
						break;
					case 'activityall' :
						if (strtolower($share) == 'public' && !(is_user_logged_in())) {
							// don't show all activity to public
						} else {
							$i = '<li id="menu_all" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						}
						break;
					case 'myfriends' :
						if ( ($uid1 == $uid2) || (is_user_logged_in() && strtolower($share) == 'everyone') || (strtolower($share) == 'friends only' && $is_friend) || __wps__get_current_userlevel() == 5) {
							if ($uid1 == $uid2) {
								$i = '<li id="menu_friends" class="__wps__profile_menu" href="javascript:void(0)">'.$title.' '.$pending_friends.'</li>';
							} else {
								$i = '<li id="menu_friends" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
							}
						}
						break;
					case 'mygroups' :
						if (function_exists('__wps__group'))
							$i = '<li id="menu_groups" class="__wps__profile_menu" href="javascript:void(0)">'.$title.'</li>';
						break;
					default :
						$i = apply_filters ( '__wps__profile_menu_tabs', '', $title, $value, $uid1, $uid2, $privacy, $is_friend, $extended, $share );
						break;
					}
					if ($i) $menu .= $i;
				}
				
			}
			if ($started_top_level) {
				$menu .= '</ul></li>';
			}

			$menu .= '</ul>';
				
			$menu .= '<div id="__wps__menu_tabs_wrapper"></div>';
			
			$menu .= '<div style="clear:both;padding-bottom:20px;"></div>';
		
		} else {
			
			$menu = '';
			
		}
		
	return $menu;

}
Exemplo n.º 11
0
				}
				
				$time_now = time();
				$last_active_minutes = strtotime($member['last_activity']);
				$last_active_minutes = floor(($time_now-$last_active_minutes)/60);
												
				$html .= "<div id='request_".$member['ID']."' class='wall_post_div members_row row_odd corners'>";		

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

						// Delete icons
						if ( (__wps__get_current_userlevel() == 5 || __wps__group_admin($uid1) == "yes") && ($member['admin'] != 'on') ) {
							$html .= " <a title='".$member['ID']."' href='javascript:void(0);' style='display:none; float:right;' class='delete_group_member delete delete_post_top'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' style='width:16px;height:16px' /></a>";
						}

						if ( ($member['ID'] == $me) || (is_user_logged_in() && strtolower($member['share']) == 'everyone') || (strtolower($member['share']) == 'public') || (strtolower($member['share']) == 'friends only' && __wps__friend_of($member['ID'], $current_user->ID)) ) {
							$html .= "<div class='members_location'>";
								if (isset($city) && $city != '') {
									$html .= $member['city'];
								}
								if (isset($country) && $country != '') {
									if ($city != '') {
										$html .= ', '.$member['country'];
									} else {
										$html .= $member['country'];
									}
								}								
							$html .= "</div>";
						}
	
						$html .= "<div class='members_avatar'>";