<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][5712] trunk/bp-friends: Remove unneeded globals and clean up some code in Friends component.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/5712">5712</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2012-02-11 04:42:04 +0000 (Sat, 11 Feb 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove unneeded globals and clean up some code in Friends component. See <a href="http://buddypress.trac.wordpress.org/ticket/3989">#3989</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpfriendsbpfriendsactionsphp">trunk/bp-friends/bp-friends-actions.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsactivityphp">trunk/bp-friends/bp-friends-activity.php</a></li>
<li><a href="#trunkbpfriendsbpfriendscachephp">trunk/bp-friends/bp-friends-cache.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsfunctionsphp">trunk/bp-friends/bp-friends-functions.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsnotificationsphp">trunk/bp-friends/bp-friends-notifications.php</a></li>
<li><a href="#trunkbpfriendsbpfriendsscreensphp">trunk/bp-friends/bp-friends-screens.php</a></li>
<li><a href="#trunkbpfriendsbpfriendstemplatephp">trunk/bp-friends/bp-friends-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpfriendsbpfriendsactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-actions.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-actions.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-actions.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,8 +1,14 @@
</span><span class="cx"> &lt;?php
</span><ins>+
</ins><span class="cx"> /**
</span><ins>+ * BuddyPress Friends Actions
+ *
</ins><span class="cx">  * Action functions are exactly the same as screen functions, however they do not
</span><span class="cx">  * have a template screen associated with them. Usually they will send the user
</span><span class="cx">  * back to the default screen after execution.
</span><ins>+ *
+ * @package BuddyPress
+ * @subpackage FriendsActions
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> // Exit if accessed directly
</span><span class="lines">@@ -78,4 +84,4 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_init', 'friends_action_remove_friend' );
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendsactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-activity.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-activity.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-activity.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,7 +1,13 @@
</span><span class="cx"> &lt;?php
</span><ins>+
</ins><span class="cx"> /**
</span><del>- * These functions handle the recording, deleting and formatting of activity and
- * notifications for the user and for this specific component.
</del><ins>+ * BuddyPress Friends Activity Functions
+ *
+ * These functions handle the recording, deleting and formatting of activity 
+ * for the user and for this specific component.
+ *
+ * @package BuddyPress
+ * @subpackage FriendsActivity
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> // Exit if accessed directly
</span><span class="lines">@@ -36,7 +42,7 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         if ( bp_is_active( 'activity' ) ) {
</span><del>-                extract( (array)$args );
</del><ins>+                extract( (array) $args );
</ins><span class="cx">                 bp_activity_delete_by_item_id( array( 'item_id' =&gt; $item_id, 'component' =&gt; $bp-&gt;friends-&gt;id, 'type' =&gt; $type, 'user_id' =&gt; $user_id ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -70,7 +76,6 @@
</span><span class="cx">  * @param str $format 'string' for BuddyBar-compatible notifications; 'array' for WP Admin Bar
</span><span class="cx">  */
</span><span class="cx"> function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         switch ( $action ) {
</span><span class="cx">                 case 'friendship_accepted':
</span><span class="lines">@@ -109,7 +114,7 @@
</span><span class="cx">                 $return = apply_filters( $filter, array(
</span><span class="cx">                         'link' =&gt; $link,
</span><span class="cx">                         'text' =&gt; $text
</span><del>-                ), (int)$total_items );
</del><ins>+                ), (int) $total_items );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
</span><span class="lines">@@ -117,4 +122,4 @@
</span><span class="cx">         return $return;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendscachephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-cache.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-cache.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-cache.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,9 +1,16 @@
</span><span class="cx"> &lt;?php
</span><ins>+
</ins><span class="cx"> /**
</span><ins>+ * BuddyPress Friends Caching
+ *
</ins><span class="cx">  * Caching functions handle the clearing of cached objects and pages on specific
</span><span class="cx">  * actions throughout BuddyPress.
</span><ins>+ *
+ * @package BuddyPress
+ * @subpackage FriendsCaching
</ins><span class="cx">  */
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="lines">@@ -35,4 +42,4 @@
</span><span class="cx"> add_action( 'friends_friendship_deleted',   'bp_core_clear_cache' );
</span><span class="cx"> add_action( 'friends_friendship_requested', 'bp_core_clear_cache' );
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-functions.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-functions.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-functions.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,11 +1,15 @@
</span><span class="cx"> &lt;?php
</span><del>-/********************************************************************************
- * Business Functions
</del><ins>+
+/**
+ * BuddyPress Friends Functions
</ins><span class="cx">  *
</span><del>- * Business functions are where all the magic happens in BuddyPress. They will
</del><ins>+ * Functions are where all the magic happens in BuddyPress. They will
</ins><span class="cx">  * handle the actual saving or manipulation of information. Usually they will
</span><span class="cx">  * hand off to a database class for data access, then return
</span><span class="cx">  * true or false on success or failure.
</span><ins>+ *
+ * @package BuddyPress
+ * @subpackage FriendsFunctions
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> // Exit if accessed directly
</span><span class="lines">@@ -52,7 +56,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_remove_friend( $initiator_userid, $friend_userid ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
</span><span class="cx">         $friendship    = new BP_Friends_Friendship( $friendship_id );
</span><span class="lines">@@ -137,7 +140,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_check_friendship( $user_id, $possible_friend_id ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
</span><span class="cx">                 return true;
</span><span class="lines">@@ -151,9 +153,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_get_total_friend_count( $user_id = 0 ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><del>-        if ( !$user_id )
</del><ins>+        if ( empty( $user_id ) )
</ins><span class="cx">                 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
</span><span class="cx"> 
</span><span class="cx">         if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
</span><span class="lines">@@ -181,7 +182,7 @@
</span><span class="cx">         return BP_Friends_Friendship::get_friendship_id( $initiator_user_id, $friend_user_id );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false, $filter = false ) {
</del><ins>+function friends_get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
</ins><span class="cx">         return BP_Friends_Friendship::get_friend_user_ids( $user_id, $friend_requests_only, $assoc_arr );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -292,13 +293,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_search_users( $search_terms, $user_id, $pag_num = 0, $pag_page = 0 ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
</span><span class="cx"> 
</span><del>-        if ( !$user_ids )
</del><ins>+        if ( empty( $user_ids ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><ins>+        $users = array();
</ins><span class="cx">         for ( $i = 0, $count = count( $user_ids ); $i &lt; $count; ++$i )
</span><span class="cx">                 $users[] = new BP_Core_User( $user_ids[$i] );
</span><span class="cx"> 
</span><span class="lines">@@ -311,7 +312,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( 'add' == $status ) {
</span><span class="cx">                 bp_update_user_meta( $initiator_user_id, 'total_friend_count', (int)bp_get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 );
</span><span class="lines">@@ -327,7 +327,7 @@
</span><span class="cx"> 
</span><span class="cx">         do_action( 'friends_before_remove_data', $user_id );
</span><span class="cx"> 
</span><del>-        BP_Friends_Friendship::delete_all_for_user($user_id);
</del><ins>+        BP_Friends_Friendship::delete_all_for_user( $user_id );
</ins><span class="cx"> 
</span><span class="cx">         // Remove usermeta
</span><span class="cx">         bp_delete_user_meta( $user_id, 'total_friend_count' );
</span><span class="lines">@@ -341,4 +341,4 @@
</span><span class="cx"> add_action( 'delete_user',       'friends_remove_data' );
</span><span class="cx"> add_action( 'bp_make_spam_user', 'friends_remove_data' );
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendsnotificationsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-notifications.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-notifications.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-notifications.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,22 +1,30 @@
</span><span class="cx"> &lt;?php
</span><ins>+
+/**
+ * BuddyPress Friends Activity Functions
+ *
+ * These functions handle the recording, deleting and formatting of activity
+ * for the user and for this specific component.
+ *
+ * @package BuddyPress
+ * @subpackage FriendsActivity
+ */
+
</ins><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="cx"> function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         $initiator_name = bp_core_get_user_displayname( $initiator_id );
</span><span class="cx"> 
</span><span class="cx">         if ( 'no' == bp_get_user_meta( (int)$friend_id, 'notification_friends_friendship_request', true ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $ud = get_userdata( $friend_id );
-        $initiator_ud = get_userdata( $initiator_id );
-
</del><ins>+        $ud                = get_userdata( $friend_id );
</ins><span class="cx">         $all_requests_link = bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/';
</span><del>-        $settings_slug    = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
-        $settings_link    = trailingslashit( bp_core_get_user_domain( $friend_id ) .  $settings_slug . '/notifications' );
-        $initiator_link   = bp_core_get_user_domain( $initiator_id );
</del><ins>+        $settings_slug     = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
+        $settings_link     = trailingslashit( bp_core_get_user_domain( $friend_id ) .  $settings_slug . '/notifications' );
+        $initiator_link    = bp_core_get_user_domain( $initiator_id );
</ins><span class="cx"> 
</span><span class="cx">         // Set up and send the message
</span><span class="cx">         $to       = $ud-&gt;user_email;
</span><span class="lines">@@ -46,17 +54,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><del>-        $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
-
</del><span class="cx">         $friend_name = bp_core_get_user_displayname( $friend_id );
</span><span class="cx"> 
</span><del>-        if ( 'no' == bp_get_user_meta( (int)$initiator_id, 'notification_friends_friendship_accepted', true ) )
</del><ins>+        if ( 'no' == bp_get_user_meta( (int) $initiator_id, 'notification_friends_friendship_accepted', true ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $ud = get_userdata( $initiator_id );
-
</del><ins>+        $ud            = get_userdata( $initiator_id );
</ins><span class="cx">         $friend_link   = bp_core_get_user_domain( $friend_id );
</span><span class="cx">         $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
</span><span class="cx">         $settings_link = trailingslashit( bp_core_get_user_domain( $initiator_id ) . $settings_slug . '/notifications' );
</span><span class="lines">@@ -86,4 +90,4 @@
</span><span class="cx">         do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendsscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-screens.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-screens.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-screens.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,8 +1,14 @@
</span><span class="cx"> &lt;?php
</span><ins>+
</ins><span class="cx"> /**
</span><ins>+ * BuddyPress Friends Screen Functions
+ *
</ins><span class="cx">  * Screen functions are the controllers of BuddyPress. They will execute when their
</span><span class="cx">  * specific URL is caught. They will first save or manipulate data using business
</span><span class="cx">  * functions, then pass on the user to a template file.
</span><ins>+ *
+ * @package BuddyPress
+ * @subpackage FriendsScreens
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> // Exit if accessed directly
</span><span class="lines">@@ -52,14 +58,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function friends_screen_notification_settings() {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
</span><span class="cx">                 $send_requests   = 'yes';
</span><span class="cx"> 
</span><span class="cx">         if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
</span><del>-                $accept_requests = 'yes';
-?&gt;
</del><ins>+                $accept_requests = 'yes'; ?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;table class=&quot;notification-settings&quot; id=&quot;friends-notification-settings&quot;&gt;
</span><span class="cx">                 &lt;thead&gt;
</span><span class="lines">@@ -94,4 +98,4 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkbpfriendsbpfriendstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-template.php (5711 => 5712)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-template.php        2012-02-11 04:36:07 UTC (rev 5711)
+++ trunk/bp-friends/bp-friends-template.php        2012-02-11 04:42:04 UTC (rev 5712)
</span><span class="lines">@@ -1,4 +1,12 @@
</span><span class="cx"> &lt;?php
</span><ins>+
+/**
+ * BuddyPress Friends Template Functions
+ *
+ * @package BuddyPress
+ * @subpackage FriendsTemplate
+ */
+
</ins><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="lines">@@ -57,7 +65,7 @@
</span><span class="cx">  * @todo Deprecate?
</span><span class="cx">  */
</span><span class="cx"> function bp_friends_header_tabs() {
</span><del>-        global $bp; ?&gt;
</del><ins>+?&gt;
</ins><span class="cx"> 
</span><span class="cx">         &lt;li&lt;?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?&gt; class=&quot;current&quot;&lt;?php endif; ?&gt;&gt;&lt;a href=&quot;&lt;?php echo trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/recently-active' ) ?&gt;&quot;&gt;&lt;?php _e( 'Recently Active', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/li&gt;
</span><span class="cx">         &lt;li&lt;?php if ( bp_is_action_variable( 'newest', 0 ) ) : ?&gt; class=&quot;current&quot;&lt;?php endif; ?&gt;&gt;&lt;a href=&quot;&lt;?php echo trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/newest' ) ?&gt;&quot;&gt;&lt;?php _e( 'Newest', 'buddypress' ) ?&gt;&lt;/a&gt;&lt;/li&gt;
</span><span class="lines">@@ -90,7 +98,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_friends_random_friends() {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) {
</span><span class="cx">                 $friend_ids = BP_Friends_Friendship::get_random_friends( bp_displayed_user_id() );
</span><span class="lines">@@ -122,8 +129,10 @@
</span><span class="cx">                         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;?php } ?&gt;
</span><ins>+
</ins><span class="cx">                 &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
</span><span class="cx">         &lt;/div&gt;
</span><ins>+
</ins><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -137,7 +146,6 @@
</span><span class="cx">  * @param int $total_members The number of members to retrieve
</span><span class="cx">  */
</span><span class="cx"> function bp_friends_random_members( $total_members = 5 ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
</span><span class="cx">                 $user_ids = BP_Core_User::get_users( 'random', $total_members );
</span><span class="lines">@@ -195,10 +203,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_friend_search_form() {
</span><del>-        global $friends_template, $bp;
</del><span class="cx"> 
</span><span class="cx">         $action = bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/search/';
</span><del>-        $label = __( 'Filter Friends', 'buddypress' ); ?&gt;
</del><ins>+        $label  = __( 'Filter Friends', 'buddypress' ); ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                 &lt;form action=&quot;&lt;?php echo $action ?&gt;&quot; id=&quot;friend-search-form&quot; method=&quot;post&quot;&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -227,8 +234,6 @@
</span><span class="cx"> add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
</span><span class="cx"> 
</span><span class="cx"> function bp_member_total_friend_count() {
</span><del>-        global $members_template;
-
</del><span class="cx">         echo bp_get_member_total_friend_count();
</span><span class="cx"> }
</span><span class="cx">         function bp_get_member_total_friend_count() {
</span><span class="lines">@@ -256,13 +261,12 @@
</span><span class="cx">          *
</span><span class="cx">          * Returns the ID of the potential friend
</span><span class="cx">          *
</span><del>-         * @global object $bp
</del><span class="cx">          * @global object $friends_template
</span><span class="cx">          * @param int $user_id
</span><span class="cx">          * @return int ID of potential friend
</span><span class="cx">          */
</span><span class="cx">         function bp_get_potential_friend_id( $user_id = 0 ) {
</span><del>-                global $bp, $friends_template;
</del><ins>+                global $friends_template;
</ins><span class="cx"> 
</span><span class="cx">                 if ( empty( $user_id ) &amp;&amp; isset( $friends_template-&gt;friendship-&gt;friend ) )
</span><span class="cx">                         $user_id = $friends_template-&gt;friendship-&gt;friend-&gt;id;
</span><span class="lines">@@ -277,12 +281,10 @@
</span><span class="cx">  *
</span><span class="cx">  * Returns - 'is_friend', 'not_friends', 'pending'
</span><span class="cx">  *
</span><del>- * @global object $bp
</del><span class="cx">  * @param int $potential_friend_id
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function bp_is_friend( $user_id = 0 ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><span class="cx">         if ( !is_user_logged_in() )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -300,7 +302,6 @@
</span><span class="cx">         echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
</span><span class="cx"> }
</span><span class="cx">         function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
</span><del>-                global $bp, $friends_template;
</del><span class="cx"> 
</span><span class="cx">                 if ( empty( $potential_friend_id ) )
</span><span class="cx">                         $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id );
</span><span class="lines">@@ -366,9 +367,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_get_friend_ids( $user_id = 0 ) {
</span><del>-        global $bp;
</del><span class="cx"> 
</span><del>-        if ( !$user_id )
</del><ins>+        if ( empty( $user_id ) )
</ins><span class="cx">                 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
</span><span class="cx"> 
</span><span class="cx">         $friend_ids = friends_get_friend_user_ids( $user_id );
</span><span class="lines">@@ -379,8 +379,6 @@
</span><span class="cx">         return implode( ',', friends_get_friend_user_ids( $user_id ) );
</span><span class="cx"> }
</span><span class="cx"> function bp_get_friendship_requests() {
</span><del>-        global $bp;
-
</del><span class="cx">         return apply_filters( 'bp_get_friendship_requests', implode( ',', (array) friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -388,7 +386,7 @@
</span><span class="cx">         echo bp_get_friend_friendship_id();
</span><span class="cx"> }
</span><span class="cx">         function bp_get_friend_friendship_id() {
</span><del>-                global $members_template, $bp;
</del><ins>+                global $members_template;
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template-&gt;member-&gt;id . '_' . bp_loggedin_user_id() ) ) {
</span><span class="cx">                         $friendship_id = friends_get_friendship_id( $members_template-&gt;member-&gt;id, bp_loggedin_user_id() );
</span><span class="lines">@@ -402,7 +400,7 @@
</span><span class="cx">         echo bp_get_friend_accept_request_link();
</span><span class="cx"> }
</span><span class="cx">         function bp_get_friend_accept_request_link() {
</span><del>-                global $members_template, $bp;
</del><ins>+                global $members_template;
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template-&gt;member-&gt;id . '_' . bp_loggedin_user_id() ) ) {
</span><span class="cx">                         $friendship_id = friends_get_friendship_id( $members_template-&gt;member-&gt;id, bp_loggedin_user_id() );
</span><span class="lines">@@ -416,7 +414,7 @@
</span><span class="cx">         echo bp_get_friend_reject_request_link();
</span><span class="cx"> }
</span><span class="cx">         function bp_get_friend_reject_request_link() {
</span><del>-                global $members_template, $bp;
</del><ins>+                global $members_template;
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template-&gt;member-&gt;id . '_' . bp_loggedin_user_id() ) ) {
</span><span class="cx">                         $friendship_id = friends_get_friendship_id( $members_template-&gt;member-&gt;id, bp_loggedin_user_id() );
</span><span class="lines">@@ -438,12 +436,10 @@
</span><span class="cx">         echo bp_friend_get_total_requests_count( $user_id );
</span><span class="cx"> }
</span><span class="cx">         function bp_friend_get_total_requests_count( $user_id = 0 ) {
</span><del>-                global $bp;
-
</del><span class="cx">                 if ( empty( $user_id ) )
</span><span class="cx">                         $user_id = bp_loggedin_user_id();
</span><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>