Skip to:
Content

BuddyPress.org

Changeset 3300 for trunk/bp-activity.php


Ignore:
Timestamp:
10/24/2010 09:22:29 PM (15 years ago)
Author:
djpaul
Message:

Fixed #2676

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2863 r3300  
    55
    66function bp_activity_setup_globals() {
    7     global $bp, $wpdb, $current_blog;
     7    global $bp, $current_blog;
    88
    99    if ( !defined( 'BP_ACTIVITY_SLUG' ) )
    1010        define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );
    1111
    12     /* For internal identification */
     12    // For internal identification
    1313    $bp->activity->id = 'activity';
    1414    $bp->activity->name = $bp->pages->activity->name;
    1515    $bp->activity->slug = BP_ACTIVITY_SLUG;
    1616
    17     $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
    18     $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
     17    $bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
     18    $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
     19
    1920    $bp->activity->format_notification_function = 'bp_activity_format_notifications';
    2021
    21     /* Register this in the active components array */
     22    // Register this in the active components array
    2223    $bp->active_components[$bp->activity->slug] = $bp->activity->id;
    2324
     
    4344
    4445    if ( bp_is_active( 'groups' ) )
    45         bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => $bp->groups->name, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
     46        bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
    4647
    4748    bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
     
    9394        return false;
    9495
    95     if ( !is_site_admin() )
     96    if ( !is_super_admin() )
    9697        $bp->is_item_admin = false;
    9798
     
    106107        return false;
    107108
    108     if ( !is_site_admin() )
     109    if ( !is_super_admin() )
    109110        $bp->is_item_admin = false;
    110111
     
    116117    global $bp;
    117118
    118     if ( !is_site_admin() )
     119    if ( !is_super_admin() )
    119120        $bp->is_item_admin = false;
    120121
     
    126127    global $bp;
    127128
    128     if ( !is_site_admin() )
     129    if ( !is_super_admin() )
    129130        $bp->is_item_admin = false;
    130131
     
    173174            bp_core_redirect( $bp->loggedin_user->domain );
    174175        else
    175             bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . clean_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
     176            bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
    176177    }
    177178
     
    183184function bp_activity_screen_notification_settings() {
    184185    global $bp; ?>
    185     <table class="notification-settings" id="activity-notification-settings">
    186         <tr>
    187             <th class="icon"></th>
    188             <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
    189             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    190             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    191         </tr>
    192 
    193         <tr>
    194             <td></td>
    195             <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
    196             <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
    197             <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
    198         </tr>
    199         <tr>
    200             <td></td>
    201             <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
    202             <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
    203             <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
    204         </tr>
    205 
    206         <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
     186    <table class="notification-settings zebra" id="activity-notification-settings">
     187        <thead>
     188            <tr>
     189                <th class="icon"></th>
     190                <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
     191                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     192                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     193            </tr>
     194        </thead>
     195
     196        <tbody>
     197            <tr>
     198                <td></td>
     199                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
     200                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) || 'yes' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
     201                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
     202            </tr>
     203            <tr>
     204                <td></td>
     205                <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
     206                <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) || 'yes' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
     207                <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
     208            </tr>
     209
     210            <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
     211        </tbody>
    207212    </table>
    208213<?php
     
    271276
    272277    /* Check access */
    273     if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
     278    if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id )
    274279        return false;
    275280
     
    541546
    542547function bp_activity_add( $args = '' ) {
    543     global $bp, $wpdb;
     548    global $bp;
    544549
    545550    $defaults = array(
    546         'id' => false, // Pass an existing activity ID to update an existing entry.
    547 
    548         'action' => '', // The activity action - e.g. "Jon Doe posted an update"
    549         'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    550 
    551         'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    552         'type' => false, // The activity type e.g. activity_update, profile_updated
    553         'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    554 
    555         'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
    556         'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
     551        'id'                => false, // Pass an existing activity ID to update an existing entry.
     552
     553        'action'            => '', // The activity action - e.g. "Jon Doe posted an update"
     554        'content'           => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
     555
     556        'component'         => false, // The name/ID of the component e.g. groups, profile, mycomponent
     557        'type'              => false, // The activity type e.g. activity_update, profile_updated
     558        'primary_link'      => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
     559
     560        'user_id'           => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
     561        'item_id'           => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
    557562        'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
    558         'recorded_time' => gmdate( "Y-m-d H:i:s" ), // The GMT time that this activity was recorded
    559         'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
     563        'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
     564        'hide_sitewide'     => false // Should this be hidden on the sitewide activity stream?
    560565    );
    561566
     
    628633
    629634    /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
    630     update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
     635    update_user_meta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
    631636
    632637    /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
     
    755760        $user_id = $args['user_id'];
    756761
    757     $latest_update = get_usermeta( $user_id, 'bp_latest_update' );
     762    $latest_update = get_user_meta( $user_id, 'bp_latest_update', true );
    758763    if ( !empty( $latest_update ) ) {
    759764        if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
    760             delete_usermeta( $user_id, 'bp_latest_update' );
     765            delete_user_meta( $user_id, 'bp_latest_update' );
    761766    }
    762767
     
    909914
    910915function bp_activity_get_user_favorites( $user_id ) {
    911     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     916    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    912917    $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
    913918
     
    916921
    917922    $new_favs = array_unique( (array)$new_favs );
    918     update_usermeta( $user_id, 'bp_favorite_activities', $new_favs );
     923    update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
    919924
    920925    return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
     
    928933
    929934    /* Update the user's personal favorites */
    930     $my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
     935    $my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
    931936    $my_favs[] = $activity_id;
    932937
     
    939944        $fav_count = 1;
    940945
    941     update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
     946    update_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
    942947    bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
    943948
     
    954959
    955960    /* Remove the fav from the user's favs */
    956     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     961    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    957962    $my_favs = array_flip( (array) $my_favs );
    958963    unset( $my_favs[$activity_id] );
     
    967972    }
    968973
    969     update_usermeta( $user_id, 'bp_favorite_activities', $my_favs );
     974    update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
    970975
    971976    do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
     
    10891094
    10901095    // Remove any usermeta
    1091     delete_usermeta( $user_id, 'bp_latest_update' );
    1092     delete_usermeta( $user_id, 'bp_favorite_activities' );
     1096    delete_user_meta( $user_id, 'bp_latest_update' );
     1097    delete_user_meta( $user_id, 'bp_favorite_activities' );
    10931098
    10941099    do_action( 'bp_activity_remove_data', $user_id );
     
    10981103add_action( 'make_spam_user', 'bp_activity_remove_data' );
    10991104
     1105/**
     1106 * updates_register_activity_actions()
     1107 *
     1108 * Register the activity stream actions for updates
     1109 *
     1110 * @global array $bp
     1111 */
     1112function updates_register_activity_actions() {
     1113    global $bp;
     1114
     1115    bp_activity_set_action( $bp->activity->id, 'activity_update', __( 'Posted an update', 'buddypress' ) );
     1116
     1117    do_action( 'updates_register_activity_actions' );
     1118}
     1119add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' );
    11001120
    11011121/********************************************************************************
     
    11101130    do_action( 'bp_register_activity_actions' );
    11111131}
    1112 add_action( 'plugins_loaded', 'bp_register_activity_actions' );
     1132add_action( 'bp_loaded', 'bp_register_activity_actions', 8 );
    11131133
    11141134
Note: See TracChangeset for help on using the changeset viewer.