Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/29/2014 01:28:41 PM (10 years ago)
Author:
johnjamesjacoby
Message:

A bit more clean up in bp-activity-functions.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-functions.php

    r8710 r8711  
    1818 * @since BuddyPress (1.5.0)
    1919 *
    20  * @global object $bp BuddyPress global settings
    21  *
    2220 * @return bool True if activity directory page is found, otherwise false.
    2321 */
    2422function bp_activity_has_directory() {
    25     global $bp;
    26 
    27     return (bool) !empty( $bp->pages->activity->id );
     23    return (bool) !empty( buddypress()->pages->activity->id );
    2824}
    2925
     
    7975
    8076    // We've found some mentions! Check to see if users exist
    81     foreach( (array) $usernames as $key => $username ) {
     77    foreach( (array) array_values( $usernames ) as $username ) {
    8278        $user_id = bp_activity_get_userid_from_mentionname( $username );
    8379
    8480        // user ID exists, so let's add it to our array
    8581        if ( ! empty( $user_id ) ) {
    86             $mentioned_users[$user_id] = $username;
     82            $mentioned_users[ $user_id ] = $username;
    8783        }
    8884    }
     
    144140
    145141    // Increment mention count foreach mentioned user
    146     foreach( (array) $usernames as $user_id => $username ) {
     142    foreach( (array) array_keys( $usernames ) as $user_id ) {
    147143        bp_activity_update_mention_count_for_user( $user_id, $activity_id, $action );
    148144    }
     
    12021198    $activity->hide_sitewide     = $r['hide_sitewide'];
    12031199    $activity->is_spam           = $r['is_spam'];
    1204     $activity->action            = ! empty( $r['action'] ) ? $r['action'] : bp_activity_generate_action_string( $activity );
    1205 
    1206     if ( !$activity->save() )
    1207         return false;
     1200    $activity->action            = ! empty( $r['action'] )
     1201                                        ? $r['action']
     1202                                        : bp_activity_generate_action_string( $activity );
     1203
     1204    if ( ! $activity->save() ) {
     1205        return false;
     1206    }
    12081207
    12091208    // If this is an activity comment, rebuild the tree
    1210     if ( 'activity_comment' == $activity->type ) {
     1209    if ( 'activity_comment' === $activity->type ) {
    12111210        BP_Activity_Activity::rebuild_activity_comment_tree( $activity->item_id );
    12121211    }
     
    16271626     * @param int $comment_id The ID of the comment to be deleted.
    16281627     */
    1629     function bp_activity_delete_children( $activity_id, $comment_id) {
     1628    function bp_activity_delete_children( $activity_id, $comment_id ) {
     1629
     1630        // Get activity children to delete
     1631        $children = BP_Activity_Activity::get_child_comments( $comment_id );
     1632
    16301633        // Recursively delete all children of this comment.
    1631         if ( $children = BP_Activity_Activity::get_child_comments( $comment_id ) ) {
     1634        if ( ! empty( $children ) ) {
    16321635            foreach( (array) $children as $child ) {
    16331636                bp_activity_delete_children( $activity_id, $child->id );
    16341637            }
    16351638        }
    1636         bp_activity_delete( array( 'secondary_item_id' => $comment_id, 'type' => 'activity_comment', 'item_id' => $activity_id ) );
     1639       
     1640        // Delete the comment itself
     1641        bp_activity_delete( array(
     1642            'secondary_item_id' => $comment_id,
     1643            'type'              => 'activity_comment',
     1644            'item_id'           => $activity_id
     1645        ) );
    16371646    }
    16381647
     
    17101719 * @param string $link Optional. The unescaped URL that the image should link
    17111720 *        to. If absent, the image will not be a link.
    1712  * @param array $activity_args Optional. The args passed to the activity
     1721 * @param array $args Optional. The args passed to the activity
    17131722 *        creation function (eg bp_blogs_record_activity()).
    17141723 * @return string $content The content with images stripped and replaced with a
     
    17231732
    17241733    if ( !empty( $matches ) && !empty( $matches[0] ) ) {
     1734
    17251735        // Get the SRC value
    17261736        preg_match( '/<img.*?(src\=[\'|"]{0,1}.*?[\'|"]{0,1})[\s|>]{1}/i', $matches[0][0], $src );
Note: See TracChangeset for help on using the changeset viewer.