Changeset 3300
- Timestamp:
- 10/24/2010 09:22:29 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 99 edited
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 -
trunk/bp-activity/bp-activity-classes.php
r3236 r3300 98 98 $where_conditions = array(); 99 99 100 /* Searching */ 101 if ( $search_terms ) { 102 $search_terms = $wpdb->escape( $search_terms ); 103 $where_conditions['search_sql'] = "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'"; 104 } 105 100 106 /* Filtering */ 101 107 if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) ) … … 117 123 $where_sql = 'WHERE ' . join( ' AND ', $where_conditions ); 118 124 119 /* Searching */120 if ( $search_terms ) {121 $search_terms = $wpdb->escape( $search_terms );122 123 if ( !empty( $filter['user_id'] ) )124 $where_sql .= ' OR ';125 else if ( !empty( $where_conditions ) )126 $where_sql .= ' AND ';127 128 $where_sql .= "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'";129 }130 131 125 if ( $per_page && $page ) { 132 126 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) ); 133 127 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ) ); 134 } else 128 } else { 135 129 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) ) ); 130 } 136 131 137 132 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) ); … … 532 527 global $bp, $wpdb; 533 528 534 return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );529 return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" ) ); 535 530 } 536 531 … … 538 533 global $bp; 539 534 540 if ( !$favorite_activity_entries = get_user meta( $user_id, 'bp_favorite_activities') )535 if ( !$favorite_activity_entries = get_user_meta( $user_id, 'bp_favorite_activities', true ) ) 541 536 return 0; 542 537 -
trunk/bp-activity/bp-activity-notifications.php
r3232 r3300 5 5 6 6 /* Scan for @username strings in an activity update. Notify each user. */ 7 $pattern = '/[@]+([A-Za-z0-9-_ ]+)/';7 $pattern = '/[@]+([A-Za-z0-9-_\.]+)/'; 8 8 preg_match_all( $pattern, $content, $usernames ); 9 9 … … 13 13 14 14 foreach( (array)$usernames as $username ) { 15 if ( !$receiver_user_id = bp_core_get_userid( $username) )15 if ( !$receiver_user_id = bp_core_get_userid( $username ) ) 16 16 continue; 17 17 18 18 // Now email the user with the contents of the message (if they have enabled email notifications) 19 if ( 'no' != get_user meta( $receiver_user_id, 'notification_activity_new_mention') ) {19 if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 20 20 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 21 21 … … 27 27 28 28 // Set up and send the message 29 $ud = bp_core_get_core_userdata( $receiver_user_id ); 30 $to = $ud->user_email; 31 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ); 29 $ud = bp_core_get_core_userdata( $receiver_user_id ); 30 $to = $ud->user_email; 31 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 32 $subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ); 32 33 33 34 $message = sprintf( __( … … 61 62 $original_activity = new BP_Activity_Activity( $activity_id ); 62 63 63 if ( $original_activity->user_id != $commenter_id && 'no' != get_user meta( $original_activity->user_id, 'notification_activity_new_reply') ) {64 if ( $original_activity->user_id != $commenter_id && 'no' != get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { 64 65 $poster_name = bp_core_get_user_displayname( $commenter_id ); 65 66 $thread_link = bp_activity_get_permalink( $activity_id ); … … 70 71 71 72 // Set up and send the message 72 $ud = bp_core_get_core_userdata( $original_activity->user_id ); 73 $to = $ud->user_email; 74 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ); 73 $ud = bp_core_get_core_userdata( $original_activity->user_id ); 74 $to = $ud->user_email; 75 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 76 $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ); 75 77 76 78 $message = sprintf( __( … … 103 105 $parent_comment = new BP_Activity_Activity( $parent_id ); 104 106 105 if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_user meta( $parent_comment->user_id, 'notification_activity_new_reply') ) {107 if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) { 106 108 $poster_name = bp_core_get_user_displayname( $commenter_id ); 107 109 $thread_link = bp_activity_get_permalink( $activity_id ); … … 109 111 110 112 // Set up and send the message 111 $ud = bp_core_get_core_userdata( $parent_comment->user_id ); 112 $to = $ud->user_email; 113 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ); 113 $ud = bp_core_get_core_userdata( $parent_comment->user_id ); 114 $to = $ud->user_email; 115 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 116 $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ); 114 117 115 118 $poster_name = stripslashes( $poster_name ); -
trunk/bp-activity/bp-activity-templatetags.php
r3263 r3300 26 26 27 27 // Get an array of the logged in user's favorite activities 28 $this->my_favs = maybe_unserialize( get_user meta( $bp->loggedin_user->id, 'bp_favorite_activities') );28 $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) ); 29 29 30 30 // Fetch specific activity items based on ID's 31 31 if ( !empty( $include ) ) 32 32 $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) ); 33 // Fetch all activity items 33 34 else 34 35 $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) ); … … 155 156 $primary_id = $bp->groups->current_group->id; 156 157 157 if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id) )158 if ( 'public' != $bp->groups->current_group->status && ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) || $bp->loggedin_user->is_super_admin ) ) 158 159 $show_hidden = true; 159 160 } … … 201 202 // are we displaying user specific activity? 202 203 if ( is_numeric( $user_id ) ) { 203 $show_hidden = ( $user_id == $bp->loggedin_user->id ) ? 1 : 0;204 $show_hidden = ( $user_id == $bp->loggedin_user->id && $scope != 'friends' ) ? 1 : 0; 204 205 205 206 switch ( $scope ) { … … 275 276 global $bp, $activities_template; 276 277 277 $from_num = bp_core_number_format( intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1 ); 278 $to_num = bp_core_number_format( ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1 ) ); 278 $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1; 279 $from_num = bp_core_number_format( $start_num ); 280 $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) ); 279 281 $total = bp_core_number_format( $activities_template->total_activity_count ); 280 282 281 return sprintf( __( 'Viewing item % s to %s (of %s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>';283 return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>'; 282 284 } 283 285 … … 403 405 } 404 406 407 /** 408 * bp_activity_avatar( $args ) 409 * 410 * Output the avatar of the user that performed the action 411 * 412 * @param array $args 413 */ 405 414 function bp_activity_avatar( $args = '' ) { 406 415 echo bp_get_activity_avatar( $args ); 407 416 } 417 /** 418 * bp_get_activity_avatar( $args ) 419 * 420 * Return the avatar of the user that performed the action 421 * 422 * @global array $bp 423 * @global object $activities_template 424 * @param array $args optional 425 * @return string 426 */ 408 427 function bp_get_activity_avatar( $args = '' ) { 409 428 global $bp, $activities_template; 410 429 411 430 $defaults = array( 412 'type' => 'thumb',413 'width' => 20,431 'type' => 'thumb', 432 'width' => 20, 414 433 'height' => 20, 415 'class' => 'avatar',416 'alt' => __( 'Avatar', 'buddypress' ),417 'email' => false434 'class' => 'avatar', 435 'alt' => __( 'Avatar', 'buddypress' ), 436 'email' => false 418 437 ); 419 438 … … 421 440 extract( $r, EXTR_SKIP ); 422 441 423 $item_id = false; 424 if ( (int)$activities_template->activity->user_id ) 425 $item_id = $activities_template->activity->user_id; 426 else if ( $activities_template->activity->item_id ) 427 $item_id = $activities_template->activity->item_id; 428 429 $object = 'user'; 430 if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 431 $object = 'group'; 432 if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id ) 433 $object = 'blog'; 434 435 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object ); 436 437 /* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */ 438 if ( 'user' == $object && empty($email) ) 442 // Primary activity avatar is always a user, but can be modified via a filter 443 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, 'user' ); 444 $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $activities_template->activity->user_id ); 445 446 // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. 447 if ( 'user' == $object && empty( $email ) ) 439 448 $email = $activities_template->activity->user_email; 440 449 441 450 return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) ); 451 } 452 453 /** 454 * bp_activity_secondary_avatar( $args ) 455 * 456 * Output the avatar of the object that action was performed on 457 * 458 * @param array $args optional 459 */ 460 function bp_activity_secondary_avatar( $args = '' ) { 461 echo bp_get_activity_secondary_avatar( $args ); 462 } 463 /** 464 * bp_get_activity_secondary_avatar( $args ) 465 * 466 * Return the avatar of the object that action was performed on 467 * 468 * @global array $bp 469 * @global object $activities_template 470 * @param array $args optional 471 * @return string 472 */ 473 function bp_get_activity_secondary_avatar( $args = '' ) { 474 global $bp, $activities_template; 475 476 $defaults = array( 477 'type' => 'thumb', 478 'width' => 20, 479 'height' => 20, 480 'class' => 'avatar', 481 'alt' => __( 'Avatar', 'buddypress' ), 482 'email' => false 483 ); 484 485 $r = wp_parse_args( $args, $defaults ); 486 extract( $r, EXTR_SKIP ); 487 488 // Set item_id and object (default to user) 489 switch ( $activities_template->activity->component ) { 490 case 'groups' : 491 $object = 'group'; 492 $item_id = $activities_template->activity->item_id; 493 break; 494 case 'blogs' : 495 $object = 'blog'; 496 $item_id = $activities_template->activity->item_id; 497 break; 498 case 'friends' : 499 $object = 'user'; 500 $item_id = $activities_template->activity->secondary_item_id; 501 break; 502 default : 503 $object = 'user'; 504 $item_id = $activities_template->activity->user_id; 505 $email = $activities_template->activity->user_email; 506 break; 507 } 508 509 // Allow object and item_id to be filtered 510 $object = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object ); 511 $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id ); 512 513 // If we have no item_id or object, there is no avatar to display 514 if ( empty( $item_id ) || empty( $object ) ) 515 return false; 516 517 return apply_filters( 'bp_get_activity_secondary_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) ); 442 518 } 443 519 … … 449 525 450 526 $action = $activities_template->activity->action; 527 528 $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity ); 451 529 452 530 if ( !empty( $action ) ) … … 498 576 global $activities_template, $bp; 499 577 500 $meta = '<span class="activity-actions">'; 578 /* Strip any legacy time since placeholders -- TODO: Remove this in 1.3 */ 579 $content = str_replace( '<span class="time-since">%s</span>', '', $content ); 501 580 502 581 /* Insert the time since. */ 503 $ meta .=apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity );582 $content .= ' ' . apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity ); 504 583 505 584 /* Insert the permalink */ 506 $ meta.= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity );585 $content .= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity ); 507 586 508 587 /* Add the delete link if the user has permission on this item */ 509 if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_site_admin ) 510 $meta .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), &$activities_template->activity ); 511 512 $meta .= '</span>'; 513 514 return apply_filters( 'bp_insert_activity_meta', $content . ' ' . $meta, $content, $meta ); 588 if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_super_admin ) 589 $content .= apply_filters( 'bp_activity_delete_link', ' · ' . bp_get_activity_delete_link(), &$activities_template->activity ); 590 591 return apply_filters( 'bp_insert_activity_meta', $content ); 515 592 } 516 593 … … 585 662 586 663 $content .= '<li id="acomment-' . $comment->id . '">'; 587 $content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 2 5, 'height' => 25, 'email' => $comment->user_email ) ) . '</a></div>';588 $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_ get_member_name', $comment->user_fullname ) . '</a> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( strtotime( $comment->date_recorded )) );664 $content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 20, 'height' => 20, 'email' => $comment->user_email ) ) . '</a></div>'; 665 $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_acomment_name', $comment->user_fullname, $comment ) . '</a> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) ); 589 666 590 667 /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */ … … 593 670 594 671 /* Delete link */ 595 if ( $bp->loggedin_user->is_s ite_admin || $bp->loggedin_user->id == $comment->user_id )672 if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id ) 596 673 $content .= ' · <a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>'; 597 674 … … 739 816 $user_id = $bp->displayed_user->id; 740 817 741 if ( !$update = get_user meta( $user_id, 'bp_latest_update') )818 if ( !$update = get_user_meta( $user_id, 'bp_latest_update', true ) ) 742 819 return false; 743 820 744 $latest_update = '"' . trim( strip_tags( bp_create_excerpt( $update['content'], 40) ) ) . '"';821 $latest_update = '"' . apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 40 ) ) ) ) . '"'; 745 822 $latest_update .= ' · <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>'; 746 823 … … 777 854 unset($selected); 778 855 779 $component = attribute_escape( $component );856 $component = esc_attr( $component ); 780 857 781 858 switch ( $style ) { … … 805 882 $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 806 883 807 $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;884 $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after; 808 885 } 809 886 … … 811 888 812 889 if ( isset( $_GET['afilter'] ) ) 813 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';890 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>'; 814 891 815 892 return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) ); … … 841 918 } 842 919 function bp_get_total_mention_count_for_user( $user_id = false ) { 843 return apply_filters( 'bp_get_total_mention_count_for_user', get_user meta( $user_id, 'bp_new_mention_count') );920 return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) ); 844 921 } 845 922 -
trunk/bp-activity/feeds/bp-activity-favorites-feed.php
r2600 r3300 15 15 xmlns:dc="http://purl.org/dc/elements/1.1/" 16 16 xmlns:atom="http://www.w3.org/2005/Atom" 17 <?php do_action('bp_activity_ mentions_feed'); ?>17 <?php do_action('bp_activity_favorites_feed'); ?> 18 18 > 19 19 -
trunk/bp-blogs.php
r3232 r3300 10 10 global $bp, $wpdb; 11 11 12 if ( !defined( 'BP_BLOGS_SLUG' ) ) 13 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug ); 14 12 15 /* For internal identification */ 13 16 $bp->blogs->id = 'blogs'; … … 45 48 46 49 /* Add 'Blogs' to the main navigation */ 47 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs-> name, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );48 49 $blogs_link = $bp->loggedin_user->domain . $bp->blogs-> name. '/';50 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) ); 51 52 $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/'; 50 53 51 54 /* Set up the component options navigation for Blog */ … … 97 100 } 98 101 99 function bp_blogs_screen_recent_posts() {100 do_action( 'bp_blogs_screen_recent_posts' );101 bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) );102 }103 104 function bp_blogs_screen_recent_comments() {105 do_action( 'bp_blogs_screen_recent_comments' );106 bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) );107 }108 109 102 function bp_blogs_screen_create_a_blog() { 110 103 global $bp; … … 164 157 'item_id' => false, 165 158 'secondary_item_id' => false, 166 'recorded_time' => gmdate( "Y-m-d H:i:s"),159 'recorded_time' => bp_core_current_time(), 167 160 'hide_sitewide' => false 168 161 ); … … 179 172 180 173 if ( !empty( $content ) ) 181 $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ) );174 $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content ); 182 175 183 176 /* Check for an existing entry and update if one exists. */ … … 245 238 } 246 239 247 248 240 function bp_blogs_record_existing_blogs() { 249 241 global $bp, $wpdb; … … 270 262 } 271 263 264 /** 265 * Makes BuddyPress aware of a new site so that it can track its activity. 266 * 267 * @global object $bp BuddyPress global settings 268 * @param int $blog_id 269 * @param int $user_id 270 * @param $bool $no_activity ; optional. 271 * @since 1.0 272 * @uses BP_Blogs_Blog 273 */ 272 274 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) { 273 275 global $bp; … … 290 292 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name ); 291 293 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description ); 292 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s") );293 294 / * Only record this activity if the blog is public */294 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', bp_core_current_time() ); 295 296 // Only record this activity if the blog is public 295 297 if ( (int)$_POST['blog_public'] && !$no_activity ) { 296 / * Record this in activity streams */298 // Record this in activity streams 297 299 bp_blogs_record_activity( array( 298 'user_id' => $recorded_blog->user_id,299 'action' => apply_filters( 'bp_blogs_activity_created_blog_action', sprintf( __( '%1$s created the blog %2$s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),300 'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_ blog_option( $recorded_blog->blog_id, 'siteurl'), $recorded_blog->blog_id ),301 'type' => 'new_blog',302 'item_id' => $recorded_blog->blog_id300 'user_id' => $recorded_blog->user_id, 301 'action' => apply_filters( 'bp_blogs_activity_created_blog_action', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_site_url( $recorded_blog->blog_id ) . '">' . esc_attr( $name ) . '</a>' ), &$recorded_blog, $name, $description ), 302 'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_site_url( $recorded_blog->blog_id ), $recorded_blog->blog_id ), 303 'type' => 'new_blog', 304 'item_id' => $recorded_blog->blog_id 303 305 ) ); 304 306 } … … 307 309 } 308 310 add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 ); 311 312 /** 313 * bp_blogs_update_option_blogname() 314 * 315 * Updates blogname in BuddyPress blogmeta table 316 * 317 * @global object $wpdb DB Layer 318 * @param string $oldvalue Value before save (not used) 319 * @param string $newvalue Value to change meta to 320 */ 321 function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) { 322 global $wpdb; 323 bp_blogs_update_blogmeta( $wpdb->blogid, 'name', $newvalue ); 324 } 325 add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 ); 326 327 /** 328 * bp_blogs_update_option_blogdescription() 329 * 330 * Updates blogdescription in BuddyPress blogmeta table 331 * 332 * @global object $wpdb DB Layer 333 * @param string $oldvalue Value before save (not used) 334 * @param string $newvalue Value to change meta to 335 */ 336 function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) { 337 global $wpdb; 338 bp_blogs_update_blogmeta( $wpdb->blogid, 'description', $newvalue ); 339 } 340 add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 ); 309 341 310 342 function bp_blogs_record_post( $post_id, $post, $user_id = false ) { … … 317 349 $user_id = (int)$post->post_author; 318 350 319 /* This is to stop infin ate loops with Donncha's sitewide tags plugin */351 /* This is to stop infinite loops with Donncha's sitewide tags plugin */ 320 352 if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id ) 321 353 return false; … … 325 357 return false; 326 358 327 if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) { 328 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 329 330 /* If we're on a multiblog install, record this post */ 331 if ( bp_core_is_multisite() ) { 332 $recorded_post = new BP_Blogs_Post; 333 $recorded_post->user_id = $user_id; 334 $recorded_post->blog_id = $blog_id; 335 $recorded_post->post_id = $post_id; 336 $recorded_post->date_created = strtotime( $post->post_date ); 337 338 $recorded_post_id = $recorded_post->save(); 339 340 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 341 } 342 343 if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { 344 /* Record this in activity streams */ 345 $post_permalink = get_permalink( $post_id ); 346 347 $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); 348 $activity_content = $post->post_content; 349 350 bp_blogs_record_activity( array( 351 'user_id' => (int)$post->post_author, 352 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ), 353 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ), 354 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 355 'type' => 'new_blog_post', 356 'item_id' => $blog_id, 357 'secondary_item_id' => $post_id, 358 'recorded_time' => $post->post_date_gmt 359 )); 360 } 361 } 362 } else { 363 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id ); 364 365 /* Delete the recorded post if the status is not published or it is password protected */ 366 if ( 'publish' != $post->post_status || '' != $post->post_password ) { 367 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 368 369 /* If the post author has changed, delete the post and re-add it. */ 370 } else if ( (int)$existing_post->user_id != (int)$post->post_author ) { 371 // Delete the existing recorded post 372 bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 373 374 // Re-record the post with the new author. 375 bp_blogs_record_post( $post_id ); 376 } 377 378 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 379 359 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 380 360 if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { 381 /* Now re-record the post in theactivity streams */361 /* Record this in activity streams */ 382 362 $post_permalink = get_permalink( $post_id ); 383 363 384 $activity_action = sprintf( __( '% 1$s wrote a new blog post: %2$s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );364 $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); 385 365 $activity_content = $post->post_content; 386 366 … … 394 374 'secondary_item_id' => $post_id, 395 375 'recorded_time' => $post->post_date_gmt 396 ) 376 )); 397 377 } 398 } 399 400 bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 401 402 do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded ); 378 } else 379 bp_blogs_remove_post( $post_id, $blog_id ); 380 381 bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); 382 383 do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id ); 403 384 } 404 385 add_action( 'save_post', 'bp_blogs_record_post', 10, 2 ); 405 386 387 /** 388 * bp_blogs_record_comment() 389 * 390 * Record blog comment activity. Checks if blog is public and post is not 391 * password protected. 392 * 393 * @global object $wpdb 394 * @global $bp $bp 395 * @param int $comment_id 396 * @param bool $is_approved 397 * @return mixed 398 */ 406 399 function bp_blogs_record_comment( $comment_id, $is_approved = true ) { 407 400 global $wpdb, $bp; … … 436 429 // If blog is public allow activity to be posted 437 430 if ( get_blog_option( $blog_id, 'blog_public' ) ) { 431 438 432 // Get activity related links 439 433 $post_permalink = get_permalink( $recorded_comment->comment_post_ID ); … … 441 435 442 436 // Prepare to record in activity streams 443 $activity_action 444 $activity_content 437 $activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' ); 438 $activity_content = $recorded_comment->comment_content; 445 439 446 440 // Record in activity streams … … 523 517 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 ); 524 518 525 function bp_blogs_remove_post( $post_id, $blog_id = false , $existing_post = false) {519 function bp_blogs_remove_post( $post_id, $blog_id = false ) { 526 520 global $current_blog, $bp; 527 521 … … 531 525 $blog_id = (int)$current_blog->blog_id; 532 526 533 if ( !$existing_post )534 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );535 536 // Delete post from the bp_blogs table537 BP_Blogs_Post::delete( $post_id, $blog_id );538 539 527 // Delete activity stream item 540 528 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) ); … … 546 534 function bp_blogs_remove_comment( $comment_id ) { 547 535 global $wpdb, $bp; 548 549 $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );550 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );551 536 552 537 // Delete activity stream item … … 585 570 /* If this is regular blog, delete all data for that blog. */ 586 571 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 587 BP_Blogs_Post::delete_posts_for_blog( $blog_id );588 BP_Blogs_Comment::delete_comments_for_blog( $blog_id );589 572 590 573 // Delete activity stream item … … 599 582 } 600 583 601 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_post' filter. */602 function bp_blogs_get_posts_for_user( $user_id ) {603 return BP_Blogs_Post::get_posts_for_user( $user_id );604 }605 606 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_comment' filter. */607 function bp_blogs_get_comments_for_user( $user_id ) {608 return BP_Blogs_Comment::get_comments_for_user( $user_id );609 }610 611 function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {612 global $bp;613 614 if ( !is_numeric( $limit ) )615 $limit = 5;616 617 return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );618 }619 620 584 function bp_blogs_get_all_blogs( $limit = null, $page = null ) { 621 585 return BP_Blogs_Blog::get_all( $limit, $page ); … … 626 590 } 627 591 628 function bp_blogs_get_all_posts( $limit = null, $page = null ) {629 return BP_Blogs_Post::get_all( $limit, $page );630 }631 632 function bp_blogs_total_post_count( $blog_id ) {633 return BP_Blogs_Post::total_post_count( $blog_id );634 }635 636 function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {637 return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );638 }639 640 592 function bp_blogs_is_blog_hidden( $blog_id ) { 641 593 return BP_Blogs_Blog::is_hidden( $blog_id ); … … 648 600 $blog = bp_blogs_get_random_blogs( 1, 1 ); 649 601 650 bp_core_redirect( get_ blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );602 bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) ); 651 603 } 652 604 } … … 664 616 global $wpdb, $bp; 665 617 666 if ( !is_numeric( $blog_id ) )618 if ( !is_numeric( $blog_id ) || !bp_core_is_multisite() ) 667 619 return false; 668 620 … … 692 644 $blog_id = (int) $blog_id; 693 645 694 if ( !$blog_id )646 if ( !$blog_id || !bp_core_is_multisite() ) 695 647 return false; 696 648 … … 724 676 global $wpdb, $bp; 725 677 726 if ( !is_numeric( $blog_id ) )678 if ( !is_numeric( $blog_id ) || !bp_core_is_multisite() ) 727 679 return false; 728 680 … … 754 706 755 707 function bp_blogs_remove_data( $user_id ) { 708 if ( !bp_core_is_multisite() ) 709 return false; 710 756 711 /* If this is regular blog, delete all data for that blog. */ 757 712 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 758 BP_Blogs_Post::delete_posts_for_user( $user_id );759 BP_Blogs_Comment::delete_comments_for_user( $user_id );760 713 761 714 do_action( 'bp_blogs_remove_data', $user_id ); 762 715 } 763 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 ); 764 add_action( 'delete_user', 'bp_blogs_remove_data', 1 ); 716 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 717 add_action( 'delete_user', 'bp_blogs_remove_data' ); 718 add_action( 'make_spam_user', 'bp_blogs_remove_data' ); 765 719 766 720 … … 789 743 } 790 744 791 function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {792 wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );793 }794 795 function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {796 bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );797 798 /* Clear the sitewide activity cache */799 wp_cache_delete( 'sitewide_activity', 'bp' );800 }801 802 function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {803 wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );804 }805 806 function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {807 bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );808 809 /* Clear the sitewide activity cache */810 wp_cache_delete( 'sitewide_activity', 'bp' );811 }812 813 745 // List actions to clear object caches on 814 746 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 ); 815 add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );816 add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );817 818 747 add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 ); 819 add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );820 add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );821 748 822 749 // List actions to clear super cached pages on, if super cache is installed -
trunk/bp-blogs/bp-blogs-classes.php
r3232 r3300 76 76 bp_blogs_setup_globals(); 77 77 78 if ( !is_user_logged_in() || ( !is_s ite_admin() && ( $user_id != $bp->loggedin_user->id ) ) )78 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 79 79 $hidden_sql = "AND wb.public = 1"; 80 80 … … 162 162 // Show logged in users their hidden blogs. 163 163 if ( !bp_is_my_profile() && !$show_hidden ) 164 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b. id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id ) );164 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) ); 165 165 else 166 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b. id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id ) );166 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) ); 167 167 168 168 $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id ); 169 169 170 170 foreach ( (array)$blogs as $blog ) { 171 $user_blogs[$blog->id] = new stdClass; 172 $user_blogs[$blog->id]->id = $blog->id; 173 $user_blogs[$blog->id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path; 174 $user_blogs[$blog->id]->name = $blog->name; 171 $user_blogs[$blog->blog_id] = new stdClass; 172 $user_blogs[$blog->blog_id]->id = $blog->id; 173 $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id; 174 $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path; 175 $user_blogs[$blog->blog_id]->name = $blog->name; 175 176 } 176 177 … … 209 210 210 211 // If the user is logged in return the blog count including their hidden blogs. 211 if ( ( is_user_logged_in() && $user_id == $bp->loggedin_user->id ) || is_s ite_admin() )212 if ( ( is_user_logged_in() && $user_id == $bp->loggedin_user->id ) || is_super_admin() ) 212 213 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) ); 213 214 else … … 223 224 $filter = like_escape( $wpdb->escape( $filter ) ); 224 225 225 if ( !is_s ite_admin() )226 if ( !is_super_admin() ) 226 227 $hidden_sql = "AND wb.public = 1"; 227 228 … … 241 242 bp_blogs_setup_globals(); 242 243 243 if ( !is_s ite_admin() )244 if ( !is_super_admin() ) 244 245 $hidden_sql = "AND wb.public = 1"; 245 246 … … 261 262 $letter = like_escape( $wpdb->escape( $letter ) ); 262 263 263 if ( !is_s ite_admin() )264 if ( !is_super_admin() ) 264 265 $hidden_sql = "AND wb.public = 1"; 265 266 … … 279 280 return $paged_blogs; 280 281 281 /* Fetch lastest post for each blog. */282 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) );283 284 282 for ( $i = 0; $i < count( $paged_blogs ); $i++ ) { 285 foreach ( (array)$post_ids as $post ) { 286 if ( $post->blog_id == $paged_blogs[$i]->blog_id ) { 287 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" ); 288 } 289 } 283 $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id ); 284 $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" ); 290 285 } 291 286 … … 316 311 } 317 312 318 /* DEPRECATED - Post DB recording is scheduled for removal. Please use the activity stream to fetch a user's posts. */319 Class BP_Blogs_Post {320 var $id;321 var $user_id;322 var $blog_id;323 var $post_id;324 var $date_created;325 326 function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {327 global $bp, $wpdb;328 329 if ( $id || ( !$id && $blog_id && $post_id ) ) {330 $this->id = $id;331 $this->blog_id = $blog_id;332 $this->post_id = $post_id;333 $this->populate();334 }335 }336 337 function populate() {338 global $wpdb, $bp;339 340 if ( $this->id )341 $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );342 else343 $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );344 345 $this->id = $post->id;346 $this->user_id = $post->user_id;347 $this->blog_id = $post->blog_id;348 $this->post_id = $post->post_id;349 $this->date_created = $post->date_created;350 }351 352 function save() {353 global $wpdb, $bp;354 355 $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );356 $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );357 $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );358 $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );359 360 do_action( 'bp_blogs_post_before_save', $this );361 362 if ( $this->id ) {363 // Update364 $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );365 } else {366 // Save367 $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );368 }369 370 if ( !$wpdb->query($sql) )371 return false;372 373 do_action( 'bp_blogs_post_after_save', $this );374 375 if ( $this->id )376 return $this->id;377 else378 return $wpdb->insert_id;379 }380 381 /* Static Functions */382 383 function delete( $post_id, $blog_id ) {384 global $wpdb, $bp, $current_user;385 386 if ( !$bp->blogs )387 bp_blogs_setup_globals();388 389 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );390 }391 392 function delete_oldest( $user_id = null ) {393 global $wpdb, $bp;394 395 if ( !$bp->blogs )396 bp_blogs_setup_globals();397 398 if ( !$user_id )399 $user_id = $current_user->ID;400 401 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );402 }403 404 function delete_posts_for_user( $user_id = null ) {405 global $wpdb, $bp;406 407 if ( !$bp->blogs )408 bp_blogs_setup_globals();409 410 if ( !$user_id )411 $user_id = $bp->loggedin_user->id;412 413 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );414 }415 416 function delete_posts_for_blog( $blog_id ) {417 global $wpdb, $bp;418 419 if ( !$bp->blogs )420 bp_blogs_setup_globals();421 422 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );423 }424 425 function get_latest_posts( $blog_id = null, $limit = 5 ) {426 global $wpdb, $bp;427 428 if ( !$bp->blogs )429 bp_blogs_setup_globals();430 431 if ( $blog_id )432 $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );433 434 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );435 436 for ( $i = 0; $i < count($post_ids); $i++ ) {437 $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);438 }439 440 return $posts;441 }442 443 function get_posts_for_user( $user_id = null ) {444 global $bp, $wpdb;445 446 if ( !$bp->blogs )447 bp_blogs_setup_globals();448 449 if ( !$user_id )450 $user_id = $bp->displayed_user->id;451 452 // Show a logged in user their posts on private blogs, but not anyone else.453 if ( !bp_is_my_profile() ) {454 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );455 $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );456 } else {457 $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );458 459 $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );460 }461 462 for ( $i = 0; $i < count($post_ids); $i++ ) {463 $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);464 }465 466 return array( 'posts' => $posts, 'count' => $total_post_count );467 }468 469 function fetch_post_content( $post_object ) {470 // TODO: switch_to_blog() calls are expensive and this needs to be changed.471 switch_to_blog( $post_object->blog_id );472 $post = get_post($post_object->post_id);473 $post->blog_id = $post_object->blog_id;474 restore_current_blog();475 476 return $post;477 }478 479 function get_total_recorded_for_user( $user_id = null ) {480 global $bp, $wpdb;481 482 if ( !$bp->blogs )483 bp_blogs_setup_globals();484 485 if ( !$user_id )486 $user_id = $current_user->ID;487 488 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );489 }490 491 function is_recorded( $post_id, $blog_id, $user_id = null ) {492 global $bp, $wpdb, $current_user;493 494 if ( !$bp->blogs )495 bp_blogs_setup_globals();496 497 if ( !$user_id )498 $user_id = $current_user->ID;499 500 return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );501 }502 503 function total_post_count( $blog_id ) {504 global $bp, $wpdb;505 506 if ( !$bp->blogs )507 bp_blogs_setup_globals();508 509 if ( !$blog_id )510 return false;511 512 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );513 }514 515 function get_all() {516 global $bp, $wpdb;517 518 if ( !$bp->blogs )519 bp_blogs_setup_globals();520 521 return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );522 }523 524 }525 526 /* DEPRECATED - Comment DB recording is scheduled for removal. Please use the activity stream to fetch a user's comments. */527 Class BP_Blogs_Comment {528 var $id;529 var $user_id;530 var $blog_id;531 var $comment_id;532 var $comment_post_id;533 var $date_created;534 535 function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {536 global $bp, $wpdb;537 538 if ( !$user_id )539 $user_id = $bp->displayed_user->id;540 541 if ( $id || ( !$id && $blog_id && $comment_id ) ) {542 $this->id = $id;543 $this->blog_id = $blog_id;544 $this->comment_id = $comment_id;545 $this->populate();546 }547 }548 549 function populate() {550 global $wpdb, $bp;551 552 if ( $this->id )553 $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );554 else555 $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );556 557 $this->comment_id = $comment->comment_id;558 $this->user_id = $comment->user_id;559 $this->blog_id = $comment->blog_id;560 $this->comment_post_id = $comment->comment_post_id;561 $this->date_created = $comment->date_created;562 }563 564 function save() {565 global $wpdb, $bp;566 567 $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );568 $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );569 $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );570 $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );571 $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );572 573 do_action( 'bp_blogs_comment_before_save', $this );574 575 if ( $this->id ) {576 // Update577 $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );578 } else {579 // Save580 $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created );581 }582 583 if ( !$wpdb->query($sql) )584 return false;585 586 do_action( 'bp_blogs_comment_after_save', $this );587 588 if ( $this->id )589 return $this->id;590 else591 return $wpdb->insert_id;592 }593 594 /* Static Functions */595 596 function delete( $comment_id, $blog_id ) {597 global $wpdb, $bp, $current_user;598 599 if ( !$bp->blogs )600 bp_blogs_setup_globals();601 602 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );603 }604 605 function delete_oldest( $user_id = null ) {606 global $wpdb, $bp, $current_user;607 608 if ( !$bp->blogs )609 bp_blogs_setup_globals();610 611 if ( !$user_id )612 $user_id = $current_user->ID;613 614 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );615 }616 617 function delete_comments_for_user( $user_id = null ) {618 global $wpdb, $bp;619 620 if ( !$bp->blogs )621 bp_blogs_setup_globals();622 623 if ( !$user_id )624 $user_id = $bp->loggedin_user->id;625 626 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );627 }628 629 function delete_comments_for_blog( $blog_id ) {630 global $wpdb, $bp;631 632 if ( !$bp->blogs )633 bp_blogs_setup_globals();634 635 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );636 }637 638 function get_comments_for_user( $user_id = null ) {639 global $bp, $wpdb;640 641 if ( !$bp->blogs )642 bp_blogs_setup_globals();643 644 if ( !$user_id )645 $user_id = $bp->displayed_user->id;646 647 // Show the logged in user their comments on hidden blogs, but not to anyone else.648 if ( !bp_is_my_profile() ) {649 $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );650 $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );651 } else {652 $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );653 654 $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );655 }656 657 for ( $i = 0; $i < count($comment_ids); $i++ )658 $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);659 660 return array( 'comments' => $comments, 'count' => $total_comment_count );661 }662 663 function fetch_comment_content( $comment_object ) {664 switch_to_blog($comment_object->blog_id);665 $comment = get_comment($comment_object->comment_id);666 $comment->blog_id = $comment_object->blog_id;667 $comment->post = &get_post( $comment->comment_post_ID );668 restore_current_blog();669 670 return $comment;671 }672 673 function get_total_recorded_for_user( $user_id = null ) {674 global $bp, $wpdb, $current_user;675 676 if ( !$bp->blogs )677 bp_blogs_setup_globals();678 679 if ( !$user_id )680 $user_id = $current_user->ID;681 682 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );683 }684 685 function total_comment_count( $blog_id, $post_id ) {686 global $bp, $wpdb;687 688 if ( !$bp->blogs )689 bp_blogs_setup_globals();690 691 if ( $post_id )692 $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );693 694 return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );695 }696 697 698 function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {699 global $bp, $wpdb, $current_user;700 701 if ( !$bp->blogs )702 bp_blogs_setup_globals();703 704 if ( !$user_id )705 $user_id = $current_user->ID;706 707 return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );708 }709 710 }711 712 313 ?> -
trunk/bp-blogs/bp-blogs-templatetags.php
r3263 r3300 22 22 23 23 $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page; 24 $this->pag_num 24 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 25 25 26 26 if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) … … 37 37 38 38 if ( $max ) { 39 if ( $max >= count( $this->blogs) ) {39 if ( $max >= count($this->blogs) ) { 40 40 $this->blog_count = count( $this->blogs ); 41 41 } else { … … 148 148 149 149 $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms ); 150 return $blogs_template->has_blogs();150 return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template ); 151 151 } 152 152 … … 166 166 global $bp, $blogs_template; 167 167 168 $from_num = bp_core_number_format( intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1 ); 169 $to_num = bp_core_number_format( ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) ); 168 $start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1; 169 $from_num = bp_core_number_format( $start_num ); 170 $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) ); 170 171 $total = bp_core_number_format( $blogs_template->total_blog_count ); 171 172 172 echo sprintf( __( 'Viewing blog % s to %s (of %s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> 173 echo sprintf( __( 'Viewing blog %1$s to %2$s (of %3$s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> 173 174 <span class="ajax-loader"></span><?php 174 175 } … … 270 271 function bp_blog_hidden_fields() { 271 272 if ( isset( $_REQUEST['s'] ) ) { 272 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';273 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ). '" name="search_terms" />'; 273 274 } 274 275 275 276 if ( isset( $_REQUEST['letter'] ) ) { 276 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';277 echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 277 278 } 278 279 279 280 if ( isset( $_REQUEST['blogs_search'] ) ) { 280 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';281 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['blogs_search'] ) . '" name="search_terms" />'; 281 282 } 282 283 } … … 347 348 348 349 <input type="hidden" name="stage" value="gimmeanotherblog" /> 349 <?php do_action( "signup_hidden_fields"); ?>350 <?php do_action( 'signup_hidden_fields' ); ?> 350 351 351 352 <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?> … … 364 365 365 366 // Blog name 366 if( 'no' == constant( "VHOST") )367 if( !is_subdomain_install() ) 367 368 echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>'; 368 369 else … … 373 374 <?php } 374 375 375 if ( 'no' == constant( "VHOST" ) ) {376 if ( !is_subdomain_install() ) 376 377 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />'; 377 } else {378 else 378 379 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /> <span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />'; 379 } 380 380 381 if ( !is_user_logged_in() ) { 381 382 print '(<strong>' . __( 'Your address will be ' , 'buddypress'); 382 if( 'no' == constant( "VHOST" ) ) { 383 384 if ( !is_subdomain_install() ) { 383 385 print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress'); 384 386 } else { 385 387 print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path; 386 388 } 389 387 390 echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>'; 388 391 } … … 476 479 477 480 function bp_blogs_blog_tabs() { 478 global $bp ;481 global $bp, $groups_template; 479 482 480 483 // Don't show these tabs on a user's own profile -
trunk/bp-blogs/bp-blogs-widgets.php
r2698 r3300 22 22 global $bp; 23 23 24 24 extract( $args ); 25 25 26 26 echo $before_widget; 27 echo $before_title 28 . $widget_name 29 . $after_title; ?> 27 echo $before_title . $widget_name . $after_title; 30 28 31 <?php32 29 if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] ) 33 30 $instance['max_posts'] = 10; ?> … … 81 78 ?> 82 79 83 <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo attribute_escape( $max_posts ); ?>" style="width: 30%" /></label></p>80 <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p> 84 81 <?php 85 82 } -
trunk/bp-core.php
r3242 r3300 30 30 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' ); 31 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' ); 32 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' ); 33 34 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' ); … … 65 66 */ 66 67 function bp_core_setup_globals() { 67 global $bp , $wpdb;68 global $bp; 68 69 global $current_user, $current_component, $current_action, $current_blog; 69 70 global $displayed_user_id, $bp_pages; … … 72 73 $current_user = wp_get_current_user(); 73 74 75 /* Get the base database prefix */ 76 $bp->table_prefix = bp_core_get_table_prefix(); 77 74 78 /* The domain for the root of the site where the main blog resides */ 75 79 $bp->root_domain = bp_core_get_root_domain(); 76 77 /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */78 $bp->active_components = array();79 80 80 81 /* The names of the core WordPress pages used to display BuddyPress content */ … … 95 96 $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id ); 96 97 97 /* is_site_admin() hits the DB on single WP installs, so we need to get this separately so we can call it in a loop. */ 98 $bp->loggedin_user->is_site_admin = is_site_admin(); 98 /* is_super_admin() hits the DB on single WP installs, so we need to get this separately so we can call it in a loop. */ 99 $bp->loggedin_user->is_super_admin = is_super_admin(); 100 $bp->loggedin_user->is_site_admin = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6 99 101 100 102 /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */ … … 141 143 $bp->bp_options_nav = array(); 142 144 145 /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */ 146 $bp->active_components = array(); 147 143 148 /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */ 144 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );149 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] ); 145 150 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' ); 146 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );151 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' ); 147 152 148 153 /* Fetch the full name for the logged in and current user */ 149 $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );154 $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id ); 150 155 $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id ); 151 156 … … 154 159 generic variable so it can be used by other components. It can also be modified, so when viewing a group 155 160 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */ 156 $bp->is_item_admin = bp_ is_my_profile();161 $bp->is_item_admin = bp_user_has_access(); 157 162 158 163 /* Used to determine if the logged in user is a moderator for the current content. */ 159 164 $bp->is_item_mod = false; 160 165 161 $bp->core->table_name_notifications = $ wpdb->base_prefix . 'bp_notifications';166 $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications'; 162 167 163 168 if ( !$bp->current_component && $bp->displayed_user->id ) … … 169 174 170 175 /** 176 * bp_core_get_table_prefix() 177 * 178 * Allow filtering of database prefix. Intended for use in multinetwork installations. 179 * 180 * @global object $wpdb WordPress database object 181 * @return string Filtered database prefix 182 */ 183 function bp_core_get_table_prefix() { 184 global $wpdb; 185 186 return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix ); 187 } 188 189 /** 171 190 * bp_core_define_slugs() 172 191 * … … 188 207 if ( !defined( 'BP_ACTIVATION_SLUG' ) ) 189 208 define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug ); 209 210 if ( !defined( 'BP_SEARCH_SLUG' ) ) 211 define( 'BP_SEARCH_SLUG', 'search' ); 190 212 } 191 213 add_action( 'bp_setup_globals', 'bp_core_define_slugs' ); … … 231 253 } 232 254 233 234 255 /** 235 256 * bp_core_admin_menu_init() … … 238 259 * 239 260 * @package BuddyPress Core 240 * @uses is_s ite_admin() returns true if the current user is a site admin, false if not261 * @uses is_super_admin() returns true if the current user is a site admin, false if not 241 262 */ 242 263 function bp_core_admin_menu_init() { 243 if ( !is_s ite_admin() )264 if ( !is_super_admin() ) 244 265 return false; 245 266 … … 255 276 * @package BuddyPress Core 256 277 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 257 * @global $wpdb WordPress DB access object. 258 * @uses is_site_admin() returns true if the current user is a site admin, false if not 278 * @uses is_super_admin() returns true if the current user is a site admin, false if not 259 279 * @uses add_submenu_page() WP function to add a submenu item 260 280 */ 261 281 function bp_core_add_admin_menu() { 262 if ( !is_s ite_admin() )282 if ( !is_super_admin() ) 263 283 return false; 264 284 … … 280 300 add_action( 'admin_menu', 'bp_core_add_admin_menu' ); 281 301 302 /** 303 * bp_core_is_root_component() 304 * 305 * Checks to see if a component's URL should be in the root, not under a member page: 306 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group 307 * 308 * @package BuddyPress Core 309 * @return true if root component, else false. 310 */ 311 function bp_core_is_root_component( $component_name ) { 312 global $bp; 313 314 foreach ( (array) $bp->pages as $key => $page ) { 315 if ( $key == $component_name || $page->slug == $component_name ) 316 return true; 317 } 318 319 return false; 320 } 282 321 283 322 /** … … 380 419 */ 381 420 function bp_core_action_set_spammer_status() { 382 global $bp, $wpdb ;383 384 if ( !is_s ite_admin() || bp_is_my_profile() || !$bp->displayed_user->id )421 global $bp, $wpdb, $wp_version; 422 423 if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id ) 385 424 return false; 386 425 … … 390 429 391 430 /* Get the functions file */ 392 if ( file_exists( ABSPATH . 'wp-admin/includes/mu.php' ) &&bp_core_is_multisite() )393 require ( ABSPATH . 'wp-admin/includes/mu.php' );431 if ( bp_core_is_multisite() ) 432 require_once( ABSPATH . 'wp-admin/includes/ms.php' ); 394 433 395 434 if ( 'mark-spammer' == $bp->current_action ) … … 446 485 global $bp; 447 486 448 if ( !is_s ite_admin() || bp_is_my_profile() || !$bp->displayed_user->id )487 if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id ) 449 488 return false; 450 489 … … 462 501 } 463 502 464 do_action( 'bp_core_action_ set_spammer_status', $errors );503 do_action( 'bp_core_action_delete_user', $errors ); 465 504 466 505 if ( $errors ) … … 472 511 add_action( 'wp', 'bp_core_action_delete_user', 3 ); 473 512 513 474 514 /******************************************************************************** 475 515 * Business Functions … … 496 536 'search_terms' => false, // Limit to users that match these search terms 497 537 538 'include' => false, // Pass comma separated list of user_ids to limit to only these users 498 539 'per_page' => 20, // The number of results to return per page 499 540 'page' => 1, // The page to return if limiting per page … … 504 545 extract( $params, EXTR_SKIP ); 505 546 506 return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $ search_terms, $populate_extras ), &$params );547 return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &$params ); 507 548 } 508 549 … … 516 557 * @global $current_user WordPress global variable containing current logged in user information 517 558 * @param user_id The ID of the user. 518 * @uses get_user meta() WordPress function to get the usermeta for a user.559 * @uses get_user_meta() WordPress function to get the usermeta for a user. 519 560 */ 520 561 function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) { … … 574 615 575 616 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) 576 $domain = get_blog_option( $current_blog->blog_id, ' siteurl' );617 $domain = get_blog_option( $current_blog->blog_id, 'home' ); 577 618 else 578 $domain = get_blog_option( BP_ROOT_BLOG, ' siteurl' );619 $domain = get_blog_option( BP_ROOT_BLOG, 'home' ); 579 620 580 621 return apply_filters( 'bp_core_get_root_domain', $domain ); … … 626 667 627 668 /* If this is for site admins only and the user is not one, don't create the subnav item */ 628 if ( $site_admin_only && !is_s ite_admin() )669 if ( $site_admin_only && !is_super_admin() ) 629 670 return false; 630 671 … … 647 688 * looking at their own profile, don't create the nav item. 648 689 */ 649 if ( !$show_for_displayed_user && !bp_ is_my_profile() )690 if ( !$show_for_displayed_user && !bp_user_has_access() ) 650 691 return false; 651 692 … … 654 695 * default subnav function so we can display a directory or something else. 655 696 */ 656 if ( !$bp->displayed_user->id )697 if ( bp_core_is_root_component( $slug ) && !$bp->displayed_user->id ) 657 698 return; 658 699 … … 773 814 774 815 /* If this is for site admins only and the user is not one, don't create the subnav item */ 775 if ( $site_admin_only && !is_s ite_admin() )816 if ( $site_admin_only && !is_super_admin() ) 776 817 return false; 777 818 … … 868 909 global $bp; 869 910 870 if ( $function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) { 871 if ( !is_object( $function[0] ) ) 872 remove_action( 'wp', $function, 3 ); 911 $screen_function = $bp->bp_options_nav[$parent_id][$slug]['screen_function']; 912 913 if ( $screen_function ) { 914 if ( !is_object( $screen_function[0] ) ) 915 remove_action( 'wp', $screen_function, 3 ); 873 916 else 874 remove_action( 'wp', array( &$ function[0], $function[1] ), 3 );917 remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 ); 875 918 } 876 919 … … 898 941 /** 899 942 * bp_core_get_random_member() 943 * 944 * Returns the user_id for a user based on their username. 945 * 946 * @package BuddyPress Core 947 * @param $username str Username to check. 948 * @return false on no match 949 * @return int the user ID of the matched user. 950 */ 951 function bp_core_get_random_member() { 952 global $bp; 953 954 if ( isset( $_GET['random-member'] ) ) { 955 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) ); 956 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) ); 957 } 958 } 959 add_action( 'wp', 'bp_core_get_random_member' ); 960 961 /** 962 * bp_core_get_userid() 900 963 * 901 964 * Returns the user_id for a user based on their username. … … 907 970 * @return int the user ID of the matched user. 908 971 */ 909 function bp_core_get_random_member() {910 global $bp, $wpdb;911 912 if ( isset( $_GET['random-member'] ) ) {913 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );914 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );915 }916 }917 add_action( 'wp', 'bp_core_get_random_member' );918 919 /**920 * bp_core_get_userid()921 *922 * Returns the user_id for a user based on their username.923 *924 * @package BuddyPress Core925 * @param $username str Username to check.926 * @global $wpdb WordPress DB access object.927 * @return false on no match928 * @return int the user ID of the matched user.929 */930 972 function bp_core_get_userid( $username ) { 931 973 global $wpdb; 932 974 933 if ( !empty( $username ) ) 934 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 975 if ( empty( $username ) ) 976 return false; 977 978 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 935 979 } 936 980 … … 1119 1163 } 1120 1164 1121 return apply_filters( 'bp_core_get_user_displayname', $fullname );1165 return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id ); 1122 1166 } 1123 1167 add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 ); … … 1215 1259 1216 1260 /** 1217 * bp_core_format_time() 1218 */ 1219 function bp_core_format_time( $time, $just_date = false ) { 1220 if ( !$time ) 1221 return false; 1222 1223 $date = date( "F j, Y ", $time ); 1224 1225 if ( !$just_date ) { 1226 $date .= __('at', 'buddypress') . date( ' g:iA', $time ); 1227 } 1228 1229 return $date; 1261 * bp_core_current_time() 1262 * 1263 * Get the current GMT time to save into the DB 1264 * 1265 * @package BuddyPress Core 1266 * @since 1.2.6 1267 */ 1268 function bp_core_current_time( $gmt = true ) { 1269 // Get current time in MYSQL format 1270 $current_time = current_time( 'mysql', $gmt ); 1271 1272 return apply_filters( 'bp_core_current_time', $current_time ); 1230 1273 } 1231 1274 … … 1283 1326 @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 1284 1327 } 1285 add_action( 'bp_init', 'bp_core_setup_message' ); 1286 1328 add_action( 'wp', 'bp_core_setup_message', 2 ); 1287 1329 1288 1330 /** … … 1302 1344 ?> 1303 1345 <div id="message" class="<?php echo $type; ?>"> 1304 <p><?php echo stripslashes( attribute_escape( $bp->template_message ) ); ?></p>1346 <p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p> 1305 1347 </div> 1306 1348 <?php … … 1326 1368 */ 1327 1369 function bp_core_time_since( $older_date, $newer_date = false ) { 1370 1328 1371 // array of time period chunks 1329 1372 $chunks = array( 1330 array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),1331 array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),1332 array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),1333 array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),1334 array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),1335 array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),1336 array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )1373 array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ), 1374 array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ), 1375 array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ), 1376 array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ), 1377 array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ), 1378 array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ), 1379 array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) ) 1337 1380 ); 1338 1381 … … 1346 1389 /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */ 1347 1390 /* $newer_date will have a value if we want to work out time elapsed between two known dates */ 1348 $newer_date = ( !$newer_date ) ? gmmktime( gmdate( 'H' ), gmdate( 'i' ), gmdate( 's' ), gmdate( 'n' ), gmdate( 'j' ), gmdate( 'Y') ) : $newer_date;1391 $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date; 1349 1392 1350 1393 /* Difference in seconds */ … … 1381 1424 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 1382 1425 /* Add to output var */ 1383 $output .= ( 1 == $count2 ) ? _ c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];1426 $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2]; 1384 1427 } 1385 1428 } … … 1401 1444 * @package BuddyPress Core 1402 1445 * @global $userdata WordPress user data for the current logged in user. 1403 * @uses update_user meta() WordPress function to update user metadata in the usermeta table.1446 * @uses update_user_meta() WordPress function to update user metadata in the usermeta table. 1404 1447 */ 1405 1448 function bp_core_record_activity() { … … 1409 1452 return false; 1410 1453 1411 $activity = get_user meta( $bp->loggedin_user->id, 'last_activity');1454 $activity = get_user_meta( $bp->loggedin_user->id, 'last_activity', true ); 1412 1455 1413 1456 if ( !is_numeric( $activity ) ) 1414 1457 $activity = strtotime( $activity ); 1415 1458 1416 if ( '' == $activity || strtotime( gmdate( "Y-m-d H:i:s" ) ) >= strtotime( '+5 minutes', $activity ) ) 1417 update_usermeta( $bp->loggedin_user->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); 1459 // Get current time 1460 $current_time = bp_core_current_time(); 1461 1462 if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) ) 1463 update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time ); 1418 1464 } 1419 1465 add_action( 'wp_head', 'bp_core_record_activity' ); … … 1446 1492 return $number; 1447 1493 1448 return apply_filters( 'bp_core_ bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );1494 return apply_filters( 'bp_core_number_format', number_format( $number, $decimals ), $number, $decimals ); 1449 1495 } 1450 1496 … … 1474 1520 * 1475 1521 * @package BuddyPress Core 1476 * @global $comment WordPress comment global for the current comment. 1477 * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address. 1522 * 1523 * @global $bp $bp 1524 * @global object $current_site 1525 * @return string 1478 1526 */ 1479 1527 function bp_core_get_site_path() { … … 1493 1541 unset( $site_path[2] ); 1494 1542 1495 $site_path = '/' . implode( '/', $site_path ) . '/'; 1543 if ( !count( $site_path ) ) 1544 $site_path = '/'; 1545 else 1546 $site_path = '/' . implode( '/', $site_path ) . '/'; 1496 1547 } 1497 1548 } … … 1536 1587 1537 1588 if ( bp_core_is_multisite() ) 1538 $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) " );1589 $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" ); 1539 1590 else 1540 1591 $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" ); … … 1563 1614 1564 1615 // Make sure we don't call status_header() in bp_core_do_catch_uri() 1565 1616 // as this conflicts with wp_redirect() 1566 1617 $bp_no_status_set = true; 1567 1618 … … 1616 1667 1617 1668 /** 1618 * bp_core_email_from_name_filter()1619 *1620 * Sets the "From" name in emails sent to the name of the site and not "WordPress"1621 *1622 * @package BuddyPress Core1623 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table1624 * @return The blog name for the root blog1625 */1626 function bp_core_email_from_name_filter() {1627 return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );1628 }1629 add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );1630 1631 1632 /**1633 * bp_core_email_from_name_filter()1634 *1635 * Sets the "From" address in emails sent1636 *1637 * @package BuddyPress Core1638 * @global $current_site Object containing current site metadata1639 * @return noreply@sitedomain email address1640 */1641 function bp_core_email_from_address_filter() {1642 $domain = (array) explode( '/', site_url() );1643 1644 return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );1645 }1646 add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );1647 1648 /**1649 1669 * bp_core_delete_account() 1650 1670 * … … 1653 1673 * @package BuddyPress Core 1654 1674 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1655 * @uses is_s ite_admin() Checks to see if the user is a site administrator.1675 * @uses is_super_admin() Checks to see if the user is a site administrator. 1656 1676 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs. 1657 1677 * @uses wp_delete_user() Deletes a user from the system on singlesite installs. … … 1744 1764 function bp_core_ucfirst( $str ) { 1745 1765 if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) { 1746 1747 1766 $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) ); 1767 return $fc.mb_substr( $str, 1 ); 1748 1768 } else { 1749 1769 return ucfirst( $str ); … … 1792 1812 */ 1793 1813 function bp_core_print_generation_time() { 1794 global $wpdb; 1795 ?> 1814 ?> 1796 1815 1797 1816 <!-- Generated in <?php timer_stop(1); ?> seconds. (<?php echo get_num_queries(); ?> q) --> … … 1866 1885 $user = get_userdatabylogin( $username ); 1867 1886 1868 if ( ( int)$user->spam)1887 if ( ( bp_core_is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status ) 1869 1888 bp_core_redirect( $bp->root_domain ); 1870 1889 else … … 1880 1899 * @package BuddyPress Core 1881 1900 * @param $user_id The user id for the user to delete usermeta for 1882 * @uses delete_user meta() deletes a row from the wp_usermeta table based on meta_key1901 * @uses delete_user_meta() deletes a row from the wp_usermeta table based on meta_key 1883 1902 */ 1884 1903 function bp_core_remove_data( $user_id ) { 1885 1904 /* Remove usermeta */ 1886 delete_user meta( $user_id, 'last_activity' );1905 delete_user_meta( $user_id, 'last_activity' ); 1887 1906 1888 1907 /* Flush the cache to remove the user from all cached objects */ 1889 1908 wp_cache_flush(); 1890 1909 } 1891 add_action( 'wpmu_delete_user', 'bp_core_remove_data' , 1);1892 add_action( 'delete_user', 'bp_core_remove_data' , 1);1893 add_action( 'make_spam_user', 'bp_core_remove_data' , 1);1910 add_action( 'wpmu_delete_user', 'bp_core_remove_data' ); 1911 add_action( 'delete_user', 'bp_core_remove_data' ); 1912 add_action( 'make_spam_user', 'bp_core_remove_data' ); 1894 1913 1895 1914 /** … … 1907 1926 load_textdomain( 'buddypress', $mofile ); 1908 1927 } 1909 add_action ( ' plugins_loaded', 'bp_core_load_buddypress_textdomain', 5);1928 add_action ( 'bp_loaded', 'bp_core_load_buddypress_textdomain', 2 ); 1910 1929 1911 1930 function bp_core_add_ajax_hook() { … … 1929 1948 1930 1949 /** 1931 * bp_core_filter_parent_theme()1932 *1933 * Remove social network parent theme from the theme list.1934 *1935 * @package BuddyPress Core1936 */1937 function bp_core_filter_parent_theme() {1938 global $wp_themes, $pagenow;1939 1940 if ( is_admin() && 'themes.php' == $pagenow )1941 $wp_themes = get_themes();1942 1943 unset( $wp_themes['BuddyPress Classic Parent'] );1944 }1945 add_filter( 'admin_menu', 'bp_core_filter_parent_theme' );1946 1947 /**1948 * bp_core_allow_default_theme()1949 *1950 * On multiblog installations you must first allow themes to be activated and show1951 * up on the theme selection screen. This function will let the BuddyPress bundled1952 * themes show up on the root blog selection screen and bypass this step. It also1953 * means that the themes won't show for selection on other blogs.1954 *1955 * @package BuddyPress Core1956 */1957 function bp_core_allow_default_theme( $themes ) {1958 global $bp, $current_blog;1959 1960 if ( !is_site_admin() )1961 return $themes;1962 1963 if ( $current_blog->ID == $bp->root_blog ) {1964 $themes['bp-default'] = 1;1965 $themes['bp-classic'] = 1;1966 }1967 1968 return $themes;1969 }1970 add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );1971 1972 /**1973 1950 * bp_core_activation_notice() 1974 1951 * … … 1985 1962 return false; 1986 1963 1987 if ( !is_s ite_admin() )1964 if ( !is_super_admin() ) 1988 1965 return false; 1989 1966 … … 2011 1988 add_action( 'admin_notices', 'bp_core_activation_notice' ); 2012 1989 2013 2014 /** 2015 * bp_core_filter_comments() 2016 * 2017 * Filter the blog post comments array and insert BuddyPress URLs for users. 2018 * 2019 * @package BuddyPress Core 2020 */ 2021 function bp_core_filter_comments( $comments, $post_id ) { 2022 global $wpdb; 2023 2024 foreach( (array)$comments as $comment ) { 2025 if ( $comment->user_id ) 2026 $user_ids[] = $comment->user_id; 2027 } 2028 2029 if ( empty( $user_ids ) ) 2030 return $comments; 2031 2032 $user_ids = implode( ',', $user_ids ); 2033 2034 if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) ) 2035 return $comments; 2036 2037 foreach( (array)$userdata as $user ) 2038 $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login ); 2039 2040 foreach( (array)$comments as $i => $comment ) { 2041 if ( !empty( $comment->user_id ) ) { 2042 if ( !empty( $users[$comment->user_id] ) ) 2043 $comments[$i]->comment_author_url = $users[$comment->user_id]; 1990 /** 1991 * bp_core_activate_site_options() 1992 * 1993 * When switching from single to multisite we need to copy blog options to 1994 * site options. 1995 * 1996 * @package BuddyPress Core 1997 */ 1998 function bp_core_activate_site_options( $keys = array() ) { 1999 global $bp; 2000 2001 if ( !empty( $keys ) && is_array( $keys ) ) { 2002 $errors = false; 2003 2004 foreach ( $keys as $key => $default ) { 2005 if ( empty( $bp->site_options[ $key ] ) ) { 2006 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default ); 2007 2008 if ( !update_site_option( $key, $bp->site_options[ $key ] ) ) 2009 $errors = true; 2010 } 2044 2011 } 2045 } 2046 2047 return $comments; 2048 } 2049 add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 ); 2050 2051 2052 /** 2053 * bp_core_login_redirect() 2054 * 2055 * When a user logs in, always redirect them back to the previous page. NOT the admin area. 2056 * 2057 * @package BuddyPress Core 2058 */ 2059 function bp_core_login_redirect( $redirect_to ) { 2060 global $bp, $current_blog; 2061 2062 if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG ) 2063 return $redirect_to; 2064 2065 if ( !empty( $_REQUEST['redirect_to'] ) || strpos( $_REQUEST['redirect_to'], 'wp-admin' ) ) 2066 return $redirect_to; 2067 2068 if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) ) 2069 return wp_get_referer(); 2070 2071 return $bp->root_domain; 2072 } 2073 add_filter( 'login_redirect', 'bp_core_login_redirect' ); 2074 2012 2013 if ( empty( $errors ) ) 2014 return true; 2015 } 2016 2017 return false; 2018 } 2075 2019 2076 2020 /******************************************************************************** … … 2080 2024 * hook in to. 2081 2025 */ 2082 2083 /* Allow core components and dependent plugins to set globals */ 2026 2027 /** 2028 * bp_include() 2029 * 2030 * Allow plugins to include their files ahead of core filters 2031 */ 2032 function bp_include() { 2033 do_action( 'bp_include' ); 2034 } 2035 add_action( 'bp_loaded', 'bp_include', 2 ); 2036 2037 /** 2038 * bp_setup_root_components() 2039 * 2040 * Allow core components and dependent plugins to set root components 2041 */ 2042 function bp_setup_root_components() { 2043 do_action( 'bp_setup_root_components' ); 2044 } 2045 add_action( 'bp_loaded', 'bp_setup_root_components', 2 ); 2046 2047 /** 2048 * bp_setup_globals() 2049 * 2050 * Allow core components and dependent plugins to set globals 2051 */ 2084 2052 function bp_setup_globals() { 2085 2053 do_action( 'bp_setup_globals' ); 2086 2054 } 2087 add_action( 'plugins_loaded', 'bp_setup_globals', 5 ); 2088 2089 /* Allow core components and dependent plugins to set root components */ 2090 function bp_setup_root_components() { 2091 do_action( 'bp_setup_root_components' ); 2092 } 2093 add_action( 'plugins_loaded', 'bp_setup_root_components', 2 ); 2094 2095 /* Allow core components and dependent plugins to set their nav */ 2055 add_action( 'bp_loaded', 'bp_setup_globals', 6 ); 2056 2057 /** 2058 * bp_setup_nav() 2059 * 2060 * Allow core components and dependent plugins to set their nav 2061 */ 2096 2062 function bp_setup_nav() { 2097 2063 do_action( 'bp_setup_nav' ); … … 2099 2065 add_action( 'bp_loaded', 'bp_setup_nav', 8 ); 2100 2066 2101 /* Allow core components and dependent plugins to register widgets */ 2067 /** 2068 * bp_setup_widgets() 2069 * 2070 * Allow core components and dependent plugins to register widgets 2071 */ 2102 2072 function bp_setup_widgets() { 2103 2073 do_action( 'bp_register_widgets' ); 2104 2074 } 2105 add_action( 'plugins_loaded', 'bp_setup_widgets' ); 2075 add_action( 'bp_loaded', 'bp_setup_widgets', 8 ); 2076 2077 /** 2078 * bp_init() 2079 * 2080 * Allow components to initialize themselves cleanly 2081 */ 2082 function bp_init() { 2083 do_action( 'bp_init' ); 2084 } 2085 add_action( 'bp_loaded', 'bp_init' ); 2106 2086 2107 2087 … … 2112 2092 * actions throughout BuddyPress. 2113 2093 */ 2094 2095 /** 2096 * bp_core_add_global_group() 2097 * 2098 * Add's 'bp' to global group of network wide cachable objects 2099 * 2100 * @package BuddyPress Core 2101 */ 2102 function bp_core_add_global_group() { 2103 wp_cache_init(); 2104 2105 if ( function_exists( 'wp_cache_add_global_groups' ) ) 2106 wp_cache_add_global_groups( array( 'bp' ) ); 2107 } 2108 add_action( 'init', 'bp_core_add_global_group' ); 2114 2109 2115 2110 /** … … 2184 2179 update_site_option( 'bp-pages', $page_ids ); 2185 2180 } 2186 2187 function bp_core_is_root_component( $component_name ) {2188 global $bp;2189 2190 foreach ( (array) $bp->pages as $key => $page ) {2191 if ( $key == $component_name || $page->slug == $component_name )2192 return true;2193 }2194 2195 return false;2196 }2197 2198 2181 ?> -
trunk/bp-core/bp-core-adminbar.php
r3232 r3300 109 109 } 110 110 111 echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/ my-blogs">';111 echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">'; 112 112 113 113 _e( 'My Blogs', 'buddypress' ); -
trunk/bp-core/bp-core-avatars.php
r3232 r3300 479 479 function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) { 480 480 global $pagenow; 481 481 482 482 // Do not filter if inside WordPress options page 483 483 if ( 'options-discussion.php' == $pagenow ) 484 484 return $avatar; 485 485 486 486 // If passed an object, assume $user->user_id 487 487 if ( is_object( $user ) ) -
trunk/bp-core/bp-core-catchuri.php
r3234 r3300 43 43 } 44 44 45 // Ajax or not? 45 46 if ( strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) ) 46 47 $path = bp_core_referrer(); 47 48 else 48 $path = clean_url( $_SERVER['REQUEST_URI'] );49 $path = esc_url( $_SERVER['REQUEST_URI'] ); 49 50 50 51 $path = apply_filters( 'bp_uri', $path ); 51 52 52 // Firstly, take GET variables off the URL to avoid problems,53 // they are still registered in the global $_GET variable */53 // Take GET variables off the URL to avoid problems, 54 // they are still registered in the global $_GET variable 54 55 $noget = substr( $path, 0, strpos( $path, '?' ) ); 55 if ( $noget != '' ) $path = $noget; 56 57 /* Fetch the current URI and explode each part separated by '/' into an array */ 56 if ( $noget != '' ) 57 $path = $noget; 58 59 // Fetch the current URI and explode each part separated by '/' into an array 58 60 $bp_uri = explode( "/", $path ); 59 61 60 / * Loop and remove empties */62 // Loop and remove empties 61 63 foreach ( (array)$bp_uri as $key => $uri_chunk ) 62 64 if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] ); 63 65 64 if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) { 65 /* If we are running BuddyPress on any blog, not just a root blog, we need to first 66 shift off the blog name if we are running a subdirectory install of WPMU. */ 67 if ( $current_blog->path != '/' ) 68 array_shift( $bp_uri ); 69 } 70 71 /* Set the indexes, these are incresed by one if we are not on a VHOST install */ 72 $component_index = 0; 73 $action_index = $component_index + 1; 74 75 /* Get site path items */ 66 // Running off blog other than root 67 if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) { 68 69 // Any subdirectory names must be removed from $bp_uri. 70 // This includes two cases: (1) when WP is installed in a subdirectory, 71 // and (2) when BP is running on secondary blog of a subdirectory 72 // multisite installation. Phew! 73 if ( $chunks = explode( '/', $current_blog->path ) ) { 74 foreach( $chunks as $key => $chunk ) { 75 $bkey = array_search( $chunk, $bp_uri ); 76 77 if ( $bkey !== false ) 78 unset( $bp_uri[$bkey] ); 79 80 $bp_uri = array_values( $bp_uri ); 81 } 82 } 83 } 84 85 // Set the indexes, these are incresed by one if we are not on a VHOST install 86 $component_index = 0; 87 $action_index = $component_index + 1; 88 89 // Get site path items 76 90 $paths = explode( '/', bp_core_get_site_path() ); 77 91 78 / * Take empties off the end of path */92 // Take empties off the end of path 79 93 if ( empty( $paths[count($paths) - 1] ) ) 80 94 array_pop( $paths ); 81 95 82 / * Take empties off the start of path */96 // Take empties off the start of path 83 97 if ( empty( $paths[0] ) ) 84 98 array_shift( $paths ); … … 90 104 } 91 105 92 / * Reset the keys by merging with an empty array */93 $bp_uri 94 $bp_unfiltered_uri = $bp_uri;95 96 / * Find a match within registered BuddyPress controlled WP pages (check members first) */106 // Reset the keys by merging with an empty array 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 109 110 // Find a match within registered BuddyPress controlled WP pages (check members first) 97 111 foreach ( (array)$bp_pages as $page_key => $bp_page ) { 98 112 if ( in_array( $bp_page->name, (array)$bp_uri ) ) { 99 / * Match found, now match the slug to make sure. */113 // Match found, now match the slug to make sure. 100 114 $uri_chunks = explode( '/', $bp_page->slug ); 101 115 … … 120 134 } 121 135 122 / * This is not a BuddyPress page, so just return. */136 // This is not a BuddyPress page, so just return. 123 137 if ( in_array( 0, (array) $matches ) ) 124 138 return false; 125 139 126 / * Find the offset */140 // Find the offset 127 141 $uri_offset = 0; 128 142 $slug = explode( '/', $match->slug ); … … 133 147 } 134 148 135 / * Global the unfiltered offset to use in bp_core_load_template() */149 // Global the unfiltered offset to use in bp_core_load_template() 136 150 $bp_unfiltered_uri_offset = $uri_offset; 137 151 138 / * This is a members page so lets check if we have a displayed member */152 // This is a members page so lets check if we have a displayed member 139 153 if ( 'members' == $match->key ) { 140 154 if ( !empty( $bp_uri[$uri_offset + 1] ) ) { … … 146 160 $uri_offset = $uri_offset + 2; 147 161 148 / * Remove everything from the URI up to the offset and take it from there. */162 // Remove everything from the URI up to the offset and take it from there. 149 163 for ( $i = 0; $i < $uri_offset; $i++ ) 150 164 unset( $bp_uri[$i] ); … … 154 168 } 155 169 156 / * Reset the keys by merging with an empty array */170 // Reset the keys by merging with an empty array 157 171 $bp_uri = array_merge( array(), $bp_uri ); 158 172 159 / * Set the current component */173 // Set the current component 160 174 if ( empty( $current_component ) ) { 161 175 for ( $i = 0; $i <= $uri_offset; $i++ ) { … … 170 184 $i = 1; 171 185 172 / * Set the current action */186 // Set the current action 173 187 $current_action = $bp_uri[$i]; 174 188 175 / * Unset the current_component and action from action_variables */189 // Unset the current_component and action from action_variables 176 190 for ( $j = 0; $j <= $i; $j++ ) 177 191 unset( $bp_uri[$j] ); 178 192 179 / * Set the entire URI as the action variables, we will unset the current_component and action in a second */193 // Set the entire URI as the action variables, we will unset the current_component and action in a second 180 194 $action_variables = $bp_uri; 181 195 182 / * Remove the username from action variables if this is not a VHOST install */196 // Remove the username from action variables if this is not a VHOST install 183 197 if ( 'no' == VHOST && !$is_root_component ) 184 198 array_shift($bp_uri); 185 199 186 / * Reset the keys by merging with an empty array */200 // Reset the keys by merging with an empty array 187 201 $action_variables = array_merge( array(), $action_variables ); 188 189 //var_dump($current_component, $current_action, $bp_uri);190 202 } 191 add_action( ' plugins_loaded', 'bp_core_set_uri_globals', 3);203 add_action( 'bp_loaded', 'bp_core_set_uri_globals', 4 ); 192 204 193 205 /** -
trunk/bp-core/bp-core-classes.php
r3267 r3300 51 51 * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text 52 52 * @uses bp_core_get_user_email() Returns the email address for the user based on user ID 53 * @uses get_user meta() WordPress function returns the value of passed usermeta name from usermeta table53 * @uses get_user_meta() WordPress function returns the value of passed usermeta name from usermeta table 54 54 * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user 55 55 * @uses bp_profile_last_updated_date() Returns the last updated date for a user. … … 61 61 if ( $this->profile_data ) { 62 62 $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] ); 63 $this->fullname = attribute_escape( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );63 $this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] ); 64 64 $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>"; 65 $this->email = attribute_escape( $this->profile_data['user_email'] );65 $this->email = esc_attr( $this->profile_data['user_email'] ); 66 66 } else { 67 67 $this->user_url = bp_core_get_user_domain( $this->id ); 68 68 $this->user_link = bp_core_get_userlink( $this->id ); 69 $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );70 $this->email = attribute_escape( bp_core_get_user_email( $this->id ) );69 $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) ); 70 $this->email = esc_attr( bp_core_get_user_email( $this->id ) ); 71 71 } 72 72 … … 80 80 $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ); 81 81 82 $this->last_active = bp_core_get_last_activity( get_user meta( $this->id, 'last_activity'), __( 'active %s ago', 'buddypress' ) );82 $this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) ); 83 83 } 84 84 … … 107 107 /* Static Functions */ 108 108 109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $ search_terms = false, $populate_extras = true ) {109 function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true ) { 110 110 global $wpdb, $bp; 111 111 112 112 $sql = array(); 113 113 114 $sql['select_main'] = "SELECT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";114 $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email"; 115 115 116 116 if ( 'active' == $type || 'online' == $type ) … … 125 125 $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID"; 126 126 127 if ( $search_terms && function_exists( 'xprofile_install' ) || 'alphabetical' == $type ) 128 $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id"; 129 127 130 $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' ); 128 131 … … 134 137 135 138 if ( 'online' == $type ) 136 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";139 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()"; 137 140 138 141 if ( 'alphabetical' == $type ) 139 142 $sql['where_alpha'] = "AND pd.field_id = 1"; 140 143 141 if ( $user_id && function_exists( 'friends_install' ) ) { 144 if ( $include ) { 145 if ( is_array( $include ) ) 146 $uids = $wpdb->escape( implode( ',', (array)$include ) ); 147 else 148 $uids = $wpdb->escape( $include ); 149 150 if ( !empty( $uids ) ) 151 $sql['where_users'] = "AND u.ID IN ({$uids})"; 152 } 153 154 else if ( $user_id && function_exists( 'friends_install' ) ) { 142 155 $friend_ids = friends_get_friend_user_ids( $user_id ); 143 156 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) ); … … 151 164 } 152 165 153 if ( $search_terms ) {166 if ( $search_terms && function_exists( 'xprofile_install' ) ) { 154 167 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 155 $sql['where_searchterms'] = "AND u.display_name LIKE '%%$search_terms%%'";168 $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'"; 156 169 } 157 170 … … 164 177 break; 165 178 case 'alphabetical': 166 $sql[] = "ORDER BY u.display_name ASC";179 $sql[] = "ORDER BY pd.value ASC"; 167 180 break; 168 181 case 'random': … … 178 191 179 192 /* Get paginated results */ 180 $paged_users = $wpdb->get_results( join( ' ', (array)$sql ) ); 193 $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ), $sql ); 194 $paged_users = $wpdb->get_results( $paged_users_sql ); 181 195 182 196 /* Re-jig the SQL so we can get the total user count */ … … 198 212 199 213 /* Get total user results */ 200 $total_users = $wpdb->get_var( join( ' ', (array)$sql ) ); 214 $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ), $sql ); 215 $total_users = $wpdb->get_var( $total_users_sql ); 201 216 202 217 /*** … … 223 238 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 224 239 225 if ( strlen($letter) > 1 || is_numeric($letter) || !$letter ) 226 return false; 240 // Multibyte compliance 241 if ( function_exists( 'mb_strlen' ) ) { 242 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) { 243 return false; 244 } 245 } else { 246 if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) { 247 return false; 248 } 249 } 227 250 228 251 $letter = like_escape( $wpdb->escape( $letter ) ); … … 318 341 /* Fetch the user's full name */ 319 342 if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) { 343 /* Ensure xprofile globals are set */ 344 if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) ) 345 xprofile_setup_globals(); 346 320 347 $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 321 348 for ( $i = 0; $i < count( $paged_users ); $i++ ) { … … 436 463 if ( $this->id ) { 437 464 // Update 438 $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );465 $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id ); 439 466 } else { 440 467 // Save 441 $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );468 $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new ); 442 469 } 443 470 -
trunk/bp-core/bp-core-cssjs.php
r3280 r3300 39 39 <style type="text/css"> 40 40 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo BP_PLUGIN_URL . '/bp-core/images/admin_menu_icon.png' ?> ) !important; background-position: -1px -32px; } 41 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a { background-position: -1px 0; }41 ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a, ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a { background-position: -1px 0; } 42 42 ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; } 43 43 </style> … … 50 50 global $current_blog; 51 51 52 if ( $current_blog->blog_id != BP_ROOT_BLOG )52 if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG ) 53 53 return false; 54 54 ?> … … 83 83 global $bp; 84 84 85 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );85 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( BP_AVATAR_UPLOAD_PATH . $bp->avatar_admin->image->dir ) ); 86 86 $aspect_ratio = 1; 87 87 88 / * Calculate Aspect Ratio */88 // Calculate Aspect Ratio 89 89 if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) ) 90 90 $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' ); -
trunk/bp-core/bp-core-filters.php
r2941 r3300 33 33 */ 34 34 function bp_core_email_from_name_filter() { 35 return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname') );35 return apply_filters( 'bp_core_email_from_name_filter', wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ) ); 36 36 } 37 37 add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); … … 66 66 global $bp, $current_blog; 67 67 68 if ( !is_s ite_admin() )68 if ( !is_super_admin() ) 69 69 return $themes; 70 70 … … 142 142 * Replace the generated password in the welcome email. 143 143 * This will not filter when the site admin registers a user. 144 * 145 * @uses locate_template To see if custom registration files exist 146 * @param string $welcome_email Complete email passed through WordPress 147 * @return string Filtered $welcome_email with 'PASSWORD' replaced by [User Set] 144 148 */ 145 149 function bp_core_filter_user_welcome_email( $welcome_email ) { … … 148 152 return $welcome_email; 149 153 154 // [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user 150 155 return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email ); 151 156 } … … 158 163 * Replace the generated password in the welcome email. 159 164 * This will not filter when the site admin registers a user. 165 * 166 * @uses locate_template To see if custom registration files exist 167 * @param string $welcome_email Complete email passed through WordPress 168 * @param integer $blog_id ID of the blog user is joining 169 * @param integer $user_id ID of the user joining 170 * @param string $password Password of user 171 * @return string Filtered $welcome_email with $password replaced by [User Set] 160 172 */ 161 173 function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) { … … 164 176 return $welcome_email; 165 177 178 // [User Set] Replaces $password in welcome email; Represents value set by user 166 179 return str_replace( $password, __( '[User Set]', 'buddypress' ), $welcome_email ); 167 180 } … … 175 188 // Send email with activation link. 176 189 $activate_url = bp_get_activation_page() ."?key=$key"; 177 $activate_url = clean_url($activate_url);190 $activate_url = esc_url($activate_url); 178 191 179 192 $admin_email = get_site_option( "admin_email" ); … … 184 197 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 185 198 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 186 $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2$s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );187 $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));199 $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2$s", 'buddypress' ), $activate_url, esc_url("http://{$domain}{$path}" ) ); 200 $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), esc_url('http://' . $domain . $path)); 188 201 189 202 /* Send the message */ … … 204 217 205 218 $activate_url = bp_get_activation_page() ."?key=$key"; 206 $activate_url = clean_url($activate_url);219 $activate_url = esc_url($activate_url); 207 220 $admin_email = get_site_option( "admin_email" ); 208 221 … … 216 229 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 217 230 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 218 $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, clean_url("http://{$domain}{$path}" ) );231 $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, esc_url( "http://{$domain}{$path}" ) ); 219 232 $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' ); 220 233 -
trunk/bp-core/bp-core-notifications.php
r2576 r3300 5 5 6 6 if ( !$date_notified ) 7 $date_notified = time();7 $date_notified = bp_core_current_time(); 8 8 9 9 $notification = new BP_Core_Notification; -
trunk/bp-core/bp-core-settings.php
r2717 r3300 22 22 bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) ); 23 23 24 if ( !is_s ite_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] )24 if ( !is_super_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] ) 25 25 bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) ); 26 26 } 27 add_action( 'wp', 'bp_core_add_settings_nav', 2 ); 28 add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 ); 27 add_action( 'bp_setup_nav', 'bp_core_add_settings_nav' ); 29 28 30 29 /**** GENERAL SETTINGS ****/ … … 88 87 <form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form"> 89 88 <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label> 90 <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />89 <input type="text" name="email" id="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" class="settings-input" /> 91 90 92 91 <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label> … … 95 94 96 95 <div class="submit"> 97 <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" /></p>96 <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" /> 98 97 </div> 99 98 … … 115 114 if ( $_POST['notifications'] ) { 116 115 foreach ( (array)$_POST['notifications'] as $key => $value ) { 117 update_user meta( (int)$current_user->id, $key, $value );116 update_user_meta( (int)$current_user->id, $key, $value ); 118 117 } 119 118 } … … 148 147 149 148 <div class="submit"> 150 <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" /></p>149 <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" /> 151 150 </div> 152 151 … … 190 189 191 190 <div class="submit"> 192 <input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> →" id="delete-account-button" name="delete-account-button" /> </p>191 <input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> →" id="delete-account-button" name="delete-account-button" /> 193 192 </div> 194 193 -
trunk/bp-core/bp-core-signup.php
r3277 r3300 181 181 182 182 /* Make sure we include the jQuery jCrop file for image cropping */ 183 add_action( 'wp ', 'bp_core_add_jquery_cropper' );183 add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' ); 184 184 } 185 185 } -
trunk/bp-core/bp-core-templatetags.php
r3286 r3300 30 30 $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras ); 31 31 else 32 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, ' search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );32 $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) ); 33 33 34 34 if ( !$max || $max >= (int)$this->members['total'] ) … … 126 126 $search_terms = false; 127 127 128 / * User filtering */128 // User filtering 129 129 if ( !empty( $bp->displayed_user->id ) ) 130 130 $user_id = $bp->displayed_user->id; 131 131 132 / * Pass a filter if ?s= is set. */133 if ( $_REQUEST['s'])132 // Pass a filter if ?s= is set. 133 if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) ) 134 134 $search_terms = $_REQUEST['s']; 135 135 … … 157 157 } 158 158 159 / * Make sure we return no members if we looking at friendship requests and there are none. */159 // Make sure we return no members if we looking at friendship requests and there are none. 160 160 if ( empty( $include ) && $bp->friends->slug == $bp->current_component && 'requests' == $bp->current_action ) 161 161 return false; 162 162 163 163 $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras ); 164 165 return $members_template->has_members(); 164 return apply_filters( 'bp_has_members', $members_template->has_members(), &$members_template ); 166 165 } 167 166 … … 182 181 global $bp, $members_template; 183 182 184 $from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 ); 185 $to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1) ); 183 $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 184 $from_num = bp_core_number_format( $start_num ); 185 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) ); 186 186 $total = bp_core_number_format( $members_template->total_member_count ); 187 187 … … 195 195 $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total ); 196 196 197 return apply_filters( 'bp_members_pagination_count', $pag );197 return apply_filters( 'bp_members_pagination_count', $pag . '<span class="ajax-loader"></span>' ); 198 198 } 199 199 … … 207 207 } 208 208 209 /** 210 * bp_member_user_id() 211 * 212 * Echo id from bp_get_member_user_id() 213 * 214 * @uses bp_get_member_user_id() 215 */ 209 216 function bp_member_user_id() { 210 217 echo bp_get_member_user_id(); 211 218 } 219 /** 220 * bp_get_member_user_id() 221 * 222 * Get the id of the user in a members loop 223 * 224 * @global object $members_template 225 * @return string Members id 226 */ 212 227 function bp_get_member_user_id() { 213 228 global $members_template; … … 215 230 return apply_filters( 'bp_get_member_user_id', $members_template->member->id ); 216 231 } 232 233 /** 234 * bp_member_user_nicename() 235 * 236 * Echo nicename from bp_get_member_user_nicename() 237 * 238 * @uses bp_get_member_user_nicename() 239 */ 240 function bp_member_user_nicename() { 241 echo bp_get_member_user_nicename(); 242 } 243 /** 244 * bp_get_member_user_nicename() 245 * 246 * Get the nicename of the user in a members loop 247 * 248 * @global object $members_template 249 * @return string Members nicename 250 */ 251 function bp_get_member_user_nicename() { 252 global $members_template; 253 return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename ); 254 } 255 256 /** 257 * bp_member_user_login() 258 * 259 * Echo login from bp_get_member_user_login() 260 * 261 * @uses bp_get_member_user_login() 262 */ 263 function bp_member_user_login() { 264 echo bp_get_member_user_login(); 265 } 266 /** 267 * bp_get_member_user_login() 268 * 269 * Get the login of the user in a members loop 270 * 271 * @global object $members_template 272 * @return string Members login 273 */ 274 function bp_get_member_user_login() { 275 global $members_template; 276 return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login ); 277 } 278 279 /** 280 * bp_member_user_email() 281 * 282 * Echo email address from bp_get_member_user_email() 283 * 284 * @uses bp_get_member_user_email() 285 */ 286 function bp_member_user_email() { 287 echo bp_get_member_user_email(); 288 } 289 /** 290 * bp_get_member_user_email() 291 * 292 * Get the email address of the user in a members loop 293 * 294 * @global object $members_template 295 * @return string Members email address 296 */ 297 function bp_get_member_user_email() { 298 global $members_template; 299 return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email ); 300 } 301 302 function bp_member_is_loggedin_user() { 303 global $bp, $members_template; 304 return apply_filters( 'bp_member_is_loggedin_user', $bp->loggedin_user->id == $members_template->member->id ? true : false ); 305 } 217 306 218 307 function bp_member_avatar( $args = '' ) { … … 315 404 316 405 // Populate the user if it hasn't been already. 317 if ( empty( $members_template->member->profile_data ) )318 $members_template->member = new BP_Core_User( $members_template->member->id );406 if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) 407 $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id ); 319 408 320 409 $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] ); … … 329 418 global $members_template; 330 419 331 $registered = attribute_escape( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );420 $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) ); 332 421 333 422 return apply_filters( 'bp_member_last_active', $registered ); … … 346 435 function bp_member_hidden_fields() { 347 436 if ( isset( $_REQUEST['s'] ) ) { 348 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';437 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />'; 349 438 } 350 439 351 440 if ( isset( $_REQUEST['letter'] ) ) { 352 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';441 echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 353 442 } 354 443 355 444 if ( isset( $_REQUEST['members_search'] ) ) { 356 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['members_search'] ) . '" name="search_terms" />';445 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['members_search'] ) . '" name="search_terms" />'; 357 446 } 358 447 } … … 367 456 ?> 368 457 <form action="" method="get" id="search-members-form"> 369 <label><input type="text" name="s" id="members_search" value="<?php echo attribute_escape( $search_value ) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>458 <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 370 459 <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 371 460 </form> … … 517 606 $bp->bp_options_title = __( 'Options', 'buddypress' ); 518 607 519 echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );608 echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) ); 520 609 } 521 610 … … 575 664 576 665 $defaults = array( 577 'type' => 'thumb', 578 'width' => false, 579 'height' => false 666 'type' => 'thumb', 667 'width' => false, 668 'height' => false, 669 'html' => true 580 670 ); 581 671 … … 583 673 extract( $r, EXTR_SKIP ); 584 674 585 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );675 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) ); 586 676 } 587 677 … … 593 683 594 684 $defaults = array( 595 'type' => 'thumb', 596 'width' => false, 597 'height' => false 685 'type' => 'thumb', 686 'width' => false, 687 'height' => false, 688 'html' => true 598 689 ); 599 690 … … 601 692 extract( $r, EXTR_SKIP ); 602 693 603 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );694 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) ); 604 695 } 605 696 … … 641 732 } 642 733 643 function bp_is_my_profile() {644 global $bp;645 646 if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )647 return true;648 649 return false;650 }651 function bp_is_home() { return bp_is_my_profile(); }652 653 function bp_get_loggedin_user_link() {654 global $bp;655 656 return $bp->loggedin_user->domain;657 }658 659 function bp_get_displayed_user_link() {660 global $bp;661 662 return $bp->displayed_user->domain;663 }664 665 function bp_last_activity( $user_id = false, $echo = true ) {666 global $bp;667 668 if ( !$user_id )669 $user_id = $bp->displayed_user->id;670 671 $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );672 673 if ( $echo )674 echo apply_filters( 'bp_last_activity', $last_activity );675 else676 return apply_filters( 'bp_last_activity', $last_activity );677 }678 679 function bp_user_firstname() {680 echo bp_get_user_firstname();681 }682 function bp_get_user_firstname( $name = false ) {683 global $bp;684 685 if ( !$name )686 $name = $bp->loggedin_user->fullname;687 688 $fullname = (array)explode( ' ', $name );689 690 return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );691 }692 693 function bp_user_link() {694 global $bp;695 696 echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );697 }698 699 734 function bp_core_get_wp_profile() { 700 735 global $bp; … … 706 741 <h4><?php _e( 'My Profile' ) ?></h4> 707 742 708 <table class="wp-profile-fields ">743 <table class="wp-profile-fields zebra"> 709 744 <?php if ( $ud->display_name ) { ?> 710 745 <tr id="wp_displayname"> … … 784 819 785 820 function bp_format_time( $time, $just_date = false ) { 786 $date = date( get_option('date_format'), $time ); 787 821 if ( !$time ) 822 return false; 823 824 // Get GMT offset from root blog 825 $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' ); 826 827 // Calculate offset time 828 $time_offset = $time + ( $root_blog_offset * 3600 ); 829 830 // Current date (January 1, 2010) 831 $date = date( 'F j, Y ', $time_offset ); 832 833 // Should we show the time also? 788 834 if ( !$just_date ) { 789 $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time ); 835 // Current time (9:50pm) 836 $time = date( ' g:ia', $time_offset ); 837 838 // Return string formatted with date and time 839 $date = sprintf( __( '%1$s at %2$s', 'buddypress' ), $date, $time ); 790 840 } 791 841 … … 833 883 } 834 884 835 function bp_loggedinuser_link() {836 global $bp;837 838 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {839 echo apply_filters( 'bp_loggedinuser_link', $link );840 }841 }842 843 885 function bp_get_plugin_sidebar() { 844 886 locate_template( array( 'plugin-sidebar.php' ), true ); 845 887 } 846 888 847 function bp_is_blog_page() {848 global $bp, $is_member_page, $wp_query;849 850 if ( $wp_query->is_home && !$bp->is_directory )851 return true;852 853 if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory && !bp_core_is_root_component( $bp->current_component ) )854 return true;855 856 return false;857 }858 859 889 function bp_page_title() { 860 890 echo bp_get_page_title(); … … 864 894 global $bp, $post, $wp_query, $current_blog; 865 895 866 if ( is_front_page() || !bp_current_component() ||( is_home() && bp_is_page( 'home' ) ) ) {896 if ( is_front_page() || ( is_home() && bp_is_page( 'home' ) ) ) { 867 897 $title = __( 'Home', 'buddypress' ); 868 898 … … 886 916 887 917 } else if ( $bp->is_directory ) { 888 $title = get_the_title(); 918 if ( !$bp->current_component ) 919 $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) ); 920 else 921 $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) ); 889 922 890 923 } else if ( bp_is_register_page() ) { 891 892 924 $title = __( 'Create an Account', 'buddypress' ); 893 925 894 926 } else if ( bp_is_activation_page() ) { 895 927 $title = __( 'Activate your Account', 'buddypress' ); 928 929 } else if ( bp_is_group_create() ) { 930 $title = __( 'Create a Group', 'buddypress' ); 931 932 } else if ( bp_is_create_blog() ) { 933 $title = __( 'Create a Blog', 'buddypress' ); 896 934 } 897 935 … … 952 990 } 953 991 992 /** 993 * bp_search_form_available() 994 * 995 * Only show the search form if there are available objects to search for. 996 * 997 * @global array $bp 998 * @uses function_exists 999 * @uses bp_core_is_multisite() 1000 * @return bool Filterable result 1001 */ 1002 function bp_search_form_enabled() { 1003 global $bp; 1004 1005 if ( function_exists( 'xprofile_install' ) 1006 || function_exists( 'groups_install' ) 1007 || ( function_exists( 'bp_blogs_install' ) && bp_core_is_multisite() ) 1008 || ( function_exists( 'bp_forums_setup' ) && !(int)$bp->site_options['bp-disable-forum-directory'] ) 1009 ) { 1010 $search_enabled = true; 1011 } else { 1012 $search_enabled = false; 1013 } 1014 1015 return apply_filters( 'bp_search_form_enabled', $search_enabled ); 1016 } 1017 954 1018 function bp_search_form_action() { 955 1019 global $bp; … … 959 1023 960 1024 function bp_search_form_type_select() { 1025 global $bp; 1026 961 1027 // Eventually this won't be needed and a page will be built to integrate all search results. 962 1028 $selection_box = '<select name="search-which" id="search-which" style="width: auto">'; … … 1013 1079 function bp_custom_profile_sidebar_boxes() { 1014 1080 do_action( 'bp_custom_profile_sidebar_boxes' ); 1015 }1016 1017 function bp_is_directory() {1018 global $bp;1019 1020 return $bp->is_directory;1021 1081 } 1022 1082 … … 1225 1285 1226 1286 function bp_registration_needs_activation() { 1227 return apply_filters( 'bp_registration_needs_activation', bp_core_is_multisite());1287 return apply_filters( 'bp_registration_needs_activation', true ); 1228 1288 } 1229 1289 … … 1268 1328 also means we dont have to use the $bp variable in the template (looks messy) */ 1269 1329 1330 function bp_last_activity( $user_id = false, $echo = true ) { 1331 global $bp; 1332 1333 if ( !$user_id ) 1334 $user_id = $bp->displayed_user->id; 1335 1336 $last_activity = bp_core_get_last_activity( get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') ); 1337 1338 if ( $echo ) 1339 echo apply_filters( 'bp_last_activity', $last_activity ); 1340 else 1341 return apply_filters( 'bp_last_activity', $last_activity ); 1342 } 1343 1344 function bp_user_has_access() { 1345 global $bp; 1346 1347 if ( is_super_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id ) 1348 $has_access = true; 1349 else 1350 $has_access = false; 1351 1352 return apply_filters( 'bp_user_has_access', $has_access ); 1353 } 1354 1355 function bp_user_firstname() { 1356 echo bp_get_user_firstname(); 1357 } 1358 function bp_get_user_firstname( $name = false ) { 1359 global $bp; 1360 1361 // Try to get displayed user 1362 if ( empty( $name ) ) 1363 $name = $bp->displayed_user->fullname; 1364 1365 // Fall back on logged in user 1366 if ( empty( $name ) ) 1367 $name = $bp->loggedin_user->fullname; 1368 1369 $fullname = (array)explode( ' ', $name ); 1370 1371 return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname ); 1372 } 1373 1374 function bp_loggedin_user_link() { 1375 echo bp_get_loggedin_user_link(); 1376 } 1377 function bp_get_loggedin_user_link() { 1378 global $bp; 1379 1380 return apply_filters( 'bp_get_loggedin_user_link', $bp->loggedin_user->domain ); 1381 } 1382 1383 /* @todo Deprecate incorrectly named function? */ 1384 function bp_loggedinuser_link() { 1385 global $bp; 1386 1387 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) 1388 echo apply_filters( 'bp_loggedin_user_link', $link ); 1389 } 1390 1391 function bp_displayed_user_link() { 1392 echo bp_get_displayed_user_link(); 1393 } 1394 function bp_get_displayed_user_link() { 1395 global $bp; 1396 1397 return apply_filters( 'bp_get_displayed_user_link', $bp->displayed_user->domain ); 1398 } 1399 function bp_user_link() { bp_displayed_user_link(); } // Deprecated. 1400 1270 1401 function bp_displayed_user_id() { 1271 1402 global $bp; … … 1350 1481 global $bp; 1351 1482 1352 return $bp->root_domain;1483 return apply_filters( 'bp_get_root_domain', $bp->root_domain ); 1353 1484 } 1354 1485 1355 1486 /* Template is_() functions to determine the current page */ 1487 1488 function bp_is_blog_page() { 1489 global $bp, $is_member_page, $wp_query; 1490 1491 if ( $wp_query->is_home && !$bp->is_directory ) 1492 return true; 1493 1494 if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory && !bp_core_is_root_component( $bp->current_component ) ) 1495 return true; 1496 1497 return false; 1498 } 1499 1500 function bp_is_my_profile() { 1501 global $bp; 1502 1503 if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id ) 1504 $my_profile = true; 1505 else 1506 $my_profile = false; 1507 1508 return apply_filters( 'bp_is_my_profile', $my_profile ); 1509 } 1510 function bp_is_home() { return bp_is_my_profile(); } 1356 1511 1357 1512 function bp_is_front_page() { … … 1365 1520 1366 1521 function bp_is_activity_front_page() { 1367 return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == bp_core_get_site_path() ); 1522 global $current_blog; 1523 1524 if ( bp_core_is_main_site() ) 1525 $path = bp_core_get_site_path(); 1526 else 1527 $path = $current_blog->path; 1528 1529 return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path ); 1530 } 1531 1532 function bp_is_directory() { 1533 global $bp; 1534 1535 return $bp->is_directory; 1368 1536 } 1369 1537 -
trunk/bp-core/bp-core-widgets.php
r3263 r3300 59 59 </ul> 60 60 <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?> 61 <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />61 <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" /> 62 62 63 63 <?php else: ?> … … 85 85 ?> 86 86 87 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>87 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p> 88 88 <?php 89 89 } … … 139 139 ?> 140 140 141 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>141 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p> 142 142 <?php 143 143 } … … 154 154 global $bp; 155 155 156 156 extract( $args ); 157 157 158 158 echo $before_widget; … … 193 193 ?> 194 194 195 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>195 <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p> 196 196 <?php 197 197 } … … 209 209 $type = 'newest'; 210 210 break; 211 211 212 case 'recently-active-members': 212 213 $type = 'active'; 213 214 break; 215 214 216 case 'popular-members': 215 217 if ( bp_is_active( 'friends' ) ) -
trunk/bp-core/bp-core-wpabstraction.php
r3284 r3300 23 23 24 24 return true; 25 } 26 27 /** 28 * bp_core_is_main_site 29 * 30 * Checks if current blog is root blog of site 31 * 32 * @since 1.2.6 33 * @package BuddyPress 34 * 35 * @param int $blog_id optional blog id to test (default current blog) 36 * @return bool True if not multisite or $blog_id is main site 37 */ 38 function bp_core_is_main_site( $blog_id = '' ) { 39 global $current_site, $current_blog; 40 41 if ( !bp_core_is_multisite() ) 42 return true; 43 44 if ( empty( $blog_id ) ) 45 $blog_id = $current_blog->blog_id; 46 47 return $blog_id == $current_site->blog_id; 25 48 } 26 49 … … 74 97 } 75 98 76 if ( !function_exists( 'wpmu_validate_user_signup' ) ) { 77 function wpmu_validate_user_signup( $user_name, $user_email ) { 78 global $wpdb; 99 if ( !function_exists( 'is_subdomain_install' ) ) { 100 function is_subdomain_install() { 101 if ( ( defined( 'VHOST' ) && 'yes' == VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) ) 102 return true; 79 103 80 $errors = new WP_Error(); 81 82 $user_email = sanitize_email( $user_email ); 83 84 if ( empty( $user_name ) ) 85 $errors->add('user_name', __("Please enter a username")); 86 87 $maybe = array(); 88 preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 89 90 $illegal_names = get_site_option( "illegal_names" ); 91 if( is_array( $illegal_names ) == false ) { 92 $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" ); 93 add_site_option( "illegal_names", $illegal_names ); 94 } 95 96 if ( !validate_username( $user_name ) || in_array( $user_name, $illegal_names ) == true || $user_name != $maybe[0] ) { 97 $errors->add('user_name', __("Only lowercase letters and numbers allowed")); 98 } 99 100 if( strlen( $user_name ) < 4 ) { 101 $errors->add('user_name', __("Username must be at least 4 characters")); 102 } 103 104 if ( strpos( " " . $user_name, "_" ) != false ) 105 $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!")); 106 107 // all numeric? 108 $match = array(); 109 preg_match( '/[0-9]*/', $user_name, $match ); 110 if ( $match[0] == $user_name ) 111 $errors->add('user_name', __("Sorry, usernames must have letters too!")); 112 113 if ( !is_email( $user_email ) ) 114 $errors->add('user_email', __("Please check your email address.")); 115 116 $limited_email_domains = get_site_option( 'limited_email_domains' ); 117 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 118 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 119 if( in_array( $emaildomain, $limited_email_domains ) == false ) { 120 $errors->add('user_email', __("Sorry, that email address is not allowed!")); 121 } 122 } 123 124 // Check if the username has been used already. 125 if ( username_exists($user_name) ) 126 $errors->add('user_name', __("Sorry, that username already exists!")); 127 128 // Check if the email address has been used already. 129 if ( email_exists($user_email) ) 130 $errors->add('user_email', __("Sorry, that email address is already used!")); 131 132 $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 133 134 return apply_filters('wpmu_validate_user_signup', $result); 104 return false; 135 105 } 136 106 } 107 108 // Deprecated - 1.2.6 109 if ( !function_exists( 'is_site_admin' ) ) { 110 function is_site_admin( $user_id = false ) { 111 return is_super_admin( $user_id ); 112 } 113 } 114 137 115 ?> -
trunk/bp-forums.php
r3232 r3300 1 1 <?php 2 2 3 /* Define the parent forum ID */ 3 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 4 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 5 6 7 if ( !defined( 'BP_FORUMS_SLUG' ) ) 8 define( 'BP_FORUMS_SLUG', 'forums' ); 9 6 10 if ( !defined( 'BB_PATH' ) ) 7 11 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' ); … … 13 17 global $bp; 14 18 15 if ( !defined( 'BP_FORUMS_SLUG' ) )16 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );17 18 19 /* For internal identification */ 19 20 $bp->forums->id = 'forums'; 20 $bp->forums->name = $bp->pages->forums->name;21 $bp->forums->slug = BP_FORUMS_SLUG;22 21 23 22 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 24 23 $bp->forums->bbconfig = $bp->site_options['bb-config-location']; 24 $bp->forums->slug = BP_FORUMS_SLUG; 25 25 26 26 /* Register this in the active components array */ … … 40 40 } 41 41 42 function bp_forums_setup_root_component() { 43 /* Register 'forums' as a root component */ 44 bp_core_add_root_component( BP_FORUMS_SLUG ); 45 } 46 add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' ); 47 42 48 function bp_forums_directory_forums_setup() { 43 49 global $bp; 44 50 45 51 if ( $bp->current_component == $bp->forums->slug ) { 46 if ( (int) $bp->site_options['bp-disable-forum-directory'] || ! bp_is_active( 'groups' ) )52 if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) ) 47 53 return false; 48 54 … … 63 69 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) { 64 70 /* Auto join this user if they are not yet a member of this group */ 65 if ( !is_s ite_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )71 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 66 72 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id ); 67 73 … … 73 79 74 80 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' ); 81 } else { 82 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' ); 75 83 } 76 84 } … … 87 95 global $bp; 88 96 89 if ( !is_s ite_admin() )97 if ( !is_super_admin() ) 90 98 return false; 91 99 … … 119 127 120 128 return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 129 } 130 131 function bp_forums_update_forum( $args = '' ) { 132 do_action( 'bbpress_init' ); 133 134 $defaults = array( 135 'forum_id' => '', 136 'forum_name' => '', 137 'forum_desc' => '', 138 'forum_slug' => '', 139 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 140 'forum_order' => false, 141 'forum_is_category' => 0 142 ); 143 144 $r = wp_parse_args( $args, $defaults ); 145 extract( $r, EXTR_SKIP ); 146 147 return bb_update_forum( array( 'forum_id' => (int)$forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 121 148 } 122 149 … … 356 383 357 384 /* Fetch fullname for the topic's last poster */ 358 if ( bp_is_active( 'xprofile' ) ) {385 if ( function_exists( 'xprofile_install' ) ) { 359 386 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) ); 360 387 for ( $i = 0; $i < count( $topics ); $i++ ) { … … 441 468 $post_position = $post->post_position; 442 469 443 $post = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );444 445 if ( $post )470 $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 471 472 if ( $post_id ) 446 473 do_action( 'bp_forums_new_post', $post_id ); 447 474 448 return $post ;475 return $post_id; 449 476 } 450 477 … … 474 501 475 502 /* Fetch fullname for each poster. */ 476 if ( bp_is_active( 'xprofile' ) ) {503 if ( function_exists( 'xprofile_install' ) ) { 477 504 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 478 505 for ( $i = 0; $i < count( $posts ); $i++ ) { … … 501 528 global $bp, $wp_roles, $bb_table_prefix; 502 529 503 $bb_cap = get_user meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities');530 $bb_cap = get_user_meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities', true ); 504 531 505 532 if ( empty( $bb_cap ) ) -
trunk/bp-forums/bp-forums-admin.php
r2665 r3300 122 122 123 123 function bp_forums_bbpress_install() { 124 global $wpdb, $bbdb ;124 global $wpdb, $bbdb, $bp; 125 125 126 126 check_admin_referer( 'bp_forums_new_install_init' ); … … 141 141 "define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . addslashes( LOGGED_IN_KEY ) . "'" ), 142 142 "define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . addslashes( NONCE_KEY ) . "'" ), 143 "\$bb_table_prefix = '" => array( "'bb_'", "'" . $ wpdb->base_prefix . "bb_'" ),143 "\$bb_table_prefix = '" => array( "'bb_'", "'" . $bp->table_prefix . "bb_'" ), 144 144 "define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" ) 145 145 ) … … 154 154 155 155 $file = substr( $file, 0, -2 ); 156 $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";';157 $file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';158 $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';159 $file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';156 $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';'; 157 $file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';'; 158 $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';'; 159 $file .= "\n" . '$bb->name = \'' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';'; 160 160 161 161 if ( bp_core_is_multisite() ) … … 163 163 164 164 if ( defined( 'AUTH_SALT' ) ) 165 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . addslashes( AUTH_SALT ) . '");';165 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');'; 166 166 167 167 if ( defined( 'LOGGED_IN_SALT' ) ) 168 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . addslashes( LOGGED_IN_SALT ) . '");';168 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');'; 169 169 170 170 if ( defined( 'SECURE_AUTH_SALT' ) ) 171 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . addslashes( SECURE_AUTH_SALT ) . '");';171 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');'; 172 172 173 173 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; -
trunk/bp-forums/bp-forums-bbpress.php
r2209 r3300 66 66 /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */ 67 67 if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) 68 require_once( ABSPATH . 'wp-admin/ upgrade-functions.php' );68 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 69 69 70 70 require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' ); 71 71 72 72 if ( is_object( $wp_roles ) ) { 73 $bb_roles = &$wp_roles;73 $bb_roles = $wp_roles; 74 74 bb_init_roles( $bb_roles ); 75 75 } … … 104 104 $site_admins = get_site_option( 'site_admins', array('admin') ); 105 105 foreach ( (array)$site_admins as $site_admin ) 106 update_user meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );106 update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) ); 107 107 108 108 // Create the first forum. … … 131 131 extract( $args, EXTR_SKIP ); 132 132 133 return update_user meta( $id, $meta_key, $meta_value );133 return update_user_meta( $id, $meta_key, $meta_value ); 134 134 } 135 135 } -
trunk/bp-forums/bp-forums-filters.php
r2770 r3300 3 3 /* Apply WordPress defined filters */ 4 4 add_filter( 'bp_forums_bbconfig_location', 'wp_filter_kses', 1 ); 5 add_filter( 'bp_forums_bbconfig_location', ' attribute_escape', 1 );5 add_filter( 'bp_forums_bbconfig_location', 'esc_attr', 1 ); 6 6 7 7 add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 ); 8 8 add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_kses', 1 ); 9 9 add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_kses', 1 ); 10 11 add_filter( 'bp_get_the_topic_title', 'force_balance_tags' ); 12 add_filter( 'bp_get_the_topic_latest_post_excerpt', 'force_balance_tags' ); 13 add_filter( 'bp_get_the_topic_post_content', 'force_balance_tags' ); 10 14 11 15 add_filter( 'bp_get_the_topic_title', 'wptexturize' ); … … 31 35 add_filter( 'bp_get_the_topic_poster_name', 'stripslashes_deep' ); 32 36 add_filter( 'bp_get_the_topic_last_poster_name', 'stripslashes_deep' ); 37 add_filter( 'bp_get_the_topic_object_name', 'stripslashes_deep' ); 33 38 34 39 add_filter( 'bp_get_the_topic_post_content', 'make_clickable' ); … … 84 89 } 85 90 91 /** 92 * bp_forums_add_forum_topic_to_page_title( $title ) 93 * 94 * Append forum topic to page title 95 * 96 * @global object $bp 97 * @param string $title 98 * @return string 99 */ 100 function bp_forums_add_forum_topic_to_page_title( $title ) { 101 global $bp; 102 103 if ( $bp->current_action == 'forum' && $bp->action_variables[0] == 'topic' ) { 104 if ( bp_has_forum_topic_posts() ) { 105 $title .= ' | ' . bp_get_the_topic_title(); 106 } 107 } 108 109 return $title; 110 } 111 add_filter( 'bp_page_title', 'bp_forums_add_forum_topic_to_page_title' ); 112 86 113 ?> -
trunk/bp-forums/bp-forums-templatetags.php
r3247 r3300 7 7 var $topic; 8 8 9 var $forum_id; 10 9 11 var $in_the_loop; 10 12 … … 26 28 $this->type = $type; 27 29 $this->search_terms = $search_terms; 30 $this->forum_id = $forum_id; 28 31 29 32 switch ( $type ) { … … 48 51 49 52 if ( !(int)$this->topics ) { 50 $this->topic_count = 0;53 $this->topic_count = 0; 51 54 $this->total_topic_count = 0; 52 55 } else { … … 60 63 } 61 64 62 if ( !$max || $max >= $topic_count ) 65 if ( !$max || $max >= $topic_count ) { 63 66 $this->total_topic_count = $topic_count; 64 else67 } else { 65 68 $this->total_topic_count = (int)$max; 69 } 66 70 67 71 if ( $max ) { 68 if ( $max >= count( $this->topics) ) {72 if ( $max >= count($this->topics) ) { 69 73 $this->topic_count = count( $this->topics ); 70 74 } else { … … 99 103 'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ), 100 104 'format' => '', 101 'total' => ceil( (int)$this->total_topic_count / (int)$this->pag_num 105 'total' => ceil( (int)$this->total_topic_count / (int)$this->pag_num), 102 106 'current' => $this->pag_page, 103 107 'prev_text' => '←', … … 259 263 260 264 $post = bb_get_first_post( (int)$forum_template->topic->topic_id, false ); 261 return apply_filters( 'bp_get_the_topic_text', attribute_escape( $post->post_text ) );265 return apply_filters( 'bp_get_the_topic_text', esc_attr( $post->post_text ) ); 262 266 } 263 267 … … 295 299 global $forum_template; 296 300 297 if ( !$name = bp_core_get_userlink( $forum_template->topic->poster_id ) ) 301 $poster_id = ( empty( $forum_template->topic->poster_id ) ) ? $forum_template->topic->topic_poster : $forum_template->topic->poster_id; 302 303 if ( !$name = bp_core_get_userlink( $poster_id ) ) 298 304 return __( 'Deleted User', 'buddypress' ); 299 305 … … 467 473 global $forum_template; 468 474 469 return $forum_template->topic->topic_posts;475 return apply_filters( 'bp_get_the_topic_total_posts', $forum_template->topic->topic_posts ); 470 476 } 471 477 … … 557 563 $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit Topic', 'buddypress' ) . '</a>'; 558 564 559 if ( $bp->is_item_admin || $bp->is_item_mod || is_s ite_admin() ) {565 if ( $bp->is_item_admin || $bp->is_item_mod || is_super_admin() ) { 560 566 if ( 0 == (int)$forum_template->topic->topic_sticky ) 561 567 $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky Topic', 'buddypress' ) . '</a>'; … … 592 598 $class .= ' closed'; 593 599 594 return trim( $class);600 return apply_filters( 'bp_get_the_topic_css_class', trim( $class ) ); 595 601 } 596 602 … … 670 676 global $bp, $forum_template; 671 677 672 $from_num = bp_core_number_format( intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1 ); 673 $to_num = bp_core_number_format( ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ) ); 678 $start_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1; 679 $from_num = bp_core_number_format( $start_num ); 680 $to_num = bp_core_number_format( ( $start_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $start_num + ( $forum_template->pag_num - 1 ) ); 674 681 $total = bp_core_number_format( $forum_template->total_topic_count ); 675 682 … … 678 685 $pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms ); 679 686 680 return apply_filters( 'bp_get_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (of %s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) );687 return apply_filters( 'bp_get_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (of %s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) . '<span class="ajax-loader"></span>' ); 681 688 } 682 689 … … 697 704 var $post; 698 705 706 var $forum_id; 699 707 var $topic_id; 700 708 var $topic; … … 712 720 var $order; 713 721 714 function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {722 function BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order ) { 715 723 global $bp, $current_user, $forum_template; 716 724 … … 721 729 $this->topic_id = $topic_id; 722 730 $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id ); 731 $this->forum_id = $forum_template->topic->forum_id; 723 732 724 733 $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) ); 725 734 726 735 if ( !$this->posts ) { 727 $this->post_count = 0;736 $this->post_count = 0; 728 737 $this->total_post_count = 0; 729 738 } else { 730 if ( !$max || $max >= (int) 731 $this->total_post_count = (int) 739 if ( !$max || $max >= (int)$forum_template->topic->topic_posts ) { 740 $this->total_post_count = (int)$forum_template->topic->topic_posts; 732 741 } else { 733 742 $this->total_post_count = (int)$max; … … 814 823 'topic_id' => false, 815 824 'per_page' => 15, 816 'max' => false 825 'max' => false, 826 'order' => 'ASC' 817 827 ); 818 828 … … 823 833 $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] ); 824 834 825 if ( is_numeric( $topic_id ) ) 826 $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max ); 827 else 835 if ( is_numeric( $topic_id ) ) { 836 $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order ); 837 838 // Current topic forum_id needs to match current_group forum_id 839 if ( $bp->current_component == $bp->groups->slug && $topic_template->forum_id != groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) 840 return false; 841 842 } else { 828 843 return false; 844 } 829 845 830 846 return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template ); … … 857 873 858 874 return apply_filters( 'bp_get_the_topic_post_content', stripslashes( $topic_template->post->post_text ) ); 875 } 876 877 function bp_the_topic_post_css_class() { 878 echo bp_get_the_topic_post_css_class(); 879 } 880 881 function bp_get_the_topic_post_css_class() { 882 global $topic_template; 883 884 $class = false; 885 886 if ( $topic_template->current_post % 2 == 1 ) 887 $class .= 'alt'; 888 889 if ( 1 == (int)$topic_template->post->post_status ) 890 $class .= ' deleted'; 891 892 if ( 0 == (int)$topic_template->post->post_status ) 893 $class .= ' open'; 894 895 return apply_filters( 'bp_get_the_topic_post_css_class', trim( $class ) ); 859 896 } 860 897 … … 936 973 $query_vars = '?' . $_SERVER['QUERY_STRING']; 937 974 938 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id .'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';975 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' '; 939 976 $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a> | '; 940 977 … … 949 986 950 987 $post = bp_forums_get_post( $bp->action_variables[4] ); 951 return apply_filters( 'bp_get_the_topic_post_edit_text', attribute_escape( $post->post_text ) );988 return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) ); 952 989 } 953 990 … … 964 1001 global $bp, $topic_template; 965 1002 966 $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; 967 $to_num = ( $from_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 ); 968 969 echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $topic_template->total_post_count ) ); 1003 $start_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; 1004 $from_num = bp_core_number_format( $start_num ); 1005 $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) ); 1006 $total = bp_core_number_format( $topic_template->total_post_count ); 1007 1008 echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %1$s to %2$s (%3$s total posts)', 'buddypress' ), $from_num, $to_num, $total ) ); 970 1009 ?> 971 1010 <span class="ajax-loader"></span> … … 991 1030 ?> 992 1031 <form action="" method="get" id="search-forums-form"> 993 <label><input type="text" name="s" id="forums_search" value="<?php echo attribute_escape($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>1032 <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 994 1033 <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 995 1034 </form> … … 1039 1078 global $topic_template; 1040 1079 1041 return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );1080 return apply_filters( 'bp_get_forum_action', $bp->root_domain . esc_attr( $_SERVER['REQUEST_URI'] ) ); 1042 1081 } 1043 1082 … … 1048 1087 global $bp; 1049 1088 1050 return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );1089 return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . esc_attr( $_SERVER['REQUEST_URI'] ) ); 1051 1090 } 1052 1091 -
trunk/bp-friends.php
r3232 r3300 1 1 <?php 2 3 define ( 'BP_FRIENDS_DB_VERSION', '1800' ); 4 5 /* Define the slug for the component */ 6 if ( !defined( 'BP_FRIENDS_SLUG' ) ) 7 define ( 'BP_FRIENDS_SLUG', 'friends' ); 8 2 9 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' ); 3 10 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' ); 4 11 5 12 function friends_setup_globals() { 6 global $bp, $wpdb; 7 8 if ( !defined( 'BP_FRIENDS_SLUG' ) ) 9 define( 'BP_FRIENDS_SLUG', 'friends' ); 13 global $bp; 10 14 11 15 /* For internal identification */ 12 16 $bp->friends->id = 'friends'; 13 17 14 $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends'; 18 $bp->friends->slug = BP_FRIENDS_SLUG; 19 20 $bp->friends->table_name = $bp->table_prefix . 'bp_friends'; 21 15 22 $bp->friends->format_notification_function = 'friends_format_notifications'; 16 $bp->friends->slug = BP_FRIENDS_SLUG;17 23 18 24 /* Register this in the active components array */ … … 103 109 function friends_screen_notification_settings() { 104 110 global $current_user; ?> 105 <table class="notification-settings" id="friends-notification-settings"> 106 <tr> 107 <th class="icon"></th> 108 <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th> 109 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 110 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 111 </tr> 112 <tr> 113 <td></td> 114 <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td> 115 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_request') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_request') ) { ?>checked="checked" <?php } ?>/></td> 116 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_usermeta( $current_user->id,'notification_friends_friendship_request') == 'no' ) { ?>checked="checked" <?php } ?>/></td> 117 </tr> 118 <tr> 119 <td></td> 120 <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td> 121 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_accepted') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td> 122 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td> 123 </tr> 124 125 <?php do_action( 'friends_screen_notification_settings' ); ?> 111 <table class="notification-settings zebra" id="friends-notification-settings"> 112 <thead> 113 <tr> 114 <th class="icon"></th> 115 <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th> 116 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 117 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 118 </tr> 119 </thead> 120 121 <tbody> 122 <tr> 123 <td></td> 124 <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td> 125 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) ) { ?>checked="checked" <?php } ?>/></td> 126 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) == 'no' ) { ?>checked="checked" <?php } ?>/></td> 127 </tr> 128 <tr> 129 <td></td> 130 <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td> 131 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td> 132 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td> 133 </tr> 134 135 <?php do_action( 'friends_screen_notification_settings' ); ?> 136 </tbody> 126 137 </table> 127 138 <?php … … 237 248 'item_id' => false, 238 249 'secondary_item_id' => false, 239 'recorded_time' => gmdate( "Y-m-d H:i:s"),250 'recorded_time' => bp_core_current_time(), 240 251 'hide_sitewide' => false 241 252 ); … … 318 329 $friendship->is_confirmed = 0; 319 330 $friendship->is_limited = 0; 320 $friendship->date_created = time();331 $friendship->date_created = bp_core_current_time(); 321 332 322 333 if ( $force_accept ) … … 372 383 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 373 384 374 / * Remove the friend request notice */385 // Remove the friend request notice 375 386 bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' ); 376 387 377 / * Add a friend accepted notice for the initiating user */388 // Add a friend accepted notice for the initiating user 378 389 bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' ); 379 390 … … 381 392 $friend_link = bp_core_get_userlink( $friendship->friend_user_id ); 382 393 383 / * Record in activity streams for the initiator */394 // Record in activity streams for the initiator 384 395 friends_record_activity( array( 385 'user_id' => $friendship->initiator_user_id, 386 'type' => 'friendship_created', 387 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ), 388 'item_id' => $friendship_id 396 'user_id' => $friendship->initiator_user_id, 397 'type' => 'friendship_created', 398 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ), 399 'item_id' => $friendship_id, 400 'secondary_item_id' => $friendship->friend_user_id 389 401 ) ); 390 402 391 / * Record in activity streams for the friend */403 // Record in activity streams for the friend 392 404 friends_record_activity( array( 393 'user_id' => $friendship->friend_user_id, 394 'type' => 'friendship_created', 395 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ), 396 'item_id' => $friendship_id, 397 'hide_sitewide' => true /* We've already got the first entry site wide */ 405 'user_id' => $friendship->friend_user_id, 406 'type' => 'friendship_created', 407 'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ), 408 'item_id' => $friendship_id, 409 'secondary_item_id' => $friendship->initiator_user_id, 410 'hide_sitewide' => true // We've already got the first entry site wide 398 411 ) ); 399 412 400 / * Send the email notification */413 // Send the email notification 401 414 require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' ); 402 415 friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); … … 444 457 445 458 if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) { 446 $count = get_user meta( $user_id, 'total_friend_count');459 $count = get_user_meta( $user_id, 'total_friend_count', true ); 447 460 if ( empty( $count ) ) $count = 0; 448 461 wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' ); … … 547 560 function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) { 548 561 if ( 'add' == $status ) { 549 update_user meta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count') + 1 );550 update_user meta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count') + 1 );562 update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 ); 563 update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 ); 551 564 } else { 552 update_user meta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count') - 1 );553 update_user meta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count') - 1 );565 update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 ); 566 update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 ); 554 567 } 555 568 } … … 559 572 560 573 /* Remove usermeta */ 561 delete_user meta( $user_id, 'total_friend_count' );574 delete_user_meta( $user_id, 'total_friend_count' ); 562 575 563 576 /* Remove friendship requests FROM user */ … … 566 579 do_action( 'friends_remove_data', $user_id ); 567 580 } 568 add_action( 'wpmu_delete_user', 'friends_remove_data' , 1);569 add_action( 'delete_user', 'friends_remove_data' , 1);570 add_action( 'make_spam_user', 'friends_remove_data' , 1);581 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 582 add_action( 'delete_user', 'friends_remove_data' ); 583 add_action( 'make_spam_user', 'friends_remove_data' ); 571 584 572 585 … … 595 608 global $bp; 596 609 597 if ( isset( $_GET['new']) )598 bp_core_delete_notifications_for_user_by_type( $bp-> displayed_user->id, $bp->friends->id, 'friendship_accepted' );610 if ( isset( $_GET['new'] ) ) 611 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' ); 599 612 } 600 613 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' ); -
trunk/bp-friends/bp-friends-classes.php
r2919 r3300 61 61 if ( $this->id ) { 62 62 // Update 63 $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = FROM_UNIXTIME(%d)) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );63 $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) ); 64 64 } else { 65 65 // Save 66 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->friends->table_name} ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d))", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created ) );66 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->friends->table_name} ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES ( %d, %d, %d, %d, %s )", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created ) ); 67 67 $this->id = $wpdb->insert_id; 68 68 } … … 127 127 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) ); 128 128 129 if ( !$count ) 129 // Do not update meta if user has never had friends 130 if ( !$count && !get_user_meta( $user_id, 'total_friend_count', true ) ) 130 131 return 0; 131 132 132 update_user meta( $user_id, 'total_friend_count',$count );133 return $count;133 update_user_meta( $user_id, 'total_friend_count', (int)$count ); 134 return (int)$count; 134 135 } 135 136 … … 202 203 global $wpdb, $bp; 203 204 204 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = FROM_UNIXTIME(%d) WHERE id = %d AND friend_user_id = %d",time(), $friendship_id, $bp->loggedin_user->id ) );205 return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, $bp->loggedin_user->id ) ); 205 206 } 206 207 … … 315 316 global $wpdb, $bp; 316 317 318 // Get friends of $user_id 319 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ); 320 321 // Delete all friendships related to $user_id 317 322 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) ); 318 323 319 324 // Delete friend request notifications for members who have a notification from this user. 320 325 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) ); 326 327 // Loop through friend_ids and update their counts 328 foreach ( (array)$friend_ids as $friend_id ) { 329 BP_Friends_Friendship::total_friend_count( $friend_id ); 330 } 321 331 } 322 332 } -
trunk/bp-friends/bp-friends-notifications.php
r2941 r3300 6 6 $initiator_name = bp_core_get_user_displayname( $initiator_id ); 7 7 8 if ( 'no' == get_user meta( (int)$friend_id, 'notification_friends_friendship_request') )8 if ( 'no' == get_user_meta( (int)$friend_id, 'notification_friends_friendship_request', true ) ) 9 9 return false; 10 10 … … 18 18 19 19 // Set up and send the message 20 $to = $ud->user_email; 21 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name ); 20 $to = $ud->user_email; 21 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 22 $subject = '[' . $sitename . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name ); 22 23 23 24 $message = sprintf( __( … … 48 49 $friend_name = bp_core_get_user_displayname( $friend_id ); 49 50 50 if ( 'no' == get_user meta( (int)$initiator_id, 'notification_friends_friendship_accepted') )51 if ( 'no' == get_user_meta( (int)$initiator_id, 'notification_friends_friendship_accepted', true ) ) 51 52 return false; 52 53 … … 57 58 58 59 // Set up and send the message 59 $to = $ud->user_email; 60 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name ); 60 $to = $ud->user_email; 61 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 62 $subject = '[' . $sitename . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name ); 61 63 62 64 $message = sprintf( __( -
trunk/bp-friends/bp-friends-templatetags.php
r3263 r3300 105 105 <form action="<?php echo $action ?>" id="friend-search-form" method="post"> 106 106 107 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>108 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />109 110 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>111 <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />107 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label> 108 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> /> 109 110 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?> 111 <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( $bp->displayed_user->id ) ?>" /> 112 112 113 113 </form> -
trunk/bp-groups.php
r3273 r3300 16 16 $bp->groups->slug = BP_GROUPS_SLUG; 17 17 18 $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups'; 19 $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members'; 20 $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta'; 18 $bp->groups->table_name = $bp->table_prefix . 'bp_groups'; 19 $bp->groups->table_name_members = $bp->table_prefix . 'bp_groups_members'; 20 $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta'; 21 21 22 $bp->groups->format_notification_function = 'groups_format_notifications'; 22 23 … … 37 38 $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) ); 38 39 40 // Auto join group when non group member performs group activity 41 $bp->groups->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true; 42 39 43 do_action( 'groups_setup_globals' ); 40 44 } … … 44 48 global $bp; 45 49 46 if ( $ group_id = BP_Groups_Group::group_exists($bp->current_action) ) {50 if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { 47 51 48 52 /* This is a single group page. */ … … 51 55 52 56 /* Using "item" not "group" for generic support in other components. */ 53 if ( is_s ite_admin() )57 if ( is_super_admin() ) 54 58 $bp->is_item_admin = 1; 55 59 else … … 100 104 101 105 if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ) 102 $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';106 $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />'; 103 107 104 108 $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/'; … … 106 110 // If this is a private or hidden group, does the user have access? 107 111 if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) { 108 if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_s ite_admin() )112 if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_super_admin() ) 109 113 $bp->groups->current_group->user_has_access = true; 110 114 else … … 128 132 129 133 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 130 if ( !is_s ite_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )134 if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' ) 131 135 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) ); 132 136 … … 166 170 167 171 /* Don't show this menu to non site admins or if you're viewing your own profile */ 168 if ( !is_s ite_admin() )172 if ( !is_super_admin() ) 169 173 return false; 170 174 ?> … … 226 230 227 231 groups_record_activity( array( 228 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$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 ),232 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ), 229 233 'type' => 'joined_group', 230 234 'item_id' => $group->id … … 292 296 293 297 /* Auto join this user if they are not yet a member of this group */ 294 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )298 if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 295 299 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 296 300 … … 470 474 471 475 /* Auto join this user if they are not yet a member of this group */ 472 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )476 if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 473 477 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 474 478 … … 492 496 493 497 if ( $bp->is_single_item ) { 498 /* Refresh the group member count meta */ 499 groups_update_groupmeta( $bp->groups->current_group->id, 'total_member_count', groups_get_total_member_count( $bp->groups->current_group->id ) ); 500 494 501 do_action( 'groups_screen_group_members', $bp->groups->current_group->id ); 495 502 bp_core_load_template( apply_filters( 'groups_template_group_members', 'groups/single/home' ) ); … … 711 718 $status = $bp->action_variables[2]; 712 719 713 / * Check the nonce first. */720 // Check the nonce first. 714 721 if ( !check_admin_referer( 'groups_promote_member' ) ) 715 722 return false; 716 723 717 724 // Promote a user. 718 if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {725 if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) 719 726 bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' ); 720 } else {727 else 721 728 bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) ); 722 }723 729 724 730 do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id ); … … 730 736 $user_id = $bp->action_variables[2]; 731 737 732 / * Check the nonce first. */738 // Check the nonce first. 733 739 if ( !check_admin_referer( 'groups_demote_member' ) ) 734 740 return false; 735 741 736 742 // Demote a user. 737 if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {743 if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) 738 744 bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' ); 739 } else {745 else 740 746 bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) ); 741 }742 747 743 748 do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id ); … … 749 754 $user_id = $bp->action_variables[2]; 750 755 751 / * Check the nonce first. */756 // Check the nonce first. 752 757 if ( !check_admin_referer( 'groups_ban_member' ) ) 753 758 return false; 754 759 755 760 // Ban a user. 756 if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {761 if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) 757 762 bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' ); 758 } else {763 else 759 764 bp_core_add_message( __( 'User banned successfully', 'buddypress' ) ); 760 }761 765 762 766 do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id ); … … 768 772 $user_id = $bp->action_variables[2]; 769 773 770 / * Check the nonce first. */774 // Check the nonce first. 771 775 if ( !check_admin_referer( 'groups_unban_member' ) ) 772 776 return false; 773 777 774 778 // Remove a ban for user. 775 if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {779 if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) 776 780 bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' ); 777 } else {781 else 778 782 bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) ); 779 }780 783 781 784 do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id ); … … 784 787 } 785 788 789 if ( 'remove' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) { 790 $user_id = $bp->action_variables[2]; 791 792 // Check the nonce first. 793 if ( !check_admin_referer( 'groups_remove_member' ) ) 794 return false; 795 796 // Remove a user. 797 if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) ) 798 bp_core_add_message( __( 'There was an error removing that user from the group, please try again', 'buddypress' ), 'error' ); 799 else 800 bp_core_add_message( __( 'User removed successfully', 'buddypress' ) ); 801 802 do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id ); 803 804 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' ); 805 } 806 786 807 do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id ); 787 808 … … 795 816 796 817 if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) { 818 819 /* Ask for a login if the user is coming here via an email notification */ 820 if ( !is_user_logged_in() ) 821 bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) ); 797 822 798 823 if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status ) … … 850 875 if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) { 851 876 852 if ( !$bp->is_item_admin && !is_s ite_admin() )877 if ( !$bp->is_item_admin && !is_super_admin() ) 853 878 return false; 854 879 … … 881 906 function groups_screen_notification_settings() { 882 907 global $current_user; ?> 883 <table class="notification-settings" id="groups-notification-settings"> 884 <tr> 885 <th class="icon"></th> 886 <th class="title"><?php _e( 'Groups', 'buddypress' ) ?></th> 887 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 888 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 889 </tr> 890 <tr> 891 <td></td> 892 <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td> 893 <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_invite') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td> 894 <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td> 895 </tr> 896 <tr> 897 <td></td> 898 <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td> 899 <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td> 900 <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td> 901 </tr> 902 <tr> 903 <td></td> 904 <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td> 905 <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_admin_promotion') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td> 906 <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td> 907 </tr> 908 <tr> 909 <td></td> 910 <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td> 911 <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_membership_request') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td> 912 <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td> 913 </tr> 914 915 <?php do_action( 'groups_screen_notification_settings' ); ?> 908 <table class="notification-settings zebra" id="groups-notification-settings"> 909 <thead> 910 <tr> 911 <th class="icon"></th> 912 <th class="title"><?php _e( 'Groups', 'buddypress' ) ?></th> 913 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 914 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 915 </tr> 916 </thead> 917 918 <tbody> 919 <tr> 920 <td></td> 921 <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td> 922 <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_invite', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td> 923 <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td> 924 </tr> 925 <tr> 926 <td></td> 927 <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td> 928 <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td> 929 <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td> 930 </tr> 931 <tr> 932 <td></td> 933 <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td> 934 <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td> 935 <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td> 936 </tr> 937 <tr> 938 <td></td> 939 <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td> 940 <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td> 941 <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td> 942 </tr> 943 944 <?php do_action( 'groups_screen_notification_settings' ); ?> 945 </tbody> 916 946 </table> 917 947 <?php … … 982 1012 } 983 1013 984 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( $_POST['group-name']) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) {1014 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) { 985 1015 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 986 1016 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' ); … … 1041 1071 /* Once we compelete all steps, record the group creation in the activity stream. */ 1042 1072 groups_record_activity( array( 1043 'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$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>' ) ),1073 'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ), 1044 1074 'type' => 'created_group', 1045 1075 'item_id' => $bp->groups->new_group_id … … 1105 1135 return false; 1106 1136 1107 // user wants to join a group 1137 // Nonce check 1138 if ( !check_admin_referer( 'groups_join_group' ) ) 1139 return false; 1140 1141 // Skip if banned or already a member 1108 1142 if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 1109 if ( !groups_join_group($bp->groups->current_group->id) ) { 1110 bp_core_add_message( __('There was an error joining the group.', 'buddypress'), 'error' ); 1143 1144 // User wants to join a group that is not public 1145 if ( $bp->groups->current_group->status != 'public' ) { 1146 if ( !groups_check_user_has_invite( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 1147 bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' ); 1148 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 1149 } 1150 } 1151 1152 // User wants to join any group 1153 if ( !groups_join_group( $bp->groups->current_group->id ) ) 1154 bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' ); 1155 else 1156 bp_core_add_message( __( 'You joined the group!', 'buddypress' ) ); 1157 1158 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 1159 } 1160 1161 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 1162 } 1163 add_action( 'wp', 'groups_action_join_group', 3 ); 1164 1165 1166 function groups_action_leave_group() { 1167 global $bp; 1168 1169 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' ) 1170 return false; 1171 1172 // Nonce check 1173 if ( !check_admin_referer( 'groups_leave_group' ) ) 1174 return false; 1175 1176 // User wants to leave any group 1177 if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 1178 if ( !groups_leave_group( $bp->groups->current_group->id ) ) { 1179 bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' ); 1111 1180 } else { 1112 bp_core_add_message( __( 'You joined the group!', 'buddypress') );1181 bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) ); 1113 1182 } 1114 1183 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); … … 1117 1186 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 1118 1187 } 1119 add_action( 'wp', 'groups_action_join_group', 3 ); 1188 add_action( 'wp', 'groups_action_leave_group', 3 ); 1189 1120 1190 1121 1191 function groups_action_sort_creation_steps() { … … 1218 1288 'item_id' => false, 1219 1289 'secondary_item_id' => false, 1220 'recorded_time' => gmdate( "Y-m-d H:i:s"),1290 'recorded_time' => bp_core_current_time(), 1221 1291 'hide_sitewide' => $hide_sitewide 1222 1292 ); … … 1250 1320 1251 1321 if ( (int)$total_items > 1 ) { 1252 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );1322 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name ); 1253 1323 } else { 1254 1324 $user_fullname = bp_core_get_user_displayname( $requesting_user_id ); 1255 return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . $user_fullname .' requests group membership">' . sprintf( __('%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );1325 return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . sprintf( __( '%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name ); 1256 1326 } 1257 1327 break; … … 1263 1333 $group_link = bp_get_group_permalink( $group ); 1264 1334 1265 if ( (int)$total_items > 1 ) {1266 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );1267 } else {1268 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );1269 } 1335 if ( (int)$total_items > 1 ) 1336 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name ); 1337 else 1338 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1339 1270 1340 break; 1271 1341 … … 1276 1346 $group_link = bp_get_group_permalink( $group ); 1277 1347 1278 if ( (int)$total_items > 1 ) { 1279 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name ); 1280 } else { 1281 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name ); 1282 } 1348 if ( (int)$total_items > 1 ) 1349 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name ); 1350 else 1351 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1283 1352 1284 1353 break; … … 1290 1359 $group_link = bp_get_group_permalink( $group ); 1291 1360 1292 if ( (int)$total_items > 1 ) {1293 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );1294 } else {1295 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );1296 } 1361 if ( (int)$total_items > 1 ) 1362 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1363 else 1364 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1365 1297 1366 break; 1298 1367 … … 1303 1372 $group_link = bp_get_group_permalink( $group ); 1304 1373 1305 if ( (int)$total_items > 1 ) {1306 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );1307 } else {1308 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );1309 } 1374 if ( (int)$total_items > 1 ) 1375 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1376 else 1377 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name ); 1378 1310 1379 break; 1311 1380 … … 1316 1385 $user_url = bp_core_get_user_domain( $user_id ); 1317 1386 1318 if ( (int)$total_items > 1 ) {1319 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );1320 } else {1321 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );1322 } 1387 if ( (int)$total_items > 1 ) 1388 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1389 else 1390 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name ); 1391 1323 1392 break; 1324 1393 } … … 1413 1482 $member->user_title = __( 'Group Admin', 'buddypress' ); 1414 1483 $member->is_confirmed = 1; 1415 $member->date_modified = gmdate( "Y-m-d H:i:s");1484 $member->date_modified = bp_core_current_time(); 1416 1485 1417 1486 $member->save(); 1418 1487 do_action( 'groups_create_group', $group->id, $member, $group ); 1488 1419 1489 } else { 1420 1490 do_action( 'groups_update_group', $group->id, $group ); … … 1481 1551 } 1482 1552 1553 /** 1554 * Delete a group and all of its associated meta 1555 * 1556 * @global object $bp BuddyPress global settings 1557 * @param int $group_id 1558 * @since 1.0 1559 */ 1483 1560 function groups_delete_group( $group_id ) { 1484 1561 global $bp; … … 1490 1567 // Get the group object 1491 1568 $group = new BP_Groups_Group( $group_id ); 1492 1493 1569 if ( !$group->delete() ) 1494 1570 return false; 1495 1571 1496 / * Delete all group activity from activity streams */1497 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {1572 // Delete all group activity from activity streams 1573 if ( bp_is_active( 'activity' ) ) 1498 1574 bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component' => $bp->groups->id ) ); 1499 }1500 1575 1501 1576 // Remove all outstanding invites for this group … … 1505 1580 bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug ); 1506 1581 1507 do_action( 'groups_delete_group', $group_id ); 1582 // Remove forum if component is active and current group has one 1583 if ( bp_is_active( 'forums' ) && $forum_id = groups_get_groupmeta( $group_id, 'forum_id' ) ) { 1584 do_action( 'bbpress_init' ); 1585 bb_delete_forum( $forum_id ); 1586 } 1587 1588 do_action( 'groups_delete_group', $group_id); 1508 1589 1509 1590 return true; … … 1567 1648 1568 1649 /* Modify user's group memberhip count */ 1569 update_user meta( $user_id, 'total_group_count', (int) get_usermeta( $user_id, 'total_group_count') - 1 );1650 update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 ); 1570 1651 1571 1652 /* If the user joined this group less than five minutes ago, remove the joined_group activity so … … 1617 1698 /* Record this in activity streams */ 1618 1699 groups_record_activity( array( 1619 'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$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>' ) ),1700 'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ), 1620 1701 'type' => 'joined_group', 1621 1702 'item_id' => $group_id … … 1649 1730 } 1650 1731 1732 function groups_get_total_member_count( $group_id ) { 1733 return BP_Groups_Group::get_total_member_count( $group_id ); 1734 } 1735 1651 1736 /*** Group Fetching, Filtering & Searching *************************************/ 1652 1737 … … 1657 1742 'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts 1658 1743 'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of 1659 'include' => false, // Only include these specific groups (group_ids)1660 1744 'search_terms' => false, // Limit to groups that match these search terms 1661 1745 … … 1668 1752 extract( $params, EXTR_SKIP ); 1669 1753 1670 $groups = BP_Groups_Group::get( $type, $per_page, $page, $user_id, $search_terms, $include, $populate_extras ); 1754 switch ( $type ) { 1755 case 'active': default: 1756 $groups = BP_Groups_Group::get_active( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1757 break; 1758 case 'newest': 1759 $groups = BP_Groups_Group::get_newest( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1760 break; 1761 case 'popular': 1762 $groups = BP_Groups_Group::get_popular( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1763 break; 1764 case 'alphabetical': 1765 $groups = BP_Groups_Group::get_alphabetically( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1766 break; 1767 case 'random': 1768 $groups = BP_Groups_Group::get_random( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1769 break; 1770 case 'most-forum-topics': 1771 $groups = BP_Groups_Group::get_by_most_forum_topics( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1772 break; 1773 case 'most-forum-posts': 1774 $groups = BP_Groups_Group::get_by_most_forum_posts( $per_page, $page, $user_id, $search_terms, $populate_extras ); 1775 break; 1776 } 1671 1777 1672 1778 return apply_filters( 'groups_get_groups', $groups, &$params ); … … 1719 1825 @wp_mkdir_p( $path ); 1720 1826 1721 $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );1827 $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id; 1722 1828 $newburl = $newurl; 1723 1829 $newsubdir = '/group-avatars/' . $group_id; … … 1742 1848 function groups_is_user_banned( $user_id, $group_id ) { 1743 1849 return BP_Groups_Member::check_is_banned( $user_id, $group_id ); 1850 } 1851 1852 /** 1853 * Is the specified user the creator of the group? 1854 * 1855 * @param int $user_id 1856 * @param int $group_id 1857 * @since 1.2.6 1858 * @uses BP_Groups_Member 1859 */ 1860 function groups_is_user_creator( $user_id, $group_id ) { 1861 return BP_Groups_Member::check_is_creator( $user_id, $group_id ); 1744 1862 } 1745 1863 … … 1764 1882 1765 1883 /* Be sure the user is a member of the group before posting. */ 1766 if ( !is_s ite_admin() && !groups_is_user_member( $user_id, $group_id ) )1884 if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) ) 1767 1885 return false; 1768 1886 1769 1887 /* Record this in activity streams */ 1770 $activity_action = sprintf( __( '%1$s posted an update in the group %2$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>' );1888 $activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1771 1889 $activity_content = $content; 1772 1890 … … 1806 1924 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 1807 1925 1808 do_action( 'groups_new_group_forum', $forum, $group_id ); 1809 } 1926 do_action( 'groups_new_group_forum', $forum_id, $group_id ); 1927 } 1928 1929 function groups_update_group_forum( $group_id ) { 1930 1931 $group = new BP_Groups_Group( $group_id ); 1932 1933 if ( !$group->enable_forum || !function_exists( 'bp_forums_setup' ) ) 1934 return false; 1935 1936 $args = array( 1937 'forum_id' => groups_get_groupmeta( $group_id, 'forum_id' ), 1938 'forum_name' => $group->name, 1939 'forum_desc' => $group->desc, 1940 'forum_slug' => $group->slug 1941 ); 1942 1943 bp_forums_update_forum( apply_filters( 'groups_update_group_forum', $args ) ); 1944 } 1945 add_action( 'groups_details_updated', 'groups_update_group_forum' ); 1810 1946 1811 1947 function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) { … … 1821 1957 $topic = bp_forums_get_topic_details( $topic_id ); 1822 1958 1823 $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$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>' );1959 $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$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 .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1824 1960 $activity_content = bp_create_excerpt( $post_text ); 1825 1961 $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/'; … … 1860 1996 $topic = bp_forums_get_topic_details( $topic_id ); 1861 1997 1862 $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$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>' );1998 $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$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 .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1863 1999 $activity_content = bp_create_excerpt( $topic_text ); 1864 2000 … … 1892 2028 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' ) ); 1893 2029 1894 $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$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>' );2030 $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1895 2031 $activity_content = bp_create_excerpt( $topic_text ); 1896 2032 … … 1926 2062 $topic = bp_forums_get_topic_details( $topic_id ); 1927 2063 1928 $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$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>' );2064 $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ); 1929 2065 $activity_content = bp_create_excerpt( $post_text ); 1930 2066 $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/'; … … 2065 2201 return false; 2066 2202 2203 /* Remove request to join */ 2204 if ( $member->check_for_membership_request( $user_id, $group_id ) ) 2205 $member->delete_request( $user_id, $group_id ); 2206 2067 2207 /* Modify group meta */ 2068 2208 groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 ); … … 2167 2307 do_action( 'groups_ban_member', $group_id, $user_id ); 2168 2308 2169 if ( !$member->ban() ) 2170 return false; 2171 2172 update_usermeta( $user_id, 'total_group_count', (int)$total_count - 1 ); 2309 return $member->ban(); 2173 2310 } 2174 2311 … … 2184 2321 2185 2322 return $member->unban(); 2323 } 2324 2325 /*** Group Removal *******************************************************/ 2326 2327 function groups_remove_member( $user_id, $group_id ) { 2328 global $bp; 2329 2330 if ( !$bp->is_item_admin ) 2331 return false; 2332 2333 $member = new BP_Groups_Member( $user_id, $group_id ); 2334 2335 do_action( 'groups_remove_member', $group_id, $user_id ); 2336 2337 return $member->remove(); 2186 2338 } 2187 2339 … … 2240 2392 return false; 2241 2393 2394 /* Check if the user has an outstanding invite, if so delete it. */ 2395 if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) ) 2396 groups_delete_invite( $membership->user_id, $membership->group_id ); 2397 2242 2398 /* Modify group member count */ 2243 2399 groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 ); 2244 2400 2245 2401 /* Record this in activity streams */ 2246 $group = new BP_Groups_Group( $ group_id );2402 $group = new BP_Groups_Group( $membership->group_id ); 2247 2403 2248 2404 groups_record_activity( array( 2249 'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),2250 'type' 2251 'item_id' => $group->id,2252 'user_id' => $user_id2405 'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ), 2406 'type' => 'joined_group', 2407 'item_id' => $membership->group_id, 2408 'user_id' => $membership->user_id 2253 2409 ) ); 2254 2410 … … 2409 2565 do_action( 'groups_remove_data_for_user', $user_id ); 2410 2566 } 2411 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' , 1);2412 add_action( 'delete_user', 'groups_remove_data_for_user' , 1);2413 add_action( 'make_spam_user', 'groups_remove_data_for_user' , 1);2567 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' ); 2568 add_action( 'delete_user', 'groups_remove_data_for_user' ); 2569 add_action( 'make_spam_user', 'groups_remove_data_for_user' ); 2414 2570 2415 2571 -
trunk/bp-groups/bp-groups-classes.php
r3232 r3300 38 38 39 39 /* Get group admins and mods */ 40 $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ), $this->id ) );40 $admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) ); 41 41 foreach( (array)$admin_mods as $user ) { 42 42 if ( (int)$user->is_admin ) … … 205 205 } 206 206 207 if ( !is_s ite_admin() )207 if ( !is_super_admin() ) 208 208 $hidden_sql = "AND status != 'hidden'"; 209 209 … … 256 256 } 257 257 258 function get( $type = 'newest', $per_page = null, $page = null, $user_id = false, $search_terms = false, $include = false, $populate_extras = true ) { 259 global $wpdb, $bp; 260 261 $sql = array(); 262 263 $sql['select'] = "SELECT g.*, gm1.meta_value AS total_member_count, gm2.meta_value AS last_activity"; 264 $sql['from'] = " FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2,"; 265 266 if ( !empty( $user_id ) ) 267 $sql['members_from'] = " {$bp->groups->table_name_members} m,"; 268 269 $sql['group_from'] = " {$bp->groups->table_name} g WHERE"; 270 271 if ( !empty( $user_id ) ) 272 $sql['user_where'] = " g.id = m.group_id AND"; 273 274 $sql['where'] = " g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'"; 275 276 if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 277 $sql['hidden'] = " AND g.status != 'hidden'"; 258 /* TODO: Merge all these get_() functions into one. */ 259 260 function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 261 global $wpdb, $bp; 262 263 if ( $limit && $page ) 264 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 265 266 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 267 $hidden_sql = "AND g.status != 'hidden'"; 278 268 279 269 if ( $search_terms ) { 280 270 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 281 $sql['search'] = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 282 } 283 284 if ( !empty( $user_id ) ) 285 $sql['user'] = $wpdb->prepare( " AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ); 286 287 if ( !empty( $include ) ) { 288 $include = $wpdb->escape( $include ); 289 $sql['include'] = " AND g.id IN ({$include})"; 290 } 291 292 switch ( $type ) { 293 case 'newest': default: 294 $sql['order'] = " ORDER BY g.date_created DESC"; 295 break; 296 case 'active': 297 $sql[] = "ORDER BY last_activity DESC"; 298 break; 299 case 'popular': 300 $sql[] = "ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC"; 301 break; 302 case 'alphabetical': 303 $sql[] = "ORDER BY g.name ASC"; 304 break; 305 case 'random': 306 $sql[] = "ORDER BY rand()"; 307 break; 308 } 309 310 if ( $per_page && $page ) 311 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page), intval( $per_page ) ); 312 313 /* Get paginated results */ 314 $paged_groups = $wpdb->get_results( join( ' ', (array)$sql ) ); 315 316 $total_sql['select'] = "SELECT COUNT(g.id) FROM {$bp->groups->table_name} g"; 317 318 if ( !empty( $user_id ) ) 319 $total_sql['select'] .= ", {$bp->groups->table_name_members} m"; 320 321 if ( !empty( $sql['hidden'] ) ) 322 $total_sql['where'][] = "g.status != 'hidden'"; 323 324 if ( !empty( $sql['search'] ) ) 325 $total_sql['where'][] = "( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 326 327 if ( !empty( $user_id ) ) 328 $total_sql['where'][] = "m.group_id = g.id AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0"; 329 330 $t_sql = $total_sql['select']; 331 332 if ( !empty( $total_sql['where'] ) ) 333 $t_sql .= " WHERE " . join( ' AND ', (array)$total_sql['where'] ); 334 335 /* Get total group results */ 336 $total_groups = $wpdb->get_var( join( ' ', (array)$t_sql ) ); 337 338 /* Populate some extra information instead of querying each time in the loop */ 271 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 272 } 273 274 if ( $user_id ) { 275 $user_id = $wpdb->escape( $user_id ); 276 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}" ); 277 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 278 } else { 279 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" ); 280 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ); 281 } 282 339 283 if ( !empty( $populate_extras ) ) { 340 284 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 341 285 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 342 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, $type ); 343 } 344 345 unset( $sql, $total_sql ); 286 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 287 } 288 289 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 290 } 291 292 function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 293 global $wpdb, $bp; 294 295 if ( $limit && $page ) 296 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 297 298 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 299 $hidden_sql = "AND g.status != 'hidden'"; 300 301 if ( $search_terms ) { 302 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 303 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 304 } 305 306 if ( $user_id ) { 307 $user_id = $wpdb->escape( $user_id ); 308 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}" ); 309 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 310 } else { 311 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" ); 312 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ); 313 } 314 315 if ( !empty( $populate_extras ) ) { 316 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 317 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 318 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 319 } 320 321 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 322 } 323 324 function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 325 global $wpdb, $bp; 326 327 if ( $limit && $page ) { 328 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 329 } 330 331 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 332 $hidden_sql = "AND g.status != 'hidden'"; 333 334 if ( $search_terms ) { 335 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 336 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 337 } 338 339 if ( $user_id ) { 340 $user_id = $wpdb->escape( $user_id ); 341 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" ); 342 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 343 } else { 344 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" ); 345 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ); 346 } 347 348 if ( !empty( $populate_extras ) ) { 349 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 350 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 351 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 352 } 353 354 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 355 } 356 357 function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 358 global $wpdb, $bp; 359 360 if ( $limit && $page ) 361 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 362 363 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 364 $hidden_sql = " AND g.status != 'hidden'"; 365 366 if ( $search_terms ) { 367 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 368 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 369 } 370 371 if ( $user_id ) { 372 $user_id = $wpdb->escape( $user_id ); 373 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}" ); 374 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 375 } else { 376 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ); 377 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" ); 378 } 379 380 if ( !empty( $populate_extras ) ) { 381 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 382 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 383 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 384 } 346 385 347 386 return array( 'groups' => $paged_groups, 'total' => $total_groups ); … … 358 397 } 359 398 360 if ( !is_user_logged_in() || ( !is_s ite_admin() && ( $user_id != $bp->loggedin_user->id ) ) )399 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 361 400 $hidden_sql = " AND g.status != 'hidden'"; 362 401 … … 394 433 } 395 434 396 if ( !is_user_logged_in() || ( !is_s ite_admin() && ( $user_id != $bp->loggedin_user->id ) ) )435 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 397 436 $hidden_sql = " AND g.status != 'hidden'"; 398 437 … … 420 459 } 421 460 461 function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) { 462 global $wpdb, $bp; 463 464 // Default sql WHERE conditions are blank. TODO: generic handler function. 465 $where_sql = null; 466 $where_conditions = array(); 467 468 // Limit results to public status 469 if ( $only_public ) 470 $where_conditions[] = $wpdb->prepare( "g.status = 'public'" ); 471 472 if ( !is_super_admin() ) 473 $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'"); 474 475 // Build where sql statement if necessary 476 if ( !empty( $where_conditions ) ) 477 $where_sql = 'WHERE ' . join( ' AND ', $where_conditions ); 478 479 if ( $limit && $page ) 480 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 481 482 if ( $sort_by && $order ) { 483 $sort_by = $wpdb->escape( $sort_by ); 484 $order = $wpdb->escape( $order ); 485 $order_sql = "ORDER BY g.$sort_by $order"; 486 487 switch ( $sort_by ) { 488 default: 489 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" ); 490 break; 491 case 'members': 492 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); 493 break; 494 case 'last_active': 495 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); 496 break; 497 } 498 } else { 499 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" ); 500 } 501 502 return $wpdb->get_results($sql); 503 } 504 422 505 function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true ) { 423 506 global $wpdb, $bp; 424 507 425 if ( strlen($letter) > 1 || is_numeric($letter) || !$letter ) 426 return false; 427 428 if ( !is_site_admin() ) 508 // Multibyte compliance 509 if ( function_exists( 'mb_strlen' ) ) { 510 if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) { 511 return false; 512 } 513 } else { 514 if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) { 515 return false; 516 } 517 } 518 519 if ( !is_super_admin() ) 429 520 $hidden_sql = $wpdb->prepare( " AND status != 'hidden'"); 430 521 … … 437 528 438 529 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" ) ); 530 531 if ( !empty( $populate_extras ) ) { 532 foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id; 533 $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) ); 534 $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' ); 535 } 536 537 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 538 } 539 540 function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) { 541 global $wpdb, $bp; 542 543 if ( $limit && $page ) 544 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 545 546 if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) ) 547 $hidden_sql = "AND g.status != 'hidden'"; 548 549 if ( $search_terms ) { 550 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 551 $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )"; 552 } 553 554 if ( $user_id ) { 555 $user_id = $wpdb->escape( $user_id ); 556 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}" ); 557 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" ); 558 } else { 559 $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" ); 560 $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" ); 561 } 439 562 440 563 if ( !empty( $populate_extras ) ) { … … 482 605 global $wpdb, $bp; 483 606 484 if ( !is_s ite_admin() )607 if ( !is_super_admin() ) 485 608 $hidden_sql = "WHERE status != 'hidden'"; 486 609 … … 654 777 655 778 function accept_invite() { 656 $this->inviter_id = 0;657 $this->is_confirmed = 1;779 $this->inviter_id = 0; 780 $this->is_confirmed = 1; 658 781 $this->date_modified = bp_core_current_time(); 782 783 update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 ); 659 784 } 660 785 … … 662 787 $this->is_confirmed = 1; 663 788 $this->date_modified = bp_core_current_time(); 664 } 665 666 function remove( $user_id, $group_id ) { 667 global $wpdb, $bp; 668 669 $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ); 789 790 update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 ); 791 } 792 793 function remove() { 794 global $wpdb, $bp; 795 796 $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id ); 670 797 671 798 if ( !$result = $wpdb->query( $sql ) ) -
trunk/bp-groups/bp-groups-filters.php
r2770 r3300 93 93 global $bp; 94 94 95 if ( is_s ite_admin() )95 if ( is_super_admin() ) 96 96 return true; 97 97 -
trunk/bp-groups/bp-groups-notifications.php
r2941 r3300 4 4 global $bp; 5 5 6 $group = new BP_Groups_Group( $group_id ); 7 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' ); 6 $group = new BP_Groups_Group( $group_id ); 7 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 8 $subject = '[' . $sitename . '] ' . __( 'Group Details Updated', 'buddypress' ); 8 9 9 10 $user_ids = BP_Groups_Member::get_group_member_ids( $group->id ); 10 11 foreach ( (array)$user_ids as $user_id ) { 11 if ( 'no' == get_user meta( $user_id, 'notification_groups_group_updated') ) continue;12 if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) continue; 12 13 13 14 $ud = bp_core_get_core_userdata( $user_id ); … … 45 46 bp_core_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id ); 46 47 47 if ( 'no' == get_user meta( $admin_id, 'notification_groups_membership_request') )48 if ( 'no' == get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) 48 49 return false; 49 50 … … 59 60 60 61 // Set up and send the message 61 $to = $ud->user_email; 62 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ); 62 $to = $ud->user_email; 63 $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 64 $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ); 63 65 64 66 $message = sprintf( __( … … 94 96 bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' ); 95 97 96 if ( 'no' == get_user meta( $requesting_user_id, 'notification_membership_request_completed') )98 if ( 'no' == get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) 97 99 return false; 98 100 … … 105 107 106 108 // Set up and send the message 107 $to = $ud->user_email; 109 $to = $ud->user_email; 110 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 108 111 109 112 if ( $accepted ) { 110 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ). '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );113 $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ); 111 114 $message = sprintf( __( 112 115 'Your membership request for the group "%1$s" has been accepted. … … 118 121 119 122 } else { 120 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ). '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );123 $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name ); 121 124 $message = sprintf( __( 122 125 'Your membership request for the group "%1$s" has been rejected. … … 152 155 bp_core_add_notification( $group_id, $user_id, 'groups', $type ); 153 156 154 if ( 'no' == get_user meta( $user_id, 'notification_groups_admin_promotion') )157 if ( 'no' == get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) 155 158 return false; 156 159 … … 162 165 163 166 // Set up and send the message 164 $to = $ud->user_email;165 166 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ). '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name );167 $to = $ud->user_email; 168 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 169 $subject = '[' . $sitename . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ); 167 170 168 171 $message = sprintf( __( … … 200 203 bp_core_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' ); 201 204 202 if ( 'no' == get_user meta( $invited_user_id, 'notification_groups_invite') )205 if ( 'no' == get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) 203 206 return false; 204 207 … … 210 213 211 214 // Set up and send the message 212 $to = $invited_ud->user_email;213 214 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ). '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name );215 $to = $invited_ud->user_email; 216 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 217 $subject = '[' . $sitename . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ); 215 218 216 219 $message = sprintf( __( … … 241 244 242 245 /* Scan for @username strings in an activity update. Notify each user. */ 243 $pattern = '/[@]+([A-Za-z0-9-_ ]+)/';246 $pattern = '/[@]+([A-Za-z0-9-_\.]+)/'; 244 247 preg_match_all( $pattern, $content, $usernames ); 245 248 … … 251 254 252 255 foreach( (array)$usernames as $username ) { 253 if ( !$receiver_user_id = bp_core_get_userid( $username) )256 if ( !$receiver_user_id = bp_core_get_userid( $username ) ) 254 257 continue; 255 258 … … 259 262 260 263 // Now email the user with the contents of the message (if they have enabled email notifications) 261 if ( 'no' != get_user meta( $user_id, 'notification_activity_new_mention') ) {264 if ( 'no' != get_user_meta( $user_id, 'notification_activity_new_mention', true ) ) { 262 265 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 263 266 … … 271 274 $ud = bp_core_get_core_userdata( $receiver_user_id ); 272 275 $to = $ud->user_email; 273 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name ); 276 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 277 $subject = '[' . $sitename . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name ); 274 278 275 279 $message = sprintf( __( -
trunk/bp-groups/bp-groups-templatetags.php
r3263 r3300 19 19 20 20 var $single_group = false; 21 22 var $sort_by; 23 var $order; 21 24 22 25 function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $include, $populate_extras ) { … … 67 70 if ( (int)$this->total_group_count && (int)$this->pag_num ) { 68 71 $this->pag_links = paginate_links( array( 69 'base' => add_query_arg( array( 'grpage' => '%#%' ) ),72 'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ), 70 73 'format' => '', 71 74 'total' => ceil( (int)$this->total_group_count / (int)$this->pag_num ), … … 197 200 global $bp, $groups_template; 198 201 199 if ( $bp->loggedin_user->is_s ite_admin )202 if ( $bp->loggedin_user->is_super_admin ) 200 203 return true; 201 204 … … 292 295 /* Fetch the avatar from the folder, if not provide backwards compat. */ 293 296 if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) ) 294 $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';297 $avatar = '<img src="' . esc_attr( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />'; 295 298 296 299 return apply_filters( 'bp_get_group_avatar', $avatar ); … … 559 562 global $bp, $groups_template; 560 563 561 $from_num = bp_core_number_format( intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1 ); 562 $to_num = bp_core_number_format( ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1 ) ); 564 $start_num = intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1; 565 $from_num = bp_core_number_format( $start_num ); 566 $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) ); 563 567 $total = bp_core_number_format( $groups_template->total_group_count ); 564 568 565 return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ) ); 566 } 569 return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ) . '<span class="ajax-loader"></span>' ); 570 } 571 572 function bp_groups_auto_join() { 573 global $bp; 574 575 return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join ); 576 } 567 577 568 578 function bp_group_total_members() { … … 875 885 } 876 886 function bp_get_group_member_unban_link( $user_id = false, $group = false ) { 877 global $members_template ;887 global $members_template, $groups_template; 878 888 879 889 if ( !$user_id ) … … 884 894 885 895 return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) ); 896 } 897 898 899 function bp_group_member_remove_link( $user_id = false ) { 900 global $members_template; 901 902 if ( !$user_id ) 903 $user_id = $members_template->member->user_id; 904 905 echo bp_get_group_member_remove_link( $user_id ); 906 } 907 function bp_get_group_member_remove_link( $user_id = false, $group = false ) { 908 global $members_template, $groups_template; 909 910 if ( !$group ) 911 $group =& $groups_template->group; 912 913 return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id, 'groups_remove_member' ) ); 886 914 } 887 915 … … 962 990 } 963 991 992 /** 993 * bp_group_is_member() 994 * 995 * Checks if current user is member of a group. 996 * 997 * @uses is_super_admin Check if current user is super admin 998 * @uses apply_filters Creates bp_group_is_member filter and passes $is_member 999 * @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility 1000 * @global array $bp BuddyPress Master global 1001 * @global object $groups_template Current Group (usually in template loop) 1002 * @param object $group Group to check is_member 1003 * @return bool If user is member of group or not 1004 */ 964 1005 function bp_group_is_member( $group = false ) { 965 1006 global $bp, $groups_template; 966 1007 967 if ( is_site_admin() ) 1008 // Site admins always have access 1009 if ( is_super_admin() ) 968 1010 return true; 969 1011 1012 // Load group if none passed 970 1013 if ( !$group ) 971 1014 $group =& $groups_template->group; 972 1015 1016 // Check membership 973 1017 if ( null == $group->is_member ) 974 return false; 975 976 return true; 1018 $is_member = false; 1019 else 1020 $is_member = true; 1021 1022 // Return 1023 return apply_filters( 'bp_group_is_member', $is_member ); 977 1024 } 978 1025 … … 1051 1098 return true; 1052 1099 } 1100 1053 1101 function bp_group_new_topic_button() { 1054 1102 if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) { … … 1190 1238 function bp_group_hidden_fields() { 1191 1239 if ( isset( $_REQUEST['s'] ) ) { 1192 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';1240 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />'; 1193 1241 } 1194 1242 1195 1243 if ( isset( $_REQUEST['letter'] ) ) { 1196 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';1244 echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 1197 1245 } 1198 1246 1199 1247 if ( isset( $_REQUEST['groups_search'] ) ) { 1200 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';1248 echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['groups_search'] ) . '" name="search_terms" />'; 1201 1249 } 1202 1250 } … … 1430 1478 } 1431 1479 1480 function bp_group_member_css_class() { 1481 global $members_template; 1482 1483 if ( $members_template->member->is_banned ) 1484 echo apply_filters( 'bp_group_member_css_class', 'banned-user' ); 1485 } 1486 1432 1487 function bp_group_member_joined_since() { 1433 1488 echo bp_get_group_member_joined_since(); … … 1481 1536 global $members_template; 1482 1537 1483 $from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 ); 1484 $to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ) ); 1538 $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 1539 $from_num = bp_core_number_format( $start_num ); 1540 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) ); 1485 1541 $total = bp_core_number_format( $members_template->total_member_count ); 1486 1542 1487 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members % s to %s (of %s members)', 'buddypress' ), $from_num, $to_num, $total ) );1543 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total ) ); 1488 1544 } 1489 1545 … … 1745 1801 } 1746 1802 1747 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';1803 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . esc_attr( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; 1748 1804 } 1749 1805 } … … 1761 1817 ?> 1762 1818 <form action="" method="get" id="search-groups-form"> 1763 <label><input type="text" name="s" id="groups_search" value="<?php echo attribute_escape($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>1819 <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr($search_value) ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 1764 1820 <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 1765 1821 </form> … … 1828 1884 1829 1885 if ( $bp->groups->current_group->avatar_full ) { ?> 1830 <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />1886 <img src="<?php echo esc_attr( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" /> 1831 1887 <?php } else { ?> 1832 1888 <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" /> -
trunk/bp-groups/bp-groups-widgets.php
r2656 r3300 51 51 </ul> 52 52 <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?> 53 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />53 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $instance['max_groups'] ); ?>" /> 54 54 55 55 <?php else: ?> … … 77 77 ?> 78 78 79 <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo attribute_escape( $max_groups ); ?>" style="width: 30%" /></label></p>79 <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p> 80 80 <?php 81 81 } … … 130 130 </ul> 131 131 <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?> 132 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" />132 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $_POST['max_groups'] ); ?>" /> 133 133 134 134 <?php else: ?> -
trunk/bp-loader.php
r3282 r3300 7 7 Version: 1.3-bleeding 8 8 Author URI: http://buddypress.org/community/members/ 9 Network: true 9 10 */ 10 11 … … 61 62 include( BP_PLUGIN_DIR . '/bp-xprofile.php' ); 62 63 63 /**64 * bp_loaded()65 *66 * Allow dependent plugins and core actions to attach themselves in a safe way.67 *68 * See bp-core.php for the following core actions:69 * - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets70 */71 function bp_loaded() {72 do_action( 'bp_loaded' );73 }74 64 add_action( 'plugins_loaded', 'bp_loaded', 20 ); 65 } 66 67 /** 68 * bp_loaded() 69 * 70 * Allow dependent plugins and core actions to attach themselves in a safe way. 71 * 72 * See bp-core.php for the following core actions: 73 * - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets 74 */ 75 function bp_loaded() { 76 do_action( 'bp_loaded' ); 75 77 } 76 78 … … 84 86 switch_theme( 'bp-default', 'bp-default' ); 85 87 88 /* Install site options on activation */ 89 //TODO: Find where to put this back. Here is no good because bp-core.php isn't loaded on new installation. 90 //bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0, 'bp-disable-forum-directory' => 0, 'bp-disable-profile-sync' => 0 ) ); 91 86 92 do_action( 'bp_loader_activate' ); 87 93 } … … 93 99 return false; 94 100 101 delete_site_option( 'bp-core-db-version' ); 102 delete_site_option( 'bp-activity-db-version' ); 103 delete_site_option( 'bp-blogs-db-version' ); 104 delete_site_option( 'bp-friends-db-version' ); 105 delete_site_option( 'bp-groups-db-version' ); 106 delete_site_option( 'bp-messages-db-version' ); 107 delete_site_option( 'bp-xprofile-db-version' ); 95 108 delete_site_option( 'bp-deactivated-components' ); 96 109 delete_site_option( 'bp-blogs-first-install' ); -
trunk/bp-messages.php
r2941 r3300 6 6 7 7 function messages_setup_globals() { 8 global $bp , $wpdb;8 global $bp; 9 9 10 10 if ( !defined( 'BP_MESSAGES_SLUG' ) ) … … 14 14 $bp->messages->id = 'messages'; 15 15 16 $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages'; 17 $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients'; 18 $bp->messages->table_name_notices = $wpdb->base_prefix . 'bp_messages_notices'; 16 $bp->messages->slug = BP_MESSAGES_SLUG; 17 $bp->messages->table_name_notices = $bp->table_prefix . 'bp_messages_notices'; 18 $bp->messages->table_name_messages = $bp->table_prefix . 'bp_messages_messages'; 19 $bp->messages->table_name_recipients = $bp->table_prefix . 'bp_messages_recipients'; 19 20 $bp->messages->format_notification_function = 'messages_format_notifications'; 20 $bp->messages->slug = BP_MESSAGES_SLUG;21 21 22 22 /* Register this in the active components array */ … … 45 45 bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); 46 46 47 if ( is_s ite_admin() )48 bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_s ite_admin() ) );47 if ( is_super_admin() ) 48 bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) ); 49 49 50 50 if ( $bp->current_component == $bp->messages->slug ) { … … 85 85 messages_remove_callback_values(); 86 86 87 / * Check if the message form has been submitted */87 // Check if the message form has been submitted 88 88 if ( isset( $_POST['send'] ) ) { 89 89 90 / * Check the nonce */90 // Check the nonce 91 91 check_admin_referer( 'messages_send_message' ); 92 92 93 / * Check we have what we need */93 // Check we have what we need 94 94 if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { 95 95 bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' ); 96 96 } else { 97 / * If this is a notice, send it */97 // If this is a notice, send it 98 98 if ( isset( $_POST['send-notice'] ) ) { 99 99 if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) { … … 104 104 } 105 105 } else { 106 / * Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) */106 // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) 107 107 $autocomplete_recipients = explode( ',', $_POST['send-to-input'] ); 108 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] ); 109 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients ); 110 111 /* Send the message */ 108 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] ); 109 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients ); 110 $recipients = apply_filters( 'bp_messages_recipients', $recipients ); 111 112 // Send the message 112 113 if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) { 113 114 bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) ); … … 118 119 } 119 120 } 120 121 121 } 122 122 … … 129 129 global $bp, $notice_id; 130 130 131 if ( !is_s ite_admin() )131 if ( !is_super_admin() ) 132 132 return false; 133 133 … … 166 166 function messages_screen_notification_settings() { 167 167 global $current_user; ?> 168 <table class="notification-settings" id="messages-notification-settings"> 169 <tr> 170 <th class="icon"></th> 171 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th> 172 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 173 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 174 </tr> 175 <tr> 176 <td></td> 177 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td> 178 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_message' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td> 179 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td> 180 </tr> 181 <tr> 182 <td></td> 183 <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td> 184 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_notice' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td> 185 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td> 186 </tr> 187 188 <?php do_action( 'messages_screen_notification_settings' ) ?> 168 <table class="notification-settings zebra" id="messages-notification-settings"> 169 <thead> 170 <tr> 171 <th class="icon"></th> 172 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th> 173 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 174 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 175 </tr> 176 </thead> 177 178 <tbody> 179 <tr> 180 <td></td> 181 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td> 182 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_message', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td> 183 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td> 184 </tr> 185 <tr> 186 <td></td> 187 <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td> 188 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td> 189 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td> 190 </tr> 191 192 <?php do_action( 'messages_screen_notification_settings' ) ?> 193 </tbody> 189 194 </table> 190 195 <?php … … 209 214 $thread_id = $bp->action_variables[0]; 210 215 211 if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_s ite_admin() ) )216 if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_super_admin() ) ) 212 217 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component ); 213 218 … … 328 333 'subject' => false, 329 334 'content' => false, 330 'date_sent' => time()335 'date_sent' => bp_core_current_time() 331 336 ); 332 337 … … 345 350 $message->date_sent = $date_sent; 346 351 347 / * If we have a thread ID, use the existing recipients, otherwise use the recipients passed */352 // If we have a thread ID, use the existing recipients, otherwise use the recipients passed 348 353 if ( $thread_id ) { 349 354 $thread = new BP_Messages_Thread( $thread_id ); 350 355 $message->recipients = $thread->get_recipients(); 351 356 357 // Strip the sender from the recipient list if they exist 358 if ( isset( $message->recipients[$sender_id] ) ) 359 unset( $message->recipients[$sender_id] ); 360 352 361 if ( empty( $message->subject ) ) 353 362 $message->subject = sprintf( __( 'Re: %s', 'buddypress' ), $thread->messages[0]->subject ); 354 363 364 // No thread ID, so make some adjustments 355 365 } else { 356 366 if ( empty( $recipients ) ) … … 406 416 407 417 function messages_send_notice( $subject, $message ) { 408 if ( !is_s ite_admin() || empty( $subject ) || empty( $message ) ) {418 if ( !is_super_admin() || empty( $subject ) || empty( $message ) ) { 409 419 return false; 410 420 } else { … … 413 423 $notice->subject = $subject; 414 424 $notice->message = $message; 415 $notice->date_sent = time();425 $notice->date_sent = bp_core_current_time(); 416 426 $notice->is_active = 1; 417 427 $notice->save(); // send it. -
trunk/bp-messages/bp-messages-classes.php
r2576 r3300 244 244 global $bp; 245 245 246 $this->date_sent = time();246 $this->date_sent = bp_core_current_time(); 247 247 $this->sender_id = $bp->loggedin_user->id; 248 248 … … 289 289 290 290 // First insert the message into the messages table 291 if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, FROM_UNIXTIME(%d))", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )291 if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, %s )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) ) 292 292 return false; 293 293 … … 388 388 389 389 if ( !$this->id ) { 390 $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );390 $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, %s, %d)", $this->subject, $this->message, $this->date_sent, $this->is_active ); 391 391 } else { 392 392 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id ); … … 402 402 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) ); 403 403 404 update_user meta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );404 update_user_meta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) ); 405 405 406 406 do_action( 'messages_notice_after_save', $this ); -
trunk/bp-messages/bp-messages-cssjs.php
r2077 r3300 15 15 16 16 } 17 add_action( ' template_redirect', 'messages_add_autocomplete_js', 1);17 add_action( 'wp', 'messages_add_autocomplete_js', 2 ); 18 18 19 19 function messages_add_autocomplete_css() { … … 28 28 29 29 function messages_autocomplete_init_jsblock() { 30 global $bp; 30 31 ?> 31 32 <script type="text/javascript"> -
trunk/bp-messages/bp-messages-filters.php
r2679 r3300 45 45 add_filter( 'bp_get_the_thread_message_content', 'make_clickable' ); 46 46 47 add_filter( 'bp_get_message_notice_subject', 'wpautop' );48 47 add_filter( 'bp_get_message_notice_text', 'wpautop' ); 49 add_filter( 'bp_get_message_thread_subject', 'wpautop' );50 48 add_filter( 'bp_get_the_thread_message_content', 'wpautop' ); 51 49 -
trunk/bp-messages/bp-messages-notifications.php
r3232 r3300 8 8 9 9 foreach( $recipients as $recipient ) { 10 if ( $sender_id == $recipient->user_id || 'no' == get_user meta( $recipient->user_id, 'notification_messages_new_message') ) continue;10 if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue; 11 11 12 12 $ud = get_userdata( $recipient->user_id ); … … 19 19 20 20 // Set up and send the message 21 $email_to = $ud->user_email; 22 $email_subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ); 21 $email_to = $ud->user_email; 22 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 23 $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ); 23 24 24 25 $email_content = sprintf( __( 25 '% 1$s sent you a new message:26 '%s sent you a new message: 26 27 27 Subject: % 2$s28 Subject: %s 28 29 29 "% 3$s"30 "%s" 30 31 31 To view and read your messages please log in and visit: % 4$s32 To view and read your messages please log in and visit: %s 32 33 33 34 --------------------- 34 35 ', 'buddypress' ), $sender_name, $subject, $content, $message_link ); 35 36 36 $ content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );37 $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 37 38 38 39 /* Send the message */ -
trunk/bp-messages/bp-messages-templatetags.php
r3263 r3300 28 28 $this->type = $type; 29 29 30 if ( 'notices' == $this->box ) 30 if ( 'notices' == $this->box ) { 31 31 $this->threads = BP_Messages_Notice::get_notices(); 32 else {32 } else { 33 33 $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page ); 34 34 … … 162 162 extract( $r, EXTR_SKIP ); 163 163 164 if ( 'notices' == $bp->current_action && !is_s ite_admin() ) {164 if ( 'notices' == $bp->current_action && !is_super_admin() ) { 165 165 wp_redirect( $bp->displayed_user->id ); 166 166 } else { … … 250 250 } 251 251 252 function bp_message_css_class() { 253 echo bp_get_message_css_class(); 254 } 255 256 function bp_get_message_css_class() { 257 global $messages_template; 258 259 $class = false; 260 261 if ( $messages_template->current_thread % 2 == 1 ) 262 $class .= 'alt'; 263 264 return apply_filters( 'bp_get_message_css_class', trim( $class ) ); 265 } 266 252 267 function bp_message_thread_has_unread() { 253 268 global $messages_template; … … 313 328 global $messages_template; 314 329 315 $from_num = bp_core_number_format( intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1 ); 316 $to_num = bp_core_number_format( ( $from_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $from_num + ( $messages_template->pag_num - 1 ) ); 330 $start_num = intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1; 331 $from_num = bp_core_number_format( $start_num ); 332 $to_num = bp_core_number_format( ( $start_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $start_num + ( $messages_template->pag_num - 1 ) ); 317 333 $total = bp_core_number_format( $messages_template->total_thread_count ); 318 334 319 echo sprintf( __( 'Viewing message % s to %s (of %s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> 335 echo sprintf( __( 'Viewing message %1$s to %2$s (of %3$s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> 320 336 <span class="ajax-loader"></span><?php 321 337 } … … 327 343 global $bp; 328 344 329 return apply_filters( 'bp_get_messages_form_action', $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $bp->action_variables[0] . '/');345 return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $bp->action_variables[0] . '/' ) ); 330 346 } 331 347 … … 460 476 return false; 461 477 462 $closed_notices = get_user meta( $userdata->ID, 'closed_notices');478 $closed_notices = get_user_meta( $userdata->ID, 'closed_notices', true ); 463 479 464 480 if ( !$closed_notices ) -
trunk/bp-messages/css/autocomplete/jquery.autocompletefb.css
r2191 r3300 36 36 37 37 .ac_loading { 38 background : url('../../ images/ajax-loader.gif') right center no-repeat;38 background : url('../../../bp-themes/bp-default/_inc/images/ajax-loader.gif') right center no-repeat; 39 39 } 40 40 -
trunk/bp-themes/bp-default/_inc/ajax.php
r2733 r3300 184 184 <li id="acomment-<?php bp_activity_id() ?>"> 185 185 <div class="acomment-avatar"> 186 <?php bp_activity_avatar( array( 'width' => 25, 'height' => 25 )) ?>186 <?php bp_activity_avatar() ?> 187 187 </div> 188 188 189 189 <div class="acomment-meta"> 190 <?php echo bp_core_get_userlink( bp_get_activity_user_id() ) ?> · <?php printf( __( '%s ago', 'buddypress' ), bp_core_time_since( gmdate( "Y-m-d H:i:s") ) ) ?> ·191 <a class="acomment-reply" href="#acomment-<?php bp_activity_id() ?>" id="acomment-reply-<?php echo attribute_escape( $_POST['form_id'] ) ?>"><?php _e( 'Reply', 'buddypress' ) ?></a>190 <?php echo bp_core_get_userlink( bp_get_activity_user_id() ) ?> · <?php printf( __( '%s ago', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?> · 191 <a class="acomment-reply" href="#acomment-<?php bp_activity_id() ?>" id="acomment-reply-<?php echo esc_attr( $_POST['form_id'] ) ?>"><?php _e( 'Reply', 'buddypress' ) ?></a> 192 192 · <a href="<?php echo wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . bp_get_activity_id() . '?cid=' . $comment_id, 'bp_activity_delete_link' ) ?>" class="delete acomment-delete confirm"><?php _e( 'Delete', 'buddypress' ) ?></a> 193 193 </div> … … 217 217 218 218 /* Check access */ 219 if ( !is_s ite_admin() && $activity->user_id != $bp->loggedin_user->id )219 if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id ) 220 220 return false; 221 221 … … 250 250 251 251 /* Check access */ 252 if ( !is_s ite_admin() && $comment->user_id != $bp->loggedin_user->id )252 if ( !is_super_admin() && $comment->user_id != $bp->loggedin_user->id ) 253 253 return false; 254 254 … … 313 313 echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>'; 314 314 echo '<div class="action"> 315 <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>315 <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a> 316 316 </div>'; 317 317 echo '</li>'; … … 405 405 _e( 'Error joining group', 'buddypress' ); 406 406 } else { 407 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';407 echo '<a id="group-' . esc_attr( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 408 408 } 409 409 … … 415 415 _e( 'Error requesting membership', 'buddypress' ); 416 416 } else { 417 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';417 echo '<a id="group-' . esc_attr( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>'; 418 418 } 419 419 } … … 427 427 } else { 428 428 if ( 'public' == $group->status ) { 429 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';429 echo '<a id="group-' . esc_attr( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 430 430 } else if ( 'private' == $group->status ) { 431 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';431 echo '<a id="group-' . esc_attr( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>'; 432 432 } 433 433 } … … 443 443 echo "-1<div id='message' class='error'><p>" . __('There was a problem closing the notice.', 'buddypress') . '</p></div>'; 444 444 } else { 445 $notice_ids = get_user meta( $userdata->ID, 'closed_notices');445 $notice_ids = get_user_meta( $userdata->ID, 'closed_notices', true ); 446 446 447 447 $notice_ids[] = (int) $_POST['notice_id']; 448 448 449 update_user meta( $userdata->ID, 'closed_notices', $notice_ids );449 update_user_meta( $userdata->ID, 'closed_notices', $notice_ids ); 450 450 } 451 451 } … … 466 466 <?php echo bp_loggedin_user_avatar( 'type=thumb&width=30&height=30' ); ?> 467 467 468 <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( time() ) ) ?></span></strong>468 <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?></span></strong> 469 469 470 470 <?php do_action( 'bp_after_message_meta' ) ?> -
trunk/bp-themes/bp-default/_inc/css/default.css
r3232 r3300 36 36 a:focus { outline: 1px dotted #ccc; } 37 37 38 .padder { padding: 20px; }38 .padder { padding: 19px; } 39 39 .clear { clear: left; } 40 40 … … 180 180 margin-left: -226px; 181 181 margin-top: 1px; 182 border-left: 1px solid # e4e4e4;182 border-left: 1px solid #ddd; 183 183 -moz-border-radius-topright: 3px; 184 184 -webkit-border-top-right-radius: 3px; … … 226 226 227 227 div#sidebar ul.item-list img.avatar { 228 width: 2 5px;229 height: 2 5px;228 width: 20px; 229 height: 20px; 230 230 margin-right: 10px; 231 231 } … … 274 274 div#content .padder { 275 275 margin-right: 225px; 276 border-right: 1px solid # e4e4e4;276 border-right: 1px solid #ddd; 277 277 -moz-border-radius-topleft: 6px; 278 278 -webkit-border-top-left-radius: 6px; … … 400 400 } 401 401 ul.single-line li { border: none; } 402 body.activity-permalink ul.item-list li { padding-top: 0; }403 402 404 403 ul.item-list li img.avatar { … … 449 448 clear: left; 450 449 overflow: hidden; 451 margin: 25px - 20px 20px -20px;450 margin: 25px -19px 20px -19px; 452 451 background: #eaeaea; 453 452 } … … 525 524 div.item-list-tabs#subnav { 526 525 background: #fff; 527 margin: -15px - 20px 15px -20px;526 margin: -15px -19px 15px -19px; 528 527 border-bottom: 1px solid #eaeaea; 529 528 min-height: 35px; … … 575 574 576 575 div.pagination { 577 margin: - 15px -20px 9px -20px;576 margin: -20px -20px 9px -20px; 578 577 border-bottom: 1px solid #eaeaea; 579 578 padding: 10px 20px 10px 20px; … … 604 603 font-weight: bold; 605 604 } 605 606 div#pag-bottom { 607 margin-top: 0; 608 } 606 609 607 610 /* > Error / Success Messages … … 645 648 -------------------------------------------------------------- */ 646 649 647 a.button, input[type=submit], input[type=button], 650 a.button, input[type=submit], input[type=button], input[type=reset], 648 651 ul.button-nav li a, div.generic-button a { 649 652 background: url( ../images/white-grad.png ) top left repeat-x; … … 660 663 cursor: pointer; 661 664 } 662 a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover, 665 a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover, 663 666 ul.button-nav li a:hover, ul.button-nav li.current a, 664 667 div.generic-button a:hover { … … 803 806 } 804 807 808 form.standard-form a.clear-value { 809 display: block; 810 margin-top: 5px; 811 outline: none; 812 } 813 805 814 form.standard-form #basic-details-section, form.standard-form #blog-details-section, 806 815 form.standard-form #profile-details-section { … … 841 850 width: 100%; 842 851 } 852 table thead tr { 853 background: #eaeaea; 854 } 855 843 856 table#message-threads { 844 857 margin: 0 -20px; … … 889 902 width: auto; 890 903 } 891 table.forum tr:first-child {892 background: #fafafa;893 }894 895 904 table.forum tr.sticky td { 896 905 background: #FFF9DB; … … 992 1001 form#whats-new-form textarea { 993 1002 width: 100%; 994 height: 60px;1003 height: 50px; 995 1004 font-size: 14px; 996 1005 font-family: inherit; … … 1107 1116 1108 1117 .activity-list .activity-avatar img { 1109 width: 60px;1110 height: 60px;1118 width: 50px; 1119 height: 50px; 1111 1120 } 1112 1121 body.activity-permalink .activity-list .activity-avatar img { … … 1146 1155 line-height: 220%; 1147 1156 } 1157 1158 .activity-list .activity-content .activity-header img.avatar { 1159 float: none !important; 1160 margin: 0 5px -8px 0 !important; 1161 } 1148 1162 1149 1163 .activity-list .activity-header a:first-child, span.highlight { … … 1276 1290 -moz-border-radius: 4px; 1277 1291 -webkit-border-radius: 4px; 1292 padding: 0 10px 0; 1278 1293 } 1279 1294 div.activity-comments ul, div.activity-comments ul li { … … 1288 1303 div.activity-comments ul li { 1289 1304 border-top: 2px solid #fff; 1290 padding: 10px 15px 10px 0; 1291 margin-left: 15px; 1305 padding: 10px 0 0; 1292 1306 } 1293 1307 body.activity-permalink div.activity-comments ul li { 1294 1308 border-width: 1px; 1295 padding: 1 5px 0 15px0;1309 padding: 10px 0 0; 1296 1310 } 1297 1311 1298 1312 div.activity-comments ul li p:last-child { 1299 margin-bottom: 0;1313 margin-bottom: 10px; 1300 1314 } 1301 1315 … … 1309 1323 1310 1324 div.activity-comments ul li > ul { 1311 margin-top: 5px;1312 margin-left: 2 5px;1325 margin-top: 0; 1326 margin-left: 20px; 1313 1327 } 1314 1328 body.activity-permalink div.activity-comments ul li > ul { … … 1343 1357 display: none; 1344 1358 margin: 10px 0 10px 33px; 1345 background: #eee; 1346 border-bottom: 1px solid #ddd; 1347 border-right: 1px solid #ddd; 1359 background: #fafafa; 1360 border: 1px solid #ddd; 1348 1361 -moz-border-radius: 4px; 1349 1362 -webkit-border-radius: 4px; … … 1400 1413 1401 1414 div.activity-comments form div.ac-reply-content { 1402 margin-left: 25px;1415 margin-left: 50px; 1403 1416 padding-left: 15px; 1404 1417 color: #888; -
trunk/bp-themes/bp-default/_inc/global.js
r3232 r3300 825 825 jq(this).removeClass('over'); 826 826 }); 827 827 828 828 jq('body#bp-default table.zebra tbody tr:odd').addClass('alt'); 829 829 -
trunk/bp-themes/bp-default/activity/entry.php
r2761 r3300 56 56 <?php if ( is_user_logged_in() ) : ?> 57 57 <form action="<?php bp_activity_comment_form_action() ?>" method="post" id="ac-form-<?php bp_activity_id() ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display() ?>> 58 <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width= 25&height=25') ?></div>58 <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ) ?></div> 59 59 <div class="ac-reply-content"> 60 60 <div class="ac-textarea"> -
trunk/bp-themes/bp-default/activity/index.php
r2908 r3300 58 58 <div class="item-list-tabs no-ajax" id="subnav"> 59 59 <ul> 60 <li class="feed"><a href="<?php bp_sitewide_activity_feed_link() ?>" title=" RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>60 <li class="feed"><a href="<?php bp_sitewide_activity_feed_link() ?>" title="<?php _e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ) ?></a></li> 61 61 62 62 <?php do_action( 'bp_activity_syndication_options' ) ?> -
trunk/bp-themes/bp-default/activity/post-form.php
r2696 r3300 11 11 <div id="whats-new-avatar"> 12 12 <a href="<?php echo bp_loggedin_user_domain() ?>"> 13 <?php bp_loggedin_user_avatar( 'width= 60&height=60') ?>13 <?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ) ?> 14 14 </a> 15 15 </div> … … 25 25 <div id="whats-new-content"> 26 26 <div id="whats-new-textarea"> 27 <textarea name="whats-new" id="whats-new" value="" /><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>27 <textarea name="whats-new" id="whats-new" cols="50" rows="10"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea> 28 28 </div> 29 29 -
trunk/bp-themes/bp-default/archive.php
r2694 r3300 33 33 <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 34 34 35 <p class="date"><?php the_time( 'F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>35 <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p> 36 36 37 37 <div class="entry"> -
trunk/bp-themes/bp-default/blogs/blogs-loop.php
r3263 r3300 5 5 <?php if ( bp_has_blogs( bp_ajax_querystring( 'blogs' ) ) ) : ?> 6 6 7 <div class="pagination">7 <div id="pag-top" class="pagination"> 8 8 9 <div class="pag-count" id="blog-dir-count ">9 <div class="pag-count" id="blog-dir-count-top"> 10 10 <?php bp_blogs_pagination_count() ?> 11 11 </div> 12 12 13 <div class="pagination-links" id="blog-dir-pag ">13 <div class="pagination-links" id="blog-dir-pag-top"> 14 14 <?php bp_blogs_pagination_links() ?> 15 15 </div> 16 16 17 17 </div> 18 19 <?php do_action( 'bp_before_directory_blogs_list' ) ?> 18 20 19 21 <ul id="blogs-list" class="item-list"> … … 52 54 <?php bp_blog_hidden_fields() ?> 53 55 56 <div id="pag-bottom" class="pagination"> 57 58 <div class="pag-count" id="blog-dir-count-bottom"> 59 <?php bp_blogs_pagination_count() ?> 60 </div> 61 62 <div class="pagination-links" id="blog-dir-pag-bottom"> 63 <?php bp_blogs_pagination_links() ?> 64 </div> 65 66 </div> 67 54 68 <?php else: ?> 55 69 -
trunk/bp-themes/bp-default/comments.php
r3232 r3300 15 15 16 16 <?php 17 $numTrackBacks = 0; $numComments = 0; 18 foreach ( (array)$comments as $comment ) if ( get_comment_type() != "comment") $numTrackBacks++; else $numComments++; 17 // Only include comments 18 $numTrackBacks = 0; $numComments = 0; 19 foreach ( (array)$comments as $comment ) 20 if ( 'comment' != get_comment_type() ) 21 $numTrackBacks++; 22 else 23 $numComments++; 19 24 ?> 20 25 21 <span class="title"><?php the_title() ?></span> 22 <h3 id="comments"><?php comments_number( 'No Comments', 'One Comment', $numComments . ' Comments' );?></h3> 26 <h3 id="comments"> 27 <?php 28 printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', $numComments, 'buddypress' ), 29 number_format_i18n( $numComments ), '<em>' . get_the_title() . '</em>' ); 30 ?> 31 </h3> 23 32 24 33 <?php do_action( 'bp_before_blog_comment_list' ) ?> … … 96 105 <?php do_action( 'bp_before_blog_comment_form' ) ?> 97 106 98 <form action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php" method="post" id="commentform" class="standard-form">107 <form action="<?php echo site_url( 'wp-comments-post.php' ) ?>" method="post" id="commentform" class="standard-form"> 99 108 100 109 <?php if ( $user_ID ) : ?> -
trunk/bp-themes/bp-default/footer.php
r2284 r3300 5 5 6 6 <div id="footer"> 7 <p><?php printf( __( '%s is proudly powered by <a href="http://wordpress.org">WordPress</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), bloginfo('name') ); ?></p>7 <p><?php printf( __( '%s is proudly powered by <a href="http://wordpress.org">WordPress</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), get_bloginfo( 'name' ) ); ?></p> 8 8 9 9 <?php do_action( 'bp_footer' ) ?> -
trunk/bp-themes/bp-default/forums/index.php
r3232 r3300 1 1 <?php get_header() ?> 2 3 <?php do_action( 'bp_before_directory_forums_content' ) ?>4 2 5 3 <div id="content"> … … 7 5 8 6 <form action="" method="post" id="forums-search-form" class="dir-form"> 7 9 8 <h3><?php _e( 'Group Forums Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> <a class="button" href="#new-topic" id="new-topic-button"><?php _e( 'New Topic', 'buddypress' ) ?></a><?php endif; ?></h3> 9 10 <?php do_action( 'bp_before_directory_forums_content' ) ?> 10 11 11 12 <div id="forums-dir-search" class="dir-search"> … … 14 15 </form> 15 16 16 17 17 <div id="new-topic-post"> 18 <?php if ( is_user_logged_in() ) : ?> 18 19 19 20 <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?> 20 21 21 22 <form action="" method="post" id="forum-topic-form" class="standard-form"> 22 23 23 24 <?php do_action( 'groups_forum_new_topic_before' ) ?> 24 25 25 26 26 <a name="post-new"></a> 27 <h5><?php _e( 'Post a New Topic:', 'buddypress' ) ?></h5> 27 28 28 29 29 <label><?php _e( 'Title:', 'buddypress' ) ?></label> 30 <input type="text" name="topic_title" id="topic_title" value="" /> 30 31 31 32 32 <label><?php _e( 'Content:', 'buddypress' ) ?></label> 33 <textarea name="topic_text" id="topic_text"></textarea> 33 34 34 35 35 <label><?php _e( 'Tags (comma separated):', 'buddypress' ) ?></label> 36 <input type="text" name="topic_tags" id="topic_tags" value="" /> 36 37 37 <label><?php _e( 'Post In Group Forum:', 'buddypress' ) ?></label> 38 <select id="topic_group_id" name="topic_group_id"> 39 <?php while ( bp_groups() ) : bp_the_group(); ?> 40 <?php if ( 'public' == bp_get_group_status() ) : ?> 41 <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option> 42 <?php endif; ?> 43 <?php endwhile; ?> 44 </select> 38 <label><?php _e( 'Post In Group Forum:', 'buddypress' ) ?></label> 39 <select id="topic_group_id" name="topic_group_id"> 45 40 46 < ?php do_action( 'groups_forum_new_topic_after' ) ?>41 <option value="">----</option> 47 42 48 <div class="submit"> 49 <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ) ?>" /> 50 <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ) ?>" /> 51 </div> 43 <?php while ( bp_groups() ) : bp_the_group(); ?> 52 44 53 <?php wp_nonce_field( 'bp_forums_new_topic' )?>45 <?php if ( bp_group_is_forum_enabled() && 'public' == bp_get_group_status() ) : ?> 54 46 55 </form>47 <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option> 56 48 57 <?php else :?>49 <?php endif; ?> 58 50 59 <div id="message" class="info"> 60 <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( BP_GROUPS_SLUG . '/create/' ) ) ?></p> 51 <?php endwhile; ?> 52 53 </select><!-- #topic_group_id --> 54 55 <?php do_action( 'groups_forum_new_topic_after' ) ?> 56 57 <div class="submit"> 58 <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ) ?>" /> 59 <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ) ?>" /> 61 60 </div> 62 61 63 <?php endif; ?> 62 <?php wp_nonce_field( 'bp_forums_new_topic' ) ?> 63 64 </form><!-- #forum-topic-form --> 65 66 <?php else : ?> 67 68 <div id="message" class="info"> 69 <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( BP_GROUPS_SLUG . '/create/' ) ) ?></p> 70 </div> 64 71 65 72 <?php endif; ?> 66 </div> 73 74 <?php endif; ?> 75 </div><!-- #new-topic-post --> 67 76 68 77 <form action="" method="post" id="forums-directory-form" class="dir-form"> -
trunk/bp-themes/bp-default/functions.php
r3263 r3300 1 1 <?php 2 2 3 / * Stop the theme from killing WordPress if BuddyPress is not enabled. */3 // Stop the theme from killing WordPress if BuddyPress is not enabled. 4 4 if ( !class_exists( 'BP_Core_User' ) ) 5 5 return false; 6 6 7 / * Register the widget columns */7 // Register the widget columns 8 8 register_sidebars( 1, 9 9 array( 10 'name' => 'Sidebar',10 'name' => 'Sidebar', 11 11 'before_widget' => '<div id="%1$s" class="widget %2$s">', 12 'after_widget' => '</div>',13 'before_title' => '<h3 class="widgettitle">',14 'after_title' => '</h3>'12 'after_widget' => '</div>', 13 'before_title' => '<h3 class="widgettitle">', 14 'after_title' => '</h3>' 15 15 ) 16 16 ); 17 17 18 / * Load the AJAX functions for the theme */18 // Load the AJAX functions for the theme 19 19 require_once( TEMPLATEPATH . '/_inc/ajax.php' ); 20 20 21 / * Load the javascript for the theme */21 // Load the javascript for the theme 22 22 wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) ); 23 23 24 /* Add the JS needed for blog comment replies */ 24 // Add words that we need to use in JS to the end of the page so they can be translated and still used. 25 $params = array( 26 'my_favs' => __( 'My Favorites', 'buddypress' ), 27 'accepted' => __( 'Accepted', 'buddypress' ), 28 'rejected' => __( 'Rejected', 'buddypress' ), 29 'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ), 30 'show_all' => __( 'Show all', 'buddypress' ), 31 'comments' => __( 'comments', 'buddypress' ), 32 'close' => __( 'Close', 'buddypress' ), 33 'mention_explain' => sprintf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", 'buddypress' ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname( bp_get_displayed_user_fullname() ), bp_get_user_firstname( bp_get_displayed_user_fullname() ) ) 34 ); 35 wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params ); 36 37 /** 38 * Add the JS needed for blog comment replies 39 * 40 * @package BuddyPress Theme 41 * @since 1.2 42 */ 25 43 function bp_dtheme_add_blog_comments_js() { 26 44 if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); … … 28 46 add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' ); 29 47 30 /* HTML for outputting blog comments as defined by the WP comment API */ 48 /** 49 * HTML for outputting blog comments as defined by the WP comment API 50 * 51 * @param mixed $comment Comment record from database 52 * @param array $args Arguments from wp_list_comments() call 53 * @param int $depth Comment nesting level 54 * @see wp_list_comments() 55 * @package BuddyPress Theme 56 * @since 1.2 57 */ 31 58 function bp_dtheme_blog_comments( $comment, $args, $depth ) { 32 59 $GLOBALS['comment'] = $comment; ?> … … 66 93 67 94 </div> 68 </li>69 95 <?php 70 96 } 71 97 72 /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */ 98 /** 99 * Filter the dropdown for selecting the page to show on front to include "Activity Stream" 100 * 101 * @param string $page_html A list of pages as a dropdown (select list) 102 * @see wp_dropdown_pages() 103 * @return string 104 * @package BuddyPress Theme 105 * @since 1.2 106 */ 73 107 function bp_dtheme_wp_pages_filter( $page_html ) { 108 if ( !bp_is_active( 'activity' ) ) 109 return $page_html; 110 74 111 if ( 'page_on_front' != substr( $page_html, 14, 13 ) ) 75 112 return $page_html; … … 86 123 add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' ); 87 124 88 /* Hijack the saving of page on front setting to save the activity stream setting */ 125 /** 126 * Hijack the saving of page on front setting to save the activity stream setting 127 * 128 * @param $string $oldvalue Previous value of get_option( 'page_on_front' ) 129 * @param $string $oldvalue New value of get_option( 'page_on_front' ) 130 * @return string 131 * @package BuddyPress Theme 132 * @since 1.2 133 */ 89 134 function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) { 90 if ( !is_admin() || !is_s ite_admin() )135 if ( !is_admin() || !is_super_admin() ) 91 136 return false; 92 137 … … 98 143 add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 ); 99 144 100 /* Load the activity stream template if settings allow */ 145 /** 146 * Load the activity stream template if settings allow 147 * 148 * @param string $template Absolute path to the page template 149 * @return string 150 * @global WP_Query $wp_query WordPress query object 151 * @package BuddyPress Theme 152 * @since 1.2 153 */ 101 154 function bp_dtheme_page_on_front_template( $template ) { 102 155 global $wp_query; … … 109 162 add_filter( 'page_template', 'bp_dtheme_page_on_front_template' ); 110 163 111 /* Return the ID of a page set as the home page. */ 164 /** 165 * Return the ID of a page set as the home page. 166 * 167 * @return false|int ID of page set as the home page 168 * @package BuddyPress Theme 169 * @since 1.2 170 */ 112 171 function bp_dtheme_page_on_front() { 113 172 if ( 'page' != get_option( 'show_on_front' ) ) … … 117 176 } 118 177 119 /* Force the page ID as a string to stop the get_posts query from kicking up a fuss. */ 178 /** 179 * Force the page ID as a string to stop the get_posts query from kicking up a fuss. 180 * 181 * @global WP_Query $wp_query WordPress query object 182 * @package BuddyPress Theme 183 * @since 1.2 184 */ 120 185 function bp_dtheme_fix_get_posts_on_activity_front() { 121 186 global $wp_query; … … 126 191 add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' ); 127 192 128 /**** 193 /** 194 * WP 3.0 requires there to be a non-null post in the posts array 195 * 196 * @param array $posts Posts as retrieved by WP_Query 197 * @global WP_Query $wp_query WordPress query object 198 * @return array 199 * @package BuddyPress Theme 200 * @since 1.2.5 201 */ 202 function bp_dtheme_fix_the_posts_on_activity_front( $posts ) { 203 global $wp_query; 204 205 // NOTE: the double quotes around '"activity"' are thanks to our previous function bp_dtheme_fix_get_posts_on_activity_front() 206 if ( empty( $posts ) && !empty( $wp_query->query_vars['page_id'] ) && '"activity"' == $wp_query->query_vars['page_id'] ) 207 $posts = array( (object) array( 'ID' => 'activity' ) ); 208 209 return $posts; 210 } 211 add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' ); 212 213 /** 214 * Add secondary avatar image to this activity stream's record, if supported 215 * 216 * @param string $action The text of this activity 217 * @param BP_Activity_Activity $activity Activity object 218 * @return string 219 * @package BuddyPress Theme 220 * @since 1.2.6 221 */ 222 function bp_dtheme_activity_secondary_avatars( $action, $activity ) { 223 switch ( $activity->component ) { 224 case 'groups' : 225 case 'blogs' : 226 case 'friends' : 227 // Only insert avatar if one exists 228 if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) { 229 $reverse_content = strrev( $action ); 230 $position = strpos( $reverse_content, 'a<' ); 231 $action = substr_replace( $action, $secondary_avatar, -$position - 2, 0 ); 232 } 233 break; 234 } 235 236 return $action; 237 } 238 add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 ); 239 240 /** 129 241 * Custom header image support. You can remove this entirely in a child theme by adding this line 130 242 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true ); 243 * 244 * @package BuddyPress Theme 245 * @since 1.2 131 246 */ 132 247 function bp_dtheme_add_custom_header_support() { 133 / * Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */248 // Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) 134 249 define( 'HEADER_TEXTCOLOR', 'FFFFFF' ); 135 250 define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri … … 203 318 add_action( 'init', 'bp_dtheme_add_custom_header_support' ); 204 319 205 /* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */ 320 /** 321 * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) 322 * 323 * @package BuddyPress Theme 324 * @since 1.2 325 */ 206 326 function bp_dtheme_show_notice() { ?> 207 327 <div id="message" class="updated fade"> … … 215 335 add_action( 'admin_notices', 'bp_dtheme_show_notice' ); 216 336 217 /* Add words that we need to use in JS to the end of the page so they can be translated and still used. */218 function bp_dtheme_js_terms() { ?>219 <script type="text/javascript">220 var bp_terms_my_favs = '<?php _e( "My Favorites", "buddypress" ) ?>';221 var bp_terms_accepted = '<?php _e( "Accepted", "buddypress" ) ?>';222 var bp_terms_rejected = '<?php _e( "Rejected", "buddypress" ) ?>';223 var bp_terms_show_all_comments = '<?php _e( "Show all comments for this thread", "buddypress" ) ?>';224 var bp_terms_show_all = '<?php _e( "Show all", "buddypress" ) ?>';225 var bp_terms_comments = '<?php _e( "comments", "buddypress" ) ?>';226 var bp_terms_close = '<?php _e( "Close", "buddypress" ) ?>';227 var bp_terms_mention_explain = '<?php printf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", "buddypress" ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname(bp_get_displayed_user_fullname()), bp_get_user_firstname(bp_get_displayed_user_fullname()) ); ?>';228 </script>229 <?php230 }231 add_action( 'wp_footer', 'bp_dtheme_js_terms' );232 337 233 338 // Member Buttons 234 add_action( 'bp_member_header_actions', 'bp_add_friend_button' ); 235 add_action( 'bp_member_header_actions', 'bp_send_public_message_button' ); 236 add_action( 'bp_member_header_actions', 'bp_send_private_message_button' ); 339 if ( bp_is_active( 'friends' ) ) 340 add_action( 'bp_member_header_actions', 'bp_add_friend_button' ); 341 342 if ( bp_is_active( 'activity' ) ) 343 add_action( 'bp_member_header_actions', 'bp_send_public_message_button' ); 344 345 if ( bp_is_active( 'messages' ) ) 346 add_action( 'bp_member_header_actions', 'bp_send_private_message_button' ); 237 347 238 348 // Group Buttons 239 add_action( 'bp_group_header_actions', 'bp_group_join_button' ); 240 add_action( 'bp_group_header_actions', 'bp_group_new_topic_button' ); 241 add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); 349 if ( bp_is_active( 'groups' ) ) { 350 add_action( 'bp_group_header_actions', 'bp_group_join_button' ); 351 add_action( 'bp_group_header_actions', 'bp_group_new_topic_button' ); 352 add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); 353 } 242 354 243 355 // Blog Buttons 244 add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' ); 356 if ( bp_is_active( 'blogs' ) ) 357 add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' ); 245 358 246 359 ?> -
trunk/bp-themes/bp-default/groups/create.php
r2770 r3300 53 53 </div> 54 54 <?php else : ?> 55 <?php if ( is_s ite_admin() ) : ?>55 <?php if ( is_super_admin() ) : ?> 56 56 <div class="checkbox"> 57 57 <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), bp_get_root_domain() . '/wp-admin/admin.php?page=bb-forums-setup' ) ?></label> -
trunk/bp-themes/bp-default/groups/groups-loop.php
r3263 r3300 5 5 <?php if ( bp_has_groups( bp_ajax_querystring( 'groups' ) ) ) : ?> 6 6 7 <div class="pagination">7 <div id="pag-top" class="pagination"> 8 8 9 <div class="pag-count" id="group-dir-count ">9 <div class="pag-count" id="group-dir-count-top"> 10 10 <?php bp_groups_pagination_count() ?> 11 11 </div> 12 12 13 <div class="pagination-links" id="group-dir-pag ">13 <div class="pagination-links" id="group-dir-pag-top"> 14 14 <?php bp_groups_pagination_links() ?> 15 15 </div> 16 16 17 17 </div> 18 19 <?php do_action( 'bp_before_directory_groups_list' ) ?> 18 20 19 21 <ul id="groups-list" class="item-list"> … … 53 55 </ul> 54 56 55 <?php do_action( 'bp_after_groups_loop' ) ?> 57 <?php do_action( 'bp_after_directory_groups_list' ) ?> 58 59 <div id="pag-bottom" class="pagination"> 60 61 <div class="pag-count" id="group-dir-count-bottom"> 62 <?php bp_groups_pagination_count() ?> 63 </div> 64 65 <div class="pagination-links" id="group-dir-pag-bottom"> 66 <?php bp_groups_pagination_links() ?> 67 </div> 68 69 </div> 56 70 57 71 <?php else: ?> … … 62 76 63 77 <?php endif; ?> 78 79 <?php do_action( 'bp_after_groups_loop' ) ?> -
trunk/bp-themes/bp-default/groups/index.php
r3232 r3300 15 15 <div class="item-list-tabs"> 16 16 <ul> 17 <li class="selected" id="groups-all"><a href="<?php bp_root_domain()?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li>17 <li class="selected" id="groups-all"><a href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG ?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li> 18 18 19 19 <?php if ( is_user_logged_in() && bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?> … … 38 38 </div><!-- .item-list-tabs --> 39 39 40 <?php do_action( 'bp_before_directory_groups_list' ) ?>41 42 40 <div id="groups-dir-list" class="groups dir-list"> 43 41 <?php locate_template( array( 'groups/groups-loop.php' ), true ) ?> -
trunk/bp-themes/bp-default/groups/single/activity.php
r2539 r3300 1 1 <div class="item-list-tabs no-ajax" id="subnav"> 2 2 <ul> 3 <li class="feed"><a href="<?php bp_group_activity_feed_link() ?>" title=" RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>3 <li class="feed"><a href="<?php bp_group_activity_feed_link() ?>" title="<?php _e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ) ?></a></li> 4 4 5 5 <?php do_action( 'bp_group_activity_syndication_options' ) ?> … … 34 34 <div class="activity single-group"> 35 35 <?php locate_template( array( 'activity/activity-loop.php' ), true ) ?> 36 </div><!-- .activity -->36 </div><!-- .activity.single-group --> 37 37 38 38 <?php do_action( 'bp_after_group_activity_content' ) ?> -
trunk/bp-themes/bp-default/groups/single/admin.php
r3263 r3300 195 195 <?php while ( bp_group_members() ) : bp_group_the_member(); ?> 196 196 197 <?php if ( bp_get_group_member_is_banned() ) : ?> 198 199 <li class="banned-user"> 200 <?php bp_group_member_avatar_mini() ?> 201 202 <h5><?php bp_group_member_link() ?> <?php _e( '(banned)', 'buddypress') ?> <span class="small"> - <a href="<?php bp_group_member_unban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a> </h5> 203 204 <?php else : ?> 205 206 <li> 207 <?php bp_group_member_avatar_mini() ?> 208 <h5><?php bp_group_member_link() ?> <span class="small"> - <a href="<?php bp_group_member_ban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick & Ban', 'buddypress' ); ?></a> | <a href="<?php bp_group_member_promote_mod_link() ?>" class="confirm" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a> | <a href="<?php bp_group_member_promote_admin_link() ?>" class="confirm" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a></span></h5> 209 210 <?php endif; ?> 211 212 <?php do_action( 'bp_group_manage_members_admin_item' ); ?> 213 </li> 197 <li class="<?php bp_group_member_css_class(); ?>"> 198 <?php bp_group_member_avatar_mini() ?> 199 200 <h5> 201 <?php bp_group_member_link() ?> 202 203 <?php if ( bp_get_group_member_is_banned() ) _e( '(banned)', 'buddypress'); ?> 204 205 <span class="small"> - 206 207 <?php if ( bp_get_group_member_is_banned() ) : ?> 208 209 <a href="<?php bp_group_member_unban_link() ?>" class="confirm" title="<?php _e( 'Unban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a> 210 211 <?php else : ?> 212 213 <a href="<?php bp_group_member_ban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick & Ban', 'buddypress' ); ?></a> 214 | <a href="<?php bp_group_member_promote_mod_link() ?>" class="confirm" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a> 215 | <a href="<?php bp_group_member_promote_admin_link() ?>" class="confirm" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a> 216 217 <?php endif; ?> 218 219 | <a href="<?php bp_group_member_remove_link() ?>" class="confirm" title="<?php _e( 'Remove this member', 'buddypress' ); ?>"><?php _e( 'Remove from group', 'buddypress' ); ?></a> 220 221 <?php do_action( 'bp_group_manage_members_admin_item' ); ?> 222 223 </span> 224 </h5> 225 </li> 214 226 215 227 <?php endwhile; ?> … … 299 311 300 312 <?php /* This is important, don't forget it */ ?> 301 <input type="hidden" name="group-id" id="group-id" value="<?php bp_group_id() ?>" />313 <input type="hidden" name="group-id" id="group-id" value="<?php bp_group_id() ?>" /> 302 314 303 315 <?php do_action( 'bp_after_group_admin_content' ) ?> 304 316 305 </form> 306 317 </form><!-- #group-settings-form --> 318 -
trunk/bp-themes/bp-default/groups/single/forum.php
r2488 r3300 11 11 <div class="forums single-forum"> 12 12 <?php locate_template( array( 'forums/forums-loop.php' ), true ) ?> 13 </div><!-- .forums -->13 </div><!-- .forums.single-forum --> 14 14 15 <?php do_action( 'bp_after_group_forum_content' ) ?> 15 <?php endif; ?> 16 17 <?php do_action( 'bp_after_group_forum_content' ) ?> 18 19 <?php if ( !bp_is_group_forum_topic_edit() && !bp_is_group_forum_topic() ) : ?> 16 20 17 21 <?php if ( ( is_user_logged_in() && 'public' == bp_get_group_status() ) || bp_group_is_member() ) : ?> … … 22 26 <?php do_action( 'bp_before_group_forum_post_new' ) ?> 23 27 24 <?php if ( !bp_group_is_member() ) : ?>28 <?php if ( bp_groups_auto_join() && !bp_group_is_member() ) : ?> 25 29 <p><?php _e( 'You will auto join this group when you start a new topic.', 'buddypress' ) ?></p> 26 30 <?php endif; ?> … … 46 50 <?php wp_nonce_field( 'bp_forums_new_topic' ) ?> 47 51 </div><!-- #post-new-topic --> 48 </form> 52 </form><!-- #forum-topic-form --> 49 53 50 54 <?php endif; ?> -
trunk/bp-themes/bp-default/groups/single/forum/edit.php
r2714 r3300 1 <?php do_action( 'bp_before_group_forum_edit_form' ) ?> 2 1 3 <?php if ( bp_has_forum_topic_posts() ) : ?> 2 4 … … 5 7 <div id="topic-meta"> 6 8 <h3><?php bp_the_topic_title() ?> (<?php bp_the_topic_total_post_count() ?>)</h3> 7 <a class="button" href="<?php bp_forum_permalink() ?>/">← <?php _e( 'Group Forum', 'buddypress' ) ?></a> <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a> </span>9 <a class="button" href="<?php bp_forum_permalink() ?>/">← <?php _e( 'Group Forum', 'buddypress' ) ?></a> <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a> 8 10 9 11 <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?> … … 58 60 <?php endif; ?> 59 61 60 </form> 62 </form><!-- #forum-topic-form --> 61 63 62 64 <?php else: ?> … … 67 69 68 70 <?php endif;?> 71 72 <?php do_action( 'bp_after_group_forum_edit_form' ) ?> -
trunk/bp-themes/bp-default/groups/single/forum/topic.php
r2695 r3300 1 <?php do_action( 'bp_before_group_forum_topic' ) ?> 2 1 3 <?php if ( bp_has_forum_topic_posts() ) : ?> 2 4 … … 17 19 <div id="topic-meta"> 18 20 <h3><?php bp_the_topic_title() ?> (<?php bp_the_topic_total_post_count() ?>)</h3> 19 <a class="button" href="<?php bp_forum_permalink() ?>/">← <?php _e( 'Group Forum', 'buddypress' ) ?></a> <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a> </span>21 <a class="button" href="<?php bp_forum_permalink() ?>/">← <?php _e( 'Group Forum', 'buddypress' ) ?></a> <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a> 20 22 21 <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?> 22 <div class="admin-links"><?php bp_the_topic_admin_links() ?></div> 23 <?php endif; ?> 23 <div class="admin-links"> 24 <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?> 25 <?php bp_the_topic_admin_links() ?> 26 <?php endif; ?> 27 28 <?php do_action( 'bp_group_forum_topic_meta' ); ?> 29 </div> 24 30 </div> 31 32 <?php do_action( 'bp_before_group_forum_topic_posts' ) ?> 25 33 26 34 <ul id="topic-post-list" class="item-list"> 27 35 <?php while ( bp_forum_topic_posts() ) : bp_the_forum_topic_post(); ?> 28 36 29 <li id="post-<?php bp_the_topic_post_id() ?>" >37 <li id="post-<?php bp_the_topic_post_id() ?>" class="<?php bp_the_topic_post_css_class() ?>"> 30 38 <div class="poster-meta"> 31 39 <a href="<?php bp_the_topic_post_poster_link() ?>"> … … 43 51 <?php bp_the_topic_post_admin_links() ?> 44 52 <?php endif; ?> 53 54 <?php do_action( 'bp_group_forum_post_meta' ); ?> 55 45 56 <a href="#post-<?php bp_the_topic_post_id() ?>" title="<?php _e( 'Permanent link to this post', 'buddypress' ) ?>">#</a> 46 57 </div> … … 48 59 49 60 <?php endwhile; ?> 50 </ul> 61 </ul><!-- #topic-post-list --> 62 63 <?php do_action( 'bp_after_group_forum_topic_posts' ) ?> 51 64 52 65 <div class="pagination no-ajax"> … … 71 84 <p id="post-reply"></p> 72 85 73 <?php if ( !bp_group_is_member() ) : ?>86 <?php if ( bp_groups_auto_join() && !bp_group_is_member() ) : ?> 74 87 <p><?php _e( 'You will auto join this group when you reply to this topic.', 'buddypress' ) ?></p> 75 88 <?php endif; ?> … … 102 115 <?php endif; ?> 103 116 104 </form> 117 </form><!-- #forum-topic-form --> 105 118 <?php else: ?> 106 119 … … 110 123 111 124 <?php endif;?> 125 126 <?php do_action( 'bp_after_group_forum_topic' ) ?> -
trunk/bp-themes/bp-default/groups/single/group-header.php
r2626 r3300 36 36 <?php bp_group_description() ?> 37 37 38 <?php bp_group_join_button() ?> 38 <div id="item-buttons"> 39 40 <?php do_action( 'bp_group_header_actions' ); ?> 41 42 </div><!-- #item-buttons --> 39 43 40 44 <?php do_action( 'bp_group_header_meta' ) ?> -
trunk/bp-themes/bp-default/groups/single/home.php
r2740 r3300 9 9 <div id="item-header"> 10 10 <?php locate_template( array( 'groups/single/group-header.php' ), true ) ?> 11 </div> 11 </div><!-- #item-header --> 12 12 13 13 <div id="item-nav"> … … 19 19 </ul> 20 20 </div> 21 </div> 21 </div><!-- #item-nav --> 22 22 23 23 <div id="item-body"> … … 61 61 62 62 <?php do_action( 'bp_after_group_body' ) ?> 63 </div> 63 </div><!-- #item-body --> 64 64 65 65 <?php do_action( 'bp_after_group_home_content' ) ?> -
trunk/bp-themes/bp-default/groups/single/plugins.php
r2822 r3300 9 9 <div id="item-header"> 10 10 <?php locate_template( array( 'groups/single/group-header.php' ), true ) ?> 11 </div> 11 </div><!-- #item-header --> 12 12 13 13 <div id="item-nav"> … … 19 19 </ul> 20 20 </div> 21 </div> 21 </div><!-- #item-nav --> 22 22 23 23 <div id="item-body"> 24 24 25 <?php do_action( 'bp_before_group_body' ) ?> 26 25 27 <?php do_action( 'bp_template_content' ) ?> 26 28 29 <?php do_action( 'bp_after_group_body' ) ?> 27 30 </div><!-- #item-body --> 28 31 -
trunk/bp-themes/bp-default/groups/single/request-membership.php
r2278 r3300 2 2 3 3 <?php if ( !bp_group_has_requested_membership() ) : ?> 4 <p><?php printf( __( "You are requesting to become a member of the group '%s'.", "buddypress" ), bp_g roup_name( false,false ) ); ?></p>4 <p><?php printf( __( "You are requesting to become a member of the group '%s'.", "buddypress" ), bp_get_group_name( false ) ); ?></p> 5 5 6 6 <form action="<?php bp_group_form_action('request-membership') ?>" method="post" name="request-membership-form" id="request-membership-form" class="standard-form"> … … 13 13 14 14 <?php wp_nonce_field( 'groups_request_membership' ) ?> 15 </form> 15 </form><!-- #request-membership-form --> 16 16 <?php endif; ?> 17 17 -
trunk/bp-themes/bp-default/groups/single/send-invites.php
r2339 r3300 15 15 </div> 16 16 17 </div> 17 </div><!-- .left-menu --> 18 18 19 19 <div class="main-column"> … … 49 49 50 50 <?php endif; ?> 51 </ul> 51 </ul><!-- #friend-list --> 52 52 53 53 <?php do_action( 'bp_after_group_send_invites_list' ) ?> 54 54 55 </div> 55 </div><!-- .main-column --> 56 56 57 57 <div class="clear"></div> … … 63 63 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites') ?> 64 64 65 < !-- Don't leave out this hidden field -->65 <?php /* This is important, don't forget it */ ?> 66 66 <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" /> 67 </form> 67 68 </form><!-- #send-invite-form --> 68 69 69 70 <?php else : ?> -
trunk/bp-themes/bp-default/header.php
r2863 r3300 57 57 <div class="padder"> 58 58 59 <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form"> 60 <input type="text" id="search-terms" name="search-terms" value="" /> 61 <?php echo bp_search_form_type_select() ?> 59 <?php if ( bp_search_form_enabled() ) : ?> 62 60 63 <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 64 <?php wp_nonce_field( 'bp_search_form' ) ?> 65 </form><!-- #search-form --> 61 <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form"> 62 <input type="text" id="search-terms" name="search-terms" value="" /> 63 <?php echo bp_search_form_type_select() ?> 64 65 <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 66 <?php wp_nonce_field( 'bp_search_form' ) ?> 67 </form><!-- #search-form --> 68 69 <?php endif; ?> 66 70 67 71 <?php do_action( 'bp_search_login_bar' ) ?> -
trunk/bp-themes/bp-default/index.php
r2694 r3300 24 24 <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 25 25 26 <p class="date"><?php the_time( 'F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>26 <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p> 27 27 28 28 <div class="entry"> -
trunk/bp-themes/bp-default/members/index.php
r2908 r3300 41 41 </div><!-- .item-list-tabs --> 42 42 43 <?php do_action( 'bp_before_directory_members_list' ) ?>44 45 43 <div id="members-dir-list" class="members dir-list"> 46 44 <?php locate_template( array( 'members/members-loop.php' ), true ) ?> -
trunk/bp-themes/bp-default/members/members-loop.php
r3263 r3300 5 5 <?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?> 6 6 7 <div class="pagination">7 <div id="pag-top" class="pagination"> 8 8 9 <div class="pag-count" id="member-dir-count ">9 <div class="pag-count" id="member-dir-count-top"> 10 10 <?php bp_members_pagination_count() ?> 11 11 </div> 12 12 13 <div class="pagination-links" id="member-dir-pag ">13 <div class="pagination-links" id="member-dir-pag-top"> 14 14 <?php bp_members_pagination_links() ?> 15 15 </div> … … 70 70 <?php bp_member_hidden_fields() ?> 71 71 72 <div id="pag-bottom" class="pagination"> 73 74 <div class="pag-count" id="member-dir-count-bottom"> 75 <?php bp_members_pagination_count() ?> 76 </div> 77 78 <div class="pagination-links" id="member-dir-pag-bottom"> 79 <?php bp_members_pagination_links() ?> 80 </div> 81 82 </div> 83 72 84 <?php else: ?> 73 85 -
trunk/bp-themes/bp-default/members/single/blogs.php
r2586 r3300 20 20 <div class="blogs myblogs"> 21 21 <?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ?> 22 </div><!-- .blogs -->22 </div><!-- .blogs.myblogs --> 23 23 24 24 <?php do_action( 'bp_after_member_blogs_content' ) ?> -
trunk/bp-themes/bp-default/members/single/friends.php
r2488 r3300 28 28 <div class="members friends"> 29 29 <?php locate_template( array( 'members/members-loop.php' ), true ) ?> 30 </div> 30 </div><!-- .members.friends --> 31 31 32 32 <?php do_action( 'bp_after_member_friends_content' ) ?> -
trunk/bp-themes/bp-default/members/single/groups.php
r2586 r3300 9 9 10 10 <?php _e( 'Order By:', 'buddypress' ) ?> 11 <select id="groups- all">11 <select id="groups-sort-by"> 12 12 <option value="active"><?php _e( 'Last Active', 'buddypress' ) ?></option> 13 13 <option value="popular"><?php _e( 'Most Members', 'buddypress' ) ?></option> … … 20 20 <?php endif; ?> 21 21 </ul> 22 </div> 22 </div><!-- .item-list-tabs --> 23 23 24 24 <?php if ( 'invites' == bp_current_action() ) : ?> -
trunk/bp-themes/bp-default/members/single/home.php
r3232 r3300 15 15 <?php bp_get_displayed_user_nav() ?> 16 16 17 <?php do_action( 'bp_member s_directory_member_types' ) ?>17 <?php do_action( 'bp_member_options_nav' ) ?> 18 18 </ul> 19 19 </div> … … 41 41 <?php locate_template( array( 'members/single/profile.php' ), true ) ?> 42 42 43 <?php else : ?> 44 <?php 45 /* If nothing sticks, just load a member front template if one exists. */ 46 locate_template( array( 'members/single/front.php' ), true ); 47 ?> 43 48 <?php endif; ?> 44 49 -
trunk/bp-themes/bp-default/members/single/member-header.php
r3263 r3300 9 9 <div id="item-header-content"> 10 10 11 <h2 class="fn"><a href="<?php bp_ user_link() ?>"><?php bp_displayed_user_fullname() ?></a> <span class="highlight">@<?php bp_displayed_user_username() ?> <span>?</span></span></h2>11 <h2 class="fn"><a href="<?php bp_displayed_user_link() ?>"><?php bp_displayed_user_fullname() ?></a> <span class="highlight">@<?php bp_displayed_user_username() ?> <span>?</span></span></h2> 12 12 <span class="activity"><?php bp_last_activity( bp_displayed_user_id() ) ?></span> 13 13 -
trunk/bp-themes/bp-default/members/single/messages.php
r2397 r3300 3 3 <?php bp_get_options_nav() ?> 4 4 </ul> 5 </div> 5 </div><!-- .item-list-tabs --> 6 6 7 7 <?php if ( 'compose' == bp_current_action() ) : ?> … … 23 23 24 24 <?php endif; ?> 25 </div> 25 </div><!-- .messages --> 26 26 27 27 <?php do_action( 'bp_after_member_messages_content' ) ?> -
trunk/bp-themes/bp-default/members/single/messages/compose.php
r2191 r3300 11 11 </ul> 12 12 13 <?php if ( is_s ite_admin() ) : ?>13 <?php if ( is_super_admin() ) : ?> 14 14 <input type="checkbox" id="send-notice" name="send-notice" value="1" /> <?php _e( "This is a notice to all users.", "buddypress" ) ?> 15 15 <?php endif; ?> -
trunk/bp-themes/bp-default/members/single/messages/messages-loop.php
r2502 r3300 18 18 <?php do_action( 'bp_before_member_messages_threads' ) ?> 19 19 20 <table id="message-threads" >20 <table id="message-threads" class="zebra"> 21 21 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 22 22 -
trunk/bp-themes/bp-default/members/single/messages/notices-loop.php
r2397 r3300 18 18 <?php do_action( 'bp_before_notices' ) ?> 19 19 20 <table id="message-threads" >20 <table id="message-threads" class="zebra"> 21 21 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 22 22 <tr> -
trunk/bp-themes/bp-default/members/single/plugins.php
r2822 r3300 8 8 <div id="item-header"> 9 9 <?php locate_template( array( 'members/single/member-header.php' ), true ) ?> 10 </div> 10 </div><!-- #item-header --> 11 11 12 12 <div id="item-nav"> … … 14 14 <ul> 15 15 <?php bp_get_displayed_user_nav() ?> 16 17 <?php do_action( 'bp_member_options_nav' ) ?> 16 18 </ul> 17 19 </div> 18 </div> 20 </div><!-- #item-nav --> 19 21 20 22 <div id="item-body"> 23 <?php do_action( 'bp_before_member_body' ) ?> 21 24 22 25 <div class="item-list-tabs no-ajax" id="subnav"> … … 26 29 <?php do_action( 'bp_member_plugin_options_nav' ) ?> 27 30 </ul> 28 </div> 31 </div><!-- .item-list-tabs --> 32 33 <?php do_action( 'bp_template_title' ) ?> 29 34 30 35 <?php do_action( 'bp_template_content' ) ?> 36 37 <?php do_action( 'bp_after_member_body' ) ?> 31 38 32 39 </div><!-- #item-body --> … … 39 46 <?php locate_template( array( 'sidebar.php' ), true ) ?> 40 47 41 <?php do_action( 'bp_after_member_plugin_template' ) ?>42 43 48 <?php get_footer() ?> -
trunk/bp-themes/bp-default/members/single/profile.php
r2287 r3300 4 4 <?php bp_get_options_nav() ?> 5 5 </ul> 6 </div> 6 </div><!-- .item-list-tabs --> 7 7 <?php endif; ?> 8 8 -
trunk/bp-themes/bp-default/members/single/profile/edit.php
r3232 r3300 48 48 <?php bp_the_profile_field_options() ?> 49 49 </select> 50 51 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 52 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 53 <?php endif; ?> 50 54 51 55 <?php endif; ?> -
trunk/bp-themes/bp-default/members/single/profile/profile-loop.php
r2585 r3300 16 16 <?php endif; ?> 17 17 18 <table class="profile-fields ">18 <table class="profile-fields zebra"> 19 19 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 20 20 21 21 <?php if ( bp_field_has_data() ) : ?> 22 <tr >22 <tr<?php bp_field_css_class() ?>> 23 23 24 24 <td class="label"> -
trunk/bp-themes/bp-default/registration/register.php
r2784 r3300 46 46 <?php do_action( 'bp_after_account_details_fields' ) ?> 47 47 48 <?php do_action( 'bp_before_blog_details_fields' ) ?>49 50 51 48 <?php /***** Extra Profile Details ******/ ?> 52 49 53 50 <?php if ( bp_is_active( 'xprofile' ) ) : ?> 54 <div class="register-section" id="profile-details-section"> 55 56 <h4><?php _e( 'Profile Details', 'buddypress' ) ?></h4> 57 58 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 59 <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 60 61 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 62 63 <div class="editfield"> 64 65 <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?> 66 67 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 68 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 69 <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" /> 70 71 <?php endif; ?> 72 73 <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?> 74 75 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 76 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 77 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea> 78 79 <?php endif; ?> 80 81 <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?> 82 83 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 84 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 85 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"> 86 <?php bp_the_profile_field_options() ?> 87 </select> 88 89 <?php endif; ?> 90 91 <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?> 92 93 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 94 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 95 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple"> 96 <?php bp_the_profile_field_options() ?> 97 </select> 98 99 <?php endif; ?> 100 101 <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?> 102 103 <div class="radio"> 104 <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span> 105 51 52 <?php do_action( 'bp_before_signup_profile_fields' ) ?> 53 54 <div class="register-section" id="profile-details-section"> 55 56 <h4><?php _e( 'Profile Details', 'buddypress' ) ?></h4> 57 58 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 59 <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 60 61 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 62 63 <div class="editfield"> 64 65 <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?> 66 67 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 106 68 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 107 <?php bp_the_profile_field_options() ?> 108 109 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 110 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 111 <?php endif; ?> 112 </div> 113 114 <?php endif; ?> 115 116 <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?> 117 118 <div class="checkbox"> 119 <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span> 120 69 <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" /> 70 71 <?php endif; ?> 72 73 <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?> 74 75 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 121 76 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 122 <?php bp_the_profile_field_options() ?> 123 </div> 124 125 <?php endif; ?> 126 127 <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?> 128 129 <div class="datebox"> 130 <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 77 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea> 78 79 <?php endif; ?> 80 81 <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?> 82 83 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 131 84 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 132 133 <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day"> 134 <?php bp_the_profile_field_options( 'type=day' ) ?> 85 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"> 86 <?php bp_the_profile_field_options() ?> 135 87 </select> 136 88 137 <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month"> 138 <?php bp_the_profile_field_options( 'type=month' ) ?> 89 <?php endif; ?> 90 91 <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?> 92 93 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 94 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 95 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple"> 96 <?php bp_the_profile_field_options() ?> 139 97 </select> 140 98 141 <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year"> 142 <?php bp_the_profile_field_options( 'type=year' ) ?> 143 </select> 144 </div> 145 146 <?php endif; ?> 147 148 <?php do_action( 'bp_custom_profile_edit_fields' ) ?> 149 150 <p class="description"><?php bp_the_profile_field_description() ?></p> 151 152 </div> 153 154 <?php endwhile; ?> 155 156 <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" /> 157 158 <?php endwhile; endif; endif; ?> 159 160 </div><!-- #profile-details-section --> 99 <?php endif; ?> 100 101 <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?> 102 103 <div class="radio"> 104 <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span> 105 106 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 107 <?php bp_the_profile_field_options() ?> 108 109 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 110 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 111 <?php endif; ?> 112 </div> 113 114 <?php endif; ?> 115 116 <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?> 117 118 <div class="checkbox"> 119 <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span> 120 121 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 122 <?php bp_the_profile_field_options() ?> 123 </div> 124 125 <?php endif; ?> 126 127 <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?> 128 129 <div class="datebox"> 130 <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label> 131 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 132 133 <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day"> 134 <?php bp_the_profile_field_options( 'type=day' ) ?> 135 </select> 136 137 <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month"> 138 <?php bp_the_profile_field_options( 'type=month' ) ?> 139 </select> 140 141 <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year"> 142 <?php bp_the_profile_field_options( 'type=year' ) ?> 143 </select> 144 </div> 145 146 <?php endif; ?> 147 148 <?php do_action( 'bp_custom_profile_edit_fields' ) ?> 149 150 <p class="description"><?php bp_the_profile_field_description() ?></p> 151 152 </div> 153 154 <?php endwhile; ?> 155 156 <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" /> 157 158 <?php endwhile; endif; endif; ?> 159 160 </div><!-- #profile-details-section --> 161 162 <?php do_action( 'bp_after_signup_profile_fields' ) ?> 163 161 164 <?php endif; ?> 162 163 <?php do_action( 'bp_after_signup_profile_fields' ) ?> 164 165 165 166 <?php if ( bp_get_blog_signup_allowed() ) : ?> 166 167 … … 180 181 <?php do_action( 'bp_signup_blog_url_errors' ) ?> 181 182 182 <?php if ( 'yes' == VHOST) : ?>183 <?php if ( is_subdomain_install() ) : ?> 183 184 http:// <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" /> .<?php echo str_replace( 'http://', '', site_url() ) ?> 184 185 <?php else : ?> … … 207 208 208 209 <div class="submit"> 209 <input type="submit" name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> →" />210 <input type="submit" name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> →" /> 210 211 </div> 211 212 -
trunk/bp-themes/bp-default/search.php
r2425 r3300 33 33 <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 34 34 35 <p class="date"><?php the_time( 'F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>35 <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p> 36 36 37 37 <div class="entry"> -
trunk/bp-themes/bp-default/sidebar.php
r3232 r3300 15 15 </a> 16 16 17 <h4><?php bp_loggedinuser_link()?></h4>17 <h4><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></h4> 18 18 <a class="button logout" href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>"><?php _e( 'Log Out', 'buddypress' ) ?></a> 19 19 … … 38 38 </p> 39 39 40 <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login ' ) ?>" method="post">40 <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login_post' ) ?>" method="post"> 41 41 <label><?php _e( 'Username', 'buddypress' ) ?><br /> 42 <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" /></label>42 <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" /></label> 43 43 44 44 <label><?php _e( 'Password', 'buddypress' ) ?><br /> -
trunk/bp-themes/bp-default/single.php
r2694 r3300 27 27 <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 28 28 29 <p class="date"><?php the_time( 'F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>29 <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em> <?php edit_post_link( __( 'Edit this entry', 'buddypress' ), '<em class="edit-link">', '</em>' ); ?></p> 30 30 31 31 <div class="entry"> -
trunk/bp-xprofile.php
r3232 r3300 16 16 * @uses site_url() Returns the site URL 17 17 */ 18 19 18 function xprofile_setup_globals() { 20 19 global $bp, $wpdb; … … 30 29 $bp->profile->id = 'profile'; 31 30 32 $bp->profile->table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups'; 33 $bp->profile->table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields'; 34 $bp->profile->table_name_data = $wpdb->base_prefix . 'bp_xprofile_data'; 31 $bp->profile->slug = BP_XPROFILE_SLUG; 32 33 $bp->profile->table_name_data = $bp->table_prefix . 'bp_xprofile_data'; 34 $bp->profile->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups'; 35 $bp->profile->table_name_fields = $bp->table_prefix . 'bp_xprofile_fields'; 35 36 36 37 $bp->profile->format_notification_function = 'xprofile_format_notifications'; 37 $bp->profile->slug = BP_XPROFILE_SLUG;38 38 39 39 /* Register this in the active components array */ … … 56 56 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 57 57 * @global $wpdb WordPress DB access object. 58 * @uses is_s ite_admin() returns true if the current user is a site admin, false if not58 * @uses is_super_admin() returns true if the current user is a site admin, false if not 59 59 * @uses bp_xprofile_install() runs the installation of DB tables for the xprofile component 60 60 * @uses wp_enqueue_script() Adds a JS file to the JS queue ready for output … … 66 66 global $wpdb, $bp; 67 67 68 if ( !is_s ite_admin() )68 if ( !is_super_admin() ) 69 69 return false; 70 70 … … 127 127 128 128 /* Don't show this menu to non site admins or if you're viewing your own profile */ 129 if ( !is_s ite_admin() || bp_is_my_profile() )130 return false; ?>131 129 if ( !is_super_admin() || bp_is_my_profile() ) 130 return false; 131 ?> 132 132 <li id="bp-adminbar-adminoptions-menu"> 133 133 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> 134 134 135 135 <ul> 136 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>137 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>138 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 139 < li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>140 <?php else : ?>141 142 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>143 <?php endif; ?>144 145 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>146 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 147 136 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li> 137 <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li> 138 139 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 140 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li> 141 <?php else : ?> 142 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li> 143 <?php endif; ?> 144 145 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li> 146 147 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 148 148 </ul> 149 149 </li> 150 <?php150 <?php 151 151 } 152 152 add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 ); … … 188 188 global $bp; 189 189 190 if ( !bp_is_my_profile() && !is_s ite_admin() )190 if ( !bp_is_my_profile() && !is_super_admin() ) 191 191 return false; 192 192 … … 235 235 } 236 236 237 if ( $errors)237 if ( !empty( $errors ) ) 238 238 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 239 239 else { … … 249 249 } 250 250 251 do_action( 'xprofile_updated_profile', $ posted_field_ids, $errors );251 do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors ); 252 252 253 253 /* Set the feedback messages */ … … 278 278 global $bp; 279 279 280 if ( !bp_is_my_profile() && !is_s ite_admin() )280 if ( !bp_is_my_profile() && !is_super_admin() ) 281 281 return false; 282 282 … … 347 347 check_admin_referer( 'bp_delete_avatar_link' ); 348 348 349 if ( !bp_is_my_profile() && !is_s ite_admin() )349 if ( !bp_is_my_profile() && !is_super_admin() ) 350 350 return false; 351 351 … … 406 406 'item_id' => false, 407 407 'secondary_item_id' => false, 408 'recorded_time' => gmdate( "Y-m-d H:i:s"),408 'recorded_time' => bp_core_current_time(), 409 409 'hide_sitewide' => false 410 410 ); … … 642 642 return false; 643 643 644 /* If the value is empty, then delete any field data that exists */ 645 if ( empty( $value ) ) { 646 xprofile_delete_field_data( $field_id, $user_id ); 647 return true; 648 } 649 644 650 $field = new BP_XProfile_Field( $field_id ); 645 651 646 /* Check th at value is acceptable */652 /* Check the value is an acceptable value */ 647 653 if ( 'checkbox' == $field->type || 'radio' == $field->type || 'selectbox' == $field->type || 'multiselectbox' == $field->type ) { 648 654 $options = $field->get_children(); 649 650 /* Not required fields can have empty value */651 if ( !$is_required )652 $possible_values[] = '';653 655 654 656 foreach( $options as $option ) … … 661 663 } 662 664 663 /* Field must be required to trigger error */ 664 if ( $is_required && empty( $value ) ) 665 if ( empty( $value ) ) 665 666 return false; 666 667 … … 687 688 $field_id = xprofile_get_field_id_from_name( $field ); 688 689 689 if ( !$field_id)690 return false; 691 692 $field = new BP_XProfile_ProfileData( $field_id );690 if ( empty( $field_id ) || empty( $user_id ) ) 691 return false; 692 693 $field = new BP_XProfile_ProfileData( $field_id, $user_id ); 693 694 return $field->delete(); 694 695 } … … 796 797 @wp_mkdir_p( $path ); 797 798 798 $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );799 $newurl = BP_AVATAR_URL . '/avatars/' . $user_id; 799 800 $newburl = $newurl; 800 801 $newsubdir = '/avatars/' . $user_id; … … 833 834 } 834 835 835 update_user meta( $user_id, 'nickname', $fullname );836 update_user meta( $user_id, 'first_name', $firstname );837 update_user meta( $user_id, 'last_name', $lastname );836 update_user_meta( $user_id, 'nickname', $fullname ); 837 update_user_meta( $user_id, 'first_name', $firstname ); 838 update_user_meta( $user_id, 'last_name', $lastname ); 838 839 839 840 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) ); … … 842 843 add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' ); 843 844 add_action( 'bp_core_signup_user', 'xprofile_sync_wp_profile' ); 845 846 847 /* xprofile_sync_bp_profile() 848 * 849 * Syncs the standard built in WordPress profile data to XProfile. 850 * 851 * @since 1.2.4 852 * @package BuddyPress Core 853 */ 854 function xprofile_sync_bp_profile( &$errors, $update, &$user ) { 855 global $bp; 856 857 if ( (int)$bp->site_options['bp-disable-profile-sync'] || !$update || $errors->get_error_codes() ) 858 return; 859 860 xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user->ID, $user->display_name ); 861 } 862 add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 ); 844 863 845 864 /** … … 869 888 * @package BuddyPress XProfile 870 889 * @param $user_id The ID of the deleted user 871 * @uses get_user meta() Get a user meta value based on meta key from wp_usermeta872 * @uses delete_user meta() Delete user meta value based on meta key from wp_usermeta890 * @uses get_user_meta() Get a user meta value based on meta key from wp_usermeta 891 * @uses delete_user_meta() Delete user meta value based on meta key from wp_usermeta 873 892 * @uses delete_data_for_user() Removes all profile data from the xprofile tables for the user 874 893 */ … … 919 938 } 920 939 921 / * List actions to clear object caches on */940 // List actions to clear object caches on 922 941 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' ); 923 942 add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' ); 924 943 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 925 944 926 / * List actions to clear super cached pages on, if super cache is installed */945 // List actions to clear super cached pages on, if super cache is installed 927 946 add_action( 'xprofile_updated_profile', 'bp_core_clear_cache' ); 928 947 -
trunk/bp-xprofile/admin/css/admin.css
r3232 r3300 165 165 } 166 166 167 select.multi-select {167 select.multi-select { 168 168 width:90%; 169 169 height:10em !important; … … 180 180 } 181 181 182 ul.multi-checkbox li {182 ul.multi-checkbox li { 183 183 padding: 0; 184 184 margin: 0; -
trunk/bp-xprofile/admin/js/admin.js
r2887 r3300 37 37 38 38 toDeleteText = document.createTextNode('[x]'); 39 40 39 toDelete.setAttribute('href',"javascript:hide('" + forWhat + '_div' + theId + "')"); 40 41 41 toDelete.setAttribute('class','delete'); 42 42 43 toDelete.appendChild(toDeleteText); 43 44 … … 50 51 holder.appendChild(newDiv); 51 52 53 52 54 theId++ 53 55 document.getElementById(forWhat + "_option_number").value = theId; … … 74 76 75 77 function hide(id) { 76 if ( !document.getElementById(id) ) return ;78 if ( !document.getElementById(id) ) return false; 77 79 78 80 document.getElementById(id).style.display = "none"; … … 80 82 } 81 83 82 / * Set up deleting options ajax */84 // Set up deleting options ajax 83 85 jQuery(document).ready( function() { 86 84 87 jQuery("a.ajax-option-delete").click( 85 88 function() { … … 91 94 'cookie': encodeURIComponent(document.cookie), 92 95 '_wpnonce': jQuery("input#_wpnonce").val(), 96 93 97 'option_id': theId 94 98 }, 95 function(response){}); 99 function(response) 100 {}); 96 101 } 97 ); 102 ); 98 103 }); 99 104 100 /* Main XProfile behavior layer */ 105 var fixHelper = function(e, ui) { 106 ui.children().each(function() { 107 jQuery(this).width( jQuery(this).width() ); 108 }); 109 return ui; 110 }; 111 112 // Main XProfile behavior layer 101 113 jQuery(document).ready( function() { 102 114 /* Show object if JS is enabled */ … … 137 149 'field_group_id': jQuery(this).attr( 'id' ) 138 150 }, 139 function(response){}); 151 function(response) 152 {}); 140 153 } 141 154 }) -
trunk/bp-xprofile/bp-xprofile-admin.php
r3232 r3300 59 59 60 60 <div id="message" class="<?php echo $type; ?> fade"> 61 <p><?php echo wp_specialchars( attribute_escape( $message ) ); ?></p>61 <p><?php echo wp_specialchars( esc_attr( $message ) ); ?></p> 62 62 </div> 63 63 <?php endif; ?> -
trunk/bp-xprofile/bp-xprofile-classes.php
r3232 r3300 202 202 <?php endif; ?> 203 203 <div id="poststuff"> 204 <form action="<?php echo attribute_escape( $action ); ?>" method="post">204 <form action="<?php echo esc_attr( $action ); ?>" method="post"> 205 205 <div id="titlediv"> 206 206 <h3><label for="group_name"><?php _e( "Field Group Title", 'buddypress') ?> *</label></h3> 207 207 <div id="titlewrap"> 208 <input type="text" name="group_name" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />208 <input type="text" name="group_name" id="title" value="<?php echo esc_attr( $this->name ); ?>" style="width:50%" /> 209 209 </div> 210 210 </div> … … 220 220 221 221 <p class="submit"> 222 <input type="hidden" name="group_order" id="group_order" value="<?php echo attribute_escape( $this->group_order ); ?>" />223 <input type="submit" name="save_group" value="<?php echo attribute_escape( $button ); ?>" class="button-primary"/>222 <input type="hidden" name="group_order" id="group_order" value="<?php echo esc_attr( $this->group_order ); ?>" /> 223 <input type="submit" name="save_group" value="<?php echo esc_attr( $button ); ?>" class="button-primary"/> 224 224 <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a> 225 225 </p> … … 321 321 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->id ); 322 322 else 323 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order );323 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, %d, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->parent_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order ); 324 324 325 325 /* … … 547 547 ?> 548 548 <p><?php _e('Option', 'buddypress'); ?> <?php echo $j; ?>: 549 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo attribute_escape( $options[$i]->name ); ?>" />549 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo esc_attr( $options[$i]->name ); ?>" /> 550 550 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?> 551 551 <?php … … 610 610 <h3><label for="title"><?php _e( 'Field Title', 'buddypress' ); ?> *</label></h3> 611 611 <div id="titlewrap"> 612 <input type="text" name="title" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />612 <input type="text" name="title" id="title" value="<?php echo esc_attr( $this->name ); ?>" style="width:50%" /> 613 613 </div> 614 614 </div> … … 650 650 <?php } ?> 651 651 <p class="submit"> 652 <input type="hidden" name="field_order" id="field_order" value="<?php echo attribute_escape( $this->field_order ); ?>" />652 <input type="hidden" name="field_order" id="field_order" value="<?php echo esc_attr( $this->field_order ); ?>" /> 653 653 <input type="submit" value="<?php _e( 'Save', 'buddypress' ); ?>" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" /> 654 654 <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a> -
trunk/bp-xprofile/bp-xprofile-filters.php
r3254 r3300 129 129 if ( $fullnames = BP_XProfile_ProfileData::get_value_byid( 1, $user_ids ) ) { 130 130 foreach( (array)$fullnames as $user ) { 131 $users[$user->user_id] = trim( $user->value);131 $users[$user->user_id] = trim($user->value); 132 132 } 133 133 } -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r3232 r3300 21 21 function bp_xprofile_data_template( $user_id, $profile_group_id ) { 22 22 $this->groups = BP_XProfile_Group::get( array( 23 'profile_group_id' 24 'user_id' 25 'hide_empty_groups' 26 'fetch_fields' 27 'fetch_field_data' 23 'profile_group_id' => $profile_group_id, 24 'user_id' => $user_id, 25 'hide_empty_groups' => true, 26 'fetch_fields' => true, 27 'fetch_field_data' => true 28 28 ) ); 29 29 30 $this->group_count = count( $this->groups);30 $this->group_count = count($this->groups); 31 31 $this->user_id = $user_id; 32 32 } … … 51 51 function rewind_groups() { 52 52 $this->current_group = -1; 53 54 if ( $this->group_count > 0 ) 53 if ( $this->group_count > 0 ) { 55 54 $this->group = $this->groups[0]; 55 } 56 56 } 57 57 … … 60 60 return true; 61 61 } elseif ( $this->current_group + 1 == $this->group_count ) { 62 do_action( 'xprofile_template_loop_end');63 / * Do some cleaning up after the loop */62 do_action('xprofile_template_loop_end'); 63 // Do some cleaning up after the loop 64 64 $this->rewind_groups(); 65 65 } … … 75 75 $group = $this->next_group(); 76 76 77 if ( 0 == $this->current_group ) / * loop has just started */78 do_action( 'xprofile_template_loop_start');77 if ( 0 == $this->current_group ) // loop has just started 78 do_action('xprofile_template_loop_start'); 79 79 } 80 80 … … 90 90 function rewind_fields() { 91 91 $this->current_field = -1; 92 93 if ( $this->field_count > 0 ) 92 if ( $this->field_count > 0 ) { 94 93 $this->field = $this->group->fields[0]; 94 } 95 95 } 96 96 … … 101 101 $field = &$this->group->fields[$i]; 102 102 103 if ( $field->data->value != null ) 103 if ( $field->data->value != null ) { 104 104 $has_data = true; 105 } 105 106 } 106 107 … … 112 113 113 114 function profile_fields() { 114 if ( $this->current_field + 1 < $this->field_count ) 115 if ( $this->current_field + 1 < $this->field_count ) { 115 116 return true; 116 117 /* Do some cleaning up after the loop */ 118 elseif ( $this->current_field + 1 == $this->field_count ) 117 } elseif ( $this->current_field + 1 == $this->field_count ) { 118 // Do some cleaning up after the loop 119 119 $this->rewind_fields(); 120 } 120 121 121 122 return false; … … 127 128 $field = $this->next_field(); 128 129 129 if ( !empty( $field->data->value ) ) 130 if ( !empty( $field->data->value ) ) { 130 131 $this->field_has_data = true; 131 else 132 } 133 else { 132 134 $this->field_has_data = false; 135 } 133 136 } 134 137 } … … 177 180 178 181 if ( $class ) 179 $css_classes[] = sanitize_title( attribute_escape( $class ) );182 $css_classes[] = sanitize_title( esc_attr( $class ) ); 180 183 181 184 /* Set a class with the field ID */ … … 185 188 $css_classes[] = 'field_' . sanitize_title( $profile_template->field->name ); 186 189 187 if ( $profile_template->current_field % 2 )190 if ( $profile_template->current_field % 2 == 1 ) 188 191 $css_classes[] = 'alt'; 189 192 … … 254 257 global $group; 255 258 256 foreach ( (array) $group->fields as $field ) {259 foreach ( (array) $group->fields as $field ) 257 260 $field_ids .= $field->id . ','; 258 }259 261 260 262 return substr( $field_ids, 0, -1 ); … … 343 345 global $field; 344 346 345 return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id ); 347 $array_box = false; 348 if ( 'multiselectbox' == $field->type ) 349 $array_box = '[]'; 350 351 return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id . $array_box ); 346 352 } 347 353 … … 369 375 if ( 'multiselectbox' != $field->type ) 370 376 $html .= '<option value="">--------</option>'; 377 378 for ( $k = 0; $k < count($options); $k++ ) { 379 $option_values = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ); 380 $option_values = (array)$option_values; 381 382 /* Check for updated posted values, but errors preventing them from being saved first time */ 383 foreach( (array)$option_values as $i => $option_value ) { 384 if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) { 385 if ( !empty( $_POST['field_' . $field->id] ) ) 386 $option_values[$i] = $_POST['field_' . $field->id]; 387 } 388 } 389 390 if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option ) { 391 $selected = ' selected="selected"'; 392 } else { 393 $selected = ''; 394 } 395 396 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . esc_attr( $options[$k]->name ) . '">' . esc_attr( $options[$k]->name ) . '</option>', $options[$k] ); 397 } 398 break; 399 400 case 'radio': 401 $html = '<div id="field_' . $field->id . '">'; 371 402 372 403 for ( $k = 0; $k < count($options); $k++ ) { … … 379 410 } 380 411 381 if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option )382 $selected = ' selected="selected"';383 else412 if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) { 413 $selected = ' checked="checked"'; 414 } else { 384 415 $selected = ''; 385 386 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . attribute_escape( stripslashes( $options[$k]->name ) ) . '">' . attribute_escape( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k] );387 }388 break;389 390 case 'radio':391 $html = '<div id="field_' . $field->id . '">';392 393 for ( $k = 0; $k < count( $options ); $k++ ) {394 $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id );395 396 /* Check for updated posted values, but errors preventing them from being saved first time */397 if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) {398 if ( !empty( $_POST['field_' . $field->id] ) )399 $option_value = $_POST['field_' . $field->id];400 416 } 401 417 402 if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) 403 $selected = ' checked="checked"'; 404 else 405 $selected = ''; 406 407 $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] ); 418 $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . esc_attr( $options[$k]->name ) . '"> ' . esc_attr( $options[$k]->name ) . '</label>', $options[$k] ); 408 419 } 409 420 … … 412 423 413 424 case 'checkbox': 414 $option_values = BP_XProfile_ProfileData::get_value_byid( $options[0]->parent_id);425 $option_values = BP_XProfile_ProfileData::get_value_byid($options[0]->parent_id); 415 426 416 427 /* Check for updated posted values, but errors preventing them from being saved first time */ … … 420 431 } 421 432 422 $option_values = maybe_unserialize( $option_values);423 424 for ( $k = 0; $k < count( $options); $k++ ) {425 for ( $j = 0; $j < count( $option_values); $j++ ) {433 $option_values = maybe_unserialize($option_values); 434 435 for ( $k = 0; $k < count($options); $k++ ) { 436 for ( $j = 0; $j < count($option_values); $j++ ) { 426 437 if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) { 427 438 $selected = ' checked="checked"'; … … 430 441 } 431 442 432 $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<label><input' . $selected . ' type="checkbox" name="field_' . $field->id . '[]" id="field_' . $options[$k]->id . '_' . $k . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] );443 $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<label><input' . $selected . ' type="checkbox" name="field_' . $field->id . '[]" id="field_' . $options[$k]->id . '_' . $k . '" value="' . esc_attr( $options[$k]->name ) . '"> ' . esc_attr( $options[$k]->name ) . '</label>', $options[$k] ); 433 444 $selected = ''; 434 445 } … … 438 449 439 450 if ( !empty( $field->data->value ) ) { 440 $day 441 $month 442 $year 443 $default_select 451 $day = date("j", $field->data->value); 452 $month = date("F", $field->data->value); 453 $year = date("Y", $field->data->value); 454 $default_select = ' selected="selected"'; 444 455 } 445 456 … … 462 473 switch ( $type ) { 463 474 case 'day': 464 $html .= '<option value=""' . attribute_escape( $default_select ) . '>--</option>';475 $html .= '<option value=""' . esc_attr( $default_select ) . '>--</option>'; 465 476 466 477 for ( $i = 1; $i < 32; $i++ ) { 467 if ( $day == $i ) 478 if ( $day == $i ) { 468 479 $selected = ' selected = "selected"'; 469 else480 } else { 470 481 $selected = ''; 471 482 } 472 483 $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>'; 473 484 } … … 483 494 ); 484 495 485 $html .= '<option value=""' . attribute_escape( $default_select ) . '>------</option>';496 $html .= '<option value=""' . esc_attr( $default_select ) . '>------</option>'; 486 497 487 498 for ( $i = 0; $i < 12; $i++ ) { 488 if ( $month == $eng_months[$i] ) 499 if ( $month == $eng_months[$i] ) { 489 500 $selected = ' selected = "selected"'; 490 else501 } else { 491 502 $selected = ''; 503 } 492 504 493 505 $html .= '<option value="' . $eng_months[$i] . '"' . $selected . '>' . $months[$i] . '</option>'; … … 496 508 497 509 case 'year': 498 $html .= '<option value=""' . attribute_escape( $default_select ) . '>----</option>';510 $html .= '<option value=""' . esc_attr( $default_select ) . '>----</option>'; 499 511 500 512 for ( $i = date( 'Y', time() ); $i > 1899; $i-- ) { 501 if ( $year == $i ) 513 if ( $year == $i ) { 502 514 $selected = ' selected = "selected"'; 503 else515 } else { 504 516 $selected = ''; 517 } 505 518 506 519 $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>'; … … 523 536 global $field; 524 537 525 return apply_filters( 'bp_get_the_profile_field_is_required', (int) 538 return apply_filters( 'bp_get_the_profile_field_is_required', (int)$field->is_required ); 526 539 } 527 540 528 541 function bp_unserialize_profile_field( $value ) { 529 if ( is_serialized( $value) ) {530 $field_value = maybe_unserialize( $value);542 if ( is_serialized($value) ) { 543 $field_value = maybe_unserialize($value); 531 544 $field_value = implode( ', ', $field_value ); 532 545 return $field_value; … … 541 554 function bp_get_profile_field_data( $args = '' ) { 542 555 $defaults = array( 543 'field' => false, /* Field name or ID. */544 'user_id' 545 );556 'field' => false, // Field name or ID. 557 'user_id' => $bp->displayed_user->id 558 ); 546 559 547 560 $r = wp_parse_args( $args, $defaults ); … … 562 575 $group_name = bp_profile_group_name(false); 563 576 564 for ( $i = 0; $i < count( $groups); $i++ ) {565 if ( $group_name == $groups[$i]->name ) 577 for ( $i = 0; $i < count($groups); $i++ ) { 578 if ( $group_name == $groups[$i]->name ) { 566 579 $selected = ' class="current"'; 567 else580 } else { 568 581 $selected = ''; 582 } 569 583 570 584 if ( $groups[$i]->fields ) 571 echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . attribute_escape( $groups[$i]->name ) . '</a></li>';585 echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . esc_attr( $groups[$i]->name ) . '</a></li>'; 572 586 } 573 587 … … 584 598 585 599 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 586 $group = new BP_XProfile_Group( $group_id);600 $group = new BP_XProfile_Group($group_id); 587 601 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' ); 588 602 } 589 603 590 if ( !$deprecated ) 604 if ( !$deprecated ) { 591 605 return bp_get_profile_group_name(); 592 else606 } else { 593 607 echo bp_get_profile_group_name(); 608 } 594 609 } 595 610 function bp_get_profile_group_name() { … … 602 617 603 618 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 604 $group = new BP_XProfile_Group( $group_id);619 $group = new BP_XProfile_Group($group_id); 605 620 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' ); 606 621 } … … 623 638 $last_updated = bp_get_profile_last_updated(); 624 639 625 if ( !$last_updated ) 640 if ( !$last_updated ) { 626 641 _e( 'Profile not recently updated', 'buddypress' ) . '.'; 627 else642 } else { 628 643 echo $last_updated; 644 } 629 645 } 630 646 function bp_get_profile_last_updated() { 631 647 global $bp; 632 648 633 $last_updated = get_user meta( $bp->displayed_user->id, 'profile_last_updated');649 $last_updated = get_user_meta( $bp->displayed_user->id, 'profile_last_updated', true ); 634 650 635 651 if ( $last_updated ) … … 648 664 $profile_group_id = 1; 649 665 650 /* admin/profile/edit/[group-id] */ 651 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); 666 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); // admin/profile/edit/[group-id] 652 667 } 653 668 … … 671 686 global $bp; 672 687 688 bp_button( array ( 689 'id' => 'edit_profile', 690 'component' => 'xprofile', 691 'must_be_logged_in' => true, 692 'block_self' => true, 693 'link_href' => trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit' ), 694 'link_class' => 'edit', 695 'link_text' => __( 'Edit Profile', 'buddypress' ), 696 'link_title' => __( 'Edit Profile', 'buddypress' ), 697 ) ); 698 } 699 673 700 ?> 674 675 <div class="generic-button">676 <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ); ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ); ?></a>677 </div>678 <?php679 }680 681 ?>
Note: See TracChangeset
for help on using the changeset viewer.