function wpmudev_chat_buddypress_friends_list() { global $bp, $members_template, $wpmudev_chat; // Set thsi so when we get to wp_footer it knows we need to load the JS/CSS for the Friends display. $wpmudev_chat->_chat_plugin_settings['blocked_urls']['front'] = false; if (isset($members_template->member->is_friend) && $members_template->member->is_friend == true || $bp->loggedin_user->is_site_admin == true) { $content = ''; $content .= '<div id="wpmudev-chat-now-button-' . $members_template->member->ID . '" class="wpmudev-chat-now-button">'; $friends_status = wpmudev_chat_get_friends_status($bp->loggedin_user->id, $members_template->member->ID); if (!empty($friends_status[0])) { $friends_status = $friends_status[0]; } else { $friends_status = ''; } $friend_data = wpmudev_chat_get_chat_status_data($members_template->member->ID, $friends_status); $friend_status_display = $friend_data['icon'] . $friend_data['label']; if (!empty($friend_data['href'])) { $content .= '<a class="button wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#" rel="' . $friend_data['href'] . '">' . $friend_status_display . '</a>'; } else { $content .= '<a onclick="return false;" disabled="disabled" class="button wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#">' . $friend_status_display . '</a>'; } $content .= '</div>'; echo $content; } }
function wpmudev_chat_buddypress_member_header_actions() { global $bp, $members_template, $wpmudev_chat, $current_user; if ($bp->loggedin_user->id === bp_displayed_user_id()) { return; } //if (!is_object('BP_Friends_Friendship')) return; if (!bp_is_active('friends')) { return; } if (!class_exists('BP_Friends_Friendship')) { return $is_friend_ret = BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), bp_displayed_user_id()); } //echo "is_friend_ret[". $is_friend_ret ."]<br />"; // Set this so when we get to wp_footer it knows we need to load the JS/CSS for the Friends display. $wpmudev_chat->_chat_plugin_settings['blocked_urls']['front'] = false; if (BP_Friends_Friendship::check_is_friend(bp_loggedin_user_id(), bp_displayed_user_id()) == 'is_friend' || $bp->loggedin_user->is_site_admin == true) { $content = ''; $content .= '<div id="wpmudev-chat-now-button-' . bp_displayed_user_id() . '" class="generic-button wpmudev-chat-now-button">'; $friends_status = wpmudev_chat_get_friends_status($bp->loggedin_user->id, bp_displayed_user_id()); if (!empty($friends_status[0])) { $friends_status = $friends_status[0]; } else { $friends_status = ''; } $friend_data = wpmudev_chat_get_chat_status_data(bp_displayed_user_id(), $friends_status); //echo "friend_data<pre>"; print_r($friend_data); echo "</pre>"; $friend_status_display = $friend_data['icon'] . $friend_data['label']; if (!empty($friend_data['href'])) { $content .= '<a class="button wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#" rel="' . $friend_data['href'] . '">' . $friend_status_display . '</a>'; } else { $content .= '<a onclick="return false;" disabled="disabled" class="wpmudev-chat-button ' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#">' . $friend_status_display . '</a>'; } $content .= '</div>'; echo $content; } }
function wpmudev_chat_get_chat_status_label($user_id, $friend_id, $label_on = '', $label_off = '') { global $wpmudev_chat; $friends_status = wpmudev_chat_get_friends_status($user_id, $friend_id); //echo "friends_status<pre>"; print_r($friends_status); echo "</pre>"; if (!empty($friends_status[0])) { $friends_status = $friends_status[0]; } else { $friends_status = ''; } $friend_data = wpmudev_chat_get_chat_status_data($user_id, $friends_status); //echo "friend_data<pre>"; print_r($friend_data); echo "</pre>"; $friend_status_display = $friend_data['icon'] . $friend_data['label']; if (!empty($friend_data) && isset($friend_data['href']) && !empty($friend_data['href'])) { return '<a class="' . $friend_data['href_class'] . '" title="' . $friend_data['href_title'] . '" href="#" rel="' . $friend_data['href'] . '">' . $friend_status_display . '</a>'; } else { return $friend_status_display; } }
function wpmudev_chat_friends_dashboard_widget_proc() { global $bp, $wpmudev_chat, $current_user; $friends_list_ids = array(); if (!empty($bp) && function_exists('bp_get_friend_ids')) { $friends_ids = bp_get_friend_ids($bp->loggedin_user->id); //echo "friends_ids=[". $friends_ids ."]<br />"; if (!empty($friends_ids)) { $friends_list_ids = explode(',', $friends_ids); } //echo "friends_list_ids<pre>"; print_r($friends_list_ids); echo "</pre>"; } else { if (!is_admin() && !function_exists('is_plugin_active')) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } if (!is_plugin_active('friends/friends.php')) { if (is_multisite() && !is_plugin_active_for_network('friends/friends.php')) { ?> <p class="error"><?php $this->plugin_error_message; ?> </p><?php return; } } if (!function_exists('friends_get_list')) { return; } $friends_list_ids = friends_get_list($current_user->ID); } //echo "friends_list_ids<pre>"; print_r($friends_list_ids); echo "</pre>"; if (!is_array($friends_list_ids) || !count($friends_list_ids)) { return; } $chat_output = ''; $friends_status = wpmudev_chat_get_friends_status($current_user->ID, $friends_list_ids); //echo "friends_status<pre>"; print_r($friends_status); echo "</pre>"; if ($friends_status && is_array($friends_status) && count($friends_status)) { //echo "friends_status<pre>"; print_r($friends_status); echo "</pre>"; foreach ($friends_status as $friend) { if (isset($friend->chat_status) && $friend->chat_status == "available") { $friend_status_data = wpmudev_chat_get_chat_status_data($current_user->ID, $friend); //echo "friend_status_data<pre>"; print_r($friend_status_data); echo "</pre>"; $chat_output .= '<li><a class="' . $friend_status_data['href_class'] . '" title="' . $friend_status_data['href_title'] . '" href="#" rel="' . md5($friend->ID) . '"><span class="wpmudev-chat-ab-icon wpmudev-chat-ab-icon-' . $friend->chat_status . '"></span><span class="wpmudev-chat-ab-label">' . $friend->display_name . '</span>' . '</a></li>'; } } if (!empty($chat_output)) { $height_style = ' style="max-height: ' . $this->instance['box_height'] . '; overflow:auto;" '; echo '<ul id="wpmudev-chat-friends-dashboard-widget" ' . $height_style . ' class="wpmudev-chat-friends-widget">' . $chat_output . '</ul>'; } } else { ?> <p><?php _e("No Friends online.", $wpmudev_chat->translation_domain); ?> </p><?php } }