<!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][8711] trunk/src/bp-activity/bp-activity-functions.php: A bit more clean up in `bp-activity-functions.php`.</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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/8711">8711</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2014-07-29 13:28:41 +0000 (Tue, 29 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>A bit more clean up in `bp-activity-functions.php`.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityfunctionsphp">trunk/src/bp-activity/bp-activity-functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/bp-activity/bp-activity-functions.php (8710 => 8711)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/bp-activity/bp-activity-functions.php  2014-07-29 13:24:17 UTC (rev 8710)
+++ trunk/src/bp-activity/bp-activity-functions.php     2014-07-29 13:28:41 UTC (rev 8711)
</span><span class="lines">@@ -17,14 +17,10 @@
</span><span class="cx">  *
</span><span class="cx">  * @since BuddyPress (1.5.0)
</span><span class="cx">  *
</span><del>- * @global object $bp BuddyPress global settings
- *
</del><span class="cx">  * @return bool True if activity directory page is found, otherwise false.
</span><span class="cx">  */
</span><span class="cx"> function bp_activity_has_directory() {
</span><del>-       global $bp;
-
-       return (bool) !empty( $bp->pages->activity->id );
</del><ins>+        return (bool) !empty( buddypress()->pages->activity->id );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -78,12 +74,12 @@
</span><span class="cx">  $mentioned_users = array();
</span><span class="cx"> 
</span><span class="cx">  // We've found some mentions! Check to see if users exist
</span><del>-       foreach( (array) $usernames as $key => $username ) {
</del><ins>+        foreach( (array) array_values( $usernames ) as $username ) {
</ins><span class="cx">           $user_id = bp_activity_get_userid_from_mentionname( $username );
</span><span class="cx"> 
</span><span class="cx">          // user ID exists, so let's add it to our array
</span><span class="cx">          if ( ! empty( $user_id ) ) {
</span><del>-                       $mentioned_users[$user_id] = $username;
</del><ins>+                        $mentioned_users[ $user_id ] = $username;
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -143,7 +139,7 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  // Increment mention count foreach mentioned user
</span><del>-       foreach( (array) $usernames as $user_id => $username ) {
</del><ins>+        foreach( (array) array_keys( $usernames ) as $user_id ) {
</ins><span class="cx">           bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
</span><span class="cx">  }
</span><span class="cx"> }
</span><span class="lines">@@ -1201,13 +1197,16 @@
</span><span class="cx">  $activity->date_recorded     = $r['recorded_time'];
</span><span class="cx">  $activity->hide_sitewide     = $r['hide_sitewide'];
</span><span class="cx">  $activity->is_spam           = $r['is_spam'];
</span><del>-       $activity->action            = ! empty( $r['action'] ) ? $r['action'] : bp_activity_generate_action_string( $activity );
</del><ins>+        $activity->action            = ! empty( $r['action'] )
+                                                                               ? $r['action']
+                                                                               : bp_activity_generate_action_string( $activity );
</ins><span class="cx"> 
</span><del>-       if ( !$activity->save() )
</del><ins>+        if ( ! $activity->save() ) {
</ins><span class="cx">           return false;
</span><ins>+       }
</ins><span class="cx"> 
</span><span class="cx">  // If this is an activity comment, rebuild the tree
</span><del>-       if ( 'activity_comment' == $activity->type ) {
</del><ins>+        if ( 'activity_comment' === $activity->type ) {
</ins><span class="cx">           BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -1626,14 +1625,24 @@
</span><span class="cx">   *        comment's oldest ancestor.
</span><span class="cx">   * @param int $comment_id The ID of the comment to be deleted.
</span><span class="cx">   */
</span><del>-       function bp_activity_delete_children( $activity_id, $comment_id) {
</del><ins>+        function bp_activity_delete_children( $activity_id, $comment_id ) {
+
+               // Get activity children to delete
+               $children = BP_Activity_Activity::get_child_comments( $comment_id );
+
</ins><span class="cx">           // Recursively delete all children of this comment.
</span><del>-               if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
</del><ins>+                if ( ! empty( $children ) ) {
</ins><span class="cx">                   foreach( (array) $children as $child ) {
</span><span class="cx">                          bp_activity_delete_children( $activity_id, $child->id );
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-               bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
</del><ins>+                
+               // Delete the comment itself
+               bp_activity_delete( array(
+                       'secondary_item_id' => $comment_id,
+                       'type'              => 'activity_comment',
+                       'item_id'           => $activity_id
+               ) );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1709,7 +1718,7 @@
</span><span class="cx">  * @param string $content The content of the activity item.
</span><span class="cx">  * @param string $link Optional. The unescaped URL that the image should link
</span><span class="cx">  *        to. If absent, the image will not be a link.
</span><del>- * @param array $activity_args Optional. The args passed to the activity
</del><ins>+ * @param array $args Optional. The args passed to the activity
</ins><span class="cx">  *        creation function (eg bp_blogs_record_activity()).
</span><span class="cx">  * @return string $content The content with images stripped and replaced with a
</span><span class="cx">  *         single thumb.
</span><span class="lines">@@ -1722,6 +1731,7 @@
</span><span class="cx">  $content = preg_replace('|(\[caption(.*?)\])?<img[^>]*>([^\[\[]*\[\/caption\])?|', '', $content );
</span><span class="cx"> 
</span><span class="cx">  if ( !empty( $matches ) && !empty( $matches[0] ) ) {
</span><ins>+
</ins><span class="cx">           // Get the SRC value
</span><span class="cx">          preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>