function __wps__add_rss_icon($html,$uid1,$uid2,$privacy,$is_friend,$extended) { global $wpdb; $rss_share = __wps__get_meta($uid1, 'rss_share'); if ($rss_share == 'on') { $display_name = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM ".$wpdb->base_prefix."users WHERE ID = %d", $uid1)); $html = "<div id='__wps__rss_icon' title='".$display_name."'></div>".$html; } 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; }
function get_friend_requests($max=10) { global $wpdb; $id = $this->id; $sql = "SELECT f.friend_from AS id, friend_timestamp FROM ".$wpdb->base_prefix."symposium_friends f WHERE friend_to = %d AND friend_accepted != 'on' LIMIT 0,%d"; $friends_list = $wpdb->get_results($wpdb->prepare($sql, $id, $max)); if ($friends_list) { $friends_array = array(); foreach ($friends_list as $friend) { $add = array ( 'id' => $friend->id, 'last_activity' => __wps__get_meta($friend->id, 'last_activity'), 'requested' => $friend->friend_timestamp ); array_push($friends_array, $add); } $friends = __wps__sub_val_sort($friends_array, 'last_activity', false); } else { $friends = false; } return $friends; }
function symposium_forum_latestposts_showThreadChildren($count, $cat_id, $parent, $level, $use_answers) { global $wpdb, $current_user; $thispage = __wps__get_url('forum'); if ($thispage[strlen($thispage)-1] != '/') { $thispage .= '/'; } $q = __wps__string_query($thispage); $symposium_last_login = __wps__get_meta($current_user->ID, 'symposium_last_login'); $html = ""; $preview = 30; if ($count != '') { $postcount = $count; } else { $postcount = get_option(WPS_OPTIONS_PREFIX.'_symposium_forumlatestposts_count'); } if ($level == 0) { $avatar_size = 30; $margin_top = 10; $desc = "DESC"; } else { $avatar_size = 20; $margin_top = 6; $desc = "DESC"; } // All topics started $cat_sql = ($cat_id) ? " AND t.topic_category = ".$cat_id : ''; $posts = $wpdb->get_results(" SELECT t.tid, t.topic_subject, t.stub, p.stub as parent_stub, t.topic_owner, t.topic_post, t.topic_category, t.topic_started, u.display_name, t.topic_parent, t.topic_answer, t.topic_date, t.topic_approved FROM ".$wpdb->prefix.'symposium_topics'." t INNER JOIN ".$wpdb->base_prefix.'users'." u ON t.topic_owner = u.ID LEFT JOIN ".$wpdb->prefix.'symposium_topics'." p ON t.topic_parent = p.tid WHERE t.topic_parent = ".$parent." AND t.topic_group = 0".$cat_sql." ORDER BY t.tid ".$desc." LIMIT 0,".$postcount); if ($posts) { foreach ($posts as $post) { if ( ($post->topic_approved == 'on') || ($post->topic_approved != 'on' && ($post->topic_owner == $current_user->ID || current_user_can('level_10'))) ) { $padding_left = ($level == 0) ? 40 : 30; $html .= "<div class='__wps__latest_forum_row' style='padding-left: ".$padding_left."px; margin-left: ".($level*40)."px; margin-top:".$margin_top."px;'>"; $html .= "<div class='__wps__latest_forum_row_avatar'>"; $html .= get_avatar($post->topic_owner, $avatar_size); $html .= "</div>"; $html .= "<div style='float:left'>"; if ($post->topic_parent > 0) { $text = strip_tags(stripslashes($post->topic_post)); if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; } $reply_text = $level == 1 ? 'replied' : 'commented'; $html .= __wps__profile_link($post->topic_owner)." ".__($reply_text, WPS_TEXT_DOMAIN)." "; if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure')) { $perma_cat = __wps__get_forum_category_part_url($post->topic_category); $html .= "<a title='".$text."' href='".$thispage.$perma_cat.$post->parent_stub."'>"; } else { $html .= "<a title='".$text."' href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->topic_parent."'>"; } $html .= $text."</a> ".__wps__time_ago($post->topic_started); if ($use_answers == 'on' && $post->topic_answer == 'on') { $html .= ' <img style="width:12px;height:12px" src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/tick.png" alt="'.__('Answer Accepted', WPS_TEXT_DOMAIN).'" />'; } $html .= "<br>"; } else { $text = stripslashes($post->topic_subject); if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; } $html .= __wps__profile_link($post->topic_owner)." ".__('started', WPS_TEXT_DOMAIN); if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure')) { $perma_cat = __wps__get_forum_category_part_url($post->topic_category); $html .= " <a title='".$text."' href='".$thispage.$perma_cat.$post->stub."'>".$text."</a> "; } else { $html .= " <a title='".$text."' href='".$thispage.$q."cid=".$post->topic_category."&show=".$post->tid."'>".$text."</a> "; } $html .= __wps__time_ago($post->topic_started).".<br>"; } $html .= "</div>"; if ($post->topic_date > $symposium_last_login && $post->topic_owner != $current_user->ID) { $html .= "<div style='float:left;'>"; $html .= " <img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/new.gif' alt='New!' />"; $html .= "</div>"; } if ($post->topic_approved != 'on') { $html .= " <em>[".__("pending approval", WPS_TEXT_DOMAIN)."]</em>"; } $html .= "</div>"; } $html .= symposium_forum_latestposts_showThreadChildren($count, $cat_id, $post->tid, $level+1, $use_answers); } } return $html; }
array( $choice, $cid, $current_user->ID, date("Y-m-d H:i:s") ) ) ); // Send a mail informing the author that a like/dislike has been chosen $sql = "SELECT author_uid, comment, type, comment_parent FROM ".$wpdb->base_prefix."symposium_comments WHERE cid = %d"; $author = $wpdb->get_row($wpdb->prepare($sql, $cid)); // Support for CubePoints do_action('symposium_profile_like_hook', $author->author_uid, $choice); if (__wps__get_meta($author->author_uid, 'notify_likes')) { $sql = "SELECT u.user_email FROM ".$wpdb->base_prefix."users u WHERE u.ID = %d"; $recipient = $wpdb->get_row($wpdb->prepare($sql, $author->author_uid)); if ($recipient) { if ($choice == 'like') { $verb = "likes"; } else { $verb = "dislikes"; } if ($author->comment_parent == 0) { $type = 'post'; $goto = $cid;
function __wps__do_Forumnoanswer_Widget($preview,$cat_id,$cat_id_exclude,$timescale,$postcount,$groups) { global $wpdb, $current_user; $html = ''; // Previous login if (is_user_logged_in()) { $previous_login = __wps__get_meta($current_user->ID, 'previous_login'); } // Content of widget $sql = "SELECT t.tid, t.topic_subject, t.topic_owner, t.topic_post, t.topic_category, t.topic_date, u.display_name, t.topic_parent, t.topic_group, t.topic_started, (SELECT COUNT(*) FROM ".$wpdb->prefix."symposium_topics v WHERE v.topic_parent = t.tid) AS replies FROM ".$wpdb->prefix."symposium_topics t INNER JOIN ".$wpdb->base_prefix.'users'." u ON t.topic_owner = u.ID WHERE t.topic_parent = 0 AND t.for_info != 'on' AND t.topic_approved = 'on' AND t.topic_started >= ( CURDATE() - INTERVAL ".$timescale." DAY ) AND NOT EXISTS (SELECT tid from ".$wpdb->prefix."symposium_topics s WHERE s.topic_parent = t.tid AND s.topic_answer = 'on') "; if ($cat_id != '' && $cat_id > 0) { $sql .= "AND topic_category IN (".$cat_id.") "; } if ($cat_id_exclude != '' && $cat_id_exclude > 0) { $sql .= "AND topic_category NOT IN (".$cat_id_exclude.") "; } if ($groups != 'on') { $sql .= "AND topic_group = 0 "; } $sql .= "ORDER BY t.topic_started DESC LIMIT 0,".$postcount; $posts = $wpdb->get_results($sql); // Get forum URL worked out $forum_url = __wps__get_url('forum'); $forum_q = __wps__string_query($forum_url); // Get list of roles for this user $user_roles = $current_user->roles; $user_role = strtolower(array_shift($user_roles)); if ($user_role == '') $user_role = 'NONE'; if ($posts) { $html .= "<div id='__wps__latest_forum'>"; foreach ($posts as $post) { if ($post->topic_group == 0 || (__wps__member_of($post->topic_group) == "yes") || ($wpdb->get_var($wpdb->prepare("SELECT content_private FROM ".$wpdb->prefix."symposium_groups WHERE gid = %d", $post->topic_group)) != "on") ) { // Check permitted to see forum category $sql = "SELECT level FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d"; $levels = $wpdb->get_var($wpdb->prepare($sql, $post->topic_category)); $cat_roles = unserialize($levels); if (strpos(strtolower($cat_roles), 'everyone,') !== FALSE || strpos(strtolower($cat_roles), $user_role.',') !== FALSE) { $html .= "<div class='__wps__latest_forum_row'>"; $html .= "<div class='__wps__latest_forum_row_avatar'>"; $html .= get_avatar($post->topic_owner, 32); $html .= "</div>"; $html .= "<div class='__wps__latest_forum_row_post'>"; $html .= __wps__profile_link($post->topic_owner); if ($preview > 0) { $text = stripslashes($post->topic_subject); if ( strlen($text) > $preview ) { $text = substr($text, 0, $preview)."..."; } if ($post->topic_group == 0) { $url = $forum_url; $q = $forum_q; } else { // Get group URL worked out $url = __wps__get_url('group'); if (strpos($url, '?') !== FALSE) { $q = "&gid=".$post->topic_group."&"; } else { $q = "?gid=".$post->topic_group."&"; } } $html .= " ".__('started', WPS_TEXT_DOMAIN)." <a href='".$url.$q."cid=".$post->topic_category."&show=".$post->tid."'>".$text."</a>"; } else { $html .= "<br />"; } $html .= " ".__wps__time_ago($post->topic_started).". "; if ($post->replies > 0) { $html .= $post->replies.' '; if ($post->replies != 1) { $html .= __('replies', WPS_TEXT_DOMAIN); } else { $html .= __('reply', WPS_TEXT_DOMAIN); } $html .= "."; } if (is_user_logged_in() && get_option(WPS_OPTIONS_PREFIX.'_forum_stars')) { if ($post->topic_started > $previous_login && $post->topic_owner != $current_user->ID) { $html .= " <img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/new.gif' alt='New!' />"; } } $html .= "<br />"; $html .= "</div>"; $html .= "</div>"; } } } $html .= "</div>"; } echo $html; }
$sql = "SELECT u.ID, u.display_name FROM ".$wpdb->base_prefix."users u WHERE u.ID != ".$me; } $friends_list = $wpdb->get_results($sql); if ($friends_list) { $friends_array = array(); foreach ($friends_list as $friend) { $add = array ( 'ID' => $friend->ID, 'display_name' => $friend->display_name, 'last_activity' => __wps__get_meta($friend->ID, 'last_activity'), 'status' => __wps__get_meta($friend->ID, 'status') ); array_push($friends_array, $add); } $friends = __wps__sub_val_sort($friends_array, 'last_activity', false); } else { $friends = false; } if ($friends) { foreach ($friends as $friend) { $time_now = time();
function widget( $args, $instance ) { global $wpdb, $current_user; wp_get_current_user(); extract( $args ); // Get options $__wps__vote_question = apply_filters('__wps__widget_vote_question', $instance['symposium_vote_question'] ); $__wps__vote_forum = apply_filters('widget___wps__vote_forum', $instance['__wps__vote_forum'] ); $__wps__vote_counts = apply_filters('__wps__widget_vote_counts', $instance['symposium_vote_counts'] ); $__wps__vote_type = apply_filters('__wps__widget_vote_type', $instance['symposium_vote_type'] ); $__wps__vote_key = apply_filters('__wps__widget_vote_key', $instance['symposium_vote_key'] ); // Start widget echo $before_widget; echo $before_title . $__wps__vote_question . $after_title; // Content of widget echo '<div id="__wps__chartcontainer">Chart of results</div>'; echo '<div id="symposium_chart_type" style="display:none">'.$__wps__vote_type.'</div>'; echo '<div id="symposium_chart_counts" style="display:none">'.$__wps__vote_counts.'</div>'; echo '<div id="symposium_chart_key" style="display:none">'.$__wps__vote_key.'</div>'; // Store values $__wps__vote_yes = get_option(WPS_OPTIONS_PREFIX."_vote_yes"); if ($__wps__vote_yes != false) { $__wps__vote_yes = (int) $__wps__vote_yes; } else { update_option(WPS_OPTIONS_PREFIX."_vote_yes", 0); $__wps__vote_yes = 0; } $__wps__vote_no = get_option(WPS_OPTIONS_PREFIX."_vote_no"); if ($__wps__vote_no != false) { $__wps__vote_no = (int) $__wps__vote_no; } else { update_option(WPS_OPTIONS_PREFIX."_vote_no", 0); $__wps__vote_no = 0; } echo '<div id="__wps__chart_yes" style="display:none">'.$__wps__vote_yes.'</div>'; echo '<div id="symposium_chart_no" style="display:none">'.$__wps__vote_no.'</div>'; if (is_user_logged_in()) { $voted = __wps__get_meta($current_user->ID, 'widget_voted'); if ($voted == "on") { echo "<p>"; echo __('Thank you for voting', WPS_TEXT_DOMAIN)."."; if ($__wps__vote_forum != '') { echo "<br /><a href='".$__wps__vote_forum."'>".__('Discuss this on the forum', WPS_TEXT_DOMAIN)."...</a>"; } echo "</p>"; } else { echo "<div id='__wps__vote_forum'>"; echo "<p>".__('Your vote', WPS_TEXT_DOMAIN).": "; echo "<a href='javascript:void(0)' title='yes' class='symposium_answer' value='".__("Yes", WPS_TEXT_DOMAIN)."'>".__("Yes", WPS_TEXT_DOMAIN)."</a> ".__('or', WPS_TEXT_DOMAIN)." "; echo "<a href='javascript:void(0)' title='no' class='symposium_answer' value='".__("No", WPS_TEXT_DOMAIN)."'>".__("No", WPS_TEXT_DOMAIN)."</a>"; if ($__wps__vote_forum != '') { echo "<br /><a href='".$__wps__vote_forum."'>".__('Discuss this on the forum', WPS_TEXT_DOMAIN)."...</a>"; } echo "</p>"; echo "</div>"; echo "<div id='__wps__vote_thankyou'>"; echo "<p>".__("Thank you for voting, refresh the page for latest results", WPS_TEXT_DOMAIN); if ($__wps__vote_forum != '') { echo "<br /><a href='".$__wps__vote_forum."'>".__('Discuss this on the forum', WPS_TEXT_DOMAIN)."...</a>"; } echo "</p>"; echo "</div>"; } } else { echo "<p>".__("Log in to vote...", WPS_TEXT_DOMAIN)."</p>"; } // End content echo $after_widget; // End widget }
function sendmail($compose_recipient_id) { global $wpdb, $current_user; if (is_user_logged_in()) { $recipient = $wpdb->get_row("SELECT * FROM ".$wpdb->base_prefix."users WHERE ID = '".$compose_recipient_id."'"); if (!$recipient) { $return = false; } else { // subject and message from wps_ui elements $subject = $_POST['wps-mail-subject']; $message = $_POST['wps-mail-message']; // Do some magic to the message $message = str_replace(chr(13), "<br />", $message); // Send mail if ( $rows_affected = $wpdb->prepare( $wpdb->insert( $wpdb->base_prefix . "symposium_mail", array( 'mail_from' => $current_user->ID, 'mail_to' => $recipient->ID, 'mail_sent' => date("Y-m-d H:i:s"), 'mail_subject' => $subject, 'mail_message' => $message ) ) ) ) { $return = true; } else { $return = false; } $mail_id = $wpdb->insert_id; // Filter to allow further actions to take place apply_filters ('__wps__sendmessage_filter', $recipient->ID, $current_user->ID, $current_user->display_name, $mail_id); // Send real email if chosen if ( __wps__get_meta($recipient->ID, 'notify_new_messages') ) { $url = __wps__get_url('mail'); $body = "<h1>".$subject."</h1>"; $body .= "<p><a href='".$url.__wps__string_query($url)."mid=".$mail_id."'>".sprintf(__("Go to %s Mail", WPS_TEXT_DOMAIN), __wps__get_url('mail'))."...</a></p>"; $body .= "<p>"; $body .= $message; $body .= "</p>"; $body .= "<p><em>"; $body .= $current_user->display_name; $body .= "</em></p>"; $body .= $previous; $body = str_replace(chr(13), "<br />", $body); $body = str_replace("\\r\\n", "<br />", $body); $body = str_replace("\\", "", $body); $mail_subject = get_option(WPS_OPTIONS_PREFIX.'_subject_mail_new'); if (strpos($mail_subject, '[subject]') !== FALSE) { $mail_subject = str_replace("[subject]", $subject, $mail_subject); } if ( __wps__sendmail($recipient->user_email, $mail_subject, $body) ) { $return = true; } else { $return = false; } } } } else { $return = false; // not logged in } return $return; }
echo $html; } exit; } // AJAX function to toggle post as a favourite if ($_POST['action'] == 'toggleFav') { if (is_user_logged_in()) { $tid = $_POST['tid']; // Update meta record exists for user $favs = __wps__get_meta($current_user->ID, "forum_favs"); if (strpos($favs, "[".$tid."]") === FALSE) { $favs .= "[".$tid."]"; $r = "added"; } else { $favs = str_replace("[".$tid."]", "", $favs); $r = $tid; } __wps__update_meta($current_user->ID, "forum_favs", $favs); echo $r; } exit; }
$display_name = $wpdb->get_var($wpdb->prepare($sql, $uid)); header("Content-type: application/rss+xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<rss version="2.00">'; echo '<channel>'; echo '<title>'.get_bloginfo('name').': '.$display_name.'</title>'; echo '<link>'.get_bloginfo('url').'</link>'; echo '<description>'.get_bloginfo('description').'</description>'; $now = date("D, d M Y H:i:s T"); echo '<lastBuildDate>'.$now.'</lastBuildDate>'; if ($uid > 0) { $rss_share = __wps__get_meta($uid, 'rss_share'); if ($rss_share == 'on') { $sql = "SELECT cid, comment_timestamp, comment FROM ".$wpdb->base_prefix."symposium_comments WHERE is_group != 'on' AND comment_parent = 0 AND author_uid = %d AND subject_uid = %d ORDER BY cid DESC LIMIT 0,25"; $activities = $wpdb->get_results($wpdb->prepare($sql, $uid, $uid)); $profile_url = __wps__get_url('profile'); foreach ($activities as $activity) { echo '<item>'; echo '<title>'.stripslashes($activity->comment).'</title>'; echo '<link>'.$profile_url.__wps__string_query($profile_url).'uid='.$uid.'&post='.$activity->cid.'</link>'; echo '<guid>'.$profile_url.__wps__string_query($profile_url).'uid='.$uid.'&post='.$activity->cid.'</guid>'; echo '<pubDate>'.date(DATE_RSS, strtotime($activity->comment_timestamp)).'</pubDate>';
if (WPS_DEBUG) { $html .= ' '.$member->distance; $html .= ' ['.$member->u_lat.'/'.$member->u_long.']'; $html .= ' ('.__wps__get_meta($member->uid, 'plus_lat').'/'.__wps__get_meta($member->uid, 'plus_lng').')<br />'; } } else { $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) {
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; }
$get_members = $wpdb->get_results($wpdb->prepare($sql, $uid1)); if ($get_members) { $members_array = array(); foreach ($get_members as $member) { $add = array ( 'ID' => $member->ID, 'admin' => $member->admin, 'valid' => $member->valid, 'last_activity' => __wps__get_meta($member->ID, 'last_activity'), 'city' => __wps__get_meta($member->ID, 'city'), 'country' => __wps__get_meta($member->ID, 'country'), 'share' => __wps__get_meta($member->ID, 'share') ); array_push($members_array, $add); } $members = __wps__sub_val_sort($members_array, 'last_activity', false); $inactive = get_option(WPS_OPTIONS_PREFIX.'_online'); $offline = get_option(WPS_OPTIONS_PREFIX.'_offline'); $profile = __wps__get_url('profile'); $shown_pending_title = false; $shown_members_title = true; foreach ($members as $member) {
'mail_to' => $recipient->ID, 'mail_sent' => date("Y-m-d H:i:s"), 'mail_subject' => $subject, 'mail_message' => $message ) ) ) { $return = __('Message sent to', WPS_TEXT_DOMAIN).' '.$recipient->display_name; } else { $return = '<p><strong>'.__('There was a problem sending your mail to', WPS_TEXT_DOMAIN).' '.$recipient->display_name.'.</strong></p>'; } $mail_id = $wpdb->insert_id; // Filter to allow further actions to take place apply_filters ('__wps__sendmessage_filter', $recipient->ID, $current_user->ID, $current_user->display_name, $mail_id); // Send real email if chosen if ( __wps__get_meta($recipient->ID, 'notify_new_messages') ) { $url = __wps__get_url('mail'); $body = "<h1>".$subject."</h1>"; $body .= "<p><a href='".$url.__wps__string_query($url)."mid=".$mail_id."'>".sprintf(__("Go to %s Mail", WPS_TEXT_DOMAIN), __wps__get_url('mail'))."...</a></p>"; $body .= "<p>"; $body .= $message; $body .= "</p>"; $body .= "<p><em>"; $body .= $current_user->display_name; $body .= "</em></p>"; $body .= $previous; $body = str_replace(chr(13), "<br />", $body); $body = str_replace("\\r\\n", "<br />", $body);
function __wps__scriptsAction() { $__wps__plugin_url = WPS_PLUGIN_URL; $__wps__plugin_path = str_replace("http://".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"], "", $__wps__plugin_url); global $wpdb, $current_user; wp_get_current_user(); // Set script timeout if (get_option(WPS_OPTIONS_PREFIX.'_wps_time_out') > 0) { set_time_limit(get_option(WPS_OPTIONS_PREFIX.'_wps_time_out')); } // Debug mode? define('WPS_DEBUG', get_option(WPS_OPTIONS_PREFIX.'_debug_mode')); // Using Panel? $use_panel = false; if ((get_option(WPS_OPTIONS_PREFIX.'__wps__add_notification_bar_activated') || get_option(WPS_OPTIONS_PREFIX.'__wps__add_notification_bar_network_activated')) && file_exists(dirname(__FILE__).'/panel.php')) $use_panel = true; // Set up variables for use throughout if (!is_admin()) { // Mail if ( !isset($_GET['view']) ) { $view = "in"; } else { $view = $_GET['view']; } // Current User Page (eg. a profile page) if (isset($_GET['uid'])) { $page_uid = $_GET['uid']*1; } else { $page_uid = 0; if (isset($_POST['uid'])) { $page_uid = $_POST['uid']*1; } else { // Try the permalink? if (get_option(WPS_OPTIONS_PREFIX.'_permalink_structure')) { // get URL $url = $_SERVER["REQUEST_URI"]; // if trailing slash, remove if if ( $url[strlen($url)-1] == '/' ) $url = substr($url, 0, strlen($url)-1); $last_slash = strrpos($url, '/'); if ($last_slash === FALSE) { $page_uid = $current_user->ID; } else { $u = substr($url, $last_slash+1, strlen($url)-$last_slash); $sql = "SELECT ID FROM ".$wpdb->base_prefix."users WHERE replace(display_name, ' ', '') = %s"; $id = $wpdb->get_row($wpdb->prepare($sql, str_replace(' ', '', $u))); if ($id) { $page_uid = $id->ID; } else { $page_uid = $current_user->ID; } } } else { // default then to current user $page_uid = $current_user->ID; } } } if ($page_uid == 0) { if (isset($_POST['from']) && $_POST['from'] == 'small_search') { $search = $_POST['member_small']; $get_uid = $wpdb->get_var("SELECT u.ID FROM ".$wpdb->base_prefix."users u WHERE (u.display_name LIKE '".$search."%') OR (u.display_name LIKE '% %".$search."%') ORDER BY u.display_name LIMIT 0,1"); if ($get_uid) { $page_uid = $get_uid; } } } define('WPS_CURRENT_USER_PAGE', $page_uid); // Forum if (isset($_GET['show'])) { $show_tid = $_GET['show']*1; } else { $show_tid = 0; if (isset($_POST['tid'])) { $show_tid = $_POST['tid']*1; } } $cat_id = ''; if (isset($_GET['cid'])) { $cat_id = $_GET['cid']; } if (isset($_POST['cid'])) { $cat_id = $_POST['cid']; } // Group page if (isset($_GET['gid'])) { $page_gid = $_GET['gid']*1; } else { $page_gid = 0; if (isset($_POST['gid'])) { $page_gid = $_POST['gid']*1; } } // If visiting a group page, check to see if forum is default view if (is_user_logged_in() && $page_gid > 0) { $forum = $wpdb->get_row($wpdb->prepare("SELECT group_forum, default_page FROM ".$wpdb->prefix."symposium_groups WHERE gid = %d", $page_gid)); if ($forum->default_page == 'forum' && $forum->group_forum == 'on') { $cat_id = 0; } } // Gallery $album_id = 0; if (isset($_GET['album_id'])) { $album_id = $_GET['album_id']; } if (isset($_POST['album_id'])) { $album_id = $_POST['album_id']; } // Get styles for JS if (get_option(WPS_OPTIONS_PREFIX.'_use_styles') == "on") { $bg_color_2 = get_option(WPS_OPTIONS_PREFIX.'_bg_color_2'); $row_border_size = get_option(WPS_OPTIONS_PREFIX.'_row_border_size'); $row_border_style = get_option(WPS_OPTIONS_PREFIX.'_row_border_style'); $text_color_2 = get_option(WPS_OPTIONS_PREFIX.'_text_color_2'); } else { $bg_color_2 = ''; $row_border_size = ''; $row_border_style = ''; $text_color_2 = ''; } // GET post? if (isset($_GET['post'])) { $GETpost = $_GET['post']; } else { $GETpost = ''; } // Display Name if (isset($current_user->display_name)) { $display_name = stripslashes($current_user->display_name); } else { $display_name = ''; } // Embedded content from external plugin? if (isset($_GET['embed'])) { $embed = 'on'; } else { $embed = ''; } // to parameter if (isset($_GET['to'])) { $to = $_GET['to']; } else { $to = ''; } // mail ID if (isset($_GET['mid'])) { $mid = $_GET['mid']; } else { $mid = ''; } // chat sound $chat_sound = __wps__get_meta($current_user->ID, 'chat_sound'); if (!$chat_sound) $chat_sound = 'Pop.mp3'; // Get forum upload valid extensions $permitted_ext = get_option(WPS_OPTIONS_PREFIX.'_image_ext').','.get_option(WPS_OPTIONS_PREFIX.'_video_ext').','.get_option(WPS_OPTIONS_PREFIX.'_doc_ext'); global $blog_id; if ($blog_id > 1) { $wps_content = get_option(WPS_OPTIONS_PREFIX.'_img_url')."/".$blog_id; } else { $wps_content = get_option(WPS_OPTIONS_PREFIX.'_img_url'); } // Load JS wp_enqueue_script('__wps__', $__wps__plugin_url.'/js/'.get_option(WPS_OPTIONS_PREFIX.'_wps_js_file'), array('jquery')); // Load JScharts? if (get_option(WPS_OPTIONS_PREFIX.'_jscharts')) { if (get_option(WPS_OPTIONS_PREFIX.'_wps_js_file') == 'wps.js') { wp_enqueue_script('wps_jscharts', $__wps__plugin_url.'/js/jscharts.js', array('jquery')); } else { wp_enqueue_script('wps_jscharts', $__wps__plugin_url.'/js/jscharts.min.js', array('jquery')); } } // Use WP editor? (not for use yet!!!!) update_option(WPS_OPTIONS_PREFIX.'_use_wp_editor', false); // Set JS variables wp_localize_script( '__wps__', '__wps__', array( // variables 'permalink' => get_permalink(), 'plugins' => WP_PLUGIN_URL, 'plugin_url' => WPS_PLUGIN_URL.'/', 'wps_content_dir' => WP_CONTENT_DIR.'/wps-content', 'plugin_path' => $__wps__plugin_path, 'images_url' => get_option(WPS_OPTIONS_PREFIX.'_images'), 'inactive' => get_option(WPS_OPTIONS_PREFIX.'_online'), 'forum_url' => __wps__get_url('forum'), 'mail_url' => __wps__get_url('mail'), 'profile_url' => __wps__get_url('profile'), 'groups_url' => __wps__get_url('groups'), 'group_url' => __wps__get_url('group'), 'gallery_url' => __wps__get_url('gallery'), 'page_gid' => $page_gid, 'offline' => get_option(WPS_OPTIONS_PREFIX.'_offline'), 'use_chat' => get_option(WPS_OPTIONS_PREFIX.'_use_chat'), 'chat_polling' => get_option(WPS_OPTIONS_PREFIX.'_chat_polling'), 'bar_polling' => get_option(WPS_OPTIONS_PREFIX.'_bar_polling'), 'view' => $view, 'profile_default' => get_option(WPS_OPTIONS_PREFIX.'_wps_profile_default'), 'show_tid' => $show_tid, 'cat_id' => $cat_id, 'album_id' => $album_id, 'current_user_id' => $current_user->ID, 'current_user_display_name' => $display_name, 'current_user_level' => __wps__get_current_userlevel($current_user->ID), 'current_user_page' => $page_uid, 'current_group' => $page_gid, 'post' => $GETpost, 'please_wait' => __('Please Wait...', WPS_TEXT_DOMAIN), 'saving' => __('Saving...', WPS_TEXT_DOMAIN), 'site_title' => get_bloginfo('name'), 'site_url' => get_bloginfo('url'), 'bg_color_2' => $bg_color_2, 'row_border_size' => $row_border_size, 'row_border_style' => $row_border_style, 'text_color_2' => $text_color_2, 'template_mail_tray' => get_option(WPS_OPTIONS_PREFIX.'_template_mail_tray'), 'embed' => $embed, 'to' => $to, 'is_admin' => 0, 'mail_id' => $mid, 'permitted_ext' => $permitted_ext, 'forum_ajax' => get_option(WPS_OPTIONS_PREFIX.'_forum_ajax'), 'wps_lite' => get_option(WPS_OPTIONS_PREFIX.'_wps_lite'), 'wps_use_poke' => get_option(WPS_OPTIONS_PREFIX.'_use_poke'), 'wps_forum_stars' => get_option(WPS_OPTIONS_PREFIX.'_forum_stars'), 'wps_forum_refresh' => get_option(WPS_OPTIONS_PREFIX.'_forum_refresh'), 'wps_wysiwyg' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg'), 'wps_wysiwyg_1' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_1'), 'wps_wysiwyg_2' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_2'), 'wps_wysiwyg_3' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_3'), 'wps_wysiwyg_4' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_4'), 'wps_wysiwyg_css' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_css'), 'wps_wysiwyg_skin' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_skin'), 'wps_wysiwyg_width' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_width'), 'wps_wysiwyg_height' => get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg_height'), 'wps_plus' => (defined('WPS_PLUS')) ? WPS_PLUS : '', 'wps_alerts_activated' => (get_option(WPS_OPTIONS_PREFIX.'__wps__news_main_activated') || get_option(WPS_OPTIONS_PREFIX.'__wps__news_main_network_activated')), 'wps_admin_page' => 'na', 'dir_page_length' => get_option(WPS_OPTIONS_PREFIX.'_dir_page_length'), 'dir_full_ver' => get_option(WPS_OPTIONS_PREFIX.'_dir_full_ver') ? true : false, 'use_elastic' => get_option(WPS_OPTIONS_PREFIX.'_elastic'), 'events_user_places' => get_option(WPS_OPTIONS_PREFIX.'_events_user_places'), 'events_use_wysiwyg' => get_option(WPS_OPTIONS_PREFIX.'_events_use_wysiwyg'), 'debug' => WPS_DEBUG, 'include_context' => get_option(WPS_OPTIONS_PREFIX.'_include_context'), 'use_wp_editor' => get_option(WPS_OPTIONS_PREFIX.'_use_wp_editor'), 'profile_menu_scrolls' => get_option(WPS_OPTIONS_PREFIX.'_profile_menu_scrolls'), 'profile_menu_delta' => get_option(WPS_OPTIONS_PREFIX.'_profile_menu_delta'), 'profile_menu_adjust' => get_option(WPS_OPTIONS_PREFIX.'_profile_menu_adjust'), 'panel_enabled' => $use_panel, 'chat_sound' => $chat_sound, 'wps_content' => $wps_content, // translations 'clear' => __( 'Clear', WPS_TEXT_DOMAIN ), 'update' => __( 'Update', WPS_TEXT_DOMAIN ), 'cancel' => __( 'Cancel', WPS_TEXT_DOMAIN ), 'pleasewait' => __( 'Please wait', WPS_TEXT_DOMAIN ), 'saving' => __( 'Saving', WPS_TEXT_DOMAIN ), 'more' => __( 'more...', WPS_TEXT_DOMAIN ), 'next' => __( 'Next', WPS_TEXT_DOMAIN ), 'areyousure' => __( 'Are you sure?', WPS_TEXT_DOMAIN ), 'browseforfile' => __( 'Browse for file', WPS_TEXT_DOMAIN ), 'attachimage' => __( 'Attach an image', WPS_TEXT_DOMAIN ), 'attachfile' => __( 'Attach file', WPS_TEXT_DOMAIN ), 'whatsup' => stripslashes(get_option(WPS_OPTIONS_PREFIX.'_status_label')), 'whatsup_done' => __( 'Post added to your activity.', WPS_TEXT_DOMAIN ), 'sendmail' => __( 'Send a private mail...', WPS_TEXT_DOMAIN ), 'privatemail' => __( 'Private Mail', WPS_TEXT_DOMAIN ), 'privatemailsent' => __( 'Private mail sent!', WPS_TEXT_DOMAIN ), 'addasafriend' => sprintf(__("Add as a %s...", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')), 'friendpending' => sprintf(__("%s request sent", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')), 'attention' => get_option(WPS_OPTIONS_PREFIX.'_poke_label'), 'follow' => __( 'Follow', WPS_TEXT_DOMAIN ), 'unfollow' => __( 'Unfollow', WPS_TEXT_DOMAIN ), 'sent' => __( 'Message sent!', WPS_TEXT_DOMAIN ), 'likes' => __( 'Likes', WPS_TEXT_DOMAIN ), 'dislikes' => __( 'Dislikes', WPS_TEXT_DOMAIN ), 'forumsearch' => __( 'Search on forum', WPS_TEXT_DOMAIN ), 'gallerysearch' => __( 'Search Gallery', WPS_TEXT_DOMAIN ), 'profile_info' => __( 'Member Profile', WPS_TEXT_DOMAIN ), 'plus_mail' => __( 'Mailbox', WPS_TEXT_DOMAIN ), 'plus_follow_who' => __( 'Who am I following?', WPS_TEXT_DOMAIN ), 'plus_friends' => get_option(WPS_OPTIONS_PREFIX.'_alt_friends'), 'request_sent' => sprintf(__("Your %s request has been sent.", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friend')), 'add_a_comment' => __( 'Add a comment:', WPS_TEXT_DOMAIN ), 'add' => __( 'Add', WPS_TEXT_DOMAIN ), 'show_original' => __( 'Show original', WPS_TEXT_DOMAIN ), 'write_a_comment' => __( 'Write a comment...', WPS_TEXT_DOMAIN ), 'follow_box' => __( 'Hi', WPS_TEXT_DOMAIN ), 'events_enable_places' => __( 'Enable booking places:', WPS_TEXT_DOMAIN ), 'events_max_places' => __( 'Maximum places:', WPS_TEXT_DOMAIN ), 'events_show_max' => __( 'Maximum places:', WPS_TEXT_DOMAIN ), 'events_confirmation' => __( 'Bookings require confirmation:', WPS_TEXT_DOMAIN ), 'events_tickets_per_booking' => __( 'Max tickets per booking:', WPS_TEXT_DOMAIN ), 'events_tab_1' => __( 'Summary', WPS_TEXT_DOMAIN ), 'events_tab_2' => __( 'More Information', WPS_TEXT_DOMAIN ), 'events_tab_3' => __( 'Confirmation Email', WPS_TEXT_DOMAIN ), 'events_tab_4' => __( 'Attendees', WPS_TEXT_DOMAIN ), 'events_send_email' => __( 'Send confirmation email:', WPS_TEXT_DOMAIN ), 'events_replacements' => __( 'You can use the following:', WPS_TEXT_DOMAIN ), 'events_pay_link' => __( 'HTML for payment:', WPS_TEXT_DOMAIN ), 'events_cost' => __( 'Price per booking:', WPS_TEXT_DOMAIN ), 'events_howmany' => __( 'How many tickets do you want?', WPS_TEXT_DOMAIN ), 'events_labels' => __( 'Ref|User|Booked|Confirmation email sent|# Tickets|Payment Confirmed|Actions|Confirm attendee|Send Mail|Re-send confirmation email|Remove attendee|Confirm payment', WPS_TEXT_DOMAIN ), 'gallery_labels' => __( 'Rename|Photo renamed.|Drag thumbnails to re-order, and then|save|Delete this photo|Set as album cover', WPS_TEXT_DOMAIN ), 'sending' => __( 'Sending', WPS_TEXT_DOMAIN ), 'go' => __( 'Go', WPS_TEXT_DOMAIN ), 'bbcode_url' => __( 'Enter a website URL...', WPS_TEXT_DOMAIN ), 'bbcode_problem' => __( 'Please make sure all BB Codes have open and close tags!', WPS_TEXT_DOMAIN ), 'bbcode_label' => __( 'Enter text to show...', WPS_TEXT_DOMAIN ) )); } if (is_admin()) { // Load admin JS wp_enqueue_script('__wps__', $__wps__plugin_url.'/js/wps-admin.js', array('jquery')); // Set JS variables wp_localize_script( '__wps__', '__wps__', array( 'plugins' => WP_PLUGIN_URL, 'plugin_url' => WPS_PLUGIN_URL.'/', 'plugin_path' => $__wps__plugin_path, 'images_url' => get_option(WPS_OPTIONS_PREFIX.'_images'), 'inactive' => get_option(WPS_OPTIONS_PREFIX.'_online'), 'forum_url' => get_option(WPS_OPTIONS_PREFIX.'_forum_url'), 'mail_url' => get_option(WPS_OPTIONS_PREFIX.'_mail_url'), 'profile_url' => get_option(WPS_OPTIONS_PREFIX.'_profile_url'), 'groups_url' => get_option(WPS_OPTIONS_PREFIX.'_groups_url'), 'group_url' => get_option(WPS_OPTIONS_PREFIX.'_group_url'), 'gallery_url' => get_option(WPS_OPTIONS_PREFIX.'_gallery_url'), 'offline' => get_option(WPS_OPTIONS_PREFIX.'_offline'), 'use_chat' => get_option(WPS_OPTIONS_PREFIX.'_use_chat'), 'chat_polling' => get_option(WPS_OPTIONS_PREFIX.'_chat_polling'), 'bar_polling' => get_option(WPS_OPTIONS_PREFIX.'_bar_polling'), 'current_user_id' => $current_user->ID, 'is_admin' => 1, 'wps_admin_page' => 'symposium_debug' )); } }
LEFT JOIN ".$wpdb->base_prefix."users u ON l.author = u.ID ORDER BY l.lid DESC LIMIT 0,".$max_items; $comment_array = array(); $comment_list = $wpdb->get_results($sql); foreach ($comment_list as $comment) { $add = array ( 'lid' => $comment->lid, 'comment' => $comment->comment, 'author' => $comment->author, 'added' => $comment->added, 'display_name' => $comment->display_name, 'ID' => $comment->ID, 'last_activity' => __wps__get_meta($comment->ID, 'last_activity'), 'status' => __wps__get_meta($comment->ID, 'status') ); array_push($comment_array, $add); } $comments = __wps__sub_val_sort($comment_array, 'lid', false); // Prepare to return comments in JSON format $return_arr = array(); // Loop through comments, adding to array if any exist if ($comments) { foreach ($comments as $comment) { // Work out if they are active or not $time_now = time();
function __wps__show_metadata($user) { global $wpdb; $uid = $user->ID; // get values $dob_day = __wps__get_meta($uid, 'dob_day'); $dob_month = __wps__get_meta($uid, 'dob_month'); $dob_year = __wps__get_meta($uid, 'dob_year'); $city = __wps__get_meta($uid, 'extended_city'); $country = __wps__get_meta($uid, 'extended_country'); $share = __wps__get_meta($uid, 'share'); $wall_share = __wps__get_meta($uid, 'wall_share'); if (function_exists('__wps__rss_main')) { $rss_share = __wps__get_meta($uid, 'rss_share'); } else { $rss_share = ''; } $trusted = __wps__get_meta($uid, 'trusted'); $notify_new_messages = __wps__get_meta($uid, 'notify_new_messages'); $notify_new_wall = __wps__get_meta($uid, 'notify_new_wall'); $forum_all = __wps__get_meta($uid, 'forum_all'); $signature = __wps__get_meta($uid, 'signature'); $html = '<h3>' . __("Profile Details", WPS_TEXT_DOMAIN) . '</h3>'; $html .= '<table class="form-table">'; // Share personal information $html .= '<tr><th><label for="share">'.__('Who do you want to share personal information with?', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><select id="share" name="share">'; $html .= "<option value='Nobody'"; if ($share == 'Nobody') { $html .= ' SELECTED '; } $html .= '>'.__('Nobody', WPS_TEXT_DOMAIN).'</option>'; $html .= "<option value='Friends only'"; if ($share == 'Friends only') { $html .= ' SELECTED '; } $html .= '>'.sprintf(__('%s Only', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends')).'</option>'; $html .= "<option value='Everyone'"; if ($share == 'Everyone') { $html .= ' SELECTED '; } $html .= '>'.stripslashes(get_option(WPS_OPTIONS_PREFIX.'_alt_everyone')).'</option>'; $html .= "<option value='public'"; if ($share == 'public') { $html .= ' SELECTED '; } $html .= '>'.__('Public', WPS_TEXT_DOMAIN).'</option>'; $html .= '</select></td></tr>'; // Share Wall / Activity $html .= '<tr><th><label for="wall_share">'.__('Who do you want to share your activity with?', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><select id="wall_share" name="wall_share">'; $html .= "<option value='Nobody'"; if ($wall_share == 'Nobody') { $html .= ' SELECTED '; } $html .= '>'.__('Nobody', WPS_TEXT_DOMAIN).'</option>'; $html .= "<option value='Friends only'"; if ($wall_share == 'Friends only') { $html .= ' SELECTED '; } $html .= '>'.sprintf(__('%s Only', WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends')).'</option>'; $html .= "<option value='Everyone'"; if ($wall_share == 'Everyone') { $html .= ' SELECTED '; } $html .= '>'.stripslashes(get_option(WPS_OPTIONS_PREFIX.'_alt_everyone')).'</option>'; $html .= "<option value='public'"; if ($wall_share == 'public') { $html .= ' SELECTED '; } $html .= '>'.__('Public', WPS_TEXT_DOMAIN).'</option>'; $html .= '</select></td></tr>'; // Publish RSS feed? if (function_exists('__wps__rss_main')) { $html .= '<tr><th><label for="rss_share">'.__('RSS feed', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><select id="rss_share" name="rss_share">'; $html .= "<option value=''"; if ($rss_share == '') { $html .= ' SELECTED '; } $html .= '>'.__('No', WPS_TEXT_DOMAIN).'</option>'; $html .= "<option value='on'"; if ($rss_share == 'on') { $html .= ' SELECTED '; } $html .= '>'.__('Yes', WPS_TEXT_DOMAIN).'</option>'; $html .= '</select> '; $html .= '<span class="description">'.__('Publish your activity via RSS (only your initial posts)?', WPS_TEXT_DOMAIN).'</span>'; $html .= '</td></tr>'; } else { $html .= '<input type="hidden" id="rss_share" value="">'; } // Birthday if (get_option(WPS_OPTIONS_PREFIX.'_show_dob') == 'on') { $html .= '<tr><th><label for="dob">'.__('Your date of birth', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><select id="dob_day" name="dob_day">'; $html .= '<option value=0'; if ($dob_day == 0) { $html .= ' SELECTED '; } $html .= '>---</option>'; for ($i = 1; $i <= 31; $i++) { $html .= '<option value="'.$i.'"'; if ($dob_day == $i) { $html .= ' SELECTED '; } $html .= '>'.$i.'</option>'; } $html .= '</select> / '; $html .= '<select id="dob_month" name="dob_month">'; $html .= '<option value=0'; if ($dob_month == 0) { $html .= ' SELECTED '; } $html .= '>---</option>'; for ($i = 1; $i <= 12; $i++) { switch($i) { case 1:$monthname = __("January", WPS_TEXT_DOMAIN);break; case 2:$monthname = __("February", WPS_TEXT_DOMAIN);break; case 3:$monthname = __("March", WPS_TEXT_DOMAIN);break; case 4:$monthname = __("April", WPS_TEXT_DOMAIN);break; case 5:$monthname = __("May", WPS_TEXT_DOMAIN);break; case 6:$monthname = __("June", WPS_TEXT_DOMAIN);break; case 7:$monthname = __("July", WPS_TEXT_DOMAIN);break; case 8:$monthname = __("August", WPS_TEXT_DOMAIN);break; case 9:$monthname = __("September", WPS_TEXT_DOMAIN);break; case 10:$monthname = __("October", WPS_TEXT_DOMAIN);break; case 11:$monthname = __("November", WPS_TEXT_DOMAIN);break; case 12:$monthname = __("December", WPS_TEXT_DOMAIN);break; } $html .= '<option value="'.$i.'"'; if ($dob_month == $i) { $html .= ' SELECTED '; } $html .= '>'.$monthname.'</option>'; } $html .= '</select> / '; $html .= '<select id="dob_year" name="dob_year">'; $html .= '<option value=0'; if ($dob_year == 0) { $html .= ' SELECTED '; } $html .= '>---</option>'; for ($i = date("Y"); $i >= 1900; $i--) { $html .= '<option value="'.$i.'"'; if ($dob_year == $i) { $html .= ' SELECTED '; } $html .= '>'.$i.'</option>'; } $html .= '</td></select>'; } else { $html .= '<input type="hidden" id="dob_day" value="'.$dob_day.'">'; $html .= '<input type="hidden" id="dob_month" value="'.$dob_month.'">'; $html .= '<input type="hidden" id="dob_year" value="'.$dob_year.'">'; } // City $html .= '<tr><th><label for="extended_city">'.__('Which town/city are you in?', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="text" class="input-field" id="extended_city" name="extended_city" style="width:300px" value="'.trim($city, "'").'">'; $html .= '</td></tr>'; // Country $html .= '<tr><th><label for="extended_country">'.__('Which country are you in?', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="text" class="input-field" id="extended_country" name="extended_country" style="width:300px" value="'.trim($country, "'").'">'; $html .= '</td></tr>'; // Google map if ( ($city != '' || $country != '') && (get_option(WPS_OPTIONS_PREFIX.'_profile_google_map') > 0) ){ $html .= '<tr><th></th><td>'; $html .= '<a target="_blank" style="width:'.get_option(WPS_OPTIONS_PREFIX.'_profile_google_map').'px; height:'.get_option(WPS_OPTIONS_PREFIX.'_profile_google_map').'px;" href="http://maps.google.co.uk/maps?f=q&source=embed&hl=en&geocode=&q='.$city.',+'.$country.'&ie=UTF8&hq=&hnear='.$city.',+'.$country.'&output=embed&z=5" alt="Click on map to enlarge" title="Click on map to enlarge">'; $html .= '<img src="http://maps.google.com/maps/api/staticmap?center='.$city.',.+'.$country.'&zoom=5&size='.get_option(WPS_OPTIONS_PREFIX.'_profile_google_map').'x'.get_option(WPS_OPTIONS_PREFIX.'_profile_google_map').'&maptype=roadmap&markers=color:blue|label: |'.$city.',+'.$country.'&sensor=false" />'; $html .= '</a><br /><span class="description"> '.sprintf(__("The Google map that will be displayed on top of your %s profile page, resulting from your personal data above.", WPS_TEXT_DOMAIN), WPS_WL).'</span></td></tr>'; } // Extensions $extensions = $wpdb->get_results("SELECT * FROM ".$wpdb->base_prefix."symposium_extended ORDER BY extended_order, extended_name"); if ($extensions) { $sql = "SELECT * FROM ".$wpdb->base_prefix."usermeta WHERE user_id = %d AND meta_key like 'symposium_extended_%%'"; $fields = $wpdb->get_results($wpdb->prepare($sql, $uid)); foreach ($extensions as $extension) { // Don't display Extended Fields that are associated to WP usermeta data, they should be displayed somewhere else in the dashboard if ( $extension->wp_usermeta == '' ) { $value = $extension->extended_default; if ($extension->extended_type == "List") { $default_list = explode(',', $extension->extended_default); $value = $default_list[0]; } foreach ($fields as $field) { $slug = str_replace('symposium_extended_', '', $field->meta_key); if ($slug == $extension->extended_slug) { $value = $field->meta_value; break; } } // Draw the object according to type switch ($extension->extended_type) : case 'Text' : $html .= '<tr><th><label for="extended_'.$slug.'">'.stripslashes($extension->extended_name).'</label></th>'; $html .= '<td><input type="text" class="input-field" id="extended_'.$slug.'" name="extended_'.$slug.'" style="width:300px" value="'.$value.'"'; if ( $extension->readonly ) { $html .= ' disabled="disabled"'; } $html .= ' /></td></tr>'; break; case 'Textarea' : $html .= '<tr><th><label for="extended_'.$slug.'">'.stripslashes($extension->extended_name).'</label></th>'; $html .= '<td><textarea rows="5" cols="30" id="extended_'.$slug.'" name="extended_'.$slug.'"'; if ( $extension->readonly ) { $html .= ' disabled="disabled"'; } $html .= '>'.$value.'</textarea></td></tr>'; break; case 'List' : $html .= '<tr><th><label for="extended_'.$slug.'">'.stripslashes($extension->extended_name).'</label></th>'; $html .= '<td><select id="extended_'.$slug.'" name="extended_'.$slug.'"'; if ( $extension->readonly ) { $html .= ' disabled="disabled"'; } $html .= '>'; foreach ($default_list as $list_value) { $html .= '<option value="'.$list_value.'"'; if ( $value == $list_value) { $html .= ' SELECTED '; } $html .= '>'.$list_value.'</option>'; } $html .= '</select></td></tr>'; break; case 'Checkbox' : $html .= '<tr><th><label for="extended_'.$slug.'">'.stripslashes($extension->extended_name).'</label></th>'; $html .= '<td><input type="checkbox" id="extended_'.$slug.'" name="extended_'.$slug.'"'; if ( $extension->readonly ) { $html .= ' disabled="disabled"'; } if ( $value == 'on') { $html .= ' CHECKED '; } $html .= '/></td>'; $html .= '</tr>'; break; endswitch; } } } $html .= '</table>'; $html .= '<h3>' . __("Community Settings", WPS_TEXT_DOMAIN) . '</h3>'; $html .= '<table class="form-table">'; // Trusted member (for example, for support staff) if (__wps__get_current_userlevel() == 5) { $html .= '<tr><th><label for="trusted">'.__('Trusted Member?', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="checkbox" name="trusted" id="trusted"'; if ($trusted == 'on') { $html .= ' CHECKED '; } $html .= '/> '; $html .= '<span class="description">'.__('Is this member trusted?', WPS_TEXT_DOMAIN).'</span>'; $html .= '</td></tr>'; } else { $html .= '<tr><td><input type="hidden" name="trusted_hidden" id="trusted_hidden" value="'.$trusted.'" /><td></tr>'; } // profile_photo, avatar if ( get_option('show_avatars') ) { // AG - select your avatar here --> } // forum_digest // Email notifications for private messages $html .= '<tr><th><label for="notify_new_messages">'.__('Emails for private messages', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="checkbox" name="notify_new_messages" id="notify_new_messages"'; if ($notify_new_messages =='on') { $html .= ' CHECKED '; } $html .= '/> '; $html .= '<span class="description">'.__('Receive an email when you get new mail messages?', WPS_TEXT_DOMAIN).'</span>'; $html .= '</td></tr>'; // Email notifications for wall posts $html .= '<tr><th><label for="notify_new_wall">'.__('Emails for posts on the Wall', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="checkbox" name="notify_new_wall" id="notify_new_wall"'; if ($notify_new_wall == 'on') { $html .= ' CHECKED '; } $html .= '/> '; $html .= '<span class="description">'.__('Receive an email when a friend adds a post?', WPS_TEXT_DOMAIN).'</span>'; $html .= '</td></tr>'; if (function_exists('__wps__forum')) { // Email notifications for all forum activity (if allowed) if (get_option(WPS_OPTIONS_PREFIX.'_allow_subscribe_all') == "on") { $html .= '<tr><th><label for="forum_all">'.__('Emails for all new forum topics and replies', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="checkbox" name="forum_all" id="forum_all"'; if ($forum_all == 'on') { $html .= ' CHECKED '; } $html .= '/> '; $html .= '<span class="description">'.__('Receive an email for all new forum topics and replies?', WPS_TEXT_DOMAIN).'</span><br />'; $html .= '</td></tr>'; } else { $html .= '<input type="hidden" name="forum_all" value="" />'; } // Signature in the forum $html .= '<tr><th><label for="signature">'.__('Forum signature', WPS_TEXT_DOMAIN).'</label></th>'; $html .= '<td><input type="text" class="input-field" id="signature" name="signature" style="width:300px" value="'.stripslashes(trim($signature, "'")).'"><br />'; $html .= '<span class="description">'.__('If you want a signature to be appended automatically under your forum posts', WPS_TEXT_DOMAIN).'</span></td></tr>'; } // Facebook // AG - the return value needs to be dealt with... $html .= '</table>'; echo $html; }
echo 'OK'; 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>';
function add_reply($tid, $reply_text, $uid=0, $replybyemail=false) { if ($tid != '') { global $wpdb, $current_user; // Defaults for current state of class $topic_approved = 'on'; $group_id = 0; $answered = ''; // User ID? if ($uid == 0) { $uid = $current_user->ID; } // Get category for this topic ID $cat_id = $wpdb->get_var($wpdb->prepare("SELECT topic_category from ".$wpdb->prefix."symposium_topics where tid = %d", $tid)); // Don't allow HTML in subject if not using WYSIWYG editor if (get_option(WPS_OPTIONS_PREFIX.'_use_wysiwyg') != 'on') { $reply_text = str_replace("<", "<", $reply_text); $reply_text = str_replace(">", ">", $reply_text); } // Check for banned words $chatroom_banned = get_option(WPS_OPTIONS_PREFIX.'_chatroom_banned'); if ($chatroom_banned != '') { $badwords = $pieces = explode(",", $chatroom_banned); for($i=0;$i < sizeof($badwords);$i++){ if (strpos(' '.$reply_text.' ', $badwords[$i])) { $reply_text=eregi_replace($badwords[$i], "***", $reply_text); } } } // First check for potential duplicate $sql = "SELECT tid FROM ".$wpdb->prefix."symposium_topics WHERE topic_parent = %d AND topic_post = %s"; $duplicate = $wpdb->get_var($wpdb->prepare($sql, $tid, $reply_text)); if (!$duplicate) { if ( // Store new reply in post $wpdb->query( $wpdb->prepare( " INSERT INTO ".$wpdb->prefix."symposium_topics ( topic_subject, topic_category, topic_post, topic_date, topic_started, topic_owner, topic_parent, topic_views, topic_approved, topic_group, topic_answer ) VALUES ( %s, %d, %s, %s, %s, %d, %d, %d, %s, %d, %s )", array( '', $cat_id, $reply_text, date("Y-m-d H:i:s"), date("Y-m-d H:i:s"), $uid, $tid, 0, $topic_approved, $group_id, $answered ) ) ) ) { // get new topic id (or response) for return $new_id = $wpdb->insert_id; // Now send out emails as appropriate // Get forum URL worked out $forum_url = __wps__get_url('forum'); if (strpos($forum_url, '?') !== FALSE) { $q = "&"; } else { $q = "?"; } // Get group URL worked out if ($group_id > 0) { $forum_url = __wps__get_url('group'); if (strpos($forum_url, '?') !== FALSE) { $q = "&gid=".$group_id."&"; } else { $q = "?gid=".$group_id."&"; } } // Email people who want to know and prepare body $owner_name = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM ".$wpdb->base_prefix."users WHERE ID = %d", $uid)); $parent = $wpdb->get_var($wpdb->prepare("SELECT topic_subject FROM ".$wpdb->prefix."symposium_topics WHERE tid = %d", $tid)); $body = "<span style='font-size:24px'>".$parent."</span><br /><br />"; $body .= "<p>".$owner_name." ".__('replied', WPS_TEXT_DOMAIN)."...</p>"; $body .= "<p>".$reply_text."</p>"; $url = $forum_url.$q."cid=".$cat_id."&show=".$tid; $body .= "<p><a href='".$url."'>".$url."</a></p>"; $body = str_replace(chr(13), "<br />", $body); $body = str_replace("\\r\\n", "<br />", $body); $body = str_replace("\\", "", $body); $email_list = '0,'; if ($topic_approved == "on") { $query = $wpdb->get_results($wpdb->prepare(" SELECT user_email, ID FROM ".$wpdb->base_prefix."users u RIGHT JOIN ".$wpdb->prefix."symposium_subs ON ".$wpdb->prefix."symposium_subs.uid = u.ID WHERE u.ID != %d AND tid = %d", $uid, $tid)); if ($query) { foreach ($query as $user) { // Filter to allow further actions to take place apply_filters ('__wps__forum_newreply_filter', $user->ID, $uid, $owner_name, $url); // Keep track of who sent to so far $email_list .= $user->ID.','; // Check for Reply-By-Email if ($replybyemail || function_exists('__wps__mailinglist')) { $subject_add = ' #TID='.$tid.' ['.__('do not edit', WPS_TEXT_DOMAIN).']'; $body = get_option(WPS_OPTIONS_PREFIX.'_mailinglist_prompt').'<br />'.get_option(WPS_OPTIONS_PREFIX.'_mailinglist_divider').'<br /><br />'.get_option(WPS_OPTIONS_PREFIX.'_mailinglist_divider_bottom').'<br /><br />'.'<br /><br />'.$body; } else { $subject_add = ''; } // Send mail if (strpos(get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply'), '[topic]') !== FALSE) { $subject = str_replace("[topic]", $parent, get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply')); } else { $subject = get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply'); } __wps__sendmail($user->user_email, $subject.$subject_add, $body); } } // Now send to everyone who wants to know about all new topics and replies $email_list .= '0'; $sql = "SELECT ID,user_email FROM ".$wpdb->base_prefix."users u WHERE ID != %d AND ID NOT IN (".$email_list.")"; $list = $wpdb->get_results($wpdb->prepare($sql, $current_user->ID)); if ($list) { $list_array = array(); foreach ($list as $item) { if (__wps__get_meta($item->ID, 'forum_all') == 'on') { $add = array ( 'ID' => $item->ID, 'user_email' => $item->user_email ); array_push($list_array, $add); } } $query = __wps__sub_val_sort($list_array, 'last_activity'); } else { $query = false; } // Get list of permitted roles for this topic category $sql = "SELECT level FROM ".$wpdb->prefix."symposium_cats WHERE cid = %d"; $level = $wpdb->get_var($wpdb->prepare($sql, $cat_id)); $cat_roles = unserialize($level); if ($query) { foreach ($query as $user) { // If a group and a member of the group, or not a group forum... if ($group_id == 0 || __wps__member_of($group_id) == "yes") { // Get role of recipient user $the_user = get_userdata( $user->ID ); $capabilities = $the_user->{$wpdb->prefix . 'capabilities'}; if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $user_role = 'NONE'; if ($capabilities) { foreach ( $wp_roles->role_names as $role => $name ) { if ( array_key_exists( $role, $capabilities ) ) $user_role = $role; } } // Check in this topics category level if (strpos(strtolower($cat_roles), 'everyone,') !== FALSE || strpos(strtolower($cat_roles), $user_role.',') !== FALSE) { // Filter to allow further actions to take place apply_filters ('__wps__forum_newreply_filter', $user->ID, $uid, $owner_name, $url); // Send mail if (strpos(get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply'), '[topic]') !== FALSE) { $subject = str_replace("[topic]", $parent, get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply')); } else { $subject = get_option(WPS_OPTIONS_PREFIX.'_subject_forum_reply'); } __wps__sendmail($user->user_email, $subject, $body); } } } } } else { // Email admin if post needs approval $body = "<span style='font-size:24px; font-style:italic;'>".__("Moderation required for a reply", WPS_TEXT_DOMAIN)."</span><br /><br />".$body; __wps__sendmail(get_bloginfo('admin_email'), __('Moderation required for a reply', WPS_TEXT_DOMAIN), $body); } return $new_id; } else { //__wps__sendmail(get_bloginfo('admin_email'), __('POP3 insert failed', WPS_TEXT_DOMAIN), 'Query:'.$wpdb->last_query); return false; } } else { //__wps__sendmail(get_bloginfo('admin_email'), __('POP3 insert failed', WPS_TEXT_DOMAIN), 'Duplicate skipped: '.$wpdb->last_query); return false; } // End duplicate check } else { //__wps__sendmail(get_bloginfo('admin_email'), __('POP3 insert failed', WPS_TEXT_DOMAIN), 'No tid passed'); return false; } }
function __wps__mail_menu() { global $wpdb, $current_user; // See if the user has posted forum settings if( isset($_POST[ 'symposium_update' ]) && $_POST[ 'symposium_update' ] == '__wps__mail_menu' ) { $mail_all = (isset($_POST[ 'mail_all' ])) ? $_POST[ 'mail_all' ] : ''; // Update database update_option(WPS_OPTIONS_PREFIX.'_mail_all', $mail_all); } if ( isset($_POST['bulk_message']) ) { $cnt = 0; $subject = $_POST['bulk_subject']; $message =$_POST['bulk_message']; if ($subject == '' || $message == '') { echo "<div class='error'><p>".__('Please fill in the subject and message fields.', WPS_TEXT_DOMAIN).".</p></div>"; } else { if (isset($_POST['roles'])) { $range = array_keys($_POST['roles']); $include_roles = ''; foreach ($range as $key) { $include_roles .= $_POST['roles'][$key].','; } $include_roles = str_replace('', ' ', $include_roles); } else { $include_roles = ''; } // Chosen at least one WordPress role? if ($include_roles != '') { $url = __wps__get_url('mail'); $sql = "SELECT * FROM ".$wpdb->base_prefix."users"; $members = $wpdb->get_results($sql); foreach ($members as $member) { // Get this member's WP role and check in permitted list $the_user = get_userdata( $member->ID ); $capabilities = $the_user->{$wpdb->prefix . 'capabilities'}; $user_role = 'NONE'; if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles(); if ($capabilities) { foreach ( $wp_roles->role_names as $role => $name ) { if ( array_key_exists( $role, $capabilities ) ) { $user_role = str_replace(' ', '', $role); } } } // Check in this topics category level if (strpos(strtolower($include_roles), 'everyone,') !== FALSE || strpos(strtolower($include_roles), $user_role.',') !== FALSE) { // Send mail if ( $rows_affected = $wpdb->prepare( $wpdb->insert( $wpdb->base_prefix . "symposium_mail", array( 'mail_from' => $current_user->ID, 'mail_to' => $member->ID, 'mail_sent' => date("Y-m-d H:i:s"), 'mail_subject' => $subject, 'mail_message' => $message ) ), '' ) ) { $cnt++; } $mail_id = $wpdb->insert_id; // Filter to allow further actions to take place apply_filters ('__wps__sendmessage_filter', $member->ID, $current_user->ID, $current_user->display_name, $mail_id); // Send real email if chosen if ( __wps__get_meta($member->ID, 'notify_new_messages') ) { $body = "<h1>".$subject."</h1>"; $body .= "<p><a href='".$url.__wps__string_query($url)."mid=".$mail_id."'>".__("Go to Mail", WPS_TEXT_DOMAIN)."...</a></p>"; $body .= "<p>"; $body .= $message; $body .= "</p>"; $body .= "<p><em>"; $body .= $current_user->display_name; $body .= "</em></p>"; $body = str_replace(chr(13), "<br />", $body); $body = str_replace("\\r\\n", "<br />", $body); $body = str_replace("\\", "", $body); // Send real email if (isset($_POST['bulk_email'])) { __wps__sendmail($member->user_email, __('New Mail Message', WPS_TEXT_DOMAIN), $body); } } } } echo "<div class='updated'><p>"; if (isset($_POST['bulk_email'])) { echo sprintf(__('Bulk message sent to %d members, and to their email addresses.', WPS_TEXT_DOMAIN), $cnt); } else { echo sprintf(__('Bulk message sent to %d members (but not to their email addresses).', WPS_TEXT_DOMAIN), $cnt); } echo "</p></div>"; $subject = ''; $message = ''; } else { echo "<div class='error'><p>".__('Please choose at least one WordPress role.', WPS_TEXT_DOMAIN).".</p></div>"; } } } else { $subject = ''; $message = ''; } // Get config data to show $mail_all = get_option(WPS_OPTIONS_PREFIX.'_mail_all'); echo '<div class="wrap">'; echo '<div id="icon-themes" class="icon32"><br /></div>'; echo '<h2>'.sprintf(__('%s Options', WPS_TEXT_DOMAIN), WPS_WL).'</h2><br />'; __wps__show_tabs_header('mail'); ?> <form method="post" action=""> <input type="hidden" name="symposium_update" value="__wps__mail_menu"> <table class="form-table __wps__admin_table"> <tr><td colspan="2"><h2><?php _e('Options', WPS_TEXT_DOMAIN) ?></h2></td></tr> <tr valign="top"> <td scope="row"><label for="mail_all"><?php echo __('Mail to all', WPS_TEXT_DOMAIN); ?></label></td> <td> <input type="checkbox" name="mail_all" id="mail_all" <?php if ($mail_all == "on") { echo "CHECKED"; } ?>/> <span class="description"><?php echo __('Allow mail to all members, even if not a friend?', WPS_TEXT_DOMAIN); ?></span></td> </tr> </table> <p class="submit" style='margin-left:6px;'> <input type="submit" name="Submit" class="button-primary" value="<?php echo __('Save Changes', WPS_TEXT_DOMAIN); ?>" /> </p> </form> <?php echo '<div style="margin-left:10px">'; echo '<h2>'.__('Send bulk mail', WPS_TEXT_DOMAIN).'</h2>'; echo '<p>'.sprintf(__('Send a message from you (%s) to all members of this website - if running WordPress MultiSite, this means all members on your site network.', WPS_TEXT_DOMAIN), $current_user->display_name).'</p>'; echo '<form method="post" action="">'; echo '<strong>'.__('Subject', WPS_TEXT_DOMAIN).'</strong><br />'; echo '<textarea name="bulk_subject" style="width:500px; height:23px; margin-bottom:15px; overflow:hidden;">'.$subject.'</textarea><br />'; echo '<strong>'.__('Select WordPress roles to include', WPS_TEXT_DOMAIN).'</strong><br />'; echo '<div style="margin:10px">'; // Get list of roles global $wp_roles; $all_roles = $wp_roles->roles; echo '<input type="checkbox" name="roles[]" value="everyone"> '.__('All users', WPS_TEXT_DOMAIN).'<br />'; foreach ($all_roles as $role) { echo '<input type="checkbox" name="roles[]" value="'.$role['name'].'"'; echo '> '.$role['name'].'<br />'; } echo '</div>'; echo '<strong>'.__('Message', WPS_TEXT_DOMAIN).'</strong><br />'; echo '<textarea name="bulk_message" style="width:500px; height:200px;">'.$message.'</textarea><br />'; echo '<p><em>'.__('You can include HTML.', WPS_TEXT_DOMAIN).'</em></p>'; echo '<input type="checkbox" name="bulk_email" CHECKED> '.__('Internal mail will be sent, but also send out email notifications?', WPS_TEXT_DOMAIN); echo '<br /><em>'.__('Be wary of limitations from your hosting provider. Members who do not want email notifications will not be sent one.', WPS_TEXT_DOMAIN).'</em><br /><br />'; echo '<input type="submit" name="Submit" class="button-primary" value="'.__('Send', WPS_TEXT_DOMAIN).'" />'; echo '</form></div>'; ?> <table style="margin-left:10px; margin-top:10px;"> <tr><td colspan="2"><h2>Shortcodes</h2></td></tr> <tr><td width="165px">[<?php echo WPS_SHORTCODE_PREFIX; ?>-mail]</td> <td><?php echo __('Display the mail page.', WPS_TEXT_DOMAIN); ?></td></tr> </table> <?php __wps__show_tabs_header_end(); echo '</div>'; }
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; }
function __wps__add_notification_bar() { global $wpdb, $current_user; wp_get_current_user(); $plugin = WPS_PLUGIN_URL; if ( is_user_logged_in() ) { $use_chat = get_option(WPS_OPTIONS_PREFIX.'_use_chat'); if (get_option(WPS_OPTIONS_PREFIX.'_wps_lite')) $use_chat = ''; $inactive = get_option(WPS_OPTIONS_PREFIX.'_online'); $offline = get_option(WPS_OPTIONS_PREFIX.'_offline'); if (get_option(WPS_OPTIONS_PREFIX.'_use_styles') == "on") $border_radius = get_option(WPS_OPTIONS_PREFIX.'_border_radius'); ?> <style> <?php if (get_option(WPS_OPTIONS_PREFIX.'_use_styles') == "on") { echo '.header_bg_blink {'; echo 'background-color: '.get_option(WPS_OPTIONS_PREFIX.'_categories_background'); echo '}'; } ?> .__wps__online_box { <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> <?php if (!function_exists('__wps__profile')) { echo 'display: none'; }?> } .__wps__online_box-none { <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> <?php if (!function_exists('__wps__profile')) { echo 'display: none'; }?> } #__wps__logout { background-image:url('<?php echo get_option(WPS_OPTIONS_PREFIX.'_images'); ?>/logout.gif'); <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> } .__wps__email_box { <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> <?php if (!function_exists('__wps__mail')) { echo 'display: none'; }?> } .__wps__email_box-read { background-image:url('<?php echo get_option(WPS_OPTIONS_PREFIX.'_images'); ?>/email.gif'); } .__wps__email_box-unread { background-image:url('<?php echo get_option(WPS_OPTIONS_PREFIX.'_images'); ?>/emailunread.gif'); } .__wps__friends_box { <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> <?php if (!function_exists('__wps__profile')) { echo 'display: none'; }?> } .__wps__friends_box-none { background-image:url('<?php echo get_option(WPS_OPTIONS_PREFIX.'_images'); ?>/friends.gif'); } .__wps__friends_box-new { background-image:url('<?php echo get_option(WPS_OPTIONS_PREFIX.'_images'); ?>/friendsnew.gif'); } .corners { <?php if (isset($border_radius)) { ?> border-radius: <?php echo $border_radius; ?>px; -moz-border-radius: <?php echo $border_radius; ?>px; <?php } ?> } </style> <?php echo "<!-- NOTIFICATION BAR -->"; if (is_user_logged_in()) { // DIV for who's online echo "<div id='__wps__who_online'>"; echo "<div id='__wps__who_online_header'>"; echo "<div id='__wps__who_online_close'><img src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/close.png' alt='".__("Close", WPS_TEXT_DOMAIN)."' /></div>"; echo "<div id='__wps__who_online_close_label'>".sprintf(__("%s Status", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends'))."</div>"; echo "</div>"; echo "<div id='__wps__friends_online_list'></div>"; echo "</div>"; // Logout button DIV echo "<div id='__wps__logout_div'>"; echo "<div id='__wps__online_status_div'>"; echo "<input type='checkbox' id='__wps__online_status' "; if (__wps__get_meta($current_user->ID, 'status') == "offline") { echo " CHECKED"; } echo "> ".__("Appear offline?", WPS_TEXT_DOMAIN); echo "</div>"; echo "<div id='__wps__online_status_div'>"; echo "<img style='float: left; margin-left: 1px; margin-right: 5px;' src='".get_option(WPS_OPTIONS_PREFIX.'_images')."/close.png' alt='".__("Logout", WPS_TEXT_DOMAIN)."' />"; echo "<a id='__wps__logout-link' href='javascript:void(0);'>".__("Logout", WPS_TEXT_DOMAIN)."</a>"; echo "</div>"; echo "</div>"; echo '<div id="__wps__notification_bar" >'; // Log out echo "<div id='__wps__logout'>".__('Logout', WPS_TEXT_DOMAIN)."</div>"; // Pending Friends if (function_exists('__wps__profile')) { echo "<div id='__wps__friends_box' title='".sprintf(__("Go to %s", WPS_TEXT_DOMAIN), get_option(WPS_OPTIONS_PREFIX.'_alt_friends'))."' class='__wps__friends_box __wps__friends_box-none'>"; } else { echo "<div id='__wps__friends_box' style='display:none'>"; } echo "</div>"; // Unread Mail if (function_exists('__wps__mail')) { echo "<div id='__wps__email_box' title='".__("Go to Mail", WPS_TEXT_DOMAIN)."' class='__wps__email_box __wps__email_box-read'>"; } else { echo "<div id='__wps__email_box' style='display:none'>"; } echo "</div>"; // Friends Status/Online echo "<div id='__wps__online_box' class='__wps__online_box-none'></div>"; echo "</div>"; } // Re-open any windows (and add DIV for sound alert) echo '<div id="player_div"></div>'; if ((get_option(WPS_OPTIONS_PREFIX.'__wps__add_notification_bar_activated') || get_option(WPS_OPTIONS_PREFIX.'__wps__add_notification_bar_network_activated'))) { // re-open any previous chatboxes @session_start(); if (isset($_SESSION['chatbox_status'])) { print '<script type="text/javascript">'; print 'jQuery(function() {'; foreach ($_SESSION['chatbox_status'] as $openedchatbox) { if (isset($openedchatbox['partner_id']) && isset($openedchatbox['partner_username']) && isset($openedchatbox['chatbox_status'])) print 'PopupChat('.$openedchatbox['partner_id'].',"'.$openedchatbox['partner_username'].'",'.$openedchatbox['chatbox_status'].',1);'; } print "});"; print '</script>'; } } } }