Skip to:
Content

BuddyPress.org

Changeset 1691


Ignore:
Timestamp:
08/25/2009 12:44:29 AM (17 years ago)
Author:
apeatling
Message:

Added support for deleting activity stream items.

Location:
trunk
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r1687 r1691  
    120120 * back to the default screen after execution.
    121121 */
     122
     123function bp_activity_action_delete_activity() {
     124    global $bp;
     125
     126    if ( $bp->current_component != $bp->activity->slug || $bp->current_action != 'delete' )
     127        return false;
     128
     129    if ( empty( $bp->action_variables[0] ) || !is_numeric( $bp->action_variables[0] ) )
     130        return false;
     131
     132    /* Check the nonce */
     133    check_admin_referer( 'bp_activity_delete_link' );
     134   
     135    $activity_id = $bp->action_variables[0];
     136   
     137    /* Check access */
     138    if ( !is_site_admin() ) {
     139        $activity = new BP_Activity_Activity( $activity_id );
     140       
     141        if ( $activity->user_id != $bp->loggedin_user->id )
     142            return false;
     143    }
     144   
     145    /* Now delete the activity item */
     146    if ( bp_activity_delete_by_activity_id( $activity_id ) )
     147        bp_core_add_message( __( 'Activity deleted', 'buddypress' ) );
     148    else
     149        bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
     150   
     151    bp_core_redirect( $_SERVER['HTTP_REFERER'] );
     152}
     153add_action( 'wp', 'bp_activity_action_delete_activity', 3 );
     154
    122155
    123156function bp_activity_action_sitewide_feed() {
  • trunk/bp-activity/bp-activity-classes.php

    r1670 r1691  
    1212    var $hide_sitewide = false;
    1313   
    14     function bp_activity_activity( $args = false, $populate = false ) {
     14    function bp_activity_activity( $id = false ) {
    1515        global $bp;
    1616       
    17         if ( $args && is_array($args) ) {
    18             extract( $args );
    19            
    20             $this->user_id = $user_id;
    21             $this->component_name = $component_name;
    22             $this->component_action = $component_action;
    23             $this->item_id = $item_id;
    24             $this->secondary_item_id = $secondary_item_id;
    25            
    26             if ( $populate )
    27                 $this->populate();
     17        if ( $id ) {
     18            $this->id = $id;
     19            $this->populate();
    2820        }
    2921    }
     
    171163
    172164        for ( $i = 0; $i < count( $activities ); $i++ ) {
     165            $activities_formatted[$i]['id'] = $activities[$i]->id;
    173166            $activities_formatted[$i]['user_id'] = $activities[$i]->user_id;
    174167            $activities_formatted[$i]['content'] = $activities[$i]->content;
     
    238231
    239232        for ( $i = 0; $i < count( $activities ); $i++ ) {
     233            $activities_formatted[$i]['id'] = $activities[$i]->id;
    240234            $activities_formatted[$i]['user_id'] = $activities[$i]->user_id;
    241235            $activities_formatted[$i]['content'] = $activities[$i]->content;
  • trunk/bp-activity/bp-activity-filters.php

    r1608 r1691  
    1414    $allowedtags['span'] = array();
    1515    $allowedtags['span']['class'] = array();
     16    $allowedtags['a']['class'] = array();
     17    $allowedtags['img'] = array();
    1618    return $allowedtags;
    1719}
  • trunk/bp-activity/bp-activity-templatetags.php

    r1670 r1691  
    249249}
    250250    function bp_get_activity_content() {
    251         global $activities_template, $allowed_tags;
    252 
    253         if ( bp_is_home() && $activities_template->activity_type == 'personal' ) {
     251        global $activities_template, $allowed_tags, $bp;
     252
     253        if ( bp_is_home() && $activities_template->activity_type == 'personal' )
    254254            $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );                       
    255         } else {
    256             $activities_template->activity->content = bp_activity_insert_time_since( $activities_template->activity->content, $activities_template->activity->date_recorded );
    257             $content = $activities_template->activity->content;
    258         }
    259        
     255        else
     256            $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false );
     257
    260258        return apply_filters( 'bp_get_activity_content', $content );
    261259    }
    262260
    263261function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
     262    global $activities_template, $bp;
     263   
    264264    if ( !$content )
    265265        return false;
     
    274274    if ( $insert_time )
    275275        $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
    276 
     276   
    277277    // The "You" and "Your" conversion is only done in english, if a translation file is present
    278278    // then do not translate as it causes problems in other languages.
     
    288288        }
    289289    }
     290
     291    /* Add the delete link if the user has permission on this item */
     292    if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
     293        $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 
    290294   
    291295    $content_new = '';
     
    314318       
    315319        return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
     320    }
     321
     322function bp_activity_delete_link() {
     323    echo bp_get_activity_delete_link();
     324}
     325    function bp_get_activity_delete_link() {
     326        global $activities_template, $bp;
     327
     328        return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete confirm">' . __( 'Delete', 'buddypress' ) . '</a>' );
    316329    }
    317330
  • trunk/bp-themes/bp-default/_inc/css/screen.css

    r1687 r1691  
    675675        }
    676676
     677a.item-button {
     678    border: 1px solid #eee;
     679    background: #f5f5f5;
     680    color: #999;
     681    padding: 0 3px;
     682    -moz-border-radius: 3px;
     683    -webkit-border-radius: 3px;
     684    border-radius: 3px;
     685    font-size: 0.8em;
     686    text-decoration: none;
     687}
     688    a.item-button:hover {
     689        border-color: #ccc;
     690        color: #777;
     691    }
     692
     693    .activity-list li a.item-button {
     694        display: none;
     695        position: absolute;
     696        right: 0 !important;
     697        top: 0 !important;
     698    }
     699        .item-list li a.item-button {
     700            display: none;
     701            position: absolute;
     702            top: 10px;
     703            right: 10px;
     704        }
     705
     706    .activity-list li:hover a.item-button, .item-list li:hover a.item-button {
     707        display: inline;
     708    }
    677709
    678710/*** Standard Form Styles ***************************************************/
     
    12121244
    12131245.activity-list li {
     1246    position: relative;
    12141247    margin: 5px 15px;
    1215     padding: 0 0 0 34px !important;
     1248    padding: 0 50px 0 34px !important;
    12161249    background: none !important;
    12171250}
     
    12581291    padding: 7px 15px 7px 40px;
    12591292    background: url(../images/quotes_background.gif) 10px 9px no-repeat #eee;
    1260     margin: -10px 0 15px 0;
     1293    margin: -10px -50px 15px 0;
    12611294    border-radius: 5px;
    12621295    -moz-border-radius: 5px;
     
    13201353    overflow: hidden;
    13211354}
     1355
     1356
    13221357/**** BLOGS *****************/
    13231358       
     
    17671802}
    17681803
    1769 a.delete {
     1804table#message-threads a.delete {
    17701805    overflow: hidden;
    17711806    text-indent: -999px;
     
    17781813}
    17791814
    1780 span.unread-count {
     1815table#message-threads span.unread-count {
    17811816    background: #c2582b;
    17821817    border: 2px solid #c2582b;
  • trunk/bp-themes/bp-sn-framework/activity/my-friends.php

    r1670 r1691  
    4848                           
    4949                            <?php bp_activity_content() ?>
    50                            
     50
    5151                            <?php do_action( 'bp_friends_activity_item' ) ?>
    5252                        </li>
  • trunk/bp-wire/bp-wire-templatetags.php

    r1688 r1691  
    364364        if ( ( $wire_posts_template->wire_post->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() ) {
    365365            if ( $bp->wire->slug == $bp->current_component || $bp->profile->slug == $bp->current_component ) {
    366                 return apply_filters( 'bp_get_wire_delete_link', '<a class="confirm" href="' . wp_nonce_url( $bp->displayed_user->domain . $bp->wire->slug . '/delete/' . $wire_posts_template->wire_post->id, 'bp_wire_delete_link' ) . '">[' . __('Delete', 'buddypress') . ']</a>' );
     366                return apply_filters( 'bp_get_wire_delete_link', '<a class="item-button delete confirm" href="' . wp_nonce_url( $bp->displayed_user->domain . $bp->wire->slug . '/delete/' . $wire_posts_template->wire_post->id, 'bp_wire_delete_link' ) . '">' . __('Delete', 'buddypress') . '</a>' );
    367367            } else {
    368                 return apply_filters( 'bp_get_wire_delete_link', '<a class="confirm" href="' . wp_nonce_url( site_url( $bp->{$bp->current_component}->slug . '/' . $uri . '/wire/delete/' . $wire_posts_template->wire_post->id ), 'bp_wire_delete_link' ) . '">[' . __('Delete', 'buddypress') . ']</a>' );
     368                return apply_filters( 'bp_get_wire_delete_link', '<a class="item-button delete confirm" href="' . wp_nonce_url( site_url( $bp->{$bp->current_component}->slug . '/' . $uri . '/wire/delete/' . $wire_posts_template->wire_post->id ), 'bp_wire_delete_link' ) . '">' . __('Delete', 'buddypress') . '</a>' );
    369369            }
    370370        }
Note: See TracChangeset for help on using the changeset viewer.