Skip to:
Content

BuddyPress.org

Changeset 2381 for trunk/bp-groups.php


Ignore:
Timestamp:
01/20/2010 04:21:20 PM (16 years ago)
Author:
apeatling
Message:

Standardizing activity stream fields and splitting the action from the content for better manageability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2352 r2381  
    306306
    307307            groups_record_activity( array(
    308                 'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
    309                 'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ),
    310                 'component_action' => 'joined_group',
     308                'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
     309                'type' => 'joined_group',
    311310                'item_id' => $group->id
    312311            ) );
     
    11551154            /* Once we compelete all steps, record the group creation in the activity stream. */
    11561155            groups_record_activity( array(
    1157                 'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
    1158                 'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    1159                 'component_action' => 'created_group',
     1156                'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
     1157                'type' => 'created_group',
    11601158                'item_id' => $bp->groups->new_group_id
    11611159            ) );
     
    13211319    $defaults = array(
    13221320        'user_id' => $bp->loggedin_user->id,
    1323         'content' => false,
    1324         'primary_link' => false,
    1325         'component_name' => $bp->groups->id,
    1326         'component_action' => false,
     1321        'action' => '',
     1322        'content' => '',
     1323        'primary_link' => '',
     1324        'component' => $bp->groups->id,
     1325        'type' => false,
    13271326        'item_id' => false,
    13281327        'secondary_item_id' => false,
     
    13341333    extract( $r, EXTR_SKIP );
    13351334
    1336     return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
     1335    return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    13371336}
    13381337
     
    16021601    /* Delete all group activity from activity streams */
    16031602    if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
    1604         bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->id ) );
     1603        bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component' => $bp->groups->id ) );
    16051604    }
    16061605
     
    17021701    /* Record this in activity streams */
    17031702    groups_record_activity( array(
    1704         'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
    1705         'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    1706         'component_action' => 'joined_group',
     1703        'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
     1704        'type' => 'joined_group',
    17071705        'item_id' => $group_id
    17081706    ) );
     
    18941892
    18951893    /* Record this in activity streams */
    1896     $activity_content = sprintf( __( '%s posted an update in the group %s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    1897     $activity_content .= '<div class="activity-inner">' . $content . '</div>';
     1894    $activity_action = sprintf( __( '%s posted an update in the group %s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1895    $activity_content = '<div class="activity-inner">' . $content . '</div>';
    18981896
    18991897    $activity_id = groups_record_activity( array(
    19001898        'user_id' => $user_id,
     1899        'action' => apply_filters( 'groups_activity_new_update_action', $activity_action ),
    19011900        'content' => apply_filters( 'groups_activity_new_update_content', $activity_content ),
    1902         'primary_link' => apply_filters( 'groups_activity_new_update_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    1903         'component_action' => 'activity_update',
     1901        'type' => 'activity_update',
    19041902        'item_id' => $bp->groups->current_group->id
    19051903    ) );
     
    19411939        $topic = bp_forums_get_topic_details( $topic_id );
    19421940
    1943         $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    1944         $activity_content .= '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
     1941        $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1942        $activity_content = '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
    19451943
    19461944        /* Record this in activity streams */
    19471945        groups_record_activity( array(
    1948             'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
     1946            'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
     1947            'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
    19491948            'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
    1950             'component_action' => 'new_forum_post',
     1949            'type' => 'new_forum_post',
    19511950            'item_id' => $bp->groups->current_group->id,
    19521951            'secondary_item_id' => $forum_post
     
    19751974        $topic = bp_forums_get_topic_details( $topic_id );
    19761975
    1977         $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    1978         $activity_content .= '<blockquote>' . bp_create_excerpt( $topic_text ) . '</blockquote>';
     1976        $activity_action = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1977        $activity_content = '<blockquote>' . bp_create_excerpt( $topic_text ) . '</blockquote>';
    19791978
    19801979        /* Record this in activity streams */
    19811980        groups_record_activity( array(
    1982             'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
     1981            'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
     1982            'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
    19831983            'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
    1984             'component_action' => 'new_forum_topic',
     1984            'type' => 'new_forum_topic',
    19851985            'item_id' => $bp->groups->current_group->id,
    19861986            'secondary_item_id' => $topic->topic_id
     
    20042004        /* Update the activity stream item */
    20052005        if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    2006             bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) );
    2007 
    2008         $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    2009         $activity_content .= '<blockquote>' . bp_create_excerpt( $topic_text ) . '</blockquote>';
     2006            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
     2007
     2008        $activity_action = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     2009        $activity_content = '<blockquote>' . bp_create_excerpt( $topic_text ) . '</blockquote>';
    20102010
    20112011        /* Record this in activity streams */
    20122012        groups_record_activity( array(
    2013             'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
     2013            'action' => apply_filters( 'groups_activity_new_forum_topic_action', $activity_action, $topic_text, &$topic ),
     2014            'content' => apply_filters( 'groups_activity_new_forum_topic_content', $activity_content, $topic_text, &$topic ),
    20142015            'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
    2015             'component_action' => 'new_forum_topic',
     2016            'type' => 'new_forum_topic',
    20162017            'item_id' => (int)$bp->groups->current_group->id,
    20172018            'user_id' => (int)$topic->topic_poster,
     
    20412042        /* Update the activity stream item */
    20422043        if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    2043             bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
    2044 
    2045         $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    2046         $activity_content .= '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
     2044            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
     2045
     2046        $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     2047        $activity_content = '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
    20472048
    20482049        /* Record this in activity streams */
    20492050        groups_record_activity( array(
    2050             'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
     2051            'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
     2052            'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
    20512053            'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    2052             'component_action' => 'new_forum_post',
     2054            'type' => 'new_forum_post',
    20532055            'item_id' => (int)$bp->groups->current_group->id,
    20542056            'user_id' => (int)$post->poster_id,
     
    20712073        /* Delete the activity stream item */
    20722074        if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
    2073             bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) );
    2074             bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
     2075            bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
     2076            bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
    20752077        }
    20762078
     
    20892091        /* Delete the activity stream item */
    20902092        if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
    2091             bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
     2093            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
    20922094        }
    20932095
     
    23442346
    23452347    groups_record_activity( array(
    2346         'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
    2347         'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ),
    2348         'component_action' => 'joined_group',
     2348        'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
     2349        'type' => 'joined_group',
    23492350        'item_id' => $group->id,
    23502351        'user_id' => $user_id
Note: See TracChangeset for help on using the changeset viewer.