function __wps_show_group($page) { global $wpdb, $current_user; $gid = ''; if (isset($_GET['gid'])) { $gid = $_GET['gid']; } else { if (isset($_POST['gid'])) { $gid = $_POST['gid']; } } $group_url = __wps__get_url('group'); if (strpos($group_url, '?') !== FALSE) { $q = "&"; } else { $q = "?"; } // Check if private or public $sql = "SELECT private FROM ".$wpdb->prefix."symposium_groups WHERE gid = %d"; $private = $wpdb->get_var($wpdb->prepare($sql, $gid)); if (is_user_logged_in()) { if ($gid != '') { // Wrapper $html = "<div class='__wps__wrapper'>"; $plugin = WPS_PLUGIN_URL; // Group views, therefore considered active, so update last activity $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."symposium_groups SET last_activity = %s WHERE gid = %d", date("Y-m-d H:i:s"), $gid )); $group = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix . 'symposium_groups WHERE gid=%d', $gid)); // Use default layout, or templates? if (get_option(WPS_OPTIONS_PREFIX.'_use_group_templates') == "on") { $template = get_option(WPS_OPTIONS_PREFIX.'_template_group'); $template = str_replace("[]", "", stripslashes($template)); } else { $template = "<div id='group_header_div'><div id='group_header_panel'>"; $template .= "<div id='group_details'>"; $template .= "<div id='group_name'>[group_name]</div>"; $template .= "<div id='group_description'>[group_description]</div>"; $template .= "<div style='padding-top: 15px;padding-bottom: 15px;'>[actions]</div>"; $template .= "</div>"; $template .= "</div>"; $template .= "<div id='group_photo' class='corners'>[avatar,170]</div>"; $template .= "</div>"; $template .= "<div id='group_wrapper'>"; $template .= "<div id='force_group_page' style='display:none'>[default]</div>"; $template .= "<div id='group_body_wrapper'>"; $template .= "[menu_tabs]"; $template .= "<div id='group_body' class='group_body_full'>[page]</div>"; $template .= "</div>"; $template .= "</div>"; } // Buttons $buttons = ""; $member_of = __wps__member_of($gid); if (is_user_logged_in()) { if ($member_of != "yes") { if ($member_of == "no") { // Not a member, or pending, so show join button $member_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(gmid) FROM ".$wpdb->prefix."symposium_group_members WHERE group_id = %d", $gid)); if ($group->max_members == 0 || $member_count < $group->max_members) { if ($group->private != "on") { $buttons .='<input type="submit" value="'.__("Join Group", WPS_TEXT_DOMAIN).'" id="groups_join_button" class="__wps__button">'; $buttons .='<p id="groups_join_button_done" style="padding:6px;display:none">'.__('You are now a member of this group.', WPS_TEXT_DOMAIN).'</p>'; } else { $buttons .='<input type="submit" value="'.__("Request to Join", WPS_TEXT_DOMAIN).'" id="groups_join_button" class="__wps__button">'; $buttons .='<p id="groups_join_button_done" style="padding:6px;display:none">'.__('Your membership is awaiting approval.', WPS_TEXT_DOMAIN).'</p>'; } } else { $buttons .='<p>'.__('Group membership is full.', WPS_TEXT_DOMAIN).'</p>'; } } else { // Asked to join, waiting for decision $buttons .= "<p>".__("Your request to join is awaiting approval.", WPS_TEXT_DOMAIN)."</p>"; } } else { if (__wps__group_admin($gid) != "yes") { // Is a member, so show leave button (if not an admin) $buttons .='<input type="submit" value="'.__("Leave Group", WPS_TEXT_DOMAIN).'" id="groups_leave_button" class="__wps__button">'; $buttons .='<p id="groups_leave_button_done" style="padding:6px;display:none">'.__('You are no longer a member of this group.', WPS_TEXT_DOMAIN).'</p>'; } } if (__wps__group_admin($gid) == "yes" || __wps__get_current_userlevel() == 5) { // Admin, so can delete group if (__wps__get_current_userlevel() == 5) { $buttons .= '<input type="submit" value="'.__("Delete Group", WPS_TEXT_DOMAIN).'" id="groups_delete_button" class="__wps__button">'; $buttons .='<p id="groups_delete_button_done" style="padding:6px;display:none">'.__('Group deleted.', WPS_TEXT_DOMAIN).'</p>'; } else { $buttons .= '<input type="submit" title="'.$gid.'" value="'.__("Delete Group", WPS_TEXT_DOMAIN).'" id="groups_delete_button_request" class="__wps__button">'; } } } else { $buttons = ""; } // Replace Header Codes $template = str_replace("[group_name]", stripslashes($group->name), $template); $template = str_replace("[group_description]", stripslashes($group->description), $template); $template = str_replace("[actions]", $buttons, $template); // Avatar if (strpos($template, '[avatar') !== FALSE) { if (strpos($template, '[avatar]')) { $template = str_replace("[avatar]", __wps__get_group_avatar($gid, 200), $template); } else { $x = strpos($template, '[avatar'); $avatar = substr($template, 0, $x); $avatar2 = substr($template, $x+8, 3); $avatar3 = substr($template, $x+12, strlen($template)-$x-12); $template = $avatar . __wps__get_group_avatar($gid, $avatar2) . $avatar3; } } // Menu if (strpos($template, '[menu]') !== false) { // vertical menu $menu = ""; $menu .= '<div id="group_menu_all" class="__wps__group_menu">'.__('All Groups', WPS_TEXT_DOMAIN).'</div>'; $menu .= '<div id="group_menu_about" class="__wps__group_menu">'.__('Welcome page', WPS_TEXT_DOMAIN).'</div>'; if ($member_of == "yes" || $group->content_private != "on") { $menu .= '<div id="group_menu_wall" class="__wps__group_menu">'.__('Group Activity', WPS_TEXT_DOMAIN).'</div>'; if ($group->group_forum == "on") { $menu .= '<div id="group_menu_forum" class="__wps__group_menu">'.__('Group Forum', WPS_TEXT_DOMAIN).'</div>'; } $menu .= '<div id="group_menu_members" class="__wps__group_menu">'.__('Active Members', WPS_TEXT_DOMAIN).'</div>'; } if (__wps__group_admin($gid) == "yes" || __wps__get_current_userlevel() == 5) { $menu .= '<div id="group_menu_settings" class="__wps__group_menu">'.__('Group Settings', WPS_TEXT_DOMAIN).'</div>'; if (get_option(WPS_OPTIONS_PREFIX.'_group_invites') == 'on') { $menu .= '<div id="group_menu_invites" class="__wps__group_menu">'.__('Group Invites', WPS_TEXT_DOMAIN).'</div>'; } } $template = str_replace("[menu]", $menu, $template); } else { // horizontal menu $template = str_replace("[menu_tabs]", __wps__show_group_menu_tabs($gid, $member_of, $group), $template); } // Body if ($member_of == "yes" || $group->content_private != "on") { $template = str_replace("[page]", "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/busy.gif' />", $template); $template = str_replace("[default]", $page, $template); } else { $private_link = ''; if (!is_user_logged_in()) { $private_link .= " <a href=".wp_login_url( $group_url.$q.'gid='.$gid )." class='simplemodal-login' title='".__("Login", WPS_TEXT_DOMAIN)."'>".__("Login", WPS_TEXT_DOMAIN).".</a>"; } $template = str_replace("[page]", $private_link, $template); $template = str_replace("[default]", "", $template); } $template .= "<br class='clear' />"; $html .= $template; $html .= "</div>"; // End of Wrapper $html .= "<br class='clear' />"; } else { $html = __("Group not found, sorry.", WPS_TEXT_DOMAIN); } } else { $html = __wps__show_login_link(__("You need to <a href='%s'>login</a> to access this group.", WPS_TEXT_DOMAIN)); } // Filter for header $html = apply_filters ( '__wps__group_header_filter', $html, $gid ); return $html; exit; }
function __wps__activity_stream($uid1='', $version='wall', $limit_from=0, $limit_count=10, $post='', $show_add_comment=true) { // Get button style from extension if available $button_style = __wps__get_extension_button_style(); // 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'; $html = ""; $html = apply_filters( '__wps__activity_top', $html, $uid1, $uid2, $version ); 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) { $profile_page = __wps__get_url('profile'); if ($profile_page[strlen($profile_page)-1] != '/') { $profile_page .= '/'; } $q = __wps__string_query($profile_page); $html .= "<div id='__wps__wall'>"; if ( ( ( ($version == 'stream_activity') && ($uid2 > 0) ) || ( ($limit_from == 0) && ($post == '') && ($uid1 != '') && ( ($uid1 == $uid2) || ($is_friend)) ) && (is_user_logged_in()) ) ) { // Post Comment Input if ($show_add_comment) { if ($uid1 == $uid2) { $whatsup = stripslashes(get_option(WPS_OPTIONS_PREFIX.'_status_label')); $whatsup = str_replace("'", "`", $whatsup); } else { $whatsup = __('Write a comment...', WPS_TEXT_DOMAIN); } $html .= "<div id='symposium_user_id' style='display:none'>".strtolower($current_user->ID)."</div>"; $html .= "<div id='symposium_user_login' style='display:none'>".strtolower($current_user->user_login)."</div>"; $html .= "<div id='symposium_user_email' style='display:none'>".strtolower($current_user->user_email)."</div>"; // Add status surrounding div $html .= '<div id="symposium_add_status">'; // The textarea $html .= '<textarea '; if (get_option(WPS_OPTIONS_PREFIX.'_elastic')) $html .= 'class="elastic" '; $html .= 'id="__wps__comment" onblur="this.value=(this.value==\'\') ? \''.$whatsup.'\' : this.value;" onfocus="this.value=(this.value==\''.$whatsup.'\') ? \'\' : this.value;">'; $html .= $whatsup; $html .= '</textarea>'; if (get_option(WPS_OPTIONS_PREFIX.'_show_buttons')) { $html .= '<input id="__wps__add_comment" type="submit" class="__wps__button" style="'.$button_style.'" value="'.__('Post', WPS_TEXT_DOMAIN).'" /><br />'; } else { $html .= '<br />'; } // Embed YouTube... if (get_option(WPS_OPTIONS_PREFIX."_activity_youtube")) { $html .= '<input type="submit" id="activity_youtube_embed_button" onclick="return false;" class="__wps__button" style="'.$button_style.'" value="'.__('YouTube', WPS_TEXT_DOMAIN).'">'; $html .= '<div id="activity_youtube_embed_id"></div>'; } // Attach an image... if (get_option(WPS_OPTIONS_PREFIX."_activity_images")) { include_once('server/file_upload_include.php'); $html .= show_upload_form( WP_CONTENT_DIR.'/wps-content/members/'.$current_user->ID.'/activity_upload/', WP_CONTENT_URL.'/wps-content/members/'.$current_user->ID.'/activity_upload/', 'activity', __('Add image', WPS_TEXT_DOMAIN), 0, 0, 0, $uid1, $button_style ); } $html .= '</div>'; // End surrounding div } } $html = apply_filters( '__wps__activity_below_whatsup', $html, $uid1, $uid2, $version ); if ($post != '') { $post_cid = 'c.cid = '.$post.' AND '; } else { $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 (WPS_DEBUG) $html .= '$version='.$version.'<br />'; 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)); } if (WPS_DEBUG) $html .= $wpdb->last_query.'<br />'; // Build wall if ($comments) { $cnt = 0; foreach ($comments as $comment) { $continue = true; if (is_user_logged_in() && $version == "friends_activity" && $uid1 != $uid2 && $comment->author_uid == $uid1 && $comment->subject_uid == $uid1) { $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_comments c WHERE c.comment_parent = %d AND c.is_group != 'on' AND c.author_uid != %d"; if ($wpdb->get_var($wpdb->prepare($sql, $comment->cid, $uid1)) == 0) $continue = false; if (WPS_DEBUG) $html .= $wpdb->last_query.'<br />'; } if ($continue) { if (WPS_DEBUG) $html .= '<br>continue<br>'; $cnt++; $privacy = __wps__get_meta($comment->author_uid, 'wall_share'); if ( ($comment->subject_uid == $uid1) || ($comment->author_uid == $uid1) || (strtolower($privacy) == 'everyone' && $uid2 > 0) || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && (__wps__friend_of($comment->author_uid, $uid1) || (__wps__friend_of($comment->author_uid, $uid2) && $version == "stream_activity") ) ) ) { // If a group post and user is not the author we need to check privacy of group settings if ($comment->is_group == 'on' && $comment->author_uid != $uid2) { // If not private group, or a member, then display if ($comment->content_private != 'on' || __wps__member_of($comment->subject_uid) == 'yes') { $private_group = ''; } else { // Otherwise hide $private_group = 'on'; } } else { // Not a group post so not applicable $private_group = ''; } if ($private_group != 'on') { // Check to avoid poke's (as private) if ( ($comment->type != 'poke') || ($comment->type == 'poke' && ($comment->author_uid == $uid2 || $comment->subject_uid == $uid2 )) ) { $comment_div = "<div class='wall_post_div' id='post_".$comment->cid."'>"; // Avatar $comment_inner_div = "<div class='wall_post_avatar'>"; $comment_inner_div .= get_avatar($comment->author_uid, 64); $comment_inner_div .= "</div>"; $user_info = get_user_by('id', $comment->author_uid); if ($user_info && $user_info->user_login != 'nobody') { $comment_inner_div .= '<a href="'.$profile_page.$q.'uid='.$comment->author_uid.'">'.stripslashes($comment->display_name).'</a> '; if ($comment->author_uid != $comment->subject_uid && !$comment->is_group) { $comment_inner_div .= ' → '; $user_info = get_userdata($comment->subject_uid); if ($user_info->user_login != 'nobody') { $comment_inner_div .= '<a href="'.$profile_page.$q.'uid='.$comment->subject_uid.'">'.stripslashes($comment->subject_name).'</a> '; } else { $comment_inner_div .= stripslashes($comment->subject_name).' '; } } } else { $comment_inner_div .= stripslashes($comment->display_name).' '; if ($comment->author_uid != $comment->subject_uid && !$comment->is_group) { $comment_inner_div .= ' → '; $user_info = get_userdata($comment->subject_uid); if ($user_info->user_login != 'nobody') { $comment_inner_div .= '<a href="'.$profile_page.$q.'uid='.$comment->subject_uid.'">'.stripslashes($comment->subject_name).'</a> '; } else { $comment_inner_div .= stripslashes($comment->subject_name).' '; } } } $comment_inner_div .= __wps__time_ago($comment->comment_timestamp)."."; $comment_inner_div .= "<div class='__wps__activity_icons'>"; // Like/dislike icons if (get_option(WPS_OPTIONS_PREFIX.'_activity_likes') && is_user_logged_in() && $comment->author_uid != $uid2 ) { $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND uid = %d"; $already_liked = $wpdb->get_var($wpdb->prepare($sql, $comment->cid, $current_user->ID)); if (!$already_liked) { $comment_inner_div .= "<div class='wall_post_like delete_post_top'>"; $comment_inner_div .= "<img class='wall_add_like' title='".__('You like this.', WPS_TEXT_DOMAIN)."' data-action='like' rel='".$comment->cid."' style='width:20px;height:20px;' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' />"; $comment_inner_div .= "<img class='wall_add_like' title='".__('You do not like this.', WPS_TEXT_DOMAIN)."' data-action='dislike' rel='".$comment->cid."' style='width:20px;height:20px' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' />"; $comment_inner_div .= "</div>"; } } // Delete and report $comment_inner_div .= "<div style='width:60px; float:right;height:16px;'>"; if (get_option(WPS_OPTIONS_PREFIX.'_allow_reports') == 'on') { $comment_inner_div .= " <a title='post_".$comment->cid."' href='javascript:void(0);' class='report_post report_post_top symposium_report'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/warning.png' style='width:16px;height:16px' /></a>"; } if (__wps__get_current_userlevel() == 5 || $comment->subject_uid == $uid2 || $comment->author_uid == $uid2) { $comment_inner_div .= " <a title='".$comment->cid."' rel='post' href='javascript:void(0);' class='delete_post delete_post_top'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' style='width:16px;height:16px' /></a>"; } $comment_inner_div .= '</div>'; // Likes/Dislikes if (get_option(WPS_OPTIONS_PREFIX.'_activity_likes')) { $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like'"; $likes = $wpdb->get_var($wpdb->prepare($sql, $comment->cid)); $start_likes = $likes; $sql = "SELECT vid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like' AND uid=%d"; $youlike = $wpdb->get_var($wpdb->prepare($sql, $comment->cid, $uid2)); $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike'"; $dislikes = $wpdb->get_var($wpdb->prepare($sql, $comment->cid)); $sql = "SELECT vid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike' AND uid=%d"; $youdislike = $wpdb->get_var($wpdb->prepare($sql, $comment->cid, $uid2)); $comment_inner_div .= "<div id='__wps__likes_".$comment->cid."'>"; if ($likes) { $link = '<a id="symposium_show_likes" href="javascript:void(0)" rel="'.$comment->cid.'">'; $comment_inner_div .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' style='width:16px;height:16px' /> "; if ($youlike) { $comment_inner_div .= __('You', WPS_TEXT_DOMAIN); $likes--; if ($likes > 1) { $comment_inner_div .= ' '.sprintf(__('and %s%d others</a> like this.', WPS_TEXT_DOMAIN), $link, $likes); } if ($likes == 1) { $comment_inner_div .= ' '.sprintf(__('and %s1 other</a> person likes this.', WPS_TEXT_DOMAIN), $link); } if ($likes == 0) { $comment_inner_div .= ' '.__('like this.', WPS_TEXT_DOMAIN); } } else { if ($likes > 1) { $comment_inner_div .= sprintf(__('%s%d people</a> like this.', WPS_TEXT_DOMAIN), $link, $likes); } if ($likes == 1) { $sql = "SELECT uid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like'"; $uid = $wpdb->get_var($wpdb->prepare($sql, $comment->cid)); $comment_inner_div .= __wps__profile_link($uid).' '.__('likes this.', WPS_TEXT_DOMAIN); } } } if ($dislikes) { if ($start_likes) $comment_inner_div .= '<br />'; $link = '<a id="symposium_show_likes" href="javascript:void(0)" rel="'.$comment->cid.'">'; $comment_inner_div .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' style='width:16px;height:16px' /> "; if ($youdislike) { $comment_inner_div .= __('You', WPS_TEXT_DOMAIN); $dislikes--; if ($dislikes > 1) { $comment_inner_div .= ' '.sprintf(__('and %s%d others</a> don\'t like this.', WPS_TEXT_DOMAIN), $link, $dislikes); } if ($dislikes == 1) { $comment_inner_div .= ' '.sprintf(__('and %s1 other</a> person don\'t like this.', WPS_TEXT_DOMAIN), $link); } if ($dislikes == 0) { $comment_inner_div .= ' '.__('don\'t like this.', WPS_TEXT_DOMAIN); } } else { if ($dislikes > 1) { $comment_inner_div .= sprintf(__('%s%d people</a> don\'t like this.', WPS_TEXT_DOMAIN), $link, $dislikes); } if ($dislikes == 1) { $sql = "SELECT uid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike'"; $uid = $wpdb->get_var($wpdb->prepare($sql, $comment->cid)); $comment_inner_div .= __wps__profile_link($uid).' '.__('doesn\'t like this.', WPS_TEXT_DOMAIN); } } } $comment_inner_div .= "</div>"; } $comment_inner_div .= "</div>"; // Always show reply fields or not? $show_class = (get_option(WPS_OPTIONS_PREFIX.'_profile_comments')) ? '' : 'symposium_wall_replies'; $show_field = (get_option(WPS_OPTIONS_PREFIX.'_profile_comments')) ? '' : 'display:none;'; // $text = the comment $text = $comment->comment; // Added to or comment on a gallery if ($comment->type == 'gallery' && strpos($text, '[]')) { $lib = explode('[]', $text); $text = '<div style="width:100%">'; // Add message $text .= $lib[0].'<br />'; $action = $lib[2]; $aid = $lib[1]; if ($action == 'comment') { $single_iid = $lib[3]; $comment_text = $lib[4]; } // Get album title $sql = "SELECT name FROM ".$wpdb->base_prefix."symposium_gallery WHERE gid = %d"; $album_title = $wpdb->get_var($wpdb->prepare($sql, $aid)); $text .= '<div id="wps_gallery_album_name_'.$aid.'" style="display:none">'.stripslashes($album_title).'</div>'; // Get images $sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_gallery_items WHERE gid = %d ORDER BY photo_order"; $photos = $wpdb->get_results($wpdb->prepare($sql, $aid)); $cnt = 0; if ($photos) { foreach ($photos as $photo) { $cnt++; // DB or Filesystem? if (get_option(WPS_OPTIONS_PREFIX.'_img_db') == "on") { $thumb_src = WP_CONTENT_URL."/plugins/wp-symposium/get_album_item.php?iid=".$photo->iid."&size=photo"; } else { $thumb_src = get_option(WPS_OPTIONS_PREFIX.'_img_url').'/members/'.$photo->owner.'/media/'.$aid.'/thumb_'.$photo->name; } $image = $thumb_src; $iid = $photo->iid; $name = $photo->title; if (($action == 'added' && $cnt == 1) || ($action == 'comment' && $iid == $single_iid)) { $image = preg_replace('/thumb_/', 'show_', $image, 1); $title = ''; $text .= '<a class="__wps__photo_cover_action wps_gallery_album" data-name="'.stripslashes($title).'" data-iid="'.$iid.'" href="'.$image.'" rev="'.$cnt.'" rel="symposium_gallery_photos_'.$aid.'" title="'.$name.'">'; $text .= '<img class="profile_activity_gallery_first_image" src="'.$image.'" /><br />'; $text .= '</a>'; } if ($action == 'added') { if (sizeof($photos) > 2) { if ($cnt == 2) { $text .= '<div id="wps_comment_plus" style="height:55px;overflow:hidden;width:100%">'; } if ($cnt > 1 && $cnt <= sizeof($photos)) { $text .= '<a class="__wps__photo_cover_action wps_gallery_album" data-name="'.stripslashes($title).'" data-owner="'.$photo->owner.'" data-iid="'.$iid.'" href="'.$image.'" rev="'.$cnt.'" rel="symposium_gallery_photos_'.$aid.'" title="'.$name.'">'; $text .= '<img style="width:50px;height:50px;margin-right:5px;margin-bottom:5px;float:left;" src="'.$image.'" />'; $text .= '</a>'; } if ($cnt == sizeof($photos)) { $text .= '</div>'; } } } else { if ($iid != $single_iid) { if (!isset($title)) $title = ''; $text .= '<a class="__wps__photo_cover_action wps_gallery_album" data-name="'.stripslashes($title).'" data-iid="'.$iid.'" href="'.$image.'" rev="'.$cnt.'" rel="symposium_gallery_photos_'.$aid.'" title="'.$name.'">'; $text .= '<img style="display:none;" src="'.$image.'" />'; $text .= '</a>'; } } } if ($cnt > 7 && $action == 'added') { $text .= '<div id="wps_gallery_comment_more" style="clear:both;cursor:pointer">'; $text .= __('more...', WPS_TEXT_DOMAIN).'</div>'; } } if ($action == 'comment') { $text .= $comment_text; } $text .= '</div>'; } // Check for any associated uploaded images for activity $directory = WP_CONTENT_DIR."/wps-content/members/".$comment->subject_uid.'/activity/'; if (file_exists($directory)) { $handler = opendir($directory); while ($image = readdir($handler)) { $path_parts = pathinfo($image); if ($path_parts['filename'] == $comment->cid) { $directoryURL = WP_CONTENT_URL."/wps-content/members/".$comment->subject_uid.'/activity/'.$image; $text .= '<div style="margin-bottom:5px"></div>'; // sort out text for title bar of dialog box if (strlen($comment->comment) < 75) { $title_bar = $comment->comment; } else { $title_bar = substr($comment->comment, 0, 75).'...'; } // remove emoticons to avoid breaking image link to popup $remove = array("{{", "}}", ":)",";)",":-)",":(",":'(",":x",":X",":D",":|",":?",":z",":P"); foreach ($remove as $key => $value){ $title_bar = str_replace($value, "", $title_bar); } // rev = this image to default on (would be a count of all images included) // rel = the 'group' of images to be included $text .= "<a target='_blank' href='".$directoryURL."' rev='1' rel='symposium_activity_images_".$comment->cid."' data-owner='".$comment->subject_uid."' data-name='".$title_bar."' data-iid='".$comment->cid."' class='wps_gallery_album'>"; $text .= '<img class="profile_activity_image" src="'.$directoryURL.'" />'; $text .= '</a>'; } } } // Finally show comment...! $text = stripslashes($text); $comment_inner_div .= '<div class="next_comment '.$show_class.'" id="'.$comment->cid.'">'; if ($comment->is_group) { $url = __wps__get_url('group'); $q = __wps__string_query($url); $url .= $q.'gid='.$comment->subject_uid.'&post='.$comment->cid; $group_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM ".$wpdb->base_prefix."symposium_groups WHERE gid = %d", $comment->subject_uid)); $comment_inner_div .= __("Group post in", WPS_TEXT_DOMAIN)." <a href='".$url."'>".stripslashes($group_name)."</a>: ".__wps__make_url($text); } else { $comment_inner_div .= __wps__make_url($text); } $comment_inner_div = apply_filters( '__wps__activity_row_item_filter', $comment_inner_div, $comment ); // Replies +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $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 LEFT JOIN ".$wpdb->base_prefix."symposium_comments p ON c.comment_parent = p.cid WHERE c.comment_parent = %d AND c.is_group != 'on' ORDER BY c.cid"; $replies = $wpdb->get_results($wpdb->prepare($sql, $comment->cid)); $count = 0; if ($replies) { if (count($replies) > 4) { $comment_inner_div .= "<div id='view_all_comments_div'>"; $comment_inner_div .= "<a title='".$comment->cid."' class='view_all_comments' href='javascript:void(0);'>".__(sprintf("View all %d comments", count($replies)), WPS_TEXT_DOMAIN)."</a>"; $comment_inner_div .= "</div>"; } foreach ($replies as $reply) { $count++; if ($count > count($replies)-4) { $reply_style = ""; } else { $reply_style = "display:none; "; } $comment_inner_div .= "<div id='".$reply->cid."' class='reply_div' style='".$reply_style."'>"; $comment_inner_div .= "<div class='__wps__wall_reply_div'>"; $comment_inner_div .= "<div class='wall_reply'>"; $comment_inner_div .= '<a href="'.$profile_page.$q.'uid='.$reply->author_uid.'">'.stripslashes($reply->display_name).'</a> '; $comment_inner_div .= __wps__time_ago($reply->comment_timestamp)."."; $comment_inner_div .= '<div style="width:50px; float:right;">'; if (get_option(WPS_OPTIONS_PREFIX.'_allow_reports') == 'on') { $comment_inner_div .= " <a title='post_".$reply->cid."' href='javascript:void(0);' style='padding:0px' class='report_post symposium_report reply_warning'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/warning.png' style='width:14px;height:14px' /></a>"; } // Like/dislike icons for reply if (get_option(WPS_OPTIONS_PREFIX.'_activity_likes') && is_user_logged_in() && $reply->author_uid != $uid2 ) { $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND uid = %d"; $already_liked = $wpdb->get_var($wpdb->prepare($sql, $reply->cid, $current_user->ID)); if (!$already_liked) { $comment_inner_div .= "<div class='wall_post_like delete_reply' style='margin:0;padding:0;'>"; $comment_inner_div .= "<img class='wall_add_like' title='".__('You like this.', WPS_TEXT_DOMAIN)."' data-action='like' rel='".$reply->cid."' style='padding:0;width:20px;height:20px;' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' />"; $comment_inner_div .= "<img class='wall_add_like' title='".__('You do not like this.', WPS_TEXT_DOMAIN)."' data-action='dislike' rel='".$reply->cid."' style='padding:0;width:20px;height:20px' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' />"; $comment_inner_div .= "</div>"; } } if (__wps__get_current_userlevel($uid2) == 5 || $reply->subject_uid == $uid2 || $reply->author_uid == $uid2) { $comment_inner_div .= " <a title='".$reply->cid."' rel='reply' href='javascript:void(0);' style='padding:0px' class='delete_post delete_reply'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/delete.png' style='width:14px;height:14px' /></a>"; } $comment_inner_div .= '</div>'; $comment_inner_div .= "<br />"; // Likes/Dislikes for replies if (get_option(WPS_OPTIONS_PREFIX.'_activity_likes')) { $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like'"; $likes = $wpdb->get_var($wpdb->prepare($sql, $reply->cid)); $start_likes = $likes; $sql = "SELECT vid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like' AND uid=%d"; $youlike = $wpdb->get_var($wpdb->prepare($sql, $reply->cid, $uid2)); $sql = "SELECT COUNT(*) FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike'"; $dislikes = $wpdb->get_var($wpdb->prepare($sql, $reply->cid)); $sql = "SELECT vid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike' AND uid=%d"; $youdislike = $wpdb->get_var($wpdb->prepare($sql, $reply->cid, $uid2)); $comment_inner_div .= "<div id='__wps__likes_".$reply->cid."'>"; if ($likes) { $link = '<a id="symposium_show_likes" href="javascript:void(0)" rel="'.$reply->cid.'">'; $comment_inner_div .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/good.png' style='width:16px;height:16px' /> "; if ($youlike) { $comment_inner_div .= __('You', WPS_TEXT_DOMAIN); $likes--; if ($likes > 1) { $comment_inner_div .= ' '.sprintf(__('and %s%d others</a> like this.', WPS_TEXT_DOMAIN), $link, $likes); } if ($likes == 1) { $comment_inner_div .= ' '.sprintf(__('and %s1 other person</a> likes this.', WPS_TEXT_DOMAIN), $link); } if ($likes == 0) { $comment_inner_div .= ' '.__('like this.', WPS_TEXT_DOMAIN); } } else { if ($likes > 1) { $comment_inner_div .= sprintf(__('%s%d people</a> like this.', WPS_TEXT_DOMAIN), $link, $likes); } if ($likes == 1) { $sql = "SELECT uid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'like'"; $uid = $wpdb->get_var($wpdb->prepare($sql, $reply->cid)); $comment_inner_div .= __wps__profile_link($uid).' '.__('likes this.', WPS_TEXT_DOMAIN); } } } if ($dislikes) { if ($start_likes) $comment_inner_div .= '<br />'; $link = '<a id="symposium_show_likes" href="javascript:void(0)" rel="'.$reply->cid.'">'; $comment_inner_div .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/smilies/bad.png' style='width:16px;height:16px' /> "; if ($youdislike) { $comment_inner_div .= __('You', WPS_TEXT_DOMAIN); $dislikes--; if ($dislikes > 1) { $comment_inner_div .= ' '.sprintf(__('and %s%d others</a> don\'t like this.', WPS_TEXT_DOMAIN), $link, $dislikes); } if ($dislikes == 1) { $comment_inner_div .= ' '.sprintf(__('and %s1 other</a> person don\'t like this.', WPS_TEXT_DOMAIN), $link); } if ($dislikes == 0) { $comment_inner_div .= ' '.__('don\'t like this.', WPS_TEXT_DOMAIN); } } else { if ($dislikes > 1) { $comment_inner_div .= sprintf(__('%s%d people</a> don\'t like this.', WPS_TEXT_DOMAIN), $link, $dislikes); } if ($dislikes == 1) { $sql = "SELECT uid FROM ".$wpdb->base_prefix."symposium_likes WHERE cid = %d AND type = 'dislike'"; $uid = $wpdb->get_var($wpdb->prepare($sql, $reply->cid)); $comment_inner_div .= __wps__profile_link($uid).' '.__('doesn\'t like this.', WPS_TEXT_DOMAIN); } } } $comment_inner_div .= "</div>"; } $comment_inner_div .= __wps__make_url(stripslashes($reply->comment)); $comment_inner_div .= "</div>"; $comment_inner_div .= "</div>"; $comment_inner_div .= "<div class='wall_reply_avatar'>"; $comment_inner_div .= get_avatar($reply->author_uid, 40); $comment_inner_div .= "</div>"; $comment_inner_div .= "</div>"; } } else { $comment_inner_div .= "<div class='no_wall_replies'></div>"; } $comment_inner_div .= "<div style='clear:both;' id='__wps__comment_".$comment->cid."'></div>"; // Reply (comment) field if ( (is_user_logged_in()) && ( ($uid1 == $uid2) || ( strtolower($privacy) == 'everyone' || strtolower($privacy) == 'public' || (strtolower($privacy) == 'friends only' && $is_friend) || ($version = "stream_activity" && strtolower($privacy) == 'friends only' && __wps__friend_of($comment->author_uid, $current_user->ID)) ) ) ) { if ($comment->type != 'gallery' && $comment->type != 'friend') { $comment_inner_div .= '<div style="margin-top:5px;'.$show_field.'" id="__wps__reply_div_'.$comment->cid.'" >'; $comment_inner_div .= '<textarea title="'.$comment->cid.'" class="__wps__reply'; if (get_option(WPS_OPTIONS_PREFIX.'_elastic')) $comment_inner_div .= ' elastic'; $comment_inner_div .= '" id="__wps__reply_'.$comment->cid.'" onblur="this.value=(this.value==\'\') ? \''.__('Write a comment...', WPS_TEXT_DOMAIN).'\' : this.value;" onfocus="this.value=(this.value==\''.__('Write a comment...', WPS_TEXT_DOMAIN).'\') ? \'\' : this.value;">'.__('Write a comment...', WPS_TEXT_DOMAIN).'</textarea>'; if (get_option(WPS_OPTIONS_PREFIX.'_show_buttons')) { $comment_inner_div .= '<br /><input title="'.$comment->cid.'" type="submit" style="width:75px;'.$button_style.'" class="__wps__button symposium_add_reply" value="'.__('Add', WPS_TEXT_DOMAIN).'" />'; } $comment_inner_div .= '<input id="symposium_author_'.$comment->cid.'" type="hidden" value="'.$comment->subject_uid.'" />'; $comment_inner_div .= '</div>'; } } $comment_inner_div .= "</div>"; $comment_inner_div = apply_filters( '__wps__activity_item_inner_filter', $comment_inner_div ); $comment_div .= $comment_inner_div."</div>"; $comment_div = apply_filters( '__wps__activity_item_filter', $comment_div ); // Check if forcing UTF8 (to handle umlets, etc) if (get_option(WPS_OPTIONS_PREFIX.'_force_utf8') == 'on') $comment_div = utf8_decode($comment_div); $html .= $comment_div; } } } else { // Protected by privacy settings } } // Comment by member with no replies and looking at friends activity } $id = 'wall'; if ($version == "all_activity" || $version == "stream_activity") { $id='all'; } if ($version == "friends_activity") { $id='activity'; } if ($post == '' && $cnt > 0) { // Set next comment to show // old version was $next (regression testing) = $limit_from+$cnt+1; $next = $limit_from+$limit_count; if (is_user_logged_in()) $html .= "<a href='javascript:void(0)' id='".$id."' class='showmore_wall' title='".($next)."'>".__("more...", WPS_TEXT_DOMAIN)."</a>"; } else { if ($post == '') { $html .= "<br />".__("Nothing to show, sorry.", WPS_TEXT_DOMAIN); } } } else { $html .= "<br />".__("Nothing to show, sorry.", WPS_TEXT_DOMAIN); } $html .= "</div>"; } else { if ($version == "friends_activity") { $html .= '<p>'.__("Sorry, this member has chosen not to share their activity.", WPS_TEXT_DOMAIN); } if ($version == "wall") { $html .= '<p>'.__("Sorry, this member has chosen not to share their activity.", WPS_TEXT_DOMAIN); } } return $html; // return __wps__buffer($html); } else { return __wps__show_login_link(__("Please <a href='%s'>login</a> to view this member's profile.", WPS_TEXT_DOMAIN), false); } return $html; }
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> '; } else { $html .= '<strong>'.chr($i).'</strong> '; } } $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; }
$html .= "</div>"; $html .= "</div>"; $html .= "</div>"; } } else { $html .= __("Not a member of any groups.", WPS_TEXT_DOMAIN); } echo $html; } else { echo __wps__show_login_link(__("You need to be <a href='%s'>logged in</a> to view this member's groups.", WPS_TEXT_DOMAIN)); } exit; } // Show Friends if ($_POST['action'] == 'menu_friends') { $uid1 = $_POST['uid1']; $share = __wps__get_meta($uid1, 'wall_share'); if (is_user_logged_in() || $share == 'public') {
if (is_user_logged_in()) { if ( __wps__get_current_userlevel() == 5 ) { $sql = "DELETE FROM ".$wpdb->base_prefix."symposium_events WHERE eid = %d"; $rows_affected = $wpdb->query( $wpdb->prepare($sql, $eid) ); $sql = "DELETE FROM ".$wpdb->base_prefix."symposium_events_bookings WHERE event_id = %d"; $rows_affected = $wpdb->query( $wpdb->prepare($sql, $eid) ); } else { $sql = "DELETE FROM ".$wpdb->base_prefix."symposium_events WHERE eid = %d AND event_owner = %d"; $rows_affected = $wpdb->query( $wpdb->prepare($sql, $eid, $current_user->ID) ); $sql = "DELETE FROM ".$wpdb->base_prefix."symposium_events_bookings WHERE event_id = %d"; $rows_affected = $wpdb->query( $wpdb->prepare($sql, $eid) ); } } else { echo __wps__show_login_link(__("You need to be <a href='%s'>logged in</a> to delete events.", WPS_TEXT_DOMAIN)); } echo 'OK'; exit; } // Add Event if ($_POST['action'] == 'addEvent') { global $current_user, $wpdb; $name = $_POST['name']; $desc = $_POST['desc']; $location = $_POST['location'];
function __wps__show_profile($page) { global $wpdb, $current_user; $uid = ''; if (isset($_POST['from']) && $_POST['from'] == 'small_search') { if ($_POST['uid'] == '') { $search = $_POST['member_small']; $uid = $wpdb->get_var($wpdb->prepare("SELECT u.ID FROM ".$wpdb->base_prefix."users u WHERE u.display_name LIKE '%s%%'", $search)); } } if ($uid == '') { if (isset($_GET['uid'])) { $uid = $_GET['uid']; } else { if (isset($_POST['uid'])) { $uid = $_POST['uid']; } else { $uid = $current_user->ID; } } } $uid2 = $current_user->ID; // resolve stubs if using permalinks if ( get_option(WPS_OPTIONS_PREFIX.'_permalink_structure') && get_query_var('stub')) { $stubs = explode('/', get_query_var('stub')); $stub0 = $stubs[0]; if (WPS_DEBUG) echo $stub0.'<br />'; if ($stub0) { $sql = "SELECT ID FROM ".$wpdb->base_prefix."users WHERE replace(display_name, ' ', '') = %s"; $id = $wpdb->get_var($wpdb->prepare($sql, $stub0)); if (WPS_DEBUG) echo $wpdb->last_query.'<br />'; if ($id) { $uid = $id; } } } // Use default layout, or templates? if (get_option(WPS_OPTIONS_PREFIX.'_use_templates') != "on") { $html = "<div class='__wps__wrapper'>"; $html .= "<div id='profile_header_div'>"; $html .= "<div id='profile_label'>[profile_label]</div>"; $html .= "<div id='profile_header_panel'>"; $html .= "<div id='profile_photo' class='corners'>[avatar,200]</div>"; $html .= "<div id='profile_details'>"; $html .= "<div id='profile_name'>[display_name]</div>"; $html .= "<p>[location]<br />[born]</p>"; // Include any extended fields $sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_extended"; $extensions = $wpdb->get_results($sql); $ext_rows = array(); if ($extensions) { foreach ($extensions as $extension) { array_push ($ext_rows, array ( 'eid'=>$extension->eid, 'slug'=>$extension->extended_slug, 'order'=>$extension->extended_order ) ); } } if ($ext_rows) { $include = get_option(WPS_OPTIONS_PREFIX.'_profile_extended_fields'); $ext_rows = __wps__sub_val_sort($ext_rows,'order'); foreach ($ext_rows as $row) { if (strpos($include, $row['eid'].',') !== FALSE) $html .= '[ext_'.$row['slug'].']'; } } $html .= "</div>"; $html .= "</div>"; $html .= "</div>"; $html .= "<div id='profile_actions_div'>[actions][poke][follow]</div>"; $html .= "<div id='force_profile_page' style='display:none'>".$page."</div>"; $html .= "<div id='profile_body_tabs_wrapper'>"; $html .= "[menu_tabs]"; $html .= "<div id='profile_body' class='profile_body_no_menu'>[page]</div>"; $html .= "</div>"; $html .= '</div>'; $privacy = __wps__get_meta($uid, 'share'); $html .= '<div id="__wps__current_user_page" style="display:none">'.$uid.'</div>'; if (is_user_logged_in() || $privacy == 'public') { $display_name = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM ".$wpdb->base_prefix."users WHERE ID = %d", $uid)); $html = str_replace("[display_name]", $display_name, $html); // Profile label if ($label = __wps__get_meta($uid, 'profile_label')) { $html = str_replace("[profile_label]", $label, $html); } else { $html = str_replace("<div id='profile_label'>[profile_label]</div>", '', $html); } // Follow/Unfollow if (function_exists('__wps__profile_plus') && is_user_logged_in() && $uid != $uid2) { if (__wps__is_following($uid2, $uid)) { $html = str_replace("[follow]", '<input type="submit" ref="unfollow" value="'.__('Unfollow', WPS_TEXT_DOMAIN).'" class="__wps__button follow-button">', $html); } else { $html = str_replace("[follow]", '<input type="submit" ref="follow" value="'.__('Follow', WPS_TEXT_DOMAIN).'" class="__wps__button follow-button">', $html); } } else { $html = str_replace("[follow]", '', $html); } // Poke if (get_option(WPS_OPTIONS_PREFIX.'_use_poke') == 'on' && is_user_logged_in() && $uid != $uid2) { $html = str_replace("[poke]", '<input type="submit" value="'.get_option(WPS_OPTIONS_PREFIX.'_poke_label').'" class="__wps__button poke-button">', $html); } else { $html = str_replace("[poke]", '', $html); } // Extended fields if (strpos($html, '[ext_') !== FALSE) { // Prepare array for use $sql = "SELECT * FROM ".$wpdb->base_prefix."symposium_extended"; $extensions = $wpdb->get_results($sql); $ext_rows = array(); if ($extensions) { foreach ($extensions as $extension) { $value = __wps__get_meta($uid, 'extended_'.$extension->extended_slug); // New way $value = stripslashes($extension->extended_default); if ($extension->extended_type == "List") { $sql = "SELECT meta_value FROM ".$wpdb->base_prefix."usermeta WHERE user_id = %d and meta_key = 'symposium_extended_".$extension->extended_slug."'"; if ($listitem = $wpdb->get_row($wpdb->prepare($sql, $uid))) { $value = stripslashes($listitem->meta_value); } } if ($extension->extended_type == "Checkbox") { $sql = "SELECT meta_value FROM ".$wpdb->base_prefix."usermeta WHERE user_id = %d and meta_key = 'symposium_extended_".$extension->extended_slug."'"; if ($checkbox = $wpdb->get_row($wpdb->prepare($sql, $uid))) { $value = stripslashes($checkbox->meta_value); } } if ($extension->extended_type == "Text" || $extension->extended_type == "Textarea") { $sql = "SELECT meta_value FROM ".$wpdb->base_prefix."usermeta WHERE user_id = %d and meta_key = 'symposium_extended_".$extension->extended_slug."'"; if ($text = $wpdb->get_row($wpdb->prepare($sql, $uid))) { $value = stripslashes($text->meta_value); } } if ($extension->extended_type == 'Checkbox' || $value) { array_push ($ext_rows, array ( 'slug'=>$extension->extended_slug, 'name'=>$extension->extended_name, 'value'=>$value, 'type'=>$extension->extended_type, 'order'=>$extension->extended_order ) ); } } } $c = 0; while ($c < 100 && strpos($html, '[ext_') !== FALSE) { $ext = ''; $c++; $s1 = strpos($html, '[ext_'); $s2 = strpos($html, ']', $s1+1); $start = substr($html, 0, $s1); $code = substr($html, $s1+5, $s2-$s1-5); $end = substr($html, $s2+1, strlen($html)-$s1); if ( ($uid == $uid2) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && __wps__friend_of($uid, $current_user->ID)) ) { if ($ext_rows) { $ext_rows = __wps__sub_val_sort($ext_rows,'order'); foreach ($ext_rows as $row) { if (strtolower($row['slug']) == strtolower($code)) { if ($row['type'] == 'Checkbox' && !$row['value'] && get_option(WPS_OPTIONS_PREFIX.'_profile_show_unchecked') != 'on') { // Don't show if unchecked and chosen not to show (in Profile config) } else { if ($row['type'] == 'Text' && $row['value']) { $ext .= '<div class="__wps__profile_page_header_ext_label">'.$row['name'].'</div>'; $ext .= '<div class="__wps__profile_page_header_ext_value">'.stripslashes(stripslashes($row['value'])).'</div>'; } if ($row['type'] == 'Textarea' && $row['value']) { $ext .= '<div class="__wps__profile_page_header_ext_label">'.stripslashes($row['name']).'</div>'; $ext .= '<div class="__wps__profile_page_header_ext_value">'.stripslashes(str_replace(chr(10),'<br />',__wps__make_url(stripslashes($row['value'])))).'</div>'; } if ($row['type'] == 'List' && $row['value']) { $ext .= '<div class="__wps__profile_page_header_ext_label">'.stripslashes($row['name']).'</div>'; $ext .= '<div class="__wps__profile_page_header_ext_value">'.str_replace(chr(10),'<br />',stripslashes(__wps__make_url($row['value']))).'</div>'; } if ($row['type'] == 'Checkbox') { if (get_option(WPS_OPTIONS_PREFIX.'_profile_show_unchecked') == 'on' || $row['value']) { $ext .= '<div class="__wps__profile_page_header_ext_label">'; $ext .= stripslashes($row['name'])." "; if ($row['value']) { $ext .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/tick.png' />"; } else { $ext .= "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/cross.png' />"; } $ext .= '</div>'; } } } } } } if ($c == 1) { $html = $start.'<div id="__wps__profile_page_header_ext_fields">'.$ext; } else { $html = $start.$ext; } if (strpos($end, '[ext_') === FALSE) $html .= '</div>'; $html .= $end; } else { $html = $start.$end; } } } $location = ""; $born = ""; if ( ($uid == $uid2) || (is_user_logged_in() && strtolower($privacy) == 'everyone') || (strtolower($privacy) == 'public') || (strtolower($privacy) == 'friends only' && __wps__friend_of($uid, $uid2)) ) { $city = __wps__get_meta($uid, 'extended_city'); $country = __wps__get_meta($uid, 'extended_country'); if ($city != '') { $location .= $city; } if ($city != '' && $country != '') { $location .= ", "; } if ($country != '') { $location .= $country; } $day = (int)__wps__get_meta($uid, 'dob_day'); $month = __wps__get_meta($uid, 'dob_month'); $year = (int)__wps__get_meta($uid, 'dob_year'); if ($year > 0 || $month > 0 || $day > 0) { $monthname = __wps__get_monthname($month); if ($day == 0) $day = ''; if ($year == 0) $year = ''; $born = get_option(WPS_OPTIONS_PREFIX.'_show_dob_format'); $born = ( $born != '') ? $born : __('Born', WPS_TEXT_DOMAIN).' %monthname %day%th, %year'; $day0 = str_pad($day, 2, '0', STR_PAD_LEFT); $month = ($month > 0) ? str_pad($month, 2, '0', STR_PAD_LEFT) : ''; $month0 = ($month > 0) ? str_pad($month, 2, '0', STR_PAD_LEFT) : ''; $year = ($year > 0) ? $year : ''; $born = str_replace('%0day', $day0, $born); $born = str_replace('%day', $day, $born); $born = str_replace('%monthname', $monthname, $born); $born = str_replace('%0month', $month0, $born); $born = str_replace('%month', $month, $born); $born = str_replace('%year', $year, $born); $th = 'th'; if ($day == 1 || $day == 21 || $day == 31) $th = 'st'; if ($day == 2 || $day == 22) $th = 'nd'; if ($day == 3 || $day == 23) $th = 'rd'; if (strpos($born, '%th')) { if ($day) { $born = str_replace('%th', $th, $born); } else { $born = str_replace('%th', '', $born); } } $born = str_replace(' ,', ',', $born); if ($year == '') $born = str_replace(', ', '', $born); $born = apply_filters ( '__wps__profile_born', $born, $day, $month, $year ); } } else { if (strtolower($privacy) == 'friends only') { $html = str_replace("[born]", sprintf(__("Personal information only for %s.", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends')), $html); } if (strtolower($privacy) == 'nobody') { $html = str_replace("[born]", __("Personal information is private.", WPS_TEXT_DOMAIN), $html); } } $html = str_replace("[location]", $location, $html); if (get_option(WPS_OPTIONS_PREFIX.'_show_dob') == 'on') { $html = str_replace("[born]", $born, $html); } else { $html = str_replace("[born]", "", $html); } if ( is_user_logged_in() ) { $actions = ''; if ($uid == $uid2) { // Facebook Connect if (function_exists('__wps__facebook')) $actions .= __wps__get_facebook(); } else { // Buttons if (__wps__friend_of($uid, $uid2)) { // A friend // Send mail if (function_exists('__wps__mail')) $actions .= '<input type="submit" class="__wps__button" id="profile_send_mail_button" value="'.__('Send a Mail...', WPS_TEXT_DOMAIN).'" />'; } if (!__wps__friend_of($uid, $uid2)) { if (__wps__pending_friendship($uid)) { // Pending $actions .= '<input type="submit" title="'.$uid.'" id="cancelfriendrequest" class="__wps__button" value="'.sprintf(__('Cancel %s Request', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'" /> '; $actions .= '<div id="cancelfriendrequest_done" class="hidden addasfriend_input">'.sprintf(__('%s Request Cancelled', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'</div>'; } else { // Not a friend $actions .= '<div id="addasfriend_done1_'.$uid.'" class="addasfriend_input">'; $actions .= '<div id="add_as_friend_message">'; $actions .= '<input type="text" title="'.$uid.'" id="addfriend" class="input-field" onclick="this.value=\'\'" value="'.sprintf(__('Add as a %s', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'...."'; if (!get_option(WPS_OPTIONS_PREFIX.'_show_buttons')) { $actions .= ' style="width:210px"'; } $actions .= '>'; if (get_option(WPS_OPTIONS_PREFIX.'_show_buttons')) { $actions .= '<input type="submit" title="'.$uid.'" id="addasfriend" class="__wps__button" value="'.__('Add', WPS_TEXT_DOMAIN).'" /> '; } $actions .= '</div></div>'; $actions .= '<div id="addasfriend_done2_'.$uid.'" class="hidden addasfriend_input">'.sprintf(__('%s Request Sent', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')).'</div>'; } if (__wps__get_current_userlevel() == 5) { // Send mail if WPS admin if (function_exists('__wps__mail')) $actions .= '<input type="submit" class="__wps__button" style="float:left" id="profile_send_mail_button" value="'.__('Send a Mail...', WPS_TEXT_DOMAIN).'" />'; } } } $html = str_replace("[actions]", $actions, $html); } else { $html = str_replace("[actions]", "", $html); } // Photo if (strpos($html, '[avatar') !== FALSE) { if (strpos($html, '[avatar]')) { $html = str_replace("[avatar]", get_avatar($uid, 200), $html); } else { $x = strpos($html, '[avatar'); $y = strpos($html, ']', $x); $diff = $y-$x-8; $avatar = substr($html, 0, $x); $avatar2 = substr($html, $x+8, $diff); $avatar3 = substr($html, $x+$diff+9, strlen($html)-$x-($diff+9)); $html = $avatar . get_avatar($uid, $avatar2) . $avatar3; } } // Put in menu $html = str_replace("[menu_tabs]", __wps__show_profile_menu_tabs($uid, $uid2), $html); // add activity stream if ($page == 'activity' || $page == 'all') { $view = get_option(WPS_OPTIONS_PREFIX.'_wps_profile_default'); switch($view) { case 'extended':$view = ''; break; case 'all':$view = 'all_activity'; break; case 'activity':$view = 'friends_activity'; break; case 'extended':$view = ''; break; default: break; } $body = __wps__buffer(__wps__profile_body($uid, $uid2, 0, $view, 0, false)); } else { $body = ''; } $html = str_replace("[page]", $body, $html); // Filter for profile header $html = apply_filters ( '__wps__profile_header_filter', $html, $uid ); } else { $html = __wps__show_login_link(__("Please <a href='%s'>login</a> to view this member's profile.", WPS_TEXT_DOMAIN)); } } else { $share = __wps__get_meta($uid, 'share'); if (WPS_DEBUG) echo 'UID:'.$uid.'<br />'; $html = '<div id="__wps__current_user_page" style="display:none">'.$uid.'</div>'; if (is_user_logged_in() || $share == 'public') { $user = $wpdb->get_row($wpdb->prepare("SELECT display_name FROM ".$wpdb->base_prefix."users WHERE ID = %d", $uid)); if ($user) { // Wrapper $html .= "<div class='__wps__wrapper'>"; $html .= __wps__profile_header($uid, $current_user->ID, __wps__get_url('mail'), $user->display_name); if ($page != 'header') { if (isset($_GET['view']) && $_GET['view'] != '') { $page = $_GET['view']; } if (isset($_POST['view']) && $_POST['view'] != '') { $page = $_POST['view']; } if ($page == '') { $page = get_option(WPS_OPTIONS_PREFIX.'_wps_profile_default'); } $template = get_option(WPS_OPTIONS_PREFIX.'_template_profile_body'); $template = str_replace("[]", "", stripslashes($template)); // Put in forced profile page $template = str_replace("[default]", $page, stripslashes($template)); // Put in busy image $template = str_replace("[page]", "<img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/busy.gif' />", stripslashes($template)); // Put in menu $template = str_replace("[menu]", __wps__show_profile_menu($uid, $current_user->ID), stripslashes($template)); $template = str_replace("[menu_tabs]", __wps__show_profile_menu_tabs($uid, $current_user->ID), stripslashes($template)); $html .= $template; $html .= "<br class='clear' />"; } $html .= "</div>"; $html .= "<div style='clear: both'></div>"; } else { $html = __("Member not found, sorry", WPS_TEXT_DOMAIN); } } else { $html = __wps__show_login_link(__("Please <a href='%s'>login</a> to view this member's profile.", WPS_TEXT_DOMAIN)); } // Finally, substitute other codes $html = str_replace("[menu_tabs]", __wps__show_profile_menu_tabs($uid, $current_user->ID), stripslashes($html)); // Facebook Connect } return $html; exit; }