Changeset 3300 for trunk/bp-activity.php
- Timestamp:
- 10/24/2010 09:22:29 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-activity.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2863 r3300 5 5 6 6 function bp_activity_setup_globals() { 7 global $bp, $ wpdb, $current_blog;7 global $bp, $current_blog; 8 8 9 9 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 10 10 define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug ); 11 11 12 / * For internal identification */12 // For internal identification 13 13 $bp->activity->id = 'activity'; 14 14 $bp->activity->name = $bp->pages->activity->name; 15 15 $bp->activity->slug = BP_ACTIVITY_SLUG; 16 16 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 19 20 $bp->activity->format_notification_function = 'bp_activity_format_notifications'; 20 21 21 / * Register this in the active components array */22 // Register this in the active components array 22 23 $bp->active_components[$bp->activity->slug] = $bp->activity->id; 23 24 … … 43 44 44 45 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' ) ); 46 47 47 48 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' ) ); … … 93 94 return false; 94 95 95 if ( !is_s ite_admin() )96 if ( !is_super_admin() ) 96 97 $bp->is_item_admin = false; 97 98 … … 106 107 return false; 107 108 108 if ( !is_s ite_admin() )109 if ( !is_super_admin() ) 109 110 $bp->is_item_admin = false; 110 111 … … 116 117 global $bp; 117 118 118 if ( !is_s ite_admin() )119 if ( !is_super_admin() ) 119 120 $bp->is_item_admin = false; 120 121 … … 126 127 global $bp; 127 128 128 if ( !is_s ite_admin() )129 if ( !is_super_admin() ) 129 130 $bp->is_item_admin = false; 130 131 … … 173 174 bp_core_redirect( $bp->loggedin_user->domain ); 174 175 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 ) ) ); 176 177 } 177 178 … … 183 184 function bp_activity_screen_notification_settings() { 184 185 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> 207 212 </table> 208 213 <?php … … 271 276 272 277 /* Check access */ 273 if ( !is_s ite_admin() && $activity->user_id != $bp->loggedin_user->id )278 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id ) 274 279 return false; 275 280 … … 541 546 542 547 function bp_activity_add( $args = '' ) { 543 global $bp , $wpdb;548 global $bp; 544 549 545 550 $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, mycomponent552 'type' => false, // The activity type e.g. activity_update, profile_updated553 '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_id551 '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 557 562 '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 recorded559 '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? 560 565 ); 561 566 … … 628 633 629 634 /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */ 630 update_user meta( $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 ) ) ); 631 636 632 637 /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */ … … 755 760 $user_id = $args['user_id']; 756 761 757 $latest_update = get_user meta( $user_id, 'bp_latest_update');762 $latest_update = get_user_meta( $user_id, 'bp_latest_update', true ); 758 763 if ( !empty( $latest_update ) ) { 759 764 if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) ) 760 delete_user meta( $user_id, 'bp_latest_update' );765 delete_user_meta( $user_id, 'bp_latest_update' ); 761 766 } 762 767 … … 909 914 910 915 function bp_activity_get_user_favorites( $user_id ) { 911 $my_favs = maybe_unserialize( get_user meta( $user_id, 'bp_favorite_activities') );916 $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) ); 912 917 $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) ); 913 918 … … 916 921 917 922 $new_favs = array_unique( (array)$new_favs ); 918 update_user meta( $user_id, 'bp_favorite_activities', $new_favs );923 update_user_meta( $user_id, 'bp_favorite_activities', $new_favs ); 919 924 920 925 return apply_filters( 'bp_activity_get_user_favorites', $new_favs ); … … 928 933 929 934 /* Update the user's personal favorites */ 930 $my_favs = maybe_unserialize( get_user meta( $bp->loggedin_user->id, 'bp_favorite_activities') );935 $my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) ); 931 936 $my_favs[] = $activity_id; 932 937 … … 939 944 $fav_count = 1; 940 945 941 update_user meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );946 update_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs ); 942 947 bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count ); 943 948 … … 954 959 955 960 /* Remove the fav from the user's favs */ 956 $my_favs = maybe_unserialize( get_user meta( $user_id, 'bp_favorite_activities') );961 $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) ); 957 962 $my_favs = array_flip( (array) $my_favs ); 958 963 unset( $my_favs[$activity_id] ); … … 967 972 } 968 973 969 update_user meta( $user_id, 'bp_favorite_activities', $my_favs );974 update_user_meta( $user_id, 'bp_favorite_activities', $my_favs ); 970 975 971 976 do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id ); … … 1089 1094 1090 1095 // Remove any usermeta 1091 delete_user meta( $user_id, 'bp_latest_update' );1092 delete_user meta( $user_id, 'bp_favorite_activities' );1096 delete_user_meta( $user_id, 'bp_latest_update' ); 1097 delete_user_meta( $user_id, 'bp_favorite_activities' ); 1093 1098 1094 1099 do_action( 'bp_activity_remove_data', $user_id ); … … 1098 1103 add_action( 'make_spam_user', 'bp_activity_remove_data' ); 1099 1104 1105 /** 1106 * updates_register_activity_actions() 1107 * 1108 * Register the activity stream actions for updates 1109 * 1110 * @global array $bp 1111 */ 1112 function 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 } 1119 add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' ); 1100 1120 1101 1121 /******************************************************************************** … … 1110 1130 do_action( 'bp_register_activity_actions' ); 1111 1131 } 1112 add_action( ' plugins_loaded', 'bp_register_activity_actions');1132 add_action( 'bp_loaded', 'bp_register_activity_actions', 8 ); 1113 1133 1114 1134
Note: See TracChangeset
for help on using the changeset viewer.