<!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][4462] trunk/bp-core: Add some tasty phpdoc.</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>4462</dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-06-05 20:26:32 +0000 (Sun, 05 Jun 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add some tasty phpdoc. Props Backie, see #2345</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreavatarsphp">trunk/bp-core/bp-core-avatars.php</a></li>
<li><a href="#trunkbpcorebpcoreclassesphp">trunk/bp-core/bp-core-classes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreavatarsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-avatars.php (4461 => 4462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-avatars.php        2011-06-05 10:42:22 UTC (rev 4461)
+++ trunk/bp-core/bp-core-avatars.php        2011-06-05 20:26:32 UTC (rev 4462)
</span><span class="lines">@@ -278,6 +278,18 @@
</span><span class="cx">                 return apply_filters( 'bp_core_fetch_avatar_url', $gravatar );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Delete an existing avatar
+ *
+ * Accepted values for $args are:
+ *  item_id - item id which relates to the object type.
+ *  object - the objetc type user, group, blog, etc.
+ *  avatar_dir - The directory where the avatars to be uploaded.
+ *
+ * @global object $bp BuddyPress global settings
+ * @param mixed $args
+ * @return bool Success/failure
+ */
</ins><span class="cx"> function bp_core_delete_existing_avatar( $args = '' ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -336,6 +348,20 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Handles avatar uploading.
+ *
+ * The functions starts off by checking that the file has been uploaded properly using bp_core_check_avatar_upload().
+ * It then checks that the file size is within limits, and that it has an accepted file extension (jpg, gif, png).
+ * If everything checks out, crop the image and move it to its real location.
+ *
+ * @global object $bp BuddyPress global settings
+ * @param array $file The appropriate entry the from $_FILES superglobal.
+ * @param string $upload_dir_filter A filter to be applied to upload_dir
+ * @return bool Success/failure
+ * @see bp_core_check_avatar_upload()
+ * @see bp_core_check_avatar_type()
+ */
</ins><span class="cx"> function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -421,6 +447,23 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Crop an uploaded avatar
+ *
+ * $args has the following parameters:
+ *  object - What component the avatar is for, e.g. &quot;user&quot;
+ *  avatar_dir  The absolute path to the avatar
+ *  item_id - Item ID
+ *  original_file - The absolute path to the original avatar file
+ *  crop_w - Crop width
+ *  crop_h - Crop height
+ *  crop_x - The horizontal starting point of the crop
+ *  crop_y - The vertical starting point of the crop
+ *
+ * @global object $bp BuddyPress global settings
+ * @param mixed $args
+ * @return bool Success/failure
+ */
</ins><span class="cx"> function bp_core_avatar_handle_crop( $args = '' ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -537,20 +580,40 @@
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
</span><span class="cx"> 
</span><del>-function bp_core_check_avatar_upload($file) {
</del><ins>+/**
+ * Has the current avatar upload generated an error?
+ *
+ * @param array $file
+ * @return bool
+ */
+function bp_core_check_avatar_upload( $file ) {
</ins><span class="cx">         if ( isset( $file['error'] ) &amp;&amp; $file['error'] )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function bp_core_check_avatar_size($file) {
</del><ins>+/**
+ * Is the file size of the current avatar upload permitted?
+ *
+ * @param array $file
+ * @return bool
+ */
+function bp_core_check_avatar_size( $file ) {
</ins><span class="cx">         if ( $file['file']['size'] &gt; BP_AVATAR_ORIGINAL_MAX_FILESIZE )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Does the current avatar upload have an allowed file type?
+ *
+ * Permitted file types are JPG, GIF and PNG.
+ *
+ * @param string $file
+ * @return bool
+ */
</ins><span class="cx"> function bp_core_check_avatar_type($file) {
</span><span class="cx">         if ( ( !empty( $file['file']['type'] ) &amp;&amp; !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="trunkbpcorebpcoreclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-classes.php (4461 => 4462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-classes.php        2011-06-05 10:42:22 UTC (rev 4461)
+++ trunk/bp-core/bp-core-classes.php        2011-06-05 20:26:32 UTC (rev 4462)
</span><span class="lines">@@ -13,28 +13,113 @@
</span><span class="cx">  * @package BuddyPress Core
</span><span class="cx">  */
</span><span class="cx"> class BP_Core_User {
</span><ins>+
+        /**
+         * ID of the user which the object relates to.
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $id;
</span><ins>+
+        /**
+         * The URL to the full size of the avatar for the user.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $avatar;
</span><ins>+
+        /**
+         * The URL to the thumb size of the avatar for the user.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $avatar_thumb;
</span><ins>+
+        /**
+         * The URL to the mini size of the avatar for the user.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $avatar_mini;
</span><ins>+
+        /**
+         * The full name of the user
+         *
+         * @var string
+         */
</ins><span class="cx">         var $fullname;
</span><ins>+
+        /**
+         * The email for the user.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $email;
</span><span class="cx"> 
</span><ins>+        /**
+         * The absolute url for the user's profile.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $user_url;
</span><ins>+
+        /**
+         * The HTML for the user link, with the link text being the user's full name.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $user_link;
</span><span class="cx"> 
</span><ins>+        /**
+         * Contains a formatted string when the last time the user was active.
+         *
+         * Example: &quot;active 2 hours and 50 minutes ago&quot;
+         *
+         * @var string
+         */
</ins><span class="cx">         var $last_active;
</span><span class="cx"> 
</span><span class="cx">         /* Extras */
</span><ins>+
+        /**
+         * The total number of &quot;Friends&quot; the user has on site.
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $total_friends;
</span><ins>+
+        /**
+         * The total number of blog posts posted by the user
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $total_blogs;
</span><ins>+
+        /**
+         * The total number of groups the user is a part of.
+         *
+         * Example: &quot;1 group&quot;, &quot;2 groups&quot;
+         *
+         * @var string
+         */
</ins><span class="cx">         var $total_groups;
</span><span class="cx"> 
</span><ins>+        /**
+         * PHP4 constructor.
+         *
+         * @see BP_Core_User::__construct()
+         */
</ins><span class="cx">         function bp_core_user( $user_id, $populate_extras = false ) {
</span><span class="cx">                 $this-&gt;__construct( $user_id, $populate_extras );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-                function __construct( $user_id, $populate_extras = false ) {
</del><ins>+        /**
+         * Class constructor.
+         *
+         * @param integer $user_id The ID for the user
+         * @param boolean $populate_extras Whether to fetch extra information such as group/friendship counts or not.
+         */
+        function __construct( $user_id, $populate_extras = false ) {
</ins><span class="cx">                 if ( $user_id ) {
</span><span class="cx">                         $this-&gt;id = $user_id;
</span><span class="cx">                         $this-&gt;populate();
</span><span class="lines">@@ -45,12 +130,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><del>-         * populate()
-         *
</del><span class="cx">          * Populate the instantiated class with data based on the User ID provided.
</span><span class="cx">          *
</span><del>-         * @package BuddyPress Core
-          * @global $userdata WordPress user data for the current logged in user.
</del><ins>+         * @global object $bp Global BuddyPress settings object
</ins><span class="cx">          * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
</span><span class="cx">          * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
</span><span class="cx">          * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
</span><span class="lines">@@ -60,7 +142,7 @@
</span><span class="cx">          */
</span><span class="cx">         function populate() {
</span><span class="cx">                 global $bp;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( bp_is_active( 'xprofile' ) )
</span><span class="cx">                         $this-&gt;profile_data = $this-&gt;get_profile_data();
</span><span class="cx"> 
</span><span class="lines">@@ -87,6 +169,11 @@
</span><span class="cx">                 $this-&gt;last_active  = bp_core_get_last_activity( get_user_meta( $this-&gt;id, bp_get_user_meta_key( 'last_activity' ), true ), __( 'active %s ago', 'buddypress' ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Populates extra fields such as group and friendship counts.
+         *
+         * @global object $bp Global BuddyPress settings object
+         */
</ins><span class="cx">         function populate_extras() {
</span><span class="cx">                 global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -95,13 +182,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( bp_is_active( 'groups' ) ) {
</span><span class="cx">                         $this-&gt;total_groups = BP_Groups_Member::total_group_count( $this-&gt;id );
</span><del>-
-                        if ( $this-&gt;total_groups ) {
-                                if ( 1 == $this-&gt;total_groups )
-                                        $this-&gt;total_groups .= ' ' . __( 'group', 'buddypress' );
-                                else
-                                        $this-&gt;total_groups .= ' ' . __( 'groups', 'buddypress' );
-                        }
</del><ins>+                        $this-&gt;total_groups = sprintf( _n( '%d group', '%d groups', $this-&gt;total_groups ), $this-&gt;total_groups );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -126,10 +207,10 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( 'alphabetical' == $type )
</span><span class="cx">                         $sql['select_alpha'] = &quot;, pd.value as fullname&quot;;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( $meta_key ) {
</span><span class="cx">                         $sql['select_meta'] = &quot;, umm.meta_key&quot;;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ( $meta_value )
</span><span class="cx">                                 $sql['select_meta'] .= &quot;, umm.meta_value&quot;;
</span><span class="cx">                 }
</span><span class="lines">@@ -138,7 +219,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( $search_terms &amp;&amp; bp_is_active( 'xprofile' ) || 'alphabetical' == $type )
</span><span class="cx">                         $sql['join_profiledata'] = &quot;LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id&quot;;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 if ( $meta_key )
</span><span class="cx">                         $sql['join_meta'] = &quot;LEFT JOIN {$wpdb-&gt;usermeta} umm ON umm.user_id = u.ID&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -186,10 +267,10 @@
</span><span class="cx">                         $search_terms             = like_escape( $wpdb-&gt;escape( $search_terms ) );
</span><span class="cx">                         $sql['where_searchterms'] = &quot;AND pd.value LIKE '%%$search_terms%%'&quot;;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ( $meta_key ) {
</span><span class="cx">                         $sql['where_meta'] = $wpdb-&gt;prepare( &quot; AND umm.meta_key = %s&quot;, $meta_key );
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         // If a meta value is provided, match it
</span><span class="cx">                         if ( $meta_value ) {
</span><span class="cx">                                 $sql['where_meta'] .= $wpdb-&gt;prepare( &quot; AND umm.meta_value = %s&quot;, $meta_value );
</span><span class="lines">@@ -261,9 +342,23 @@
</span><span class="cx">                 return array( 'users' =&gt; $paged_users, 'total' =&gt; $total_users );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = false ) {
-                global $wpdb, $bp;
</del><span class="cx"> 
</span><ins>+        /**
+         * Fetches the user details for all the users who username starts with the letter given.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param string $letter The letter the users names are to start with.
+         * @param integer $limit The number of users we wish to retrive.
+         * @param integer $page The page number we are currently on, used in conjunction with $limit to get the start position for the limit.
+         * @param boolean $populate_extras Populate extra user fields?
+         * @param string $exclude Comma-separated IDs of users whose results aren't to be fetched.
+         * @return mixed False on error, otherwise associative array of results.
+         * @static
+         */
+        function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = '' ) {
+                global $bp, $wpdb;
+
</ins><span class="cx">                 $pag_sql = '';
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="lines">@@ -307,8 +402,20 @@
</span><span class="cx">                 return array( 'users' =&gt; $paged_users, 'total' =&gt; $total_users );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Get details of specific users from the database
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param array $user_ids The user IDs of the users who we wish to fetch information on.
+         * @param integer $limit The limit of results we want.
+         * @param integer $page The page we are on for pagination.
+         * @param boolean $populate_extras Populate extra user fields?
+         * @return array Associative array
+         * @static
+         */
</ins><span class="cx">         function get_specific_users( $user_ids, $limit = null, $page = 1, $populate_extras = true ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 $pag_sql = '';
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="lines">@@ -335,8 +442,20 @@
</span><span class="cx">                 return array( 'users' =&gt; $paged_users, 'total' =&gt; $total_users );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Find users who match on the value of an xprofile data.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param string $search_terms The terms to search the profile table value column for.
+         * @param integer $limit The limit of results we want.
+         * @param integer $page The page we are on for pagination.
+         * @param boolean $populate_extras Populate extra user fields?
+         * @return array Associative array
+         * @static
+         */
</ins><span class="cx">         function search_users( $search_terms, $limit = null, $page = 1, $populate_extras = true ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="lines">@@ -366,6 +485,19 @@
</span><span class="cx">                 return array( 'users' =&gt; $paged_users, 'total' =&gt; $total_users );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Fetch extra user information, such as friend count and last profile update message.
+         *
+         * Accepts multiple user IDs to fetch data for.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param array $paged_users an array of stdClass containing the users
+         * @param string $user_ids the user ids to select information about
+         * @param string $type the type of fields we wish to get
+         * @return mixed False on error, otherwise associative array of results.
+         * @static
+         */
</ins><span class="cx">         function get_user_extras( &amp;$paged_users, &amp;$user_ids, $type = false ) {
</span><span class="cx">                 global $bp, $wpdb;
</span><span class="cx"> 
</span><span class="lines">@@ -438,6 +570,14 @@
</span><span class="cx">                 return $paged_users;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Get WordPress user details for a specified user.
+         *
+         * @global wpdb $wpdb WordPress database object
+         * @param integer $user_id User ID
+         * @return array Associative array
+         * @static
+         */
</ins><span class="cx">         function get_core_userdata( $user_id ) {
</span><span class="cx">                 global $wpdb;
</span><span class="cx"> 
</span><span class="lines">@@ -457,28 +597,93 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> class BP_Core_Notification {
</span><ins>+
+        /**
+         * The notification id
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $id;
</span><ins>+
+        /**
+         * The ID to which the notification relates to within the component.
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $item_id;
</span><ins>+
+        /**
+         * The secondary ID to which the notification relates to within the component.
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $secondary_item_id = null;
</span><ins>+
+        /**
+         * The user ID for who the notification is for.
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $user_id;
</span><ins>+
+        /**
+         * The name of the component that the notification is for.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $component_name;
</span><ins>+
+        /**
+         * The action within the component which the notification is related to.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $component_action;
</span><ins>+
+        /**
+         * The date the notification was created.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $date_notified;
</span><ins>+
+        /**
+         * Is the notification new or has it already been read.
+         *
+         * @var boolean
+         */
</ins><span class="cx">         var $is_new;
</span><span class="cx"> 
</span><del>-        function bp_core_notification( $id = false ) {
</del><ins>+
+        /**
+         * PHP4 constructor
+         *
+         * @param integer $id
+         */
+        function bp_core_notification( $id = 0 ) {
</ins><span class="cx">                 $this-&gt;__construct($id);
</span><span class="cx">         }
</span><del>-                
-        function __construct( $id = false ) {
</del><ins>+
+        /**
+         * Constructor
+         *
+         * @param integer $id
+         */
+        function __construct( $id = 0 ) {
</ins><span class="cx">                 if ( $id ) {
</span><span class="cx">                         $this-&gt;id = $id;
</span><span class="cx">                         $this-&gt;populate();
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Fetches the notification data from the database.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         */
</ins><span class="cx">         function populate() {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 if ( $notification = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE id = %d&quot;, $this-&gt;id ) ) ) {
</span><span class="cx">                         $this-&gt;item_id = $notification-&gt;item_id;
</span><span class="lines">@@ -491,8 +696,15 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Update or insert notification details into the database.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @return bool Success or failure
+         */
</ins><span class="cx">         function save() {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 // Update
</span><span class="cx">                 if ( $this-&gt;id )
</span><span class="lines">@@ -517,34 +729,86 @@
</span><span class="cx">                 return $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT COUNT(id) FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE id = %d AND user_id = %d&quot;, $notification_id, $user_id ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Fetches all the notifications in the database for a specific user.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param integer $user_id User ID
+         * @return array Associative array
+         * @static
+         */
</ins><span class="cx">         function get_all_for_user( $user_id ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                  return $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE user_id = %d AND is_new = 1&quot;, $user_id ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Delete all the notifications for a user based on the component name and action.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param integer $user_id
+         * @param string $component_name
+         * @param string $component_action
+         * @static
+         */
</ins><span class="cx">         function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s&quot;, $user_id, $component_name, $component_action ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Delete all the notifications that have a specific item id, component name and action.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param integer $user_id The ID of the user who the notifications are for.
+         * @param integer $item_id The item ID of the notifications we wish to delete.
+         * @param string $component_name The name of the component that the notifications we wish to delete.
+         * @param string $component_action The action of the component that the notifications we wish to delete.
+         * @param integer $secondary_item_id (optional) The secondary item id of the notifications that we wish to use to delete.
+         * @static
+         */
</ins><span class="cx">         function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb-&gt;prepare( &quot; AND secondary_item_id = %d&quot;, $secondary_item_id ) : '';
</span><span class="cx"> 
</span><span class="cx">                 return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}&quot;, $user_id, $item_id, $component_name, $component_action ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Deletes all the notifications sent by a specific user, by component and action.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param integer $user_id The ID of the user whose sent notifications we wish to delete.
+         * @param string $component_name The name of the component the notification was sent from.
+         * @param string $component_action The action of the component the notification was sent from.
+         * @static
+         */
</ins><span class="cx">         function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;core-&gt;table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s&quot;, $user_id, $component_name, $component_action ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Deletes all the notifications for all users by item id, and optional secondary item id, and component name and action.
+         *
+         * @global object $bp Global BuddyPress settings object
+         * @global wpdb $wpdb WordPress database object
+         * @param string $item_id The item id that they notifications are to be for.
+         * @param string $component_name The component that the notifications are to be from.
+         * @param string $component_action The action that the notificationsa are to be from.
+         * @param string $secondary_item_id Optional secondary item id that the notifications are to have.
+         * @static
+         */
</ins><span class="cx">         function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
</span><del>-                global $wpdb, $bp;
</del><ins>+                global $bp, $wpdb;
</ins><span class="cx"> 
</span><span class="cx">                 if ( $component_action )
</span><span class="cx">                         $component_action_sql = $wpdb-&gt;prepare( &quot;AND component_action = %s&quot;, $component_action );
</span><span class="lines">@@ -569,27 +833,109 @@
</span><span class="cx">  * @since 1.2.6
</span><span class="cx">  */
</span><span class="cx"> class BP_Button {
</span><ins>+        // Button properties
</ins><span class="cx"> 
</span><del>-        // Button properties
</del><ins>+        /**
+         * The button ID
+         *
+         * @var integer
+         */
</ins><span class="cx">         var $id;
</span><ins>+
+        /**
+         * The component name that button belongs to.
+         *
+         * @var string
+         */
</ins><span class="cx">         var $component;
</span><ins>+
+        /**
+         * Does the user need to be logged in to see this button?
+         *
+         * @var boolean
+         */
</ins><span class="cx">         var $must_be_logged_in;
</span><ins>+
+        /**
+         * True or false if the button should not be displayed while viewing your own profile.
+         *
+         * @var boolean
+         */
</ins><span class="cx">         var $block_self;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">         // Wrapper
</span><ins>+
+        /**
+         * What type of DOM element to use for a wrapper.
+         *
+         *
+         * @var mixed div|span|p|li, or false for no wrapper
+         */
</ins><span class="cx">         var $wrapper;
</span><ins>+
+        /**
+         * The DOM class of the button wrapper
+         *
+         * @var string
+         */
</ins><span class="cx">         var $wrapper_class;
</span><ins>+
+        /**
+         * The DOM ID of the button wrapper
+         *
+         * @var string
+         */
</ins><span class="cx">         var $wrapper_id;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">         // Button
</span><ins>+
+        /**
+         * The destination link of the button
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_href;
</span><ins>+
+        /**
+         * The DOM class of the button link
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_class;
</span><ins>+
+        /**
+         * The DOM ID of the button link
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_id;
</span><ins>+
+        /**
+         * The DOM rel value of the button link
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_rel;
</span><ins>+
+        /**
+         * Title of the button link
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_title;
</span><ins>+
+        /**
+         * The contents of the button link
+         *
+         * @var string
+         */
</ins><span class="cx">         var $link_text;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">         // HTML result
</span><ins>+
</ins><span class="cx">         var $contents;
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -616,7 +962,7 @@
</span><span class="cx">         function bp_button( $args = '' ) {
</span><span class="cx">                 $this-&gt;__construct($args);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function __construct( $args = '' ) {
</span><span class="cx"> 
</span><span class="cx">                 // Default arguments
</span></span></pre>
</div>
</div>

</body>
</html>