Changeset 2077
- Timestamp:
- 11/02/2009 07:54:21 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 118 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2002 r2077 14 14 /* Include deprecated functions if settings allow */ 15 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' ); 17 16 require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' ); 17 18 18 function bp_activity_install() { 19 19 global $wpdb, $bp; 20 20 21 21 if ( !empty($wpdb->charset) ) 22 22 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 23 23 24 24 $sql[] = "CREATE TABLE {$bp->activity->table_name} ( 25 25 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 41 41 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 42 42 dbDelta($sql); 43 43 44 44 /* Drop the old sitewide and user activity tables */ 45 45 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" ); 46 46 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" ); 47 47 48 48 /* TODO: Rename the old user activity cached table */ 49 49 //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" ); … … 57 57 /* Internal identifier */ 58 58 $bp->activity->id = 'activity'; 59 59 60 60 $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached'; 61 61 $bp->activity->slug = BP_ACTIVITY_SLUG; 62 62 63 63 /* Register this in the active components array */ 64 64 $bp->active_components[$bp->activity->slug] = $bp->activity->id; 65 65 66 66 do_action( 'bp_activity_setup_globals' ); 67 67 } … … 69 69 add_action( 'admin_menu', 'bp_activity_setup_globals', 2 ); 70 70 71 function bp_activity_check_installed() { 71 function bp_activity_check_installed() { 72 72 global $wpdb, $bp; 73 73 74 74 if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION ) 75 75 bp_activity_install(); … … 100 100 } else { 101 101 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 102 $bp->bp_options_title = $bp->displayed_user->fullname; 102 $bp->bp_options_title = $bp->displayed_user->fullname; 103 103 } 104 104 } … … 120 120 function bp_activity_screen_my_activity() { 121 121 do_action( 'bp_activity_screen_my_activity' ); 122 bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) ); 122 bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) ); 123 123 } 124 124 125 125 function bp_activity_screen_friends_activity() { 126 126 do_action( 'bp_activity_screen_friends_activity' ); 127 bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) ); 127 bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) ); 128 128 } 129 129 … … 148 148 /* Check the nonce */ 149 149 check_admin_referer( 'bp_activity_delete_link' ); 150 150 151 151 $activity_id = $bp->action_variables[0]; 152 152 153 153 /* Check access */ 154 154 if ( !is_site_admin() ) { 155 155 $activity = new BP_Activity_Activity( $activity_id ); 156 156 157 157 if ( $activity->user_id != $bp->loggedin_user->id ) 158 158 return false; 159 159 } 160 160 161 161 /* Now delete the activity item */ 162 162 if ( bp_activity_delete_by_activity_id( $activity_id ) ) … … 164 164 else 165 165 bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' ); 166 166 167 167 do_action( 'bp_activity_action_delete_activity', $activity_id ); 168 168 169 169 bp_core_redirect( $_SERVER['HTTP_REFERER'] ); 170 170 } … … 187 187 188 188 function bp_activity_action_personal_feed() { 189 global $bp, $wp_query; 189 global $bp, $wp_query; 190 190 191 191 if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' ) 192 192 return false; 193 193 194 194 $wp_query->is_404 = false; 195 195 status_header( 200 ); … … 206 206 return false; 207 207 208 $wp_query->is_404 = false; 208 $wp_query->is_404 = false; 209 209 status_header( 200 ); 210 210 211 211 include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' ); 212 die; 212 die; 213 213 } 214 214 add_action( 'wp', 'bp_activity_action_friends_feed', 3 ); … … 226 226 function bp_activity_add( $args = '' ) { 227 227 global $bp, $wpdb; 228 228 229 229 $defaults = array( 230 230 'content' => false, // The content of the activity item … … 232 232 'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent 233 233 'component_action' => false, // The component action e.g. new_wire_post, profile_updated 234 234 235 235 '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. 236 236 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id … … 242 242 $r = wp_parse_args( $args, $defaults ); 243 243 extract( $r, EXTR_SKIP ); 244 244 245 245 /* Insert the "time-since" placeholder */ 246 246 if ( $content ) … … 257 257 $activity->date_recorded = $recorded_time; 258 258 $activity->hide_sitewide = $hide_sitewide; 259 259 260 260 if ( !$activity->save() ) 261 261 return false; 262 262 263 263 do_action( 'bp_activity_add', $args ); 264 264 265 265 return true; 266 266 } … … 296 296 do_action( 'bp_activity_delete_by_activity_id', $activity_id ); 297 297 298 return true; 298 return true; 299 299 } 300 300 … … 316 316 317 317 do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name ); 318 318 319 319 return true; 320 320 } … … 322 322 function bp_activity_add_timesince_placeholder( $content ) { 323 323 /* Check a time-since span doesn't already exist */ 324 if ( false === strpos( $content, '<span class="time-since">' ) ) { 324 if ( false === strpos( $content, '<span class="time-since">' ) ) { 325 325 if ( !$pos = strpos( $content, '<blockquote' ) ) { 326 326 if ( !$pos = strpos( $content, '<div' ) ) { … … 331 331 } 332 332 } 333 333 334 334 if ( (int) $pos ) { 335 335 $before = substr( $content, 0, (int) $pos ); 336 336 $after = substr( $content, (int) $pos, strlen( $content ) ); 337 337 338 338 $content = $before . ' <span class="time-since">%s</span>' . $after; 339 339 } … … 342 342 } 343 343 344 function bp_activity_set_action( $component_id, $key, $value ) { 345 global $bp; 346 347 if ( empty( $component_id ) || empty( $key ) || empty( $value ) ) 348 return false; 349 350 $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array( 351 'key' => $key, 352 'value' => $value 353 ), $component_id, $key, $value ); 354 } 355 356 function bp_activity_get_action( $component_id, $key ) { 357 global $bp; 358 359 if ( empty( $component_id ) || empty( $key ) ) 360 return false; 361 362 return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 363 } 344 function bp_activity_set_action( $component_id, $key, $value ) { 345 global $bp; 346 347 if ( empty( $component_id ) || empty( $key ) || empty( $value ) ) 348 return false; 349 350 $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array( 351 'key' => $key, 352 'value' => $value 353 ), $component_id, $key, $value ); 354 } 355 356 function bp_activity_get_action( $component_id, $key ) { 357 global $bp; 358 359 if ( empty( $component_id ) || empty( $key ) ) 360 return false; 361 362 return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 363 } 364 364 365 365 function bp_activity_check_exists_by_content( $content ) { … … 389 389 // Clear the user's activity from the sitewide stream and clear their activity tables 390 390 BP_Activity_Activity::delete_for_user( $user_id ); 391 391 392 392 do_action( 'bp_activity_remove_data', $user_id ); 393 393 } … … 398 398 /* Ordering function - don't call this directly */ 399 399 function bp_activity_order_by_date( $a, $b ) { 400 return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) ); 400 return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) ); 401 401 } 402 402 -
trunk/bp-activity/bp-activity-classes.php
r2036 r2077 11 11 var $date_recorded; 12 12 var $hide_sitewide = false; 13 13 14 14 function bp_activity_activity( $id = false ) { 15 15 global $bp; 16 16 17 17 if ( $id ) { 18 18 $this->id = $id; … … 20 20 } 21 21 } 22 22 23 23 function populate() { 24 24 global $wpdb, $bp; 25 25 26 26 $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) ); 27 27 28 28 $this->id = $activity->id; 29 29 $this->item_id = $activity->item_id; … … 37 37 $this->hide_sitewide = $activity->hide_sitewide; 38 38 } 39 39 40 40 function save() { 41 41 global $wpdb, $bp, $current_user; 42 42 43 43 do_action( 'bp_activity_before_save', $this ); 44 44 45 45 if ( !$this->component_name || !$this->component_action ) 46 46 return false; 47 47 48 48 /*** 49 49 * Before v1.1 of BuddyPress, activity content was calculated at a later point. This is no longer the … … 54 54 if ( !$fetched_content = call_user_func( $bp->{$this->component_name}->format_activity_function, $this->item_id, $this->user_id, $this->component_action, $this->secondary_item_id, $this->for_secondary_user ) ) 55 55 return false; 56 56 57 57 $this->content = $fetched_content['content']; 58 58 $this->primary_link = $fetched_content['primary_link']; 59 59 } 60 60 } 61 61 62 62 if ( !$this->primary_link ) 63 63 $this->primary_link = $bp->loggedin_user->domain; 64 64 65 65 if ( $existing_activity_id = $this->exists() ) 66 66 BP_Activity_Activity::delete_by_activity_id( $existing_activity_id ); 67 67 68 68 /* If we have an existing ID, update the activity item, otherwise insert it. */ 69 69 if ( $this->id ) { … … 81 81 return false; 82 82 } 83 83 84 84 function exists() { 85 85 global $wpdb, $bp; 86 86 87 87 /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */ 88 88 return false; 89 89 90 90 /* If we have an item id, try and match on that, if not do a content match */ 91 91 if ( $this->item_id ) { 92 92 if ( $this->secondary_item_id ) 93 93 $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id ); 94 95 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) ); 94 95 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) ); 96 96 } else { 97 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) ); 98 } 99 } 100 101 /* Static Functions */ 97 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) ); 98 } 99 } 100 101 /* Static Functions */ 102 102 103 103 function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) { … … 106 106 if ( $secondary_item_id ) 107 107 $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id ); 108 108 109 109 if ( $component_action ) 110 110 $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action ); 111 111 112 112 if ( $user_id ) 113 113 $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id ); … … 115 115 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) ); 116 116 } 117 117 118 118 function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) { 119 119 return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); … … 122 122 function delete_by_activity_id( $activity_id ) { 123 123 global $bp, $wpdb; 124 124 125 125 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) ); 126 126 } 127 127 128 128 function delete_by_content( $user_id, $content, $component_name, $component_action ) { 129 129 global $bp, $wpdb; 130 131 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) ); 132 } 133 130 131 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) ); 132 } 133 134 134 function delete_for_user_by_component( $user_id, $component_name ) { 135 135 global $bp, $wpdb; 136 137 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) ); 138 } 139 136 137 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) ); 138 } 139 140 140 function delete_for_user( $user_id ) { 141 141 global $wpdb, $bp; … … 143 143 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) ); 144 144 } 145 145 146 146 function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) { 147 147 global $wpdb, $bp; 148 148 149 149 if ( $limit && $page ) 150 150 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 152 152 if ( $max_items ) 153 153 $max_sql = $wpdb->prepare( "LIMIT %d", $max_items ); 154 154 155 155 /* Sort out filtering */ 156 156 if ( $filter ) 157 157 $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ); 158 158 159 159 if ( $limit && $page && $max_items ) 160 160 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) ); 161 161 else 162 162 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) ); 163 163 164 164 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) ); 165 165 166 166 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 167 167 } 168 168 169 169 function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) { 170 170 global $wpdb, $bp; 171 171 172 172 // TODO: Max items per friend not yet implemented. 173 173 174 174 if ( !function_exists('friends_get_friend_user_ids') ) 175 175 return false; … … 177 177 if ( $limit && $page ) 178 178 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 179 179 180 180 if ( $max_items ) 181 181 $max_sql = $wpdb->prepare( "LIMIT %d", $max_items ); … … 189 189 if ( !$friend_ids ) 190 190 return false; 191 191 192 192 $friend_ids = implode( ',', $friend_ids ); 193 193 194 194 if ( $limit && $page && $max_items ) 195 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql" ) ); 195 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql" ) ); 196 196 else 197 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) ); 198 199 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) ); 200 197 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) ); 198 199 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) ); 200 201 201 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 202 202 } 203 203 204 204 function get_sitewide_activity( $max, $limit, $page, $filter ) { 205 205 global $wpdb, $bp; 206 206 207 207 if ( $limit && $page ) 208 208 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 209 209 210 210 if ( $max ) 211 211 $max_sql = $wpdb->prepare( "LIMIT %d", $max ); 212 212 213 213 /* Sort out filtering */ 214 214 if ( $filter ) … … 224 224 return array( 'activities' => $activities, 'total' => (int)$total_activities ); 225 225 } 226 226 227 227 function get_recorded_component_names() { 228 228 global $wpdb, $bp; 229 229 230 230 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component_name FROM {$bp->activity->table_name} ORDER BY component_name ASC" ) ); 231 231 } 232 232 233 233 function get_sitewide_items_for_feed( $limit = 35 ) { 234 234 global $wpdb, $bp; 235 235 236 236 $activities = bp_activity_get_sitewide_activity( $limit ); 237 237 for ( $i = 0; $i < count($activities); $i++ ) { … … 244 244 } 245 245 246 return $activity_feed; 247 } 248 246 return $activity_feed; 247 } 248 249 249 function get_filter_sql( $filter_array ) { 250 250 global $wpdb; 251 251 252 252 if ( !empty( $filter_array['object'] ) ) { 253 253 $object_filter = explode( ',', $filter_array['object'] ); 254 254 $object_sql = ' AND ( '; 255 255 256 256 $counter = 1; 257 257 foreach( (array) $object_filter as $object ) { 258 258 $object_sql .= $wpdb->prepare( "component_name = %s", trim( $object ) ); 259 259 260 260 if ( $counter != count( $object_filter ) ) 261 261 $object_sql .= ' || '; 262 262 263 263 $counter++; 264 264 } 265 265 266 266 $object_sql .= ' )'; 267 267 } … … 270 270 $action_filter = explode( ',', $filter_array['action'] ); 271 271 $action_sql = ' AND ( '; 272 272 273 273 $counter = 1; 274 274 foreach( (array) $action_filter as $action ) { 275 275 $action_sql .= $wpdb->prepare( "component_action = %s", trim( $action ) ); 276 276 277 277 if ( $counter != count( $action_filter ) ) 278 278 $action_sql .= ' || '; 279 279 280 280 $counter++; 281 281 } 282 282 283 283 $action_sql .= ' )'; 284 284 } … … 287 287 $pid_filter = explode( ',', $filter_array['primary_id'] ); 288 288 $pid_sql = ' AND ( '; 289 289 290 290 $counter = 1; 291 291 foreach( (array) $pid_filter as $pid ) { 292 292 $pid_sql .= $wpdb->prepare( "item_id = %s", trim( $pid ) ); 293 293 294 294 if ( $counter != count( $pid_filter ) ) 295 295 $pid_sql .= ' || '; 296 296 297 297 $counter++; 298 298 } 299 299 300 300 $pid_sql .= ' )'; 301 301 } … … 304 304 $sid_filter = explode( ',', $filter_array['secondary_id'] ); 305 305 $sid_sql = ' AND ( '; 306 306 307 307 $counter = 1; 308 308 foreach( (array) $sid_filter as $sid ) { 309 309 $sid_sql .= $wpdb->prepare( "secondary_item_id = %s", trim( $sid ) ); 310 310 311 311 if ( $counter != count( $sid_filter ) ) 312 312 $sid_sql .= ' || '; 313 313 314 314 $counter++; 315 315 } 316 316 317 317 $sid_sql .= ' )'; 318 318 } 319 319 320 320 return $object_sql . $action_sql . $pid_sql . $sid_sql; 321 321 } 322 322 323 323 function get_last_updated() { 324 324 global $bp, $wpdb; 325 325 326 326 return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) ); 327 327 } 328 328 329 329 function check_exists_by_content( $content ) { 330 330 global $wpdb, $bp; -
trunk/bp-activity/bp-activity-filters.php
r2055 r2077 15 15 function bp_activity_filter_kses( $content ) { 16 16 global $allowedtags; 17 17 18 18 $activity_allowedtags = $allowedtags; 19 19 $activity_allowedtags['span'] = array(); 20 20 $activity_allowedtags['span']['class'] = array(); 21 21 $activity_allowedtags['a']['class'] = array(); 22 $activity_allowedtags['img'] = array(); 22 $activity_allowedtags['img'] = array(); 23 23 $activity_allowedtags['img']['src'] = array(); 24 24 $activity_allowedtags['img']['alt'] = array(); -
trunk/bp-activity/bp-activity-templatetags.php
r2071 r2077 8 8 var $activity; 9 9 var $activity_type; 10 10 11 11 var $in_the_loop; 12 12 13 13 var $pag_page; 14 14 var $pag_num; … … 26 26 if ( $type == 'sitewide' ) 27 27 $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter ); 28 28 29 29 if ( $type == 'personal' ) 30 30 $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter ); … … 32 32 if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) ) 33 33 $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter ); 34 34 35 35 if ( !$max || $max >= (int)$this->activities['total'] ) 36 36 $this->total_activity_count = (int)$this->activities['total']; 37 37 else 38 38 $this->total_activity_count = (int)$max; 39 39 40 40 $this->activities = $this->activities['activities']; 41 41 42 42 if ( $max ) { 43 43 if ( $max >= count($this->activities) ) … … 48 48 $this->activity_count = count($this->activities); 49 49 } 50 50 51 51 $this->full_name = $bp->displayed_user->fullname; 52 52 … … 63 63 } 64 64 } 65 65 66 66 function has_activities() { 67 67 if ( $this->activity_count ) 68 68 return true; 69 69 70 70 return false; 71 71 } 72 72 73 73 function next_activity() { 74 74 $this->current_activity++; 75 75 $this->activity = $this->activities[$this->current_activity]; 76 76 77 77 return $this->activity; 78 78 } 79 79 80 80 function rewind_activities() { 81 81 $this->current_activity = -1; … … 84 84 } 85 85 } 86 87 function user_activities() { 86 87 function user_activities() { 88 88 if ( $this->current_activity + 1 < $this->activity_count ) { 89 89 return true; … … 97 97 return false; 98 98 } 99 99 100 100 function the_activity() { 101 101 global $activity; … … 103 103 $this->in_the_loop = true; 104 104 $this->activity = $this->next_activity(); 105 105 106 106 if ( is_array( $this->activity ) ) 107 107 $this->activity = (object) $this->activity; … … 114 114 function bp_has_activities( $args = '' ) { 115 115 global $bp, $activities_template; 116 116 117 117 /* Note: any params used for filtering can be a single value, or multiple values comma separated. */ 118 118 119 119 $defaults = array( 120 120 'type' => 'sitewide', … … 138 138 $per_page = $max; 139 139 } 140 140 141 141 if ( isset( $_GET['afilter'] ) ) 142 142 $filter = array( 'object' => $_GET['afilter'] ); 143 143 else 144 144 $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id ); 145 146 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter ); 145 146 $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter ); 147 147 return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template ); 148 148 } … … 160 160 function bp_activity_pagination_count() { 161 161 global $bp, $activities_template; 162 162 163 163 $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1; 164 164 $to_num = ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1) ; … … 173 173 function bp_get_activity_pagination_links() { 174 174 global $activities_template; 175 175 176 176 return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links ); 177 177 } … … 179 179 function bp_activities_title() { 180 180 global $bp_activity_title; 181 181 182 182 echo bp_get_activities_title(); 183 183 } … … 190 190 function bp_activities_no_activity() { 191 191 global $bp_activity_no_activity; 192 192 193 193 echo bp_get_activities_no_activity(); 194 194 } 195 195 function bp_get_activities_no_activity() { 196 196 global $bp_activity_no_activity; 197 197 198 198 return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity ); 199 199 } … … 218 218 'height' => 20, 219 219 'class' => 'avatar', 220 'alt' => __( 'Avatar', 'buddypress' ) 220 'alt' => __( 'Avatar', 'buddypress' ) 221 221 ); 222 222 223 223 $r = wp_parse_args( $args, $defaults ); 224 224 extract( $r, EXTR_SKIP ); 225 225 226 226 $item_id = false; 227 227 if ( (int)$activities_template->activity->user_id ) … … 235 235 if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id ) 236 236 $object = 'blog'; 237 237 238 238 $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object ); 239 239 240 240 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 ) ) ); 241 241 } … … 248 248 249 249 if ( bp_is_home() && $activities_template->activity_type == 'personal' ) 250 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ); 250 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name ); 251 251 else 252 252 $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false ); … … 254 254 /* Add 'the_content' filter to activity to allow existing plugins to replace text as they would on post text. (extra smilies etc) */ 255 255 $content = apply_filters( 'the_content', $content ); 256 256 257 257 return apply_filters( 'bp_get_activity_content', $content ); 258 258 } … … 260 260 function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) { 261 261 global $activities_template, $bp; 262 262 263 263 if ( !$content ) 264 264 return false; 265 265 266 266 /* Split the content so we don't evaluate and replace text on content we don't want to */ 267 267 $content = explode( '%s', $content ); … … 273 273 if ( $insert_time ) 274 274 $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded ); 275 275 276 276 // The "You" and "Your" conversion is only done in english, if a translation file is present 277 277 // then do not translate as it causes problems in other languages. … … 284 284 /* Remove the 'You' and replace if with the persons name */ 285 285 if ( $filter_you && $full_name != '' ) { 286 $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 ); 286 $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 ); 287 287 } 288 288 } … … 290 290 /* Add the delete link if the user has permission on this item */ 291 291 if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() ) 292 $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 293 292 $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 293 294 294 $content_new = ''; 295 295 296 296 for ( $i = 0; $i < count($content); $i++ ) 297 297 $content_new .= $content[$i]; 298 298 299 299 return apply_filters( 'bp_activity_content_filter', $content_new ); 300 300 } … … 306 306 // Make sure we don't have any URL encoding in links when trying to insert the time. 307 307 $content = urldecode($content); 308 308 309 309 return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( ' %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) ); 310 310 } … … 315 315 function bp_get_activity_css_class() { 316 316 global $activities_template; 317 317 318 318 return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name ); 319 319 } … … 333 333 function bp_get_activity_filter_links( $args = false ) { 334 334 global $activities_template, $bp; 335 335 336 336 $defaults = array( 337 337 'style' => 'list' … … 340 340 $r = wp_parse_args( $args, $defaults ); 341 341 extract( $r, EXTR_SKIP ); 342 342 343 343 /* Fetch the names of components that have activity recorded in the DB */ 344 344 $component_names = BP_Activity_Activity::get_recorded_component_names(); 345 345 346 346 if ( !$component_names ) 347 347 return false; 348 348 349 349 foreach ( (array) $component_names as $component_name ) { 350 350 if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] ) … … 352 352 else 353 353 unset($selected); 354 354 355 $component_name = attribute_escape( $component_name ); 356 355 357 $component_name = attribute_escape( $component_name ); 356 358 … … 372 374 break; 373 375 } 374 376 375 377 $link = add_query_arg( 'afilter', $component_name ); 376 378 $link = remove_query_arg( 'acpage' , $link ); 377 379 378 380 $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name ); 379 381 380 382 /* Make sure all core internal component names are translatable */ 381 383 $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 382 384 383 385 $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after; 384 386 } … … 388 390 if ( isset( $_GET['afilter'] ) ) 389 391 $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>'; 390 391 392 393 return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) ); 392 394 } 393 395 … … 410 412 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' ); 411 413 else 412 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ); 414 return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' ); 413 415 } 414 416 … … 421 423 global $activities_template; 422 424 423 return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) ); 425 return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) ); 424 426 } 425 427 … … 453 455 454 456 function bp_activity_feed_item_description() { 455 echo bp_get_activity_feed_item_description(); 457 echo bp_get_activity_feed_item_description(); 456 458 } 457 459 function bp_get_activity_feed_item_description() { 458 460 global $activities_template; 459 461 460 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) ); 462 return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) ); 461 463 } 462 464 -
trunk/bp-activity/bp-activity-widgets.php
r1926 r2077 14 14 function widget($args, $instance) { 15 15 global $bp; 16 16 17 17 extract( $args ); 18 18 19 19 echo $before_widget; 20 20 echo $before_title 21 . $widget_name . 22 ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>' 21 . $widget_name . 22 ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>' 23 23 . $after_title; ?> 24 24 25 25 <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?> 26 26 … … 30 30 <?php bp_activity_pagination_count() ?> 31 31 </div> 32 32 33 33 <div class="pagination-links" id="activity-pag"> 34 34 <?php bp_activity_pagination_links() ?> 35 35 </div> 36 36 </div> 37 37 38 38 <ul id="activity-filter-links"> 39 39 <?php bp_activity_filter_links() ?> 40 40 </ul> 41 41 <?php endif; ?> 42 42 43 43 <ul id="site-wide-stream" class="activity-list"> 44 44 <?php while ( bp_activities() ) : bp_the_activity(); ?> … … 49 49 </div> 50 50 <?php endif; ?> 51 51 52 52 <?php bp_activity_content() ?> 53 53 </li> … … 61 61 </div> 62 62 <?php endif;?> 63 63 64 64 <?php echo $after_widget; ?> 65 65 <?php -
trunk/bp-activity/deprecated/bp-activity-deprecated.php
r1909 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 25 25 function bp_activity_deprecated_globals() { 26 26 global $bp; 27 27 28 28 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 29 29 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 32 32 $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images'; 33 33 } 34 add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 ); 34 add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 ); 35 35 add_action( 'admin_menu', 'bp_activity_deprecated_globals', 2 ); 36 36 … … 38 38 function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false, $recorded_time = false ) { 39 39 global $bp, $wpdb; 40 40 41 41 if ( !$user_id ) 42 42 $user_id = $bp->loggedin_user->id; … … 44 44 if ( !$recorded_time ) 45 45 $recorded_time = time(); 46 46 47 47 $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' ); 48 48 bp_activity_add( $args ); 49 49 50 50 if ( $secondary_user_id ) { 51 51 $hide_sitewide = true; … … 53 53 bp_activity_add( $args ); 54 54 } 55 55 56 56 do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id ); 57 57 58 58 return true; 59 59 } 60 60 61 61 /* DEPRECATED - use bp_activity_delete_by_item_id() */ 62 function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) { 62 function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) { 63 63 if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) ) 64 64 return false; 65 65 66 66 do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); 67 67 68 68 return true; 69 69 } … … 72 72 function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) { 73 73 global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity; 74 74 75 75 $bp_activity_user_id = $user_id; 76 76 $bp_activity_limit = $limit; 77 77 $bp_activity_title = $title; 78 78 $bp_activity_no_activity = $no_activity; 79 79 80 80 locate_template( array( '/activity/activity-list.php' ), true ); 81 81 } … … 87 87 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 88 88 return $template; 89 89 90 90 /* Enqueue the structure CSS file to give basic positional formatting for components */ 91 wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' ); 91 wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' ); 92 92 } 93 93 add_action( 'bp_styles', 'bp_activity_add_structure_css' ); -
trunk/bp-blogs.php
r2055 r2077 13 13 /* Include deprecated functions if settings allow */ 14 14 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 15 require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 16 15 require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 16 17 17 function bp_blogs_install() { 18 18 global $wpdb, $bp; 19 19 20 20 if ( !empty($wpdb->charset) ) 21 21 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 22 22 23 23 $sql[] = "CREATE TABLE {$bp->blogs->table_name} ( 24 24 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 52 52 KEY comment_post_id (comment_post_id) 53 53 ) {$charset_collate};"; 54 54 55 55 $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} ( 56 56 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 61 61 KEY meta_key (meta_key) 62 62 ) {$charset_collate};"; 63 64 63 64 65 65 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 66 66 … … 69 69 // On first installation - record all existing blogs in the system. 70 70 if ( !(int)get_site_option( 'bp-blogs-first-install') ) { 71 71 72 72 bp_blogs_record_existing_blogs(); 73 73 add_site_option( 'bp-blogs-first-install', 1 ); 74 74 75 75 } else { 76 77 // Import blog titles and descriptions into the blogmeta table 76 77 // Import blog titles and descriptions into the blogmeta table 78 78 if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) { 79 79 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) ); … … 82 82 $name = get_blog_option( $blog_ids[$i], 'blogname' ); 83 83 $desc = get_blog_option( $blog_ids[$i], 'blogdescription' ); 84 84 85 85 bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name ); 86 86 bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc ); … … 88 88 } 89 89 } 90 91 } 92 90 91 } 92 93 93 update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION ); 94 94 } 95 95 96 function bp_blogs_check_installed() { 96 function bp_blogs_check_installed() { 97 97 global $wpdb, $bp, $userdata; 98 98 99 99 if ( is_site_admin() ) { 100 100 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ … … 107 107 function bp_blogs_setup_globals() { 108 108 global $bp, $wpdb; 109 109 110 110 /* For internal identification */ 111 111 $bp->blogs->id = 'blogs'; 112 112 113 113 $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs'; 114 114 $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts'; … … 117 117 $bp->blogs->format_notification_function = 'bp_blogs_format_notifications'; 118 118 $bp->blogs->slug = BP_BLOGS_SLUG; 119 119 120 120 /* Register this in the active components array */ 121 121 $bp->active_components[$bp->blogs->slug] = $bp->blogs->id; … … 123 123 do_action( 'bp_blogs_setup_globals' ); 124 124 } 125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 ); 125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 ); 126 126 add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 ); 127 127 … … 136 136 * 137 137 * Adds "Blog" to the navigation arrays for the current and logged in user. 138 * 138 * 139 139 * @package BuddyPress Blogs 140 140 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 143 143 function bp_blogs_setup_nav() { 144 144 global $bp; 145 145 146 146 /* Add 'Blogs' to the main navigation */ 147 147 bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) ); 148 148 149 149 $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/'; 150 150 151 151 /* Add the subnav items to the blogs nav item */ 152 152 bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) ); … … 159 159 if ( bp_is_home() ) { 160 160 if ( function_exists('xprofile_setup_nav') ) { 161 $bp->bp_options_title = __('My Blogs', 'buddypress'); 161 $bp->bp_options_title = __('My Blogs', 'buddypress'); 162 162 } 163 163 } else { 164 164 /* If we are not viewing the logged in user, set up the current users avatar and name */ 165 165 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 166 $bp->bp_options_title = $bp->displayed_user->fullname; 166 $bp->bp_options_title = $bp->displayed_user->fullname; 167 167 } 168 168 } 169 169 170 170 do_action( 'bp_blogs_setup_nav' ); 171 171 } … … 178 178 if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) { 179 179 $bp->is_directory = true; 180 180 181 181 do_action( 'bp_blogs_directory_blogs_setup' ); 182 182 bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) ); … … 196 196 function bp_blogs_screen_my_blogs() { 197 197 do_action( 'bp_blogs_screen_my_blogs' ); 198 bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) ); 198 bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) ); 199 199 } 200 200 … … 224 224 function bp_blogs_register_activity_actions() { 225 225 global $bp; 226 226 227 227 if ( !function_exists( 'bp_activity_set_action' ) ) 228 228 return false; … … 238 238 function bp_blogs_record_activity( $args = '' ) { 239 239 global $bp; 240 240 241 241 if ( !function_exists( 'bp_activity_add' ) ) 242 242 return false; 243 243 244 244 /* Because blog, comment, and blog post code execution happens before anything else 245 245 we may need to manually instantiate the activity component globals */ 246 246 if ( !$bp->activity && function_exists('bp_activity_setup_globals') ) 247 247 bp_activity_setup_globals(); 248 248 249 249 $defaults = array( 250 250 'user_id' => $bp->loggedin_user->id, … … 260 260 261 261 $r = wp_parse_args( $args, $defaults ); 262 extract( $r, EXTR_SKIP ); 263 262 extract( $r, EXTR_SKIP ); 263 264 264 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 265 265 } … … 268 268 if ( function_exists('bp_activity_delete_by_item_id') ) { 269 269 extract($args); 270 271 bp_activity_delete_by_item_id( array( 272 'item_id' => $item_id, 270 271 bp_activity_delete_by_item_id( array( 272 'item_id' => $item_id, 273 273 'component_name' => $component_name, 274 'component_action' => $component_action, 274 'component_action' => $component_action, 275 275 'user_id' => $user_id, 276 276 'secondary_item_id' => $secondary_item_id … … 292 292 293 293 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) ); 294 294 295 295 if ( $blog_ids ) { 296 296 foreach( $blog_ids as $blog_id ) { … … 311 311 function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) { 312 312 global $bp; 313 313 314 314 if ( !$user_id ) 315 315 $user_id = $bp->loggedin_user->id; 316 316 317 317 $name = get_blog_option( $blog_id, 'blogname' ); 318 318 $description = get_blog_option( $blog_id, 'blogdescription' ); 319 319 320 320 $recorded_blog = new BP_Blogs_Blog; 321 321 $recorded_blog->user_id = $user_id; … … 323 323 324 324 $recorded_blog_id = $recorded_blog->save(); 325 325 326 326 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name ); 327 327 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description ); 328 328 bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() ); 329 329 330 330 /* Only record this activity if the blog is public */ 331 331 if ( (int)$_POST['blog_public'] || !$no_activity ) { … … 333 333 bp_blogs_record_activity( array( 334 334 'user_id' => $recorded_blog->user_id, 335 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %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 ), 335 'content' => apply_filters( 'bp_blogs_activity_created_blog', sprintf( __( '%s created the blog %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 ), 336 336 'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ), 337 337 'component_action' => 'new_blog', … … 339 339 ) ); 340 340 } 341 341 342 342 do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded ); 343 343 } … … 346 346 function bp_blogs_record_post( $post_id, $post, $user_id = false ) { 347 347 global $bp, $wpdb; 348 348 349 349 $post_id = (int)$post_id; 350 350 $blog_id = (int)$wpdb->blogid; 351 351 352 352 if ( !$user_id ) 353 353 $user_id = (int)$post->post_author; 354 355 354 /* This is to stop infinate loops with Donncha's sitewide tags plugin */ 356 355 if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id ) 357 356 return false; 358 357 359 358 /* Don't record this if it's not a post */ 360 359 if ( $post->post_type != 'post' ) 361 360 return false; 362 361 363 362 if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) { 364 363 if ( 'publish' == $post->post_status && '' == $post->post_password ) { 365 364 366 365 $recorded_post = new BP_Blogs_Post; 367 366 $recorded_post->user_id = $user_id; … … 369 368 $recorded_post->post_id = $post_id; 370 369 $recorded_post->date_created = strtotime( $post->post_date ); 371 370 372 371 $recorded_post_id = $recorded_post->save(); 373 372 374 373 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() ); 375 374 … … 380 379 $activity_content = 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>' ); 381 380 $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>"; 382 381 383 382 bp_blogs_record_activity( array( 384 383 'user_id' => (int)$post->post_author, 385 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 384 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 386 385 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 387 386 'component_action' => 'new_blog_post', … … 399 398 /* Delete the recorded post if the status is not published or it is password protected */ 400 399 if ( 'publish' != $post->post_status || '' != $post->post_password ) { 401 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 402 400 return bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 401 403 402 /* If the post author has changed, delete the post and re-add it. */ 404 403 } else if ( (int)$existing_post->user_id != (int)$post->post_author ) { 405 404 // Delete the existing recorded post 406 405 bp_blogs_remove_post( $post_id, $blog_id, $existing_post ); 407 406 408 407 // Re-record the post with the new author. 409 bp_blogs_record_post( $post_id ); 408 bp_blogs_record_post( $post_id ); 410 409 } 411 410 412 411 if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) { 413 /* Now re-record the post in the activity streams */ 412 /* Now re-record the post in the activity streams */ 414 413 $post_permalink = bp_post_get_permalink( $post, $blog_id ); 415 414 416 415 $activity_content = 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>' ); 417 416 $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>"; 418 417 419 418 /* Record this in activity streams */ 420 419 bp_blogs_record_activity( array( 421 420 'user_id' => (int)$post->post_author, 422 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 421 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 423 422 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 424 423 'component_action' => 'new_blog_post', … … 435 434 function bp_blogs_record_comment( $comment_id, $is_approved ) { 436 435 global $wpdb, $bp; 437 436 438 437 if ( !$is_approved ) 439 438 return false; 440 439 441 440 $comment = get_comment($comment_id); 442 441 $comment->post = get_post( $comment->comment_post_ID ); 443 442 444 443 /* Get the user_id from the author email. */ 445 444 $user = get_user_by_email( $comment->comment_author_email ); 446 445 $user_id = (int)$user->ID; 447 446 448 447 if ( !$user_id ) 449 448 return false; … … 457 456 458 457 $recorded_commment_id = $recorded_comment->save(); 459 458 460 459 bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() ); 461 460 … … 463 462 /* Record in activity streams */ 464 463 $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id ); 465 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 464 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 466 465 $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>'; 467 466 … … 469 468 bp_blogs_record_activity( array( 470 469 'user_id' => $recorded_comment->user_id, 471 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 470 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 472 471 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ), 473 472 'component_action' => 'new_blog_comment', … … 484 483 function bp_blogs_approve_comment( $comment_id, $comment_status ) { 485 484 global $bp, $wpdb; 486 485 487 486 if ( 'approve' != $comment_status ) 488 487 return false; … … 491 490 $comment = get_comment($comment_id); 492 491 $comment->post = get_post( $comment->comment_post_ID ); 493 492 494 493 bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) ); 495 494 … … 497 496 /* Record in activity streams */ 498 497 $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id ); 499 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 498 $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' ); 500 499 $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>'; 501 500 … … 503 502 bp_blogs_record_activity( array( 504 503 'user_id' => $recorded_comment->user_id, 505 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 504 'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 506 505 'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ), 507 506 'component_action' => 'new_blog_comment', 508 507 'item_id' => $comment_id, 509 508 'secondary_item_id' => $recorded_comment->blog_id, 510 'recorded_time' => $recorded_comment->date_created 509 'recorded_time' => $recorded_comment->date_created 511 510 ) ); 512 511 } … … 516 515 function bp_blogs_unapprove_comment( $comment_id, $comment_status ) { 517 516 if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status ) 518 bp_blogs_remove_comment( $comment_id ); 517 bp_blogs_remove_comment( $comment_id ); 519 518 } 520 519 add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 ); … … 538 537 539 538 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 540 539 541 540 // Delete activity stream item 542 541 bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) ); 543 542 544 543 do_action( 'bp_blogs_remove_blog', $blog_id ); 545 544 } … … 548 547 function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) { 549 548 global $current_user; 550 549 551 550 $blog_id = (int)$blog_id; 552 551 $user_id = (int)$user_id; … … 565 564 566 565 $post_id = (int)$post_id; 567 566 568 567 if ( !$blog_id ) 569 568 $blog_id = (int)$current_blog->blog_id; 570 569 571 570 if ( !$existing_post ) 572 571 $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id ); … … 574 573 // Delete post from the bp_blogs table 575 574 BP_Blogs_Post::delete( $post_id, $blog_id ); 576 575 577 576 // Delete activity stream item 578 577 bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) ); … … 586 585 587 586 $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id ); 588 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 587 BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 589 588 590 589 // Delete activity stream item … … 597 596 function bp_blogs_remove_data_for_blog( $blog_id ) { 598 597 global $bp; 599 598 600 599 /* If this is regular blog, delete all data for that blog. */ 601 600 BP_Blogs_Blog::delete_blog_for_all( $blog_id ); 602 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 601 BP_Blogs_Post::delete_posts_for_blog( $blog_id ); 603 602 BP_Blogs_Comment::delete_comments_for_blog( $blog_id ); 604 603 … … 624 623 function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) { 625 624 global $bp; 626 625 627 626 if ( !is_numeric( $limit ) ) 628 627 $limit = 5; 629 628 630 629 return BP_Blogs_Post::get_latest_posts( $blog_id, $limit ); 631 630 } … … 645 644 function bp_blogs_total_post_count( $blog_id ) { 646 645 return BP_Blogs_Post::total_post_count( $blog_id ); 647 } 646 } 648 647 649 648 function bp_blogs_total_comment_count( $blog_id, $post_id = false ) { 650 649 return BP_Blogs_Post::total_comment_count( $blog_id, $post_id ); 651 } 650 } 652 651 653 652 function bp_blogs_is_blog_hidden( $blog_id ) { … … 657 656 function bp_blogs_redirect_to_random_blog() { 658 657 global $bp, $wpdb; 659 658 660 659 if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) { 661 660 $blog = bp_blogs_get_random_blog(); … … 676 675 function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) { 677 676 global $wpdb, $bp; 678 677 679 678 if ( !is_numeric( $blog_id ) ) 680 679 return false; 681 680 682 681 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 683 682 684 683 if ( is_array($meta_value) || is_object($meta_value) ) 685 684 $meta_value = serialize($meta_value); 686 685 687 686 $meta_value = trim( $meta_value ); 688 687 689 688 if ( !$meta_key ) { 690 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) ); 689 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) ); 691 690 } else if ( $meta_value ) { 692 691 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) ); … … 694 693 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 695 694 } 696 695 697 696 // TODO need to look into using this. 698 697 // wp_cache_delete($group_id, 'groups'); … … 703 702 function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') { 704 703 global $wpdb, $bp; 705 704 706 705 $blog_id = (int) $blog_id; 707 706 … … 711 710 if ( !empty($meta_key) ) { 712 711 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 713 712 714 713 // TODO need to look into using this. 715 714 //$user = wp_cache_get($user_id, 'users'); 716 715 717 716 // Check the cached user object 718 717 //if ( false !== $user && isset($user->$meta_key) ) … … 741 740 function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) { 742 741 global $wpdb, $bp; 743 742 744 743 if ( !is_numeric( $blog_id ) ) 745 744 return false; 746 745 747 746 $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key ); 748 747 749 748 if ( is_string($meta_value) ) 750 749 $meta_value = stripslashes($wpdb->escape($meta_value)); 751 750 752 751 $meta_value = maybe_serialize($meta_value); 753 752 … … 757 756 758 757 $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) ); 759 758 760 759 if ( !$cur ) { 761 760 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) ); … … 775 774 /* If this is regular blog, delete all data for that blog. */ 776 775 BP_Blogs_Blog::delete_blogs_for_user( $user_id ); 777 BP_Blogs_Post::delete_posts_for_user( $user_id ); 776 BP_Blogs_Post::delete_posts_for_user( $user_id ); 778 777 BP_Blogs_Comment::delete_comments_for_user( $user_id ); 779 778 -
trunk/bp-core.php
r2059 r2077 4 4 define( 'BP_CORE_DB_VERSION', '1800' ); 5 5 6 /*** 7 * Define the path and url of the BuddyPress plugins directory. 8 * It is important to use plugins_url() core function to obtain 9 * the correct scheme used (http or https). 6 /*** 7 * Define the path and url of the BuddyPress plugins directory. 8 * It is important to use plugins_url() core function to obtain 9 * the correct scheme used (http or https). 10 10 */ 11 11 define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' ); … … 66 66 if ( !defined( 'BP_HOME_BLOG_SLUG' ) ) 67 67 define( 'BP_HOME_BLOG_SLUG', 'blog' ); 68 68 69 /* Register BuddyPress themes contained within the theme folder */ 70 if ( function_exists( 'register_theme_folder' ) ) 71 register_theme_folder( 'buddypress/bp-themes' ); 72 69 73 /* Register BuddyPress themes contained within the theme folder */ 70 74 if ( function_exists( 'register_theme_folder' ) ) … … 94 98 global $displayed_user_id; 95 99 global $action_variables; 96 100 97 101 $current_user = wp_get_current_user(); 98 102 99 /* The domain for the root of the site where the main blog resides */ 103 /* The domain for the root of the site where the main blog resides */ 100 104 $bp->root_domain = bp_core_get_root_domain(); 101 105 102 106 /* The user ID of the user who is currently logged in. */ 103 107 $bp->loggedin_user->id = $current_user->ID; … … 105 109 /* The domain for the user currently logged in. eg: http://domain.com/members/andy */ 106 110 $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID); 107 111 108 112 /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */ 109 113 $bp->displayed_user->id = $displayed_user_id; 110 114 111 115 /* The domain for the user currently being displayed */ 112 116 $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id); 113 117 114 118 /* The component being used eg: http://domain.com/members/andy/ [profile] */ 115 119 $bp->current_component = $current_component; // type: string 116 120 117 121 /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */ 118 122 $bp->current_action = $current_action; // type: string 119 123 120 124 /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */ 121 125 $bp->action_variables = $action_variables; // type: array 122 126 123 127 /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/ 124 128 $bp->current_item = ''; // type: string … … 135 139 /* Sets up the array container for the component navigation rendered by bp_get_nav() */ 136 140 $bp->bp_nav = array(); 137 141 138 142 /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */ 139 143 $bp->bp_options_nav = array(); 140 144 141 145 /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */ 142 146 $bp->bp_options_title = ''; 143 147 144 148 /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */ 145 149 $bp->bp_options_avatar = ''; 146 150 147 151 /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */ 148 152 $bp->active_components = array(); 149 153 150 154 /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */ 151 155 $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', get_site_option( 'user-avatar-default' ) ); 152 156 $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' ); 153 157 $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' ); 154 158 155 159 /* Fetch the full name for the logged in and current user */ 156 160 $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id ); … … 162 166 'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */ 163 167 $bp->is_item_admin = bp_is_home(); 164 168 165 169 /* Used to determine if the logged in user is a moderator for the current content. */ 166 170 $bp->is_item_mod = false; … … 170 174 if ( !$bp->current_component ) 171 175 $bp->current_component = $bp->default_component; 172 176 173 177 do_action( 'bp_core_setup_globals' ); 174 178 } … … 183 187 * 184 188 * For example: http://example.org/search or http://example.org/members 185 * 189 * 186 190 * @package BuddyPress Core 187 191 * @uses bp_core_add_root_component() Adds a slug to the root components global variable. … … 202 206 * 203 207 * Installs the core DB tables for BuddyPress. 204 * 208 * 205 209 * @package BuddyPress Core 206 210 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 211 215 function bp_core_install() { 212 216 global $wpdb, $bp; 213 217 214 218 if ( !empty($wpdb->charset) ) 215 219 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 216 220 217 221 $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} ( 218 222 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 235 239 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 236 240 dbDelta( $sql ); 237 241 238 242 /* Add names of root components to the banned blog list to avoid conflicts */ 239 243 bp_core_add_illegal_names(); 240 244 241 245 update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION ); 242 246 } … … 246 250 * 247 251 * Checks to make sure the database tables are set up for the core component. 248 * 252 * 249 253 * @package BuddyPress Core 250 254 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 260 264 if ( !is_site_admin() ) 261 265 return false; 262 266 263 267 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' ); 264 268 … … 273 277 * 274 278 * Adds the "BuddyPress" admin submenu item to the Site Admin tab. 275 * 279 * 276 280 * @package BuddyPress Core 277 281 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 281 285 */ 282 286 function bp_core_add_admin_menu() { 283 global $wpdb, $bp, $menu;284 285 287 if ( !is_site_admin() ) 286 288 return false; 287 289 288 290 /* Add the administration tab under the "Site Admin" tab for site administrators */ 289 291 bp_core_add_admin_menu_page( array( … … 294 296 'position' => 2 295 297 ) ); 296 298 297 299 add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' ); 298 300 add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' ); … … 305 307 * Checks to see if a component's URL should be in the root, not under a member page: 306 308 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group 307 * 309 * 308 310 * @package BuddyPress Core 309 311 * @return true if root component, else false. … … 319 321 * 320 322 * Sets up the profile navigation item if the Xprofile component is not installed. 321 * 323 * 322 324 * @package BuddyPress Core 323 325 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 329 331 function bp_core_setup_nav() { 330 332 global $bp; 331 332 /*** 333 334 /*** 333 335 * If the extended profiles component is disabled, we need to revert to using the 334 336 * built in WordPress profile information … … 340 342 341 343 /* Add 'Profile' to the main navigation */ 342 bp_core_new_nav_item( array( 344 bp_core_new_nav_item( array( 343 345 'name' => __('Profile', 'buddypress'), 344 346 'slug' => $bp->core->profile->slug, … … 349 351 350 352 $profile_link = $bp->loggedin_user->domain . '/profile/'; 351 353 352 354 /* Add the subnav items to the profile */ 353 355 bp_core_new_subnav_item( array( … … 358 360 'screen_function' => 'bp_core_catch_profile_uri' 359 361 ) ); 360 362 361 363 362 364 if ( 'profile' == $bp->current_component ) { … … 365 367 } else { 366 368 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 367 $bp->bp_options_title = $bp->displayed_user->fullname; 369 $bp->bp_options_title = $bp->displayed_user->fullname; 368 370 } 369 371 } 370 } 372 } 371 373 } 372 374 add_action( 'plugins_loaded', 'bp_core_setup_nav' ); … … 397 399 * Listens to the $bp component and action variables to determine if the user is viewing the members 398 400 * directory page. If they are, it will set up the directory and load the members directory template. 399 * 401 * 400 402 * @package BuddyPress Core 401 403 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 421 423 * this action will fire and mark or unmark the user and their blogs as spam. 422 424 * Must be a site admin for this function to run. 423 * 425 * 424 426 * @package BuddyPress Core 425 427 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 427 429 function bp_core_action_set_spammer_status() { 428 430 global $bp; 429 431 430 432 if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id ) 431 433 return false; 432 434 433 435 if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) { 434 436 /* Check the nonce */ … … 437 439 /* Get the functions file */ 438 440 require( ABSPATH . 'wp-admin/includes/mu.php' ); 439 441 440 442 if ( 'mark-spammer' == $bp->current_action ) 441 443 $is_spam = 1; … … 445 447 /* Get the blogs for the user */ 446 448 $blogs = get_blogs_of_user( $bp->displayed_user->id, true ); 447 449 448 450 foreach ( (array) $blogs as $key => $details ) { 449 451 /* Do not mark the main or current root blog as spam */ 450 if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 451 continue; 452 452 if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 453 continue; 454 453 455 /* Update the blog status */ 454 456 update_blog_status( $details->userblog_id, 'spam', $is_spam ); 455 457 456 458 /* Fire the standard WPMU hook */ 457 459 do_action( 'make_spam_blog', $details->userblog_id ); 458 460 } 459 461 460 462 /* Finally, mark this user as a spammer */ 461 463 update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 ); 462 464 463 465 if ( $is_spam ) 464 466 bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) ); 465 467 else 466 468 bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) ); 467 469 468 470 do_action( 'bp_core_action_set_spammer_status' ); 469 471 470 472 bp_core_redirect( wp_get_referer() ); 471 473 } … … 477 479 * 478 480 * Allows a site admin to delete a user from the adminbar menu. 479 * 481 * 480 482 * @package BuddyPress Core 481 483 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 483 485 function bp_core_action_delete_user() { 484 486 global $bp; 485 487 486 488 if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id ) 487 489 return false; 488 490 489 491 if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) { 490 492 /* Check the nonce */ … … 492 494 493 495 $errors = false; 494 496 495 497 if ( bp_core_delete_account( $bp->displayed_user->id ) ) { 496 498 bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) ); … … 499 501 $errors = true; 500 502 } 501 503 502 504 do_action( 'bp_core_action_set_spammer_status', $errors ); 503 505 504 506 if ( $errors ) 505 507 bp_core_redirect( $bp->displayed_user->domain ); … … 525 527 * Returns the domain for the passed user: 526 528 * e.g. http://domain.com/members/andy/ 527 * 529 * 528 530 * @package BuddyPress Core 529 531 * @global $current_user WordPress global variable containing current logged in user information … … 533 535 function bp_core_get_user_domain( $user_id ) { 534 536 global $bp; 535 537 536 538 if ( !$user_id ) return; 537 539 538 540 $ud = get_userdata($user_id); 539 541 540 542 if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) ) 541 543 $username = $ud->user_login; 542 544 else 543 545 $username = $ud->user_nicename; 544 546 545 547 /* If we are using a members slug, include it. */ 546 548 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) 547 549 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' ); 548 550 else 549 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' ); 551 return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' ); 550 552 } 551 553 … … 555 557 * Returns the domain for the root blog. 556 558 * eg: http://domain.com/ OR https://domain.com 557 * 559 * 558 560 * @package BuddyPress Core 559 561 * @uses get_blog_option() WordPress function to fetch blog meta. … … 562 564 function bp_core_get_root_domain() { 563 565 global $current_blog; 564 566 565 567 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) 566 568 $domain = get_blog_option( $current_blog->blog_id, 'siteurl' ); … … 576 578 * Returns the user id for the user that is currently being displayed. 577 579 * eg: http://andy.domain.com/ or http://domain.com/andy/ 578 * 580 * 579 581 * @package BuddyPress Core 580 582 * @global $current_blog WordPress global containing information and settings for the current blog being viewed. … … 590 592 * 591 593 * Adds a navigation item to the main navigation array used in BuddyPress themes. 592 * 594 * 593 595 * @package BuddyPress Core 594 596 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 614 616 if ( empty($name) || empty($slug) ) 615 617 return false; 616 618 617 619 /* If this is for site admins only and the user is not one, don't create the subnav item */ 618 620 if ( $site_admin_only && !is_site_admin() ) 619 621 return false; 620 622 621 623 if ( empty( $item_css_id ) ) 622 624 $item_css_id = $slug; … … 637 639 if ( !$show_for_displayed_user && !bp_is_home() ) 638 640 return false; 639 641 640 642 /*** 641 643 * If we are not viewing a user, and this is a root component, don't attach the … … 660 662 * 661 663 * Modify the default subnav item to load when a top level nav item is clicked. 662 * 664 * 663 665 * @package BuddyPress Core 664 666 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 666 668 function bp_core_new_nav_default( $args = '' ) { 667 669 global $bp; 668 670 669 671 $defaults = array( 670 672 'parent_slug' => false, // Slug of the parent … … 692 694 * We can only sort nav items by their position integer at a later point in time, once all 693 695 * plugins have registered their navigation items. 694 * 696 * 695 697 * @package BuddyPress Core 696 698 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 698 700 function bp_core_sort_nav_items() { 699 701 global $bp; 700 702 701 703 if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) ) 702 704 return false; 703 705 704 706 foreach ( $bp->bp_nav as $slug => $nav_item ) { 705 707 if ( empty( $temp[$nav_item['position']]) ) … … 710 712 $nav_item['position']++; 711 713 } while ( !empty( $temp[$nav_item['position']] ) ); 712 714 713 715 $temp[$nav_item['position']] = $nav_item; 714 716 } 715 717 } 716 718 717 719 ksort( $temp ); 718 $bp->bp_nav = &$temp; 720 $bp->bp_nav = &$temp; 719 721 } 720 722 add_action( 'wp_head', 'bp_core_sort_nav_items' ); … … 724 726 * 725 727 * Removes a navigation item from the main navigation array. 726 * 728 * 727 729 * @package BuddyPress Core 728 730 * @param $slug The slug of the sub navigation item. … … 738 740 * 739 741 * Adds a navigation item to the sub navigation array used in BuddyPress themes. 740 * 742 * 741 743 * @package BuddyPress Core 742 744 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 756 758 'screen_function' => false // The name of the function to run when clicked 757 759 ); 758 760 759 761 $r = wp_parse_args( $args, $defaults ); 760 762 extract( $r, EXTR_SKIP ); … … 763 765 if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) ) 764 766 return false; 765 767 766 768 /* If this is for site admins only and the user is not one, don't create the subnav item */ 767 769 if ( $site_admin_only && !is_site_admin() ) 768 770 return false; 769 771 770 772 if ( empty( $item_css_id ) ) 771 773 $item_css_id = $slug; 772 774 773 775 $bp->bp_options_nav[$parent_slug][$slug] = array( 774 776 'name' => $name, … … 779 781 'user_has_access' => $user_has_access 780 782 ); 781 783 782 784 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 783 785 if ( !is_object( $screen_function[0] ) ) … … 793 795 if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) ) 794 796 return false; 795 797 796 798 foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) { 797 799 if ( !is_array( $subnav_items ) ) 798 800 continue; 799 801 800 802 foreach ( $subnav_items as $subnav_item ) { 801 803 if ( empty( $temp[$subnav_item['position']]) ) … … 806 808 $subnav_item['position']++; 807 809 } while ( !empty( $temp[$subnav_item['position']] ) ); 808 810 809 811 $temp[$subnav_item['position']] = $subnav_item; 810 812 } … … 821 823 * 822 824 * Removes a navigation item from the sub navigation array used in BuddyPress themes. 823 * 825 * 824 826 * @package BuddyPress Core 825 827 * @param $parent_id The id of the parent navigation item. … … 828 830 function bp_core_remove_subnav_item( $parent_id, $slug ) { 829 831 global $bp; 830 832 831 833 unset( $bp->bp_options_nav[$parent_id][$slug] ); 832 834 } … … 836 838 * 837 839 * Clear the subnav items for a specific nav item. 838 * 840 * 839 841 * @package BuddyPress Core 840 842 * @param $parent_id The id of the parent navigation item. … … 856 858 * Loads: 857 859 * wp-content/member-themes/[activated_theme]/profile/edit-profile.php 858 * 860 * 859 861 * @package BuddyPress Core 860 862 * @param $username str Username to check. … … 883 885 * http://community.domain.com/members/andy/friends 884 886 * http://domain.com/wpmu/members/andy/friends 885 * 887 * 886 888 * @package BuddyPress Core 887 889 * @param $slug str The slug of the component … … 898 900 * 899 901 * Returns the user_id for a user based on their username. 900 * 902 * 901 903 * @package BuddyPress Core 902 904 * @param $username str Username to check. … … 907 909 function bp_core_get_random_member() { 908 910 global $bp, $wpdb; 909 911 910 912 if ( isset( $_GET['random-member'] ) ) { 911 913 $user = BP_Core_User::get_random_users(1); 912 914 913 915 $ud = get_userdata( $user['users'][0]->user_id ); 914 915 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) ); 916 917 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) ); 916 918 } 917 919 } … … 922 924 * 923 925 * Returns the user_id for a user based on their username. 924 * 926 * 925 927 * @package BuddyPress Core 926 928 * @param $username str Username to check. … … 931 933 function bp_core_get_userid( $username ) { 932 934 global $wpdb; 933 935 934 936 if ( !empty( $username ) ) 935 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 937 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 936 938 } 937 939 … … 940 942 * 941 943 * Returns the username for a user based on their user id. 942 * 944 * 943 945 * @package BuddyPress Core 944 946 * @param $uid int User ID to check. … … 950 952 function bp_core_get_username( $uid ) { 951 953 global $userdata; 952 954 953 955 if ( $uid == $userdata->ID ) 954 956 $username = __( 'You', 'buddypress' ); 955 957 956 958 if ( !$ud = get_userdata($uid) ) 957 959 return false; 958 959 $username = $ud->user_login; 960 961 $username = $ud->user_login; 960 962 961 963 return apply_filters( 'bp_core_get_username', $username ); … … 966 968 * 967 969 * Returns the URL with no HTML markup for a user based on their user id. 968 * 970 * 969 971 * @package BuddyPress Core 970 972 * @param $uid int User ID to check. … … 976 978 function bp_core_get_userurl( $uid ) { 977 979 global $bp; 978 980 979 981 if ( !is_numeric($uid) ) 980 982 return false; … … 987 989 * 988 990 * Returns the email address for the user based on user ID 989 * 991 * 990 992 * @package BuddyPress Core 991 993 * @param $uid int User ID to check. … … 1005 1007 * eg: <a href="http://andy.domain.com/">Andy Peatling</a> 1006 1008 * Optional parameters will return just the name, or just the URL, or disable "You" text when 1007 * user matches the logged in user. 1009 * user matches the logged in user. 1008 1010 * 1009 1011 * [NOTES: This function needs to be cleaned up or split into separate functions] 1010 * 1012 * 1011 1013 * @package BuddyPress Core 1012 1014 * @param $uid int User ID to check. … … 1023 1025 function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) { 1024 1026 global $userdata; 1025 1027 1026 1028 $ud = get_userdata($user_id); 1027 1029 1028 1030 if ( !$ud ) 1029 1031 return false; 1030 1032 1031 if ( function_exists('bp_fetch_user_fullname') ) { 1033 if ( function_exists('bp_fetch_user_fullname') ) { 1032 1034 $display_name = bp_core_get_user_displayname( $user_id ); 1033 1035 1034 1036 if ( $with_s ) 1035 1037 $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name ); 1036 1038 1037 1039 } else { 1038 1040 $display_name = $ud->display_name; 1039 1041 } 1040 1042 1041 1043 if ( $no_anchor ) 1042 1044 return $display_name; … … 1044 1046 if ( !$url = bp_core_get_userurl($user_id) ) 1045 1047 return false; 1046 1048 1047 1049 if ( $just_link ) 1048 1050 return $url; 1049 1051 1050 return '<a href="' . $url . '">' . $display_name . '</a>'; 1052 return '<a href="' . $url . '">' . $display_name . '</a>'; 1051 1053 } 1052 1054 … … 1057 1059 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed. 1058 1060 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set. 1059 * 1061 * 1060 1062 * @package BuddyPress Core 1061 1063 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1068 1070 function bp_core_get_user_displayname( $user_id ) { 1069 1071 global $bp; 1070 1072 1071 1073 if ( !$user_id ) 1072 1074 return false; 1073 1075 1074 1076 if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) { 1075 1077 if ( function_exists('xprofile_install') ) { … … 1088 1090 } else { 1089 1091 $ud = get_userdata($user_id); 1090 1092 1091 1093 if ( !empty( $ud->display_name ) ) 1092 1094 $fullname = $ud->display_name; … … 1094 1096 $fullname = $ud->user_nicename; 1095 1097 } 1096 1098 1097 1099 wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' ); 1098 1100 } 1099 1101 1100 1102 return apply_filters( 'bp_core_get_user_displayname', $fullname ); 1101 1103 } … … 1109 1111 * 1110 1112 * Returns the user link for the user based on user email address 1111 * 1113 * 1112 1114 * @package BuddyPress Core 1113 1115 * @param $email str The email address for the user. … … 1125 1127 * 1126 1128 * Returns the user link for the user based on user's username 1127 * 1129 * 1128 1130 * @package BuddyPress Core 1129 1131 * @param $username str The username for the user. … … 1133 1135 function bp_core_get_userlink_by_username( $username ) { 1134 1136 global $wpdb; 1135 1136 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ); 1137 1138 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ); 1137 1139 return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) ); 1138 1140 } … … 1149 1151 function bp_core_is_user_spammer( $user_id ) { 1150 1152 global $wpdb; 1151 1152 return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 1153 1154 return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 1153 1155 } 1154 1156 … … 1164 1166 function bp_core_is_user_deleted( $user_id ) { 1165 1167 global $wpdb; 1166 1167 return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 1168 1169 return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 1168 1170 } 1169 1171 … … 1174 1176 if ( !$time ) 1175 1177 return false; 1176 1178 1177 1179 $date = date( "F j, Y ", $time ); 1178 1180 1179 1181 if ( !$just_date ) { 1180 1182 $date .= __('at', 'buddypress') . date( ' g:iA', $time ); 1181 1183 } 1182 1184 1183 1185 return $date; 1184 1186 } … … 1189 1191 * 1190 1192 * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads. 1191 * 1193 * 1192 1194 * @package BuddyPress Core 1193 1195 */ 1194 1196 function bp_core_add_message( $message, $type = false ) { 1195 1197 global $bp; 1196 1198 1197 1199 if ( !$type ) 1198 1200 $type = 'success'; 1199 1201 1200 1202 /* Send the values to the cookie for page reload display */ 1201 1203 @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH ); 1202 1204 @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH ); 1203 1205 1204 1206 /*** 1205 1207 * Send the values to the $bp global so we can still output messages … … 1218 1220 * After the message is displayed, it removes the message vars from the cookie so that the message 1219 1221 * is not shown to the user multiple times. 1220 * 1222 * 1221 1223 * @package BuddyPress Core 1222 1224 * @global $bp_message The message text … … 1229 1231 if ( empty( $bp->template_message ) ) 1230 1232 $bp->template_message = $_COOKIE['bp-message']; 1231 1233 1232 1234 if ( empty( $bp->template_message_type ) ) 1233 1235 $bp->template_message_type = $_COOKIE['bp-message-type']; 1234 1236 1235 1237 add_action( 'template_notices', 'bp_core_render_message' ); 1236 1238 1237 1239 @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH ); 1238 1240 @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); … … 1245 1247 * Renders a feedback message (either error or success message) to the theme template. 1246 1248 * The hook action 'template_notices' is used to call this function, it is not called directly. 1247 * 1249 * 1248 1250 * @package BuddyPress Core 1249 1251 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1251 1253 function bp_core_render_message() { 1252 1254 global $bp; 1253 1255 1254 1256 if ( $bp->template_message ) { 1255 1257 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; … … 1260 1262 <?php 1261 1263 do_action( 'bp_core_render_message' ); 1262 } 1264 } 1263 1265 } 1264 1266 … … 1267 1269 * 1268 1270 * Based on function created by Dunstan Orchard - http://1976design.com 1269 * 1271 * 1270 1272 * This function will return an English representation of the time elapsed 1271 1273 * since a given date. … … 1273 1275 * eg: 4 days 1274 1276 * eg: 4 weeks and 6 days 1275 * 1277 * 1276 1278 * @package BuddyPress Core 1277 1279 * @param $older_date int Unix timestamp of date you want to calculate the time since for … … 1291 1293 array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) ) 1292 1294 ); 1293 1295 1294 1296 $older_date = strtotime( gmdate( 'Y-m-d H:i:s', $older_date ) ); 1295 1297 … … 1297 1299 /* $newer_date will have a value if we want to work out time elapsed between two known dates */ 1298 1300 $newer_date = ( !$newer_date ) ? ( strtotime( gmdate( 'Y-m-d H:i:s' ) ) + ( 60*60*0 ) ) : $newer_date; 1299 1301 1300 1302 /* Difference in seconds */ 1301 1303 $since = $newer_date - $older_date; 1302 1304 1303 1305 if ( 0 > $since ) 1304 1306 return __( '[Use GMT Timezone]', 'buddypress' ); … … 1327 1329 $seconds2 = $chunks[$i + 1][0]; 1328 1330 $name2 = $chunks[$i + 1][1]; 1329 1331 1330 1332 //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output; 1331 1333 1332 1334 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 1333 1335 /* Add to output var */ … … 1349 1351 * show the length of time since the user was last active. 1350 1352 * This function will update that time as a usermeta setting for the user every 5 minutes. 1351 * 1353 * 1352 1354 * @package BuddyPress Core 1353 1355 * @global $userdata WordPress user data for the current logged in user. … … 1356 1358 function bp_core_record_activity() { 1357 1359 global $bp; 1358 1360 1359 1361 if ( !is_user_logged_in() ) 1360 1362 return false; 1361 1363 1362 1364 $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' ); 1363 1365 1364 1366 if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) ) 1365 1367 update_usermeta( $bp->loggedin_user->id, 'last_activity', time() ); … … 1372 1374 * 1373 1375 * Formats last activity based on time since date given. 1374 * 1376 * 1375 1377 * @package BuddyPress Core 1376 1378 * @param last_activity_date The date of last activity. … … 1384 1386 } else { 1385 1387 if ( strstr( $last_activity_date, '-' ) ) { 1386 $last_active = bp_core_time_since( strtotime( $last_activity_date ) ); 1388 $last_active = bp_core_time_since( strtotime( $last_activity_date ) ); 1387 1389 } else { 1388 $last_active = bp_core_time_since( $last_activity_date ); 1390 $last_active = bp_core_time_since( $last_activity_date ); 1389 1391 } 1390 1392 1391 1393 $last_active = sprintf( $string, $last_active ); 1392 1394 } 1393 1395 1394 1396 return $last_active; 1395 1397 } … … 1400 1402 * 1401 1403 * Fetch every post that is authored by the given user for the current blog. 1402 * 1404 * 1403 1405 * @package BuddyPress Core 1404 1406 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1408 1410 function bp_core_get_all_posts_for_user( $user_id = null ) { 1409 1411 global $bp, $wpdb; 1410 1412 1411 1413 if ( !$user_id ) 1412 1414 $user_id = $bp->displayed_user->id; 1413 1415 1414 1416 return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ); 1415 1417 } … … 1420 1422 * 1421 1423 * Get the path of of the current site. 1422 * 1424 * 1423 1425 * @package BuddyPress Core 1424 1426 * @global $comment WordPress comment global for the current comment. … … 1427 1429 function bp_core_get_site_path() { 1428 1430 global $current_site; 1429 1431 1430 1432 return $current_site->path; 1431 1433 } … … 1435 1437 * 1436 1438 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri() 1437 * 1439 * 1438 1440 * @package BuddyPress Core 1439 1441 * @global $bp_no_status_set Makes sure that there are no conflicts with status_header() called in bp_core_do_catch_uri() … … 1443 1445 function bp_core_redirect( $location, $status = 302 ) { 1444 1446 global $bp_no_status_set; 1445 1446 // Make sure we don't call status_header() in bp_core_do_catch_uri() 1447 1448 // Make sure we don't call status_header() in bp_core_do_catch_uri() 1447 1449 // as this conflicts with wp_redirect() 1448 1450 $bp_no_status_set = true; 1449 1451 1450 1452 wp_redirect( $location, $status ); 1451 1453 die; … … 1456 1458 * 1457 1459 * Returns the referrer URL without the http(s):// 1458 * 1460 * 1459 1461 * @package BuddyPress Core 1460 1462 * @return The referrer URL … … 1473 1475 * 1474 1476 * For example, it would stop someone creating a blog with the slug "groups". 1475 * 1477 * 1476 1478 * @package BuddyPress Core 1477 1479 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1479 1481 function bp_core_add_illegal_names() { 1480 1482 global $bp; 1481 1483 1482 1484 $current = maybe_unserialize( get_site_option( 'illegal_names' ) ); 1483 1485 $bp_illegal_names = $bp->root_components; 1484 1486 1485 1487 if ( is_array( $current ) ) { 1486 1488 foreach( $bp_illegal_names as $bp_illegal_name ) { … … 1501 1503 * 1502 1504 * Sets the "From" name in emails sent to the name of the site and not "WordPress" 1503 * 1505 * 1504 1506 * @package BuddyPress Core 1505 1507 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table … … 1516 1518 * 1517 1519 * Sets the "From" address in emails sent 1518 * 1520 * 1519 1521 * @package BuddyPress Core 1520 1522 * @global $current_site Object containing current site metadata … … 1532 1534 * 1533 1535 * Allows a user to completely remove their account from the system 1534 * 1536 * 1535 1537 * @package BuddyPress Core 1536 1538 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1564 1566 * 1565 1567 * A javascript free implementation of the search functions in BuddyPress 1566 * 1568 * 1567 1569 * @package BuddyPress Core 1568 1570 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 1575 1577 $search_terms = $_POST['search-terms']; 1576 1578 $search_which = $_POST['search-which']; 1577 1579 1578 1580 if ( !$slug || empty( $slug ) ) { 1579 1581 switch ( $search_which ) { … … 1596 1598 } 1597 1599 } 1598 1600 1599 1601 $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms ); 1600 1602 1601 1603 bp_core_redirect( $search_url ); 1602 1604 } … … 1607 1609 /** 1608 1610 * bp_core_ucfirst() 1609 * 1611 * 1610 1612 * Localization safe ucfirst() support. 1611 * 1613 * 1612 1614 * @package BuddyPress Core 1613 1615 */ … … 1615 1617 if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) { 1616 1618 $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) ); 1617 return $fc.mb_substr( $str, 1 ); 1619 return $fc.mb_substr( $str, 1 ); 1618 1620 } else { 1619 1621 return ucfirst( $str ); … … 1624 1626 /** 1625 1627 * bp_core_strip_username_spaces() 1626 * 1628 * 1627 1629 * Strips spaces from usernames that are created using add_user() and wp_insert_user() 1628 * 1630 * 1629 1631 * @package BuddyPress Core 1630 1632 */ … … 1637 1639 /** 1638 1640 * bp_core_clear_cache() 1639 * REQUIRES WP-SUPER-CACHE 1640 * 1641 * REQUIRES WP-SUPER-CACHE 1642 * 1641 1643 * When wp-super-cache is installed this function will clear cached pages 1642 1644 * so that success/error messages are not cached, or time sensitive content. 1643 * 1645 * 1644 1646 * @package BuddyPress Core 1645 1647 */ 1646 1648 function bp_core_clear_cache() { 1647 1649 global $cache_path, $cache_filename; 1648 1650 1649 1651 if ( function_exists( 'prune_super_cache' ) ) { 1650 1652 do_action( 'bp_core_clear_cache' ); 1651 1652 return prune_super_cache( $cache_path, true ); 1653 1654 return prune_super_cache( $cache_path, true ); 1653 1655 } 1654 1656 } … … 1656 1658 /** 1657 1659 * bp_core_print_generation_time() 1658 * 1660 * 1659 1661 * Prints the generation time in the footer of the site. 1660 * 1662 * 1661 1663 * @package BuddyPress Core 1662 1664 */ … … 1671 1673 /** 1672 1674 * bp_core_add_admin_menu_page() 1673 * 1675 * 1674 1676 * A better version of add_admin_menu_page() that allows positioning of menus. 1675 * 1677 * 1676 1678 * @package BuddyPress Core 1677 1679 */ … … 1691 1693 $r = wp_parse_args( $args, $defaults ); 1692 1694 extract( $r, EXTR_SKIP ); 1693 1695 1694 1696 $file = plugin_basename( $file ); 1695 1697 … … 1708 1710 $position++; 1709 1711 } while ( !empty( $menu[$position] ) ); 1710 1712 1711 1713 $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); 1712 1714 … … 1721 1723 * When a user logs in, check if they have been marked as a spammer. If then simply 1722 1724 * redirect them to the home page and stop them from logging in. 1723 * 1725 * 1724 1726 * @package BuddyPress Core 1725 1727 * @param $username The username of the user … … 1728 1730 function bp_core_boot_spammer( $auth_obj, $username ) { 1729 1731 global $bp; 1730 1732 1731 1733 $user = get_userdatabylogin( $username ); 1732 1734 … … 1740 1742 * 1741 1743 * Deletes usermeta for the user when the user is deleted. 1742 * 1744 * 1743 1745 * @package BuddyPress Core 1744 1746 * @param $user_id The user id for the user to delete usermeta for … … 1758 1760 /** 1759 1761 * bp_load_buddypress_textdomain() 1760 * 1762 * 1761 1763 * Load the buddypress translation file for current language 1762 * 1764 * 1763 1765 * @package BuddyPress Core 1764 1766 */ … … 1766 1768 $locale = apply_filters( 'buddypress_locale', get_locale() ); 1767 1769 $mofile = BP_PLUGIN_DIR . "/bp-languages/buddypress-$locale.mo"; 1768 1770 1769 1771 if ( file_exists( $mofile ) ) 1770 1772 load_textdomain( 'buddypress', $mofile ); … … 1781 1783 /** 1782 1784 * bp_core_update_message() 1783 * 1785 * 1784 1786 * Add an extra update message to the update plugin notification. 1785 * 1787 * 1786 1788 * @package BuddyPress Core 1787 1789 */ … … 1793 1795 /** 1794 1796 * bp_core_clear_user_object_cache() 1795 * 1797 * 1796 1798 * Clears all cached objects for a user, or a user is part of. 1797 * 1799 * 1798 1800 * @package BuddyPress Core 1799 1801 */ -
trunk/bp-core/bp-core-activation.php
r2025 r2077 3 3 function bp_core_screen_activation() { 4 4 global $bp, $wpdb; 5 5 6 6 if ( BP_ACTIVATION_SLUG != $bp->current_component ) 7 7 return false; 8 8 9 9 /* If we are using a BuddyPress 1.0 theme ignore this. */ 10 10 if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 11 11 return false; 12 12 13 13 /* Check if an activation key has been passed */ 14 14 if ( isset( $_GET['key'] ) ) { 15 15 16 16 require_once( ABSPATH . WPINC . '/registration.php' ); 17 17 18 18 /* Activate the signup */ 19 19 $signup = apply_filters( 'bp_core_activate_account', wpmu_activate_signup( $_GET['key'] ) ); 20 20 21 21 /* If there was errors, add a message and redirect */ 22 22 if ( $signup->errors ) { … … 24 24 bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG ); 25 25 } 26 26 27 27 /* Set the password */ 28 28 if ( !empty( $signup['meta']['password'] ) ) 29 29 $wpdb->update( $wpdb->users, array( 'user_pass' => $signup['meta']['password'] ), array( 'ID' => $signup['user_id'] ), array( '%s' ), array( '%d' ) ); 30 31 /* Set any profile data */ 30 31 /* Set any profile data */ 32 32 if ( function_exists( 'xprofile_set_field_data' ) ) { 33 33 34 34 if ( !empty( $signup['meta']['profile_field_ids'] ) ) { 35 35 $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] ); 36 36 37 37 foreach( $profile_field_ids as $field_id ) { 38 38 $current_field = $signup['meta']["field_{$field_id}"]; 39 39 40 40 if ( !empty( $current_field ) ) 41 41 xprofile_set_field_data( $field_id, $signup['user_id'], $current_field ); 42 42 } 43 43 } 44 44 45 45 } 46 46 47 47 /* Check for an uploaded avatar and move that to the correct user folder */ 48 48 $hashed_key = wp_hash( $_GET['key'] ); 49 49 50 50 /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */ 51 51 if ( file_exists( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key ) ) { 52 52 @rename( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key, WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $signup['user_id'] ); 53 53 } 54 54 55 55 /* Record the new user in the activity streams */ 56 56 if ( function_exists( 'bp_activity_add' ) ) { 57 57 $userlink = bp_core_get_userlink( $signup['user_id'] ); 58 58 59 59 bp_activity_add( array( 60 60 'user_id' => $signup['user_id'], … … 62 62 'primary_link' => apply_filters( 'bp_core_actiivty_registered_member_primary_link', $userlink ), 63 63 'component_name' => 'profile', 64 'component_action' => 'new_member' 64 'component_action' => 'new_member' 65 65 ) ); 66 66 } … … 68 68 do_action( 'bp_core_account_activated', &$signup, $_GET['key'] ); 69 69 bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) ); 70 70 71 71 $bp->activation_complete = true; 72 72 } 73 73 74 74 if ( '' != locate_template( array( 'registration/activate' ), false ) ) 75 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) ); 75 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) ); 76 76 else 77 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) ); 77 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) ); 78 78 } 79 79 add_action( 'wp', 'bp_core_screen_activation', 3 ); … … 91 91 if ( '' == locate_template( array( 'registration/register.php' ), false ) && '' == locate_template( array( 'register.php' ), false ) ) 92 92 return true; 93 93 94 94 return false; 95 95 } -
trunk/bp-core/bp-core-admin.php
r2029 r2077 4 4 global $wpdb, $bp, $current_blog; 5 5 ?> 6 6 7 7 <?php 8 8 if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) { 9 9 if ( !check_admin_referer('bp-admin') ) 10 10 return false; 11 11 12 12 // Settings form submitted, now save the settings. 13 13 foreach ( $_POST['bp-admin'] as $key => $value ) { 14 14 15 15 if ( function_exists( 'xprofile_install' ) ) { 16 16 if ( 'bp-xprofile-base-group-name' == $key ) { 17 17 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE name = %s AND id = 1", $value, stripslashes( get_site_option('bp-xprofile-base-group-name') ) ) ); 18 18 } 19 19 20 20 if ( 'bp-xprofile-fullname-field-name' == $key ) { 21 21 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE name = %s AND group_id = 1", $value, stripslashes( get_site_option('bp-xprofile-fullname-field-name') ) ) ); 22 22 } 23 23 } 24 24 25 25 update_site_option( $key, $value ); 26 26 } 27 27 } 28 28 ?> 29 29 30 30 <div class="wrap"> 31 31 32 32 <h2><?php _e( 'BuddyPress Settings', 'buddypress' ) ?></h2> 33 33 … … 39 39 40 40 <form action="" method="post" id="bp-admin-form"> 41 41 42 42 <table class="form-table"> 43 43 <tbody> … … 47 47 <td> 48 48 <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" /> 49 </td> 49 </td> 50 50 </tr> 51 51 <tr> … … 60 60 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 61 61 <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 62 </td> 62 </td> 63 63 </tr> 64 64 <?php endif; ?> … … 68 68 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 69 69 <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 70 </td> 70 </td> 71 71 </tr> 72 72 <tr> … … 83 83 <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( (int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 84 84 <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 85 </td> 86 </tr> 87 <?php } ?> 85 </td> 86 </tr> 87 <?php } ?> 88 88 <tr> 89 89 <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th> … … 91 91 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 92 92 <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) || '' == get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 93 </td> 93 </td> 94 94 </tr> 95 95 <?php if ( function_exists( 'bp_forums_setup') ) : ?> … … 99 99 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> 100 100 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) || '' == get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?> 101 </td> 102 </tr> 103 <?php endif; ?> 104 101 </td> 102 </tr> 103 <?php endif; ?> 104 105 105 <?php $themes = bp_core_get_buddypress_themes() ?> 106 106 <?php if ( $themes ) : ?> … … 109 109 <td> 110 110 <select name="bp-admin[active-member-theme]" id="active-member-theme"> 111 <?php 112 for ( $i = 0; $i < count($themes); $i++ ) { 111 <?php 112 for ( $i = 0; $i < count($themes); $i++ ) { 113 113 if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) { 114 114 $selected = ' selected="selected"'; … … 120 120 <?php } ?> 121 121 </select> 122 </td> 122 </td> 123 123 </tr> 124 124 <?php else : ?> … … 129 129 <?php endif; ?> 130 130 <?php endif; ?> 131 131 132 132 <tr> 133 133 <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th> … … 147 147 148 148 <?php do_action( 'bp_core_admin_screen' ) ?> 149 149 150 150 <p class="submit"> 151 151 <input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/> … … 153 153 154 154 <?php wp_nonce_field( 'bp-admin' ) ?> 155 155 156 156 </form> 157 157 158 158 </div> 159 160 <?php 159 160 <?php 161 161 } 162 162 … … 164 164 global $wpdb, $bp; 165 165 ?> 166 166 167 167 <?php 168 168 if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) { 169 169 if ( !check_admin_referer('bp-admin-component-setup') ) 170 170 return false; 171 171 172 172 // Settings form submitted, now save the settings. 173 173 foreach ( $_POST['bp_components'] as $key => $value ) { 174 174 if ( !(int) $value ) 175 $disabled[$key] = 1; 175 $disabled[$key] = 1; 176 176 } 177 177 update_site_option( 'bp-deactivated-components', $disabled ); 178 178 } 179 179 ?> 180 180 181 181 <div class="wrap"> 182 182 183 183 <h2><?php _e( 'BuddyPress Component Setup', 'buddypress' ) ?></h2> 184 184 185 185 <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?> 186 186 <div id="message" class="updated fade"> … … 188 188 </div> 189 189 <?php endif; ?> 190 190 191 191 <form action="" method="post" id="bp-admin-component-form"> 192 192 193 193 <p> 194 <?php _e( 195 'By default, all BuddyPress components are enabled. You can selectively disable any of the 194 <?php _e( 195 'By default, all BuddyPress components are enabled. You can selectively disable any of the 196 196 components by using the form below. Your BuddyPress installation will continue to function, however 197 197 the features of the disabled components will no longer be accessible to … … 199 199 ', 'buddypress' )?> 200 200 </p> 201 201 202 202 <?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?> 203 203 204 204 <table class="form-table" style="width: 80%"> 205 205 <tbody> … … 210 210 <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 211 211 <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 212 </td> 212 </td> 213 213 </tr> 214 214 <?php endif; ?> … … 219 219 <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 220 220 <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 221 </td> 221 </td> 222 222 </tr> 223 223 <?php endif; ?> … … 228 228 <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 229 229 <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 230 </td> 230 </td> 231 231 </tr> 232 232 <?php endif; ?> … … 237 237 <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 238 238 <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 239 </td> 239 </td> 240 240 </tr> 241 241 <?php endif; ?> … … 246 246 <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 247 247 <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 248 </td> 248 </td> 249 249 </tr> 250 250 <?php endif; ?> … … 255 255 <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 256 256 <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 257 </td> 257 </td> 258 258 </tr> 259 259 <?php endif; ?> … … 264 264 <input type="radio" name="bp_components[bp-wire.php]" value="1"<?php if ( !isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> 265 265 <input type="radio" name="bp_components[bp-wire.php]" value="0"<?php if ( isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?> 266 </td> 266 </td> 267 267 </tr> 268 268 <?php endif; ?> … … 287 287 </tbody> 288 288 </table> 289 289 290 290 <p class="submit"> 291 291 <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/> 292 292 </p> 293 293 294 294 <?php wp_nonce_field( 'bp-admin-component-setup' ) ?> 295 295 296 296 </form> 297 297 298 298 </div> 299 300 <?php 299 300 <?php 301 301 } 302 302 -
trunk/bp-core/bp-core-adminbar.php
r1905 r2077 3 3 function bp_core_admin_bar() { 4 4 global $bp, $wpdb, $current_blog, $doing_admin_bar; 5 5 6 6 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) ) 7 7 return false; 8 8 9 9 $doing_admin_bar = true; 10 10 11 11 if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) 12 12 return false; … … 18 18 19 19 echo '<ul class="main-nav">'; 20 20 21 21 // **** Do bp-adminbar-menus Actions ******** 22 22 do_action( 'bp_adminbar_menus' ); … … 29 29 function bp_adminbar_logo() { 30 30 global $bp; 31 31 32 32 echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>'; 33 33 } … … 37 37 global $bp; 38 38 39 if ( !is_user_logged_in() ) { 39 if ( !is_user_logged_in() ) { 40 40 echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>'; 41 41 42 42 // Show "Sign Up" link if user registrations are allowed 43 43 if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) { … … 55 55 56 56 if ( is_user_logged_in() ) { 57 57 58 58 echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">'; 59 59 60 60 echo __( 'My Account', 'buddypress' ) . '</a>'; 61 61 echo '<ul>'; 62 62 63 63 /* Loop through each navigation item */ 64 64 $counter = 0; 65 65 foreach( $bp->bp_nav as $nav_item ) { 66 66 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; 67 67 68 68 echo '<li' . $alt . '>'; 69 69 echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>'; 70 70 71 71 if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) { 72 72 echo '<ul>'; … … 75 75 foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) { 76 76 $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : ''; 77 echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>'; 77 echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>'; 78 78 $sub_counter++; 79 79 } 80 80 echo '</ul>'; 81 81 } 82 82 83 83 echo '</li>'; 84 84 85 85 $counter++; 86 86 } 87 87 88 88 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; 89 89 90 if ( function_exists('wp_logout_url') ) { 91 echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 92 } else { 93 echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 94 } 95 90 if ( function_exists('wp_logout_url') ) { 91 echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 92 } else { 93 echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 94 } 95 96 96 echo '</ul>'; 97 97 echo '</li>'; … … 101 101 // return a string indicating user's role in that blog 102 102 function get_blog_role_for_user( $user, $blog ) { 103 103 104 104 // If the user is a site admin, just display admin. 105 if ( is_site_admin() ) 105 if ( is_site_admin() ) 106 106 return __( 'Admin', 'buddypress'); 107 107 108 108 $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' ); 109 109 110 110 if ( isset( $roles['subscriber'] ) ) 111 $role = __( 'Subscriber', 'buddypress' ); 111 $role = __( 'Subscriber', 'buddypress' ); 112 112 elseif ( isset( $roles['contributor'] ) ) 113 113 $role = __( 'Contributor', 'buddypress' ); … … 120 120 else 121 121 return false; 122 122 123 123 return $role; 124 124 } … … 127 127 function bp_adminbar_blogs_menu() { 128 128 if ( is_user_logged_in() ) { 129 global $bp; 130 129 global $bp; 130 131 131 if ( function_exists('bp_blogs_install') ) { 132 132 133 133 if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) { 134 134 $blogs = get_blogs_of_user( $bp->loggedin_user->id ); … … 137 137 138 138 echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">'; 139 139 140 140 _e( 'My Blogs', 'buddypress' ); 141 141 142 142 echo '</a>'; 143 144 echo '<ul>'; 143 144 echo '<ul>'; 145 145 if ( is_array( $blogs )) { 146 146 147 147 $counter = 0; 148 148 foreach( $blogs as $blog ) { … … 157 157 echo '<li><a href="' . $blog->siteurl . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>'; 158 158 echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>'; 159 echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>'; 160 if ( 'Admin' == $role ) { 161 echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>'; 162 } 163 echo '</ul>'; 159 echo '<li><a href="' . $blog->siteurl . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>'; 160 if ( 'Admin' == $role ) { 161 echo '<li class="alt"><a href="' . $blog->siteurl . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>'; 162 } 163 echo '</ul>'; 164 164 } 165 165 echo '</li>'; … … 167 167 } 168 168 } 169 169 170 170 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; 171 171 172 172 if ( bp_blog_signup_enabled() ) { 173 173 echo '<li' . $alt . '>'; … … 175 175 echo '</li>'; 176 176 } 177 177 178 178 echo '</ul>'; 179 179 echo '</li>'; 180 180 } 181 181 } 182 } 182 } 183 183 184 184 // **** "Notifications" Menu ********* 185 function bp_adminbar_notifications_menu() { 185 function bp_adminbar_notifications_menu() { 186 186 if ( is_user_logged_in() ) { 187 187 global $bp; 188 188 189 189 echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">'; 190 190 _e( 'Notifications', 'buddypress' ); 191 191 192 192 if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?> 193 193 <span><?php echo count($notifications) ?></span> 194 194 <?php 195 195 } 196 196 197 197 echo '</a>'; 198 198 echo '<ul>'; 199 199 200 200 if ( $notifications ) { ?> 201 201 <?php $counter = 0; ?> … … 209 209 <?php 210 210 } 211 211 212 212 echo '</ul>'; 213 213 echo '</li>'; … … 218 218 function bp_adminbar_authors_menu() { 219 219 global $current_blog; 220 220 221 221 if ( $current_blog->blog_id > 1 ) { 222 $authors = get_users_of_blog(); 223 222 $authors = get_users_of_blog(); 223 224 224 if ( is_array( $authors ) ) { 225 225 /* This is a blog, render a menu with links to all authors */ … … 227 227 _e('Blog Authors', 'buddypress'); 228 228 echo '</a>'; 229 229 230 230 echo '<ul class="author-list">'; 231 231 foreach( $authors as $author ) { … … 246 246 } 247 247 } 248 248 249 249 // **** "Random" Menu (visible when not logged in) ******** 250 function bp_adminbar_random_menu() { 250 function bp_adminbar_random_menu() { 251 251 global $bp; ?> 252 252 <li class="align-right" id="bp-adminbar-visitrandom-menu"> … … 261 261 <?php if ( function_exists('bp_blogs_install') ) : ?> 262 262 <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li> 263 263 264 264 <?php endif; ?> 265 265 266 266 <?php do_action( 'bp_adminbar_random_menu' ) ?> 267 267 </ul> -
trunk/bp-core/bp-core-avatars.php
r2069 r2077 32 32 if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) 33 33 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ); 34 34 35 35 function bp_core_fetch_avatar( $args = '' ) { 36 36 global $bp, $current_blog; 37 37 38 38 $defaults = array( 39 39 'item_id' => false, … … 41 41 'type' => 'thumb', 42 42 'avatar_dir' => false, 43 'width' => false, 43 'width' => false, 44 44 'height' => false, 45 45 'class' => 'avatar', … … 50 50 51 51 $params = wp_parse_args( $args, $defaults ); 52 extract( $params, EXTR_SKIP ); 52 extract( $params, EXTR_SKIP ); 53 53 54 54 if ( !$item_id ) { … … 59 59 else if ( 'blog' == $object ) 60 60 $item_id = $current_blog->id; 61 61 62 62 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object ); 63 63 64 64 if ( !$item_id ) return false; 65 65 } 66 66 67 67 if ( !$avatar_dir ) { 68 68 if ( 'user' == $object ) … … 72 72 else if ( 'blog' == $object ) 73 73 $avatar_dir = 'blog-avatars'; 74 74 75 75 $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object ); 76 77 if ( !$avatar_dir ) return false; 78 } 79 76 77 if ( !$avatar_dir ) return false; 78 } 79 80 80 if ( !$css_id ) 81 $css_id = $object . '-' . $item_id . '-avatar'; 82 81 $css_id = $object . '-' . $item_id . '-avatar'; 82 83 83 if ( $width ) 84 84 $html_width = " width='{$width}'"; 85 85 else 86 86 $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"'; 87 87 88 88 if ( $height ) 89 89 $html_height = " height='{$height}'"; 90 90 else 91 91 $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"'; 92 93 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 94 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 92 93 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 94 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 95 95 96 96 /**** … … 116 116 } 117 117 118 /* If no avatars have been uploaded for this item, display a gravatar */ 118 /* If no avatars have been uploaded for this item, display a gravatar */ 119 119 if ( !file_exists( $avatar_url ) && !$no_grav ) { 120 121 120 if ( empty( $bp->grav_default->{$object} ) ) 122 121 $default_grav = 'wavatar'; … … 129 128 else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH; 130 129 else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH; 131 130 132 131 if ( 'user' == $object ) { 133 132 $ud = get_userdata( $item_id ); … … 136 135 $grav_email = "{$item_id}-{$object}@{$bp->root_domain}"; 137 136 } 138 139 $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object ); 137 138 $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object ); 140 139 $gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&s=' . $grav_size; 141 140 142 141 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params ); 143 144 142 } else if ( !file_exists( $avatar_url ) && $no_grav ) 145 143 return false; 146 147 144 } 148 145 149 146 function bp_core_delete_existing_avatar( $args = '' ) { 150 147 global $bp; 151 148 152 149 $defaults = array( 153 150 'item_id' => false, … … 157 154 158 155 $args = wp_parse_args( $args, $defaults ); 159 extract( $args, EXTR_SKIP ); 160 156 extract( $args, EXTR_SKIP ); 157 161 158 if ( !$item_id ) { 162 159 if ( 'user' == $object ) … … 166 163 else if ( 'blog' == $object ) 167 164 $item_id = $current_blog->id; 168 165 169 166 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object ); 170 167 171 168 if ( !$item_id ) return false; 172 169 } 173 170 174 171 if ( !$avatar_dir ) { 175 172 if ( 'user' == $object ) … … 179 176 else if ( 'blog' == $object ) 180 177 $avatar_dir = 'blog-avatars'; 181 178 182 179 $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object ); 183 184 if ( !$avatar_dir ) return false; 180 181 if ( !$avatar_dir ) return false; 185 182 } 186 183 … … 193 190 } 194 191 195 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 192 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 196 193 197 194 if ( !file_exists( $avatar_folder_dir ) ) … … 201 198 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 202 199 if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) 203 @unlink( $avatar_folder_dir . '/' . $avatar_file ); 200 @unlink( $avatar_folder_dir . '/' . $avatar_file ); 204 201 } 205 202 } … … 215 212 function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 216 213 global $bp; 217 214 218 215 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 219 216 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 220 217 221 218 $uploadErrors = array( 222 0 => __("There is no error, the file uploaded with success", 'buddypress'), 223 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 219 0 => __("There is no error, the file uploaded with success", 'buddypress'), 220 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 224 221 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 225 222 3 => __("The uploaded file was only partially uploaded", 'buddypress'), … … 232 229 return false; 233 230 } 234 231 235 232 if ( !bp_core_check_avatar_size( $file ) ) { 236 233 bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE) ), 'error' ); 237 234 return false; 238 235 } 239 236 240 237 if ( !bp_core_check_avatar_type( $file ) ) { 241 238 bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' ); 242 239 return false; 243 240 } 244 241 245 242 // Filter the upload location 246 243 add_filter( 'upload_dir', $upload_dir_filter, 10, 0 ); 247 244 248 245 $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) ); 249 246 … … 253 250 return false; 254 251 } 255 252 256 253 // Resize the image down to something manageable and then delete the original 257 254 if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) { 258 255 $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH ); 259 256 } 260 257 261 258 $bp->avatar_admin->image = new stdClass; 262 263 // We only want to handle one image after resize. 259 260 // We only want to handle one image after resize. 264 261 if ( empty( $bp->avatar_admin->resized ) ) 265 262 $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file']; … … 268 265 @unlink( $bp->avatar_admin->original['file'] ); 269 266 } 270 267 271 268 /* Set the url value for the image */ 272 269 $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir ); … … 277 274 function bp_core_avatar_handle_crop( $args = '' ) { 278 275 global $bp; 279 276 280 277 $defaults = array( 281 278 'object' => 'user', … … 297 294 if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) ) 298 295 return false; 299 296 300 297 if ( !$item_id ) 301 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir ); 298 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir ); 302 299 else 303 300 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); … … 305 302 if ( !file_exists( $avatar_folder_dir ) ) 306 303 return false; 307 304 308 305 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 309 306 require_once( ABSPATH . '/wp-admin/includes/file.php' ); … … 311 308 /* Delete the existing avatar files for the object */ 312 309 bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) ); 313 310 314 311 /* Make sure we at least have a width and height for cropping */ 315 312 if ( !(int)$crop_w ) 316 313 $crop_w = BP_AVATAR_FULL_WIDTH; 317 314 318 315 if ( !(int)$crop_h ) 319 316 $crop_h = BP_AVATAR_FULL_HEIGHT; … … 322 319 $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg'; 323 320 $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg'; 324 321 325 322 /* Crop the image */ 326 323 $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename ); … … 337 334 if ( is_object ( $id_or_email ) ) 338 335 $id_or_email = $id_or_email->user_id; 339 336 340 337 $bp_avatar = bp_core_fetch_avatar( array( 'no_grav' => true, 'item_id' => $id_or_email, 'width' => $size, 'height' => $size, 'alt' => $alt ) ); 341 338 … … 347 344 if ( $file['error'] ) 348 345 return false; 349 346 350 347 return true; 351 348 } … … 354 351 if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE ) 355 352 return false; 356 353 357 354 return true; 358 355 } … … 361 358 if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) ) 362 359 return false; 363 360 364 361 return true; 365 362 } -
trunk/bp-core/bp-core-catchuri.php
r2027 r2077 17 17 * - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ... 18 18 * - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ... 19 * 19 * 20 20 * Example: 21 21 * - http://domain.com/members/andy/profile/edit/group/5/ … … 23 23 * - $bp->current_action: string 'edit' 24 24 * - $bp->action_variables: array ['group', 5] 25 * 25 * 26 26 * @package BuddyPress Core 27 27 */ … … 32 32 global $bp_unfiltered_uri; 33 33 global $bp, $current_blog; 34 34 35 35 if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) { 36 36 /* Only catch URI's on the root blog if we are not running BP on multiple blogs */ … … 64 64 array_shift( $bp_uri ); 65 65 } 66 66 67 67 /* Set the indexes, these are incresed by one if we are not on a VHOST install */ 68 68 $component_index = 0; 69 69 $action_index = $component_index + 1; 70 70 71 71 // If this is a WordPress page, return from the function. 72 72 if ( is_page( $bp_uri[$component_index] ) ) 73 73 return false; 74 74 75 75 /* Get site path items */ 76 76 $paths = explode( '/', bp_core_get_site_path() ); … … 93 93 $bp_uri = array_merge( array(), $bp_uri ); 94 94 $bp_unfiltered_uri = $bp_uri; 95 95 96 96 /* If we are under anything with a members slug, set the correct globals */ 97 97 if ( $bp_uri[0] == BP_MEMBERS_SLUG ) { 98 98 $is_member_page = true; 99 $is_root_component = true; 99 $is_root_component = true; 100 100 } 101 101 102 102 /* Catch a member page and set the current member ID */ 103 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) { 104 if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) { 103 if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) { 104 if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) { 105 105 // We are within a member page, set up user id globals 106 106 $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] ); … … 108 108 unset($bp_uri[0]); 109 109 unset($bp_uri[1]); 110 110 111 111 /* Reset the keys by merging with an empty array */ 112 112 $bp_uri = array_merge( array(), $bp_uri ); … … 116 116 $is_member_page = true; 117 117 $is_root_component = true; 118 118 119 119 // We are within a member page, set up user id globals 120 120 $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[0] ); 121 121 122 122 unset($bp_uri[0]); 123 123 … … 126 126 } 127 127 } 128 128 129 129 if ( !isset($is_root_component) ) 130 130 $is_root_component = in_array( $bp_uri[0], $bp->root_components ); … … 137 137 /* Set the current component */ 138 138 $current_component = $bp_uri[$component_index]; 139 139 140 140 /* Set the current action */ 141 141 $current_action = $bp_uri[$action_index]; 142 142 143 143 /* Set the entire URI as the action variables, we will unset the current_component and action in a second */ 144 144 $action_variables = $bp_uri; … … 151 151 if ( 'no' == VHOST && !$is_root_component ) 152 152 array_shift($action_variables); 153 153 154 154 /* Reset the keys by merging with an empty array */ 155 155 $action_variables = array_merge( array(), $action_variables ); … … 162 162 * bp_catch_uri() 163 163 * 164 * Takes either a single page name or array of page names and 164 * Takes either a single page name or array of page names and 165 165 * loads the first template file that can be found. 166 166 * 167 167 * Please don't call this function directly anymore, use: bp_core_load_template() 168 * 168 * 169 169 * @package BuddyPress Core 170 170 * @global $bp_path BuddyPress global containing the template file names to use. … … 174 174 function bp_catch_uri( $pages, $skip_blog_check = false ) { 175 175 global $bp_path, $bp_skip_blog_check; 176 176 177 177 $bp_skip_blog_check = $skip_blog_check; 178 178 … … 189 189 * 190 190 * Loads the first template file found based on the $bp_path global. 191 * 191 * 192 192 * @package BuddyPress Core 193 193 * @global $bp_path BuddyPress global containing the template file names to use. … … 198 198 global $bp_no_status_set; 199 199 global $wp_query; 200 201 /* Can be a single template or an array of templates */ 200 201 /* Can be a single template or an array of templates */ 202 202 $templates = $bp_path; 203 203 204 204 /* Don't hijack any URLs on blog pages */ 205 205 if ( bp_is_blog_page() ) { … … 214 214 status_header( 200 ); 215 215 $wp_query->is_404 = false; 216 216 217 217 if ( $bp->current_component != BP_HOME_BLOG_SLUG ) 218 218 $wp_query->is_page = true; 219 219 } 220 220 221 221 foreach ( (array)$templates as $template ) 222 222 $filtered_templates[] = $template . '.php'; 223 223 224 224 if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) { 225 225 load_template( apply_filters( 'bp_load_template', $located_template ) ); … … 269 269 * If the extended profiles component is not installed we still need 270 270 * to catch the /profile URI's and display whatever we have installed. 271 * 271 * 272 272 */ 273 273 function bp_core_catch_profile_uri() { 274 274 global $bp; 275 275 276 276 if ( !function_exists('xprofile_install') ) 277 277 bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'profile/index' ) ); -
trunk/bp-core/bp-core-classes.php
r2055 r2077 3 3 * BP_Core_User class can be used by any component. It will fetch useful 4 4 * details for any user when provided with a user_id. 5 * 5 * 6 6 * Example: 7 7 * $user = new BP_Core_User( $user_id ); … … 10 10 * $user_status = $user->status; 11 11 * etc. 12 * 12 * 13 13 * @package BuddyPress Core 14 14 */ … … 20 20 var $fullname; 21 21 var $email; 22 22 23 23 var $user_url; 24 24 var $user_link; 25 25 26 26 var $last_active; 27 27 var $profile_last_updated; … … 31 31 var $total_blogs; 32 32 var $total_groups; 33 33 34 34 function bp_core_user( $user_id, $populate_extras = false ) { 35 35 if ( $user_id ) { 36 36 $this->id = $user_id; 37 37 $this->populate(); 38 38 39 39 if ( $populate_extras ) 40 40 $this->populate_extras(); 41 41 } 42 } 43 42 } 43 44 44 /** 45 45 * populate() 46 46 * 47 47 * Populate the instantiated class with data based on the User ID provided. 48 * 48 * 49 49 * @package BuddyPress Core 50 50 * @global $userdata WordPress user data for the current logged in user. … … 59 59 $this->user_url = bp_core_get_userurl( $this->id ); 60 60 $this->user_link = bp_core_get_userlink( $this->id ); 61 61 62 62 $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) ); 63 63 $this->email = attribute_escape( bp_core_get_user_email( $this->id ) ); … … 68 68 $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ); 69 69 } 70 70 71 71 function populate_extras() { 72 72 global $bp; 73 74 if ( function_exists('friends_install') ) { 73 74 if ( function_exists('friends_install') ) { 75 75 $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id ); 76 76 … … 80 80 else 81 81 $this->total_friends .= ' ' . __( 'friends', 'buddypress' ); 82 82 83 83 $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>'; 84 84 } 85 85 } 86 86 87 if ( function_exists('bp_blogs_install') ) { 87 if ( function_exists('bp_blogs_install') ) { 88 88 if ( $this->total_blogs ) { 89 89 if ( 1 == $this->total_blogs ) 90 90 $this->total_blogs .= ' ' . __( 'blog', 'buddypress' ); 91 91 else 92 $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' ); 93 92 $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' ); 93 94 94 $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>'; 95 95 } 96 96 } 97 97 98 98 if ( function_exists('groups_install') ) { 99 99 $this->total_groups = BP_Groups_Member::total_group_count( $this->id ); 100 100 101 101 if ( $this->total_groups ) { 102 102 if ( 1 == $this->total_groups ) … … 109 109 } 110 110 } 111 111 112 112 /* Static Functions */ 113 113 114 114 function get_newest_users( $limit = null, $page = 1 ) { 115 115 global $wpdb; 116 117 if ( $limit && $page ) 118 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 119 116 117 if ( $limit && $page ) 118 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 119 120 120 $total_users_sql = apply_filters( 'bp_core_newest_users_count_sql', "SELECT DISTINCT count(ID) FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC" ); 121 121 $paged_users_sql = apply_filters( 'bp_core_newest_users_sql', "SELECT DISTINCT ID as user_id, DATE_ADD( user_registered, INTERVAL " . get_option('gmt_offset') . " HOUR ) as user_registered FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC{$pag_sql}", $pag_sql ); 122 123 $total_users = $wpdb->get_var( $total_users_sql ); 124 $paged_users = $wpdb->get_results( $paged_users_sql ); 125 126 return array( 'users' => $paged_users, 'total' => $total_users ); 127 } 128 122 123 $total_users = $wpdb->get_var( $total_users_sql ); 124 $paged_users = $wpdb->get_results( $paged_users_sql ); 125 126 return array( 'users' => $paged_users, 'total' => $total_users ); 127 } 128 129 129 function get_active_users( $limit = null, $page = 1 ) { 130 130 global $wpdb; … … 135 135 $total_users_sql = apply_filters( 'bp_core_active_users_count_sql', "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC" ); 136 136 $paged_users_sql = apply_filters( 'bp_core_active_users_sql', "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql ); 137 138 $total_users = $wpdb->get_var( $total_users_sql ); 139 $paged_users = $wpdb->get_results( $paged_users_sql ); 140 137 138 $total_users = $wpdb->get_var( $total_users_sql ); 139 $paged_users = $wpdb->get_results( $paged_users_sql ); 140 141 141 return array( 'users' => $paged_users, 'total' => $total_users ); 142 142 } … … 144 144 function get_popular_users( $limit = null, $page = 1 ) { 145 145 global $wpdb; 146 146 147 147 if ( !function_exists('friends_install') ) 148 148 return false; 149 149 150 150 if ( $limit && $page ) 151 151 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 156 156 $total_users = $wpdb->get_var( $total_users_sql ); 157 157 $paged_users = $wpdb->get_results( $paged_users_sql ); 158 159 return array( 'users' => $paged_users, 'total' => $total_users ); 160 } 161 158 159 return array( 'users' => $paged_users, 'total' => $total_users ); 160 } 161 162 162 function get_random_users( $limit = null, $page = 1 ) { 163 163 global $wpdb, $bp; 164 164 165 165 if ( $limit && $page ) 166 166 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 171 171 $total_users = $wpdb->get_var( $total_users_sql ); 172 172 $paged_users = $wpdb->get_results( $paged_users_sql ); 173 174 return array( 'users' => $paged_users, 'total' => $total_users ); 175 } 176 173 174 return array( 'users' => $paged_users, 'total' => $total_users ); 175 } 176 177 177 function get_online_users( $limit = null, $page = 1 ) { 178 178 global $wpdb; 179 179 180 180 if ( $limit && $page ) 181 181 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 189 189 return array( 'users' => $paged_users, 'total' => $total_users ); 190 190 } 191 191 192 192 function get_alphabetical_users( $limit = null, $page = 1 ) { 193 193 global $wpdb, $bp; … … 195 195 if ( !function_exists( 'xprofile_install' ) ) 196 196 return BP_Core_User::get_active_users( $limit, $page ); 197 197 198 198 if ( $limit && $page ) 199 199 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 207 207 return array( 'users' => $paged_users, 'total' => $total_users ); 208 208 } 209 209 210 210 function get_users_by_letter( $letter, $limit = null, $page = 1 ) { 211 211 global $wpdb, $bp; 212 212 213 213 if ( !function_exists('xprofile_install') ) 214 214 return BP_Core_User::get_active_users( $limit, $page ); 215 216 if ( $limit && $page ) 217 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 218 215 216 if ( $limit && $page ) 217 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 218 219 219 if ( strlen($letter) > 1 || is_numeric($letter) || !$letter ) 220 220 return false; 221 221 222 222 $letter = like_escape( $wpdb->escape( $letter ) ); 223 223 … … 227 227 $total_users = $wpdb->get_var( $total_users_sql ); 228 228 $paged_users = $wpdb->get_results( $paged_users_sql ); 229 230 return array( 'users' => $paged_users, 'total' => $total_users ); 231 } 232 229 230 return array( 'users' => $paged_users, 'total' => $total_users ); 231 } 232 233 233 function search_users( $search_terms, $limit = null, $page = 1 ) { 234 234 global $wpdb, $bp; 235 235 236 236 if ( !function_exists('xprofile_install') ) 237 237 return BP_Core_User::get_active_users( $limit, $page ); 238 239 if ( $limit && $page ) 240 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 241 242 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 238 239 if ( $limit && $page ) 240 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 241 242 $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 243 243 244 244 $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms ); … … 247 247 $total_users = $wpdb->get_var( $total_users_sql ); 248 248 $paged_users = $wpdb->get_results( $paged_users_sql ); 249 249 250 250 return array( 'users' => $paged_users, 'total' => $total_users ); 251 251 } … … 256 256 * BP_Core_Notification class can be used by any component. 257 257 * It will handle the fetching, saving and deleting of a user notification. 258 * 258 * 259 259 * @package BuddyPress Core 260 260 */ … … 269 269 var $date_notified; 270 270 var $is_new; 271 271 272 272 function bp_core_notification( $id = false ) { 273 273 if ( $id ) { … … 276 276 } 277 277 } 278 278 279 279 function populate() { 280 280 global $wpdb, $bp; 281 281 282 282 if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) { 283 283 $this->item_id = $notification->item_id; … … 289 289 $this->is_new = $notification->is_new; 290 290 } 291 } 292 291 } 292 293 293 function save() { 294 294 global $wpdb, $bp; 295 295 296 296 if ( $this->id ) { 297 297 // Update … … 310 310 311 311 /* Static functions */ 312 312 313 313 function check_access( $user_id, $notification_id ) { 314 314 global $wpdb, $bp; 315 315 316 316 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) ); 317 317 } 318 318 319 319 function get_all_for_user( $user_id ) { 320 320 global $wpdb, $bp; … … 322 322 return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) ); 323 323 } 324 324 325 325 function delete_for_user_by_type( $user_id, $component_name, $component_action ) { 326 326 global $wpdb, $bp; 327 327 328 328 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); 329 329 } 330 330 331 331 function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) { 332 332 global $wpdb, $bp; 333 333 334 334 if ( $secondary_item_id ) 335 335 $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ); 336 336 337 337 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) ); 338 338 } 339 339 340 340 function delete_from_user_by_type( $user_id, $component_name, $component_action ) { 341 341 global $wpdb, $bp; 342 342 343 343 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) ); 344 344 } 345 345 346 346 function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) { 347 347 global $wpdb, $bp; 348 348 349 349 if ( $component_action ) 350 350 $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action ); 351 351 352 352 if ( $secondary_item_id ) 353 353 $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id ); 354 354 355 355 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) ); 356 356 } 357 } 357 } 358 358 359 359 -
trunk/bp-core/bp-core-cssjs.php
r2069 r2077 5 5 * 6 6 * Add the CSS needed for the admin bar on blogs (other than the root) and in the admin area. 7 * 7 * 8 8 * @package BuddyPress Core 9 9 * @uses get_option() Selects a site setting from the DB. … … 11 11 function bp_core_add_admin_bar_css() { 12 12 global $current_blog; 13 13 14 14 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) ) 15 15 return false; … … 32 32 * 33 33 * Add the minor JS needed for the admin bar. 34 * 34 * 35 35 * @package BuddyPress Core 36 36 * @uses get_option() Selects a site setting from the DB. … … 46 46 * 47 47 * Add a hover-able icon to the "BuddyPress" wp-admin area menu. 48 * 48 * 49 49 * @package BuddyPress Core 50 50 */ … … 60 60 } 61 61 add_action( 'admin_head', 'bp_core_admin_menu_icon_css' ); 62 62 63 63 function bp_core_confirmation_js() { 64 64 ?> … … 72 72 * 73 73 * Makes sure the jQuery jCrop library is loaded. 74 * 74 * 75 75 * @package BuddyPress Core 76 76 */ 77 77 function bp_core_add_jquery_cropper() { 78 78 wp_enqueue_script( 'jcrop', array( 'jquery' ) ); 79 add_action( 'wp_head', 'bp_core_add_cropper_inline_js' ); 80 add_action( 'wp_head', 'bp_core_add_cropper_inline_css' ); 79 add_action( 'wp_head', 'bp_core_add_cropper_inline_js' ); 80 add_action( 'wp_head', 'bp_core_add_cropper_inline_css' ); 81 81 } 82 82 … … 85 85 * 86 86 * Adds the inline JS needed for the cropper to work on a per-page basis. 87 * 87 * 88 88 * @package BuddyPress Core 89 89 */ 90 90 function bp_core_add_cropper_inline_js() { 91 91 global $bp; 92 92 93 93 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) ); 94 94 95 $aspect_ratio = 1; 96 95 $aspect_ratio = 1; 96 97 97 /* Calculate Aspect Ratio */ 98 if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) ) 98 if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) ) 99 99 $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' ); 100 100 ?> … … 131 131 }); 132 132 } 133 } 133 } 134 134 </script> 135 135 <?php … … 140 140 * 141 141 * Adds the inline CSS needed for the cropper to work on a per-page basis. 142 * 142 * 143 143 * @package BuddyPress Core 144 144 */ … … 166 166 * 167 167 * Adds AJAX target URL so themes can access the WordPress AJAX functionality. 168 * 168 * 169 169 * @package BuddyPress Core 170 170 */ 171 171 function bp_core_add_ajax_url_js() { 172 172 global $bp; 173 174 echo 173 174 echo 175 175 '<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script> 176 176 '; … … 182 182 * 183 183 * Overrides the theme's admin bar CSS to hide the adminbar if disabled. 184 * 184 * 185 185 * @package BuddyPress Core 186 186 */ 187 function bp_core_override_adminbar_css() { 187 function bp_core_override_adminbar_css() { 188 188 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) { 189 189 ?> -
trunk/bp-core/bp-core-notifications.php
r1905 r2077 3 3 function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) { 4 4 global $bp; 5 5 6 6 if ( !$date_notified ) 7 7 $date_notified = time(); 8 8 9 9 $notification = new BP_Core_Notification; 10 10 $notification->item_id = $item_id; … … 17 17 if ( $secondary_item_id ) 18 18 $notification->secondary_item_id = $secondary_item_id; 19 19 20 20 if ( !$notification->save() ) 21 21 return false; 22 22 23 23 return true; 24 24 } … … 27 27 if ( !bp_core_check_notification_access( $bp->loggedin_user->id, $id ) ) 28 28 return false; 29 29 30 30 return BP_Core_Notification::delete( $id ); 31 31 } 32 32 33 33 function bp_core_get_notification( $id ) { 34 return new BP_Core_Notification( $id ); 34 return new BP_Core_Notification( $id ); 35 35 } 36 36 37 37 function bp_core_get_notifications_for_user( $user_id ) { 38 38 global $bp; 39 39 40 40 $notifications = BP_Core_Notification::get_all_for_user( $user_id ); 41 41 42 42 /* Group notifications by component and component_action and provide totals */ 43 43 for ( $i = 0; $i < count($notifications); $i++ ) { 44 44 $notification = $notifications[$i]; 45 45 46 46 $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; 47 47 } 48 48 49 49 if ( !$grouped_notifications ) 50 50 return false; 51 51 52 52 /* Calculated a renderable outcome for each notification type */ 53 53 foreach ( $grouped_notifications as $component_name => $action_arrays ) { 54 54 if ( !$action_arrays ) 55 55 continue; 56 56 57 57 foreach ( $action_arrays as $component_action_name => $component_action_items ) { 58 58 $action_item_count = count($component_action_items); 59 59 60 60 if ( $action_item_count < 1 ) 61 61 continue; … … 65 65 } 66 66 } 67 } 68 67 } 68 69 69 return $renderable; 70 70 } … … 89 89 if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) ) 90 90 return false; 91 91 92 92 return true; 93 93 } -
trunk/bp-core/bp-core-settings.php
r2059 r2077 3 3 if ( !defined( 'BP_SETTINGS_SLUG' ) ) 4 4 define( 'BP_SETTINGS_SLUG', 'settings' ); 5 5 6 6 function bp_core_add_settings_nav() { 7 7 global $bp; 8 8 9 9 /* Set up settings as a sudo-component for identification and nav selection */ 10 10 $bp->settings->id = 'settings'; 11 11 $bp->settings->slug = BP_SETTINGS_SLUG; 12 12 13 13 /* Register this in the active components array */ 14 14 $bp->active_components[$bp->settings->slug] = $bp->settings->id; … … 18 18 19 19 $settings_link = $bp->loggedin_user->domain . 'settings/'; 20 20 21 21 bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_home() ) ); 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_home() ) ); 23 23 24 24 if ( !is_site_admin() && !(int) get_site_option( '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_home() ) ); … … 32 32 function bp_core_screen_general_settings() { 33 33 global $current_user, $bp_settings_updated, $pass_error; 34 34 35 35 $bp_settings_updated = false; 36 36 $pass_error = false; 37 37 38 38 if ( isset($_POST['submit']) ) { 39 39 check_admin_referer('bp_settings_general'); 40 40 41 41 require_once( WPINC . '/registration.php' ); 42 42 43 43 // Form has been submitted and nonce checks out, lets do it. 44 44 45 45 if ( $_POST['email'] != '' ) 46 46 $current_user->user_email = wp_specialchars( trim( $_POST['email'] ) ); … … 56 56 unset( $current_user->user_pass ); 57 57 } 58 58 59 59 if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) ) 60 60 $bp_settings_updated = true; 61 61 } 62 62 63 63 add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' ); 64 64 add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' ); 65 65 66 66 bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 67 67 } … … 79 79 </div> 80 80 <?php } ?> 81 81 82 82 <?php if ( $pass_error && !$bp_settings_updated ) { ?> 83 83 <div id="message" class="error fade"> 84 84 <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p> 85 </div> 85 </div> 86 86 <?php } ?> 87 87 … … 89 89 <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label> 90 90 <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" /> 91 91 92 92 <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label> 93 93 <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> <?php _e( 'New Password', 'buddypress' ) ?><br /> 94 94 <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> <?php _e( 'Repeat New Password', 'buddypress' ) ?> 95 95 96 96 <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p> 97 97 <?php wp_nonce_field('bp_settings_general') ?> … … 104 104 function bp_core_screen_notification_settings() { 105 105 global $current_user, $bp_settings_updated; 106 106 107 107 $bp_settings_updated = false; 108 108 109 109 if ( $_POST['submit'] ) { 110 110 check_admin_referer('bp_settings_notifications'); 111 111 112 112 if ( $_POST['notifications'] ) { 113 113 foreach ( $_POST['notifications'] as $key => $value ) { … … 115 115 } 116 116 } 117 117 118 118 $bp_settings_updated = true; 119 119 } 120 120 121 121 add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' ); 122 122 add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' ); 123 123 124 124 bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 125 125 } … … 137 137 </div> 138 138 <?php } ?> 139 139 140 140 <form action="<?php echo $bp->loggedin_user->domain . 'settings/notifications' ?>" method="post" id="settings-form"> 141 141 <h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3> 142 142 <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p> 143 143 144 144 <?php do_action( 'bp_notification_settings' ) ?> 145 146 <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p> 147 145 146 <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p> 147 148 148 <?php wp_nonce_field('bp_settings_notifications') ?> 149 149 150 150 </form> 151 151 <?php … … 154 154 /**** DELETE ACCOUNT ****/ 155 155 156 function bp_core_screen_delete_account() { 156 function bp_core_screen_delete_account() { 157 157 if ( isset( $_POST['delete-account-understand'] ) ) { 158 158 check_admin_referer( 'delete-account' ); … … 162 162 bp_core_redirect( site_url() ); 163 163 } 164 165 164 add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' ); 166 165 add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' ); 167 166 168 167 bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 169 168 } … … 177 176 178 177 <form action="<?php echo $bp->loggedin_user->domain . 'settings/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post"> 179 178 180 179 <div id="message" class="info"> 181 180 <p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p> 182 181 </div> 183 182 184 183 <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?> 185 184 <p><input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> »" id="delete-account-button" name="delete-account-button" /></p> -
trunk/bp-core/bp-core-signup.php
r2068 r2077 3 3 function bp_core_screen_signup() { 4 4 global $bp, $wpdb; 5 5 6 6 if ( $bp->current_component != BP_REGISTER_SLUG ) 7 7 return false; 8 8 9 9 /* If the user is logged in, redirect away from here */ 10 10 if ( is_user_logged_in() ) 11 11 bp_core_redirect( $bp->root_domain ); 12 12 13 13 /*** 14 14 * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function … … 21 21 if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() ) 22 22 bp_core_redirect( $bp->root_domain ); 23 23 24 24 $bp->signup->step = 'request-details'; 25 25 26 26 /* If the signup page is submitted, validate and save */ 27 27 if ( isset( $_POST['signup_submit'] ) ) { 28 28 29 29 /* Check the nonce */ 30 30 check_admin_referer( 'bp_new_signup' ); 31 31 32 32 require_once( ABSPATH . WPINC . '/registration.php' ); 33 33 34 34 /* Check the base account details for problems */ 35 35 $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] ); 36 36 37 37 /* If there are errors with account details, set them for display */ 38 38 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 39 39 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; 40 40 41 41 if ( !empty( $account_details['errors']->errors['user_email'] ) ) 42 42 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 43 43 44 44 /* Check that both password fields are filled in */ 45 45 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) … … 54 54 55 55 /* Loop through the posted fields formatting any datebox values then validate the field */ 56 foreach ( (array) $profile_field_ids as $field_id ) { 56 foreach ( (array) $profile_field_ids as $field_id ) { 57 57 if ( !isset( $_POST['field_' . $field_id] ) ) { 58 58 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 59 59 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 60 60 } 61 61 62 62 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) ) 63 63 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); … … 67 67 if ( isset( $_POST['signup_with_blog'] ) ) { 68 68 $active_signup = get_site_option( 'registration' ); 69 69 70 70 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 71 71 $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 72 72 73 73 /* If there are errors with blog details, set them for display */ 74 74 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) … … 88 88 } else { 89 89 $bp->signup->step = 'save-details'; 90 90 91 91 /* No errors! Let's register those deets. */ 92 92 $active_signup = get_site_option( 'registration' ); 93 93 94 94 if ( 'none' != $active_signup ) { 95 95 96 96 /* Let's compact any profile field info into usermeta */ 97 97 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 98 98 99 99 /* Loop through the posted fields formatting any datebox values then add to usermeta */ 100 foreach ( (array) $profile_field_ids as $field_id ) { 100 foreach ( (array) $profile_field_ids as $field_id ) { 101 101 if ( !isset( $_POST['field_' . $field_id] ) ) { 102 102 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 103 103 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 104 104 } 105 105 106 106 if ( !empty( $_POST['field_' . $field_id] ) ) 107 107 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; 108 108 } 109 109 110 110 /* Store the profile field ID's in usermeta */ 111 111 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; 112 112 113 113 /* Hash and store the password */ 114 114 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 115 115 116 116 /* If the user decided to create a blog, save those details to usermeta */ 117 117 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 118 118 $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false; 119 119 } 120 120 121 121 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 122 122 123 123 /* Finally, sign up the user and/or blog*/ 124 124 if ( isset( $_POST['signup_with_blog'] ) ) … … 126 126 else 127 127 wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 128 128 129 129 $bp->signup->step = 'completed-confirmation'; 130 130 } … … 132 132 do_action( 'bp_complete_signup' ); 133 133 } 134 134 135 135 } 136 136 … … 139 139 /* If user has uploaded a new avatar */ 140 140 if ( !empty( $_FILES ) ) { 141 141 142 142 /* Check the nonce */ 143 143 check_admin_referer( 'bp_avatar_upload' ); 144 144 145 145 $bp->signup->step = 'completed-confirmation'; 146 146 147 147 /* Get the activation key */ 148 148 if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) { … … 151 151 /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */ 152 152 $bp->signup->avatar_dir = wp_hash( $bp->signup->key ); 153 154 /* Pass the file to the avatar upload handler */ 155 if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) { 153 154 /* Pass the file to the avatar upload handler */ 155 if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) { 156 156 $bp->avatar_admin->step = 'crop-image'; 157 157 158 158 /* Make sure we include the jQuery jCrop file for image cropping */ 159 159 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 160 } 160 } 161 161 } 162 162 } 163 163 164 164 /* If the image cropping is done, crop the image and save a full/thumb version */ 165 165 if ( isset( $_POST['avatar-crop-submit'] ) ) { 166 166 167 167 /* Check the nonce */ 168 168 check_admin_referer( 'bp_avatar_cropstore' ); 169 169 170 170 /* Reset the avatar step so we can show the upload form again if needed */ 171 171 $bp->signup->step = 'completed-confirmation'; … … 178 178 179 179 } 180 bp_core_load_template( 'registration/register' ); 180 bp_core_load_template( 'registration/register' ); 181 181 } 182 182 add_action( 'wp', 'bp_core_screen_signup', 3 ); … … 187 187 if ( !$bp->signup->avatar_dir ) 188 188 return false; 189 189 190 190 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 191 191 $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path ); … … 193 193 194 194 $newbdir = $newdir; 195 195 196 196 if ( !file_exists( $newdir ) ) 197 197 @wp_mkdir_p( $newdir ); … … 201 201 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 202 202 203 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 203 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 204 204 } 205 205 … … 210 210 211 211 if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) ) 212 212 wp_redirect( bp_root_domain() . BP_REGISTER_SLUG ); 213 213 } 214 214 add_action( 'signup_header', 'bp_core_wpsignup_redirect' ); 215 216 215 ?> -
trunk/bp-core/bp-core-templatetags.php
r2074 r2077 6 6 * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install. 7 7 * Each component adds to this navigation array within its own [component_name]_setup_nav() function. 8 * 8 * 9 9 * This navigation array is the top level navigation, so it contains items such as: 10 10 * [Blog, Profile, Messages, Groups, Friends] ... … … 18 18 function bp_get_loggedin_user_nav() { 19 19 global $bp, $current_blog; 20 20 21 21 /* Loop through each navigation item */ 22 22 foreach( (array) $bp->bp_nav as $nav_item ) { … … 27 27 $selected = ''; 28 28 } 29 29 30 30 /* If we are viewing another person (current_userid does not equal loggedin_user->id) 31 31 then check to see if the two users are friends. if they are, add a highlight CSS class … … 33 33 if ( !bp_is_home() && $bp->displayed_user->id ) { 34 34 $selected = ''; 35 35 36 36 if ( function_exists('friends_install') ) { 37 37 if ( $nav_item['css_id'] == $bp->friends->id ) { … … 41 41 } 42 42 } 43 43 44 44 /* echo out the final list item */ 45 45 echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item ); 46 46 } 47 47 48 48 /* Always add a log out list item to the end of the navigation */ 49 49 if ( function_exists( 'wp_logout_url' ) ) { 50 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 50 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 51 51 } else { 52 52 $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 53 53 } 54 54 55 55 echo apply_filters( 'bp_logout_nav_link', $logout_link ); 56 56 } … … 72 72 73 73 foreach ( $bp->bp_nav as $user_nav_item ) { 74 if ( !$user_nav_item['show_for_displayed_user'] ) 74 if ( !$user_nav_item['show_for_displayed_user'] ) 75 75 continue; 76 76 77 77 if ( $bp->current_component == $user_nav_item['css_id'] ) 78 78 $selected = ' class="current"'; 79 79 else 80 80 $selected = ''; 81 81 82 82 if ( $bp->loggedin_user->domain ) 83 83 $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] ); 84 84 else 85 85 $link = $bp->displayed_user->domain . $user_nav_item['link']; 86 86 87 87 echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="li-subnav-' . $user_nav_item['css_id'] . '" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ); 88 } 88 } 89 89 } 90 90 /* DEPRECATED - use bp_get_displayed_user_nav() */ 91 91 function bp_get_user_nav() { bp_get_displayed_user_nav(); } 92 92 93 93 /** 94 94 * bp_get_options_nav() … … 97 97 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component. 98 98 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function. 99 * 99 * 100 100 * This sub navigation array is the secondary level navigation, so for profile it contains: 101 101 * [Public, Edit Profile, Change Avatar] … … 103 103 * The function will also analyze the current action for the current component to determine whether 104 104 * or not to highlight a particular sub nav item. 105 * 105 * 106 106 * @package BuddyPress Core 107 107 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 118 118 if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 ) 119 119 return false; 120 120 121 121 /* Loop through each navigation item */ 122 122 foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) { 123 123 if ( !$subnav_item['user_has_access'] ) 124 124 continue; 125 125 126 126 /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */ 127 127 if ( $subnav_item['slug'] == $bp->current_action ) { … … 130 130 $selected = ''; 131 131 } 132 132 133 133 /* echo out the final list item */ 134 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item ); 134 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item ); 135 135 } 136 136 } else { … … 142 142 function bp_get_options_title() { 143 143 global $bp; 144 144 145 145 if ( empty( $bp->bp_options_title ) ) 146 146 $bp->bp_options_title = __( 'Options', 'buddypress' ); 147 147 148 148 echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) ); 149 149 } 150 150 151 151 152 152 /** AVATAR TEMPLATE TAGS *******************************************************/ … … 164 164 function bp_has_options_avatar() { 165 165 global $bp; 166 166 167 167 if ( empty( $bp->bp_options_avatar ) ) 168 168 return false; 169 169 170 170 return true; 171 171 } … … 179 179 function bp_comment_author_avatar() { 180 180 global $comment; 181 181 182 182 if ( function_exists('bp_core_fetch_avatar') ) { 183 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) ); 183 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) ); 184 184 } else if ( function_exists('get_avatar') ) { 185 185 get_avatar(); … … 189 189 function bp_post_author_avatar() { 190 190 global $post; 191 191 192 192 if ( function_exists('bp_core_fetch_avatar') ) { 193 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ); 193 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ); 194 194 } else if ( function_exists('get_avatar') ) { 195 195 get_avatar(); … … 211 211 $r = wp_parse_args( $args, $defaults ); 212 212 extract( $r, EXTR_SKIP ); 213 213 214 214 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 ) ) ); 215 } 215 } 216 216 217 217 function bp_displayed_user_avatar( $args = '' ) { … … 229 229 $r = wp_parse_args( $args, $defaults ); 230 230 extract( $r, EXTR_SKIP ); 231 231 232 232 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 ) ) ); 233 } 233 } 234 234 235 235 function bp_avatar_admin_step() { … … 256 256 function bp_get_avatar_to_crop_src() { 257 257 global $bp; 258 258 259 259 return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) ); 260 260 } 261 261 262 262 function bp_avatar_cropper() { 263 263 global $bp; 264 264 265 265 echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />'; 266 266 } … … 272 272 function bp_is_home() { 273 273 global $bp; 274 274 275 275 if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id ) 276 276 return true; 277 277 278 278 return false; 279 279 } … … 281 281 function bp_last_activity( $user_id = false, $echo = true ) { 282 282 global $bp; 283 283 284 284 if ( !$user_id ) 285 285 $user_id = $bp->displayed_user->id; 286 286 287 287 $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') ); 288 288 … … 295 295 function bp_user_link() { 296 296 global $bp; 297 297 298 298 echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain ); 299 299 } … … 301 301 function bp_get_loggedin_user_link() { 302 302 global $bp; 303 303 304 304 return $bp->loggedin_user->domain; 305 305 } … … 307 307 function bp_get_displayed_user_link() { 308 308 global $bp; 309 309 310 310 return $bp->displayed_user->domain; 311 311 } … … 313 313 function bp_core_get_wp_profile() { 314 314 global $bp; 315 315 316 316 $ud = get_userdata( $bp->displayed_user->id ); 317 317 ?> … … 393 393 if ( function_exists($component_name . '_install') ) 394 394 return true; 395 395 396 396 return false; 397 397 } … … 399 399 function bp_format_time( $time, $just_date = false ) { 400 400 $date = date( get_option('date_format'), $time ); 401 401 402 402 if ( !$just_date ) { 403 403 $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time ); 404 404 } 405 405 406 406 return apply_filters( 'bp_format_time', $date ); 407 407 } … … 409 409 function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) { 410 410 global $bp; 411 411 412 412 if ( $capitalize ) 413 413 $youtext = bp_core_ucfirst($youtext); 414 414 415 415 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 416 416 if ( $echo ) … … 429 429 function bp_your_or_their( $capitalize = true, $echo = true ) { 430 430 global $bp; 431 431 432 432 if ( $capitalize ) 433 433 $yourtext = bp_core_ucfirst($yourtext); 434 434 435 435 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 436 436 if ( $echo ) … … 448 448 function bp_loggedinuser_link() { 449 449 global $bp; 450 450 451 451 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) { 452 452 echo apply_filters( 'bp_loggedinuser_link', $link ); … … 483 483 $title = __( 'Blog — ' . $post->post_title, 'buddypress' ); 484 484 } else if ( is_category() ) { 485 $title = __( 'Blog — Categories — ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' ); 485 $title = __( 'Blog — Categories — ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' ); 486 486 } else if ( is_tag() ) { 487 $title = __( 'Blog — Tags — ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' ); 487 $title = __( 'Blog — Tags — ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' ); 488 488 } else 489 489 $title = __( 'Blog', 'buddypress' ); … … 502 502 $title = get_the_title($post->ID); 503 503 } 504 504 505 505 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) { 506 506 $blog_title = get_blog_option( $current_blog->blog_id, 'blogname' ); 507 507 } else { 508 $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 509 } 510 508 $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 509 } 510 511 511 return apply_filters( 'bp_page_title', $blog_title . ' — ' . attribute_escape( $title ), attribute_escape( $title ) ); 512 512 } … … 519 519 function bp_is_page($page) { 520 520 global $bp; 521 521 522 522 if ( $bp->displayed_user->id || $bp->is_single_item ) 523 523 return false; 524 524 525 525 if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) ) 526 526 return true; 527 527 528 528 return false; 529 529 } … … 535 535 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') ) 536 536 return true; 537 537 538 538 return false; 539 539 } … … 547 547 function bp_get_signup_page() { 548 548 global $bp; 549 549 550 550 if ( bp_has_custom_signup_page() ) { 551 551 return apply_filters( 'bp_get_signup_page', $bp->root_domain . '/' . BP_REGISTER_SLUG ); … … 561 561 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') ) 562 562 return true; 563 563 564 564 return false; 565 565 } … … 567 567 function bp_activation_page( $echo = true ) { 568 568 global $bp; 569 569 570 570 if ( bp_has_custom_activation_page() ) { 571 571 if ( $echo ) … … 583 583 function bp_search_form_action() { 584 584 global $bp; 585 585 586 586 return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' ); 587 587 } … … 590 590 // Eventually this won't be needed and a page will be built to integrate all search results. 591 591 $selection_box = '<select name="search-which" id="search-which" style="width: auto">'; 592 592 593 593 if ( function_exists( 'xprofile_install' ) ) { 594 594 $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>'; 595 595 } 596 596 597 597 if ( function_exists( 'groups_install' ) ) { 598 598 $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>'; … … 602 602 $selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>'; 603 603 } 604 604 605 605 if ( function_exists( 'bp_blogs_install' ) ) { 606 606 $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>'; 607 607 } 608 608 609 609 $selection_box .= '</select>'; 610 610 611 611 return apply_filters( 'bp_search_form_type_select', $selection_box ); 612 612 } … … 615 615 $form = ' 616 616 <form action="' . bp_search_form_action() . '" method="post" id="search-form"> 617 <input type="text" id="search-terms" name="search-terms" value="" /> 617 <input type="text" id="search-terms" name="search-terms" value="" /> 618 618 ' . bp_search_form_type_select() . ' 619 619 620 620 <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" /> 621 621 ' . wp_nonce_field( 'bp_search_form' ) . ' 622 622 </form> 623 623 '; 624 624 625 625 echo apply_filters( 'bp_search_form', $form ); 626 626 } … … 631 631 $logout_link = '<a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 632 632 else 633 $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 633 $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 634 634 635 635 echo apply_filters( 'bp_logout_link', $logout_link ); … … 638 638 function bp_profile_wire_can_post() { 639 639 global $bp; 640 640 641 641 if ( bp_is_home() ) 642 642 return true; 643 643 644 644 if ( function_exists('friends_install') ) { 645 645 if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) ) … … 647 647 else 648 648 return false; 649 } 650 649 } 650 651 651 return true; 652 652 } … … 659 659 <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li> 660 660 <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li> 661 661 662 662 <?php if ( function_exists( 'groups_install' ) ) { ?> 663 663 <li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li> 664 664 <?php } ?> 665 665 666 666 <?php if ( function_exists( 'bp_blogs_install' ) ) { ?> 667 667 <li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li> … … 681 681 function bp_is_directory() { 682 682 global $bp; 683 683 684 684 return $bp->is_directory; 685 685 } … … 689 689 * 690 690 * Fakes an excerpt on any content. Will not truncate words. 691 * 691 * 692 692 * @package BuddyPress Core 693 693 * @param $text str The text to create the excerpt from … … 707 707 $text = implode(' ', $words); 708 708 } 709 709 710 710 return apply_filters( 'bp_create_excerpt', $text ); 711 711 } … … 722 722 * 723 723 * Checks to see if the data passed has been serialized. 724 * 724 * 725 725 * @package BuddyPress Core 726 726 * @param $data str The data that will be checked … … 762 762 return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] ); 763 763 } 764 764 765 765 function bp_signup_blog_url_value() { 766 766 echo bp_get_signup_blog_url_value(); … … 789 789 function bp_get_signup_avatar_dir_value() { 790 790 global $bp; 791 791 792 792 return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir ); 793 793 } … … 798 798 function bp_get_current_signup_step() { 799 799 global $bp; 800 800 801 801 return $bp->signup->step; 802 802 } … … 807 807 function bp_get_signup_avatar( $args = '' ) { 808 808 global $bp; 809 809 810 810 $defaults = array( 811 811 'size' => BP_AVATAR_FULL_WIDTH, 812 812 'class' => 'avatar', 813 'alt' => __( 'Your Avatar', 'buddypress' ) 813 'alt' => __( 'Your Avatar', 'buddypress' ) 814 814 ); 815 815 816 816 $r = wp_parse_args( $args, $defaults ); 817 817 extract( $r, EXTR_SKIP ); 818 818 819 819 $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir; 820 820 … … 827 827 $default_grav = $bp->grav_default->user; 828 828 } 829 829 830 830 $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ); 831 831 return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />'; … … 844 844 function bp_account_was_activated() { 845 845 global $bp; 846 846 847 847 return $bp->activation_complete; 848 848 } … … 863 863 var $pag_links; 864 864 var $total_member_count; 865 865 866 866 function bp_core_members_template( $type, $per_page, $max ) { 867 867 global $bp, $bp_the_member_query; … … 869 869 $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1; 870 870 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 871 871 872 872 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 873 873 $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page ); … … 879 879 $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page ); 880 880 break; 881 881 882 882 case 'newest': 883 883 $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page ); … … 886 886 case 'popular': 887 887 $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page ); 888 break; 888 break; 889 889 890 890 case 'online': 891 891 $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page ); 892 892 break; 893 893 894 894 case 'alphabetical': 895 895 $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page ); 896 896 break; 897 897 898 898 case 'active': default: 899 899 $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page ); 900 break; 900 break; 901 901 } 902 902 } 903 903 904 904 if ( !$max || $max >= (int)$this->members['total'] ) 905 905 $this->total_member_count = (int)$this->members['total']; … … 917 917 $this->member_count = count($this->members); 918 918 } 919 920 if ( (int) $this->total_member_count && (int) $this->pag_num ) { 919 920 if ( (int) $this->total_member_count && (int) $this->pag_num ) { 921 921 $this->pag_links = paginate_links( array( 922 922 'base' => add_query_arg( 'upage', '%#%' ), … … 927 927 'next_text' => '»', 928 928 'mid_size' => 1 929 )); 929 )); 930 930 } 931 931 } 932 932 933 933 function has_members() { 934 934 if ( $this->member_count ) 935 935 return true; 936 936 937 937 return false; 938 938 } 939 939 940 940 function next_member() { 941 941 $this->current_member++; 942 942 $this->member = $this->members[$this->current_member]; 943 943 944 944 return $this->member; 945 945 } 946 946 947 947 function rewind_members() { 948 948 $this->current_member = -1; … … 951 951 } 952 952 } 953 954 function site_members() { 953 954 function site_members() { 955 955 if ( $this->current_member + 1 < $this->member_count ) { 956 956 return true; … … 964 964 return false; 965 965 } 966 966 967 967 function the_member() { 968 968 global $member, $bp; … … 977 977 wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' ); 978 978 } 979 979 980 980 if ( $user_registered ) 981 981 $this->member->user_registered = $user_registered; 982 982 983 983 if ( 0 == $this->current_member ) // loop has just started 984 984 do_action('loop_start'); … … 988 988 function bp_rewind_site_members() { 989 989 global $site_members_template; 990 990 991 991 return $site_members_template->rewind_members(); 992 992 } … … 1005 1005 1006 1006 // type: active ( default ) | random | newest | popular | online | alphabetical 1007 1007 1008 1008 if ( $max ) { 1009 1009 if ( $per_page > $max ) … … 1012 1012 1013 1013 $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max ); 1014 1014 1015 1015 return $site_members_template->has_members(); 1016 1016 } … … 1028 1028 function bp_site_members_pagination_count() { 1029 1029 global $bp, $site_members_template; 1030 1030 1031 1031 $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1; 1032 1032 $to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ; … … 1041 1041 function bp_get_site_members_pagination_links() { 1042 1042 global $site_members_template; 1043 1043 1044 1044 return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links ); 1045 1045 } 1046 1046 1047 function bp_the_site_member_user_id() { 1048 echo bp_get_the_site_member_user_id(); 1049 } 1050 function bp_get_the_site_member_user_id() { 1051 global $site_members_template; 1052 1053 return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id ); 1047 function bp_the_site_member_user_id() { 1048 echo bp_get_the_site_member_user_id(); 1049 } 1050 function bp_get_the_site_member_user_id() { 1051 global $site_members_template; 1052 1053 return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id ); 1054 1054 } 1055 1055 … … 1057 1057 echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() ); 1058 1058 } 1059 function bp_get_the_site_member_avatar() { 1060 global $site_members_template; 1059 function bp_get_the_site_member_avatar() { 1060 global $site_members_template; 1061 1061 1062 1062 return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb ); … … 1100 1100 return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) ); 1101 1101 } 1102 1102 1103 1103 function bp_the_site_member_add_friend_button() { 1104 1104 global $site_members_template; 1105 1105 1106 1106 if ( function_exists( 'bp_add_friend_button' ) ) { 1107 1107 echo bp_add_friend_button( $site_members_template->member->id ); … … 1111 1111 function bp_the_site_member_total_friend_count() { 1112 1112 global $site_members_template; 1113 1113 1114 1114 if ( !(int) $site_members_template->member->total_friends ) 1115 1115 return false; 1116 1116 1117 1117 echo bp_get_the_site_member_total_friend_count(); 1118 1118 } … … 1126 1126 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1127 1127 else 1128 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1129 } 1130 1128 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1129 } 1130 1131 1131 function bp_the_site_member_random_profile_data() { 1132 1132 global $site_members_template; … … 1165 1165 function bp_home_blog_url() { 1166 1166 global $bp, $current_blog; 1167 1167 1168 1168 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) { 1169 1169 $blog_id = $current_blog->blog_id; … … 1216 1216 function bp_get_loggedin_user_fullname() { 1217 1217 global $bp; 1218 return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname ); 1218 return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname ); 1219 1219 } 1220 1220 1221 1221 function bp_current_component() { 1222 1222 global $bp; 1223 return apply_filters( 'bp_current_component', $bp->current_component ); 1223 return apply_filters( 'bp_current_component', $bp->current_component ); 1224 1224 } 1225 1225 1226 1226 function bp_current_action() { 1227 1227 global $bp; 1228 return apply_filters( 'bp_current_action', $bp->current_action ); 1228 return apply_filters( 'bp_current_action', $bp->current_action ); 1229 1229 } 1230 1230 1231 1231 function bp_current_item() { 1232 1232 global $bp; 1233 return apply_filters( 'bp_current_item', $bp->current_item ); 1233 return apply_filters( 'bp_current_item', $bp->current_item ); 1234 1234 } 1235 1235 1236 1236 function bp_action_variables() { 1237 1237 global $bp; 1238 return apply_filters( 'bp_action_variables', $bp->action_variables ); 1238 return apply_filters( 'bp_action_variables', $bp->action_variables ); 1239 1239 } 1240 1240 … … 1244 1244 function bp_get_root_domain() { 1245 1245 global $bp; 1246 1246 1247 1247 return $bp->root_domain; 1248 1248 } … … 1252 1252 function bp_is_profile_component() { 1253 1253 global $bp; 1254 1254 1255 1255 if ( BP_XPROFILE_SLUG == $bp->current_component ) 1256 1256 return true; 1257 1257 1258 1258 return false; 1259 1259 } … … 1261 1261 function bp_is_activity_component() { 1262 1262 global $bp; 1263 1263 1264 1264 if ( BP_ACTIVITY_SLUG == $bp->current_component ) 1265 1265 return true; 1266 1267 return false; 1266 1267 return false; 1268 1268 } 1269 1269 1270 1270 function bp_is_blogs_component() { 1271 1271 global $bp; 1272 1272 1273 1273 if ( BP_BLOGS_SLUG == $bp->current_component ) 1274 1274 return true; 1275 1276 return false; 1275 1276 return false; 1277 1277 } 1278 1278 1279 1279 function bp_is_wire_component() { 1280 1280 global $bp; 1281 1281 1282 1282 if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) ) 1283 1283 return true; 1284 1285 return false; 1284 1285 return false; 1286 1286 } 1287 1287 1288 1288 function bp_is_messages_component() { 1289 1289 global $bp; 1290 1290 1291 1291 if ( BP_MESSAGES_SLUG == $bp->current_component ) 1292 1292 return true; 1293 1294 return false; 1293 1294 return false; 1295 1295 } 1296 1296 1297 1297 function bp_is_friends_component() { 1298 1298 global $bp; 1299 1299 1300 1300 if ( BP_FRIENDS_SLUG == $bp->current_component ) 1301 1301 return true; 1302 1303 return false; 1302 1303 return false; 1304 1304 } 1305 1305 1306 1306 function bp_is_groups_component() { 1307 1307 global $bp; 1308 1308 1309 1309 if ( BP_GROUPS_SLUG == $bp->current_component ) 1310 1310 return true; 1311 1312 return false; 1311 1312 return false; 1313 1313 } 1314 1314 1315 1315 function bp_is_settings_component() { 1316 1316 global $bp; 1317 1317 1318 1318 if ( BP_SETTINGS_SLUG == $bp->current_component ) 1319 1319 return true; 1320 1321 return false; 1320 1321 return false; 1322 1322 } 1323 1323 1324 1324 function bp_is_user_activity() { 1325 1325 global $bp; 1326 1326 1327 1327 if ( BP_ACTIVITY_SLUG == $bp->current_component && ( !$bp->current_action || 'my-activity' == $bp->current_action ) ) 1328 1328 return true; 1329 1330 return false; 1331 } 1329 1330 return false; 1331 } 1332 1332 1333 1333 function bp_is_user_friends_activity() { 1334 1334 global $bp; 1335 1335 1336 1336 if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action ) 1337 1337 return true; 1338 1339 return false; 1338 1339 return false; 1340 1340 } 1341 1341 1342 1342 function bp_is_user_profile() { 1343 1343 global $bp; 1344 1344 1345 1345 if ( BP_XPROFILE_SLUG == $bp->current_component ) 1346 1346 return true; 1347 1348 return false; 1347 1348 return false; 1349 1349 } 1350 1350 1351 1351 function bp_is_profile_edit() { 1352 1352 global $bp; 1353 1353 1354 1354 if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action ) 1355 1355 return true; 1356 1356 1357 1357 return false; 1358 1358 } … … 1360 1360 function bp_is_change_avatar() { 1361 1361 global $bp; 1362 1362 1363 1363 if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action ) 1364 1364 return true; 1365 1366 return false; 1365 1366 return false; 1367 1367 } 1368 1368 1369 1369 function bp_is_profile_wire() { 1370 1370 global $bp; 1371 1371 1372 1372 if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action ) 1373 1373 return true; 1374 1375 return false; 1374 1375 return false; 1376 1376 } 1377 1377 1378 1378 function bp_is_user_groups() { 1379 1379 global $bp; 1380 1380 1381 1381 if ( BP_GROUPS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-groups' == $bp->current_action ) ) 1382 1382 return true; 1383 1384 return false; 1383 1384 return false; 1385 1385 } 1386 1386 1387 1387 function bp_is_group_home() { 1388 1388 global $bp; 1389 1389 1390 1390 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1391 1391 return true; 1392 1393 return false; 1392 1393 return false; 1394 1394 } 1395 1395 1396 1396 function bp_is_group_create() { 1397 1397 global $bp; 1398 1398 1399 1399 if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action ) 1400 1400 return true; 1401 1401 1402 1402 return false; 1403 1403 } … … 1406 1406 function bp_is_group_admin_page() { 1407 1407 global $bp; 1408 1408 1409 1409 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action ) 1410 1410 return true; 1411 1412 return false; 1411 1412 return false; 1413 1413 } 1414 1414 1415 1415 function bp_is_group_wire() { 1416 1416 global $bp; 1417 1417 1418 1418 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action ) 1419 1419 return true; 1420 1421 return false; 1420 1421 return false; 1422 1422 } 1423 1423 1424 1424 function bp_is_group_forum() { 1425 1425 global $bp; 1426 1426 1427 1427 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action ) 1428 1428 return true; 1429 1430 return false; 1429 1430 return false; 1431 1431 } 1432 1432 1433 1433 function bp_is_group_forum_topic() { 1434 1434 global $bp; 1435 1435 1436 1436 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] ) 1437 1437 return true; 1438 1439 return false; 1438 1439 return false; 1440 1440 } 1441 1441 1442 1442 function bp_is_group_members() { 1443 1443 global $bp; 1444 1444 1445 1445 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action ) 1446 1446 return true; 1447 1448 return false; 1447 1448 return false; 1449 1449 } 1450 1450 1451 1451 function bp_is_group_invites() { 1452 1452 global $bp; 1453 1453 1454 1454 if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action ) 1455 1455 return true; 1456 1457 return false; 1456 1457 return false; 1458 1458 } 1459 1459 1460 1460 function bp_is_group_leave() { 1461 1461 global $bp; 1462 1462 1463 1463 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action ) 1464 1464 return true; 1465 1466 return false; 1465 1466 return false; 1467 1467 } 1468 1468 … … 1478 1478 function bp_is_user_blogs() { 1479 1479 global $bp; 1480 1480 1481 1481 if ( BP_BLOGS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-blogs' == $bp->current_action ) ) 1482 1482 return true; 1483 1484 return false; 1483 1484 return false; 1485 1485 } 1486 1486 1487 1487 function bp_is_user_recent_posts() { 1488 1488 global $bp; 1489 1489 1490 1490 if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action ) 1491 1491 return true; 1492 1493 return false; 1492 1493 return false; 1494 1494 } 1495 1495 1496 1496 function bp_is_user_recent_commments() { 1497 1497 global $bp; 1498 1498 1499 1499 if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action ) 1500 1500 return true; 1501 1502 return false; 1501 1502 return false; 1503 1503 } 1504 1504 1505 1505 function bp_is_create_blog() { 1506 1506 global $bp; 1507 1507 1508 1508 if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action ) 1509 1509 return true; 1510 1511 return false; 1510 1511 return false; 1512 1512 } 1513 1513 1514 1514 function bp_is_user_friends() { 1515 1515 global $bp; 1516 1516 1517 1517 if ( BP_FRIENDS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-friends' == $bp->current_action ) ) 1518 1518 return true; 1519 1520 return false; 1519 1520 return false; 1521 1521 } 1522 1522 1523 1523 function bp_is_friend_requests() { 1524 1524 global $bp; 1525 1525 1526 1526 if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action ) 1527 1527 return true; 1528 1529 return false; 1528 1529 return false; 1530 1530 } 1531 1531 1532 1532 function bp_is_messages_inbox() { 1533 1533 global $bp; 1534 1534 1535 1535 if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) ) 1536 1536 return true; 1537 1538 return false; 1537 1538 return false; 1539 1539 } 1540 1540 1541 1541 function bp_is_messages_sentbox() { 1542 1542 global $bp; 1543 1543 1544 1544 if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action ) 1545 1545 return true; 1546 1547 return false; 1546 1547 return false; 1548 1548 } 1549 1549 … … 1551 1551 function bp_is_notices() { 1552 1552 global $bp; 1553 1553 1554 1554 if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action ) 1555 1555 return true; 1556 1557 return false; 1556 1557 return false; 1558 1558 } 1559 1559 … … 1561 1561 function bp_is_messages_compose_screen() { 1562 1562 global $bp; 1563 1563 1564 1564 if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action ) 1565 1565 return true; 1566 1567 return false; 1566 1567 return false; 1568 1568 } 1569 1569 1570 1570 function bp_is_single_item() { 1571 1571 global $bp; 1572 1572 1573 1573 if ( $bp->is_single_item ) 1574 1574 return true; 1575 1575 1576 1576 return false; 1577 1577 } … … 1579 1579 function bp_is_activation_page() { 1580 1580 global $bp; 1581 1581 1582 1582 if ( BP_ACTIVATION_SLUG == $bp->current_component ) 1583 1583 return true; 1584 1585 return false; 1584 1585 return false; 1586 1586 } 1587 1587 1588 1588 function bp_is_register_page() { 1589 1589 global $bp; 1590 1590 1591 1591 if ( BP_REGISTER_SLUG == $bp->current_component ) 1592 1592 return true; 1593 1594 return false; 1593 1594 return false; 1595 1595 } 1596 1596 … … 1603 1603 global $bp; 1604 1604 1605 if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG ) 1606 $bp_classes[] = 'home-page'; 1607 1605 if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG ) 1606 $bp_classes[] = 'home-page'; 1607 1608 1608 if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() ) 1609 1609 $bp_classes[] = 'blog-page'; 1610 1610 1611 1611 if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() ) 1612 1612 $bp_classes[] = 'internal-page'; 1613 1613 1614 1614 if ( bp_is_directory() ) 1615 1615 $bp_classes[] = 'directory'; 1616 1616 1617 1617 if ( bp_is_user_profile() && !bp_is_blog_page() ) 1618 1618 $bp_classes[] = 'profile'; 1619 1619 1620 1620 if ( bp_is_activity_component() && !bp_is_blog_page() ) 1621 $bp_classes[] = 'activity'; 1621 $bp_classes[] = 'activity'; 1622 1622 1623 1623 if ( bp_is_blogs_component() && !bp_is_blog_page() ) … … 1628 1628 1629 1629 if ( bp_is_messages_component() && !bp_is_blog_page() ) 1630 $bp_classes[] = 'messages'; 1631 1630 $bp_classes[] = 'messages'; 1631 1632 1632 if ( bp_is_friends_component() && !bp_is_blog_page() ) 1633 1633 $bp_classes[] = 'friends'; 1634 1634 1635 1635 if ( bp_is_groups_component() && !bp_is_blog_page() ) 1636 1636 $bp_classes[] = 'groups'; … … 1638 1638 if ( bp_is_settings_component() && !bp_is_blog_page() ) 1639 1639 $bp_classes[] = 'settings'; 1640 1640 1641 1641 if ( bp_is_single_item() ) 1642 1642 $bp_classes[] = 'single-item'; 1643 1643 1644 1644 if ( bp_is_messages_inbox() ) 1645 1645 $bp_classes[] = 'inbox'; … … 1653 1653 if ( bp_is_notices() ) 1654 1654 $bp_classes[] = 'notices'; 1655 1655 1656 1656 if ( bp_is_friend_requests() ) 1657 1657 $bp_classes[] = 'friend-requests'; … … 1659 1659 if ( bp_is_user_friends() ) 1660 1660 $bp_classes[] = 'my-friends'; 1661 1661 1662 1662 if ( bp_is_create_blog() ) 1663 1663 $bp_classes[] = 'create-blog'; 1664 1664 1665 1665 if ( bp_is_user_recent_commments() ) 1666 1666 $bp_classes[] = 'recent-comments'; 1667 1667 1668 1668 if ( bp_is_user_recent_posts() ) 1669 1669 $bp_classes[] = 'recent-posts'; 1670 1670 1671 1671 if ( bp_is_user_blogs() && !bp_is_directory() ) 1672 1672 $bp_classes[] = 'my-blogs'; 1673 1673 1674 1674 if ( bp_is_user_groups() && !bp_is_directory() ) 1675 1675 $bp_classes[] = 'my-groups'; 1676 1676 1677 1677 if ( bp_is_group_leave() ) 1678 1678 $bp_classes[] = 'leave-group'; 1679 1679 1680 1680 if ( bp_is_group_invites() ) 1681 1681 $bp_classes[] = 'group-invites'; 1682 1682 1683 1683 if ( bp_is_group_members() ) 1684 1684 $bp_classes[] = 'group-members'; 1685 1685 1686 1686 if ( bp_is_group_forum_topic() ) 1687 1687 $bp_classes[] = 'group-forum-topic'; 1688 1688 1689 1689 if ( bp_is_group_forum() ) 1690 1690 $bp_classes[] = 'group-forum'; 1691 1691 1692 1692 if ( bp_is_group_wire() ) 1693 1693 $bp_classes[] = 'group-wire'; 1694 1694 1695 1695 if ( bp_is_group_admin_page() ) 1696 1696 $bp_classes[] = 'group-admin'; 1697 1697 1698 1698 if ( bp_is_group_create() ) 1699 1699 $bp_classes[] = 'group-create'; 1700 1700 1701 1701 if ( bp_is_group_home() ) 1702 1702 $bp_classes[] = 'group-home'; 1703 1703 1704 1704 if ( bp_is_profile_wire() ) 1705 1705 $bp_classes[] = 'profile-wire'; 1706 1706 1707 1707 if ( bp_is_change_avatar() ) 1708 1708 $bp_classes[] = 'change-avatar'; 1709 1709 1710 1710 if ( bp_is_profile_edit() ) 1711 1711 $bp_classes[] = 'profile-edit'; 1712 1712 1713 1713 if ( bp_is_user_friends_activity() ) 1714 1714 $bp_classes[] = 'friends-activity'; 1715 1715 1716 1716 if ( bp_is_user_activity() ) 1717 1717 $bp_classes[] = 'my-activity'; 1718 1718 1719 1719 if ( bp_is_register_page() ) 1720 1720 $bp_classes[] = 'registration'; 1721 1721 1722 1722 if ( bp_is_activation_page() ) 1723 1723 $bp_classes[] = 'activation'; 1724 1724 1725 1725 if ( is_user_logged_in() ) 1726 1726 $bp_classes[] = 'logged-in'; … … 1730 1730 if ( !empty( $bp->current_component ) ) 1731 1731 $bp_classes[] = $bp->current_component; 1732 1732 1733 1733 if ( !empty( $bp->current_action ) ) 1734 1734 $bp_classes[] = $bp->current_action; 1735 1735 } 1736 1736 1737 1737 /* We don't want WordPress blog classes to appear on non-blog pages. */ 1738 1738 if ( !bp_is_blog_page() || is_home() ) { … … 1743 1743 $wp_classes = array(); 1744 1744 } 1745 1745 1746 1746 /* Merge WP classes with BP classes */ 1747 1747 $classes = array_merge( (array) $bp_classes, (array) $wp_classes ); 1748 1748 1749 1749 /* Remove any duplicates */ 1750 1750 $classes = array_unique( $classes ); 1751 1751 1752 1752 return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes ); 1753 1753 } -
trunk/bp-core/bp-core-widgets.php
r1926 r2077 31 31 <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div> 32 32 <?php } ?> 33 33 34 34 <?php echo $after_widget; ?> 35 35 <?php … … 74 74 75 75 if ( is_active_widget( false, false, $this->id_base ) ) 76 wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') ); 76 wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') ); 77 77 } 78 78 79 79 function widget($args, $instance) { 80 80 global $bp; 81 81 82 82 extract( $args ); 83 83 84 84 echo $before_widget; 85 85 echo $before_title 86 . $widget_name 86 . $widget_name 87 87 . $after_title; ?> 88 88 … … 90 90 <div class="item-options" id="members-list-options"> 91 91 <span class="ajax-loader" id="ajax-loader-members"></span> 92 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> | 93 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> | 92 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> | 93 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> | 94 94 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a> 95 95 </div> 96 96 97 97 <ul id="members-list" class="item-list"> 98 98 <?php while ( bp_site_members() ) : bp_the_site_member(); ?> … … 109 109 110 110 <?php endwhile; ?> 111 </ul> 111 </ul> 112 112 <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?> 113 113 <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" /> 114 114 115 115 <?php else: ?> 116 116 … … 120 120 121 121 <?php endif; ?> 122 122 123 123 <?php echo $after_widget; ?> 124 124 <?php … … 151 151 function widget($args, $instance) { 152 152 global $bp; 153 153 154 154 extract( $args ); 155 155 156 156 echo $before_widget; 157 157 echo $before_title 158 . $widget_name 158 . $widget_name 159 159 . $after_title; ?> 160 161 <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?> 160 161 <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?> 162 162 <div class="avatar-block"> 163 163 <?php while ( bp_site_members() ) : bp_the_site_member(); ?> … … 166 166 </div> 167 167 <?php endwhile; ?> 168 </div> 168 </div> 169 169 <?php else: ?> 170 170 … … 174 174 175 175 <?php endif; ?> 176 176 177 177 <?php echo $after_widget; ?> 178 178 <?php … … 205 205 function widget($args, $instance) { 206 206 global $bp; 207 207 208 208 extract( $args ); 209 209 210 210 echo $before_widget; 211 211 echo $before_title 212 . $widget_name 212 . $widget_name 213 213 . $after_title; ?> 214 215 <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?> 214 215 <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?> 216 216 <div class="avatar-block"> 217 217 <?php while ( bp_site_members() ) : bp_the_site_member(); ?> … … 220 220 </div> 221 221 <?php endwhile; ?> 222 </div> 222 </div> 223 223 <?php else: ?> 224 224 … … 228 228 229 229 <?php endif; ?> 230 230 231 231 <?php echo $after_widget; ?> 232 232 <?php … … 256 256 257 257 check_ajax_referer('bp_core_widget_members'); 258 258 259 259 switch ( $_POST['filter'] ) { 260 260 case 'newest-members': … … 277 277 break; 278 278 } 279 279 280 280 if ( $users['users'] ) { 281 281 echo '0[[SPLIT]]'; // return valid result. 282 282 283 283 foreach ( (array) $users['users'] as $user ) { 284 284 ?> … … 292 292 <div class="item-meta"> 293 293 <span class="activity"> 294 <?php 294 <?php 295 295 if ( 'newest-members' == $_POST['filter'] ) { 296 296 echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) ); … … 308 308 </div> 309 309 </li> 310 <?php 310 <?php 311 311 } 312 312 } else { -
trunk/bp-core/deprecated/bp-core-deprecated.php
r2070 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 25 25 function bp_core_deprecated_globals() { 26 26 global $bp; 27 27 28 28 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 29 29 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 65 65 function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 66 66 global $current_site; 67 67 68 68 ?> 69 69 <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3> … … 71 71 <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?> 72 72 </p> 73 73 74 74 <div id="blog-details-fields"> 75 75 <?php 76 76 77 77 // Blog name 78 78 if ( 'no' == constant( "VHOST" ) ) … … 90 90 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />'; 91 91 } 92 92 93 93 if ( !is_user_logged_in() ) { 94 94 echo '<p class="help-text">'; … … 105 105 // Blog Title 106 106 ?> 107 <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label> 107 <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label> 108 108 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 109 109 <p class="error"><?php echo $errmsg ?></p> … … 114 114 <p> 115 115 <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label> 116 <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?> 116 <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?> 117 117 <label class="checkbox" for="blog_public_on"> 118 118 <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> … … 153 153 <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> 154 154 <p class="error"><?php echo $errmsg ?></p> 155 <?php } ?> 155 <?php } ?> 156 156 <input name="user_email" type="text" id="user_email" value="<?php echo wp_specialchars($user_email, 1) ?>" maxlength="200" /><p class="help-text"><?php _e( '(We’ll send your password to this address, so <strong>triple-check it</strong>.)', 'buddypress' ) ?></p> 157 157 <?php … … 160 160 } 161 161 echo '</div>'; 162 162 163 163 echo '<div id="extra-fields">'; 164 164 do_action( 'signup_extra_fields', $errors ); … … 172 172 function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') { 173 173 global $current_user, $current_site; 174 174 175 175 if ( ! is_wp_error($errors) ) { 176 176 $errors = new WP_Error(); … … 186 186 <h3><?php _e( "You're already registered!", 'buddypress' )?></h3> 187 187 <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?> 188 188 189 189 190 190 <p><?php _e( "There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly. If you’re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress' ) ?></p> 191 191 192 192 <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>"> 193 193 <input type="hidden" name="stage" value="gimmeanotherblog" /> … … 254 254 255 255 ?> 256 256 257 257 <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>"> 258 258 <p id="intro-text"><?php _e( 'Registering for a new account is easy, just fill in the form below and you\'ll be a new member in no time at all.', 'buddypress' ) ?></p> 259 259 <input type="hidden" name="stage" value="validate-user-signup" /> 260 260 <?php do_action( "signup_hidden_fields" ); ?> 261 261 262 262 <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?> 263 263 264 264 <?php if( 'blog' == $active_signup ) { ?> 265 265 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> … … 270 270 <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3> 271 271 <p id="blog-help-text"><?php _e( 'If you want to create your first blog, select the option below and you\'ll be asked for a few more details.', 'buddypress' ) ?></p> 272 272 273 273 <div id="blog-or-username-fields"> 274 274 <p> 275 275 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> /> 276 <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label> 276 <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label> 277 277 </p> 278 278 279 279 <p> 280 <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> /> 280 <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> /> 281 281 <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label> 282 282 </p> … … 378 378 ?> 379 379 <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3> 380 380 381 381 <p><?php printf( __('But, before you can start using your blog, <strong>you must activate it</strong>. Check your inbox at <strong>%s</strong> and click the link given. It should arrive within 30 minutes.', 'buddypress' ), $user_email) ?></p> 382 382 <p> </p> 383 383 384 384 <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3> 385 385 <p> … … 465 465 function bp_core_activation_set_headers() { 466 466 global $wp_object_cache; 467 467 468 468 define( "WP_INSTALLING", true ); 469 469 470 470 require_once( ABSPATH . WPINC . '/registration.php'); 471 471 472 472 if( is_object( $wp_object_cache ) ) 473 473 $wp_object_cache->cache_enabled = false; 474 474 475 475 do_action("activate_header"); 476 476 } … … 478 478 function bp_core_activation_do_activation() { 479 479 global $current_site, $blog_id, $user_id; ?> 480 480 481 481 <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?> 482 482 483 483 <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3> 484 484 485 485 <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p> 486 486 487 487 <div class="field-box"> 488 488 <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php"> … … 496 496 </form> 497 497 </div> 498 498 499 499 <?php } else { 500 500 501 501 $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key']; 502 502 $result = wpmu_activate_signup($key); 503 503 504 504 if ( is_wp_error($result) ) { 505 505 if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) { 506 506 $signup = $result->get_error_data(); 507 507 ?> 508 508 509 509 <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3> 510 510 511 511 <?php 512 512 _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' ); 513 513 514 514 } else { 515 515 ?> … … 522 522 523 523 $user = new WP_User( (int) $user_id); 524 524 525 525 ?> 526 526 527 527 <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3> 528 528 529 529 <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'buddypress' ), site_url( 'wp-login.php?redirect_to=' . site_url() ), site_url() ); ?></p> 530 530 531 531 <div class="field-box" id="signup-welcome"> 532 532 <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p> 533 533 <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p> 534 534 </div> 535 536 <?php 535 536 <?php 537 537 do_action( 'bp_activation_extras', $user_id, $meta ); 538 538 } … … 550 550 $activate_url = bp_activation_page( false ) ."?key=$key"; 551 551 } 552 552 553 553 $activate_url = clean_url($activate_url); 554 554 $admin_email = get_site_option( "admin_email" ); 555 555 556 556 if ( empty( $admin_email ) ) 557 557 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 558 558 559 559 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 560 560 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 561 561 $message = sprintf(__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) ); 562 562 $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path)); 563 563 564 564 wp_mail($user_email, $subject, $message, $message_headers); 565 565 566 566 // Return false to stop the original WPMU function from continuing 567 567 return false; … … 574 574 // Send email with activation link. 575 575 $admin_email = get_site_option( "admin_email" ); 576 576 577 577 if ( empty( $admin_email ) ) 578 578 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 579 579 580 580 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 581 581 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 582 582 $message = apply_filters( 'wpmu_signup_user_notification_email', sprintf( __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n", 'buddypress' ), clean_url( bp_activation_page( false ) . "?key=$key" ) ) ); 583 $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __( 'Activate %s', 'buddypress' ), $user ) ); 583 $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __( 'Activate %s', 'buddypress' ), $user ) ); 584 584 585 585 wp_mail( $user_email, $subject, $message, $message_headers ); 586 586 587 587 // Return false to stop the original WPMU function from continuing 588 588 return false; … … 632 632 function bp_loggedinuser_avatar( $width = false, $height = false ) { 633 633 global $bp; 634 634 635 635 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) ); 636 636 } … … 639 639 function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) { 640 640 global $bp; 641 641 642 642 echo apply_filters( 'bp_get_options_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) ); 643 643 } … … 667 667 <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p> 668 668 <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress' ) ?></p> 669 670 <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data"> 669 670 <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data"> 671 671 672 672 <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?> 673 673 674 674 <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3> 675 675 676 676 <?php bp_displayed_user_avatar( 'type=full') ?> 677 677 <?php bp_displayed_user_avatar( 'type=thumb' ) ?> 678 678 679 679 <p> 680 <input type="file" name="file" id="file" /> 680 <input type="file" name="file" id="file" /> 681 681 <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" /> 682 682 <input type="hidden" name="action" id="action" value="bp_avatar_upload" /> … … 684 684 685 685 <?php wp_nonce_field( 'bp_avatar_upload' ) ?> 686 686 687 687 <?php endif; ?> 688 688 689 689 <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?> 690 690 691 691 <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3> 692 692 693 693 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" /> 694 694 695 695 <div id="avatar-crop-pane" style="width:100px;height:100px;overflow:hidden;"> 696 696 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" /> … … 698 698 699 699 <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" /> 700 700 701 701 <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" /> 702 702 <input type="hidden" id="x" name="x" /> … … 706 706 707 707 <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?> 708 708 709 709 <?php endif; ?> 710 710 711 711 </form> <?php 712 712 } … … 714 714 function bp_core_handle_avatar_upload($file) { 715 715 global $wp_upload_error; 716 716 717 717 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 718 718 719 719 // Change the upload file location to /avatars/user_id 720 720 add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' ); … … 757 757 function bp_core_get_buddypress_themes() { 758 758 global $wp_themes; 759 759 760 760 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 761 761 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 762 762 return false; 763 763 764 764 /* Remove the cached WP themes first */ 765 765 $wp_existing_themes = &$wp_themes; 766 766 $wp_themes = null; 767 767 768 768 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' ); 769 769 $themes = get_themes(); 770 770 771 771 if ( $themes ) { 772 772 foreach ( $themes as $name => $values ) { 773 773 if ( $name == 'BuddyPress Default Home Theme' ) 774 774 continue; 775 775 776 776 $member_themes[] = array( 777 777 'name' => $name, … … 781 781 } 782 782 } 783 783 784 784 /* Restore the cached WP themes */ 785 785 $wp_themes = $wp_existing_themes; 786 786 787 787 return $member_themes; 788 788 } … … 807 807 function bp_core_force_buddypress_theme( $template ) { 808 808 global $is_member_page, $bp; 809 809 810 810 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 811 811 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 812 812 return $template; 813 813 814 814 if ( $is_member_page ) { 815 815 $member_theme = get_site_option( 'active-member-theme' ); 816 816 817 817 if ( empty( $member_theme ) ) 818 818 $member_theme = 'bpmember'; … … 830 830 function bp_core_force_buddypress_stylesheet( $stylesheet ) { 831 831 global $is_member_page; 832 832 833 833 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 834 834 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 836 836 837 837 $member_theme = get_site_option( 'active-member-theme' ); 838 838 839 839 if ( empty( $member_theme ) ) 840 840 $member_theme = 'bpmember'; … … 859 859 860 860 /* Enqueue the structure CSS file to give basic positional formatting for components */ 861 wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' ); 861 wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' ); 862 862 } 863 863 add_action( 'bp_styles', 'bp_core_add_structure_css' ); … … 868 868 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 869 869 return false; 870 870 871 871 // Enable a sitewide CSS file that will apply styles to both the home blog theme 872 872 // and the member theme. 873 873 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) ) 874 874 wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ); 875 875 876 876 wp_print_styles(); 877 877 } … … 886 886 if ( defined( 'BP_DISABLE_ADMIN_BAR') ) 887 887 return false; 888 888 889 889 if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) { 890 890 wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css' ) ); 891 891 892 892 if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/deprecated/css/admin-bar-rtl.css' ) ) 893 wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' ); 893 wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' ); 894 894 } 895 895 } … … 902 902 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 903 903 return $template; 904 904 905 905 wp_enqueue_script( 'jquery' ); 906 906 wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/deprecated/js/jquery/jquery.livequery.pack.js', 'jquery' ); … … 914 914 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 915 915 return $template; 916 916 917 917 wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/deprecated/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) ); 918 918 } 919 add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' ); 919 add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' ); 920 920 921 921 /*** END DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/ … … 925 925 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 926 926 return false; 927 927 928 928 check_ajax_referer('directory_members'); 929 929 930 930 locate_template( array( 'directories/members/members-loop.php' ), true ); 931 931 } … … 935 935 function bp_login_bar() { 936 936 global $bp; 937 937 938 938 if ( !is_user_logged_in() ) : ?> 939 939 940 940 <form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post"> 941 941 <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" /> 942 942 <input type="password" name="pwd" id="user_pass" class="input" value="" /> 943 943 944 944 <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" /> 945 946 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/> 945 946 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/> 947 947 <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" /> 948 948 949 949 <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" /> 950 950 <input type="hidden" name="testcookie" value="1" /> 951 951 952 952 <?php do_action( 'bp_login_bar_logged_out' ) ?> 953 953 </form> 954 954 955 955 <?php else : ?> 956 956 957 957 <div id="logout-link"> 958 958 <?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?> 959 959 <?php bp_loggedinuser_link() ?> 960 <?php 960 <?php 961 961 if ( function_exists('wp_logout_url') ) { 962 962 $logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 963 963 } else { 964 $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 965 } 966 964 $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 965 } 966 967 967 echo apply_filters( 'bp_logout_link', $logout_link ); 968 968 ?> 969 969 970 970 <?php do_action( 'bp_login_bar_logged_in' ) ?> 971 971 </div> 972 972 973 973 <?php endif; 974 974 } … … 977 977 function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) { 978 978 global $bp; 979 979 980 980 if ( !$user_has_access && !bp_is_home() ) 981 981 return false; 982 982 983 983 if ( $admin_only && !is_site_admin() ) 984 984 return false; … … 988 988 add_action( 'wp', $function, 3 ); 989 989 } 990 990 991 991 if ( $slug ) 992 992 $bp->current_action = $slug; … … 997 997 function bp_get_userbar( $hide_on_directory = true ) { 998 998 global $bp; 999 999 1000 1000 if ( $hide_on_directory && $bp->is_directory ) 1001 1001 return false; 1002 1002 1003 1003 load_template( TEMPLATEPATH . '/userbar.php' ); 1004 1004 } … … 1007 1007 function bp_get_optionsbar( $hide_on_directory = true ) { 1008 1008 global $bp; 1009 1009 1010 1010 if ( $hide_on_directory && $bp->is_directory ) 1011 1011 return false; 1012 1012 1013 1013 load_template( TEMPLATEPATH . '/optionsbar.php' ); 1014 1014 } -
trunk/bp-forums.php
r2033 r2077 4 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 5 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 6 6 7 7 if ( !defined( 'BP_FORUMS_SLUG' ) ) 8 8 define( 'BP_FORUMS_SLUG', 'forums' ); … … 19 19 /* For internal identification */ 20 20 $bp->forums->id = 'forums'; 21 21 22 22 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 23 23 $bp->forums->bbconfig = get_site_option( 'bb-config-location' ); 24 24 $bp->forums->slug = BP_FORUMS_SLUG; 25 25 26 26 /* Register this in the active components array */ 27 27 $bp->active_components[$bp->forums->slug] = $bp->forums->id; … … 34 34 function bp_forums_is_installed_correctly() { 35 35 global $bp; 36 36 37 37 if ( file_exists( $bp->forums->bbconfig ) ) 38 38 return true; 39 39 40 40 return false; 41 41 } … … 53 53 if ( (int) get_site_option( 'bp-disable-forum-directory' ) || !function_exists( 'groups_install' ) ) 54 54 return false; 55 55 56 56 if ( !bp_forums_is_installed_correctly() ) { 57 57 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 58 58 bp_core_redirect( $bp->root_domain ); 59 59 } 60 60 61 61 $bp->is_directory = true; 62 63 do_action( 'bbpress_init' ); 62 63 do_action( 'bbpress_init' ); 64 64 do_action( 'bp_forums_directory_forums_setup' ); 65 65 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) ); … … 70 70 function bp_forums_add_admin_menu() { 71 71 global $bp; 72 72 73 73 if ( !is_site_admin() ) 74 74 return false; 75 75 76 76 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 77 77 78 78 /* Add the administration tab under the "Site Admin" tab for site administrators */ 79 79 add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); … … 90 90 function bp_forums_new_forum( $args = '' ) { 91 91 do_action( 'bbpress_init' ); 92 93 $defaults = array( 94 'forum_name' => '', 95 'forum_desc' => '', 96 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 97 'forum_order' => false, 92 93 $defaults = array( 94 'forum_name' => '', 95 'forum_desc' => '', 96 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 97 'forum_order' => false, 98 98 'forum_is_category' => 0 99 99 ); … … 101 101 $r = wp_parse_args( $args, $defaults ); 102 102 extract( $r, EXTR_SKIP ); 103 103 104 104 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 ) ); 105 105 } … … 107 107 function bp_forums_get_forum_topicpost_count( $forum_id ) { 108 108 global $wpdb, $bbdb; 109 109 110 110 do_action( 'bbpress_init' ); 111 111 … … 118 118 function bp_forums_get_forum_topics( $args = '' ) { 119 119 global $bp; 120 121 do_action( 'bbpress_init' ); 122 120 121 do_action( 'bbpress_init' ); 122 123 123 $defaults = array( 124 124 'type' => 'newest', 125 'forum_id' => false, 126 'page' => 1, 127 'per_page' => 15, 125 'forum_id' => false, 126 'page' => 1, 127 'per_page' => 15, 128 128 'exclude' => false, 129 129 'show_stickies' => 'all', 130 130 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on. 131 131 ); 132 132 133 133 $r = wp_parse_args( $args, $defaults ); 134 134 extract( $r, EXTR_SKIP ); … … 139 139 $topics = $query->results; 140 140 break; 141 141 142 142 case 'popular': 143 143 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 144 144 $topics =& $query->results; 145 145 break; 146 146 147 147 case 'unreplied': 148 148 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 149 149 $topics =& $query->results; 150 break; 151 150 break; 151 152 152 case 'personal': 153 153 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' ); 154 154 $topics =& $query->results; 155 155 break; 156 156 157 157 case 'tag': 158 158 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); … … 167 167 do_action( 'bbpress_init' ); 168 168 169 $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 169 $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 170 170 171 171 return $query->results[0]; … … 179 179 function bp_forums_new_topic( $args = '' ) { 180 180 global $bp; 181 182 do_action( 'bbpress_init' ); 183 181 182 do_action( 'bbpress_init' ); 183 184 184 $defaults = array( 185 185 'topic_title' => '', … … 198 198 $r = wp_parse_args( $args, $defaults ); 199 199 extract( $r, EXTR_SKIP ); 200 200 201 201 if ( empty( $topic_slug ) ) 202 202 $topic_slug = sanitize_title( $topic_title ); 203 203 204 204 if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) ) 205 205 return false; … … 208 208 if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) ) 209 209 return false; 210 210 211 211 return $topic_id; 212 212 } … … 214 214 function bp_forums_update_topic( $args = '' ) { 215 215 global $bp; 216 217 do_action( 'bbpress_init' ); 218 216 217 do_action( 'bbpress_init' ); 218 219 219 $defaults = array( 220 220 'topic_id' => false, … … 225 225 $r = wp_parse_args( $args, $defaults ); 226 226 extract( $r, EXTR_SKIP ); 227 227 228 228 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 229 229 return false; 230 230 231 231 if ( !$post = bb_get_first_post( $topic_id ) ) 232 232 return false; … … 235 235 if ( !$post = bb_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) 236 236 return false; 237 237 238 238 return bp_forums_get_topic_details( $topic_id ); 239 239 } … … 241 241 function bp_forums_sticky_topic( $args = '' ) { 242 242 global $bp; 243 244 do_action( 'bbpress_init' ); 245 243 244 do_action( 'bbpress_init' ); 245 246 246 $defaults = array( 247 247 'topic_id' => false, … … 251 251 $r = wp_parse_args( $args, $defaults ); 252 252 extract( $r, EXTR_SKIP ); 253 253 254 254 if ( 'stick' == $mode ) 255 255 return bb_stick_topic( $topic_id ); … … 262 262 function bp_forums_openclose_topic( $args = '' ) { 263 263 global $bp; 264 265 do_action( 'bbpress_init' ); 266 264 265 do_action( 'bbpress_init' ); 266 267 267 $defaults = array( 268 268 'topic_id' => false, … … 272 272 $r = wp_parse_args( $args, $defaults ); 273 273 extract( $r, EXTR_SKIP ); 274 274 275 275 if ( 'close' == $mode ) 276 276 return bb_close_topic( $topic_id ); … … 283 283 function bp_forums_delete_topic( $args = '' ) { 284 284 global $bp; 285 286 do_action( 'bbpress_init' ); 287 285 286 do_action( 'bbpress_init' ); 287 288 288 $defaults = array( 289 289 'topic_id' => false … … 296 296 } 297 297 298 /* Post Functions */ 298 /* Post Functions */ 299 299 300 300 function bp_forums_get_topic_posts( $args = '' ) { 301 301 do_action( 'bbpress_init' ); 302 303 $defaults = array( 304 'topic_id' => false, 302 303 $defaults = array( 304 'topic_id' => false, 305 305 'page' => 1, 306 306 'per_page' => 15, … … 321 321 function bp_forums_delete_post( $args = '' ) { 322 322 global $bp; 323 324 do_action( 'bbpress_init' ); 325 323 324 do_action( 'bbpress_init' ); 325 326 326 $defaults = array( 327 327 'post_id' => false … … 331 331 extract( $r, EXTR_SKIP ); 332 332 333 return bb_delete_post( $post_id, 1 ); 333 return bb_delete_post( $post_id, 1 ); 334 334 } 335 335 336 336 function bp_forums_insert_post( $args = '' ) { 337 337 global $bp; 338 339 do_action( 'bbpress_init' ); 340 341 $defaults = array( 342 'post_id' => false, 338 339 do_action( 'bbpress_init' ); 340 341 $defaults = array( 342 'post_id' => false, 343 343 'topic_id' => false, 344 344 'post_text' => '', … … 352 352 $r = wp_parse_args( $args, $defaults ); 353 353 extract( $r, EXTR_SKIP ); 354 354 355 355 if ( !$post = bp_forums_get_post( $post_id ) ) 356 356 $post_id = false; … … 358 358 if ( !isset( $topic_id ) ) 359 359 $topic_id = $post->topic_id; 360 360 361 361 if ( empty( $post_text ) ) 362 362 $post_text = $post->post_text; 363 363 364 364 if ( !isset( $post_time ) ) 365 365 $post_time = $post->post_time; … … 378 378 function bp_forums_filter_caps( $allcaps ) { 379 379 global $bp, $wp_roles, $bb_table_prefix; 380 380 381 381 $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' ); 382 382 383 383 if ( empty( $bb_cap ) ) 384 384 return $allcaps; 385 385 386 386 $bb_cap = array_keys($bb_cap); 387 387 $bb_cap = $wp_roles->get_role( $bb_cap[0] ); 388 388 $bb_cap = $bb_cap->capabilities; 389 389 390 390 return array_merge( (array) $allcaps, (array) $bb_cap ); 391 391 } -
trunk/bp-forums/bp-forums-admin.php
r1960 r2077 1 1 <?php 2 2 3 function bp_forums_bbpress_admin() { 3 function bp_forums_bbpress_admin() { 4 4 global $bp; 5 5 ?> … … 7 7 8 8 <h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2> 9 9 10 10 <?php if ( isset( $_POST['submit'] ) ) : ?> 11 11 <div id="message" class="updated fade"> … … 15 15 16 16 <?php 17 17 18 18 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) { 19 19 update_site_option( 'bb-config-location', false ); … … 22 22 <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), site_url( 'wp-admin/admin.php?page=bb-forums-setup&reinstall=1' ) ); ?> 23 23 <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p> 24 <?php 24 <?php 25 25 } 26 26 ?> … … 29 29 } 30 30 31 function bp_forums_bbpress_install_wizard() { 31 function bp_forums_bbpress_install_wizard() { 32 32 $post_url = site_url( 'wp-admin/admin.php?page=bb-forums-setup' ); 33 33 34 switch( $_REQUEST['step'] ) { 34 switch( $_REQUEST['step'] ) { 35 35 case 'existing': 36 36 if ( 1 == (int)$_REQUEST['doinstall'] ) { … … 53 53 <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?> 54 54 </form> 55 <?php 55 <?php 56 56 } 57 57 break; 58 58 59 59 case 'new': 60 60 if ( 1 == (int)$_REQUEST['doinstall'] ) { 61 61 $result = bp_forums_bbpress_install(); 62 62 63 63 switch ( $result ) { 64 64 case 1: … … 80 80 } 81 81 break; 82 83 default: 82 83 default: 84 84 if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?> 85 85 <div id="message" class="error"> … … 87 87 </div> 88 88 <?php } else { ?> 89 89 90 90 <p><?php _e( 'Forums in BuddyPress make use of a bbPress installation to function. You can choose to either let BuddyPress set up a new bbPress install, or use an already existing bbPress install. Please choose one of the options below.', 'buddypress' ) ?></p> 91 91 92 92 <a class="button" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Set up a new bbPress installation', 'buddypress' ) ?></a> 93 93 <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use an existing bbPress installation', 'buddypress' ) ?></a> 94 94 95 <?php } 95 <?php } 96 96 break; 97 97 } … … 100 100 function bp_forums_configure_existing_install() { 101 101 global $wpdb, $bbdb; 102 102 103 103 check_admin_referer( 'bp_forums_existing_install_init' ); 104 104 105 105 /* Sanitize $_REQUEST['bbconfigloc'] */ 106 106 $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] ); 107 107 108 108 if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) { 109 109 if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) ) 110 110 $_REQUEST['bbconfigloc'] .= '/'; 111 111 112 112 $_REQUEST['bbconfigloc'] .= 'bb-config.php'; 113 113 } … … 117 117 118 118 update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 119 119 120 120 return true; 121 121 } … … 123 123 function bp_forums_bbpress_install() { 124 124 global $wpdb, $bbdb; 125 125 126 126 check_admin_referer( 'bp_forums_new_install_init' ); 127 127 … … 145 145 ) 146 146 ); 147 147 148 148 /* Add the custom user and usermeta entries to the config file */ 149 149 if ( $initial_write == 1 ) { … … 154 154 155 155 $file = substr( $file, 0, -2 ); 156 $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";'; 156 $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";'; 157 157 $file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";'; 158 158 $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";'; 159 159 $file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";'; 160 160 $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';'; 161 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");'; 162 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");'; 163 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");'; 164 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 161 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");'; 162 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");'; 163 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");'; 164 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 165 165 $file .= "\n\n" . '?>'; 166 166 167 167 if ( $initial_write == 1 ) { 168 168 $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' ); … … 189 189 return -2; 190 190 } 191 191 192 192 // Get the existing lines in the file 193 193 $lines = file( $file_source ); … … 205 205 } 206 206 } 207 207 208 208 $writable = true; 209 209 if ( file_exists( $file_target ) ) { -
trunk/bp-forums/bp-forums-bbpress.php
r1905 r2077 5 5 global $bb, $bbdb, $bb_table_prefix, $bb_current_user; 6 6 global $bb_roles, $wp_taxonomy_object; 7 7 8 8 /* Return if we've already run this function. */ 9 9 if ( is_object( $bbdb ) && is_object( $bb_roles ) ) 10 10 return; 11 11 12 12 if ( !bp_forums_is_installed_correctly() ) 13 13 return false; 14 14 15 15 define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' ); 16 16 define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' ); … … 20 20 require_once( BB_PATH . BB_INC . 'class.bb-query.php' ); 21 21 require_once( BB_PATH . BB_INC . 'class.bb-walker.php' ); 22 22 23 23 require_once( BB_PATH . BB_INC . 'functions.bb-core.php' ); 24 24 require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' ); … … 31 31 require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' ); 32 32 require_once( BB_PATH . BB_INC . 'functions.bb-template.php' ); 33 33 34 34 require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' ); 35 35 require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' ); 36 36 37 37 $bb = new stdClass(); 38 38 require_once( $bp->forums->bbconfig ); … … 40 40 // Setup the global database connection 41 41 $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST ); 42 42 43 43 /* Set the table names */ 44 44 $bbdb->forums = $bb_table_prefix . 'forums'; … … 49 49 $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy'; 50 50 $bbdb->topics = $bb_table_prefix . 'topics'; 51 51 52 52 if ( isset( $bb->custom_user_table ) ) 53 53 $bbdb->users = $bb->custom_user_table; 54 54 else 55 55 $bbdb->users = $wpdb->users; 56 56 57 57 if ( isset( $bb->custom_user_meta_table ) ) 58 58 $bbdb->usermeta = $bb->custom_user_meta_table; 59 59 else 60 60 $bbdb->usermeta = $wpdb->usermeta; 61 61 62 62 $bbdb->prefix = $bb_table_prefix; 63 63 … … 67 67 if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) 68 68 require_once( ABSPATH . 'wp-admin/upgrade-functions.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 73 $bb_roles =& $wp_roles; … … 84 84 if ( !isset( $wp_taxonomy_object ) ) 85 85 $wp_taxonomy_object = new BB_Taxonomy( $bbdb ); 86 86 87 87 $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' ); 88 88 … … 96 96 97 97 dbDelta( $bb_queries ); 98 98 99 99 require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' ); 100 100 bb_update_db_version(); 101 101 102 102 /* Set the site admins as the keymasters */ 103 103 $site_admins = get_site_option( 'site_admins', array('admin') ); … … 107 107 // Create the first forum. 108 108 bb_new_forum( array( 'forum_name' => 'Default Forum' ) ); 109 109 110 110 // Set the site URI 111 111 bb_update_option( 'uri', BB_URL ); … … 129 129 $args = wp_parse_args( $args, $defaults ); 130 130 extract( $args, EXTR_SKIP ); 131 131 132 132 return update_usermeta( $id, $meta_key, $meta_value ); 133 133 } -
trunk/bp-forums/bp-forums-filters.php
r2019 r2077 38 38 $allowedtags['p'] = array(); 39 39 $allowedtags['br'] = array(); 40 40 41 41 return $allowedtags; 42 42 } … … 45 45 function bp_forums_filter_tag_link( $link, $tag, $page, $context ) { 46 46 global $bp; 47 47 48 48 return apply_filters( 'bp_forums_filter_tag_link', $bp->root_domain . '/' . $bp->forums->slug . '/tag/' . $tag . '/' ); 49 49 } -
trunk/bp-forums/bp-forums-templatetags.php
r2012 r2077 6 6 var $topics; 7 7 var $topic; 8 8 9 9 var $in_the_loop; 10 10 11 11 var $pag_page; 12 12 var $pag_num; 13 13 var $pag_links; 14 14 var $total_topic_count; 15 15 16 16 var $single_topic = false; 17 17 18 18 var $sort_by; 19 19 var $order; 20 20 21 21 function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ) { 22 22 global $bp; … … 24 24 $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1; 25 25 $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page; 26 26 27 27 /* Only show stickies if we are viewing a single group forum, otherwise we could end up with hundreds globally */ 28 28 if ( $no_stickies ) … … 33 33 $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 34 34 break; 35 35 36 36 case 'popular': 37 37 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 38 38 break; 39 39 40 40 case 'unreplied': 41 41 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 42 42 break; 43 43 44 44 case 'personal': 45 45 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 46 46 break; 47 47 48 48 case 'tag': 49 49 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 50 break; 50 break; 51 51 } 52 52 53 53 $this->topics = apply_filters( 'bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies ); 54 54 55 55 if ( !(int)$this->topics ) { 56 56 $this->topic_count = 0; … … 63 63 $topic_count = (int)groups_total_public_forum_topic_count( $type ); 64 64 } else { 65 $topic_count = count( $this->topics ); 65 $topic_count = count( $this->topics ); 66 66 } 67 67 68 68 if ( !$max || $max >= $topic_count ) 69 69 $this->total_topic_count = $topic_count; … … 78 78 } else { 79 79 $this->topic_count = count( $this->topics ); 80 } 80 } 81 81 } 82 82 … … 90 90 $stickies[] = $topic; 91 91 else 92 $standard[] = $topic; 92 $standard[] = $topic; 93 93 } 94 94 $this->topics = array_merge( (array)$stickies, (array)$standard ); … … 105 105 )); 106 106 } 107 107 108 108 function has_topics() { 109 109 if ( $this->topic_count ) 110 110 return true; 111 111 112 112 return false; 113 113 } 114 114 115 115 function next_topic() { 116 116 $this->current_topic++; 117 117 $this->topic = $this->topics[$this->current_topic]; 118 118 119 119 return $this->topic; 120 120 } 121 121 122 122 function rewind_topics() { 123 123 $this->current_topic = -1; … … 126 126 } 127 127 } 128 129 function user_topics() { 128 129 function user_topics() { 130 130 if ( $this->current_topic + 1 < $this->topic_count ) { 131 131 return true; … … 139 139 return false; 140 140 } 141 141 142 142 function the_topic() { 143 143 global $topic; … … 146 146 $this->topic = $this->next_topic(); 147 147 $this->topic = (object)$this->topic; 148 148 149 149 if ( $this->current_topic == 0 ) // loop has just started 150 150 do_action('loop_start'); … … 154 154 function bp_has_forum_topics( $args = '' ) { 155 155 global $forum_template, $bp; 156 156 157 157 $defaults = array( 158 158 'type' => 'newest', … … 175 175 return false; 176 176 } 177 177 178 178 /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */ 179 179 if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) ) … … 183 183 if ( $bp->is_directory && !empty( $_GET['fs'] ) ) 184 184 $filter = $_GET['fs']; 185 185 186 186 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ); 187 187 188 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); 188 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); 189 189 } 190 190 /* DEPRECATED use bp_has_forum_topics() */ … … 213 213 return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id ); 214 214 } 215 215 216 216 function bp_the_topic_title() { 217 217 echo bp_get_the_topic_title(); … … 256 256 function bp_get_the_topic_poster_avatar( $args = '' ) { 257 257 global $forum_template; 258 258 259 259 $defaults = array( 260 260 'type' => 'thumb', … … 266 266 extract( $r, EXTR_SKIP ); 267 267 268 return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 268 return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 269 269 } 270 270 … … 277 277 return apply_filters( 'bp_get_the_topic_poster_name', bp_core_get_userlink( $forum_template->topic->topic_poster ) ); 278 278 } 279 279 280 280 function bp_the_topic_object_id() { 281 281 echo bp_get_the_topic_object_id(); … … 286 286 return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id ); 287 287 } 288 288 289 289 function bp_the_topic_object_name() { 290 290 echo bp_get_the_topic_object_name(); … … 295 295 return apply_filters( 'bp_get_the_topic_object_name', $forum_template->topic->object_name ); 296 296 } 297 297 298 298 function bp_the_topic_object_slug() { 299 299 echo bp_get_the_topic_object_slug(); … … 304 304 return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug ); 305 305 } 306 306 307 307 function bp_the_topic_object_permalink() { 308 308 echo bp_get_the_topic_object_permalink(); … … 310 310 function bp_get_the_topic_object_permalink() { 311 311 global $bp, $forum_template; 312 312 313 313 /* Currently this will only work with group forums, extended support in the future */ 314 314 return apply_filters( 'bp_get_the_topic_object_permalink', $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/forum/' ); 315 315 } 316 316 317 317 function bp_the_topic_last_poster_name() { 318 318 echo bp_get_the_topic_last_poster_name(); … … 323 323 return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template->topic->topic_last_poster ) ); 324 324 } 325 325 326 326 function bp_the_topic_object_avatar( $args = '' ) { 327 327 echo bp_get_the_topic_object_avatar( $args ); … … 339 339 extract( $r, EXTR_SKIP ); 340 340 341 return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) ); 342 } 343 341 return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) ); 342 } 343 344 344 function bp_the_topic_last_poster_avatar( $args = '' ) { 345 345 echo bp_get_the_topic_last_poster_avatar( $args ); … … 357 357 extract( $r, EXTR_SKIP ); 358 358 359 return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 359 return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 360 360 } 361 361 … … 368 368 return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time ); 369 369 } 370 370 371 371 function bp_the_topic_time() { 372 372 echo bp_get_the_topic_time(); … … 432 432 return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d post', 'buddypress' ), $forum_template->topic->topic_posts ) ); 433 433 else 434 return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) ); 435 } 436 434 return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) ); 435 } 436 437 437 function bp_the_topic_total_posts() { 438 438 echo bp_get_the_topic_total_posts(); … … 440 440 function bp_get_the_topic_total_posts() { 441 441 global $forum_template; 442 442 443 443 return $forum_template->topic->topic_posts; 444 444 } 445 445 446 446 function bp_the_topic_tag_count() { 447 447 echo bp_get_the_topic_tag_count(); … … 458 458 function bp_get_the_topic_permalink() { 459 459 global $forum_template, $bp; 460 460 461 461 if ( $forum_template->topic->object_slug ) 462 462 $permalink = $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/'; … … 465 465 else 466 466 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_action . '/'; 467 467 468 468 return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug . '/' ); 469 469 } … … 477 477 return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) ); 478 478 } 479 479 480 480 function bp_the_topic_latest_post_excerpt( $args = '' ) { 481 481 echo bp_get_the_topic_latest_post_excerpt( $args ); … … 498 498 function bp_the_topic_time_since_last_post( $deprecated = true ) { 499 499 global $forum_template; 500 500 501 501 if ( !$deprecated ) 502 502 return bp_get_the_topic_time_since_last_post(); … … 515 515 function bp_get_the_topic_is_mine() { 516 516 global $bp, $forum_template; 517 517 518 518 return $bp->loggedin_user->id == $forum_template->topic->topic_poster; 519 519 } … … 523 523 } 524 524 function bp_get_the_topic_admin_links( $args = '' ) { 525 global $bp, $forum_template; 526 525 global $bp, $forum_template; 526 527 527 $defaults = array( 528 528 'seperator' => '|' … … 533 533 534 534 $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a>'; 535 535 536 536 if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) { 537 537 if ( 0 == (int)$forum_template->topic->topic_sticky ) … … 547 547 $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 548 548 } 549 549 550 550 return implode( ' ' . $seperator . ' ', (array) $links ); 551 551 } … … 557 557 function bp_get_the_topic_css_class() { 558 558 global $forum_template; 559 559 560 560 $class = false; 561 561 562 562 if ( $forum_template->current_topic % 2 == 1 ) 563 563 $class .= 'alt'; 564 564 565 565 if ( 1 == (int)$forum_template->topic->topic_sticky ) 566 566 $class .= ' sticky'; 567 567 568 568 if ( 0 == (int)$forum_template->topic->topic_open ) 569 569 $class .= ' closed'; 570 570 571 571 return trim( $class ); 572 572 } … … 577 577 function bp_get_my_forum_topics_link() { 578 578 global $bp; 579 579 580 580 return apply_filters( 'bp_get_my_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/personal/' ); 581 581 } … … 586 586 function bp_get_unreplied_forum_topics_link() { 587 587 global $bp; 588 588 589 589 return apply_filters( 'bp_get_unreplied_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/unreplied/' ); 590 590 } … … 596 596 function bp_get_popular_forum_topics_link() { 597 597 global $bp; 598 598 599 599 return apply_filters( 'bp_get_popular_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/popular/' ); 600 600 } … … 605 605 function bp_get_newest_forum_topics_link() { 606 606 global $bp; 607 607 608 608 return apply_filters( 'bp_get_newest_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/' ); 609 609 } … … 614 614 function bp_get_forum_topic_type() { 615 615 global $bp; 616 616 617 617 if ( !$bp->is_directory || !$bp->current_action ) 618 618 return 'newest'; 619 619 620 620 621 621 return apply_filters( 'bp_get_forum_topic_type', $bp->current_action ); 622 622 } 623 623 624 624 function bp_forums_tag_name() { 625 625 echo bp_get_forums_tag_name(); … … 627 627 function bp_get_forums_tag_name() { 628 628 global $bp; 629 629 630 630 if ( $bp->is_directory && $bp->forums->slug == $bp->current_component ) 631 return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] ); 631 return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] ); 632 632 } 633 633 … … 643 643 function bp_forum_pagination_count() { 644 644 global $bp, $forum_template; 645 645 646 646 $from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1; 647 $to_num = ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ); 648 647 $to_num = ( $from_num + ( $forum_template->pag_num - 1 ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ); 648 649 649 echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %d to %d (%d total topics)', 'buddypress' ), $from_num, $to_num, $forum_template->total_topic_count ) ); 650 650 ?> … … 655 655 function bp_is_edit_topic() { 656 656 global $bp; 657 657 658 658 if ( in_array( 'post', (array)$bp->action_variables ) && in_array( 'edit', (array)$bp->action_variables ) ) 659 659 return false; 660 660 661 661 return true; 662 662 } … … 668 668 var $posts; 669 669 var $post; 670 670 671 671 var $topic_id; 672 672 var $topic; 673 673 674 674 var $in_the_loop; 675 675 676 676 var $pag_page; 677 677 var $pag_num; 678 678 var $pag_links; 679 679 var $total_post_count; 680 680 681 681 var $single_post = false; 682 682 683 683 var $sort_by; 684 684 var $order; 685 685 686 686 function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) { 687 687 global $bp, $current_user, $forum_template; 688 688 689 689 $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1; 690 690 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 691 691 692 692 $this->topic_id = $topic_id; 693 693 $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id ); 694 694 695 695 $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) ); 696 696 697 697 if ( !$this->posts ) { 698 698 $this->post_count = 0; … … 724 724 )); 725 725 } 726 726 727 727 function has_posts() { 728 728 if ( $this->post_count ) 729 729 return true; 730 730 731 731 return false; 732 732 } 733 733 734 734 function next_post() { 735 735 $this->current_post++; 736 736 $this->post = $this->posts[$this->current_post]; 737 737 738 738 return $this->post; 739 739 } 740 740 741 741 function rewind_posts() { 742 742 $this->current_post = -1; … … 745 745 } 746 746 } 747 748 function user_posts() { 747 748 function user_posts() { 749 749 if ( $this->current_post + 1 < $this->post_count ) { 750 750 return true; … … 758 758 return false; 759 759 } 760 760 761 761 function the_post() { 762 762 global $post; … … 765 765 $this->post = $this->next_post(); 766 766 $this->post = (object)$this->post; 767 767 768 768 if ( $this->current_post == 0 ) // loop has just started 769 769 do_action('loop_start'); … … 773 773 function bp_has_forum_topic_posts( $args = '' ) { 774 774 global $topic_template, $bp; 775 775 776 776 $defaults = array( 777 777 'topic_id' => false, … … 815 815 function bp_get_the_topic_post_id() { 816 816 global $topic_template; 817 817 818 818 return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id ); 819 819 } … … 843 843 extract( $r, EXTR_SKIP ); 844 844 845 return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 845 return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 846 846 } 847 847 … … 855 855 global $topic_template; 856 856 857 return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) ); 857 return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) ); 858 858 } 859 859 … … 875 875 function bp_get_the_topic_post_is_mine() { 876 876 global $bp, $topic_template; 877 877 878 878 return $bp->loggedin_user->id == $topic_template->post->poster_id; 879 879 } … … 883 883 } 884 884 function bp_get_the_topic_post_admin_links( $args = '' ) { 885 global $topic_template; 886 885 global $topic_template; 886 887 887 /* Never show for the first post in a topic. */ 888 888 if ( 0 == $topic_template->current_post ) 889 889 return; 890 890 891 891 $defaults = array( 892 892 'seperator' => '|' … … 907 907 function bp_get_the_topic_post_edit_text() { 908 908 global $bp; 909 909 910 910 $post = bp_forums_get_post( $bp->action_variables[4] ); 911 911 return attribute_escape( $post->post_text ); … … 923 923 function bp_the_topic_pagination_count() { 924 924 global $bp, $topic_template; 925 925 926 926 $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; 927 $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 ); 928 927 $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 ); 928 929 929 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 ) ); 930 930 ?> … … 947 947 function bp_get_forum_permalink() { 948 948 global $bp; 949 949 950 950 if ( $bp->is_single_item ) 951 951 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/'; … … 961 961 function bp_get_forum_directory_permalink() { 962 962 global $bp; 963 963 964 964 return apply_filters( 'bp_get_forum_directory_permalink', $bp->root_domain . '/' . $bp->forums->slug ); 965 965 } 966 966 967 function bp_forums_tag_heat_map( $args = '' ) { 967 function bp_forums_tag_heat_map( $args = '' ) { 968 968 $defaults = array( 969 969 'smallest' => '10', … … 985 985 global $topic_template; 986 986 987 return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 987 return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 988 988 } 989 989 … … 993 993 function bp_get_forum_topic_action() { 994 994 global $bp; 995 996 return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 995 996 return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 997 997 } 998 998 -
trunk/bp-friends.php
r1995 r2077 16 16 function friends_install() { 17 17 global $wpdb, $bp; 18 18 19 19 if ( !empty($wpdb->charset) ) 20 20 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 21 21 22 22 $sql[] = "CREATE TABLE {$bp->friends->table_name} ( 23 23 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 33 33 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 34 34 dbDelta($sql); 35 35 36 36 update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION ); 37 37 } … … 42 42 /* For internal identification */ 43 43 $bp->friends->id = 'friends'; 44 44 45 45 $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends'; 46 46 $bp->friends->format_notification_function = 'friends_format_notifications'; 47 47 $bp->friends->slug = BP_FRIENDS_SLUG; 48 48 49 49 /* Register this in the active components array */ 50 50 $bp->active_components[$bp->friends->slug] = $bp->friends->id; … … 52 52 do_action( 'friends_setup_globals' ); 53 53 } 54 add_action( 'plugins_loaded', 'friends_setup_globals', 5 ); 54 add_action( 'plugins_loaded', 'friends_setup_globals', 5 ); 55 55 add_action( 'admin_menu', 'friends_setup_globals', 2 ); 56 56 57 function friends_check_installed() { 57 function friends_check_installed() { 58 58 global $wpdb, $bp; 59 59 60 60 if ( !is_site_admin() ) 61 61 return false; 62 62 63 63 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 64 64 if ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION ) … … 69 69 function friends_setup_nav() { 70 70 global $bp; 71 71 72 72 /* Add 'Friends' to the main navigation */ 73 73 bp_core_new_nav_item( array( 'name' => __('Friends', 'buddypress'), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) ); 74 74 75 75 $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/'; 76 76 77 77 /* Add the subnav items to the friends nav item */ 78 78 bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) ); 79 79 bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_home() ) ); 80 80 81 81 if ( $bp->current_component == $bp->friends->slug ) { 82 82 if ( bp_is_home() ) { … … 84 84 } else { 85 85 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 86 $bp->bp_options_title = $bp->displayed_user->fullname; 86 $bp->bp_options_title = $bp->displayed_user->fullname; 87 87 } 88 88 } 89 89 90 90 do_action( 'friends_setup_nav' ); 91 91 } … … 109 109 110 110 do_action( 'friends_screen_my_friends' ); 111 112 bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) ); 111 112 bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) ); 113 113 } 114 114 115 115 function friends_screen_requests() { 116 116 global $bp; 117 117 118 118 if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) { 119 119 /* Check the nonce */ 120 if ( !check_admin_referer( 'friends_accept_friendship' ) ) 120 if ( !check_admin_referer( 'friends_accept_friendship' ) ) 121 121 return false; 122 122 123 123 if ( friends_accept_friendship( $bp->action_variables[1] ) ) { 124 124 bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) ); … … 127 127 } 128 128 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 129 129 130 130 } else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) { 131 131 /* Check the nonce */ 132 if ( !check_admin_referer( 'friends_reject_friendship' ) ) 133 return false; 134 132 if ( !check_admin_referer( 'friends_reject_friendship' ) ) 133 return false; 134 135 135 if ( friends_reject_friendship( $bp->action_variables[1] ) ) { 136 136 bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) ); 137 137 } else { 138 138 bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' ); 139 } 139 } 140 140 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 141 141 } 142 142 143 143 do_action( 'friends_screen_requests' ); 144 144 145 145 bp_core_load_template( apply_filters( 'friends_template_requests', 'friends/requests' ) ); 146 146 } … … 151 151 } 152 152 153 function friends_screen_notification_settings() { 153 function friends_screen_notification_settings() { 154 154 global $current_user; ?> 155 155 <table class="notification-settings" id="friends-notification-settings"> … … 172 172 <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> 173 173 </tr> 174 174 175 175 <?php do_action( 'friends_screen_notification_settings' ); ?> 176 176 </table> 177 <?php 177 <?php 178 178 } 179 179 add_action( 'bp_notification_settings', 'friends_screen_notification_settings' ); … … 193 193 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' ) 194 194 return false; 195 195 196 196 $potential_friend_id = $bp->action_variables[0]; 197 197 … … 201 201 if ( $potential_friend_id == $bp->loggedin_user->id ) 202 202 return false; 203 203 204 204 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 205 205 206 206 if ( 'not_friends' == $friendship_status ) { 207 207 208 208 if ( !check_admin_referer( 'friends_add_friend' ) ) 209 209 return false; 210 210 211 211 if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 212 212 bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' ); … … 215 215 } 216 216 } else if ( 'is_friend' == $friendship_status ) { 217 bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' ); 217 bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' ); 218 218 } else { 219 bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' ); 220 } 221 219 bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' ); 220 } 221 222 222 bp_core_redirect( wp_get_referer() ); 223 223 224 224 return false; 225 225 } … … 228 228 function friends_action_remove_friend() { 229 229 global $bp; 230 230 231 231 if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' ) 232 232 return false; 233 233 234 234 $potential_friend_id = $bp->action_variables[0]; 235 235 … … 239 239 if ( $potential_friend_id == $bp->loggedin_user->id ) 240 240 return false; 241 241 242 242 $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id ); 243 243 244 244 if ( 'is_friend' == $friendship_status ) { 245 245 246 246 if ( !check_admin_referer( 'friends_remove_friend' ) ) 247 247 return false; 248 248 249 249 if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) { 250 250 bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' ); … … 253 253 } 254 254 } else if ( 'is_friends' == $friendship_status ) { 255 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); 255 bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' ); 256 256 } else { 257 bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' ); 258 } 259 257 bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' ); 258 } 259 260 260 bp_core_redirect( wp_get_referer() ); 261 261 262 262 return false; 263 263 } … … 274 274 function friends_record_activity( $args = '' ) { 275 275 global $bp; 276 276 277 277 if ( !function_exists( 'bp_activity_add' ) ) 278 278 return false; … … 291 291 292 292 $r = wp_parse_args( $args, $defaults ); 293 extract( $r, EXTR_SKIP ); 293 extract( $r, EXTR_SKIP ); 294 294 295 295 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); … … 305 305 function friends_register_activity_actions() { 306 306 global $bp; 307 307 308 308 if ( !function_exists( 'bp_activity_set_action' ) ) 309 309 return false; … … 317 317 function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 318 318 global $bp; 319 319 320 320 switch ( $action ) { 321 321 case 'friendship_accepted': 322 322 if ( (int)$total_items > 1 ) { 323 return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items ); 323 return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items ); 324 324 } else { 325 325 $user_fullname = bp_core_get_user_displayname( $item_id ); 326 326 $user_url = bp_core_get_userurl( $item_id ); 327 327 return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 328 } 328 } 329 329 break; 330 330 331 331 case 'friendship_request': 332 332 if ( (int)$total_items > 1 ) { 333 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 333 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 334 334 } else { 335 335 $user_fullname = bp_core_get_user_displayname( $item_id ); 336 336 $user_url = bp_core_get_userurl( $item_id ); 337 337 return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname ); 338 } 338 } 339 339 break; 340 340 } 341 341 342 342 do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 343 343 344 344 return false; 345 345 } … … 360 360 if ( empty( $friend_count ) ) 361 361 return false; 362 362 363 363 if ( !(int)$friend_count ) 364 364 return false; 365 365 366 366 return true; 367 367 } … … 381 381 function friends_get_friendship_requests( $user_id ) { 382 382 $fship_ids = friends_get_friendship_ids( $user_id, true ); 383 383 384 384 return array( 'requests' => $fship_ids, 'total' => count($fship_ids) ); 385 385 } … … 390 390 else 391 391 $friend_ids = friends_get_friend_user_ids( $user_id ); 392 392 393 393 if ( !$friend_ids ) 394 394 return false; 395 395 396 396 if ( $filter ) 397 397 $friend_ids = $friend_ids['friends']; 398 398 399 399 $ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) ); 400 400 401 401 if ( !$ids_and_activity ) 402 402 return false; 403 403 404 404 $total_friends = count( $ids_and_activity ); 405 405 406 406 if ( $pag_num && $pag_page ) 407 407 return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends ); … … 415 415 else 416 416 $friend_ids = friends_get_friend_user_ids( $user_id ); 417 417 418 418 if ( !$friend_ids ) 419 419 return false; 420 420 421 421 if ( $filter ) 422 422 $friend_ids = $friend_ids['friends']; 423 423 424 424 $sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) ); 425 425 426 426 if ( !$sorted_ids ) 427 427 return false; 428 428 429 429 $total_friends = count( $sorted_ids ); 430 430 431 431 if ( $pag_num && $pag_page ) 432 432 return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends ); … … 440 440 else 441 441 $friend_ids = friends_get_friend_user_ids( $user_id ); 442 442 443 443 if ( !$friend_ids ) 444 return false; 444 return false; 445 445 446 446 if ( $filter ) … … 448 448 449 449 $total_friends = count( $friend_ids ); 450 450 451 451 if ( $pag_num && $pag_page ) 452 return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends ); 452 return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends ); 453 453 else 454 return array( 'friends' => $friend_ids, 'total' => $total_friends ); 455 } 456 454 return array( 'friends' => $friend_ids, 'total' => $total_friends ); 455 } 456 457 457 function friends_get_bulk_last_active( $friend_ids ) { 458 458 return BP_Friends_Friendship::get_bulk_last_active( $friend_ids ); … … 461 461 function friends_get_friends_list( $user_id ) { 462 462 global $bp; 463 463 464 464 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ); 465 465 … … 470 470 if ( function_exists('bp_user_fullname') ) 471 471 $display_name = bp_core_get_user_displayname( $friend_ids[$i] ); 472 472 473 473 if ( $display_name != ' ' ) { 474 474 $friends[] = array( … … 478 478 } 479 479 } 480 480 481 481 if ( $friends && is_array($friends) ) 482 482 usort($friends, 'friends_sort_by_name'); … … 488 488 } 489 489 490 function friends_sort_by_name($a, $b) { 490 function friends_sort_by_name($a, $b) { 491 491 return strcasecmp($a['full_name'], $b['full_name']); 492 492 } … … 494 494 function friends_get_friends_invite_list( $user_id = false, $group_id ) { 495 495 global $bp; 496 496 497 497 if ( !$user_id ) 498 498 $user_id = $bp->loggedin_user->id; 499 499 500 500 $friend_ids = friends_get_alphabetically( $user_id ); 501 501 … … 506 506 if ( groups_check_user_has_invite( $friend_ids['friends'][$i]->user_id, $group_id ) || groups_is_user_member( $friend_ids['friends'][$i]->user_id, $group_id ) ) 507 507 continue; 508 508 509 509 $display_name = bp_core_get_user_displayname( $friend_ids['friends'][$i]->user_id ); 510 510 511 511 if ( $display_name != ' ' ) { 512 512 $friends[] = array( … … 535 535 536 536 $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page ); 537 537 538 538 if ( !$user_ids ) 539 539 return false; … … 542 542 $users[] = new BP_Core_User($user_ids[$i]); 543 543 } 544 544 545 545 return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) ); 546 546 } … … 551 551 if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) ) 552 552 return true; 553 553 554 554 return false; 555 555 } … … 557 557 function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) { 558 558 global $bp; 559 559 560 560 $friendship = new BP_Friends_Friendship; 561 561 562 562 if ( (int)$friendship->is_confirmed ) 563 563 return true; 564 564 565 565 $friendship->initiator_user_id = $initiator_userid; 566 566 $friendship->friend_user_id = $friend_userid; … … 568 568 $friendship->is_limited = 0; 569 569 $friendship->date_created = time(); 570 570 571 571 if ( $force_accept ) 572 572 $friendship->is_confirmed = 1; 573 573 574 574 if ( $friendship->save() ) { 575 575 576 576 if ( !$force_accept ) { 577 577 // Add the on screen notification 578 bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' ); 578 bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' ); 579 579 580 580 // Send the email notification 581 581 require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' ); 582 582 friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 583 584 do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 583 584 do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 585 585 } else { 586 586 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 587 587 } 588 588 589 589 return true; 590 590 } 591 591 592 592 return false; 593 593 } … … 595 595 function friends_remove_friend( $initiator_userid, $friend_userid ) { 596 596 global $bp; 597 597 598 598 $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 599 599 $friendship = new BP_Friends_Friendship( $friendship_id ); 600 600 601 601 // Remove the activity stream item for the user who canceled the friendship 602 602 friends_delete_activity( array( 'item_id' => $friendship_id, 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) ); 603 603 604 604 do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid ); 605 605 606 606 if ( $friendship->delete() ) { 607 607 friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' ); 608 608 609 609 return true; 610 610 } 611 611 612 612 return false; 613 613 } … … 615 615 function friends_accept_friendship( $friendship_id ) { 616 616 global $bp; 617 617 618 618 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 619 619 620 620 if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) { 621 621 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 622 622 623 623 /* Remove the friend request notice */ 624 bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' ); 625 624 bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' ); 625 626 626 /* Add a friend accepted notice for the initiating user */ 627 627 bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' ); 628 628 629 629 $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id ); 630 630 $friend_link = bp_core_get_userlink( $friendship->friend_user_id ); 631 631 632 632 $primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userlink( $friendship->initiator_user_id ), &$friendship ); 633 633 634 634 /* Record in activity streams for the initiator */ 635 friends_record_activity( array( 635 friends_record_activity( array( 636 636 'user_id' => $friendship->initiator_user_id, 637 637 'component_action' => 'friendship_created', … … 642 642 643 643 /* Record in activity streams for the friend */ 644 friends_record_activity( array( 644 friends_record_activity( array( 645 645 'user_id' => $friendship->friend_user_id, 646 646 'component_action' => 'friendship_created', … … 650 650 'hide_sitewide' => true /* We've already got the first entry site wide */ 651 651 ) ); 652 652 653 653 /* Send the email notification */ 654 654 require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' ); … … 656 656 657 657 do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 658 658 659 659 return true; 660 660 } 661 661 662 662 return false; 663 663 } 664 664 665 function friends_reject_friendship( $friendship_id ) { 665 function friends_reject_friendship( $friendship_id ) { 666 666 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 667 667 668 668 if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) { 669 669 // Remove the friend request notice 670 bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' ); 671 670 bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' ); 671 672 672 do_action( 'friends_friendship_rejected', $friendship_id, &$friendship ); 673 673 return true; 674 674 } 675 675 676 676 return false; 677 677 } … … 688 688 } else { 689 689 update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 ); 690 update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 ); 690 update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 ); 691 691 } 692 692 } … … 694 694 function friends_remove_data( $user_id ) { 695 695 BP_Friends_Friendship::delete_all_for_user($user_id); 696 696 697 697 /* Remove usermeta */ 698 698 delete_usermeta( $user_id, 'total_friend_count' ); 699 699 700 700 /* Remove friendship requests FROM user */ 701 701 bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' ); -
trunk/bp-friends/bp-friends-classes.php
r2055 r2077 8 8 var $is_limited; 9 9 var $date_created; 10 10 11 11 var $is_request; 12 12 var $populate_friend_details; 13 13 14 14 var $friend; 15 15 16 16 function bp_friends_friendship( $id = null, $is_request = false, $populate_friend_details = true ) { 17 17 $this->is_request = $is_request; 18 18 19 19 if ( $id ) { 20 20 $this->id = $id; … … 26 26 function populate() { 27 27 global $wpdb, $bp, $creds; 28 28 29 29 if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) { 30 30 $this->initiator_user_id = $friendship->initiator_user_id; … … 34 34 $this->date_created = $friendship->date_created; 35 35 } 36 36 37 37 // if running from ajax. 38 38 if ( !$bp->displayed_user->id ) 39 39 $bp->displayed_user->id = $creds['current_userid']; 40 40 41 41 if ( $this->populate_friend_details ) { 42 42 if ( $this->friend_user_id == $bp->displayed_user->id ) { … … 47 47 } 48 48 } 49 49 50 50 function save() { 51 51 global $wpdb, $bp; … … 57 57 $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id ); 58 58 59 do_action( 'friends_friendship_before_save', $this ); 60 59 do_action( 'friends_friendship_before_save', $this ); 60 61 61 if ( $this->id ) { 62 62 // Update … … 68 68 } 69 69 70 do_action( 'friends_friendship_after_save', $this ); 71 70 do_action( 'friends_friendship_after_save', $this ); 71 72 72 return $result; 73 73 } 74 74 75 75 function delete() { 76 76 global $wpdb, $bp; 77 77 78 78 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ); 79 79 } 80 80 81 81 /* Static Functions */ 82 82 83 83 function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) { 84 84 global $wpdb, $bp; 85 85 86 86 if ( $friend_requests_only ) { 87 87 $oc_sql = $wpdb->prepare( "AND is_confirmed = 0" ); … … 93 93 94 94 $friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) ); 95 95 96 96 for ( $i = 0; $i < count($friends); $i++ ) { 97 97 if ( $assoc_arr ) … … 100 100 $fids[] = ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id; 101 101 } 102 102 103 103 return $fids; 104 104 } 105 105 106 106 function get_friendship_ids( $user_id, $friend_requests_only = false ) { 107 107 global $wpdb, $bp; … … 114 114 $friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id ); 115 115 } 116 116 117 117 return $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} $friend_sql $oc_sql" ) ); 118 118 } 119 119 120 120 function get_friendship_id( $user_id, $friend_id ) { 121 121 global $wpdb, $bp; 122 122 123 123 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) ); 124 124 } 125 125 126 126 function total_friend_count( $user_id = false) { 127 127 global $wpdb, $bp; 128 128 129 129 if ( !$user_id ) 130 130 $user_id = $bp->displayed_user->id; 131 132 /* This is stored in 'total_friend_count' usermeta. 131 132 /* This is stored in 'total_friend_count' usermeta. 133 133 This function will recalculate, update and return. */ 134 134 135 135 $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 ) ); 136 136 137 137 if ( !$count ) 138 138 return 0; 139 139 140 140 update_usermeta( $user_id, 'total_friend_count', $count ); 141 141 return $count; 142 142 } 143 143 144 144 function search_friends( $filter, $user_id, $limit = null, $page = null ) { 145 145 global $wpdb, $bp; 146 146 147 147 // TODO: Optimize this function. 148 148 149 149 if ( !$user_id ) 150 150 $user_id = $bp->loggedin_user->id; 151 151 152 152 $filter = like_escape( $wpdb->escape( $filter ) ); 153 153 154 154 if ( $limit && $page ) 155 155 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 156 156 157 157 if ( !$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ) ) 158 158 return false; … … 160 160 // Get all the user ids for the current user's friends. 161 161 $fids = implode( ',', $friend_ids ); 162 162 163 163 if ( empty($fids) ) 164 164 return false; … … 173 173 } 174 174 175 $filtered_friend_ids = $wpdb->get_col($sql); 176 $total_friend_ids = $wpdb->get_var($total_sql); 177 175 $filtered_friend_ids = $wpdb->get_col($sql); 176 $total_friend_ids = $wpdb->get_var($total_sql); 177 178 178 if ( !$filtered_friend_ids ) 179 179 return false; … … 181 181 return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids ); 182 182 } 183 183 184 184 function check_is_friend( $loggedin_userid, $possible_friend_userid ) { 185 185 global $wpdb, $bp; 186 186 187 187 if ( !$loggedin_userid || !$possible_friend_userid ) 188 188 return false; 189 189 190 190 $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) ); 191 191 192 192 if ( $result ) { 193 193 if ( 0 == (int)$result[0]->is_confirmed ) { … … 200 200 } 201 201 } 202 202 203 203 function get_bulk_last_active( $user_ids ) { 204 204 global $wpdb, $bp; … … 206 206 return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC" ) ); 207 207 } 208 208 209 209 function accept($friendship_id) { 210 210 global $wpdb, $bp; … … 212 212 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 ) ); 213 213 } 214 214 215 215 function reject($friendship_id) { 216 216 global $wpdb, $bp; 217 217 218 218 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, $bp->loggedin_user->id ) ); 219 219 } 220 220 221 221 function search_users( $filter, $user_id, $limit = null, $page = null ) { 222 222 global $wpdb, $bp; 223 223 224 224 $filter = like_escape( $wpdb->escape( $filter ) ); 225 225 226 $usermeta_table = $wpdb->base_prefix . 'usermeta'; 226 227 $users_table = $wpdb->base_prefix . 'users'; … … 228 229 if ( $limit && $page ) 229 230 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 230 231 231 232 // filter the user_ids based on the search criteria. 232 233 if ( function_exists('xprofile_install') ) { … … 235 236 $sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM $usermeta_table WHERE meta_value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" ); 236 237 } 237 238 $filtered_fids = $wpdb->get_col($sql); 239 238 239 $filtered_fids = $wpdb->get_col($sql); 240 240 241 if ( !$filtered_fids ) 241 242 return false; … … 243 244 return $filtered_fids; 244 245 } 245 246 246 247 function search_users_count( $filter ) { 247 248 global $wpdb, $bp; 248 249 249 250 $filter = like_escape( $wpdb->escape( $filter ) ); 251 250 252 $usermeta_table = $wpdb->prefix . 'usermeta'; 251 253 $users_table = $wpdb->base_prefix . 'users'; 252 254 253 255 // filter the user_ids based on the search criteria. 254 256 if ( function_exists('xprofile_install') ) { … … 258 260 } 259 261 260 $user_count = $wpdb->get_col($sql); 261 262 $user_count = $wpdb->get_col($sql); 263 262 264 if ( !$user_count ) 263 265 return false; … … 265 267 return $user_count[0]; 266 268 } 267 269 268 270 function sort_by_name( $user_ids ) { 269 271 global $wpdb, $bp; 270 272 271 273 if ( !function_exists( 'xprofile_install') ) 272 274 return false; 273 275 274 276 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) ); 275 277 } 276 278 277 279 function get_random_friends( $user_id, $total_friends = 5 ) { 278 280 global $wpdb, $bp; … … 284 286 $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id; 285 287 } 286 288 287 289 // remove duplicates 288 290 if ( count($fids) > 0 ) … … 291 293 return false; 292 294 } 293 295 294 296 function get_invitable_friend_count( $user_id, $group_id ) { 295 297 global $wpdb, $bp; 296 298 297 299 $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ); 298 300 299 301 $invitable_count = 0; 300 302 for ( $i = 0; $i < count($friend_ids); $i++ ) { 301 303 302 304 if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) ) 303 305 continue; 304 306 305 307 if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id ) ) 306 308 continue; 307 309 308 310 $invitable_count++; 309 311 } … … 311 313 return $invitable_count; 312 314 } 313 315 314 316 function get_user_ids_for_friendship( $friendship_id ) { 315 317 global $wpdb, $bp; … … 317 319 return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) ); 318 320 } 319 321 320 322 function delete_all_for_user( $user_id ) { 321 323 global $wpdb, $bp; 322 324 323 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) ); 324 325 // Delete friend request notifications for members who have a notification from this user. 325 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) ); 326 327 // Delete friend request notifications for members who have a notification from this user. 326 328 $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 ) ); 327 329 } 328 330 } 329 331 330 332 331 333 -
trunk/bp-friends/bp-friends-notifications.php
r1905 r2077 3 3 function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) { 4 4 global $bp; 5 5 6 6 $initiator_name = bp_core_get_user_displayname( $initiator_id ); 7 7 8 8 if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) ) 9 9 return false; 10 10 11 11 $ud = get_userdata( $friend_id ); 12 12 $initiator_ud = get_userdata( $initiator_id ); 13 13 14 14 $all_requests_link = bp_core_get_user_domain( $friend_id ) . 'friends/requests/'; 15 15 $settings_link = bp_core_get_user_domain( $friend_id ) . 'settings/notifications'; 16 16 17 17 $initiator_link = bp_core_get_user_domain( $initiator_id ); 18 18 … … 21 21 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name ); 22 22 23 $message = sprintf( __( 23 $message = sprintf( __( 24 24 "%s wants to add you as a friend. 25 25 … … 40 40 function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) { 41 41 global $bp; 42 42 43 43 $friendship = new BP_Friends_Friendship( $friendship_id, false, false ); 44 44 45 45 $friend_name = bp_core_get_user_displayname( $friend_id ); 46 46 47 47 if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) ) 48 48 return false; 49 49 50 50 $ud = get_userdata( $initiator_id ); 51 51 52 52 $friend_link = bp_core_get_user_domain( $friend_id ); 53 $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications'; 54 53 $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications'; 54 55 55 // Set up and send the message 56 56 $to = $ud->user_email; 57 57 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name ); 58 58 59 $message = sprintf( __( 59 $message = sprintf( __( 60 60 '%s accepted your friend request. 61 61 -
trunk/bp-friends/bp-friends-templatetags.php
r2032 r2077 6 6 var $friendships; 7 7 var $friendship; 8 8 9 9 var $in_the_loop; 10 10 11 11 var $pag_page; 12 12 var $pag_num; 13 13 var $pag_links; 14 14 var $total_friend_count; 15 15 16 16 function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) { 17 17 global $bp; … … 19 19 if ( !$user_id ) 20 20 $user_id = $bp->displayed_user->id; 21 21 22 22 $this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1; 23 23 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 28 28 $this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter ); 29 29 break; 30 30 31 31 case 'alphabetical': 32 $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter ); 32 $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter ); 33 33 break; 34 34 … … 38 38 39 39 case 'active': default: 40 $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter ); 40 $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter ); 41 41 break; 42 42 } … … 74 74 )); 75 75 } 76 76 77 77 function has_friendships() { 78 78 if ( $this->friendship_count ) 79 79 return true; 80 80 81 81 return false; 82 82 } 83 83 84 84 function next_friendship() { 85 85 $this->current_friendship++; 86 86 $this->friendship = $this->friendships[$this->current_friendship]; 87 87 88 88 return $this->friendship; 89 89 } 90 90 91 91 function rewind_friendships() { 92 92 $this->current_friendship = -1; … … 95 95 } 96 96 } 97 98 function user_friendships() { 97 98 function user_friendships() { 99 99 if ( $this->current_friendship + 1 < $this->friendship_count ) { 100 100 return true; … … 108 108 return false; 109 109 } 110 110 111 111 function the_friendship() { 112 112 global $friendship, $bp; … … 123 123 else 124 124 $user_id = $this->friendship->user_id; 125 125 126 126 $this->friendship = new stdClass; 127 127 128 128 if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) { 129 129 $this->friendship->friend = new BP_Core_User( $user_id ); 130 130 wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' ); 131 131 } 132 132 133 133 /* Make sure the user_id is available in the friend object. */ 134 134 $this->friendship->friend->user_id = $user_id; … … 153 153 $r = wp_parse_args( $args, $defaults ); 154 154 extract( $r, EXTR_SKIP ); 155 155 156 156 /* The following code will auto set parameters based on the page being viewed. 157 157 * for example on example.com/members/andy/friends/my-friends/newest/ … … 167 167 $type = 'requests'; 168 168 } 169 169 170 170 if ( isset( $_REQUEST['friend-search-box'] ) ) 171 171 $filter = $_REQUEST['friend-search-box']; … … 190 190 function bp_get_friend_id() { 191 191 global $friends_template; 192 193 return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); 192 193 return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); 194 194 } 195 195 … … 208 208 function bp_get_friend_name() { 209 209 global $friends_template; 210 211 return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) ); 212 } 213 210 211 return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) ); 212 } 213 214 214 function bp_friend_link() { 215 215 echo bp_get_friend_link(); … … 238 238 return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active ); 239 239 } 240 240 241 241 function bp_friend_time_since_requested() { 242 242 echo bp_get_friend_time_since_requested(); … … 248 248 return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) ); 249 249 } 250 250 251 251 return false; 252 252 } … … 267 267 global $friends_template, $bp; 268 268 269 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) ); 269 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) ); 270 270 } 271 271 … … 275 275 function bp_get_friend_pagination() { 276 276 global $friends_template; 277 277 278 278 return apply_filters( 'bp_friend_pagination', $friends_template->pag_links ); 279 279 } … … 286 286 287 287 echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> 288 <span class="ajax-loader"></span><?php 288 <span class="ajax-loader"></span><?php 289 289 } 290 290 … … 295 295 return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() ); 296 296 } 297 297 298 298 function bp_friend_search_form() { 299 299 global $friends_template, $bp; … … 306 306 <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label> 307 307 <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> /> 308 308 309 309 <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?> 310 310 <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" /> 311 311 312 312 </form> 313 313 <?php … … 317 317 if ( isset( $_POST['friend-search-box'] ) ) 318 318 return true; 319 319 320 320 return false; 321 321 } … … 328 328 function bp_friend_latest_update_link() { 329 329 global $bp; 330 echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); 330 echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); 331 331 } 332 332 333 333 function bp_friend_recent_activity_link() { 334 334 global $bp; 335 echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); 335 echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); 336 336 } 337 337 338 338 function bp_friend_recent_status_link() { 339 339 global $bp; 340 echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' ); 340 echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' ); 341 341 } 342 342 … … 346 346 function bp_get_add_friend_button( $potential_friend_id = false ) { 347 347 global $bp, $friends_template; 348 348 349 349 $button = false; 350 350 351 351 if ( is_user_logged_in() ) { 352 352 353 353 if ( !$potential_friend_id && $friends_template->friendship->friend ) 354 354 $potential_friend_id = $friends_template->friendship->friend->id; … … 371 371 $button .= '</div>'; 372 372 } 373 373 374 374 return apply_filters( 'bp_get_add_friend_button', $button ); 375 375 } … … 387 387 function bp_friends_filter_title() { 388 388 global $bp; 389 389 390 390 $current_filter = $bp->action_variables[0]; 391 391 392 392 switch ( $current_filter ) { 393 393 case 'recently-active': default: … … 405 405 function bp_friends_random_friends() { 406 406 global $bp; 407 407 408 408 if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) { 409 409 $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id ); 410 410 wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' ); 411 411 } 412 ?> 412 ?> 413 413 <div class="info-group"> 414 414 <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> »</a></span></h4> 415 415 416 416 <?php if ( $friend_ids ) { ?> 417 417 <ul class="horiz-gallery"> … … 435 435 function bp_friends_random_members( $total_members = 5 ) { 436 436 global $bp; 437 437 438 438 if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) { 439 439 $user_ids = BP_Core_User::get_random_users( $total_members ); 440 440 wp_cache_set( 'friends_random_users', $user_ids, 'bp' ); 441 441 } 442 ?> 442 ?> 443 443 <?php if ( $user_ids['users'] ) { ?> 444 444 <ul class="item-list" id="random-members-list"> … … 454 454 </div> 455 455 <?php } ?> 456 456 457 457 <div class="action"> 458 458 <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?> … … 466 466 <div id="message" class="info"> 467 467 <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p> 468 </div> 468 </div> 469 469 <?php } ?> 470 470 <?php -
trunk/bp-groups.php
r2070 r2077 14 14 /* Include deprecated functions if settings allow */ 15 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' ); 16 require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' ); 17 17 18 18 function groups_install() { 19 19 global $wpdb, $bp; 20 20 21 21 if ( !empty($wpdb->charset) ) 22 22 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 23 23 24 24 $sql[] = "CREATE TABLE {$bp->groups->table_name} ( 25 25 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 36 36 KEY status (status) 37 37 ) {$charset_collate};"; 38 38 39 39 $sql[] = "CREATE TABLE {$bp->groups->table_name_members} ( 40 40 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 66 66 KEY meta_key (meta_key) 67 67 ) {$charset_collate};"; 68 68 69 69 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 70 70 dbDelta($sql); 71 71 72 72 /* On upgrade, handle moving of old group avatars */ 73 73 $groups = groups_get_all(); 74 74 75 75 foreach ( $groups as $group ) { 76 76 /* Don't fetch and move gravs, default images or empties */ … … 86 86 if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) ) 87 87 continue; 88 88 89 89 $upload_dir = groups_avatar_upload_dir( $group->id ); 90 90 … … 93 93 } 94 94 } 95 95 96 96 if ( function_exists('bp_wire_install') ) 97 97 groups_wire_install(); 98 98 99 99 update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION ); 100 100 } … … 102 102 function groups_wire_install() { 103 103 global $wpdb, $bp; 104 104 105 105 if ( !empty($wpdb->charset) ) 106 106 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 107 107 108 108 $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} ( 109 109 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 125 125 /* For internal identification */ 126 126 $bp->groups->id = 'groups'; 127 127 128 128 $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups'; 129 129 $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members'; … … 134 134 /* Register this in the active components array */ 135 135 $bp->active_components[$bp->groups->slug] = $bp->groups->id; 136 136 137 137 if ( function_exists('bp_wire_install') ) 138 138 $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire'; 139 139 140 140 $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) ); 141 142 $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array( 143 'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ), 141 142 $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array( 143 'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ), 144 144 'group-settings' => array( 'name' => __( 'Group Settings', 'buddypress' ), 'position' => 10 ), 145 145 'group-avatar' => array( 'name' => __( 'Group Avatar', 'buddypress' ), 'position' => 20 ), 146 146 'group-invites' => array( 'name' => __( 'Group Invites', 'buddypress' ), 'position' => 30 ) 147 147 ) ); 148 148 149 149 $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) ); 150 150 151 151 do_action( 'groups_setup_globals' ); 152 152 } 153 add_action( 'plugins_loaded', 'groups_setup_globals', 5 ); 153 add_action( 'plugins_loaded', 'groups_setup_globals', 5 ); 154 154 add_action( 'admin_menu', 'groups_setup_globals', 2 ); 155 155 … … 160 160 add_action( 'plugins_loaded', 'groups_setup_root_component', 2 ); 161 161 162 function groups_check_installed() { 162 function groups_check_installed() { 163 163 global $wpdb, $bp; 164 164 165 165 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' ); 166 166 … … 173 173 function groups_add_admin_menu() { 174 174 global $wpdb, $bp; 175 175 176 176 if ( !is_site_admin() ) 177 177 return false; 178 178 179 179 /* Add the administration tab under the "Site Admin" tab for site administrators */ 180 180 add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" ); … … 184 184 function groups_setup_nav() { 185 185 global $bp, $current_blog, $group_obj; 186 186 187 187 if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { 188 188 189 189 /* This is a single group page. */ 190 190 $bp->is_single_item = true; 191 191 $bp->groups->current_group = &new BP_Groups_Group( $group_id ); 192 192 193 193 /* Using "item" not "group" for generic support in other components. */ 194 194 if ( is_site_admin() ) … … 196 196 else 197 197 $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ); 198 198 199 199 /* If the user is not an admin, check if they are a moderator */ 200 200 if ( !$bp->is_item_admin ) 201 201 $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id ); 202 202 203 203 /* Is the logged in user a member of the group? */ 204 204 $bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false; 205 205 206 206 /* Should this group be visible to the logged in user? */ 207 207 $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false; 208 208 209 209 /* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */ 210 210 $group_obj = &$bp->groups->current_group; … … 213 213 /* Add 'Groups' to the main navigation */ 214 214 bp_core_new_nav_item( array( 'name' => __('Groups', 'buddypress'), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) ); 215 215 216 216 $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/'; 217 217 218 218 /* Add the subnav items to the groups nav item */ 219 219 bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) ); … … 222 222 223 223 if ( $bp->current_component == $bp->groups->slug ) { 224 224 225 225 if ( bp_is_home() && !$bp->is_single_item ) { 226 226 227 227 $bp->bp_options_title = __( 'My Groups', 'buddypress' ); 228 228 229 229 } else if ( !bp_is_home() && !$bp->is_single_item ) { 230 230 231 231 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 232 232 $bp->bp_options_title = $bp->displayed_user->fullname; 233 233 234 234 } else if ( $bp->is_single_item ) { 235 235 // We are viewing a single group, so set up the 236 236 // group navigation menu using the $bp->groups->current_group global. 237 237 238 238 /* When in a single group, the first action is bumped down one because of the 239 239 group name, so we need to adjust this and set the group name to current_item. */ … … 241 241 $bp->current_action = $bp->action_variables[0]; 242 242 array_shift($bp->action_variables); 243 243 244 244 $bp->bp_options_title = $bp->groups->current_group->name; 245 245 246 246 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' ) ) ) ) 247 247 $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />'; 248 248 249 249 $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/'; 250 250 251 251 // If this is a private or hidden group, does the user have access? 252 252 if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) { … … 261 261 /* Reset the existing subnav items */ 262 262 bp_core_reset_subnav_items($bp->groups->slug); 263 263 264 264 /* Add a new default subnav item for when the groups nav is selected. */ 265 265 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) ); 266 266 267 267 /* Add the "Home" subnav item, as this will always be present */ 268 268 bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'group-home' ) ); 269 269 270 270 /* If the user is a group mod or more, then show the group admin nav item */ 271 271 if ( $bp->is_item_mod || $bp->is_item_admin ) … … 283 283 284 284 bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-members' ) ); 285 285 286 286 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 287 287 if ( function_exists('friends_install') ) … … 292 292 } 293 293 } 294 294 295 295 do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access ); 296 296 } … … 312 312 function groups_setup_adminbar_menu() { 313 313 global $bp; 314 314 315 315 if ( !$bp->groups->current_group ) 316 316 return false; … … 322 322 <li id="bp-adminbar-adminoptions-menu"> 323 323 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> 324 324 325 325 <ul> 326 326 <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?>&delete-group-button=1&delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li> 327 327 328 328 <?php do_action( 'groups_adminbar_menu_items' ) ?> 329 329 </ul> … … 344 344 function groups_screen_my_groups() { 345 345 global $bp; 346 346 347 347 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' ); 348 348 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' ); 349 349 350 350 do_action( 'groups_screen_my_groups' ); 351 351 352 352 bp_core_load_template( apply_filters( 'groups_template_my_groups', 'groups/index' ) ); 353 353 } … … 355 355 function groups_screen_group_invites() { 356 356 global $bp; 357 357 358 358 $group_id = $bp->action_variables[1]; 359 359 360 360 if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) { 361 361 /* Check the nonce */ 362 362 if ( !check_admin_referer( 'groups_accept_invite' ) ) 363 363 return false; 364 364 365 365 if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) { 366 bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' ); 366 bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' ); 367 367 } else { 368 368 bp_core_add_message( __('Group invite accepted', 'buddypress') ); 369 369 370 370 /* Record this in activity streams */ 371 371 $group = new BP_Groups_Group( $group_id, false, false ); 372 372 373 373 groups_record_activity( array( 374 'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ), 374 'content' => apply_filters( 'groups_activity_accepted_invite', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ), 375 375 'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ), 376 376 'component_action' => 'joined_group', … … 380 380 381 381 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 382 382 383 383 } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) { 384 384 /* Check the nonce */ 385 385 if ( !check_admin_referer( 'groups_reject_invite' ) ) 386 386 return false; 387 387 388 388 if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) { 389 bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' ); 390 } else { 391 bp_core_add_message( __('Group invite rejected', 'buddypress') ); 389 bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' ); 390 } else { 391 bp_core_add_message( __('Group invite rejected', 'buddypress') ); 392 392 } 393 393 394 394 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 395 395 } 396 396 397 397 // Remove notifications 398 398 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' ); 399 399 400 400 do_action( 'groups_screen_group_invites', $group_id ); 401 401 402 402 if ( '' != locate_template( array( 'groups/invites.php' ), false ) ) 403 403 bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/invites' ) ); 404 404 else 405 bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) ); 405 bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) ); 406 406 } 407 407 … … 414 414 unset( $bp->groups->current_create_step ); 415 415 unset( $bp->groups->completed_create_steps ); 416 416 417 417 setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH ); 418 418 setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH ); 419 419 420 420 $reset_steps = true; 421 421 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) ); 422 422 } 423 423 424 424 /* If this is a creation step that is not recognized, just redirect them back to the first screen */ 425 425 if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) { … … 440 440 /* If the save, upload or skip button is hit, lets calculate what we need to save */ 441 441 if ( isset( $_POST['save'] ) ) { 442 442 443 443 /* Check the nonce */ 444 444 check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step ); 445 445 446 446 if ( 'group-details' == $bp->groups->current_create_step ) { 447 447 if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) { … … 449 449 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); 450 450 } 451 451 452 452 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'], 'news' => $_POST['group-news'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => time() ) ) ) { 453 453 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 454 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); 455 } 456 454 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); 455 } 456 457 457 groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 ); 458 458 groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', time() ); … … 460 460 groups_update_groupmeta( $bp->groups->new_group_id, 'stylesheet', 'buddypress' ); 461 461 } 462 462 463 463 if ( 'group-settings' == $bp->groups->current_create_step ) { 464 464 $group_status = 'public'; 465 465 $group_enable_wire = 1; 466 466 $group_enable_forum = 1; 467 467 468 468 if ( !isset($_POST['group-show-wire']) ) 469 469 $group_enable_wire = 0; 470 470 471 471 if ( !isset($_POST['group-show-forum']) ) { 472 472 $group_enable_forum = 0; … … 477 477 } 478 478 } 479 479 480 480 if ( 'private' == $_POST['group-status'] ) 481 481 $group_status = 'private'; 482 482 else if ( 'hidden' == $_POST['group-status'] ) 483 483 $group_status = 'hidden'; 484 484 485 485 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) { 486 486 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 487 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); 487 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); 488 488 } 489 489 } … … 495 495 do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step ); 496 496 do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name 497 497 498 498 /** 499 499 * Once we have successfully saved the details for this step of the creation process … … 503 503 if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) ) 504 504 $bp->groups->completed_create_steps[] = $bp->groups->current_create_step; 505 505 506 506 /* Reset cookie info */ 507 507 setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH ); 508 setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH ); 508 setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH ); 509 509 510 510 /* If we have completed all steps and hit done on the final step we can redirect to the completed group */ … … 512 512 unset( $bp->groups->current_create_step ); 513 513 unset( $bp->groups->completed_create_steps ); 514 514 515 515 /* Once we compelete all steps, record the group creation in the activity stream. */ 516 516 groups_record_activity( array( 517 'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ), 517 'content' => apply_filters( 'groups_activity_created_group', sprintf( __( '%s created the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ), 518 518 'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 519 519 'component_action' => 'created_group', 520 520 'item_id' => $bp->groups->new_group_id 521 521 ) ); 522 522 523 523 do_action( 'groups_group_create_complete', $bp->groups->new_group_id ); 524 524 525 525 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 526 526 } else { … … 531 531 foreach ( $bp->groups->group_creation_steps as $key => $value ) { 532 532 if ( $key == $bp->groups->current_create_step ) { 533 $next = 1; 533 $next = 1; 534 534 continue; 535 535 } 536 536 537 537 if ( $next ) { 538 $next_step = $key; 538 $next_step = $key; 539 539 break; 540 540 } … … 544 544 } 545 545 } 546 546 547 547 /* Group avatar is handled separately */ 548 548 if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) { … … 551 551 552 552 /* Pass the file to the avatar upload handler */ 553 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 553 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 554 554 $bp->avatar_admin->step = 'crop-image'; 555 555 … … 562 562 if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) { 563 563 /* Normally we would check a nonce here, but the group save nonce is used instead */ 564 564 565 565 if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) ) 566 566 bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' ); … … 576 576 function groups_screen_group_home() { 577 577 global $bp; 578 578 579 579 if ( $bp->is_single_item ) { 580 580 581 581 if ( isset($_GET['new']) ) { 582 582 // Delete group request notifications for the user … … 585 585 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' ); 586 586 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' ); 587 } 588 589 do_action( 'groups_screen_group_home' ); 590 587 } 588 589 do_action( 'groups_screen_group_home' ); 590 591 591 if ( '' != locate_template( array( 'groups/single/home.php' ), false ) ) 592 592 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); … … 598 598 function groups_screen_group_forum() { 599 599 global $bp; 600 600 601 601 if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) { 602 602 603 603 /* Fetch the details we need */ 604 604 $topic_slug = $bp->action_variables[1]; … … 612 612 /* Check the nonce */ 613 613 check_admin_referer( 'bp_forums_new_reply' ); 614 614 615 615 /* Auto join this user if they are not yet a member of this group */ 616 616 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 617 617 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 618 618 619 619 if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) ) 620 620 bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' ); 621 621 else 622 622 bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') ); 623 623 624 624 if ( $_SERVER['QUERY_STRING'] ) 625 $query_vars = '?' . $_SERVER['QUERY_STRING']; 626 625 $query_vars = '?' . $_SERVER['QUERY_STRING']; 626 627 627 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars ); 628 628 } 629 629 630 630 /* Sticky a topic */ 631 631 else if ( 'stick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { … … 637 637 else 638 638 bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) ); 639 639 640 640 do_action( 'groups_stick_forum_topic', $topic_id ); 641 641 bp_core_redirect( wp_get_referer() ); 642 642 } 643 643 644 644 /* Un-Sticky a topic */ 645 645 else if ( 'unstick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 646 646 /* Check the nonce */ 647 647 check_admin_referer( 'bp_forums_unstick_topic' ); 648 648 649 649 if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) ) 650 650 bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' ); 651 651 else 652 652 bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') ); 653 653 654 654 do_action( 'groups_unstick_forum_topic', $topic_id ); 655 655 bp_core_redirect( wp_get_referer() ); 656 656 } 657 657 658 658 /* Close a topic */ 659 659 else if ( 'close' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 660 660 /* Check the nonce */ 661 661 check_admin_referer( 'bp_forums_close_topic' ); 662 662 663 663 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) ) 664 664 bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' ); 665 665 else 666 666 bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') ); 667 667 668 668 do_action( 'groups_close_forum_topic', $topic_id ); 669 669 bp_core_redirect( wp_get_referer() ); … … 674 674 /* Check the nonce */ 675 675 check_admin_referer( 'bp_forums_open_topic' ); 676 676 677 677 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) ) 678 678 bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' ); 679 679 else 680 680 bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') ); 681 681 682 682 do_action( 'groups_open_forum_topic', $topic_id ); 683 683 bp_core_redirect( wp_get_referer() ); … … 692 692 if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster ) 693 693 bp_core_redirect( wp_get_referer() ); 694 694 695 695 /* Check the nonce */ 696 696 check_admin_referer( 'bp_forums_delete_topic' ); 697 697 698 698 if ( !groups_delete_group_forum_topic( $topic_id ) ) 699 699 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 700 700 else 701 701 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 702 702 703 703 do_action( 'groups_delete_forum_topic', $topic_id ); 704 704 bp_core_redirect( wp_get_referer() ); 705 705 } 706 706 707 707 /* Editing a topic */ 708 708 else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) { … … 717 717 /* Check the nonce */ 718 718 check_admin_referer( 'bp_forums_edit_topic' ); 719 719 720 720 if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) ) 721 721 bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' ); 722 722 else 723 723 bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') ); 724 724 725 725 do_action( 'groups_edit_forum_topic', $topic_id ); 726 726 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 727 727 } 728 728 729 729 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 730 730 } 731 731 732 732 /* Delete a post */ 733 733 else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { … … 746 746 else 747 747 bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') ); 748 748 749 749 do_action( 'groups_delete_forum_post', $post_id ); 750 750 bp_core_redirect( wp_get_referer() ); 751 751 } 752 752 753 753 /* Editing a post */ 754 754 else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { … … 763 763 /* Check the nonce */ 764 764 check_admin_referer( 'bp_forums_edit_post' ); 765 765 766 766 if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) ) 767 767 bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' ); 768 768 else 769 769 bp_core_add_message( __( 'The post was edited successfully', 'buddypress') ); 770 770 771 771 do_action( 'groups_edit_forum_post', $post_id ); 772 772 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 773 773 } 774 774 775 775 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 776 776 } … … 783 783 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) ); 784 784 } 785 785 786 786 } else { 787 787 788 788 /* Posting a topic */ 789 789 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) { 790 /* Check the nonce */ 790 /* Check the nonce */ 791 791 check_admin_referer( 'bp_forums_new_topic' ); 792 792 793 793 /* Auto join this user if they are not yet a member of this group */ 794 794 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) … … 799 799 else 800 800 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 801 801 802 802 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' ); 803 803 } 804 804 805 805 do_action( 'groups_screen_group_forum', $topic_id, $forum_id ); 806 806 807 807 if ( '' != locate_template( array( 'groups/single/forum/index.php' ), false ) ) 808 808 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/forum/index' ) ); 809 809 else 810 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) ); 810 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) ); 811 811 } 812 812 } … … 815 815 function groups_screen_group_wire() { 816 816 global $bp; 817 817 818 818 $wire_action = $bp->action_variables[0]; 819 819 820 820 if ( $bp->is_single_item ) { 821 821 if ( 'post' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 822 822 /* Check the nonce first. */ 823 if ( !check_admin_referer( 'bp_wire_post' ) ) 823 if ( !check_admin_referer( 'bp_wire_post' ) ) 824 824 return false; 825 825 826 826 if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) ) 827 827 bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' ); … … 833 833 else 834 834 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug ); 835 835 836 836 } else if ( 'delete' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 837 837 $wire_message_id = $bp->action_variables[1]; … … 840 840 if ( !check_admin_referer( 'bp_wire_delete_link' ) ) 841 841 return false; 842 842 843 843 if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) ) 844 844 bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' ); 845 845 else 846 846 bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') ); 847 847 848 848 if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) 849 849 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 850 850 else 851 851 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug ); 852 852 853 853 } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) { 854 854 if ( '' != locate_template( array( 'groups/single/wire.php' ), false ) ) 855 855 bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) ); 856 else 856 else 857 857 bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) ); 858 858 } else { 859 859 if ( '' != locate_template( array( 'groups/single/home.php' ), false ) ) 860 860 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 861 else 861 else 862 862 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) ); 863 863 } … … 867 867 function groups_screen_group_members() { 868 868 global $bp; 869 869 870 870 if ( $bp->is_single_item ) { 871 871 do_action( 'groups_screen_group_members', $bp->groups->current_group->id ); … … 874 874 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/members' ) ); 875 875 else 876 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) ); 876 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) ); 877 877 } 878 878 } … … 880 880 function groups_screen_group_invite() { 881 881 global $bp; 882 882 883 883 if ( $bp->is_single_item ) { 884 884 if ( isset($bp->action_variables) && 'send' == $bp->action_variables[0] ) { 885 885 886 886 if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) ) 887 887 return false; 888 888 889 889 // Send the invites. 890 890 groups_send_invites( $bp->loggedin_user->id, $bp->groups->current_group->id ); 891 891 892 892 bp_core_add_message( __('Group invites sent.', 'buddypress') ); 893 893 … … 898 898 // Show send invite page 899 899 if ( '' != locate_template( array( 'groups/single/send-invite.php' ), false ) ) 900 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) ); 900 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) ); 901 901 else 902 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) ); 902 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) ); 903 903 } 904 904 } … … 907 907 function groups_screen_group_leave() { 908 908 global $bp; 909 909 910 910 if ( $bp->is_single_item ) { 911 911 if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) { 912 912 913 913 // Check if the user is the group admin first. 914 914 if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { … … 916 916 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 917 917 } 918 918 919 919 // remove the user from the group. 920 920 if ( !groups_leave_group( $bp->groups->current_group->id ) ) { … … 925 925 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug ); 926 926 } 927 927 928 928 } else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) { 929 929 930 930 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 931 931 932 932 } else { 933 933 934 934 do_action( 'groups_screen_group_leave', $bp->groups->current_group->id ); 935 935 936 936 // Show leave group page 937 937 if ( '' != locate_template( array( 'groups/single/leave-confirm.php' ), false ) ) 938 938 bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/single/leave-confirm' ) ); 939 939 else 940 bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) ); 940 bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) ); 941 941 } 942 942 } … … 945 945 function groups_screen_group_request_membership() { 946 946 global $bp; 947 947 948 948 if ( !is_user_logged_in() ) 949 949 return false; 950 950 951 951 if ( 'private' == $bp->groups->current_group->status ) { 952 952 // If the user has submitted a request, send it. … … 955 955 if ( !check_admin_referer( 'groups_request_membership' ) ) 956 956 return false; 957 957 958 958 if ( !groups_send_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 959 959 bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' ); … … 963 963 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 964 964 } 965 965 966 966 do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id ); 967 967 968 968 if ( '' != locate_template( array( 'groups/single/request-membership.php' ), false ) ) 969 969 bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/request-membership' ) ); 970 970 else 971 bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) ); 971 bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) ); 972 972 } 973 973 } … … 975 975 function groups_screen_group_admin() { 976 976 global $bp; 977 977 978 978 if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action ) 979 979 return false; 980 980 981 981 if ( !empty( $bp->action_variables[0] ) ) 982 982 return false; 983 983 984 984 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' ); 985 985 } … … 987 987 function groups_screen_group_admin_edit_details() { 988 988 global $bp; 989 989 990 990 if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) { 991 991 992 992 if ( $bp->is_item_admin || $bp->is_item_mod ) { 993 993 994 994 // If the edit form has been submitted, save the edited details 995 995 if ( isset( $_POST['save'] ) ) { … … 997 997 if ( !check_admin_referer( 'groups_edit_group_details' ) ) 998 998 return false; 999 999 1000 1000 if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) { 1001 1001 bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' ); … … 1003 1003 bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) ); 1004 1004 } 1005 1005 1006 1006 do_action( 'groups_group_details_edited', $bp->groups->current_group->id ); 1007 1007 1008 1008 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' ); 1009 1009 } … … 1012 1012 1013 1013 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1014 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) ); 1014 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) ); 1015 1015 else 1016 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) ); 1016 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) ); 1017 1017 } 1018 1018 } … … 1022 1022 function groups_screen_group_admin_settings() { 1023 1023 global $bp; 1024 1024 1025 1025 if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) { 1026 1026 1027 1027 if ( !$bp->is_item_admin ) 1028 1028 return false; 1029 1029 1030 1030 // If the edit form has been submitted, save the edited details 1031 1031 if ( isset( $_POST['save'] ) ) { … … 1034 1034 $enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0; 1035 1035 $photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0; 1036 1036 1037 1037 $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); 1038 1038 $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public'; 1039 1039 1040 1040 /* Check the nonce first. */ 1041 1041 if ( !check_admin_referer( 'groups_edit_group_settings' ) ) 1042 1042 return false; 1043 1043 1044 1044 if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) { 1045 1045 bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' ); … … 1049 1049 1050 1050 do_action( 'groups_group_settings_edited', $bp->groups->current_group->id ); 1051 1051 1052 1052 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-settings' ); 1053 1053 } 1054 1054 1055 1055 do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id ); 1056 1056 1057 1057 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1058 bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) ); 1058 bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) ); 1059 1059 else 1060 1060 bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) ); … … 1065 1065 function groups_screen_group_admin_avatar() { 1066 1066 global $bp; 1067 1067 1068 1068 if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) { 1069 1069 1070 1070 if ( !$bp->is_item_admin ) 1071 1071 return false; 1072 1072 1073 1073 /* If the group admin has deleted the admin avatar */ 1074 1074 if ( 'delete' == $bp->action_variables[1] ) { 1075 1075 1076 1076 /* Check the nonce */ 1077 1077 check_admin_referer( 'bp_group_avatar_delete' ); 1078 1078 1079 1079 if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) 1080 1080 bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) ); 1081 1081 else 1082 1082 bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' ); 1083 1084 } 1085 1083 1084 } 1085 1086 1086 $bp->avatar_admin->step = 'upload-image'; 1087 1087 … … 1092 1092 1093 1093 /* Pass the file to the avatar upload handler */ 1094 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 1094 if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) { 1095 1095 $bp->avatar_admin->step = 'crop-image'; 1096 1096 … … 1114 1114 } 1115 1115 1116 do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id ); 1117 1116 do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id ); 1117 1118 1118 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1119 bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) ); 1119 bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) ); 1120 1120 else 1121 bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) ); 1121 bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) ); 1122 1122 } 1123 1123 } … … 1128 1128 1129 1129 if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) { 1130 1130 1131 1131 if ( !$bp->is_item_admin ) 1132 1132 return false; 1133 1133 1134 1134 if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) { 1135 1135 $user_id = $bp->action_variables[3]; 1136 1136 $status = $bp->action_variables[2]; 1137 1137 1138 1138 /* Check the nonce first. */ 1139 1139 if ( !check_admin_referer( 'groups_promote_member' ) ) 1140 1140 return false; 1141 1141 1142 1142 // Promote a user. 1143 1143 if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) { … … 1146 1146 bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) ); 1147 1147 } 1148 1148 1149 1149 do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id ); 1150 1150 1151 1151 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' ); 1152 1152 } 1153 1153 1154 1154 if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) { 1155 1155 $user_id = $bp->action_variables[2]; … … 1157 1157 /* Check if the user is the group admin first. */ 1158 1158 if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 1159 1160 1159 bp_core_add_message( __('As the only group administrator, you cannot demote yourself.', 'buddypress'), 'error' ); 1160 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 1161 1161 } 1162 1162 … … 1164 1164 if ( !check_admin_referer( 'groups_demote_member' ) ) 1165 1165 return false; 1166 1166 1167 1167 // Demote a user. 1168 1168 if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) { … … 1176 1176 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' ); 1177 1177 } 1178 1178 1179 1179 if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) { 1180 1180 $user_id = $bp->action_variables[2]; … … 1182 1182 /* Check if the user is the group admin first. */ 1183 1183 if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 1184 1185 1184 bp_core_add_message( __('As the only group administrator, you cannot ban yourself.', 'buddypress'), 'error' ); 1185 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 1186 1186 } 1187 1187 … … 1189 1189 if ( !check_admin_referer( 'groups_ban_member' ) ) 1190 1190 return false; 1191 1191 1192 1192 // Ban a user. 1193 1193 if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) { … … 1201 1201 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' ); 1202 1202 } 1203 1203 1204 1204 if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) { 1205 1205 $user_id = $bp->action_variables[2]; … … 1208 1208 if ( !check_admin_referer( 'groups_unban_member' ) ) 1209 1209 return false; 1210 1210 1211 1211 // Remove a ban for user. 1212 1212 if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) { … … 1222 1222 1223 1223 do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id ); 1224 1224 1225 1225 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1226 bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) ); 1226 bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) ); 1227 1227 else 1228 1228 bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) ); … … 1233 1233 function groups_screen_group_admin_requests() { 1234 1234 global $bp; 1235 1235 1236 1236 if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) { 1237 1237 1238 1238 if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status ) 1239 1239 return false; 1240 1240 1241 1241 // Remove any screen notifications 1242 1242 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' ); 1243 1243 1244 1244 $request_action = $bp->action_variables[1]; 1245 1245 $membership_id = $bp->action_variables[2]; … … 1251 1251 if ( !check_admin_referer( 'groups_accept_membership_request' ) ) 1252 1252 return false; 1253 1253 1254 1254 // Accept the membership request 1255 1255 if ( !groups_accept_membership_request( $membership_id ) ) { … … 1263 1263 if ( !check_admin_referer( 'groups_reject_membership_request' ) ) 1264 1264 return false; 1265 1265 1266 1266 // Reject the membership request 1267 1267 if ( !groups_reject_membership_request( $membership_id ) ) { … … 1269 1269 } else { 1270 1270 bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) ); 1271 } 1272 1273 } 1274 1271 } 1272 1273 } 1274 1275 1275 do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id ); 1276 1276 … … 1281 1281 1282 1282 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1283 bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) ); 1283 bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) ); 1284 1284 else 1285 bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) ); 1285 bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) ); 1286 1286 } 1287 1287 } … … 1290 1290 function groups_screen_group_admin_delete_group() { 1291 1291 global $bp; 1292 1292 1293 1293 if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) { 1294 1294 1295 1295 if ( !$bp->is_item_admin && !is_site_admin() ) 1296 1296 return false; 1297 1297 1298 1298 if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) { 1299 1299 /* Check the nonce first. */ 1300 1300 if ( !check_admin_referer( 'groups_delete_group' ) ) 1301 1301 return false; 1302 1302 1303 1303 // Group admin has deleted the group, now do it. 1304 1304 if ( !groups_delete_group( $bp->groups->current_group->id ) ) { … … 1318 1318 1319 1319 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1320 bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) ); 1320 bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) ); 1321 1321 else 1322 bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) ); 1322 bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) ); 1323 1323 } 1324 1324 } 1325 1325 add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 ); 1326 1326 1327 function groups_screen_notification_settings() { 1327 function groups_screen_notification_settings() { 1328 1328 global $current_user; ?> 1329 1329 <table class="notification-settings" id="groups-notification-settings"> … … 1366 1366 <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> 1367 1367 </tr> 1368 1368 1369 1369 <?php do_action( 'groups_screen_notification_settings' ); ?> 1370 1370 </table> 1371 <?php 1371 <?php 1372 1372 } 1373 1373 add_action( 'bp_notification_settings', 'groups_screen_notification_settings' ); … … 1384 1384 function groups_action_join_group() { 1385 1385 global $bp; 1386 1386 1387 1387 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' ) 1388 1388 return false; 1389 1389 1390 1390 // user wants to join a group 1391 1391 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 ) ) { … … 1399 1399 1400 1400 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) 1401 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 1401 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); 1402 1402 else 1403 1403 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) ); … … 1407 1407 function groups_action_sort_creation_steps() { 1408 1408 global $bp; 1409 1409 1410 1410 if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' ) 1411 1411 return false; … … 1413 1413 if ( !is_array( $bp->groups->group_creation_steps ) ) 1414 1414 return false; 1415 1415 1416 1416 foreach ( $bp->groups->group_creation_steps as $slug => $step ) 1417 1417 $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug ); … … 1420 1420 ksort($temp); 1421 1421 unset($bp->groups->group_creation_steps); 1422 1422 1423 1423 foreach( $temp as $position => $step ) 1424 1424 $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position ); … … 1428 1428 function groups_aciton_redirect_to_random_group() { 1429 1429 global $bp, $wpdb; 1430 1430 1431 1431 if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) { 1432 1432 $group = groups_get_random_groups( 1, 1 ); … … 1447 1447 function groups_register_activity_actions() { 1448 1448 global $bp; 1449 1449 1450 1450 if ( !function_exists( 'bp_activity_set_action' ) ) 1451 1451 return false; … … 1463 1463 function groups_record_activity( $args = '' ) { 1464 1464 global $bp; 1465 1465 1466 1466 if ( !function_exists( 'bp_activity_add' ) ) 1467 1467 return false; 1468 1468 1469 1469 /* If the group is not public, no recording of activity please. */ 1470 if ( 'public' != $bp->groups->current_group->status ) 1471 return false; 1472 1470 if ( 'public' != $bp->groups->current_group->status ) 1471 return false; 1472 1473 1473 $defaults = array( 1474 1474 'user_id' => $bp->loggedin_user->id, … … 1484 1484 1485 1485 $r = wp_parse_args( $args, $defaults ); 1486 extract( $r, EXTR_SKIP ); 1486 extract( $r, EXTR_SKIP ); 1487 1487 1488 1488 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); … … 1502 1502 function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 1503 1503 global $bp; 1504 1504 1505 1505 switch ( $action ) { 1506 1506 case 'new_membership_request': … … 1509 1509 1510 1510 $group = new BP_Groups_Group( $group_id, false, false ); 1511 1511 1512 1512 $group_link = bp_get_group_permalink( $group ); 1513 1513 1514 1514 if ( (int)$total_items > 1 ) { 1515 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name ); 1515 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name ); 1516 1516 } else { 1517 1517 $user_fullname = bp_core_get_user_displayname( $requesting_user_id ); 1518 1518 return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name ); 1519 } 1519 } 1520 1520 break; 1521 1521 1522 1522 case 'membership_request_accepted': 1523 1523 $group_id = $item_id; 1524 1524 1525 1525 $group = new BP_Groups_Group( $group_id, false, false ); 1526 1526 $group_link = bp_get_group_permalink( $group ) . '/?new'; 1527 1527 1528 1528 if ( (int)$total_items > 1 ) { 1529 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name ); 1529 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name ); 1530 1530 } else { 1531 1531 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name ); 1532 } 1532 } 1533 1533 break; 1534 1534 1535 1535 case 'membership_request_rejected': 1536 1536 $group_id = $item_id; 1537 1537 1538 1538 $group = new BP_Groups_Group( $group_id, false, false ); 1539 1539 $group_link = bp_get_group_permalink( $group ) . '/?new'; 1540 1540 1541 1541 if ( (int)$total_items > 1 ) { 1542 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name ); 1542 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name ); 1543 1543 } else { 1544 1544 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name ); 1545 } 1546 1545 } 1546 1547 1547 break; 1548 1548 1549 1549 case 'member_promoted_to_admin': 1550 1550 $group_id = $item_id; 1551 1551 1552 1552 $group = new BP_Groups_Group( $group_id, false, false ); 1553 1553 $group_link = bp_get_group_permalink( $group ) . '/?new'; 1554 1554 1555 1555 if ( (int)$total_items > 1 ) { 1556 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1556 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1557 1557 } else { 1558 1558 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name ); 1559 } 1559 } 1560 1560 break; 1561 1561 1562 1562 case 'member_promoted_to_mod': 1563 1563 $group_id = $item_id; 1564 1564 1565 1565 $group = new BP_Groups_Group( $group_id, false, false ); 1566 1566 $group_link = bp_get_group_permalink( $group ) . '/?new'; 1567 1567 1568 1568 if ( (int)$total_items > 1 ) { 1569 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1569 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1570 1570 } else { 1571 1571 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name ); 1572 } 1572 } 1573 1573 break; 1574 1574 1575 1575 case 'group_invite': 1576 1576 $group_id = $item_id; … … 1578 1578 $group = new BP_Groups_Group( $group_id, false, false ); 1579 1579 $user_url = bp_core_get_userurl( $user_id ); 1580 1580 1581 1581 if ( (int)$total_items > 1 ) { 1582 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1582 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 1583 1583 } else { 1584 1584 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name ); 1585 } 1585 } 1586 1586 break; 1587 1587 } 1588 1588 1589 1589 do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 1590 1590 1591 1591 return false; 1592 1592 } … … 1606 1606 function groups_create_group( $args = '' ) { 1607 1607 global $bp; 1608 1608 1609 1609 extract( $args ); 1610 1610 1611 1611 /** 1612 1612 * Possible parameters (pass as assoc array): … … 1627 1627 else 1628 1628 $group = new BP_Groups_Group; 1629 1629 1630 1630 if ( $creator_id ) { 1631 1631 $group->creator_id = $creator_id; … … 1633 1633 $group->creator_id = $bp->loggedin_user->id; 1634 1634 } 1635 1635 1636 1636 if ( isset( $name ) ) 1637 1637 $group->name = $name; 1638 1638 1639 1639 if ( isset( $description ) ) 1640 1640 $group->description = $description; 1641 1641 1642 1642 if ( isset( $news ) ) 1643 1643 $group->news = $news; 1644 1644 1645 1645 if ( isset( $slug ) && groups_check_slug( $slug ) ) 1646 1646 $group->slug = $slug; 1647 1647 1648 1648 if ( isset( $status ) ) { 1649 1649 if ( groups_is_valid_status( $status ) ) 1650 1650 $group->status = $status; 1651 1651 } 1652 1652 1653 1653 if ( isset( $enable_wire ) ) 1654 1654 $group->enable_wire = $enable_wire; 1655 1655 else if ( !$group_id && !isset( $enable_wire ) ) 1656 1656 $group->enable_wire = 1; 1657 1657 1658 1658 if ( isset( $enable_forum ) ) 1659 1659 $group->enable_forum = $enable_forum; 1660 1660 else if ( !$group_id && !isset( $enable_forum ) ) 1661 1661 $group->enable_forum = 1; 1662 1662 1663 1663 if ( isset( $date_created ) ) 1664 1664 $group->date_created = $date_created; 1665 1665 1666 1666 if ( !$group->save() ) 1667 1667 return false; … … 1675 1675 $member->user_title = __( 'Group Admin', 'buddypress' ); 1676 1676 $member->is_confirmed = 1; 1677 1677 1678 1678 $member->save(); 1679 1679 } … … 1687 1687 if ( empty( $group_name ) || empty( $group_desc ) ) 1688 1688 return false; 1689 1689 1690 1690 $group = new BP_Groups_Group( $group_id, false, false ); 1691 1691 $group->name = $group_name; … … 1700 1700 groups_notification_group_updated( $group->id ); 1701 1701 } 1702 1702 1703 1703 do_action( 'groups_details_updated', $group->id ); 1704 1704 1705 1705 return true; 1706 1706 } … … 1708 1708 function groups_edit_group_settings( $group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) { 1709 1709 global $bp; 1710 1710 1711 1711 $group = new BP_Groups_Group( $group_id, false, false ); 1712 1712 $group->enable_wire = $enable_wire; … … 1714 1714 $group->enable_photos = $enable_photos; 1715 1715 $group->photos_admin_only = $photos_admin_only; 1716 1717 /*** 1716 1717 /*** 1718 1718 * Before we potentially switch the group status, if it has been changed to public 1719 1719 * from private and there are outstanding membership requests, auto-accept those requests. … … 1721 1721 if ( 'private' == $group->status && 'public' == $status ) 1722 1722 groups_accept_all_pending_membership_requests( $group->id ); 1723 1723 1724 1724 /* Now update the status */ 1725 1725 $group->status = $status; 1726 1726 1727 1727 if ( !$group->save() ) 1728 1728 return false; 1729 1729 1730 1730 /* If forums have been enabled, and a forum does not yet exist, we need to create one. */ 1731 1731 if ( $group->enable_forum ) { … … 1734 1734 } 1735 1735 } 1736 1736 1737 1737 do_action( 'groups_settings_updated', $group->id ); 1738 1738 1739 1739 return true; 1740 1740 } … … 1742 1742 function groups_delete_group( $group_id ) { 1743 1743 global $bp; 1744 1744 1745 1745 // Check the user is the group admin. 1746 1746 if ( !$bp->is_item_admin ) 1747 1747 return false; 1748 1748 1749 1749 // Get the group object 1750 1750 $group = new BP_Groups_Group( $group_id ); 1751 1751 1752 1752 if ( !$group->delete() ) 1753 1753 return false; … … 1757 1757 bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->id ) ); 1758 1758 } 1759 1759 1760 1760 // Remove all outstanding invites for this group 1761 1761 groups_delete_all_group_invites( $group_id ); … … 1763 1763 // Remove all notifications for any user belonging to this group 1764 1764 bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug ); 1765 1765 1766 1766 do_action( 'groups_delete_group', $group_id ); 1767 1767 1768 1768 return true; 1769 1769 } … … 1771 1771 function groups_is_valid_status( $status ) { 1772 1772 global $bp; 1773 1773 1774 1774 return in_array( $status, (array)$bp->groups->valid_status ); 1775 1775 } … … 1780 1780 if ( 'wp' == substr( $slug, 0, 2 ) ) 1781 1781 $slug = substr( $slug, 2, strlen( $slug ) - 2 ); 1782 1782 1783 1783 if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) { 1784 1784 $slug = $slug . '-' . rand(); 1785 1785 } 1786 1786 1787 1787 if ( BP_Groups_Group::check_slug( $slug ) ) { 1788 1788 do { … … 1791 1791 while ( BP_Groups_Group::check_slug( $slug ) ); 1792 1792 } 1793 1793 1794 1794 return $slug; 1795 1795 } … … 1807 1807 if ( !$user_id ) 1808 1808 $user_id = $bp->loggedin_user->id; 1809 1809 1810 1810 // Admins cannot leave a group, that is until promotion to admin support is implemented. 1811 1811 if ( groups_is_user_admin( $user_id, $group_id ) ) 1812 1812 return false; 1813 1813 1814 1814 // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0. 1815 1815 if ( !groups_uninvite_user( $user_id, $group_id, true ) ) … … 1820 1820 /* Modify group member count */ 1821 1821 groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 ); 1822 1822 1823 1823 return true; 1824 1824 } … … 1826 1826 function groups_join_group( $group_id, $user_id = false ) { 1827 1827 global $bp; 1828 1828 1829 1829 if ( !$user_id ) 1830 1830 $user_id = $bp->loggedin_user->id; … … 1832 1832 if ( groups_check_user_has_invite( $user_id, $group_id ) ) 1833 1833 groups_delete_invite( $user_id, $group_id ); 1834 1834 1835 1835 $new_member = new BP_Groups_Member; 1836 1836 $new_member->group_id = $group_id; … … 1841 1841 $new_member->date_modified = time(); 1842 1842 $new_member->is_confirmed = 1; 1843 1843 1844 1844 if ( !$new_member->save() ) 1845 1845 return false; … … 1847 1847 /* Record this in activity streams */ 1848 1848 groups_record_activity( array( 1849 'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ), 1849 'content' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ), 1850 1850 'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 1851 1851 'component_action' => 'joined_group', … … 1903 1903 1904 1904 function groups_get_alphabetically( $limit = null, $page = 1 ) { 1905 return BP_Groups_Group::get_alphabetically( $limit, $page ); 1905 return BP_Groups_Group::get_alphabetically( $limit, $page ); 1906 1906 } 1907 1907 … … 1916 1916 function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) { 1917 1917 global $bp; 1918 1918 1919 1919 if ( !$user_id ) 1920 1920 $user_id = $bp->displayed_user->id; 1921 1921 1922 1922 return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page ); 1923 1923 } … … 1927 1927 function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1928 1928 global $bp; 1929 1929 1930 1930 if ( !$user_id ) 1931 1931 $user_id = $bp->displayed_user->id; … … 1936 1936 function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1937 1937 global $bp; 1938 1938 1939 1939 if ( !$user_id ) 1940 1940 $user_id = $bp->displayed_user->id; 1941 1941 1942 return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter ); 1942 return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter ); 1943 1943 } 1944 1944 1945 1945 function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1946 1946 global $bp; 1947 1947 1948 1948 if ( !$user_id ) 1949 1949 $user_id = $bp->displayed_user->id; 1950 1950 1951 1951 return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter ); 1952 1952 } … … 1954 1954 function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1955 1955 global $bp; 1956 1956 1957 1957 if ( !$user_id ) 1958 1958 $user_id = $bp->displayed_user->id; 1959 1959 1960 return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter ); 1960 return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter ); 1961 1961 } 1962 1962 1963 1963 function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1964 1964 global $bp; 1965 1965 1966 1966 if ( !$user_id ) 1967 1967 $user_id = $bp->displayed_user->id; 1968 1969 return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter ); 1968 1969 return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter ); 1970 1970 } 1971 1971 1972 1972 function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) { 1973 1973 global $bp; 1974 1974 1975 1975 if ( !$user_id ) 1976 1976 $user_id = $bp->displayed_user->id; 1977 1978 return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter ); 1977 1978 return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter ); 1979 1979 } 1980 1980 1981 1981 function groups_total_groups_for_user( $user_id = false ) { 1982 1982 global $bp; 1983 1983 1984 1984 if ( !$user_id ) 1985 1985 $user_id = $bp->displayed_user->id; 1986 1986 1987 1987 return BP_Groups_Member::total_group_count( $user_id ); 1988 1988 } … … 1990 1990 function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) { 1991 1991 global $bp; 1992 1992 1993 1993 if ( !$user_id ) 1994 1994 $user_id = $bp->displayed_user->id; 1995 1995 1996 1996 return BP_Groups_Member::get_random_groups( $user_id, $total_groups ); 1997 1997 } … … 2012 2012 if ( !$group_id ) 2013 2013 $group_id = $bp->groups->current_group->id; 2014 2014 2015 2015 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 2016 2016 $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path ); … … 2018 2018 2019 2019 $newbdir = $newdir; 2020 2020 2021 2021 if ( !file_exists( $newdir ) ) 2022 2022 @wp_mkdir_p( $newdir ); … … 2026 2026 $newsubdir = '/group-avatars/' . $group_id; 2027 2027 2028 return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 2028 return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 2029 2029 } 2030 2030 … … 2051 2051 function groups_new_wire_post( $group_id, $content ) { 2052 2052 global $bp; 2053 2053 2054 2054 if ( !function_exists( 'bp_wire_new_post' ) ) 2055 2055 return false; 2056 2056 2057 2057 if ( $wire_post = bp_wire_new_post( $group_id, $content, 'groups' ) ) { 2058 2058 2059 2059 /* Post an email notification if settings allow */ 2060 2060 require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 2061 2061 groups_notification_new_wire_post( $group_id, $wire_post->id ); 2062 2062 2063 2063 /* Record this in activity streams */ 2064 2064 $activity_content = sprintf( __( '%s wrote on the wire of the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2065 2065 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>'; 2066 2066 2067 2067 groups_record_activity( array( 2068 'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ), 2068 'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ), 2069 2069 'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2070 2070 'component_action' => 'new_wire_post', … … 2074 2074 2075 2075 do_action( 'groups_new_wire_post', $group_id, $wire_post->id ); 2076 2076 2077 2077 return true; 2078 2078 } 2079 2079 2080 2080 return false; 2081 2081 } … … 2087 2087 bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) ); 2088 2088 } 2089 2089 2090 2090 do_action( 'groups_deleted_wire_post', $wire_post_id ); 2091 2091 return true; 2092 2092 } 2093 2093 2094 2094 return false; 2095 2095 } … … 2102 2102 if ( !$group_id ) 2103 2103 $group_id = $bp->groups->current_group->id; 2104 2104 2105 2105 if ( !$group_name ) 2106 2106 $group_name = $bp->groups->current_group->name; 2107 2107 2108 2108 if ( !$group_desc ) 2109 2109 $group_desc = $bp->groups->current_group->description; 2110 2110 2111 2111 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) ); 2112 2112 2113 2113 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 2114 2114 2115 2115 do_action( 'groups_new_group_forum', $forum, $group_id ); 2116 2116 } … … 2118 2118 function groups_new_group_forum_post( $post_text, $topic_id ) { 2119 2119 global $bp; 2120 2120 2121 2121 if ( empty( $post_text ) ) 2122 2122 return false; 2123 2123 2124 2124 if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) { 2125 2125 $topic = bp_forums_get_topic_details( $topic_id ); 2126 2126 2127 2127 $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2128 2128 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>'; 2129 2129 2130 2130 /* Record this in activity streams */ 2131 2131 groups_record_activity( array( 2132 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 2132 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 2133 2133 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2134 2134 'component_action' => 'new_forum_post', … … 2138 2138 2139 2139 do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post ); 2140 2140 2141 2141 return $forum_post; 2142 2142 } 2143 2143 2144 2144 return false; 2145 2145 } … … 2147 2147 function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) { 2148 2148 global $bp; 2149 2149 2150 2150 if ( empty( $topic_title ) || empty( $topic_text ) ) 2151 2151 return false; 2152 2152 2153 2153 if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) { 2154 2154 $topic = bp_forums_get_topic_details( $topic_id ); … … 2156 2156 $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2157 2157 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>'; 2158 2158 2159 2159 /* Record this in activity streams */ 2160 2160 groups_record_activity( array( 2161 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 2161 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 2162 2162 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2163 2163 'component_action' => 'new_forum_topic', … … 2165 2165 'secondary_item_id' => $topic->topic_id 2166 2166 ) ); 2167 2167 2168 2168 do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic ); 2169 2169 2170 2170 return $topic; 2171 2171 } 2172 2172 2173 2173 return false; 2174 2174 } … … 2176 2176 function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) { 2177 2177 global $bp; 2178 2178 2179 2179 if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) { 2180 2180 /* Update the activity stream item */ 2181 2181 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) 2182 2182 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) ); 2183 2183 2184 2184 $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2185 2185 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>'; … … 2187 2187 /* Record this in activity streams */ 2188 2188 groups_record_activity( array( 2189 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 2189 'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 2190 2190 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2191 2191 'component_action' => 'new_forum_topic', … … 2197 2197 2198 2198 do_action( 'groups_update_group_forum_topic', &$topic ); 2199 2199 2200 2200 return true; 2201 2201 } 2202 2202 2203 2203 return false; 2204 2204 } … … 2206 2206 function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) { 2207 2207 global $bp; 2208 2208 2209 2209 $post = bp_forums_get_post( $post_id ); 2210 2210 2211 2211 if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) { 2212 2212 $topic = bp_forums_get_topic_details( $topic_id ); … … 2215 2215 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) 2216 2216 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) ); 2217 2217 2218 2218 $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ); 2219 2219 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>'; 2220 2220 2221 2221 /* Record this in activity streams */ 2222 2222 groups_record_activity( array( 2223 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 2223 'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 2224 2224 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ), 2225 2225 'component_action' => 'new_forum_post', … … 2231 2231 2232 2232 do_action( 'groups_update_group_forum_post', &$post, &$topic ); 2233 2233 2234 2234 return true; 2235 2235 } 2236 2236 2237 2237 return false; 2238 2238 } … … 2240 2240 function groups_delete_group_forum_topic( $topic_id ) { 2241 2241 global $bp; 2242 2242 2243 2243 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2244 2244 /* Delete the activity stream item */ … … 2249 2249 2250 2250 do_action( 'groups_delete_group_forum_topic', $topic_id ); 2251 2251 2252 2252 return true; 2253 2253 } 2254 2254 2255 2255 return false; 2256 2256 } … … 2258 2258 function groups_delete_group_forum_post( $post_id, $topic_id ) { 2259 2259 global $bp; 2260 2260 2261 2261 if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) { 2262 2262 /* Delete the activity stream item */ … … 2266 2266 2267 2267 do_action( 'groups_delete_group_forum_post', $post_id, $topic_id ); 2268 2268 2269 2269 return true; 2270 2270 } 2271 2271 2272 2272 return false; 2273 2273 } … … 2282 2282 function groups_get_invites_for_user( $user_id = false ) { 2283 2283 global $bp; 2284 2284 2285 2285 if ( !$user_id ) 2286 2286 $user_id = $bp->loggedin_user->id; 2287 2287 2288 2288 return BP_Groups_Member::get_invites( $user_id ); 2289 2289 } … … 2291 2291 function groups_invite_user( $args = '' ) { 2292 2292 global $bp; 2293 2293 2294 2294 $defaults = array( 2295 2295 'user_id' => false, … … 2301 2301 2302 2302 $args = wp_parse_args( $args, $defaults ); 2303 extract( $args, EXTR_SKIP ); 2303 extract( $args, EXTR_SKIP ); 2304 2304 2305 2305 if ( !$user_id || !$group_id ) 2306 2306 return false; 2307 2307 2308 2308 if ( groups_is_user_member( $user_id, $group_id ) ) 2309 2309 return false; 2310 2310 2311 2311 $invite = new BP_Groups_Member; 2312 2312 $invite->group_id = $group_id; … … 2315 2315 $invite->inviter_id = $inviter_id; 2316 2316 $invite->is_confirmed = $is_confirmed; 2317 2317 2318 2318 if ( !$invite->save() ) 2319 2319 return false; 2320 2320 2321 2321 do_action( 'groups_invite_user', $args ); 2322 2322 2323 2323 return true; 2324 2324 } … … 2326 2326 function groups_uninvite_user( $user_id, $group_id ) { 2327 2327 global $bp; 2328 2328 2329 2329 if ( !BP_Groups_Member::delete( $user_id, $group_id ) ) 2330 2330 return false; … … 2338 2338 if ( groups_is_user_member( $user_id, $group_id ) ) 2339 2339 return false; 2340 2340 2341 2341 $member = new BP_Groups_Member( $user_id, $group_id ); 2342 2342 $member->accept_invite(); 2343 2343 2344 if ( !$member->save() ) 2345 return false; 2346 2344 if ( !$member->save() ) 2345 return false; 2346 2347 2347 do_action( 'groups_accept_invite', $user_id, $group_id ); 2348 2348 return true; … … 2352 2352 if ( !BP_Groups_Member::delete( $user_id, $group_id ) ) 2353 2353 return false; 2354 2354 2355 2355 do_action( 'groups_reject_invite', $user_id, $group_id ); 2356 2356 2357 2357 return true; 2358 2358 } … … 2360 2360 function groups_delete_invite( $user_id, $group_id ) { 2361 2361 global $bp; 2362 2362 2363 2363 $delete = BP_Groups_Member::delete_invite( $user_id, $group_id ); 2364 2364 2365 2365 if ( $delete ) 2366 2366 bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' ); 2367 2367 2368 2368 return $delete; 2369 2369 } … … 2371 2371 function groups_send_invites( $user_id, $group_id ) { 2372 2372 global $bp; 2373 2373 2374 2374 require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 2375 2375 2376 2376 if ( !$user_id ) 2377 2377 $user_id = $bp->loggedin_user->id; … … 2386 2386 // Send the actual invite 2387 2387 groups_notification_group_invites( $group, $member, $user_id ); 2388 2388 2389 2389 $member->invite_sent = 1; 2390 2390 $member->save(); 2391 2391 } 2392 2392 2393 2393 do_action( 'groups_send_invites', $bp->groups->current_group->id, $invited_users ); 2394 2394 } … … 2410 2410 function groups_promote_member( $user_id, $group_id, $status ) { 2411 2411 global $bp; 2412 2412 2413 2413 if ( !$bp->is_item_admin ) 2414 2414 return false; 2415 2415 2416 2416 $member = new BP_Groups_Member( $user_id, $group_id ); 2417 2417 2418 2418 do_action( 'groups_premote_member', $user_id, $group_id, $status ); 2419 2419 2420 2420 return $member->promote( $status ); 2421 2421 } … … 2425 2425 2426 2426 $member = new BP_Groups_Member( $user_id, $group_id ); 2427 2427 2428 2428 do_action( 'groups_demote_member', $user_id, $group_id ); 2429 2429 … … 2436 2436 if ( !$bp->is_item_admin ) 2437 2437 return false; 2438 2438 2439 2439 $member = new BP_Groups_Member( $user_id, $group_id ); 2440 2440 2441 2441 do_action( 'groups_ban_member', $user_id, $group_id ); 2442 2442 2443 2443 return $member->ban(); 2444 2444 } … … 2446 2446 function groups_unban_member( $user_id, $group_id ) { 2447 2447 global $bp; 2448 2448 2449 2449 if ( !$bp->is_item_admin ) 2450 2450 return false; 2451 2451 2452 2452 $member = new BP_Groups_Member( $user_id, $group_id ); 2453 2453 2454 2454 do_action( 'groups_unban_member', $user_id, $group_id ); 2455 2455 2456 2456 return $member->unban(); 2457 2457 } … … 2471 2471 $requesting_user->is_confirmed = 0; 2472 2472 $requesting_user->comments = $_POST['group-request-membership-comments']; 2473 2473 2474 2474 if ( $requesting_user->save() ) { 2475 2475 $admins = groups_get_group_admins( $group_id ); … … 2481 2481 groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id ); 2482 2482 } 2483 2483 2484 2484 do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id ); 2485 2485 2486 2486 return true; 2487 2487 } 2488 2488 2489 2489 return false; 2490 2490 } … … 2492 2492 function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) { 2493 2493 global $bp; 2494 2494 2495 2495 if ( $user_id && $group_id ) 2496 2496 $membership = new BP_Groups_Member( $user_id, $group_id ); … … 2499 2499 2500 2500 $membership->accept_request(); 2501 2501 2502 2502 if ( !$membership->save() ) 2503 2503 return false; 2504 2504 2505 2505 /* Modify group member count */ 2506 2506 groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 ); 2507 2507 2508 2508 /* Record this in activity streams */ 2509 2509 $group = new BP_Groups_Group( $group_id, false, false ); 2510 2510 2511 2511 groups_record_activity( array( 2512 'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ), 2512 'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ), 2513 2513 'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ), 2514 2514 'component_action' => 'joined_group', … … 2520 2520 require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 2521 2521 groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true ); 2522 2522 2523 2523 do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id ); 2524 2524 2525 2525 return true; 2526 2526 } 2527 2527 2528 function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) { 2528 function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) { 2529 2529 if ( $user_id && $group_id ) 2530 2530 $membership = new BP_Groups_Member( $user_id, $group_id ); 2531 2531 else 2532 2532 $membership = new BP_Groups_Member( false, false, $membership_id ); 2533 2533 2534 2534 if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) ) 2535 2535 return false; 2536 2536 2537 2537 // Send a notification to the user. 2538 2538 require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' ); 2539 2539 groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false ); 2540 2540 2541 2541 do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id ); 2542 2542 2543 2543 return true; 2544 2544 } … … 2553 2553 if ( !$user_ids ) 2554 2554 return false; 2555 2555 2556 2556 foreach ( (array) $user_ids as $user_id ) { 2557 2557 groups_accept_membership_request( false, $user_id, $group_id ); 2558 2558 } 2559 2559 2560 2560 do_action( 'groups_accept_all_pending_membership_requests', $group_id ); 2561 2561 2562 2562 return true; 2563 2563 } … … 2567 2567 function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) { 2568 2568 global $wpdb, $bp; 2569 2569 2570 2570 if ( !is_numeric( $group_id ) ) 2571 2571 return false; 2572 2572 2573 2573 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 2574 2574 2575 2575 if ( is_array($meta_value) || is_object($meta_value) ) 2576 2576 $meta_value = serialize($meta_value); 2577 2577 2578 2578 $meta_value = trim( $meta_value ); 2579 2579 2580 2580 if ( !$meta_key ) { 2581 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) ); 2581 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) ); 2582 2582 } else if ( $meta_value ) { 2583 2583 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) ); … … 2585 2585 $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) ); 2586 2586 } 2587 2587 2588 2588 // TODO need to look into using this. 2589 2589 // wp_cache_delete($group_id, 'groups'); … … 2594 2594 function groups_get_groupmeta( $group_id, $meta_key = '') { 2595 2595 global $wpdb, $bp; 2596 2596 2597 2597 $group_id = (int) $group_id; 2598 2598 … … 2602 2602 if ( !empty($meta_key) ) { 2603 2603 $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); 2604 2604 2605 2605 // TODO need to look into using this. 2606 2606 //$user = wp_cache_get($user_id, 'users'); 2607 2607 2608 2608 // Check the cached user object 2609 2609 //if ( false !== $user && isset($user->$meta_key) ) … … 2632 2632 function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) { 2633 2633 global $wpdb, $bp; 2634 2634 2635 2635 if ( !is_numeric( $group_id ) ) 2636 2636 return false; 2637 2637 2638 2638 $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key ); 2639 2639 2640 2640 if ( is_string($meta_value) ) 2641 2641 $meta_value = stripslashes($wpdb->escape($meta_value)); 2642 2642 2643 2643 $meta_value = maybe_serialize($meta_value); 2644 2644 2645 2645 if (empty($meta_value)) { 2646 2646 return groups_delete_groupmeta( $group_id, $meta_key ); … … 2667 2667 function groups_remove_data_for_user( $user_id ) { 2668 2668 BP_Groups_Member::delete_all_for_user($user_id); 2669 2669 2670 2670 do_action( 'groups_remove_data_for_user', $user_id ); 2671 2671 } -
trunk/bp-groups/bp-groups-admin.php
r1905 r2077 1 1 <?php 2 2 3 function groups_admin_settings() { 4 3 function groups_admin_settings() { 4 5 5 if ( isset( $_POST['groups_admin_delete']) && isset( $_POST['allgroups'] ) ) { 6 6 if ( !check_admin_referer('bp-groups-admin') ) 7 7 return false; 8 8 9 9 $errors = false; 10 10 foreach ( $_POST['allgroups'] as $group_id ) { … … 14 14 } 15 15 } 16 16 17 17 if ( $errors ) { 18 18 $message = __( 'There were errors when deleting groups, please try again', 'buddypress' ); … … 32 32 <div class="wrap" style="position: relative"> 33 33 <h2><?php _e( 'Groups', 'buddypress' ) ?></h2> 34 34 35 35 <form id="wpmu-search" method="post" action=""> 36 36 <input type="text" size="17" value="<?php echo attribute_escape( stripslashes( $_REQUEST['s'] ) ); ?>" name="s" /> 37 37 <input id="post-query-submit" class="button" type="submit" value="<?php _e( 'Search Groups', 'buddypress' ) ?>" /> 38 38 </form> 39 39 40 40 <?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?> 41 41 <form id="bp-group-admin-list" method="post" action=""> … … 50 50 </div> 51 51 </div> 52 52 53 53 <br class="clear"/> 54 54 55 55 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { ?> 56 56 <p><?php echo sprintf( __( 'Groups matching: "%s"', 'buddypress' ), $_REQUEST['s'] ) ?></p> … … 111 111 <?php endwhile; ?> 112 112 </tbody> 113 </table> 113 </table> 114 114 115 115 <?php else: ?> … … 124 124 </form> 125 125 </div> 126 <?php 126 <?php 127 127 } 128 128 -
trunk/bp-groups/bp-groups-classes.php
r2055 r2077 14 14 15 15 var $user_dataset; 16 16 17 17 var $admins; 18 18 var $total_member_count; 19 19 var $random_members; 20 20 var $latest_wire_posts; 21 21 22 22 function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) { 23 23 if ( $id ) { … … 25 25 $this->populate( $get_user_dataset ); 26 26 } 27 27 28 28 if ( $single ) { 29 29 $this->populate_meta(); 30 30 } 31 31 } 32 32 33 33 function populate( $get_user_dataset ) { 34 34 global $wpdb, $bp; … … 36 36 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id ); 37 37 $group = $wpdb->get_row($sql); 38 38 39 39 if ( $group ) { 40 40 $this->id = $group->id; … … 49 49 $this->date_created = strtotime($group->date_created); 50 50 $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' ); 51 51 52 52 if ( $get_user_dataset ) { 53 53 $this->user_dataset = $this->get_user_dataset(); 54 54 55 55 //if ( !$this->total_member_count ) { 56 56 $this->total_member_count = count( $this->user_dataset ); … … 58 58 //} 59 59 } 60 } 61 } 62 60 } 61 } 62 63 63 function populate_meta() { 64 64 if ( $this->id ) { … … 67 67 } 68 68 } 69 69 70 70 function save() { 71 71 global $wpdb, $bp; 72 72 73 73 $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id ); 74 74 $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id ); … … 82 82 83 83 do_action( 'groups_group_before_save', $this ); 84 84 85 85 if ( $this->id ) { 86 $sql = $wpdb->prepare( 87 "UPDATE {$bp->groups->table_name} SET 88 creator_id = %d, 89 name = %s, 90 slug = %s, 91 description = %s, 92 news = %s, 93 status = %s, 94 enable_wire = %d, 95 enable_forum = %d, 86 $sql = $wpdb->prepare( 87 "UPDATE {$bp->groups->table_name} SET 88 creator_id = %d, 89 name = %s, 90 slug = %s, 91 description = %s, 92 news = %s, 93 status = %s, 94 enable_wire = %d, 95 enable_forum = %d, 96 96 date_created = FROM_UNIXTIME(%d) 97 97 WHERE 98 98 id = %d 99 99 ", 100 $this->creator_id, 101 $this->name, 102 $this->slug, 103 $this->description, 104 $this->news, 105 $this->status, 106 $this->enable_wire, 107 $this->enable_forum, 100 $this->creator_id, 101 $this->name, 102 $this->slug, 103 $this->description, 104 $this->news, 105 $this->status, 106 $this->enable_wire, 107 $this->enable_forum, 108 108 $this->date_created, 109 109 $this->id 110 110 ); 111 111 } else { 112 $sql = $wpdb->prepare( 113 "INSERT INTO {$bp->groups->table_name} ( 112 $sql = $wpdb->prepare( 113 "INSERT INTO {$bp->groups->table_name} ( 114 114 creator_id, 115 115 name, … … 124 124 %d, %s, %s, %s, %s, %s, %d, %d, FROM_UNIXTIME(%d) 125 125 )", 126 $this->creator_id, 127 $this->name, 128 $this->slug, 129 $this->description, 130 $this->news, 131 $this->status, 132 $this->enable_wire, 126 $this->creator_id, 127 $this->name, 128 $this->slug, 129 $this->description, 130 $this->news, 131 $this->status, 132 $this->enable_wire, 133 133 $this->enable_forum, 134 134 $this->date_created 135 135 ); 136 136 } 137 137 138 138 if ( false === $wpdb->query($sql) ) 139 139 return false; 140 140 141 141 if ( !$this->id ) { 142 142 $this->id = $wpdb->insert_id; … … 144 144 145 145 do_action( 'groups_group_after_save', $this ); 146 146 147 147 return true; 148 148 } 149 149 150 150 function get_user_dataset() { 151 151 global $wpdb, $bp; 152 152 153 153 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) ); 154 154 } 155 155 156 156 function get_administrators() { 157 157 for ( $i = 0; $i < count($this->user_dataset); $i++ ) { 158 158 if ( $this->user_dataset[$i]->is_admin ) 159 159 $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id ); 160 } 161 160 } 161 162 162 return $admins; 163 163 } … … 165 165 function get_random_members() { 166 166 $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count; 167 167 168 168 for ( $i = 0; $i < $total_randoms; $i++ ) { 169 169 if ( !(int)$this->user_dataset[$i]->is_banned ) … … 172 172 return $users; 173 173 } 174 174 175 175 function is_member() { 176 176 global $bp; 177 177 178 178 for ( $i = 0; $i < count($this->user_dataset); $i++ ) { 179 179 if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) { 180 180 return true; 181 181 } 182 } 183 182 } 183 184 184 return false; 185 185 } 186 186 187 187 function delete() { 188 188 global $wpdb, $bp; 189 189 190 190 // Delete groupmeta for the group 191 191 groups_delete_groupmeta( $this->id ); … … 194 194 for ( $i = 0; $i < count($this->user_dataset); $i++ ) { 195 195 $user = $this->user_dataset[$i]; 196 196 197 197 $total_count = get_usermeta( $user->user_id, 'total_group_count' ); 198 198 199 199 if ( $total_count != '' ) { 200 200 update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 ); 201 201 } 202 202 203 203 // Now delete the group member record 204 204 BP_Groups_Member::delete( $user->user_id, $this->id, false ); 205 205 } 206 206 207 207 // Delete the wire posts for this group if the wire is installed 208 208 if ( function_exists('bp_wire_install') ) { 209 209 BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire ); 210 210 } 211 211 212 212 // Finally remove the group entry from the DB 213 213 if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) ) … … 216 216 return true; 217 217 } 218 218 219 219 220 220 /* Static Functions */ 221 221 222 222 function group_exists( $slug, $table_name = false ) { 223 223 global $wpdb, $bp; 224 224 225 225 if ( !$table_name ) 226 226 $table_name = $bp->groups->table_name; 227 227 228 228 if ( !$slug ) 229 229 return false; 230 230 231 231 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) ); 232 232 } … … 240 240 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) ); 241 241 } 242 242 243 243 function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) { 244 244 global $wpdb, $bp; 245 245 246 246 if ( !$user_id ) 247 247 $user_id = $bp->displayed_user->id; 248 248 249 249 $filter = like_escape( $wpdb->escape( $filter ) ); 250 251 if ( $limit && $page ) 252 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 253 250 251 if ( $limit && $page ) 252 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 253 254 254 // Get all the group ids for the current user's groups. 255 255 $gids = BP_Groups_Member::get_group_ids( $user_id ); 256 256 257 257 if ( !$gids['groups'] ) 258 258 return false; 259 259 260 260 $gids = implode( ',', $gids['groups'] ); 261 261 262 262 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids}) {$pag_sql}" ) ); 263 263 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids})" ) ); 264 265 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 266 } 267 264 265 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 266 } 267 268 268 function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) { 269 269 global $wpdb, $bp; 270 270 271 271 $filter = like_escape( $wpdb->escape( $filter ) ); 272 272 273 273 if ( $limit && $page ) 274 274 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 279 279 $order_sql = "ORDER BY $sort_by $order"; 280 280 } 281 281 282 282 if ( !is_site_admin() ) 283 283 $hidden_sql = "AND status != 'hidden'"; … … 285 285 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sql} {$order_sql} {$pag_sql}" ) ); 286 286 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sq}" ) ); 287 288 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 289 } 290 287 288 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 289 } 290 291 291 function check_slug( $slug ) { 292 292 global $wpdb, $bp; 293 294 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) ); 295 } 296 293 294 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) ); 295 } 296 297 297 function get_slug( $group_id ) { 298 298 global $wpdb, $bp; 299 300 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) ); 301 } 302 299 300 return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) ); 301 } 302 303 303 function has_members( $group_id ) { 304 304 global $wpdb, $bp; 305 306 $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) ); 305 306 $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) ); 307 307 308 308 if ( !$members ) 309 309 return false; 310 310 311 311 return true; 312 312 } 313 313 314 314 function has_membership_requests( $group_id ) { 315 315 global $wpdb, $bp; 316 317 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) ); 318 } 319 316 317 return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) ); 318 } 319 320 320 function get_membership_requests( $group_id, $limit = null, $page = null ) { 321 321 global $wpdb, $bp; 322 322 323 323 if ( $limit && $page ) { 324 324 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 325 325 } 326 326 327 327 $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) ); 328 328 $total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) ); … … 330 330 return array( 'requests' => $paged_requests, 'total' => $total_requests ); 331 331 } 332 332 333 333 function get_newest( $limit = null, $page = null ) { 334 334 global $wpdb, $bp; 335 336 if ( $limit && $page ) 337 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 338 335 336 if ( $limit && $page ) 337 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 338 339 339 if ( !is_site_admin() ) 340 340 $hidden_sql = "WHERE status != 'hidden'"; 341 341 342 342 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC {$pag_sql}" ) ); 343 343 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC", $limit ) ); … … 345 345 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 346 346 } 347 347 348 348 function get_active( $limit = null, $page = null ) { 349 349 global $wpdb, $bp; 350 350 351 351 if ( $limit && $page ) 352 352 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 354 354 if ( !is_site_admin() ) 355 355 $hidden_sql = "AND g.status != 'hidden'"; 356 356 357 357 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) ); 358 358 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) ); … … 360 360 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 361 361 } 362 362 363 363 function get_popular( $limit = null, $page = null ) { 364 364 global $wpdb, $bp; 365 365 366 366 if ( $limit && $page ) { 367 367 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 370 370 if ( !is_site_admin() ) 371 371 $hidden_sql = "AND g.status != 'hidden'"; 372 372 373 373 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) ); 374 374 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(gm.group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) ); … … 376 376 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 377 377 } 378 378 379 379 function get_alphabetically( $limit = null, $page = null ) { 380 380 global $wpdb, $bp; 381 382 if ( $limit && $page ) 383 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 384 381 382 if ( $limit && $page ) 383 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 384 385 385 if ( !is_site_admin() ) 386 386 $hidden_sql = "WHERE status != 'hidden'"; 387 387 388 388 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) ); 389 389 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC", $limit ) ); … … 391 391 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 392 392 } 393 393 394 394 function get_by_most_forum_topics( $limit = null, $page = null ) { 395 395 global $wpdb, $bp, $bbdb; 396 396 397 397 if ( $limit && $page ) { 398 398 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 402 402 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC" ) ); 403 403 404 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 404 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 405 405 } 406 406 407 407 function get_by_most_forum_posts( $limit = null, $page = null ) { 408 408 global $wpdb, $bp, $bbdb; 409 409 410 410 if ( $limit && $page ) { 411 411 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 412 412 } 413 413 414 414 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC {$pag_sql}" ) ); 415 415 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC" ) ); 416 416 417 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 418 } 419 420 417 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 418 } 419 420 421 421 function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) { 422 422 global $wpdb, $bp; 423 423 424 424 if ( $only_public ) 425 425 $public_sql = $wpdb->prepare( " WHERE g.status = 'public'" ); 426 426 427 427 if ( !is_site_admin() ) 428 428 $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'"); 429 430 if ( $limit && $page ) 431 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 432 429 430 if ( $limit && $page ) 431 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 432 433 433 if ( $sort_by && $order ) { 434 434 $sort_by = $wpdb->escape( $sort_by ); 435 435 $order = $wpdb->escape( $order ); 436 436 $order_sql = "ORDER BY g.$sort_by $order"; 437 437 438 438 switch ( $sort_by ) { 439 439 default: 440 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); 440 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); 441 441 break; 442 442 case 'members': 443 $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}" ); 443 $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}" ); 444 444 break; 445 445 case 'last_active': 446 $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}" ); 446 $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}" ); 447 447 break; 448 448 } 449 449 } else { 450 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); 451 } 452 450 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" ); 451 } 452 453 453 return $wpdb->get_results($sql); 454 454 } 455 455 456 456 function get_by_letter( $letter, $limit = null, $page = null ) { 457 457 global $wpdb, $bp; 458 458 459 459 if ( strlen($letter) > 1 || is_numeric($letter) || !$letter ) 460 460 return false; 461 461 462 462 if ( !is_site_admin() ) 463 463 $hidden_sql = $wpdb->prepare( " AND status != 'hidden'"); 464 464 465 465 $letter = like_escape( $wpdb->escape( $letter ) ); 466 466 … … 469 469 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC" ) ); 470 470 } 471 471 472 472 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) ); 473 474 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 475 } 476 473 474 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 475 } 476 477 477 function get_random( $limit = null, $page = null ) { 478 478 global $wpdb, $bp; … … 485 485 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand()" ) ); 486 486 } 487 488 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) ); 489 490 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 491 } 492 487 488 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) ); 489 490 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 491 } 492 493 493 function delete_all_invites( $group_id ) { 494 494 global $wpdb, $bp; 495 495 496 496 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) ); 497 497 } 498 498 499 499 function get_global_forum_topic_count( $type ) { 500 500 global $bbdb, $wpdb, $bp; 501 501 502 502 if ( 'unreplied' == $type ) 503 503 $bp->groups->filter_sql = ' AND t.topic_posts = 1'; 504 504 505 505 $extra_sql = apply_filters( 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type ); 506 506 … … 522 522 var $comments; 523 523 var $invite_sent; 524 524 525 525 var $user; 526 526 527 527 function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) { 528 528 if ( $user_id && $group_id && !$id ) { 529 529 $this->user_id = $user_id; 530 530 $this->group_id = $group_id; 531 531 532 532 if ( $populate ) 533 533 $this->populate(); 534 534 } 535 535 536 536 if ( $id ) { 537 537 $this->id = $id; 538 538 539 539 if ( $populate ) 540 540 $this->populate(); 541 } 542 } 543 541 } 542 } 543 544 544 function populate() { 545 545 global $wpdb, $bp; 546 546 547 547 if ( $this->user_id && $this->group_id && !$this->id ) 548 548 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id ); 549 549 550 550 if ( $this->id ) 551 551 $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id ); 552 552 553 553 $member = $wpdb->get_row($sql); 554 554 555 555 if ( $member ) { 556 556 $this->id = $member->id; … … 566 566 $this->comments = $member->comments; 567 567 $this->invite_sent = $member->invite_sent; 568 568 569 569 $this->user = new BP_Core_User( $this->user_id ); 570 570 } 571 571 } 572 572 573 573 function save() { 574 574 global $wpdb, $bp; 575 575 576 576 $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id ); 577 577 $this->group_id = apply_filters( 'groups_member_group_id_before_save', $this->group_id, $this->id ); … … 585 585 $this->comments = apply_filters( 'groups_member_comments_before_save', $this->comments, $this->id ); 586 586 $this->invite_sent = apply_filters( 'groups_member_invite_sent_before_save', $this->invite_sent, $this->id ); 587 587 588 588 do_action( 'groups_member_before_save', $this ); 589 589 590 590 if ( $this->id ) { 591 591 $sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = FROM_UNIXTIME(%d), is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id ); … … 596 596 if ( !$wpdb->query($sql) ) 597 597 return false; 598 598 599 599 $this->id = $wpdb->insert_id; 600 600 601 601 do_action( 'groups_member_after_save', $this ); 602 602 603 603 return true; 604 604 } 605 605 606 606 function promote( $status = 'mod' ) { 607 607 if ( 'mod' == $status ) { … … 610 610 $this->user_title = __( 'Group Mod', 'buddypress' ); 611 611 } 612 612 613 613 if ( 'admin' == $status ) { 614 614 $this->is_admin = 1; … … 616 616 $this->user_title = __( 'Group Admin', 'buddypress' ); 617 617 } 618 618 619 619 return $this->save(); 620 620 } 621 622 function demote() { 621 622 function demote() { 623 623 $this->is_mod = 0; 624 624 $this->is_admin = 0; 625 625 $this->user_title = false; 626 627 return $this->save(); 628 } 629 626 627 return $this->save(); 628 } 629 630 630 function ban() { 631 if ( $this->is_admin ) 632 return false; 633 631 if ( $this->is_admin ) 632 return false; 633 634 634 $this->is_mod = 0; 635 635 $this->is_banned = 1; 636 636 637 637 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) ); 638 639 return $this->save(); 640 } 641 638 639 return $this->save(); 640 } 641 642 642 function unban() { 643 if ( $this->is_admin ) 644 return false; 645 643 if ( $this->is_admin ) 644 return false; 645 646 646 $this->is_banned = 0; 647 647 648 648 groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) ); 649 650 return $this->save(); 651 } 652 649 650 return $this->save(); 651 } 652 653 653 function accept_invite() { 654 654 $this->inviter_id = 0; … … 656 656 $this->date_modified = time(); 657 657 } 658 658 659 659 function accept_request() { 660 660 $this->is_confirmed = 1; 661 $this->date_modified = time(); 662 } 663 661 $this->date_modified = time(); 662 } 663 664 664 /* Static Functions */ 665 665 … … 668 668 669 669 $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 670 670 671 671 return $delete_result; 672 672 } 673 673 674 674 function get_group_ids( $user_id, $limit = false, $page = false ) { 675 675 global $wpdb, $bp; … … 677 677 if ( $limit && $page ) 678 678 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 679 679 680 680 // If the user is logged in and viewing their own groups, we can show hidden and private groupss 681 681 if ( bp_is_home() ) { 682 $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id ); 683 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) ); 682 $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id ); 683 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) ); 684 684 } else { 685 $group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id ); 685 $group_sql = $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id ); 686 686 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) ); 687 687 } 688 688 689 689 $groups = $wpdb->get_col( $group_sql ); 690 690 691 691 return array( 'groups' => $groups, 'total' => (int) $total_groups ); 692 692 } 693 693 694 694 function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) { 695 695 global $wpdb, $bp; … … 700 700 if ( $filter ) { 701 701 $filter = like_escape( $wpdb->escape( $filter ) ); 702 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 702 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 703 703 } 704 704 705 705 if ( !bp_is_home() ) 706 706 $hidden_sql = " AND g.status != 'hidden'"; 707 708 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) ); 709 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) ); 710 711 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 712 } 713 707 708 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) ); 709 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) ); 710 711 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 712 } 713 714 714 function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) { 715 715 global $wpdb, $bp; … … 720 720 if ( $filter ) { 721 721 like_escape( $wpdb->escape( $filter ) ); 722 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 722 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 723 723 } 724 724 … … 726 726 $hidden_sql = " AND g.status != 'hidden'"; 727 727 728 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) ); 729 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) ); 730 731 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 732 } 733 728 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) ); 729 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) ); 730 731 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 732 } 733 734 734 function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) { 735 735 global $wpdb, $bp; 736 737 if ( $limit && $page ) 738 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 739 736 737 if ( $limit && $page ) 738 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 739 740 740 if ( $filter ) { 741 741 $filter = like_escape( $wpdb->escape( $filter ) ); 742 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 742 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 743 743 } 744 744 745 745 if ( !bp_is_home() ) 746 746 $hidden_sql = " AND g.status != 'hidden'"; 747 748 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT 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}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) ); 749 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(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}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) ); 750 751 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 752 } 753 747 748 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT 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}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) ); 749 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(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}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) ); 750 751 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 752 } 753 754 754 function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) { 755 755 global $wpdb, $bp; 756 756 757 757 if ( $limit && $page ) 758 758 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 760 760 if ( $filter ) { 761 761 $filter = like_escape( $wpdb->escape( $filter ) ); 762 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 762 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 763 763 } 764 764 765 765 if ( !bp_is_home() ) 766 $hidden_sql = " AND g.status != 'hidden'"; 767 768 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) ); 769 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) ); 770 771 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 772 } 773 766 $hidden_sql = " AND g.status != 'hidden'"; 767 768 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) ); 769 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) ); 770 771 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 772 } 773 774 774 function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) { 775 775 global $wpdb, $bp; 776 776 777 777 if ( $limit && $page ) 778 778 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 780 780 if ( $filter ) { 781 781 $filter = like_escape( $wpdb->escape( $filter ) ); 782 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 782 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 783 783 } 784 784 785 785 if ( !bp_is_home() ) 786 $hidden_sql = " AND g.status != 'hidden'"; 787 788 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) ); 789 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) ); 790 791 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 792 } 793 786 $hidden_sql = " AND g.status != 'hidden'"; 787 788 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) ); 789 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) ); 790 791 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 792 } 793 794 794 function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) { 795 795 global $wpdb, $bp; 796 796 797 797 if ( $limit && $page ) 798 798 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); … … 800 800 if ( $filter ) { 801 801 $filter = like_escape( $wpdb->escape( $filter ) ); 802 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 802 $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )"; 803 803 } 804 804 805 805 if ( !bp_is_home() ) 806 $hidden_sql = " AND g.status != 'hidden'"; 807 808 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) ); 809 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) ); 810 811 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 812 } 813 806 $hidden_sql = " AND g.status != 'hidden'"; 807 808 $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) ); 809 $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) ); 810 811 return array( 'groups' => $paged_groups, 'total' => $total_groups ); 812 } 813 814 814 function total_group_count( $user_id = false ) { 815 815 global $bp, $wpdb; 816 816 817 817 if ( !$user_id ) 818 818 $user_id = $bp->displayed_user->id; 819 819 820 820 if ( bp_is_home() ) { 821 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) ); 821 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) ); 822 822 } else { 823 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) ); 824 } 825 } 826 823 return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0", $user_id ) ); 824 } 825 } 826 827 827 function get_invites( $user_id ) { 828 828 global $wpdb, $bp; 829 829 830 830 $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d and is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id ) ); 831 831 832 832 return $group_ids; 833 833 } 834 834 835 835 function check_has_invite( $user_id, $group_id ) { 836 836 global $wpdb, $bp; 837 837 838 838 if ( !$user_id ) 839 839 return false; 840 841 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) ); 842 } 843 840 841 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) ); 842 } 843 844 844 function delete_invite( $user_id, $group_id ) { 845 845 global $wpdb, $bp; 846 846 847 847 if ( !$user_id ) 848 848 return false; 849 850 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) ); 851 } 852 849 850 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) ); 851 } 852 853 853 function check_is_admin( $user_id, $group_id ) { 854 854 global $wpdb, $bp; 855 855 856 856 if ( !$user_id ) 857 857 return false; 858 858 859 859 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) ); 860 860 } 861 861 862 862 function check_is_mod( $user_id, $group_id ) { 863 863 global $wpdb, $bp; 864 864 865 865 if ( !$user_id ) 866 866 return false; 867 867 868 868 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) ); 869 869 } 870 870 871 871 function check_is_member( $user_id, $group_id ) { 872 872 global $wpdb, $bp; 873 873 874 874 if ( !$user_id ) 875 875 return false; 876 877 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) ); 878 } 879 876 877 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) ); 878 } 879 880 880 function check_is_banned( $user_id, $group_id ) { 881 881 global $wpdb, $bp; 882 882 883 883 if ( !$user_id ) 884 884 return false; 885 885 886 886 return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) ); 887 887 } 888 888 889 889 function check_for_membership_request( $user_id, $group_id ) { 890 890 global $wpdb, $bp; 891 891 892 892 if ( !$user_id ) 893 893 return false; 894 895 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) ); 896 } 897 894 895 return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) ); 896 } 897 898 898 function get_random_groups( $user_id, $total_groups = 5 ) { 899 899 global $wpdb, $bp; 900 900 901 901 // If the user is logged in and viewing their random groups, we can show hidden and private groups 902 902 if ( bp_is_home() ) { 903 903 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) ); 904 904 } else { 905 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) ); 906 } 907 } 908 905 return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) ); 906 } 907 } 908 909 909 function get_group_administrator_ids( $group_id ) { 910 910 global $bp, $wpdb; 911 911 912 912 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) ); 913 913 } 914 914 915 915 function get_group_moderator_ids( $group_id ) { 916 916 global $bp, $wpdb; … … 918 918 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) ); 919 919 } 920 920 921 921 function get_all_membership_request_user_ids( $group_id ) { 922 922 global $bp, $wpdb; 923 923 924 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) ); 925 } 926 924 return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) ); 925 } 926 927 927 function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) { 928 928 global $bp, $wpdb; 929 929 930 930 if ( $limit && $page ) 931 931 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 932 932 933 933 if ( $exclude_admins_mods ) 934 934 $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" ); 935 935 936 936 if ( $exclude_banned ) 937 937 $banned_sql = $wpdb->prepare( " AND is_banned = 0" ); 938 938 939 939 $members = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} {$pag_sql}", $group_id ) ); 940 940 941 941 if ( !$members ) 942 942 return false; 943 944 if ( !isset($pag_sql) ) 943 944 if ( !isset($pag_sql) ) 945 945 $total_member_count = count($members); 946 946 else 947 947 $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) ); 948 948 949 949 return array( 'members' => $members, 'count' => $total_member_count ); 950 950 } 951 951 952 952 function delete_all_for_user( $user_id ) { 953 953 global $wpdb, $bp; 954 955 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) ); 954 955 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) ); 956 956 } 957 957 } … … 959 959 /** 960 960 * API for creating group extensions without having to hardcode the content into 961 * the theme. 961 * the theme. 962 962 * 963 963 * This class must be extended for each group extension and the following methods overridden: 964 * 964 * 965 965 * BP_Group_Extension::widget_display(), BP_Group_Extension::display(), 966 966 * BP_Group_Extension::edit_screen_save(), BP_Group_Extension::edit_screen(), … … 974 974 var $name = false; 975 975 var $slug = false; 976 976 977 977 /* Will this extension be visible to non-members of a group? Options: public/private */ 978 978 var $visibility = 'public'; 979 979 980 980 var $create_step_position = 81; 981 981 var $nav_item_position = 81; 982 982 983 983 var $enable_create_step = true; 984 984 var $enable_nav_item = true; 985 985 var $enable_edit_item = true; 986 986 987 987 var $nav_item_name = false; 988 988 989 989 var $display_hook = 'groups_custom_group_boxes'; 990 990 var $template_file = 'plugin-template'; 991 991 992 992 // Methods you should override 993 993 994 994 function display() { 995 995 die( 'function BP_Group_Extension::display() must be over-ridden in a sub-class.' ); 996 996 } 997 997 998 998 function widget_display() { 999 999 die( 'function BP_Group_Extension::widget_display() must be over-ridden in a sub-class.' ); 1000 1000 } 1001 1001 1002 1002 function edit_screen() { 1003 1003 die( 'function BP_Group_Extension::edit_screen() must be over-ridden in a sub-class.' ); 1004 1004 } 1005 1005 1006 1006 function edit_screen_save() { 1007 1007 die( 'function BP_Group_Extension::edit_screen_save() must be over-ridden in a sub-class.' ); 1008 1008 } 1009 1009 1010 1010 function create_screen() { 1011 1011 die( 'function BP_Group_Extension::create_screen() must be over-ridden in a sub-class.' ); 1012 1012 } 1013 1013 1014 1014 function create_screen_save() { 1015 die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' ); 1016 } 1017 1015 die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' ); 1016 } 1017 1018 1018 // Private Methods 1019 1019 1020 1020 function _register() { 1021 1021 global $bp; … … 1027 1027 /* Attach the group creation step display content action */ 1028 1028 add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) ); 1029 1029 1030 1030 /* Attach the group creation step save content action */ 1031 1031 add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) ); 1032 1032 } 1033 1033 1034 1034 /* Construct the admin edit tab for the new group extension */ 1035 1035 if ( $this->enable_edit_item ) { 1036 add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 ); 1036 add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 ); 1037 1037 1038 1038 /* Catch the edit screen and forward it to the plugin template */ … … 1042 1042 1043 1043 if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) { 1044 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) ); 1044 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) ); 1045 1045 } else { 1046 1046 add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) ); 1047 1047 add_action( 'bp_template_content', array( &$this, 'edit_screen' ) ); 1048 bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 1048 bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 1049 1049 } 1050 1050 } … … 1055 1055 if ( $this->enable_nav_item ) { 1056 1056 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item ) 1057 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ) . '/', 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) ); 1057 bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ) . '/', 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) ); 1058 1058 1059 1059 /* When we are viewing the extension display page, set the title and options title */ … … 1063 1063 } 1064 1064 } 1065 1065 1066 1066 /* Hook the group home widget */ 1067 1067 if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) … … 1069 1069 } 1070 1070 } 1071 1071 1072 1072 function _display_hook() { 1073 1073 add_action( 'bp_template_content', array( &$this, 'display' ) ); … … 1078 1078 function bp_register_group_extension( $group_extension_class ) { 1079 1079 global $bp; 1080 1080 1081 1081 if ( !class_exists( $group_extension_class ) ) 1082 1082 return false; 1083 1083 1084 1084 /* Register the group extension on the plugins_loaded action so we have access to all plugins */ 1085 1085 add_action( 'plugins_loaded', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ) ); -
trunk/bp-groups/bp-groups-filters.php
r2026 r2077 61 61 function groups_add_forum_privacy_sql() { 62 62 global $bp; 63 63 64 64 /* Only filter the forum SQL on group pages or on the forums directory */ 65 65 if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) || bp_is_directory() ) { … … 82 82 function groups_add_forum_where_sql( $sql ) { 83 83 global $bp; 84 84 85 85 $bp->groups->filter_sql = ' AND ' . $sql; 86 86 return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND " . $sql; … … 92 92 if ( is_site_admin() ) 93 93 return true; 94 94 95 95 if ( 'add_tag_to' == $cap ) 96 96 if ( $bp->groups->current_group->user_has_access ) return true; 97 97 98 98 if ( 'manage_forums' == $cap && is_user_logged_in() ) 99 99 return true; 100 100 101 101 return $value; 102 102 } -
trunk/bp-groups/bp-groups-notifications.php
r1905 r2077 3 3 function groups_notification_new_wire_post( $group_id, $wire_post_id ) { 4 4 global $bp; 5 5 6 6 if ( !isset( $_POST['wire-post-email-notify'] ) ) 7 7 return false; 8 8 9 9 $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id ); 10 10 $group = new BP_Groups_Group( $group_id, false, true ); 11 11 12 12 $poster_name = bp_core_get_user_displayname( $wire_post->user_id ); 13 $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id ); 13 $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id ); 14 14 15 15 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); … … 17 17 foreach ( $group->user_dataset as $user ) { 18 18 if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue; 19 19 20 20 $ud = get_userdata( $user->user_id ); 21 21 22 22 // Set up and send the message 23 23 $to = $ud->user_email; … … 25 25 $wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' ); 26 26 $group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' ); 27 $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/'; 28 29 $message = sprintf( __( 27 $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/'; 28 29 $message = sprintf( __( 30 30 '%s posted on the wire of the group "%s": 31 31 … … 45 45 // Send it 46 46 wp_mail( $to, $subject, $message ); 47 47 48 48 unset( $message, $to ); 49 49 } … … 52 52 function groups_notification_group_updated( $group_id ) { 53 53 global $bp; 54 54 55 55 $group = new BP_Groups_Group( $group_id, false, true ); 56 56 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' ); … … 58 58 foreach ( $group->user_dataset as $user ) { 59 59 if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue; 60 60 61 61 $ud = get_userdata( $user->user_id ); 62 62 63 63 // Set up and send the message 64 64 $to = $ud->user_email; … … 67 67 $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/'; 68 68 69 $message = sprintf( __( 69 $message = sprintf( __( 70 70 'Group details for the group "%s" were updated: 71 71 … … 91 91 if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) ) 92 92 return false; 93 93 94 94 $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id ); 95 95 $group = new BP_Groups_Group( $group_id, false, false ); 96 96 97 97 $ud = get_userdata($admin_id); 98 98 $requesting_ud = get_userdata($requesting_user_id); … … 106 106 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); 107 107 108 $message = sprintf( __( 108 $message = sprintf( __( 109 109 '%s wants to join the group "%s". 110 110 … … 122 122 123 123 // Send it 124 wp_mail( $to, $subject, $message ); 124 wp_mail( $to, $subject, $message ); 125 125 } 126 126 127 127 function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) { 128 128 global $bp; 129 129 130 130 // Post a screen notification first. 131 131 if ( $accepted ) … … 133 133 else 134 134 bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' ); 135 135 136 136 if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) ) 137 137 return false; 138 138 139 139 $group = new BP_Groups_Group( $group_id, false, false ); 140 140 141 141 $ud = get_userdata($requesting_user_id); 142 142 … … 146 146 // Set up and send the message 147 147 $to = $ud->user_email; 148 148 149 149 if ( $accepted ) { 150 150 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); 151 $message = sprintf( __( 151 $message = sprintf( __( 152 152 'Your membership request for the group "%s" has been accepted. 153 153 … … 156 156 --------------------- 157 157 ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link ); 158 158 159 159 } else { 160 160 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); 161 $message = sprintf( __( 161 $message = sprintf( __( 162 162 'Your membership request for the group "%s" has been rejected. 163 163 … … 167 167 ', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link ); 168 168 } 169 169 170 170 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 171 171 172 172 // Send it 173 wp_mail( $to, $subject, $message ); 173 wp_mail( $to, $subject, $message ); 174 174 } 175 175 … … 184 184 $type = 'member_promoted_to_mod'; 185 185 } 186 186 187 187 // Post a screen notification first. 188 188 bp_core_add_notification( $group_id, $user_id, 'groups', $type ); … … 202 202 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); 203 203 204 $message = sprintf( __( 204 $message = sprintf( __( 205 205 'You have been promoted to %s for the group: "%s". 206 206 … … 219 219 function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) { 220 220 global $bp; 221 221 222 222 $inviter_ud = get_userdata( $inviter_user_id ); 223 223 $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true ); 224 224 $inviter_link = bp_core_get_user_domain( $inviter_user_id ); 225 225 226 226 $group_link = bp_get_group_permalink( $group ); 227 227 228 228 if ( !$member->invite_sent ) { 229 229 $invited_user_id = $member->user_id; … … 236 236 237 237 $invited_ud = get_userdata($invited_user_id); 238 238 239 239 $settings_link = bp_core_get_user_domain( $invited_user_id ) . 'settings/notifications/'; 240 240 $invited_link = bp_core_get_user_domain( $invited_user_id ); … … 246 246 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) ); 247 247 248 $message = sprintf( __( 248 $message = sprintf( __( 249 249 'One of your friends %s has invited you to the group: "%s". 250 250 -
trunk/bp-groups/bp-groups-templatetags.php
r2055 r2077 9 9 <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li> 10 10 <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li> 11 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> 11 <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li> 12 12 <?php 13 13 do_action( 'groups_header_tabs' ); … … 16 16 function bp_groups_filter_title() { 17 17 global $bp; 18 18 19 19 $current_filter = $bp->action_variables[0]; 20 20 21 21 switch ( $current_filter ) { 22 22 case 'recently-active': default: … … 44 44 function bp_is_group_admin_screen( $slug ) { 45 45 global $bp; 46 46 47 47 if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action ) 48 48 return false; 49 49 50 50 if ( $bp->action_variables[0] == $slug ) 51 51 return true; 52 52 53 53 return false; 54 54 } … … 56 56 function bp_group_current_avatar() { 57 57 global $bp; 58 58 59 59 if ( $bp->groups->current_group->avatar_full ) { ?> 60 60 <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" /> … … 70 70 if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) ) 71 71 return false; 72 72 73 73 return true; 74 74 } … … 79 79 function bp_get_group_avatar_delete_link() { 80 80 global $bp; 81 81 82 82 return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) ); 83 83 } … … 113 113 var $groups; 114 114 var $group; 115 115 116 116 var $in_the_loop; 117 117 118 118 var $pag_page; 119 119 var $pag_num; 120 120 var $pag_links; 121 121 var $total_group_count; 122 122 123 123 var $single_group = false; 124 124 125 125 var $sort_by; 126 126 var $order; 127 127 128 128 function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) { 129 129 global $bp; 130 130 131 131 if ( !$user_id ) 132 132 $user_id = $bp->displayed_user->id; 133 133 134 134 $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1; 135 135 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 141 141 142 142 case 'popular': 143 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 143 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 144 144 break; 145 145 146 146 case 'admin-of': 147 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 148 break; 147 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 148 break; 149 149 150 150 case 'mod-of': 151 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 151 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter ); 152 152 break; 153 153 154 154 case 'alphabetical': 155 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 155 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter ); 156 156 break; 157 157 … … 162 162 case 'single-group': 163 163 $group = new stdClass; 164 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 164 $group->group_id = BP_Groups_Group::get_id_from_slug($slug); 165 165 $this->groups = array( $group ); 166 166 break; … … 170 170 break; 171 171 } 172 172 173 173 if ( 'invites' == $type ) { 174 174 $this->total_group_count = count($this->groups); … … 210 210 if ( $this->group_count ) 211 211 return true; 212 212 213 213 return false; 214 214 } 215 215 216 216 function next_group() { 217 217 $this->current_group++; 218 218 $this->group = $this->groups[$this->current_group]; 219 219 220 220 return $this->group; 221 221 } 222 222 223 223 function rewind_groups() { 224 224 $this->current_group = -1; … … 227 227 } 228 228 } 229 230 function user_groups() { 229 230 function user_groups() { 231 231 if ( $this->current_group + 1 < $this->group_count ) { 232 232 return true; … … 240 240 return false; 241 241 } 242 242 243 243 function the_group() { 244 244 global $group; … … 246 246 $this->in_the_loop = true; 247 247 $this->group = $this->next_group(); 248 248 249 249 // If this is a single group then instantiate group meta when creating the object. 250 250 if ( $this->single_group ) { … … 259 259 } 260 260 } 261 261 262 262 $this->group = $group; 263 263 264 264 if ( 0 == $this->current_group ) // loop has just started 265 265 do_action('loop_start'); … … 269 269 function bp_has_groups( $args = '' ) { 270 270 global $groups_template, $bp; 271 271 272 272 $defaults = array( 273 273 'type' => 'active', … … 281 281 $r = wp_parse_args( $args, $defaults ); 282 282 extract( $r, EXTR_SKIP ); 283 283 284 284 /* The following code will auto set parameters based on the page being viewed. 285 285 * for example on example.com/members/andy/groups/my-groups/most-popular/ … … 304 304 $slug = $bp->groups->current_group->slug; 305 305 } 306 306 307 307 if ( isset( $_REQUEST['group-filter-box'] ) ) 308 308 $filter = $_REQUEST['group-filter-box']; 309 309 310 310 $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter ); 311 311 return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template ); … … 324 324 function bp_group_is_visible( $group = false ) { 325 325 global $bp, $groups_template; 326 326 327 327 if ( !$group ) 328 328 $group =& $groups_template->group; 329 329 330 330 if ( 'public' == $group->status ) { 331 331 return true; … … 335 335 } 336 336 } 337 337 338 338 return false; 339 339 } … … 341 341 function bp_group_has_news( $group = false ) { 342 342 global $groups_template; 343 343 344 344 if ( !$group ) 345 345 $group =& $groups_template->group; 346 346 347 347 if ( empty( $group->news ) ) 348 348 return false; 349 349 350 350 return true; 351 351 } … … 367 367 return apply_filters( 'bp_get_group_id', $group->id ); 368 368 } 369 369 370 370 function bp_group_name( $deprecated = true, $deprecated2 = false ) { 371 371 global $groups_template; … … 396 396 if ( 'public' == $group->status ) { 397 397 $type = __( "Public Group", "buddypress" ); 398 } else if ( 'hidden' == $group->status ) { 398 } else if ( 'hidden' == $group->status ) { 399 399 $type = __( "Hidden Group", "buddypress" ); 400 400 } else if ( 'private' == $group->status ) { … … 404 404 } 405 405 406 return apply_filters( 'bp_get_group_type', $type ); 406 return apply_filters( 'bp_get_group_type', $type ); 407 407 } 408 408 … … 416 416 $group =& $groups_template->group; 417 417 418 return apply_filters( 'bp_get_group_status', $group->status ); 418 return apply_filters( 'bp_get_group_status', $group->status ); 419 419 } 420 420 … … 431 431 'class' => 'avatar', 432 432 'id' => false, 433 'alt' => __( 'Group avatar', 'buddypress' ) 433 'alt' => __( 'Group avatar', 'buddypress' ) 434 434 ); 435 435 436 436 $r = wp_parse_args( $args, $defaults ); 437 437 extract( $r, EXTR_SKIP ); 438 438 439 439 /* Fetch the avatar from the folder, if not provide backwards compat. */ 440 440 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 ) ) ) … … 462 462 return bp_get_group_last_active(); 463 463 else 464 echo bp_get_group_last_active(); 464 echo bp_get_group_last_active(); 465 465 } 466 466 function bp_get_group_last_active( $group = false ) { … … 475 475 return __( 'not yet active', 'buddypress' ); 476 476 } else { 477 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 478 } 479 } 480 477 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) ); 478 } 479 } 480 481 481 function bp_group_permalink( $deprecated = false, $deprecated2 = true ) { 482 482 if ( !$deprecated2 ) … … 506 506 $group =& $groups_template->group; 507 507 508 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 508 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 509 509 } 510 510 … … 557 557 $group =& $groups_template->group; 558 558 559 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 559 return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) ); 560 560 } 561 561 … … 599 599 } 600 600 } 601 601 602 602 function bp_group_is_public( $deprecated = false ) { 603 603 echo bp_get_group_is_public(); … … 626 626 function bp_group_is_admin() { 627 627 global $bp; 628 628 629 629 return $bp->is_item_admin; 630 630 } … … 632 632 function bp_group_is_mod() { 633 633 global $bp; 634 634 635 635 return $bp->is_item_mod; 636 636 } … … 638 638 function bp_group_list_admins( $full_list = true, $group = false ) { 639 639 global $groups_template; 640 640 641 641 if ( !$group ) 642 642 $group =& $groups_template->group; 643 643 644 644 if ( !$admins = &$group->admins ) 645 645 $admins = $group->get_administrators(); … … 665 665 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 666 666 <?php } ?> 667 667 668 668 <?php 669 669 } … … 671 671 function bp_group_list_mods( $full_list = true, $group = false ) { 672 672 global $groups_template; 673 673 674 674 if ( !$group ) 675 675 $group =& $groups_template->group; 676 676 677 677 $group_mods = groups_get_group_mods( $group->id ); 678 678 679 679 if ( $group_mods ) { 680 680 if ( $full_list ) { ?> … … 697 697 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 698 698 <?php } ?> 699 699 700 700 <?php 701 701 } … … 706 706 if ( !$group ) 707 707 $group =& $groups_template->group; 708 708 709 709 if ( !$deprecated ) 710 710 return bp_get_group_all_members_permalink(); … … 731 731 <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label> 732 732 <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> /> 733 733 734 734 <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?> 735 735 </form> … … 739 739 function bp_group_show_no_groups_message() { 740 740 global $bp; 741 741 742 742 if ( !groups_total_groups_for_user( $bp->displayed_user->id ) ) 743 743 return true; 744 744 745 745 return false; 746 746 } … … 751 751 function bp_get_group_pagination() { 752 752 global $groups_template; 753 753 754 754 return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links ); 755 755 } … … 762 762 763 763 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> 764 <span class="ajax-loader"></span><?php 764 <span class="ajax-loader"></span><?php 765 765 } 766 766 … … 804 804 if ( !$group ) 805 805 $group =& $groups_template->group; 806 806 807 807 if ( $group->enable_wire ) 808 808 return true; 809 809 810 810 return false; 811 811 } … … 833 833 if ( $group->enable_forum ) 834 834 return true; 835 835 836 836 return false; 837 837 } else { … … 839 839 } 840 840 } 841 842 return false; 841 842 return false; 843 843 } 844 844 … … 848 848 if ( !$group ) 849 849 $group =& $groups_template->group; 850 850 851 851 if ( $group->enable_forum ) 852 852 echo ' checked="checked"'; … … 858 858 if ( !$group ) 859 859 $group =& $groups_template->group; 860 860 861 861 if ( $setting == $group->status ) 862 862 echo ' checked="checked"'; … … 865 865 function bp_group_admin_memberlist( $admin_list = false, $group = false ) { 866 866 global $groups_template; 867 867 868 868 if ( !$group ) 869 869 $group =& $groups_template->group; 870 870 871 871 $admins = groups_get_group_admins( $group->id ); 872 872 ?> … … 884 884 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 885 885 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 886 886 887 887 <?php if ( function_exists( 'friends_install' ) ) : ?> 888 888 <div class="action"> … … 890 890 </div> 891 891 <?php endif; ?> 892 </li> 892 </li> 893 893 <?php } ?> 894 894 <?php } ?> … … 902 902 903 903 function bp_group_mod_memberlist( $admin_list = false, $group = false ) { 904 global $groups_template, $group_mods; 904 global $groups_template, $group_mods; 905 905 906 906 if ( !$group ) 907 907 $group =& $groups_template->group; 908 908 909 909 $group_mods = groups_get_group_mods( $group->id ); 910 910 ?> … … 922 922 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 923 923 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> 924 924 925 925 <?php if ( function_exists( 'friends_install' ) ) : ?> 926 926 <div class="action"> … … 928 928 </div> 929 929 <?php endif; ?> 930 </li> 931 <?php } ?> 930 </li> 931 <?php } ?> 932 932 <?php } ?> 933 933 </ul> … … 1001 1001 return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) ); 1002 1002 } 1003 1003 1004 1004 function bp_group_member_ban_link( $user_id = false, $deprecated = false ) { 1005 1005 global $members_template; … … 1024 1024 if ( !$user_id ) 1025 1025 $user_id = $members_template->member->user_id; 1026 1027 echo bp_get_group_member_unban_link( $user_id ); 1026 1027 echo bp_get_group_member_unban_link( $user_id ); 1028 1028 } 1029 1029 function bp_get_group_member_unban_link( $user_id = false, $group = false ) { … … 1032 1032 if ( !$user_id ) 1033 1033 $user_id = $members_template->member->user_id; 1034 1035 if ( !$group ) 1036 $group =& $groups_template->group; 1037 1038 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' ) ); 1034 1035 if ( !$group ) 1036 $group =& $groups_template->group; 1037 1038 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' ) ); 1039 1039 } 1040 1040 … … 1044 1044 if ( !$group ) 1045 1045 $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group; 1046 1046 1047 1047 $current_tab = $bp->action_variables[0]; 1048 1048 ?> … … 1050 1050 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li> 1051 1051 <?php } ?> 1052 1052 1053 1053 <?php 1054 1054 if ( !$bp->is_item_admin ) … … 1062 1062 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li> 1063 1063 <?php endif; ?> 1064 1064 1065 1065 <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?> 1066 1066 1067 1067 <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li> 1068 1068 <?php … … 1087 1087 return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page ); 1088 1088 } 1089 1089 1090 1090 function bp_group_admin_form_action( $page = false, $deprecated = false ) { 1091 1091 echo bp_get_group_admin_form_action( $page ); … … 1105 1105 function bp_group_has_requested_membership( $group = false ) { 1106 1106 global $bp, $groups_template; 1107 1107 1108 1108 if ( !$group ) 1109 1109 $group =& $groups_template->group; 1110 1110 1111 1111 if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) ) 1112 1112 return true; 1113 1113 1114 1114 return false; 1115 1115 } … … 1120 1120 if ( !$group ) 1121 1121 $group =& $groups_template->group; 1122 1122 1123 1123 if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) 1124 1124 return true; 1125 1125 1126 1126 return false; 1127 1127 } … … 1136 1136 $group =& $groups_template->group; 1137 1137 1138 return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 1138 return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) ); 1139 1139 } 1140 1140 … … 1160 1160 $group =& $groups_template->group; 1161 1161 1162 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1162 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 1163 1163 } 1164 1164 … … 1189 1189 function bp_has_friends_to_invite( $group = false ) { 1190 1190 global $groups_template, $bp; 1191 1191 1192 1192 if ( !function_exists('friends_install') ) 1193 1193 return false; … … 1195 1195 if ( !$group ) 1196 1196 $group =& $groups_template->group; 1197 1197 1198 1198 if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) ) 1199 1199 return false; 1200 1200 1201 1201 return true; 1202 1202 } … … 1204 1204 function bp_group_join_button( $group = false ) { 1205 1205 global $bp, $groups_template; 1206 1206 1207 1207 if ( !$group ) 1208 1208 $group =& $groups_template->group; 1209 1209 1210 1210 // If they're not logged in or are banned from the group, no join button. 1211 1211 if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) ) … … 1214 1214 if ( !$group->status ) 1215 1215 return false; 1216 1216 1217 1217 echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">'; 1218 1218 1219 1219 switch ( $group->status ) { 1220 1220 case 'public': 1221 1221 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) 1222 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1222 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1223 1223 else 1224 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1224 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>'; 1225 1225 break; 1226 1226 1227 1227 case 'private': 1228 1228 if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) { 1229 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1229 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>'; 1230 1230 } else { 1231 1231 if ( !bp_group_has_requested_membership( $group ) ) 1232 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1232 echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>'; 1233 1233 else 1234 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1234 echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>'; 1235 1235 } 1236 1236 break; 1237 1237 } 1238 1238 1239 1239 echo '</div>'; 1240 1240 } … … 1242 1242 function bp_group_status_message( $group = false ) { 1243 1243 global $groups_template; 1244 1244 1245 1245 if ( !$group ) 1246 1246 $group =& $groups_template->group; 1247 1247 1248 1248 if ( 'private' == $group->status ) { 1249 1249 if ( !bp_group_has_requested_membership() ) … … 1252 1252 else 1253 1253 _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' ); 1254 else 1255 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1254 else 1255 _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' ); 1256 1256 } else { 1257 1257 _e( 'This is a hidden group and only invited members can join.', 'buddypress' ); … … 1269 1269 var $members; 1270 1270 var $member; 1271 1271 1272 1272 var $in_the_loop; 1273 1273 1274 1274 var $pag_page; 1275 1275 var $pag_num; 1276 1276 var $pag_links; 1277 1277 var $total_group_count; 1278 1278 1279 1279 function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) { 1280 1280 global $bp; 1281 1281 1282 1282 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 1283 1283 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1284 1284 1285 1285 $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned ); 1286 1286 1287 1287 if ( !$max || $max >= (int)$this->members['count'] ) 1288 1288 $this->total_member_count = (int)$this->members['count']; … … 1291 1291 1292 1292 $this->members = $this->members['members']; 1293 1293 1294 1294 if ( $max ) { 1295 1295 if ( $max >= count($this->members) ) … … 1311 1311 )); 1312 1312 } 1313 1313 1314 1314 function has_members() { 1315 1315 if ( $this->member_count ) … … 1318 1318 return false; 1319 1319 } 1320 1320 1321 1321 function next_member() { 1322 1322 $this->current_member++; 1323 1323 $this->member = $this->members[$this->current_member]; 1324 1324 1325 1325 return $this->member; 1326 1326 } 1327 1327 1328 1328 function rewind_members() { 1329 1329 $this->current_member = -1; … … 1332 1332 } 1333 1333 } 1334 1335 function members() { 1334 1335 function members() { 1336 1336 if ( $this->current_member + 1 < $this->member_count ) { 1337 1337 return true; … … 1345 1345 return false; 1346 1346 } 1347 1347 1348 1348 function the_member() { 1349 1349 global $member; … … 1359 1359 function bp_group_has_members( $args = '' ) { 1360 1360 global $bp, $members_template; 1361 1361 1362 1362 $defaults = array( 1363 1363 'group_id' => $bp->groups->current_group->id, … … 1377 1377 function bp_group_members() { 1378 1378 global $members_template; 1379 1379 1380 1380 return $members_template->members(); 1381 1381 } … … 1383 1383 function bp_group_the_member() { 1384 1384 global $members_template; 1385 1385 1386 1386 return $members_template->the_member(); 1387 1387 } … … 1440 1440 return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) ); 1441 1441 } 1442 1442 1443 1443 function bp_group_member_is_banned() { 1444 1444 echo bp_get_group_member_is_banned(); … … 1458 1458 return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) ); 1459 1459 } 1460 1460 1461 1461 function bp_group_member_id() { 1462 1462 echo bp_get_group_member_id(); … … 1473 1473 if ( $members_template->total_member_count > $members_template->pag_num ) 1474 1474 return true; 1475 1475 1476 1476 return false; 1477 1477 } … … 1502 1502 1503 1503 $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 1504 $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ); 1505 1506 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); 1504 $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ); 1505 1506 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); 1507 1507 } 1508 1508 … … 1513 1513 function bp_get_group_member_admin_pagination() { 1514 1514 global $members_template; 1515 1515 1516 1516 return $members_template->pag_links; 1517 1517 } … … 1524 1524 function bp_group_creation_tabs() { 1525 1525 global $bp; 1526 1526 1527 1527 if ( !is_array( $bp->groups->group_creation_steps ) ) 1528 1528 return false; 1529 1529 1530 1530 if ( !$bp->groups->current_create_step ) 1531 1531 $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); … … 1534 1534 foreach ( $bp->groups->group_creation_steps as $slug => $step ) { 1535 1535 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?> 1536 1536 1537 1537 <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php 1538 1538 $counter++; 1539 1539 } 1540 1540 1541 1541 unset( $is_enabled ); 1542 1542 1543 1543 do_action( 'groups_creation_tabs' ); 1544 1544 } … … 1546 1546 function bp_group_creation_stage_title() { 1547 1547 global $bp; 1548 1548 1549 1549 echo apply_filters( 'bp_group_creation_stage_title', '<span>— ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' ); 1550 1550 } … … 1555 1555 function bp_get_group_creation_form_action() { 1556 1556 global $bp; 1557 1557 1558 1558 if ( empty( $bp->action_variables[1] ) ) 1559 1559 $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1560 1560 1561 1561 return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] ); 1562 1562 } … … 1564 1564 function bp_is_group_creation_step( $step_slug ) { 1565 1565 global $bp; 1566 1566 1567 1567 /* Make sure we are in the groups component */ 1568 1568 if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action ) 1569 1569 return false; 1570 1570 1571 1571 /* If this the first step, we can just accept and return true */ 1572 1572 if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1573 1573 return true; 1574 1574 1575 1575 /* Before allowing a user to see a group creation step we must make sure previous steps are completed */ 1576 1576 if ( !bp_is_first_group_creation_step() ) { … … 1578 1578 return false; 1579 1579 } 1580 1580 1581 1581 /* Check the current step against the step parameter */ 1582 1582 if ( $bp->action_variables[1] == $step_slug ) 1583 1583 return true; 1584 1584 1585 1585 return false; 1586 1586 } … … 1588 1588 function bp_is_group_creation_step_complete( $step_slugs ) { 1589 1589 global $bp; 1590 1590 1591 1591 if ( !$bp->groups->completed_create_steps ) 1592 1592 return false; … … 1594 1594 if ( is_array( $step_slugs ) ) { 1595 1595 $found = true; 1596 1596 1597 1597 foreach ( $step_slugs as $step_slug ) { 1598 1598 if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) ) 1599 1599 $found = false; 1600 1600 } 1601 1601 1602 1602 return $found; 1603 1603 } else { 1604 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1604 return in_array( $step_slugs, $bp->groups->completed_create_steps ); 1605 1605 } 1606 1606 … … 1610 1610 function bp_are_previous_group_creation_steps_complete( $step_slug ) { 1611 1611 global $bp; 1612 1612 1613 1613 /* If this is the first group creation step, return true */ 1614 1614 if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1615 1615 return true; 1616 1616 1617 1617 reset( $bp->groups->group_creation_steps ); 1618 1618 unset( $previous_steps ); 1619 1619 1620 1620 /* Get previous steps */ 1621 1621 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1622 1622 if ( $slug == $step_slug ) 1623 1623 break; 1624 1624 1625 1625 $previous_steps[] = $slug; 1626 1626 } 1627 1627 1628 1628 return bp_is_group_creation_step_complete( $previous_steps ); 1629 1629 } … … 1636 1636 return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id ); 1637 1637 } 1638 1638 1639 1639 function bp_new_group_name() { 1640 1640 echo bp_get_new_group_name(); … … 1690 1690 function bp_get_new_group_avatar( $args = '' ) { 1691 1691 global $bp; 1692 1692 1693 1693 $defaults = array( 1694 1694 'type' => 'full', … … 1697 1697 'class' => 'avatar', 1698 1698 'id' => 'avatar-crop-preview', 1699 'alt' => __( 'Group avatar', 'buddypress' ) 1699 'alt' => __( 'Group avatar', 'buddypress' ) 1700 1700 ); 1701 1701 1702 1702 $r = wp_parse_args( $args, $defaults ); 1703 1703 extract( $r, EXTR_SKIP ); 1704 1704 1705 1705 return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) ); 1706 1706 } … … 1711 1711 function bp_get_group_creation_previous_link() { 1712 1712 global $bp; 1713 1713 1714 1714 foreach ( $bp->groups->group_creation_steps as $slug => $name ) { 1715 1715 if ( $slug == $bp->action_variables[1] ) 1716 1716 break; 1717 1717 1718 1718 $previous_steps[] = $slug; 1719 1719 } … … 1724 1724 function bp_is_last_group_creation_step() { 1725 1725 global $bp; 1726 1726 1727 1727 $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) ); 1728 1728 1729 1729 if ( $last_step == $bp->groups->current_create_step ) 1730 1730 return true; 1731 1731 1732 1732 return false; 1733 1733 } … … 1735 1735 function bp_is_first_group_creation_step() { 1736 1736 global $bp; 1737 1737 1738 1738 $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1739 1739 1740 1740 if ( $first_step == $bp->groups->current_create_step ) 1741 1741 return true; 1742 1742 1743 1743 return false; 1744 1744 } … … 1752 1752 if ( !function_exists('friends_install') ) 1753 1753 return false; 1754 1754 1755 1755 $defaults = array( 1756 1756 'group_id' => false, … … 1760 1760 $r = wp_parse_args( $args, $defaults ); 1761 1761 extract( $r, EXTR_SKIP ); 1762 1762 1763 1763 if ( !$group_id ) 1764 1764 $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id; 1765 1765 1766 1766 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id ); 1767 1767 1768 1768 if ( $friends ) { 1769 1769 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id ); … … 1775 1775 } else { 1776 1776 $checked = ''; 1777 } 1777 } 1778 1778 } 1779 1779 1780 1780 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>'; 1781 1781 } 1782 1782 } 1783 1783 1784 1784 return implode( "\n", (array)$items ); 1785 1785 } … … 1794 1794 var $groups; 1795 1795 var $group; 1796 1796 1797 1797 var $in_the_loop; 1798 1798 1799 1799 var $pag_page; 1800 1800 var $pag_num; 1801 1801 var $pag_links; 1802 1802 var $total_group_count; 1803 1803 1804 1804 function bp_groups_site_groups_template( $type, $per_page, $max ) { 1805 1805 global $bp; 1806 1806 1807 1807 /* TODO: Move $_REQUEST vars out of here */ 1808 1808 1809 1809 $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1; 1810 1810 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 1814 1814 } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) { 1815 1815 $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page ); 1816 1816 1817 1817 } else { 1818 1818 switch ( $type ) { 1819 1819 case 'active': default: 1820 1820 $this->groups = groups_get_active( $this->pag_num, $this->pag_page ); 1821 break; 1821 break; 1822 1822 1823 1823 case 'alphabetical': default: 1824 1824 $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page ); 1825 break; 1826 1827 case 'random': 1825 break; 1826 1827 case 'random': 1828 1828 $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page ); 1829 1829 break; 1830 1830 1831 1831 case 'newest': 1832 1832 $this->groups = groups_get_newest( $this->pag_num, $this->pag_page ); … … 1835 1835 case 'popular': 1836 1836 $this->groups = groups_get_popular( $this->pag_num, $this->pag_page ); 1837 break; 1837 break; 1838 1838 1839 1839 case 'most-forum-topics': 1840 1840 $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page ); 1841 1841 break; 1842 1842 1843 1843 case 'most-forum-posts': 1844 1844 $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page ); … … 1846 1846 } 1847 1847 } 1848 1848 1849 1849 if ( !$max || $max >= (int)$this->groups['total'] ) 1850 1850 $this->total_group_count = (int)$this->groups['total']; … … 1853 1853 1854 1854 $this->groups = $this->groups['groups']; 1855 1855 1856 1856 if ( $max ) { 1857 1857 if ( $max >= count($this->groups) ) … … 1862 1862 $this->group_count = count($this->groups); 1863 1863 } 1864 1864 1865 1865 if ( (int) $this->total_group_count && (int) $this->pag_num ) { 1866 1866 $this->pag_links = paginate_links( array( … … 1872 1872 'next_text' => '»', 1873 1873 'mid_size' => 1 1874 )); 1875 } 1876 } 1877 1874 )); 1875 } 1876 } 1877 1878 1878 function has_groups() { 1879 1879 if ( $this->group_count ) 1880 1880 return true; 1881 1881 1882 1882 return false; 1883 1883 } 1884 1884 1885 1885 function next_group() { 1886 1886 $this->current_group++; 1887 1887 $this->group = $this->groups[$this->current_group]; 1888 1888 1889 1889 return $this->group; 1890 1890 } 1891 1891 1892 1892 function rewind_groups() { 1893 1893 $this->current_group = -1; … … 1896 1896 } 1897 1897 } 1898 1899 function groups() { 1898 1899 function groups() { 1900 1900 if ( $this->current_group + 1 < $this->group_count ) { 1901 1901 return true; … … 1909 1909 return false; 1910 1910 } 1911 1911 1912 1912 function the_group() { 1913 1913 global $group; … … 1915 1915 $this->in_the_loop = true; 1916 1916 $this->group = $this->next_group(); 1917 1917 1918 1918 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) { 1919 1919 $group = new BP_Groups_Group( $this->group->group_id, false, false ); 1920 1920 wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' ); 1921 1921 } 1922 1922 1923 1923 $this->group = $group; 1924 1924 1925 1925 if ( 0 == $this->current_group ) // loop has just started 1926 1926 do_action('loop_start'); … … 1930 1930 function bp_rewind_site_groups() { 1931 1931 global $site_groups_template; 1932 1933 $site_groups_template->rewind_groups(); 1932 1933 $site_groups_template->rewind_groups(); 1934 1934 } 1935 1935 … … 1945 1945 $r = wp_parse_args( $args, $defaults ); 1946 1946 extract( $r, EXTR_SKIP ); 1947 1947 1948 1948 // type: active ( default ) | random | newest | popular 1949 1949 1950 1950 if ( $max ) { 1951 1951 if ( $per_page > $max ) 1952 1952 $per_page = $max; 1953 1953 } 1954 1954 1955 1955 $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max ); 1956 1956 return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template ); … … 1959 1959 function bp_site_groups() { 1960 1960 global $site_groups_template; 1961 1961 1962 1962 return $site_groups_template->groups(); 1963 1963 } … … 1965 1965 function bp_the_site_group() { 1966 1966 global $site_groups_template; 1967 1967 1968 1968 return $site_groups_template->the_group(); 1969 1969 } … … 1971 1971 function bp_site_groups_pagination_count() { 1972 1972 global $bp, $site_groups_template; 1973 1973 1974 1974 $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1; 1975 1975 $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ; 1976 1976 1977 1977 echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> 1978 <span class="ajax-loader"></span><?php 1978 <span class="ajax-loader"></span><?php 1979 1979 } 1980 1980 … … 1984 1984 function bp_get_site_groups_pagination_links() { 1985 1985 global $site_groups_template; 1986 1986 1987 1987 return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links ); 1988 1988 } … … 1993 1993 function bp_get_the_site_group_id() { 1994 1994 global $site_groups_template; 1995 1995 1996 1996 return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id ); 1997 1997 } … … 2011 2011 function bp_get_the_site_group_avatar_thumb() { 2012 2012 global $site_groups_template; 2013 2013 2014 2014 return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ); 2015 2015 } … … 2029 2029 function bp_get_the_site_group_link() { 2030 2030 global $site_groups_template; 2031 2031 2032 2032 return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) ); 2033 2033 } … … 2041 2041 return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) ); 2042 2042 } 2043 2043 2044 2044 2045 2045 function bp_the_site_group_last_active() { … … 2054 2054 function bp_the_site_group_join_button() { 2055 2055 global $site_groups_template; 2056 2056 2057 2057 echo bp_group_join_button( $site_groups_template->group ); 2058 2058 } … … 2064 2064 global $site_groups_template; 2065 2065 2066 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2066 return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 2067 2067 } 2068 2068 … … 2073 2073 global $site_groups_template; 2074 2074 2075 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) ); 2075 return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) ); 2076 2076 } 2077 2077 2078 2078 function bp_the_site_group_date_created() { 2079 echo bp_get_the_site_group_date_created(); 2079 echo bp_get_the_site_group_date_created(); 2080 2080 } 2081 2081 function bp_get_the_site_group_date_created() { 2082 2082 global $site_groups_template; 2083 2083 2084 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2084 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2085 2085 } 2086 2086 … … 2094 2094 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2095 2095 else 2096 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2096 return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) ); 2097 2097 } 2098 2098 … … 2124 2124 if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) ) 2125 2125 return false; 2126 2126 2127 2127 if ( !$site_groups_template->group->forum_counts ) 2128 2128 $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id ); … … 2132 2132 $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2133 2133 else 2134 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2134 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics ); 2135 2135 } else { 2136 2136 $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics; 2137 2137 } 2138 2138 2139 2139 return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext ); 2140 2140 } … … 2145 2145 function bp_get_the_site_group_forum_post_count( $args = '' ) { 2146 2146 global $site_groups_template; 2147 2147 2148 2148 $defaults = array( 2149 2149 'showtext' => false … … 2152 2152 $r = wp_parse_args( $args, $defaults ); 2153 2153 extract( $r, EXTR_SKIP ); 2154 2154 2155 2155 if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) ) 2156 2156 return false; … … 2158 2158 if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) ) 2159 2159 return false; 2160 2160 2161 2161 if ( !$site_groups_template->group->forum_counts ) 2162 2162 $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id ); … … 2166 2166 $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2167 2167 else 2168 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2168 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts ); 2169 2169 } else { 2170 2170 $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts; 2171 2171 } 2172 2172 2173 2173 return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext ); 2174 2174 } … … 2178 2178 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />'; 2179 2179 } 2180 2180 2181 2181 if ( isset( $_REQUEST['letter'] ) ) { 2182 2182 echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />'; 2183 2183 } 2184 2184 2185 2185 if ( isset( $_REQUEST['groups_search'] ) ) { 2186 2186 echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />'; … … 2206 2206 var $requests; 2207 2207 var $request; 2208 2208 2209 2209 var $in_the_loop; 2210 2210 2211 2211 var $pag_page; 2212 2212 var $pag_num; 2213 2213 var $pag_links; 2214 2214 var $total_request_count; 2215 2215 2216 2216 function bp_groups_membership_requests_template( $group_id, $per_page, $max ) { 2217 2217 global $bp; 2218 2218 2219 2219 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1; 2220 2220 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 2221 2222 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); 2221 2222 $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page ); 2223 2223 2224 2224 if ( !$max || $max >= (int)$this->requests['total'] ) … … 2228 2228 2229 2229 $this->requests = $this->requests['requests']; 2230 2230 2231 2231 if ( $max ) { 2232 2232 if ( $max >= count($this->requests) ) … … 2248 2248 )); 2249 2249 } 2250 2250 2251 2251 function has_requests() { 2252 2252 if ( $this->request_count ) 2253 2253 return true; 2254 2254 2255 2255 return false; 2256 2256 } 2257 2257 2258 2258 function next_request() { 2259 2259 $this->current_request++; 2260 2260 $this->request = $this->requests[$this->current_request]; 2261 2261 2262 2262 return $this->request; 2263 2263 } 2264 2264 2265 2265 function rewind_requests() { 2266 2266 $this->current_request = -1; … … 2269 2269 } 2270 2270 } 2271 2272 function requests() { 2271 2272 function requests() { 2273 2273 if ( $this->current_request + 1 < $this->request_count ) { 2274 2274 return true; … … 2282 2282 return false; 2283 2283 } 2284 2284 2285 2285 function the_request() { 2286 2286 global $request; … … 2312 2312 function bp_group_membership_requests() { 2313 2313 global $requests_template; 2314 2314 2315 2315 return $requests_template->requests(); 2316 2316 } … … 2318 2318 function bp_group_the_membership_request() { 2319 2319 global $requests_template; 2320 2320 2321 2321 return $requests_template->the_request(); 2322 2322 } … … 2324 2324 function bp_group_request_user_avatar_thumb() { 2325 2325 global $requests_template; 2326 2326 2327 2327 echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) ); 2328 2328 } 2329 2329 2330 2330 function bp_group_request_reject_link() { 2331 global $requests_template, $groups_template; 2331 global $requests_template, $groups_template; 2332 2332 2333 2333 echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) ); … … 2335 2335 2336 2336 function bp_group_request_accept_link() { 2337 global $requests_template, $groups_template; 2337 global $requests_template, $groups_template; 2338 2338 2339 2339 echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) ); … … 2341 2341 2342 2342 function bp_group_request_time_since_requested() { 2343 global $requests_template; 2343 global $requests_template; 2344 2344 2345 2345 echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) ); … … 2348 2348 function bp_group_request_comment() { 2349 2349 global $requests_template; 2350 2350 2351 2351 echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) ); 2352 2352 } … … 2354 2354 function bp_group_request_user_link() { 2355 2355 global $requests_template; 2356 2356 2357 2357 echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) ); 2358 2358 } … … 2368 2368 var $invites; 2369 2369 var $invite; 2370 2370 2371 2371 var $in_the_loop; 2372 2372 2373 2373 var $pag_page; 2374 2374 var $pag_num; 2375 2375 var $pag_links; 2376 2376 var $total_invite_count; 2377 2377 2378 2378 function bp_groups_invite_template( $user_id, $group_id ) { 2379 2379 global $bp; 2380 2380 2381 2381 $this->invites = groups_get_invites_for_group( $user_id, $group_id ); 2382 $this->invite_count = count( $this->invites ); 2383 } 2384 2382 $this->invite_count = count( $this->invites ); 2383 } 2384 2385 2385 function has_invites() { 2386 2386 if ( $this->invite_count ) 2387 2387 return true; 2388 2388 2389 2389 return false; 2390 2390 } 2391 2391 2392 2392 function next_invite() { 2393 2393 $this->current_invite++; 2394 2394 $this->invite = $this->invites[$this->current_invite]; 2395 2395 2396 2396 return $this->invite; 2397 2397 } 2398 2398 2399 2399 function rewind_invites() { 2400 2400 $this->current_invite = -1; … … 2403 2403 } 2404 2404 } 2405 2406 function invites() { 2405 2406 function invites() { 2407 2407 if ( $this->current_invite + 1 < $this->invite_count ) { 2408 2408 return true; … … 2416 2416 return false; 2417 2417 } 2418 2418 2419 2419 function the_invite() { 2420 2420 global $invite; … … 2422 2422 $this->in_the_loop = true; 2423 2423 $user_id = $this->next_invite(); 2424 2424 2425 2425 $this->invite = new stdClass; 2426 2426 $this->invite->user = new BP_Core_User( $user_id ); 2427 2427 $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites() 2428 2428 2429 2429 if ( 0 == $this->current_invite ) // loop has just started 2430 2430 do_action('loop_start'); … … 2434 2434 function bp_group_has_invites( $args = '' ) { 2435 2435 global $bp, $invites_template, $group_id; 2436 2436 2437 2437 $defaults = array( 2438 2438 'group_id' => false, … … 2442 2442 $r = wp_parse_args( $args, $defaults ); 2443 2443 extract( $r, EXTR_SKIP ); 2444 2444 2445 2445 if ( !$group_id ) { 2446 2446 /* Backwards compatibility */ … … 2448 2448 if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id; 2449 2449 } 2450 2450 2451 2451 if ( !$group_id ) 2452 2452 return false; … … 2458 2458 function bp_group_invites() { 2459 2459 global $invites_template; 2460 2460 2461 2461 return $invites_template->invites(); 2462 2462 } … … 2464 2464 function bp_group_the_invite() { 2465 2465 global $invites_template; 2466 2466 2467 2467 return $invites_template->the_invite(); 2468 2468 } … … 2509 2509 function bp_get_group_invite_user_remove_invite_url() { 2510 2510 global $invites_template; 2511 2511 2512 2512 return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' ); 2513 2513 } -
trunk/bp-groups/bp-groups-widgets.php
r1926 r2077 3 3 /* Register widgets for groups component */ 4 4 function groups_register_widgets() { 5 add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') ); 5 add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') ); 6 6 } 7 7 add_action( 'plugins_loaded', 'groups_register_widgets' ); … … 12 12 function bp_groups_widget() { 13 13 parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) ); 14 14 15 15 if ( is_active_widget( false, false, $this->id_base ) ) 16 wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') ); 16 wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') ); 17 17 } 18 18 19 19 function widget($args, $instance) { 20 20 global $bp; 21 21 22 22 extract( $args ); 23 23 24 24 echo $before_widget; 25 25 echo $before_title 26 . $widget_name 26 . $widget_name 27 27 . $after_title; ?> 28 28 29 29 <?php if ( bp_has_site_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?> 30 30 <div class="item-options" id="groups-list-options"> 31 31 <span class="ajax-loader" id="ajax-loader-groups"></span> 32 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> | 33 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> | 32 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> | 33 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> | 34 34 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a> 35 35 </div> 36 36 37 37 <ul id="groups-list" class="item-list"> 38 38 <?php while ( bp_site_groups() ) : bp_the_site_group(); ?> … … 49 49 50 50 <?php endwhile; ?> 51 </ul> 51 </ul> 52 52 <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?> 53 53 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" /> 54 54 55 55 <?php else: ?> 56 56 … … 60 60 61 61 <?php endif; ?> 62 62 63 63 <?php echo $after_widget; ?> 64 64 <?php … … 84 84 function groups_ajax_widget_groups_list() { 85 85 global $bp; 86 86 87 87 check_ajax_referer('groups_widget_groups_list'); 88 88 … … 101 101 if ( bp_has_site_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?> 102 102 <?php echo "0[[SPLIT]]"; ?> 103 103 104 104 <ul id="groups-list" class="item-list"> 105 105 <?php while ( bp_site_groups() ) : bp_the_site_group(); ?> … … 113 113 <div class="item-meta"> 114 114 <span class="activity"> 115 <?php 115 <?php 116 116 if ( 'newest-groups' == $_POST['filter'] ) { 117 117 bp_the_site_group_date_created(); … … 128 128 129 129 <?php endwhile; ?> 130 </ul> 130 </ul> 131 131 <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?> 132 132 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" /> 133 133 134 134 <?php else: ?> 135 135 … … 137 137 138 138 <?php endif; 139 139 140 140 } 141 141 add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' ); -
trunk/bp-groups/deprecated/bp-groups-deprecated.php
r1906 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 25 25 function groups_deprecated_globals() { 26 26 global $bp; 27 27 28 28 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 29 29 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 32 32 $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/deprecated/images'; 33 33 } 34 add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 ); 34 add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 ); 35 35 add_action( 'admin_menu', 'groups_deprecated_globals', 2 ); 36 36 … … 40 40 41 41 <p> 42 <input type="file" name="file" id="file" /> 42 <input type="file" name="file" id="file" /> 43 43 <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" /> 44 44 <input type="hidden" name="action" id="action" value="bp_avatar_upload" /> … … 50 50 51 51 <h3><?php _e( 'Crop Group Avatar', 'buddypress' ) ?></h3> 52 52 53 53 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" /> 54 54 55 55 <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" /> 56 56 57 57 <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" /> 58 58 <input type="hidden" name="upload" id="upload" /> … … 68 68 function groups_get_avatar_hrefs( $avatars ) { 69 69 global $bp; 70 70 71 71 $src = $bp->root_domain . '/'; 72 72 73 73 $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) ); 74 74 $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) ); 75 75 76 76 return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href ); 77 77 } … … 93 93 function groups_force_buddypress_theme( $template ) { 94 94 global $bp; 95 95 96 96 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 97 97 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 120 120 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 121 121 return $stylesheet; 122 122 123 123 if ( $bp->current_component != $bp->groups->slug ) 124 124 return $stylesheet; … … 142 142 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 143 143 return false; 144 144 145 145 if ( $bp->current_component == $bp->groups->slug ) 146 146 wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/deprecated/js/general.js' ); … … 152 152 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 153 153 return false; 154 154 155 155 /* Enqueue the structure CSS file to give basic positional formatting for components */ 156 wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' ); 156 wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' ); 157 157 } 158 158 add_action( 'bp_styles', 'groups_add_structure_css' ); … … 162 162 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 163 163 return false; 164 164 165 165 wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/deprecated/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) ); 166 166 } … … 170 170 function bp_groups_random_selection( $total_groups = 5 ) { 171 171 global $bp; 172 172 173 173 if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) { 174 174 $group_ids = BP_Groups_Group::get_random( $total_groups, 1 ); 175 175 wp_cache_set( 'groups_random_groups', $group_ids, 'bp' ); 176 176 } 177 ?> 177 ?> 178 178 <?php if ( $group_ids['groups'] ) { ?> 179 179 <ul class="item-list" id="random-groups-list"> 180 <?php 181 for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) { 180 <?php 181 for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) { 182 182 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) { 183 183 $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false ); 184 184 wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' ); 185 185 } 186 ?> 186 ?> 187 187 <li> 188 188 <div class="item-avatar"> … … 195 195 <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div> 196 196 </div> 197 197 198 198 <div class="action"> 199 199 <?php bp_group_join_button( $group ) ?> 200 200 <div class="meta"> 201 201 <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?> 202 <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> / 202 <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> / 203 203 <?php if ( 1 == $member_count ) : ?> 204 204 <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?> … … 208 208 </div> 209 209 </div> 210 210 211 211 <div class="clear"></div> 212 212 </li> … … 216 216 <div id="message" class="info"> 217 217 <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p> 218 </div> 218 </div> 219 219 <?php } ?> 220 220 <?php … … 224 224 function bp_groups_random_groups( $total_groups = 5 ) { 225 225 global $bp; 226 226 227 227 if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) { 228 228 $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 ); 229 229 wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' ); 230 230 } 231 232 ?> 231 232 ?> 233 233 <div class="info-group"> 234 234 <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> »</a></span></h4> 235 235 <?php if ( $group_ids ) { ?> 236 236 <ul class="horiz-gallery"> 237 <?php 237 <?php 238 238 for ( $i = 0; $i < count( $group_ids ); $i++ ) { 239 239 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) { … … 263 263 if ( !$group ) 264 264 $group =& $groups_template->group; 265 265 266 266 $forum_id = groups_get_groupmeta( $group->id, 'forum_id' ); 267 267 … … 269 269 if ( function_exists( 'bp_forums_setup' ) ) { 270 270 $latest_topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id ) ); 271 271 272 272 if ( $latest_topics ) { ?> 273 273 <ul class="item-list" id="recent-forum-topics"><?php 274 274 275 275 $counter = 0; 276 276 277 277 foreach( $latest_topics as $topic ) { 278 278 $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : ''; 279 279 $forum_template->topic = (object)$topic; ?> 280 280 281 281 <li<?php echo $alt ?>> 282 282 <div class="avatar"> … … 284 284 </div> 285 285 286 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 286 <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 287 287 <span class="small">- <?php bp_the_topic_total_post_count() ?> </span> 288 288 <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p> 289 289 290 290 <div class="latest-post"> 291 291 <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>: … … 294 294 </li> 295 295 <?php $counter++ ?> 296 296 297 297 <?php } ?> 298 298 </ul> … … 313 313 function bp_group_send_invite_form( $group = false ) { 314 314 global $bp, $groups_template, $invites; 315 315 316 316 if ( !$group ) 317 317 $group =& $groups_template->group; … … 325 325 326 326 <div class="main-column"> 327 327 328 328 <div id="message" class="info"> 329 329 <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> … … 331 331 332 332 <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?> 333 333 334 334 <ul id="friend-list" class="item-list"> 335 335 <?php for ( $i = 0; $i < count($invites); $i++ ) { … … 344 344 <span class="activity"><?php echo $user->last_active ?></span> 345 345 <div class="action"> 346 <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 346 <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 347 347 </div> 348 348 </li> 349 349 <?php } // end for ?> 350 350 </ul> 351 351 352 352 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?> 353 353 </div> … … 358 358 function bp_group_list_invite_friends( $args = '' ) { 359 359 global $bp, $invites; 360 360 361 361 if ( !function_exists('friends_install') ) 362 362 return false; … … 370 370 <div id="invite-list"> 371 371 <ul> 372 <?php 372 <?php 373 373 for ( $i = 0; $i < count( $friends ); $i++ ) { 374 374 if ( $invites ) { … … 377 377 } else { 378 378 $checked = ''; 379 } 379 } 380 380 } 381 381 ?> 382 382 383 383 <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo attribute_escape( $friends[$i]['id'] ); ?>" /> <?php echo $friends[$i]['full_name']; ?></li> 384 384 <?php } ?> … … 399 399 400 400 $members = &$group->random_members; 401 ?> 401 ?> 402 402 <ul class="horiz-gallery"> 403 403 <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?> … … 418 418 if ( !$user_id ) 419 419 $user_id = $members_template->member->user_id; 420 420 421 421 echo bp_get_group_member_promote_link( $user_id ); 422 422 } … … 426 426 if ( !$user_id ) 427 427 $user_id = $members_template->member->user_id; 428 428 429 429 if ( !$group ) 430 430 $group =& $groups_template->group; … … 443 443 <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label> 444 444 <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" /> 445 445 446 446 <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label> 447 447 <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea> 448 448 449 449 <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label> 450 450 <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea> 451 451 452 452 <?php do_action( 'groups_custom_group_fields_editable' ) ?> 453 453 … … 455 455 456 456 <?php break; ?> 457 457 458 458 <?php case 'group-settings': ?> 459 459 <?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?> … … 463 463 </div> 464 464 <?php endif; ?> 465 465 466 466 <?php if ( function_exists('bp_forums_setup') ) : ?> 467 467 <?php if ( bp_forums_is_installed_correctly() ) { ?> … … 479 479 }?> 480 480 <?php endif; ?> 481 481 482 482 <?php if ( function_exists('bp_albums_install') ) : ?> 483 483 <div class="checkbox with-suboptions"> … … 489 489 </div> 490 490 <?php endif; ?> 491 491 492 492 <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3> 493 493 494 494 <div class="radio"> 495 <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 495 <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 496 496 <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong> 497 497 <ul> … … 501 501 </ul> 502 502 </label> 503 503 504 504 <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 505 505 <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong> … … 510 510 </ul> 511 511 </label> 512 512 513 513 <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 514 514 <strong><?php _e('This is a hidden group', 'buddypress') ?></strong> … … 528 528 <?php } ?> 529 529 <?php break; ?> 530 530 531 531 <?php case 'group-avatar': ?> 532 532 <?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?> … … 534 534 <?php bp_new_group_avatar() ?> 535 535 </div> 536 536 537 537 <div class="main-column"> 538 538 <p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p> 539 539 540 540 <?php groups_avatar_upload() ?> 541 541 542 542 </div> 543 543 544 544 <?php wp_nonce_field( 'groups_step3_save' ) ?> 545 545 <?php } else { ?> … … 549 549 <?php } ?> 550 550 551 <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?> 551 <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?> 552 552 553 553 <?php break; ?> 554 554 <?php case 'group-invites': ?> 555 <?php 555 <?php 556 556 if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) { 557 557 $group_link = bp_get_group_permalink( $bp->groups->new_group ); 558 558 559 559 if ( function_exists('friends_install') ) { 560 560 if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) { … … 570 570 571 571 <?php wp_nonce_field( 'groups_step4_save' ) ?> 572 572 573 573 <?php 574 574 } else { ?> … … 582 582 <?php break; ?> 583 583 <?php } ?> 584 584 585 585 <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?> 586 586 587 587 <div class="clear"></div> 588 588 589 589 <div id="previous-next"> 590 590 <!-- Previous Button --> … … 597 597 <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> →" id="group-creation-next" name="save" /> 598 598 <?php endif;?> 599 599 600 600 <!-- Create Button --> 601 601 <?php if ( bp_is_first_group_creation_step() ) : ?> 602 602 <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> →" id="group-creation-create" name="save" /> 603 603 <?php endif; ?> 604 604 605 605 <!-- Finish Button --> 606 606 <?php if ( bp_is_last_group_creation_step() ) : ?> … … 622 622 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 623 623 return false; 624 624 625 625 check_ajax_referer( 'groups_invite_uninvite_user' ); 626 626 … … 633 633 if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) ) 634 634 return false; 635 635 636 636 if ( 'invite' == $_POST['friend_action'] ) { 637 637 638 638 if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) ) 639 639 return false; 640 640 641 641 $user = new BP_Core_User( $_POST['friend_id'] ); 642 642 643 643 echo '<li id="uid-' . $user->id . '">'; 644 644 echo $user->avatar_thumb; … … 646 646 echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>'; 647 647 echo '<div class="action"> 648 <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> 648 <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> 649 649 </div>'; 650 650 echo '</li>'; 651 651 652 652 } else if ( 'uninvite' == $_POST['friend_action'] ) { 653 653 654 654 if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) ) 655 655 return false; 656 656 657 657 return true; 658 658 659 659 } else { 660 660 return false; … … 669 669 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 670 670 return false; 671 671 672 672 check_ajax_referer( 'group-filter-box' ); 673 673 674 674 locate_template( array( 'groups/group-loop.php' ), true ); 675 675 } … … 683 683 return false; 684 684 ?> 685 685 686 686 <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?> 687 687 688 688 <?php if ( bp_group_member_needs_pagination() ) : ?> 689 689 <div id="member-count" class="pag-count"> … … 695 695 </div> 696 696 <?php endif; ?> 697 697 698 698 <ul id="member-list" class="item-list"> 699 699 <?php while ( bp_group_members() ) : bp_group_the_member(); ?> … … 702 702 <h5><?php bp_group_member_link() ?></h5> 703 703 <span class="activity"><?php bp_group_member_joined_since() ?></span> 704 704 705 705 <?php if ( function_exists( 'friends_install' ) ) : ?> 706 706 <div class="action"> … … 730 730 return false; 731 731 ?> 732 732 733 733 <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?> 734 734 735 735 <?php if ( bp_group_member_needs_pagination() ) : ?> 736 736 <div id="member-count" class="pag-count"> … … 742 742 </div> 743 743 <?php endif; ?> 744 744 745 745 <ul id="members-list" class="item-list single-line"> 746 746 <?php while ( bp_group_members() ) : bp_group_the_member(); ?> … … 777 777 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 778 778 return false; 779 779 780 780 check_ajax_referer('directory_groups'); 781 781 … … 793 793 if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) ) 794 794 return false; 795 795 796 796 if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) ) 797 797 return false; 798 798 799 799 if ( 'hidden' == $group->status ) 800 800 return false; 801 801 802 802 if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) { 803 803 804 804 if ( 'public' == $group->status ) { 805 805 806 806 check_ajax_referer( 'groups_join_group' ); 807 807 808 808 if ( !groups_join_group( $group->id ) ) { 809 809 _e( 'Error joining group', 'buddypress' ); 810 810 } else { 811 811 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>'; 812 } 813 812 } 813 814 814 } else if ( 'private' == $group->status ) { 815 815 816 816 check_ajax_referer( 'groups_request_membership' ); 817 817 818 818 if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) { 819 _e( 'Error requesting membership', 'buddypress' ); 819 _e( 'Error requesting membership', 'buddypress' ); 820 820 } else { 821 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>'; 822 } 821 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>'; 822 } 823 823 } 824 824 825 825 } else { 826 826 827 827 check_ajax_referer( 'groups_leave_group' ); 828 828 829 829 if ( !groups_leave_group( $group->id ) ) { 830 830 _e( 'Error leaving group', 'buddypress' ); 831 831 } else { 832 832 if ( 'public' == $group->status ) { 833 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>'; 833 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>'; 834 834 } else if ( 'private' == $group->status ) { 835 835 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>'; -
trunk/bp-loader.php
r2042 r2077 40 40 include( BP_PLUGIN_DIR . '/bp-groups.php' ); 41 41 42 /* Private Messaging */ 42 /* Private Messaging */ 43 43 if ( !isset( $deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') ) 44 44 include( BP_PLUGIN_DIR . '/bp-messages.php' ); 45 45 46 46 /* Wire Support */ 47 47 if ( !isset( $deactivated['bp-wire.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-wire.php') ) 48 48 include( BP_PLUGIN_DIR . '/bp-wire.php' ); 49 49 50 /* Extended Profiles */ 50 /* Extended Profiles */ 51 51 if ( !isset( $deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') ) 52 52 include( BP_PLUGIN_DIR . '/bp-xprofile.php' ); 53 53 54 /* Status Updates */ 54 /* Status Updates */ 55 55 if ( !isset( $deactivated['bp-status.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-status.php') ) 56 56 include( BP_PLUGIN_DIR . '/bp-status.php' ); -
trunk/bp-messages.php
r2020 r2077 15 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 16 require ( BP_PLUGIN_DIR . '/bp-messages/deprecated/bp-messages-deprecated.php' ); 17 17 18 18 function messages_install() { 19 19 global $wpdb, $bp; 20 20 21 21 if ( !empty($wpdb->charset) ) 22 22 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 23 23 24 24 $sql[] = "CREATE TABLE {$bp->messages->table_name_threads} ( 25 25 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 33 33 KEY last_sender_id (last_sender_id) 34 34 ) {$charset_collate};"; 35 35 36 36 $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} ( 37 37 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 56 56 KEY sender_id (sender_id) 57 57 ) {$charset_collate};"; 58 58 59 59 $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} ( 60 60 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 65 65 KEY is_active (is_active) 66 66 ) {$charset_collate};"; 67 67 68 68 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 69 69 dbDelta($sql); 70 70 71 71 add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION ); 72 72 } … … 77 77 /* For internal identification */ 78 78 $bp->messages->id = 'messages'; 79 79 80 80 $bp->messages->table_name_threads = $wpdb->base_prefix . 'bp_messages_threads'; 81 81 $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages'; … … 91 91 do_action( 'messages_setup_globals' ); 92 92 } 93 add_action( 'plugins_loaded', 'messages_setup_globals', 5 ); 93 add_action( 'plugins_loaded', 'messages_setup_globals', 5 ); 94 94 add_action( 'admin_menu', 'messages_setup_globals', 2 ); 95 95 96 function messages_check_installed() { 96 function messages_check_installed() { 97 97 global $wpdb, $bp; 98 98 99 99 if ( !is_site_admin() ) 100 100 return false; 101 101 102 102 /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */ 103 103 if ( get_site_option('bp-messages-db-version') < BP_MESSAGES_DB_VERSION ) … … 117 117 /* Add 'Messages' to the main navigation */ 118 118 bp_core_new_nav_item( array( 'name' => __('Messages', 'buddypress'), 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) ); 119 119 120 120 $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/'; 121 121 122 122 /* Add the subnav items to the profile */ 123 123 bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ) . $count_indicator, 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_home() ) ); 124 124 bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_home() ) ); 125 125 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_home() ) ); 126 126 127 127 if ( is_site_admin() ) 128 128 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_site_admin() ) ); … … 130 130 if ( $bp->current_component == $bp->messages->slug ) { 131 131 if ( bp_is_home() ) { 132 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 132 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 133 133 } else { 134 134 $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); … … 136 136 } 137 137 } 138 138 139 139 do_action( 'messages_setup_nav' ); 140 140 } … … 153 153 function messages_screen_inbox() { 154 154 do_action( 'messages_screen_inbox' ); 155 bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) ); 155 bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) ); 156 156 } 157 157 … … 163 163 function messages_screen_compose() { 164 164 global $bp; 165 165 166 166 // Remove any saved message data from a previous session. 167 167 messages_remove_callback_values(); … … 169 169 /* Check if the message form has been submitted */ 170 170 if ( isset( $_POST['send'] ) ) { 171 171 172 172 /* Check the nonce */ 173 173 check_admin_referer( 'messages_send_message' ); 174 174 175 175 /* Check we have what we need */ 176 176 if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { … … 185 185 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] ); 186 186 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients ); 187 187 188 188 /* Send the message */ 189 189 if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) { … … 197 197 198 198 } 199 199 200 200 do_action( 'messages_screen_compose' ); 201 201 202 202 bp_core_load_template( apply_filters( 'messages_template_compose', 'messages/compose' ) ); 203 203 } … … 205 205 function messages_screen_notices() { 206 206 global $bp, $notice_id; 207 207 208 208 if ( !is_site_admin() ) 209 209 return false; 210 210 211 211 $notice_id = $bp->action_variables[1]; 212 212 … … 216 216 if ( 'deactivate' == $bp->action_variables[0] ) { 217 217 if ( !$notice->deactivate() ) { 218 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' ); 218 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' ); 219 219 } else { 220 220 bp_core_add_message( __('Notice deactivated.', 'buddypress') ); … … 235 235 bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' ); 236 236 } 237 237 238 238 do_action( 'messages_screen_notices' ); 239 240 bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) ); 241 } 242 243 function messages_screen_notification_settings() { 239 240 bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) ); 241 } 242 243 function messages_screen_notification_settings() { 244 244 global $current_user; ?> 245 245 <table class="notification-settings" id="messages-notification-settings"> … … 262 262 <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> 263 263 </tr> 264 264 265 265 <?php do_action( 'messages_screen_notification_settings' ) ?> 266 266 </table> 267 <?php 267 <?php 268 268 } 269 269 add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 ); … … 280 280 function messages_action_view_message() { 281 281 global $bp, $thread_id; 282 282 283 283 if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' ) 284 284 return false; 285 285 286 286 $thread_id = $bp->action_variables[0]; 287 287 288 288 if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_site_admin() ) ) 289 289 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component ); 290 290 291 291 /* Check if a new reply has been submitted */ 292 292 if ( isset( $_POST['send'] ) ) { 293 293 294 294 /* Check the nonce */ 295 295 check_admin_referer( 'messages_send_message', 'send_message_nonce' ); 296 296 297 297 /* Send the reply */ 298 298 if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) … … 300 300 else 301 301 bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' ); 302 303 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' ); 304 } 305 302 303 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' ); 304 } 305 306 306 /* Mark message read */ 307 307 messages_mark_thread_read( $thread_id ); 308 308 309 309 do_action( 'messages_action_view_message' ); 310 310 311 311 bp_core_new_subnav_item( array( 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ), 'slug' => 'view', 'parent_url' => $bp->loggedin_user->domain . $bp->messages->slug . '/', 'parent_slug' => $bp->messages->slug, 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_home() ) ); 312 312 bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) ); … … 316 316 function messages_action_delete_message() { 317 317 global $bp, $thread_id; 318 318 319 319 if ( $bp->current_component != $bp->messages->slug || 'notices' == $bp->current_action || $bp->action_variables[0] != 'delete' ) 320 320 return false; 321 321 322 322 $thread_id = $bp->action_variables[1]; 323 323 … … 341 341 function messages_action_bulk_delete() { 342 342 global $bp, $thread_ids; 343 343 344 344 if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'bulk-delete' ) 345 345 return false; 346 346 347 347 $thread_ids = $_POST['thread_ids']; 348 348 349 349 if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) { 350 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action ); 350 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action ); 351 351 } else { 352 352 if ( !check_admin_referer( 'messages_delete_thread' ) ) 353 353 return false; 354 354 355 355 if ( !messages_delete_thread( $thread_ids ) ) { 356 356 bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' ); … … 373 373 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 374 374 global $bp; 375 375 376 376 if ( 'new_message' == $action ) { 377 377 if ( (int)$total_items > 1 ) 378 return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 378 return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 379 379 else 380 380 return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 381 381 } 382 382 383 383 do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 384 384 385 385 return false; 386 386 } … … 398 398 function messages_new_message( $args = '' ) { 399 399 global $bp; 400 400 401 401 $defaults = array( 402 402 'thread_id' => false, // false for a new message, thread id for a reply to a thread. … … 409 409 410 410 $r = wp_parse_args( $args, $defaults ); 411 extract( $r, EXTR_SKIP ); 412 411 extract( $r, EXTR_SKIP ); 412 413 413 if ( !$sender_id || !$subject || !$content ) 414 414 return false; 415 416 /* Create a new message object */ 415 416 /* Create a new message object */ 417 417 $message = new BP_Messages_Message; 418 418 $message->thread_id = $thread_id; … … 425 425 if ( $thread_id ) { 426 426 $thread = new BP_Messages_Thread($thread_id); 427 $message->recipients = $thread->get_recipients(); 427 $message->recipients = $thread->get_recipients(); 428 428 } else { 429 429 if ( empty( $recipients ) ) 430 430 return false; 431 431 432 432 /* Loop the recipients and convert all usernames to user_ids where needed */ 433 433 foreach( (array) $recipients as $recipient ) { 434 434 if ( is_numeric( trim( $recipient ) ) ) 435 435 $recipient_ids[] = (int)trim( $recipient ); 436 436 437 437 if ( $recipient_id = bp_core_get_userid( trim( $recipient ) ) ) 438 438 $recipient_ids[] = (int)$recipient_id; … … 445 445 /* Remove duplicates */ 446 446 $recipient_ids = array_unique( (array)$recipient_ids ); 447 447 448 448 if ( empty( $recipient_ids ) ) 449 449 return false; 450 451 $message->recipients = $recipient_ids; 452 } 453 450 451 $message->recipients = $recipient_ids; 452 } 453 454 454 if ( $message->send() ) { 455 455 require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' ); … … 457 457 // Send screen notifications to the recipients 458 458 foreach ( (array)$message->recipients as $recipient ) { 459 bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' ); 460 } 461 459 bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' ); 460 } 461 462 462 // Send email notifications to the recipients 463 463 messages_notification_new_message( array( 'item_id' => $message->id, 'recipient_ids' => $message->recipients, 'thread_id' => $message->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) ); 464 464 465 465 do_action( 'messages_message_sent', &$message ); 466 466 467 467 return $message->thread_id; 468 468 } 469 469 470 470 return false; 471 471 } … … 483 483 $notice->is_active = 1; 484 484 $notice->save(); // send it. 485 485 486 486 do_action( 'messages_send_notice', $subject, $message ); 487 487 488 488 return true; 489 489 } … … 497 497 $error = 1; 498 498 } 499 499 500 500 if ( $error ) 501 501 return false; 502 502 503 503 do_action( 'messages_delete_thread', $thread_ids ); 504 504 505 505 return true; 506 506 } else { 507 507 if ( !BP_Messages_Thread::delete($thread_ids) ) 508 508 return false; 509 509 510 510 do_action( 'messages_delete_thread', $thread_ids ); 511 511 512 512 return true; 513 513 } … … 516 516 function messages_check_thread_access( $thread_id, $user_id = false ) { 517 517 global $bp; 518 518 519 519 if ( !$user_id ) 520 520 $user_id = $bp->loggedin_user->id; 521 521 522 522 return BP_Messages_Thread::check_access( $thread_id, $user_id ); 523 523 } … … 528 528 529 529 function messages_mark_thread_unread( $thread_id ) { 530 return BP_Messages_Thread::mark_as_unread( $thread_id ); 530 return BP_Messages_Thread::mark_as_unread( $thread_id ); 531 531 } 532 532 … … 545 545 function messages_get_unread_count( $user_id = false ) { 546 546 global $bp; 547 548 if ( !$user_id ) 547 548 if ( !$user_id ) 549 549 $user_id = $bp->loggedin_user->id; 550 550 551 551 return BP_Messages_Thread::get_inbox_count( $user_id ); 552 552 } -
trunk/bp-messages/bp-messages-classes.php
r2020 r2077 1 1 <?php 2 2 3 Class BP_Messages_Thread { 3 Class BP_Messages_Thread { 4 4 var $thread_id; 5 5 var $message_ids; 6 6 var $first_post_date; 7 7 8 8 var $last_post_date; 9 9 var $last_sender_id; … … 12 12 var $last_message_message; 13 13 var $last_message_date_sent; 14 14 15 15 var $messages = null; 16 16 var $has_access = false; 17 17 var $unread_count = 0; 18 18 var $recipients = null; 19 19 20 20 var $box; 21 21 var $get_all_messages; 22 22 23 23 function bp_messages_thread( $id = null, $get_all_messages = false, $box = 'inbox' ) { 24 24 $this->box = $box; 25 25 $this->get_all_messages = $get_all_messages; 26 26 27 27 if ( $id ) { 28 28 $this->populate( $id ); 29 29 } 30 30 31 31 if ( $this->get_all_messages ) { 32 32 $this->messages = $this->get_messages(); … … 34 34 } 35 35 } 36 37 function populate( $id ) { 36 37 function populate( $id ) { 38 38 global $wpdb, $bp; 39 39 40 40 $thread = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_threads} WHERE id = %d", $id ) ); 41 41 42 42 if ( $thread ) { 43 43 44 44 // If we're only viewing a thread in a list of threads, don't bother using 45 45 // up resources checking if we have access. Only check if we're viewing the full … … 57 57 // filter the users messages out 58 58 if ( !$this->get_all_messages ) { 59 59 60 60 // Flip the array to start from the newest message 61 61 $this->message_ids = array_reverse( $this->message_ids ); 62 62 63 63 foreach ( $this->message_ids as $key => $message_id ) { 64 64 if ( 'sentbox' == $this->box ) { … … 67 67 } else { 68 68 break; 69 } 69 } 70 70 } else { 71 71 if ( messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) { … … 73 73 } else { 74 74 break; 75 } 75 } 76 76 } 77 77 } … … 86 86 $this->first_post_date = $thread->first_post_date; 87 87 $this->last_post_date = $thread->last_post_date; 88 88 89 89 if ( !empty($this->message_ids) ) 90 90 $this->message_ids = implode( ',', $this->message_ids ); 91 91 else 92 92 $this->message_ids = false; 93 93 94 94 $this->unread_count = $this->get_unread(); 95 95 96 $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) ); 97 96 $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) ); 97 98 98 if ( $last_message ) { 99 99 $this->last_message_subject = $last_message->subject; … … 101 101 $this->last_message_date_sent = $last_message->date_sent; 102 102 } 103 103 104 104 $this->recipients = $this->get_recipients(); 105 105 } 106 106 } 107 107 } 108 108 109 109 function get_messages() { 110 110 global $wpdb, $bp; 111 111 112 112 if ( $this->message_ids) 113 113 return $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id IN (" . $wpdb->escape($this->message_ids) . ")" ); … … 121 121 $sql = $wpdb->prepare( "SELECT unread_count FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $this->thread_id, $bp->loggedin_user->id ); 122 122 $unread_count = $wpdb->get_var($sql); 123 123 124 124 return $unread_count; 125 125 } 126 126 127 127 function mark_read() { 128 128 BP_Messages_Thread::mark_as_read($this->thread_id); 129 129 } 130 130 131 131 function mark_unread() { 132 132 BP_Messages_Thread::mark_as_unread($this->thread_id); 133 133 } 134 134 135 135 function get_recipients() { 136 136 global $wpdb, $bp; … … 144 144 $recipient_ids[] = $recipient; 145 145 } 146 146 147 147 return $recipient_ids; 148 148 } 149 149 150 150 /** Static Functions **/ 151 151 152 152 function delete( $thread_id ) { 153 153 global $wpdb, $bp; 154 154 155 155 $delete_for_user = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $bp->loggedin_user->id ) ); 156 156 157 157 // Check to see if any more recipients remain for this message 158 158 // if not, then delete the message from the database. … … 163 163 $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 164 164 $message_ids = unserialize($message_ids); 165 165 166 166 // delete thread: 167 167 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 168 168 169 169 // delete messages: 170 170 for ( $i = 0; $i < count($message_ids); $i++ ) { 171 171 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_ids[$i] ) ); 172 172 } 173 173 174 174 // delete the recipients 175 175 $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE id = %d", $thread_id ) ); … … 178 178 return true; 179 179 } 180 180 181 181 function get_current_threads_for_user( $user_id, $box = 'inbox', $limit = null, $page = null, $type = 'all' ) { 182 182 global $wpdb, $bp; … … 185 185 if ( $limit && $page ) 186 186 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 187 187 188 188 if ( $type == 'unread' ) 189 189 $type_sql = $wpdb->prepare( " AND r.unread_count != 0 " ); 190 190 else if ( $type == 'read' ) 191 191 $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " ); 192 192 193 193 $sql = $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id ); 194 194 195 195 if ( !$thread_ids = $wpdb->get_results($sql) ) 196 196 return false; 197 197 198 198 $threads = false; 199 199 200 200 for ( $i = 0; $i < count($thread_ids); $i++ ) { 201 201 $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box ); … … 206 206 207 207 // reset keys 208 return array_reverse( array_reverse( $threads ) ); 209 } 210 208 return array_reverse( array_reverse( $threads ) ); 209 } 210 211 211 function mark_as_read( $thread_id ) { 212 212 global $wpdb, $bp; 213 213 214 214 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id ); 215 215 $wpdb->query($sql); 216 216 } 217 217 218 218 function mark_as_unread( $thread_id ) { 219 219 global $wpdb, $bp; 220 220 221 221 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id ); 222 222 $wpdb->query($sql); 223 223 } 224 224 225 225 function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) { 226 226 global $wpdb, $bp; … … 229 229 if ( $box != 'sentbox' ) 230 230 $exclude_sender = ' AND sender_only != 1'; 231 231 232 232 if ( $type == 'unread' ) 233 233 $type_sql = $wpdb->prepare( " AND unread_count != 0 " ); … … 237 237 return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0$exclude_sender $type_sql", $user_id ) ); 238 238 } 239 239 240 240 function user_is_sender($thread_id) { 241 241 global $wpdb, $bp; 242 243 $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 244 242 243 $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 244 245 245 if ( !$sender_ids ) 246 246 return false; 247 247 248 248 $sender_ids = unserialize($sender_ids); 249 249 250 250 return in_array( $bp->loggedin_user->id, $sender_ids ); 251 251 } … … 255 255 256 256 $sql = $wpdb->prepare("SELECT last_sender_id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id); 257 257 258 258 if ( !$sender_id = $wpdb->get_var($sql) ) 259 259 return false; 260 260 261 261 return bp_core_get_userlink( $sender_id, true ); 262 262 } 263 263 264 264 function get_inbox_count() { 265 265 global $wpdb, $bp; … … 269 269 if ( !$unread_counts = $wpdb->get_results($sql) ) 270 270 return false; 271 271 272 272 $count = 0; 273 273 for ( $i = 0; $i < count($unread_counts); $i++ ) { 274 274 $count += $unread_counts[$i]->unread_count; 275 275 } 276 276 277 277 return $count; 278 278 } 279 279 280 280 function check_access( $thread_id, $user_id = false ) { 281 281 global $wpdb, $bp; 282 282 283 283 if ( !$user_id ) 284 284 $user_id = $bp->loggedin_user->id; 285 285 286 286 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) ); 287 287 } … … 289 289 function is_valid( $thread_id ) { 290 290 global $wpdb, $bp; 291 291 292 292 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 293 293 } 294 294 295 295 function get_recipient_links($recipients) { 296 296 if ( count($recipients) >= 5 ) … … 311 311 var $message; 312 312 var $date_sent; 313 313 314 314 var $thread_id; 315 315 var $recipients = false; … … 325 325 } 326 326 } 327 327 328 328 function populate( $id ) { 329 329 global $wpdb, $bp; 330 330 331 331 $sql = $wpdb->prepare("SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id); 332 332 … … 340 340 341 341 } 342 343 function send() { 344 global $wpdb, $bp; 345 342 343 function send() { 344 global $wpdb, $bp; 345 346 346 $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id ); 347 347 $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id ); 348 348 $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id ); 349 $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id ); 349 $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id ); 350 350 351 351 do_action( 'messages_message_before_save', $this ); 352 352 353 353 // First insert the message into the messages table 354 354 if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d) )", $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) ) 355 355 return false; 356 356 357 357 // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one. 358 358 if ( $this->thread_id ) { … … 362 362 $message_ids[] = $wpdb->insert_id; 363 363 $message_ids = serialize($message_ids); 364 364 365 365 // We need this so we can return the new message ID. 366 366 $message_id = $wpdb->insert_id; 367 367 368 368 // Update the sender ids for the thread 369 369 $sender_ids = unserialize($the_ids->sender_ids); … … 371 371 if ( !in_array( $this->sender_id, $sender_ids ) || !$sender_ids ) 372 372 $sender_ids[] = $this->sender_id; 373 374 $sender_ids = serialize($sender_ids); 375 373 374 $sender_ids = serialize($sender_ids); 375 376 376 // Update the thread the message belongs to. 377 377 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_threads} SET message_ids = %s, sender_ids = %s, last_message_id = %d, last_sender_id = %d, last_post_date = FROM_UNIXTIME(%d) WHERE id = %d", $message_ids, $sender_ids, $wpdb->insert_id, $this->sender_id, $this->date_sent, $this->thread_id ) ); 378 378 379 379 // Find the recipients and update the unread counts for each 380 380 if ( !$this->recipients ) 381 381 $this->recipients = $this->get_recipients(); 382 382 383 383 for ( $i = 0; $i < count($this->recipients); $i++ ) { 384 384 if ( $this->recipients[$i]->user_id != $bp->loggedin_user->id ) … … 390 390 $serialized_message_id = serialize( array( (int)$message_id ) ); 391 391 $serialized_sender_id = serialize( array( (int)$bp->loggedin_user->id ) ); 392 393 $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id ); 394 392 393 $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id ); 394 395 395 if ( false === $wpdb->query($sql) ) 396 396 return false; 397 397 398 398 399 399 $this->thread_id = $wpdb->insert_id; 400 400 401 401 // Add a new entry for each recipient; 402 402 for ( $i = 0; $i < count($this->recipients); $i++ ) { 403 403 $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count ) VALUES ( %d, %d, 1 )", $this->recipients[$i], $this->thread_id ) ); 404 404 } 405 405 406 406 if ( !in_array( $this->sender_id, (array)$this->recipients ) ) { 407 407 // Finally, add a recipient entry for the sender, as replies need to go to this person too. … … 409 409 } 410 410 } 411 411 412 412 $this->id = $message_id; 413 413 messages_remove_callback_values(); 414 414 415 415 do_action( 'messages_message_after_save', $this ); 416 416 417 417 return $this->thread_id; 418 418 } 419 419 420 420 function get_recipients() { 421 421 global $bp, $wpdb; 422 422 423 423 return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) ); 424 424 } 425 425 426 426 // Static Functions 427 427 428 428 function get_recipient_ids( $recipient_usernames ) { 429 429 if ( !$recipient_usernames ) 430 430 return false; 431 431 432 432 if ( is_array($recipient_usernames) ) { 433 433 for ( $i = 0; $i < count($recipient_usernames); $i++ ) { … … 436 436 } 437 437 } 438 438 439 439 return $recipient_ids; 440 440 } 441 441 442 442 function get_last_sent_for_user( $thread_id ) { 443 443 global $wpdb, $bp; 444 444 445 445 $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) ); 446 446 $message_ids = implode( ',', unserialize($message_ids)); … … 448 448 $sql = $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id IN (" . $wpdb->escape($message_ids) . ") ORDER BY date_sent DESC LIMIT 1", $bp->loggedin_user->id ); 449 449 return $wpdb->get_var($sql); 450 } 451 450 } 451 452 452 function is_user_sender( $user_id, $message_id ) { 453 453 global $wpdb, $bp; 454 454 return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) ); 455 455 } 456 456 457 457 function get_message_sender( $message_id ) { 458 458 global $wpdb, $bp; 459 return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) ); 459 return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) ); 460 460 } 461 461 } … … 467 467 var $date_sent; 468 468 var $is_active; 469 469 470 470 function bp_messages_notice($id = null) { 471 471 if ( $id ) { … … 474 474 } 475 475 } 476 476 477 477 function populate() { 478 478 global $wpdb, $bp; 479 479 480 480 $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) ); 481 481 482 482 if ( $notice ) { 483 483 $this->subject = $notice->subject; … … 487 487 } 488 488 } 489 489 490 490 function save() { 491 491 global $wpdb, $bp; 492 492 493 493 $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id ); 494 494 $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id ); 495 495 496 496 do_action( 'messages_notice_before_save', $this ); 497 497 498 498 if ( !$this->id ) { 499 $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 ); 499 $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 ); 500 500 } else { 501 $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 ); 502 } 503 501 $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 ); 502 } 503 504 504 if ( !$wpdb->query($sql) ) 505 505 return false; 506 506 507 507 if ( !$id = $this->id ) 508 508 $id = $wpdb->insert_id; 509 509 510 510 // Now deactivate all notices apart from the new one. 511 511 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) ); 512 513 update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) ); 512 513 update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) ); 514 514 515 515 do_action( 'messages_notice_after_save', $this ); 516 516 517 517 return true; 518 518 } 519 519 520 520 function activate() { 521 521 $this->is_active = 1; 522 522 if ( !$this->save() ) 523 523 return false; 524 524 525 525 return true; 526 526 } 527 527 528 528 function deactivate() { 529 529 $this->is_active = 0; 530 530 if ( !$this->save() ) 531 531 return false; 532 532 533 533 return true; 534 534 } 535 535 536 536 function delete() { 537 537 global $wpdb, $bp; 538 538 539 539 $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ); 540 540 541 541 if ( !$wpdb->query($sql) ) 542 542 return false; 543 544 return true; 545 } 546 543 544 return true; 545 } 546 547 547 // Static Functions 548 548 549 549 function get_notices() { 550 550 global $wpdb, $bp; 551 551 552 552 $notices = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC" ) ); 553 553 return $notices; 554 554 } 555 555 556 556 function get_total_notice_count() { 557 557 global $wpdb, $bp; 558 558 559 559 $notice_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp->messages->table_name_notices ) ); 560 560 return $notice_count; 561 561 } 562 562 563 563 function get_active() { 564 564 global $wpdb, $bp; 565 565 566 566 $notice_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1") ); 567 567 return new BP_Messages_Notice($notice_id); -
trunk/bp-messages/bp-messages-cssjs.php
r1905 r2077 3 3 function messages_add_autocomplete_js() { 4 4 global $bp; 5 5 6 6 // Include the autocomplete JS for composing a message. 7 7 if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) { 8 8 add_action( 'wp_head', 'messages_autocomplete_init_jsblock' ); 9 9 10 10 wp_enqueue_script( 'bp-jquery-autocomplete', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocomplete.js', array( 'jquery' ) ); 11 11 wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocompletefb.js' ); 12 12 wp_enqueue_script( 'bp-jquery-bgiframe', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.bgiframe.min.js' ); 13 wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' ); 13 wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' ); 14 14 } 15 15 … … 21 21 22 22 if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) { 23 wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' ); 23 wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' ); 24 24 wp_print_styles(); 25 25 } … … 31 31 <script type="text/javascript"> 32 32 jQuery(document).ready(function() { 33 var acfb = 33 var acfb = 34 34 jQuery("ul.first").autoCompletefb({urlLookup:'<?php echo $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) ?>'}); 35 35 -
trunk/bp-messages/bp-messages-notifications.php
r1905 r2077 4 4 global $bp; 5 5 extract($args); 6 6 7 7 $message = new BP_Messages_Message( $item_id ); 8 8 9 9 $sender_name = bp_core_get_user_displayname( $message->sender_id ); 10 10 … … 13 13 14 14 $ud = get_userdata( $recipient_ids[$i] ); 15 $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'messages/view/' . $message->id; 16 $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'settings/notifications'; 17 15 $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'messages/view/' . $message->id; 16 $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'settings/notifications'; 17 18 18 // Set up and send the message 19 19 $to = $ud->user_email; 20 20 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) ); 21 21 22 $content = sprintf( __( 22 $content = sprintf( __( 23 23 '%s sent you a new message: 24 24 … … 45 45 46 46 $users = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_email, user_login FROM {$wpdb->base_prefix}users WHERE user_status = 0 AND spam = 0 AND deleted = 0" ) ); 47 47 48 48 for ( $i = 0; $i < count($users); $i++ ) { 49 49 if ( get_usermeta( $users[$i]->user_id, 'notification_messages_new_notice' ) == 'no' ) continue; 50 50 51 $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages'; 52 $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications'; 51 $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages'; 52 $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications'; 53 53 54 54 // Set up and send the message … … 56 56 $subject = __( 'New Site Notice', 'buddypress' ); 57 57 58 $message = sprintf( __( 58 $message = sprintf( __( 59 59 'A new site notice has been posted on %s: 60 60 … … 70 70 // Send it 71 71 wp_mail( $to, $subject, $message ); 72 72 73 73 unset($message); 74 74 unset($subject); -
trunk/bp-messages/bp-messages-templatetags.php
r1989 r2077 11 11 var $threads; 12 12 var $thread; 13 13 14 14 var $in_the_loop; 15 15 var $user_id; 16 16 var $box; 17 17 18 18 var $pag_page; 19 19 var $pag_num; … … 25 25 $this->user_id = $user_id; 26 26 $this->box = $box; 27 27 28 28 if ( 'notices' == $this->box ) 29 29 $this->threads = BP_Messages_Notice::get_notices(); 30 30 else 31 31 $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type ); 32 32 33 33 if ( !$this->threads ) { 34 34 $this->thread_count = 0; 35 35 $this->total_thread_count = 0; 36 } else { 36 } else { 37 37 $total_notice_count = BP_Messages_Notice::get_total_notice_count(); 38 38 39 39 if ( !$max || $max >= (int)$total_notice_count ) { 40 40 if ( 'notices' == $this->box ) … … 45 45 $this->total_thread_count = (int)$max; 46 46 } 47 47 48 48 if ( $max ) { 49 49 if ( $max >= count($this->threads) ) … … 66 66 )); 67 67 } 68 68 69 69 function has_threads() { 70 70 if ( $this->thread_count ) 71 71 return true; 72 72 73 73 return false; 74 74 } 75 75 76 76 function next_thread() { 77 77 $this->current_thread++; 78 78 $this->thread = $this->threads[$this->current_thread]; 79 79 80 80 return $this->thread; 81 81 } 82 82 83 83 function rewind_threads() { 84 84 $this->current_thread = -1; … … 87 87 } 88 88 } 89 90 function message_threads() { 89 90 function message_threads() { 91 91 if ( $this->current_thread + 1 < $this->thread_count ) { 92 92 return true; … … 100 100 return false; 101 101 } 102 102 103 103 function the_message_thread() { 104 104 global $thread; … … 114 114 function bp_has_message_threads( $args = '' ) { 115 115 global $bp, $messages_template; 116 116 117 117 $defaults = array( 118 118 'user_id' => $bp->loggedin_user->id, … … 131 131 if ( 'inbox' == $bp->current_action ) 132 132 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' ); 133 133 134 134 if ( 'sentbox' == $bp->current_action ) 135 135 $box = 'sentbox'; … … 137 137 if ( 'notices' == $bp->current_action ) 138 138 $box = 'notices'; 139 139 140 140 $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type ); 141 141 } 142 142 143 143 return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template ); 144 144 } 145 145 146 function bp_message_threads() { 146 function bp_message_threads() { 147 147 global $messages_template; 148 148 return $messages_template->message_threads(); … … 202 202 return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id ); 203 203 } 204 204 205 205 function bp_message_thread_delete_link() { 206 206 echo bp_get_message_thread_delete_link(); … … 210 210 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id, 'messages_delete_thread' ) ); 211 211 } 212 212 213 213 function bp_message_thread_has_unread() { 214 214 global $messages_template; … … 216 216 if ( $messages_template->thread->unread_count ) 217 217 return true; 218 218 219 219 return false; 220 220 } … … 225 225 function bp_get_message_thread_unread_count() { 226 226 global $messages_template; 227 227 228 228 if ( (int)$messages_template->thread->unread_count ) 229 229 return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count ); 230 230 231 231 return false; 232 232 } … … 276 276 277 277 echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> 278 <span class="ajax-loader"></span><?php 278 <span class="ajax-loader"></span><?php 279 279 } 280 280 … … 315 315 function bp_messages_options() { 316 316 global $bp; 317 317 318 318 if ( $bp->current_action != 'sentbox' ) { 319 319 ?> 320 <?php _e( 'Select:', 'buddypress' ) ?> 320 <?php _e( 'Select:', 'buddypress' ) ?> 321 321 <select name="message-type-select" id="message-type-select"> 322 322 <option value=""></option> … … 329 329 <?php } ?> 330 330 <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> 331 <?php 331 <?php 332 332 } 333 333 334 334 function bp_message_is_active_notice() { 335 335 global $messages_template; 336 336 337 337 if ( $messages_template->thread->is_active ) { 338 338 echo "<strong>"; … … 346 346 if ( $messages_template->thread->is_active ) 347 347 return true; 348 348 349 349 return false; 350 350 } … … 392 392 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' ); 393 393 } else { 394 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' ); 394 $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' ); 395 395 } 396 396 return apply_filters( 'bp_get_message_activate_deactivate_link', $link ); … … 406 406 $text = __('Deactivate', 'buddypress'); 407 407 } else { 408 $text = __('Activate', 'buddypress'); 408 $text = __('Activate', 'buddypress'); 409 409 } 410 410 return apply_filters( 'bp_message_activate_deactivate_text', $text ); … … 413 413 function bp_message_get_notices() { 414 414 global $userdata; 415 415 416 416 $notice = BP_Messages_Notice::get_active(); 417 417 $closed_notices = get_usermeta( $userdata->ID, 'closed_notices'); … … 429 429 </div> 430 430 <?php 431 } 431 } 432 432 } 433 433 } … … 438 438 function bp_get_send_message_button() { 439 439 global $bp; 440 440 441 441 if ( bp_is_home() || !is_user_logged_in() ) 442 442 return false; 443 444 $ud = get_userdata( $bp->displayed_user->id ); 445 443 444 $ud = get_userdata( $bp->displayed_user->id ); 445 446 446 return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' ); 447 447 } … … 457 457 function bp_message_get_recipient_tabs() { 458 458 global $bp; 459 459 460 460 if ( isset( $_GET['r'] ) ) { 461 461 $user_id = bp_core_get_userid( $_GET['r'] ); 462 462 463 463 if ( $user_id ) { 464 464 ?> … … 467 467 <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?> 468 468 <?php echo bp_core_get_userlink( $user_id ) ?> 469 </span> 469 </span> 470 470 </li> 471 471 <?php … … 490 490 var $message_count; 491 491 var $message; 492 492 493 493 var $thread; 494 494 495 495 var $in_the_loop; 496 496 497 497 var $pag_page; 498 498 var $pag_num; 499 499 var $pag_links; 500 500 var $total_message_count; 501 501 502 502 function bp_messages_thread_template( $thread_id, $order ) { 503 503 global $bp; 504 504 505 505 $this->thread = new BP_Messages_Thread( $thread_id, true ); 506 506 $this->message_count = count( $this->thread->messages ); 507 507 } 508 508 509 509 function has_messages() { 510 510 if ( $this->message_count ) 511 511 return true; 512 512 513 513 return false; 514 514 } 515 515 516 516 function next_message() { 517 517 $this->current_message++; 518 518 $this->message = $this->thread->messages[$this->current_message]; 519 519 520 520 return $this->message; 521 521 } 522 522 523 523 function rewind_messages() { 524 524 $this->current_message = -1; … … 527 527 } 528 528 } 529 530 function messages() { 529 530 function messages() { 531 531 if ( $this->current_message + 1 < $this->message_count ) { 532 532 return true; … … 540 540 return false; 541 541 } 542 542 543 543 function the_message() { 544 544 global $message; … … 554 554 function bp_thread_has_messages( $args = '' ) { 555 555 global $bp, $thread_template, $group_id; 556 556 557 557 $defaults = array( 558 558 'thread_id' => false, … … 572 572 function bp_thread_messages() { 573 573 global $thread_template; 574 574 575 575 return $thread_template->messages(); 576 576 } … … 578 578 function bp_thread_the_message() { 579 579 global $thread_template; 580 580 581 581 return $thread_template->the_message(); 582 582 } … … 587 587 function bp_get_the_thread_id() { 588 588 global $thread_template; 589 589 590 590 return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id ); 591 591 } … … 605 605 function bp_get_the_thread_recipients() { 606 606 global $thread_template; 607 607 608 608 if ( count($thread_template->thread->recipients) >= 5 ) 609 609 return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) ); 610 610 611 611 foreach( $thread_template->thread->recipients as $recipient ) 612 612 $recipient_links[] = bp_core_get_userlink( $recipient ); … … 620 620 function bp_get_the_thread_message_alt_class() { 621 621 global $thread_template; 622 622 623 623 if ( $thread_template->current_message % 2 == 1 ) 624 624 $class = ' alt'; 625 625 else 626 626 $class = ''; 627 627 628 628 return apply_filters( 'bp_get_the_thread_message_alt_class', $class ); 629 629 } 630 630 631 631 function bp_the_thread_message_sender_avatar( $args = '' ) { 632 632 echo bp_get_the_thread_message_sender_avatar_thumb( $args ); 633 633 } 634 634 function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) { 635 global $thread_template; 636 635 global $thread_template; 636 637 637 $defaults = array( 638 638 'type' => 'thumb', … … 652 652 function bp_get_the_thread_message_sender_link() { 653 653 global $thread_template; 654 654 655 655 return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) ); 656 656 } 657 657 658 658 function bp_the_thread_message_sender_name() { 659 659 echo bp_get_the_thread_message_sender_name(); … … 661 661 function bp_get_the_thread_message_sender_name() { 662 662 global $thread_template; 663 664 return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) ); 663 664 return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) ); 665 665 } 666 666 … … 670 670 function bp_get_the_thread_message_time_since() { 671 671 global $thread_template; 672 672 673 673 return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) ); 674 674 } … … 679 679 function bp_get_the_thread_message_content() { 680 680 global $thread_template; 681 682 return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message ); 683 } 684 681 682 return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message ); 683 } 684 685 685 686 686 /*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/ 687 687 688 /* DEPRECATED - please use the view message template loop. */ 688 /* DEPRECATED - please use the view message template loop. */ 689 689 function messages_view_thread( $thread_id ) { 690 690 global $bp; 691 691 692 692 $thread = new BP_Messages_Thread( $thread_id, true ); 693 693 694 694 if ( !$thread->has_access ) { 695 695 unset($_GET['mode']); ?> … … 697 697 <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p> 698 698 </div> 699 <?php 699 <?php 700 700 } else { 701 701 if ( $thread->messages ) { ?> 702 702 <?php $thread->mark_read() ?> 703 703 704 704 <div class="wrap"> 705 705 <h2 id="message-subject"><?php echo $thread->subject; ?></h2> … … 709 709 <td> 710 710 <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> 711 <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?> 712 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>. 711 <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?> 712 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>. 713 713 </td> 714 714 </tr> 715 715 </tbody> 716 716 </table> 717 717 718 718 <?php 719 719 $counter = 0; 720 720 721 721 foreach ( $thread->messages as $message ) { 722 722 $alt = ( $counter % 2 == 1 ) ? ' alt' : ''; … … 729 729 <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small> 730 730 </div> 731 731 732 732 <?php do_action( 'messages_custom_fields_output_before' ) ?> 733 733 734 734 <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?> 735 735 736 736 <?php do_action( 'messages_custom_fields_output_after' ) ?> 737 737 738 738 <div class="clear"></div> 739 739 </div> … … 741 741 $counter++; 742 742 } 743 743 744 744 ?> 745 745 <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post"> … … 748 748 <div class="avatar-box"> 749 749 <?php echo bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?> 750 750 751 751 <h3><?php _e("Reply: ", 'buddypress') ?></h3> 752 752 </div> … … 762 762 <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" /> 763 763 </div> 764 764 765 765 <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?> 766 766 </form> -
trunk/bp-messages/deprecated/bp-messages-deprecated.php
r1957 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 24 24 function messages_deprecated_globals() { 25 25 global $bp; 26 26 27 27 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 28 28 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 31 31 $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images'; 32 32 } 33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 ); 33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 ); 34 34 add_action( 'admin_menu', 'messages_deprecated_globals', 2 ); 35 35 … … 50 50 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 51 51 return $template; 52 52 53 53 /* Enqueue the structure CSS file to give basic positional formatting for components */ 54 wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' ); 54 wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' ); 55 55 } 56 56 add_action( 'bp_styles', 'messages_add_structure_css' ); … … 62 62 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 63 63 return false; 64 64 65 65 check_ajax_referer( 'messages_send_message' ); 66 67 $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 66 67 $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 68 68 69 69 if ( $result['status'] ) { ?> 70 70 <div class="avatar-box"> 71 71 <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?> 72 72 73 73 <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3> 74 74 <small><?php echo bp_format_time($result['reply']->date_sent) ?></small> … … 90 90 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 91 91 return false; 92 92 93 93 if ( !isset($_POST['thread_ids']) ) { 94 94 echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress'); 95 95 } else { 96 96 $thread_ids = explode( ',', $_POST['thread_ids'] ); 97 97 98 98 for ( $i = 0; $i < count($thread_ids); $i++ ) { 99 99 BP_Messages_Thread::mark_as_unread($thread_ids[$i]); … … 108 108 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 109 109 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 110 return false; 111 110 return false; 111 112 112 if ( !isset($_POST['thread_ids']) ) { 113 113 echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress'); … … 128 128 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 129 129 return false; 130 130 131 131 if ( !isset($_POST['thread_ids']) ) { 132 132 echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' ); … … 137 137 BP_Messages_Thread::delete($thread_ids[$i]); 138 138 } 139 139 140 140 _e('Messages deleted.', 'buddypress'); 141 141 } … … 149 149 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 150 150 return false; 151 151 152 152 if ( !isset($_POST['notice_id']) ) { 153 153 echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress'); 154 154 } else { 155 155 $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' ); 156 156 157 157 $notice_ids[] = (int) $_POST['notice_id']; 158 158 159 159 update_usermeta( $userdata->ID, 'closed_notices', $notice_ids ); 160 160 } … … 168 168 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 169 169 return false; 170 170 171 171 $friends = false; 172 172 … … 183 183 echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ') 184 184 '; 185 } 185 } 186 186 } 187 187 } … … 193 193 global $message, $type; 194 194 global $bp, $current_user; 195 195 196 196 messages_add_callback_values( $recipients, $subject, $content ); 197 197 198 198 if ( isset( $_POST['send-notice'] ) ) { 199 199 if ( messages_send_notice( $subject, $content, $from_template ) ) { 200 200 bp_core_add_message( __('Notice posted successfully.', 'buddypress') ); 201 201 } else { 202 bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' ); 202 bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' ); 203 203 } 204 204 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' ); 205 205 return true; 206 206 } 207 207 208 208 $recipients = explode( ' ', $recipients ); 209 209 210 210 // If there are no recipients 211 211 if ( count( $recipients ) < 1 ) { 212 if ( !$from_ajax ) { 212 if ( !$from_ajax ) { 213 213 bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' ); 214 214 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); … … 216 216 return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress')); 217 217 } 218 218 219 219 // If there is only 1 recipient and it is the logged in user. 220 220 } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) { 221 221 bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' ); 222 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 223 222 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 223 224 224 // If the subject or content boxes are empty. 225 225 } else if ( empty( $subject ) || empty( $content ) ) { … … 230 230 return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress')); 231 231 } 232 232 233 233 // Passed validation continue. 234 234 } else { … … 237 237 if ( $key = array_search( $current_user->user_login, $recipients ) ) 238 238 unset( $recipients[$key] ); 239 239 240 240 $pmessage = new BP_Messages_Message; 241 241 … … 245 245 $pmessage->thread_id = $thread_id; 246 246 $pmessage->date_sent = time(); 247 247 248 248 if ( $is_reply ) { 249 249 $thread = new BP_Messages_Thread($thread_id); … … 257 257 $message = __('Message could not be sent, please try again.', 'buddypress'); 258 258 $type = 'error'; 259 259 260 260 if ( $from_ajax ) { 261 261 return array('status' => 0, 'message' => $message); … … 263 263 bp_core_add_message( $message, $type ); 264 264 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 265 } 265 } 266 266 } else { 267 267 $message = __('Message sent successfully!', 'buddypress'); 268 268 $type = 'success'; 269 269 270 270 // Send screen notifications to the recipients 271 271 for ( $i = 0; $i < count($pmessage->recipients); $i++ ) { 272 272 if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) { 273 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 273 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 274 274 } 275 275 } 276 276 277 277 // Send email notifications to the recipients 278 278 require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' ); … … 280 280 281 281 do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) ); 282 282 283 283 if ( $from_ajax ) { 284 284 return array('status' => 1, 'message' => $message, 'reply' => $pmessage); … … 291 291 $message = __('Message could not be sent, please try again.', 'buddypress'); 292 292 $type = 'error'; 293 293 294 294 if ( $from_ajax ) { 295 295 return array('status' => 0, 'message' => $message); -
trunk/bp-status.php
r2037 r2077 12 12 $bp->status->id = 'status'; 13 13 $bp->status->slug = BP_STATUS_SLUG; 14 14 15 15 /* Register this in the active components array */ 16 16 $bp->active_components[$bp->status->slug] = $bp->status->id; … … 18 18 do_action( 'bp_status_setup_globals' ); 19 19 } 20 add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 ); 20 add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 ); 21 21 add_action( 'admin_menu', 'bp_status_setup_globals', 2 ); 22 22 … … 31 31 function bp_status_register_activity_actions() { 32 32 global $bp; 33 33 34 34 if ( !function_exists( 'bp_activity_set_action' ) ) 35 35 return false; … … 44 44 function bp_status_record_activity( $user_id, $content, $primary_link, $component_action = 'new_status' ) { 45 45 global $bp; 46 46 47 47 if ( !function_exists( 'bp_activity_add' ) ) 48 48 return false; 49 50 return bp_activity_add( array( 51 'user_id' => $user_id, 52 'content' => $content, 53 'primary_link' => $primary_link, 49 50 return bp_activity_add( array( 51 'user_id' => $user_id, 52 'content' => $content, 53 'primary_link' => $primary_link, 54 54 'component_name' => $bp->status->id, 55 55 'component_action' => $component_action … … 66 66 function bp_status_register_activity_action( $key, $value ) { 67 67 global $bp; 68 68 69 69 if ( !function_exists( 'bp_activity_set_action' ) ) 70 70 return false; 71 71 72 72 return apply_filters( 'bp_status_register_activity_action', bp_activity_set_action( $bp->status->id, $key, $value ), $key, $value ); 73 73 } … … 87 87 if ( $bp->current_component != BP_STATUS_SLUG || 'add' != $bp->current_action ) 88 88 return false; 89 89 90 90 if ( !check_admin_referer( 'bp_status_add_status', '_wpnonce_add_status' ) ) 91 91 return false; … … 95 95 else 96 96 bp_core_add_message( __( 'There was a problem updating your status. Please try again.', 'buddypress' ), 'error' ); 97 97 98 98 bp_core_redirect( $bp->loggedin_user->domain ); 99 99 } … … 112 112 function bp_status_add_status( $user_id, $content, $recorded_time = false ) { 113 113 global $bp; 114 114 115 115 $content = apply_filters( 'bp_status_content_before_save', $content ); 116 117 if ( !$recorded_time ) 116 117 if ( !$recorded_time ) 118 118 $recorded_time = time(); 119 119 120 120 if ( !$content || empty($content) ) 121 121 return false; 122 122 123 123 bp_status_clear_existing_activity( $user_id ); 124 124 125 125 /* Store the status in usermeta for easy access. */ 126 126 update_usermeta( $user_id, 'bp_status', array( 'content' => $content, 'recorded_time' => $recorded_time ) ); … … 132 132 133 133 bp_status_record_activity( $user_id, apply_filters( 'bp_status_activity_new', $activity_content, $content, $user_link ), apply_filters( 'bp_status_activity_new_primary_link', $user_link, $user_id ) ); 134 134 135 135 do_action( 'bp_status_add_status', $user_id, $content ); 136 136 … … 140 140 function bp_status_clear_status( $user_id = false ) { 141 141 global $bp; 142 142 143 143 if ( !$user_id ) 144 144 $user_id = $bp->loggedin_user->id; 145 145 146 146 bp_status_clear_existing_activity( $user_id ); 147 147 148 148 return delete_usermeta( $user_id, 'bp_status' ); 149 149 } … … 152 152 /* Fetch existing status update if there is one. */ 153 153 $existing_status = get_usermeta( $user_id, 'bp_status' ); 154 154 155 155 if ( '' != $existing_status ) { 156 156 if ( strtotime( '+5 minutes', $existing_status['recorded_time'] ) >= time() ) { -
trunk/bp-status/bp-status-templatetags.php
r2038 r2077 11 11 if ( 'clear' == $_GET['status'] && is_user_logged_in() ) 12 12 bp_status_clear_status(); 13 13 14 14 echo bp_get_the_status( $args ); 15 15 } … … 17 17 function bp_get_the_status( $args = false ) { 18 18 global $bp; 19 19 20 20 $defaults = array( 21 21 'user_id' => $bp->displayed_user->id, … … 24 24 'no_anchor' => false 25 25 ); 26 26 27 27 $r = wp_parse_args( $args, $defaults ); 28 28 extract( $r, EXTR_SKIP ); 29 29 30 30 if ( !$user_id ) 31 31 $user_id = $bp->displayed_user->id; 32 33 $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) ); 34 32 33 $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) ); 34 35 35 if ( empty($status) ) 36 36 return bp_get_update_status_button( 'text=' . $new_button_text ); 37 37 38 38 $time_since = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $status['recorded_time'] ) ); 39 39 $content = apply_filters( 'the_status_content', $status['content'] ); 40 40 41 41 if ( !(int)$no_anchor && $user_id == $bp->loggedin_user->id ) 42 42 $content = '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $content . '</a>'; … … 44 44 $content .= ' <span class="time-since">' . $time_since . '</span>'; 45 45 $content .= ' ' . bp_get_clear_status_button( 'text=' . $clear_button_text ); 46 46 47 47 return apply_filters( 'bp_get_the_status', $content ); 48 48 } 49 49 50 50 function bp_update_status_button( $args = false ) { 51 51 echo bp_get_update_status_button( $args ); … … 58 58 'text' => __( 'Update Your Status', 'buddypress' ) 59 59 ); 60 60 61 61 $r = wp_parse_args( $args, $defaults ); 62 62 extract( $r, EXTR_SKIP ); 63 63 64 64 if ( !$user_id ) 65 65 $user_id = $bp->displayed_user->id; 66 66 67 67 if ( $user_id != $bp->loggedin_user->id ) 68 68 return false; 69 69 70 70 return apply_filters( 'bp_get_update_status_button', '<div class="generic-button"><a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $text . '</a></div>' ); 71 71 } … … 81 81 'text' => __( 'Clear', 'buddypress' ) 82 82 ); 83 83 84 84 $r = wp_parse_args( $args, $defaults ); 85 85 extract( $r, EXTR_SKIP ); 86 86 87 87 if ( !$user_id ) 88 88 $user_id = $bp->displayed_user->id; 89 89 90 90 if ( $user_id != $bp->loggedin_user->id ) 91 91 return false; 92 92 93 93 return apply_filters( 'bp_get_clear_status_button', '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=clear" id="status-clear-status">' . $text . '</a>' ); 94 94 } … … 96 96 function bp_status_form_action( $user_id = false ) { 97 97 global $bp; 98 98 99 99 if ( !$user_id ) 100 100 $user_id = $bp->loggedin_user->id; 101 101 102 102 echo apply_filters( 'bp_status_form_action', bp_core_get_user_domain( $user_id ) . BP_STATUS_SLUG . '/add' ); 103 103 } -
trunk/bp-themes/bp-default/_inc/css/adminbar.css
r2009 r2077 27 27 padding-right: 0; 28 28 } 29 29 30 30 #wp-admin-bar ul li ul a { 31 31 color: #666 !important; … … 144 144 -webkit-border-radius: 2px !important; 145 145 margin-left: 2px !important; 146 } 146 } -
trunk/bp-themes/bp-default/style.css
r2042 r2077 1 /* 1 /* 2 2 Theme Name: BuddyPress Default 3 3 Theme URI: http://buddypress.org/extend/themes/ -
trunk/bp-themes/bp-sn-parent/404.php
r1905 r2077 2 2 3 3 <div id="content"> 4 4 5 5 <?php do_action( 'bp_before_404' ) ?> 6 6 7 7 <div class="page 404"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Page Not Found', 'buddypress' ) ?></h2> 10 10 11 11 <div id="message" class="info"> 12 12 13 13 <p><?php _e( 'The page you were looking for was not found.', 'buddypress' ) ?> 14 14 15 15 </div> 16 16 … … 20 20 21 21 <?php do_action( 'bp_after_404' ) ?> 22 22 23 23 </div> 24 24 25 25 <?php get_sidebar() ?> 26 26 -
trunk/bp-themes/bp-sn-parent/activity/just-me.php
r1905 r2077 9 9 10 10 <?php do_action( 'bp_before_my_activity_content' ) ?> 11 11 12 12 <div class="left-menu"> 13 13 <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) --> … … 16 16 17 17 <div class="main-column"> 18 18 19 19 <?php bp_get_profile_header() ?> 20 20 … … 27 27 28 28 <?php if ( bp_has_activities( 'type=personal&per_page=25&max=500' ) ) : ?> 29 29 30 30 <div class="pagination"> 31 31 32 32 <div class="pag-count" id="activity-count"> 33 33 <?php bp_activity_pagination_count() ?> 34 34 </div> 35 35 36 36 <div class="pagination-links" id="activity-pag"> 37 37 <?php bp_activity_pagination_links() ?> 38 38 </div> 39 39 40 40 </div> 41 41 42 42 <ul id="activity-list" class="item-list activity-list"> 43 43 <?php while ( bp_activities() ) : bp_the_activity(); ?> … … 46 46 <?php bp_activity_avatar() ?> 47 47 </div> 48 48 49 49 <?php bp_activity_content() ?> 50 50 51 51 <?php do_action( 'bp_my_activity_item' ) ?> 52 52 </li> 53 53 <?php endwhile; ?> 54 54 </ul> 55 55 56 56 <?php do_action( 'bp_my_activity_content' ) ?> 57 57 … … 64 64 <?php endif;?> 65 65 </div> 66 66 67 67 </div> 68 68 -
trunk/bp-themes/bp-sn-parent/activity/my-friends.php
r1905 r2077 9 9 10 10 <?php do_action( 'bp_before_friends_activity_content' ) ?> 11 11 12 12 <div class="left-menu"> 13 13 <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) --> … … 29 29 30 30 <div class="pagination"> 31 31 32 32 <div class="pag-count" id="activity-count"> 33 33 <?php bp_activity_pagination_count() ?> 34 34 </div> 35 35 36 36 <div class="pagination-links" id="activity-pag"> 37 37 <?php bp_activity_pagination_links() ?> 38 38 </div> 39 39 40 40 </div> 41 41 42 42 <ul id="activity-list" class="item-list activity-list"> 43 43 <?php while ( bp_activities() ) : bp_the_activity(); ?> … … 46 46 <?php bp_activity_avatar() ?> 47 47 </div> 48 48 49 49 <?php bp_activity_content() ?> 50 50 … … 53 53 <?php endwhile; ?> 54 54 </ul> 55 55 56 56 <?php do_action( 'bp_friends_activity_content' ) ?> 57 57 … … 64 64 <?php endif;?> 65 65 </div> 66 66 67 67 </div> 68 68 -
trunk/bp-themes/bp-sn-parent/archive.php
r1905 r2077 4 4 5 5 <?php do_action( 'bp_before_archive' ) ?> 6 6 7 7 <div class="page" id="blog-archives"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2> 10 10 11 11 <?php if ( have_posts() ) : ?> 12 12 … … 14 14 15 15 <div class="navigation"> 16 16 17 17 <div class="alignleft"><?php next_posts_link( __( '« Previous Entries', 'buddypress' ) ) ?></div> 18 18 <div class="alignright"><?php previous_posts_link( __( 'Next Entries »', 'buddypress' ) ) ?></div> 19 19 20 20 </div> 21 21 … … 23 23 24 24 <?php do_action( 'bp_before_blog_post' ) ?> 25 25 26 26 <div class="post"> 27 27 28 28 <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3> 29 29 <small><?php the_time('F j, Y') ?></small> … … 42 42 43 43 <div class="navigation"> 44 44 45 45 <div class="alignleft"><?php next_posts_link( __( '« Previous Entries', 'buddypress' ) ) ?></div> 46 46 <div class="alignright"><?php previous_posts_link( __( 'Next Entries »', 'buddypress' ) ) ?></div> 47 47 48 48 </div> 49 49 … … 52 52 <h2 class="center"><?php _e( 'Not Found', 'buddypress' ) ?></h2> 53 53 <?php locate_template( array( 'searchform.php' ), true ) ?> 54 54 55 55 <?php endif; ?> 56 56 … … 58 58 59 59 <?php do_action( 'bp_after_archive' ) ?> 60 60 61 61 </div> 62 62 -
trunk/bp-themes/bp-sn-parent/attachment.php
r1905 r2077 4 4 5 5 <?php do_action( 'bp_before_attachment' ) ?> 6 6 7 7 <div class="page" id="attachments-page"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2> 10 10 11 11 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 12 12 … … 15 15 <?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // This also populates the iconsize for the next line ?> 16 16 <?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?> 17 17 18 18 <div class="post" id="post-<?php the_ID(); ?>"> 19 19 20 20 <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> » <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2> 21 21 22 22 <div class="entry"> 23 23 <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p> … … 27 27 <?php wp_link_pages( array( 'before' => __( '<p><strong>Pages:</strong> ', 'buddypress' ), 'after' => '</p>', 'next_or_number' => 'number')); ?> 28 28 </div> 29 29 30 30 </div> 31 31 -
trunk/bp-themes/bp-sn-parent/blogs/create.php
r1905 r2077 8 8 9 9 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 10 10 11 11 <h2><?php _e( 'Create a Blog', 'buddypress' ) ?></h2> 12 12 … … 14 14 15 15 <?php if ( bp_blog_signup_enabled() ) : ?> 16 16 17 17 <?php bp_show_blog_signup_form() ?> 18 18 19 19 <?php else: ?> 20 20 -
trunk/bp-themes/bp-sn-parent/blogs/my-blogs.php
r1905 r2077 8 8 9 9 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 10 10 11 11 <h2><?php bp_word_or_name( __( "My Blogs", 'buddypress' ), __( "%s's Blogs", 'buddypress' ) ) ?></h2> 12 12 … … 14 14 15 15 <?php if ( bp_has_blogs() ) : ?> 16 16 17 17 <ul id="blog-list" class="item-list"> 18 18 <?php while ( bp_blogs() ) : bp_the_blog(); ?> 19 19 20 20 <li> 21 21 <h4><a href="<?php bp_blog_permalink() ?>"><?php bp_blog_title() ?></a></h4> … … 24 24 <?php do_action( 'bp_my_blogs_item' ) ?> 25 25 </li> 26 26 27 27 <?php endwhile; ?> 28 28 </ul> 29 29 30 30 <?php do_action( 'bp_my_blogs_content' ) ?> 31 31 32 32 <?php else: ?> 33 33 -
trunk/bp-themes/bp-sn-parent/blogs/recent-comments.php
r1905 r2077 8 8 9 9 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 10 10 11 11 <h2><?php _e("Recent Comments", "buddypress"); ?></h2> 12 12 … … 17 17 <ul id="comment-list" class="item-list"> 18 18 <?php while ( bp_comments() ) : bp_the_comment(); ?> 19 19 20 20 <li id="comment-<?php bp_comment_id() ?>"> 21 21 <span class="small"><?php printf( __( 'On %1$s %2$s said:', 'buddypress' ), bp_comment_date( __( 'F jS, Y', 'buddypress' ), false ), bp_comment_author( false ) ); ?></span> … … 25 25 <?php do_action( 'bp_recent_comments_item' ) ?> 26 26 </li> 27 27 28 28 <?php endwhile; ?> 29 29 </ul> 30 30 31 31 <?php do_action( 'bp_recent_comments_content' ) ?> 32 32 -
trunk/bp-themes/bp-sn-parent/blogs/recent-posts.php
r1905 r2077 8 8 9 9 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 10 10 11 11 <h2><?php _e("Recent Posts", "buddypress"); ?></h2> 12 12 13 <?php do_action( 'bp_before_recent_posts_content' ) ?> 13 <?php do_action( 'bp_before_recent_posts_content' ) ?> 14 14 15 15 <?php if ( bp_has_posts() ) : ?> 16 16 17 17 <?php while ( bp_posts() ) : bp_the_post(); ?> 18 18 19 19 <div class="post" id="post-<?php bp_post_id(); ?>"> 20 20 21 21 <h2><a href="<?php bp_post_permalink() ?>" rel="bookmark" title="<?php printf ( __( 'Permanent Link to %s', 'buddypress' ), bp_post_title( false ) ); ?>"><?php bp_post_title(); ?></a></h2> 22 22 23 23 <p class="date"><?php printf( __( '%1$s <em>in %2$s by %3$s</em>', 'buddypress' ), bp_post_date(__('F jS, Y', 'buddypress'), false ), bp_post_category( ', ', '', null, false ), bp_post_author( false ) ); ?></p> 24 24 <?php bp_post_content(__('Read the rest of this entry »')); ?> 25 25 <p class="postmetadata"><?php bp_post_tags( '<span class="tags">', ', ', '</span>' ); ?> <span class="comments"><?php bp_post_comments( __('No Comments'), __('1 Comment'), __('% Comments') ); ?></span></p> 26 27 <?php do_action( 'bp_recent_posts_item' ) ?> 26 27 <?php do_action( 'bp_recent_posts_item' ) ?> 28 28 29 29 <hr /> 30 30 31 31 </div> 32 32 33 33 <?php endwhile; ?> 34 34 35 <?php do_action( 'bp_recent_posts_content' ) ?> 36 35 <?php do_action( 'bp_recent_posts_content' ) ?> 36 37 37 <?php else: ?> 38 38 … … 43 43 <?php endif;?> 44 44 45 <?php do_action( 'bp_after_recent_posts_content' ) ?> 45 <?php do_action( 'bp_after_recent_posts_content' ) ?> 46 46 47 47 </div> -
trunk/bp-themes/bp-sn-parent/comments.php
r1905 r2077 27 27 28 28 <?php if ( get_option( 'page_comments' ) ) : ?> 29 29 30 30 <div class="comment-navigation paged-navigation"> 31 31 32 32 <?php paginate_comments_links(); ?> 33 33 … … 76 76 77 77 <?php do_action( 'bp_before_blog_comment_form' ) ?> 78 78 79 79 <form action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php" method="post" id="commentform" class="standard-form"> 80 80 … … 132 132 133 133 <?php endif; ?> 134 134 135 135 </div> 136 -
trunk/bp-themes/bp-sn-parent/directories/blogs/blogs-loop.php
r1905 r2077 1 1 <?php if ( bp_has_site_blogs( 'type=active&per_page=10' ) ) : ?> 2 2 3 3 <div class="pagination"> 4 4 5 5 <div class="pag-count" id="blog-dir-count"> 6 6 <?php bp_site_blogs_pagination_count() ?> … … 10 10 <?php bp_site_blogs_pagination_links() ?> 11 11 </div> 12 12 13 13 </div> 14 14 15 <?php do_action( 'bp_before_directory_blogs_list' ) ?> 15 <?php do_action( 'bp_before_directory_blogs_list' ) ?> 16 16 17 17 <ul id="blogs-list" class="item-list"> … … 34 34 <a href="<?php bp_the_site_blog_link() ?>" class="visit" title="<?php _e( 'Visit Blog', 'buddypress' ) ?>"><?php _e( 'Visit Blog', 'buddypress' ) ?></a> 35 35 </div> 36 36 37 37 <div class="meta"> 38 38 <?php bp_the_site_blog_latest_post() ?> 39 39 </div> 40 40 41 41 <?php do_action( 'bp_directory_blogs_actions' ) ?> 42 42 </div> … … 46 46 47 47 <?php endwhile; ?> 48 </ul> 48 </ul> 49 49 50 <?php do_action( 'bp_after_directory_blogs_list' ) ?> 51 50 <?php do_action( 'bp_after_directory_blogs_list' ) ?> 51 52 52 <?php else: ?> 53 53 -
trunk/bp-themes/bp-sn-parent/directories/blogs/index.php
r1905 r2077 1 1 <?php get_header() ?> 2 2 3 <?php do_action( 'bp_before_directory_blogs_content' ) ?> 3 <?php do_action( 'bp_before_directory_blogs_content' ) ?> 4 4 5 5 <div id="content"> 6 6 7 7 <div class="page" id="blogs-directory-page"> 8 8 9 9 <form action="<?php echo site_url() . '/' ?>" method="post" id="blogs-directory-form"> 10 10 <h3><?php _e( 'Blog Directory', 'buddypress' ) ?></h3> 11 11 12 12 <ul id="letter-list"> 13 13 <li><a href="#a" id="letter-a">A</a></li> … … 41 41 <div id="blogs-directory-listing" class="directory-listing"> 42 42 <h3><?php _e( 'Blog Listing', 'buddypress' ) ?></h3> 43 43 44 44 <div id="blog-dir-list"> 45 45 <?php locate_template( array( 'directories/blogs/blogs-loop.php' ), true ) ?> … … 49 49 50 50 <?php do_action( 'bp_directory_blogs_content' ) ?> 51 51 52 52 <?php wp_nonce_field( 'directory_blogs', '_wpnonce-blog-filter' ) ?> 53 53 54 54 </form> 55 55 56 56 </div> 57 57 58 58 </div> 59 59 60 <?php do_action( 'bp_after_directory_blogs_content' ) ?> 61 <?php do_action( 'bp_before_directory_blogs_sidebar' ) ?> 60 <?php do_action( 'bp_after_directory_blogs_content' ) ?> 61 <?php do_action( 'bp_before_directory_blogs_sidebar' ) ?> 62 62 63 63 <div id="sidebar" class="directory-sidebar"> 64 64 65 <?php do_action( 'bp_before_directory_blogs_search' ) ?> 65 <?php do_action( 'bp_before_directory_blogs_search' ) ?> 66 66 67 67 <div id="blogs-directory-search" class="directory-widget"> 68 68 69 69 <h3><?php _e( 'Find Blogs', 'buddypress' ) ?></h3> 70 70 71 71 <?php bp_directory_blogs_search_form() ?> 72 72 73 <?php do_action( 'bp_directory_blogs_search' ) ?> 73 <?php do_action( 'bp_directory_blogs_search' ) ?> 74 74 75 75 </div> 76 76 77 <?php do_action( 'bp_after_directory_blogs_search' ) ?> 78 <?php do_action( 'bp_before_directory_blogs_featured' ) ?> 77 <?php do_action( 'bp_after_directory_blogs_search' ) ?> 78 <?php do_action( 'bp_before_directory_blogs_featured' ) ?> 79 79 80 80 <div id="blogs-directory-featured" class="directory-widget"> 81 81 82 82 <h3><?php _e( 'Random Blogs', 'buddypress' ) ?></h3> 83 83 84 84 <?php if ( bp_has_site_blogs( 'type=random&max=3' ) ) : ?> 85 85 … … 95 95 <div class="item-title"><a href="<?php bp_the_site_blog_link() ?>"><?php bp_the_site_blog_name() ?></a></div> 96 96 <div class="item-meta"><span class="activity"><?php bp_the_site_blog_last_active() ?></span></div> 97 97 98 98 <div class="field-data"> 99 99 <div class="field-name"> … … 102 102 </div> 103 103 </div> 104 104 105 105 <?php do_action( 'bp_directory_blogs_featured_item' ) ?> 106 106 </div> … … 108 108 109 109 <?php endwhile; ?> 110 </ul> 110 </ul> 111 111 112 <?php do_action( 'bp_directory_blogs_featured' ) ?> 113 112 <?php do_action( 'bp_directory_blogs_featured' ) ?> 113 114 114 <?php else: ?> 115 115 … … 119 119 120 120 <?php endif; ?> 121 121 122 122 </div> 123 123 124 <?php do_action( 'bp_after_directory_blogs_featured' ) ?> 124 <?php do_action( 'bp_after_directory_blogs_featured' ) ?> 125 125 126 126 </div> 127 127 128 <?php do_action( 'bp_after_directory_blogs_sidebar' ) ?> 128 <?php do_action( 'bp_after_directory_blogs_sidebar' ) ?> 129 129 130 130 <?php get_footer() ?> -
trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php
r1924 r2077 1 <?php if ( bp_has_forum_topics( 'type=' . bp_get_forum_topic_type() . '&per_page=25&max=250' ) ) : ?> 2 1 <?php if ( bp_has_forum_topics( 'type=' . bp_get_forum_topic_type() . '&per_page=25&max=250' ) ) : ?> 2 3 3 <div class="pagination"> 4 4 5 5 <div id="post-count" class="pag-count"> 6 6 <?php bp_forum_pagination_count() ?> … … 10 10 <?php bp_forum_pagination() ?> 11 11 </div> 12 12 13 13 </div> 14 14 15 <?php do_action( 'bp_before_directory_forums_list' ) ?> 16 15 <?php do_action( 'bp_before_directory_forums_list' ) ?> 16 17 17 <table id="global-forum-topic-list"> 18 18 19 19 <tr> 20 20 <th id="th-title"><?php _e( 'Topic Title', 'buddypress' ) ?></th> … … 24 24 <th id="th-freshness"><?php _e( 'Freshness', 'buddypress' ) ?></th> 25 25 </tr> 26 26 27 27 <?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?> 28 28 29 29 <tr class="<?php bp_the_topic_css_class() ?>"> 30 30 <td class="td-title"> … … 36 36 <a href="<?php bp_the_topic_permalink() ?>"> 37 37 <?php bp_the_topic_last_poster_avatar( 'type=thumb&width=20&height=20' ) ?> 38 </a> 38 </a> 39 39 <div class="poster-name"><?php bp_the_topic_last_poster_name() ?></div> 40 40 </td> 41 41 <td class="td-group"> 42 <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a> 42 <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a> 43 43 <div class="object-name"><a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></div> 44 44 </td> … … 50 50 </td> 51 51 52 <?php do_action( 'bp_directory_forums_extra_cell' ) ?> 52 <?php do_action( 'bp_directory_forums_extra_cell' ) ?> 53 53 </tr> 54 54 55 <?php do_action( 'bp_directory_forums_extra_row' ) ?> 56 55 <?php do_action( 'bp_directory_forums_extra_row' ) ?> 56 57 57 <?php endwhile; ?> 58 58 59 59 </table> 60 60 61 <?php do_action( 'bp_after_directory_forums_list' ) ?> 62 61 <?php do_action( 'bp_after_directory_forums_list' ) ?> 62 63 63 <?php else: ?> 64 64 -
trunk/bp-themes/bp-sn-parent/directories/forums/index.php
r2018 r2077 1 1 <?php get_header() ?> 2 2 3 <?php do_action( 'bp_before_directory_forums_content' ) ?> 3 <?php do_action( 'bp_before_directory_forums_content' ) ?> 4 4 5 5 <div id="content"> 6 6 7 7 <div class="page" id="forums-directory-page"> 8 8 9 9 <form action="<?php echo site_url() . '/' ?>" method="post" id="forums-directory-form"> 10 10 … … 13 13 <div id="popular-group-forum-listing"> 14 14 <h3><?php _e( 'Popular Group Forums', 'buddypress' ) ?></h3> 15 16 <?php do_action( 'bp_before_directory_popular_group_forums' ) ?> 15 16 <?php do_action( 'bp_before_directory_popular_group_forums' ) ?> 17 17 18 18 <?php while ( bp_site_groups() ) : bp_the_site_group(); ?> … … 33 33 <?php endwhile; ?> 34 34 35 <?php do_action( 'bp_after_directory_popular_group_forums' ) ?> 36 35 <?php do_action( 'bp_after_directory_popular_group_forums' ) ?> 36 37 37 </div> 38 38 39 39 <?php endif; ?> 40 40 41 41 <div id="forums-directory-listing" class="directory-listing"> 42 42 <h3><?php _e( 'Latest Forum Topics', 'buddypress' ) ?></h3> 43 43 44 44 <div id="forum-dir-list"> 45 45 46 46 <?php do_action( 'bp_before_directory_forums_topic_filters' ) ?> 47 47 48 48 <div id="global-forum-topic-filters"> 49 49 <ul> … … 51 51 <li<?php if ( 'popular' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-popular"><a href="<?php bp_popular_forum_topics_link() ?>" title="<?php _e( 'Most Popular Topics', 'buddypress' ) ?>"><?php _e( 'Most Popular Topics', 'buddypress') ?></a></li> 52 52 <li<?php if ( 'unreplied' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-unreplied"><a href="<?php bp_unreplied_forum_topics_link() ?>" title="<?php _e( 'Unreplied Topics', 'buddypress' ) ?>"><?php _e( 'Unreplied Topics', 'buddypress') ?></a></li> 53 53 54 54 <?php if ( is_user_logged_in() ) : ?> 55 55 <li<?php if ( 'personal' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-personal"><a href="<?php bp_my_forum_topics_link() ?>" title="<?php _e( 'Topics I have started or replied to', 'buddypress' ) ?>"><?php _e( 'My Topics', 'buddypress') ?></a></li> 56 56 <?php endif; ?> 57 57 58 58 <?php if ( 'tag' == bp_current_action() ) : ?> 59 59 <li class="selected" id="forums-tag"><a href="<?php bp_newest_forum_topics_link() ?>" title="<?php _e( 'Tag', 'buddypress' ) ?>"><?php printf( __( 'Tagged: %s', 'buddypress' ), bp_get_forums_tag_name() ) ?></a></li> 60 60 <?php endif; ?> 61 61 62 62 <?php if ( isset( $_GET['fs'] ) ) : ?> 63 63 <li class="selected" id="forums-search"><a href="<?php bp_newest_forum_topics_link() ?>" title="<?php _e( 'Search', 'buddypress' ) ?>"><?php printf( __( 'Matching: %s', 'buddypress' ), attribute_escape( $_GET['fs'] ) ) ?></a></li> 64 64 <?php endif; ?> 65 65 66 66 <?php do_action( 'bp_directory_forums_topic_filters' ) ?> 67 </ul> 67 </ul> 68 68 </div> 69 69 70 70 <?php do_action( 'bp_after_directory_forums_topic_filters' ) ?> 71 71 … … 74 74 75 75 </div> 76 76 77 77 <?php do_action( 'bp_directory_forums_content' ) ?> 78 78 79 79 </form> 80 80 81 81 </div> 82 82 83 83 </div> 84 84 85 <?php do_action( 'bp_after_directory_forums_content' ) ?> 86 <?php do_action( 'bp_before_directory_forums_sidebar' ) ?> 85 <?php do_action( 'bp_after_directory_forums_content' ) ?> 86 <?php do_action( 'bp_before_directory_forums_sidebar' ) ?> 87 87 88 88 <div id="sidebar" class="directory-sidebar"> 89 89 90 <?php do_action( 'bp_before_directory_forums_search' ) ?> 90 <?php do_action( 'bp_before_directory_forums_search' ) ?> 91 91 92 92 <div id="forums-directory-search" class="directory-widget"> 93 93 94 94 <h3><?php _e( 'Forum Topic Search', 'buddypress' ) ?></h3> 95 95 … … 97 97 98 98 <?php do_action( 'bp_directory_forums_search' ) ?> 99 99 100 100 </div> 101 101 102 102 <?php do_action( 'bp_after_directory_forums_search' ) ?> 103 <?php do_action( 'bp_before_directory_forums_tags' ) ?> 103 <?php do_action( 'bp_before_directory_forums_tags' ) ?> 104 104 105 105 <div id="forums-directory-tags" class="directory-widget"> 106 106 107 107 <h3><?php _e( 'Forum Topic Tags', 'buddypress' ) ?></h3> 108 108 … … 110 110 111 111 <?php do_action( 'bp_directory_forums_search' ) ?> 112 112 113 113 </div> 114 114 115 <?php do_action( 'bp_after_directory_forums_search' ) ?> 115 <?php do_action( 'bp_after_directory_forums_search' ) ?> 116 116 117 117 </div> 118 119 <?php do_action( 'bp_after_directory_forums_sidebar' ) ?> 118 119 <?php do_action( 'bp_after_directory_forums_sidebar' ) ?> 120 120 121 121 <?php get_footer() ?> -
trunk/bp-themes/bp-sn-parent/directories/groups/groups-loop.php
r1921 r2077 1 1 <?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?> 2 2 3 3 <div class="pagination"> 4 4 5 5 <div class="pag-count" id="group-dir-count"> 6 6 <?php bp_site_groups_pagination_count() ?> … … 10 10 <?php bp_site_groups_pagination_links() ?> 11 11 </div> 12 12 13 13 </div> 14 15 <?php do_action( 'bp_before_directory_groups_list' ) ?> 14 15 <?php do_action( 'bp_before_directory_groups_list' ) ?> 16 16 17 17 <ul id="groups-list" class="item-list"> … … 38 38 <?php bp_the_site_group_type() ?> / <?php bp_the_site_group_member_count() ?> 39 39 </div> 40 40 41 41 <?php do_action( 'bp_directory_groups_actions' ) ?> 42 42 </div> … … 46 46 47 47 <?php endwhile; ?> 48 </ul> 48 </ul> 49 49 50 <?php do_action( 'bp_after_directory_groups_list' ) ?> 51 50 <?php do_action( 'bp_after_directory_groups_list' ) ?> 51 52 52 <?php else: ?> 53 53 -
trunk/bp-themes/bp-sn-parent/directories/groups/index.php
r1921 r2077 1 1 <?php get_header() ?> 2 2 3 <?php do_action( 'bp_before_directory_groups_content' ) ?> 3 <?php do_action( 'bp_before_directory_groups_content' ) ?> 4 4 5 5 <div id="content"> 6 6 7 7 <div class="page" id="groups-directory-page"> 8 8 9 9 <form action="<?php echo site_url() . '/' ?>" method="post" id="groups-directory-form"> 10 10 <h3><?php _e( 'Groups Directory', 'buddypress' ) ?></h3> 11 11 12 12 <ul id="letter-list"> 13 13 <li><a href="#a" id="letter-a">A</a></li> … … 41 41 <div id="groups-directory-listing" class="directory-listing"> 42 42 <h3><?php _e( 'Groups Listing', 'buddypress' ) ?></h3> 43 43 44 44 <div id="group-dir-list"> 45 45 <?php locate_template( array( 'directories/groups/groups-loop.php' ), true ) ?> … … 47 47 48 48 </div> 49 49 50 50 <?php do_action( 'bp_directory_groups_content' ) ?> 51 51 … … 53 53 54 54 </form> 55 55 56 56 </div> 57 57 58 58 </div> 59 59 60 <?php do_action( 'bp_after_directory_groups_content' ) ?> 61 <?php do_action( 'bp_before_directory_groups_sidebar' ) ?> 60 <?php do_action( 'bp_after_directory_groups_content' ) ?> 61 <?php do_action( 'bp_before_directory_groups_sidebar' ) ?> 62 62 63 63 <div id="sidebar" class="directory-sidebar"> 64 64 65 <?php do_action( 'bp_before_directory_groups_search' ) ?> 65 <?php do_action( 'bp_before_directory_groups_search' ) ?> 66 66 67 67 <div id="groups-directory-search" class="directory-widget"> 68 68 69 69 <h3><?php _e( 'Find Groups', 'buddypress' ) ?></h3> 70 70 … … 72 72 73 73 <?php do_action( 'bp_directory_groups_search' ) ?> 74 74 75 75 </div> 76 76 77 <?php do_action( 'bp_after_directory_groups_search' ) ?> 78 <?php do_action( 'bp_before_directory_groups_featured' ) ?> 77 <?php do_action( 'bp_after_directory_groups_search' ) ?> 78 <?php do_action( 'bp_before_directory_groups_featured' ) ?> 79 79 80 80 <div id="groups-directory-featured" class="directory-widget"> 81 81 82 82 <h3><?php _e( 'Random Groups', 'buddypress' ) ?></h3> 83 83 84 84 <?php if ( bp_has_site_groups( 'type=random&max=3' ) ) : ?> 85 85 … … 93 93 94 94 <div class="item"> 95 95 96 96 <div class="item-title"><a href="<?php bp_the_site_group_link() ?>"><?php bp_the_site_group_name() ?></a></div> 97 97 <div class="item-meta"><span class="activity"><?php bp_the_site_group_last_active() ?></span></div> 98 98 99 99 <div class="field-data"> 100 100 <div class="field-name"> … … 102 102 <?php bp_the_site_group_member_count() ?> 103 103 </div> 104 104 105 105 <div class="field-name"> 106 106 <strong><?php _e( 'Description:', 'buddypress' ) ?></strong> … … 108 108 </div> 109 109 </div> 110 110 111 111 <?php do_action( 'bp_directory_groups_featured_item' ) ?> 112 112 113 113 </div> 114 114 … … 116 116 117 117 <?php endwhile; ?> 118 </ul> 118 </ul> 119 119 120 <?php do_action( 'bp_directory_groups_featured' ) ?> 121 120 <?php do_action( 'bp_directory_groups_featured' ) ?> 121 122 122 <?php else: ?> 123 123 … … 127 127 128 128 <?php endif; ?> 129 129 130 130 </div> 131 131 132 <?php do_action( 'bp_after_directory_groups_featured' ) ?> 132 <?php do_action( 'bp_after_directory_groups_featured' ) ?> 133 133 134 134 </div> 135 136 <?php do_action( 'bp_after_directory_groups_sidebar' ) ?> 135 136 <?php do_action( 'bp_after_directory_groups_sidebar' ) ?> 137 137 138 138 <?php get_footer() ?> -
trunk/bp-themes/bp-sn-parent/directories/members/index.php
r1905 r2077 1 1 <?php get_header() ?> 2 2 3 <?php do_action( 'bp_before_directory_members_content' ) ?> 3 <?php do_action( 'bp_before_directory_members_content' ) ?> 4 4 5 5 <div id="content"> 6 6 7 7 <div class="page" id="members-directory-page"> 8 8 9 9 <form action="<?php echo site_url() . '/' ?>" method="post" id="members-directory-form"> 10 10 <h3><?php _e( 'Members Directory', 'buddypress' ) ?></h3> 11 11 12 12 <ul id="letter-list"> 13 13 <li><a href="#a" id="letter-a">A</a></li> … … 41 41 <div id="members-directory-listing" class="directory-widget"> 42 42 <h3><?php _e( 'Member Listing', 'buddypress' ) ?></h3> 43 43 44 44 <div id="member-dir-list"> 45 45 <?php locate_template( array( 'directories/members/members-loop.php' ), true ) ?> … … 49 49 50 50 <?php do_action( 'bp_directory_members_content' ) ?> 51 52 <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?> 53 51 52 <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?> 53 54 54 </form> 55 55 56 56 </div> 57 57 58 58 </div> 59 60 <?php do_action( 'bp_after_directory_members_content' ) ?> 61 <?php do_action( 'bp_before_directory_members_sidebar' ) ?> 59 60 <?php do_action( 'bp_after_directory_members_content' ) ?> 61 <?php do_action( 'bp_before_directory_members_sidebar' ) ?> 62 62 63 63 <div id="sidebar" class="directory-sidebar"> 64 64 65 65 <?php do_action( 'bp_before_directory_members_search' ) ?> 66 66 … … 73 73 </div> 74 74 75 <?php do_action( 'bp_after_directory_members_search' ) ?> 76 <?php do_action( 'bp_before_directory_members_featured' ) ?> 75 <?php do_action( 'bp_after_directory_members_search' ) ?> 76 <?php do_action( 'bp_before_directory_members_featured' ) ?> 77 77 78 78 <div id="members-directory-featured" class="directory-widget"> 79 79 <h3><?php _e( 'Random Members', 'buddypress' ) ?></h3> 80 80 81 81 <?php if ( bp_has_site_members( 'type=random&max=3' ) ) : ?> 82 82 … … 92 92 <div class="item-title"><a href="<?php bp_the_site_member_link() ?>"><?php bp_the_site_member_name() ?></a></div> 93 93 <div class="item-meta"><span class="activity"><?php bp_the_site_member_last_active() ?></span></div> 94 94 95 95 <div class="field-data"> 96 96 <div class="field-name"><?php bp_the_site_member_total_friend_count() ?></div> 97 97 <div class="field-name xprofile-data"><?php bp_the_site_member_random_profile_data() ?></div> 98 98 </div> 99 99 100 100 <?php do_action( 'bp_directory_members_featured_item' ) ?> 101 101 </div> … … 103 103 104 104 <?php endwhile; ?> 105 </ul> 105 </ul> 106 106 107 <?php do_action( 'bp_directory_members_featured' ) ?> 108 107 <?php do_action( 'bp_directory_members_featured' ) ?> 108 109 109 <?php else: ?> 110 110 … … 114 114 115 115 <?php endif; ?> 116 116 117 117 </div> 118 118 119 <?php do_action( 'bp_after_directory_members_featured' ) ?> 119 <?php do_action( 'bp_after_directory_members_featured' ) ?> 120 120 121 121 </div> 122 122 123 <?php do_action( 'bp_after_directory_members_sidebar' ) ?> 123 <?php do_action( 'bp_after_directory_members_sidebar' ) ?> 124 124 125 125 <?php get_footer() ?> -
trunk/bp-themes/bp-sn-parent/directories/members/members-loop.php
r1905 r2077 1 1 <?php if ( bp_has_site_members( 'type=active&per_page=10' ) ) : ?> 2 2 3 3 <div class="pagination"> 4 4 5 5 <div class="pag-count" id="member-dir-count"> 6 6 <?php bp_site_members_pagination_count() ?> … … 12 12 13 13 </div> 14 15 <?php do_action( 'bp_before_directory_members_list' ) ?> 14 15 <?php do_action( 'bp_before_directory_members_list' ) ?> 16 16 17 17 <ul id="members-list" class="item-list"> … … 40 40 41 41 <?php endwhile; ?> 42 </ul> 42 </ul> 43 43 44 <?php do_action( 'bp_after_directory_members_list' ) ?> 45 44 <?php do_action( 'bp_after_directory_members_list' ) ?> 45 46 46 <?php else: ?> 47 47 -
trunk/bp-themes/bp-sn-parent/footer.php
r1905 r2077 1 1 </div> <!-- #container --> 2 2 3 3 <?php do_action( 'bp_after_container' ) ?> 4 4 5 5 <div class="clear"></div> 6 7 <?php do_action( 'bp_before_footer' ) ?> 6 7 <?php do_action( 'bp_before_footer' ) ?> 8 8 9 9 <div id="footer"> 10 10 <p><?php printf( __( '%s is proudly powered by <a href="http://mu.wordpress.org">WordPress MU</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), bloginfo('name') ); ?></p> 11 11 12 12 <?php do_action( 'bp_footer' ) ?> 13 13 </div> … … 16 16 17 17 <?php wp_footer(); ?> 18 18 19 19 </body> 20 20 -
trunk/bp-themes/bp-sn-parent/friends/friends-loop.php
r1905 r2077 1 <?php do_action( 'bp_before_my_friends_loop' ) ?> 1 <?php do_action( 'bp_before_my_friends_loop' ) ?> 2 2 3 3 <div id="friends-loop"> 4 4 5 5 <?php if ( bp_has_friendships() ) : ?> 6 6 7 7 <div class="pagination"> 8 8 … … 10 10 <?php bp_friend_pagination_count() ?> 11 11 </div> 12 12 13 13 <div class="pagination-links" id="pag"> 14 14 <?php bp_friend_pagination() ?> 15 15 </div> 16 16 17 17 </div> 18 18 19 19 <?php do_action( 'bp_before_my_friends_list' ) ?> 20 20 21 21 <ul id="friend-list" class="item-list"> 22 22 <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?> 23 23 24 24 <li> 25 25 <?php bp_friend_avatar_thumb() ?> … … 27 27 <span class="activity"><?php bp_friend_last_active() ?></span> 28 28 29 <?php do_action( 'bp_my_friends_list_item' ) ?> 30 29 <?php do_action( 'bp_my_friends_list_item' ) ?> 30 31 31 <div class="action"> 32 32 <?php bp_add_friend_button() ?> 33 33 34 34 <?php do_action( 'bp_my_friends_list_item_action' ) ?> 35 35 </div> 36 36 </li> 37 37 38 38 <?php endwhile; ?> 39 39 </ul> 40 40 41 41 <?php do_action( 'bp_after_my_friends_list' ) ?> 42 42 43 43 <?php else: ?> 44 44 45 45 <?php if ( bp_friends_is_filtered() ) : ?> 46 46 47 47 <div id="message" class="info"> 48 48 <p><?php _e( "No friends matched your search filter terms", 'buddypress' ) ?></p> 49 </div> 50 49 </div> 50 51 51 <?php else : ?> 52 52 53 53 <div id="message" class="info"> 54 54 <p><?php bp_word_or_name( __( "Your friends list is currently empty", 'buddypress' ), __( "%s's friends list is currently empty", 'buddypress' ) ) ?></p> 55 55 </div> 56 56 57 57 <?php endif; ?> 58 58 59 59 <?php if ( bp_is_home() && !bp_friends_is_filtered() ) : ?> 60 60 61 61 <?php do_action( 'bp_before_random_members_list' ) ?> 62 62 63 63 <h3><?php _e( 'Why not make friends with some of these members?', 'buddypress' ) ?></h3> 64 64 <?php bp_friends_random_members() ?> 65 65 66 66 <?php do_action( 'bp_after_random_members_list' ) ?> 67 67 68 68 <?php endif; ?> 69 69 70 70 <?php endif;?> 71 71 72 72 </div> 73 73 74 <?php do_action( 'bp_after_my_friends_loop' ) ?> 74 <?php do_action( 'bp_after_my_friends_loop' ) ?> -
trunk/bp-themes/bp-sn-parent/friends/index.php
r1905 r2077 10 10 <h2><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> » <?php bp_friends_filter_title() ?></h2> 11 11 12 <?php do_action( 'bp_before_my_friends_content' ) ?> 13 12 <?php do_action( 'bp_before_my_friends_content' ) ?> 13 14 14 <div class="left-menu"> 15 15 <?php do_action( 'bp_before_my_friends_search' ) ?> 16 16 17 17 <?php bp_friend_search_form() ?> 18 18 19 19 <?php do_action( 'bp_after_my_friends_search' ) ?> 20 20 </div> … … 22 22 <div class="main-column"> 23 23 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 24 24 25 25 <?php locate_template( array( 'friends/friends-loop.php' ), true ) ?> 26 26 </div> 27 27 28 <?php do_action( 'bp_after_my_friends_content' ) ?> 28 <?php do_action( 'bp_after_my_friends_content' ) ?> 29 29 </div> 30 30 -
trunk/bp-themes/bp-sn-parent/friends/requests.php
r1905 r2077 5 5 6 6 <div id="content"> 7 7 8 8 <div class="pagination"> 9 9 10 10 <div class="pagination-links" id="pag"> 11 11 <?php bp_friend_pagination() ?> 12 12 </div> 13 13 14 14 </div> 15 15 16 16 <h2><?php _e( 'Friendship Requests', 'buddypress' ); ?></h2> 17 17 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 18 18 19 <?php do_action( 'bp_before_friend_requests_content' ) ?> 20 19 <?php do_action( 'bp_before_friend_requests_content' ) ?> 20 21 21 <?php if ( bp_has_friendships() ) : ?> 22 22 23 23 <ul id="friend-list" class="item-list"> 24 24 <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?> 25 25 26 26 <li> 27 27 <?php bp_friend_avatar_thumb() ?> 28 28 <h4><?php bp_friend_link() ?></h4> 29 29 <span class="activity"><?php bp_friend_time_since_requested() ?></span> 30 31 <?php do_action( 'bp_friend_requests_item' ) ?> 32 30 31 <?php do_action( 'bp_friend_requests_item' ) ?> 32 33 33 <div class="action"> 34 34 <div class="generic-button accept"> 35 35 <a href="<?php bp_friend_accept_request_link() ?>"><?php _e( 'Accept', 'buddypress' ); ?></a> 36 36 </div> 37 38 39 37 38 39 40 40 <div class="generic-button reject"> 41 41 <a href="<?php bp_friend_reject_request_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a> 42 42 </div> 43 44 <?php do_action( 'bp_friend_requests_item_action' ) ?> 43 44 <?php do_action( 'bp_friend_requests_item_action' ) ?> 45 45 </div> 46 46 </li> 47 47 48 48 <?php endwhile; ?> 49 49 </ul> 50 51 <?php do_action( 'bp_friend_requests_content' ) ?> 52 50 51 <?php do_action( 'bp_friend_requests_content' ) ?> 52 53 53 <?php else: ?> 54 54 … … 59 59 <?php endif;?> 60 60 61 <?php do_action( 'bp_after_friend_requests_content' ) ?> 62 61 <?php do_action( 'bp_after_friend_requests_content' ) ?> 62 63 63 </div> 64 64 -
trunk/bp-themes/bp-sn-parent/functions.php
r2013 r2077 2 2 3 3 /* Register the widget columns */ 4 register_sidebars( 1, 5 array( 4 register_sidebars( 1, 5 array( 6 6 'name' => 'first-section', 7 7 'before_widget' => '<div id="%1$s" class="widget %2$s">', … … 9 9 'before_title' => '<h2 class="widgettitle">', 10 10 'after_title' => '</h2>' 11 ) 11 ) 12 12 ); 13 13 14 14 register_sidebars( 1, 15 array( 15 array( 16 16 'name' => 'second-section', 17 17 'before_widget' => '<div id="%1$s" class="widget %2$s">', … … 19 19 'before_title' => '<h2 class="widgettitle">', 20 20 'after_title' => '</h2>' 21 ) 21 ) 22 22 ); 23 23 24 24 register_sidebars( 1, 25 array( 25 array( 26 26 'name' => 'third-section', 27 27 'before_widget' => '<div id="%1$s" class="widget %2$s">', … … 29 29 'before_title' => '<h2 class="widgettitle">', 30 30 'after_title' => '</h2>' 31 ) 31 ) 32 32 ); 33 33 34 34 register_sidebars( 1, 35 array( 35 array( 36 36 'name' => 'blog-sidebar', 37 37 'before_widget' => '<div id="%1$s" class="widget %2$s">', … … 39 39 'before_title' => '<h2 class="widgettitle">', 40 40 'after_title' => '</h2>' 41 ) 41 ) 42 42 ); 43 43 … … 52 52 function bp_dtheme_show_home_blog() { 53 53 global $bp, $query_string, $paged; 54 55 if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) { 54 55 if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) { 56 56 unset( $query_string ); 57 57 58 58 if ( ( 'page' == $bp->current_action && $bp->action_variables[0] ) && false === strpos( $query_string, 'paged' ) ) { 59 59 $query_string .= '&paged=' . $bp->action_variables[0]; … … 62 62 63 63 query_posts($query_string); 64 64 65 65 bp_core_load_template( 'index', true ); 66 66 } -
trunk/bp-themes/bp-sn-parent/groups/group-loop.php
r1991 r2077 2 2 3 3 <div id="group-loop"> 4 4 5 5 <?php if ( bp_has_groups() ) : ?> 6 6 7 7 <div class="pagination"> 8 8 9 9 <div class="pag-count"> 10 10 <?php bp_group_pagination_count() ?> 11 11 </div> 12 12 13 13 <div class="pagination-links" id="<?php bp_group_pag_id() ?>"> 14 14 <?php bp_group_pagination() ?> 15 15 </div> 16 16 17 17 </div> 18 18 19 19 <?php do_action( 'bp_before_my_groups_list' ) ?> 20 20 21 21 <ul id="group-list" class="item-list"> 22 22 <?php while ( bp_groups() ) : bp_the_group(); ?> 23 23 24 24 <li> 25 25 <?php bp_group_avatar_thumb() ?> 26 26 <h4><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a><span class="small"> - <?php printf( __( '%s members', 'buddypress' ), bp_group_total_members( false ) ) ?></span></h4> 27 27 28 28 <?php if ( bp_group_has_requested_membership() ) : ?> 29 29 <p class="request-pending"><?php _e( 'Membership Pending Approval', 'buddypress' ); ?></p> 30 30 <?php endif; ?> 31 31 32 32 <div class="desc"> 33 33 <?php bp_group_description_excerpt() ?> 34 34 </div> 35 35 36 36 <?php do_action( 'bp_before_my_groups_list_item' ) ?> 37 37 </li> 38 38 39 39 <?php endwhile; ?> 40 40 </ul> 41 41 42 42 <?php do_action( 'bp_after_my_groups_list' ) ?> 43 43 44 44 <?php else: ?> 45 45 … … 51 51 52 52 <?php if ( bp_is_home() ) : ?> 53 53 54 54 <?php do_action( 'bp_before_random_groups_list' ) ?> 55 55 56 56 <h3><?php _e( 'Why not join a few of these groups?', 'buddypress') ?></h3> 57 57 <?php bp_groups_random_selection() ?> 58 58 59 59 <?php do_action( 'bp_after_random_groups_list' ) ?> 60 60 61 61 <?php endif; ?> 62 62 … … 70 70 71 71 <?php endif;?> 72 72 73 73 </div> 74 74 -
trunk/bp-themes/bp-sn-parent/groups/index.php
r1905 r2077 8 8 9 9 <div id="content"> 10 10 11 11 <h2><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> » <?php bp_groups_filter_title() ?></h2> 12 12 13 13 <?php do_action( 'bp_before_my_groups_content' ) ?> 14 14 15 15 <div class="left-menu"> 16 16 <?php bp_group_search_form() ?> 17 17 </div> 18 18 19 19 <div class="main-column"> 20 20 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 21 21 22 22 <?php locate_template( array( 'groups/group-loop.php' ), true ) ?> 23 23 </div> -
trunk/bp-themes/bp-sn-parent/groups/invites.php
r1905 r2077 13 13 14 14 <?php if ( bp_has_groups() ) : ?> 15 15 16 16 <ul id="group-list" class="invites item-list"> 17 17 18 18 <?php while ( bp_groups() ) : bp_the_group(); ?> 19 19 20 20 <li> 21 21 <?php bp_group_avatar_thumb() ?> … … 24 24 <?php bp_group_description_excerpt() ?> 25 25 </p> 26 26 27 27 <?php do_action( 'bp_group_invites_item' ) ?> 28 28 29 29 <div class="action"> 30 30 31 31 <div class="generic-button accept"> 32 <a href="<?php bp_group_accept_invite_link() ?>"><?php _e( 'Accept', 'buddypress' ) ?></a> 32 <a href="<?php bp_group_accept_invite_link() ?>"><?php _e( 'Accept', 'buddypress' ) ?></a> 33 33 </div> 34 35 34 35 36 36 37 37 <div class="generic-button reject"> 38 <a href="<?php bp_group_reject_invite_link() ?>"><?php _e( 'Reject', 'buddypress' ) ?></a> 38 <a href="<?php bp_group_reject_invite_link() ?>"><?php _e( 'Reject', 'buddypress' ) ?></a> 39 39 </div> 40 40 41 41 <?php do_action( 'bp_group_invites_item_action' ) ?> 42 42 43 43 </div> 44 44 <hr /> … … 47 47 <?php endwhile; ?> 48 48 </ul> 49 49 50 50 <?php else: ?> 51 51 -
trunk/bp-themes/bp-sn-parent/groups/single/home.php
r2014 r2077 4 4 5 5 </div> 6 6 7 7 <div id="content"> 8 8 9 9 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 10 10 … … 12 12 13 13 <?php do_action( 'bp_before_group_content' ) ?> 14 14 15 15 <div class="left-menu"> 16 16 <?php locate_template( array( 'groups/single/menu.php' ), true ) ?> … … 21 21 22 22 <?php do_action( 'bp_before_group_name' ) ?> 23 23 24 24 <div id="group-name"> 25 25 <h1><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></h1> 26 26 <p class="status"><?php bp_group_type() ?></p> 27 27 </div> 28 28 29 29 <?php do_action( 'bp_after_group_name' ) ?> 30 30 31 31 <?php if ( !bp_group_is_visible() ) : ?> 32 32 33 33 <?php do_action( 'bp_before_group_status_message' ) ?> 34 34 35 35 <div id="message" class="info"> 36 36 <p><?php bp_group_status_message() ?></p> 37 37 </div> 38 38 39 39 <?php do_action( 'bp_after_group_status_message' ) ?> 40 41 <?php endif; ?> 42 40 41 <?php endif; ?> 42 43 43 <?php do_action( 'bp_before_group_description' ) ?> 44 44 45 45 <div class="bp-widget"> 46 46 <h4><?php _e( 'Description', 'buddypress' ); ?></h4> 47 47 <p><?php bp_group_description() ?></p> 48 48 </div> 49 49 50 50 <?php do_action( 'bp_after_group_description' ) ?> 51 51 52 52 <?php if ( bp_group_is_visible() && bp_group_has_news() ) : ?> 53 53 54 54 <?php do_action( 'bp_before_group_news' ) ?> 55 55 56 56 <div class="bp-widget"> 57 57 <h4><?php _e( 'News', 'buddypress' ); ?></h4> 58 58 <p><?php bp_group_news() ?></p> 59 59 </div> 60 60 61 61 <?php do_action( 'bp_after_group_news' ) ?> 62 63 <?php endif; ?> 64 62 63 <?php endif; ?> 64 65 65 <?php if ( function_exists( 'bp_has_activities' ) && bp_group_is_visible() ) : ?> 66 66 67 67 <?php if ( bp_has_activities( 'object=groups&primary_id=' . bp_get_group_id() . '&max=150&per_page=5' ) ) : ?> 68 68 … … 71 71 <div class="bp-widget"> 72 72 <h4><?php _e( 'Group Activity', 'buddypress' ); ?></h4> 73 73 74 74 <div class="pagination"> 75 75 <div class="pag-count" id="activity-count"> 76 76 <?php bp_activity_pagination_count() ?> 77 77 </div> 78 78 79 79 <div class="pagination-links" id="activity-pag"> 80 80 <?php bp_activity_pagination_links() ?> … … 88 88 <?php bp_activity_avatar() ?> 89 89 </div> 90 90 91 91 <?php bp_activity_content() ?> 92 92 </li> … … 95 95 96 96 </div> 97 97 98 98 <?php do_action( 'bp_after_group_activity' ) ?> 99 100 <?php endif; ?> 101 102 <?php endif; ?> 103 99 100 <?php endif; ?> 101 102 <?php endif; ?> 103 104 104 <?php if ( bp_group_is_visible() && bp_group_is_forum_enabled() && function_exists( 'bp_forums_setup') ) : ?> 105 105 106 106 <?php do_action( 'bp_before_group_active_topics' ) ?> 107 107 108 108 <div class="bp-widget"> 109 109 <h4><?php _e( 'Recently Active Topics', 'buddypress' ); ?> <span><a href="<?php bp_group_forum_permalink() ?>"><?php _e( 'See All', 'buddypress' ) ?> →</a></span></h4> 110 110 111 111 <?php if ( bp_has_topics( 'no_stickies=true&max=5&per_page=5' ) ) : ?> 112 112 113 113 <ul id="forum-topic-list" class="item-list"> 114 114 <?php while ( bp_topics() ) : bp_the_topic(); ?> 115 115 116 116 <li> 117 117 <a class="topic-avatar" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_last_poster_avatar( 'width=30&height=30') ?></a> 118 <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 118 <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 119 119 <span class="small topic-meta">(<?php bp_the_topic_total_post_count() ?> → <?php bp_the_topic_time_since_last_post() ?> ago)</span> 120 120 <span class="small latest topic-excerpt"><?php bp_the_topic_latest_post_excerpt() ?></span> 121 121 122 122 <?php do_action( 'bp_group_active_topics_item' ) ?> 123 123 </li> 124 124 125 125 <?php endwhile; ?> 126 126 </ul> 127 127 128 128 <?php else: ?> 129 129 … … 133 133 134 134 <?php endif;?> 135 136 </div> 137 135 136 </div> 137 138 138 <?php do_action( 'bp_after_group_active_topics' ) ?> 139 140 <?php endif; ?> 141 139 140 <?php endif; ?> 141 142 142 <?php if ( bp_group_is_visible() ) : ?> 143 143 144 144 <?php do_action( 'bp_before_group_member_widget' ) ?> 145 145 146 146 <div class="bp-widget"> 147 147 <h4><?php printf( __( 'Members (%d)', 'buddypress' ), bp_get_group_total_members() ); ?> <span><a href="<?php bp_group_all_members_permalink() ?>"><?php _e( 'See All', 'buddypress' ) ?> →</a></span></h4> 148 148 149 149 <?php if ( bp_group_has_members( 'max=5&exclude_admins_mods=0' ) ) : ?> 150 150 151 151 <ul class="horiz-gallery"> 152 152 <?php while ( bp_group_members() ) : bp_group_the_member(); ?> 153 153 154 154 <li> 155 155 <a href="<?php bp_group_member_url() ?>"><?php bp_group_member_avatar_thumb() ?></a> … … 158 158 <?php endwhile; ?> 159 159 </ul> 160 160 161 161 <?php endif; ?> 162 163 </div> 164 162 163 </div> 164 165 165 <?php do_action( 'bp_after_group_member_widget' ) ?> 166 167 <?php endif; ?> 168 166 167 <?php endif; ?> 168 169 169 <?php do_action( 'groups_custom_group_boxes' ) ?> 170 170 171 171 <?php if ( bp_group_is_visible() && bp_group_is_wire_enabled() ) : ?> 172 172 173 173 <?php if ( function_exists('bp_wire_get_post_list') ) : ?> 174 174 175 175 <?php do_action( 'bp_before_group_wire_widget' ) ?> 176 176 177 177 <?php bp_wire_get_post_list( bp_get_group_id(), __( 'Group Wire', 'buddypress' ), sprintf( __( 'There are no wire posts for %s', 'buddypress' ), bp_get_group_name() ), bp_group_is_member(), true ) ?> 178 178 179 179 <?php do_action( 'bp_after_group_wire_widget' ) ?> 180 180 181 181 <?php endif; ?> 182 183 <?php endif; ?> 184 182 183 <?php endif; ?> 184 185 185 </div> 186 186 187 187 </div> 188 188 … … 190 190 191 191 <?php endwhile; else: ?> 192 192 193 193 <div id="message" class="error"> 194 194 <p><?php _e("Sorry, the group does not exist.", "buddypress"); ?></p> 195 195 </div> 196 196 197 197 <?php endif;?> 198 198 -
trunk/bp-themes/bp-sn-parent/groups/single/leave-confirm.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 <div id="content"> 7 <div id="content"> 8 8 9 9 <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> 10 10 11 11 <?php do_action( 'bp_before_group_leave_confirm_content' ) ?> 12 12 13 13 <div class="left-menu"> 14 14 <?php locate_template( array( 'groups/single/menu.php' ), true ) ?> … … 30 30 <h4><?php _e( 'Confirm Leave Group', 'buddypress' ); ?></h4> 31 31 <h3><?php _e( 'Are you sure you want to leave this group?', 'buddypress' ); ?></h3> 32 32 33 33 <p> 34 <a href="<?php bp_group_leave_confirm_link() ?>"><?php _e( "Yes, I'd like to leave this group.", 'buddypress' ) ?></a> | 34 <a href="<?php bp_group_leave_confirm_link() ?>"><?php _e( "Yes, I'd like to leave this group.", 'buddypress' ) ?></a> | 35 35 <a href="<?php bp_group_leave_reject_link() ?>"><?php _e( "No, I'll stay!", 'buddypress' ) ?></a> 36 36 </p> 37 37 38 38 <?php do_action( 'bp_group_leave_confirm_content' ) ?> 39 39 </div> 40 40 41 41 </div> 42 42 </div> 43 43 44 44 <?php do_action( 'bp_after_group_leave_confirm_content' ) ?> 45 45 46 46 <?php endwhile; endif; ?> 47 47 48 48 </div> 49 49 -
trunk/bp-themes/bp-sn-parent/groups/single/members.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 <div id="content"> 7 <div id="content"> 8 8 <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> 9 9 10 10 <?php do_action( 'bp_before_group_members_content' ) ?> 11 11 12 12 <div class="left-menu"> 13 13 <?php locate_template( array( 'groups/single/menu.php' ), true ) ?> … … 18 18 19 19 <?php do_action( 'bp_before_group_name' ) ?> 20 20 21 21 <div id="group-name"> 22 22 <h1><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></h1> … … 26 26 <?php do_action( 'bp_after_group_name' ) ?> 27 27 <?php do_action( 'bp_before_group_administrators_list' ) ?> 28 28 29 29 <div class="bp-widget"> 30 30 <h4><?php _e( 'Administrators', 'buddypress' ); ?></h4> … … 33 33 34 34 <?php do_action( 'bp_after_group_administrators_list' ) ?> 35 35 36 36 <?php if ( bp_group_has_moderators() ) : ?> 37 37 … … 49 49 <div class="bp-widget"> 50 50 <h4><?php _e( 'Group Members', 'buddypress' ); ?></h4> 51 51 52 52 <form action="<?php bp_group_form_action('members') ?>" method="post" id="group-members-form"> 53 53 <?php if ( bp_group_has_members() ) : ?> 54 54 55 55 <?php if ( bp_group_member_needs_pagination() ) : ?> 56 56 57 57 <div class="pagination"> 58 58 … … 66 66 67 67 </div> 68 68 69 69 <?php endif; ?> 70 70 … … 73 73 <ul id="member-list" class="item-list"> 74 74 <?php while ( bp_group_members() ) : bp_group_the_member(); ?> 75 75 76 76 <li> 77 77 <?php bp_group_member_avatar_thumb() ?> 78 78 <h5><?php bp_group_member_link() ?></h5> 79 79 <span class="activity"><?php bp_group_member_joined_since() ?></span> 80 80 81 81 <?php do_action( 'bp_group_members_list_item' ) ?> 82 82 83 83 <?php if ( function_exists( 'friends_install' ) ) : ?> 84 84 85 85 <div class="action"> 86 86 <?php bp_add_friend_button( bp_get_group_member_id() ) ?> 87 87 88 88 <?php do_action( 'bp_group_members_list_item_action' ) ?> 89 89 </div> 90 90 91 91 <?php endif; ?> 92 92 </li> 93 93 94 94 <?php endwhile; ?> 95 95 96 96 </ul> 97 97 98 98 <?php do_action( 'bp_after_group_members_list' ) ?> 99 99 100 100 <?php else: ?> 101 101 … … 105 105 106 106 <?php endif;?> 107 107 108 108 <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" /> 109 109 </form> 110 110 </div> 111 111 112 112 </div> 113 113 114 114 <?php do_action( 'bp_after_group_members_content' ) ?> 115 115 116 116 </div> 117 117 118 118 <?php endwhile; endif; ?> 119 119 </div> -
trunk/bp-themes/bp-sn-parent/groups/single/request-membership.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 <div id="content"> 7 <div id="content"> 8 8 <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> 9 9 … … 27 27 <div class="bp-widget"> 28 28 <h4><?php _e( 'Request Membership', 'buddypress' ); ?></h4> 29 29 30 30 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 31 31 … … 40 40 41 41 <p><input type="submit" name="group-request-send" id="group-request-send" value="<?php _e( 'Send Request', 'buddypress' ) ?> »" /> 42 42 43 43 <?php wp_nonce_field( 'groups_request_membership' ) ?> 44 44 </form> 45 45 <?php endif; ?> 46 46 47 47 </div> 48 48 49 49 </div> 50 50 51 51 <?php do_action( 'bp_after_group_request_membership_content' ) ?> 52 52 53 53 <?php endwhile; endif; ?> 54 54 </div> -
trunk/bp-themes/bp-sn-parent/groups/single/send-invite.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 7 <div id="content"> 8 8 9 9 <div class="pagination"> 10 10 … … 16 16 17 17 <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> 18 18 19 19 <h2><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a> » <?php _e( 'Send Invites', 'buddypress' ); ?></h2> 20 20 21 21 <?php do_action( 'bp_before_group_send_invites_content' ) ?> 22 22 23 23 <?php if ( bp_has_friends_to_invite() ) : ?> 24 24 25 25 <form action="<?php bp_group_send_invite_form_action() ?>" method="post" id="send-invite-form"> 26 26 27 27 <div class="left-menu"> 28 28 29 29 <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <span class="ajax-loader"></span></h4> 30 30 31 31 <div id="invite-list"> 32 32 <ul> 33 33 <?php bp_new_group_invite_friend_list() ?> 34 34 </ul> 35 35 36 36 <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?> 37 37 </div> 38 38 39 39 </div> 40 40 41 41 <div class="main-column"> 42 42 43 43 <div id="message" class="info"> 44 44 <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p> 45 45 </div> 46 46 47 47 <?php do_action( 'bp_before_group_send_invites_list' ) ?> 48 48 … … 50 50 <ul id="friend-list" class="item-list"> 51 51 <?php if ( bp_group_has_invites() ) : ?> 52 52 53 53 <?php while ( bp_group_invites() ) : bp_group_the_invite(); ?> 54 54 55 55 <li id="<?php bp_group_invite_item_id() ?>"> 56 56 <?php bp_group_invite_user_avatar() ?> 57 57 58 58 <h4><?php bp_group_invite_user_link() ?></h4> 59 59 <span class="activity"><?php bp_group_invite_user_last_active() ?></span> 60 60 61 61 <?php do_action( 'bp_group_send_invites_item' ) ?> 62 62 63 63 <div class="action"> 64 <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 65 64 <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 65 66 66 <?php do_action( 'bp_group_send_invites_item_action' ) ?> 67 67 </div> … … 72 72 <?php endif; ?> 73 73 </ul> 74 74 75 75 <?php do_action( 'bp_after_group_send_invites_list' ) ?> 76 76 77 77 </div> 78 78 79 79 <div class="clear"></div> 80 80 81 81 <p class="clear"><input type="submit" name="submit" id="submit" value="<?php _e( 'Send Invites', 'buddypress' ) ?>" /></p> 82 82 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites') ?> 83 83 84 84 <!-- Don't leave out this hidden field --> 85 85 <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" /> 86 86 </form> 87 87 88 88 <?php else : ?> 89 89 90 90 <div id="message" class="info"> 91 91 <p><?php _e( 'You either need to build up your friends list, or your friends have already been invited or are current members.', 'buddypress' ); ?></p> 92 92 </div> 93 93 94 94 <?php endif; ?> 95 95 96 96 <?php do_action( 'bp_before_group_send_invites_content' ) ?> 97 97 98 98 <?php endwhile; endif; ?> 99 99 100 100 </div> 101 101 -
trunk/bp-themes/bp-sn-parent/groups/single/wire.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 <div id="content"> 7 <div id="content"> 8 8 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 9 9 10 10 <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> 11 11 12 12 <?php do_action( 'bp_before_group_wire_content' ) ?> 13 13 14 14 <div class="left-menu"> 15 15 <?php locate_template( array( 'groups/single/menu.php' ), true ) ?> … … 18 18 <div class="main-column"> 19 19 <div class="inner-tube"> 20 20 21 21 <div id="group-name"> 22 22 <h1><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></h1> … … 26 26 <div class="bp-widget"> 27 27 <?php if ( function_exists('bp_wire_get_post_list') ) : ?> 28 28 29 29 <?php bp_wire_get_post_list( bp_group_id( false, false), __( 'Group Wire', 'buddypress' ), sprintf( __( 'There are no wire posts for %s', 'buddypress' ), bp_group_name(false) ), bp_group_is_member(), true ) ?> 30 30 31 31 <?php endif; ?> 32 32 </div> 33 33 34 34 </div> 35 35 </div> 36 36 37 37 <?php endwhile; endif; ?> 38 38 -
trunk/bp-themes/bp-sn-parent/header.php
r2016 r2077 29 29 30 30 <body <?php body_class() ?>> 31 32 <?php do_action( 'bp_before_search_login_bar' ) ?> 33 31 32 <?php do_action( 'bp_before_search_login_bar' ) ?> 33 34 34 <div id="search-login-bar"> 35 35 36 36 <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form"> 37 <input type="text" id="search-terms" name="search-terms" value="" /> 37 <input type="text" id="search-terms" name="search-terms" value="" /> 38 38 <?php echo bp_search_form_type_select() ?> 39 39 40 40 <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 41 41 <?php wp_nonce_field( 'bp_search_form' ) ?> 42 42 </form> 43 43 44 44 <?php if ( !is_user_logged_in() ) : ?> 45 45 46 46 <form name="login-form" id="login-form" action="<?php echo site_url( 'wp-login.php' ) ?>" method="post"> 47 47 <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" /> 48 48 <input type="password" name="pwd" id="user_pass" class="input" value="" /> 49 49 50 50 <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" /> 51 52 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/> 53 54 <?php if ( 'none' != bp_get_signup_allowed() && 'blog' != bp_get_signup_allowed() ) : ?> 51 52 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/> 53 54 <?php if ( 'none' != bp_get_signup_allowed() && 'blog' != bp_get_signup_allowed() ) : ?> 55 55 <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" /> 56 56 <?php endif; ?> 57 57 58 58 <input type="hidden" name="redirect_to" value="<?php echo bp_root_domain() ?>" /> 59 59 <input type="hidden" name="testcookie" value="1" /> 60 60 61 61 <?php do_action( 'bp_login_bar_logged_out' ) ?> 62 62 </form> 63 63 64 64 <?php else : ?> 65 65 66 66 <div id="logout-link"> 67 67 <?php bp_loggedin_user_avatar( 'width=20&height=20' ) ?> <?php bp_loggedinuser_link() ?> / <?php bp_log_out_link() ?> 68 68 69 69 <?php do_action( 'bp_login_bar_logged_in' ) ?> 70 70 </div> 71 71 72 72 <?php endif; ?> 73 73 74 74 <?php do_action( 'bp_search_login_bar' ) ?> 75 75 76 76 </div> 77 77 78 <?php do_action( 'bp_after_search_login_bar' ) ?> 79 <?php do_action( 'bp_before_header' ) ?> 78 <?php do_action( 'bp_after_search_login_bar' ) ?> 79 <?php do_action( 'bp_before_header' ) ?> 80 80 81 <div id="header"> 82 81 <div id="header"> 82 83 83 <h1 id="logo"><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php bp_site_name() ?></a></h1> 84 84 85 85 <ul id="nav"> 86 86 <li<?php if ( bp_is_page( 'home' ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li> … … 95 95 <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_FORUMS_SLUG ?>" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a></li> 96 96 <?php endif; ?> 97 97 98 98 <?php if ( function_exists( 'bp_blogs_install' ) ) : ?> 99 99 <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_BLOGS_SLUG ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li> … … 104 104 105 105 <?php do_action( 'bp_header' ) ?> 106 106 107 107 </div> 108 108 109 109 <?php do_action( 'bp_after_header' ) ?> 110 110 <?php do_action( 'bp_before_container' ) ?> 111 111 112 112 <div id="container"> 113 113 114 114 <?php if ( !bp_is_blog_page() && !bp_is_directory() && !bp_is_register_page() && !bp_is_activation_page() ) : ?> 115 115 116 116 <?php locate_template( array( 'userbar.php' ), true ) /* Load the user navigation */ ?> 117 117 <?php locate_template( array( 'optionsbar.php' ), true ) /* Load the currently displayed object navigation */ ?> 118 118 119 119 <?php endif; ?> 120 -
trunk/bp-themes/bp-sn-parent/home.php
r1932 r2077 8 8 <?php if ( !function_exists('dynamic_sidebar') 9 9 || !dynamic_sidebar('third-section') ) : ?> 10 10 11 11 <div class="widget-error"> 12 12 <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&show=&sidebar=first-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a> 13 13 </div> 14 14 15 15 <?php endif; ?> 16 16 </div> 17 17 18 18 <div id="second-section" class="widget-section"> 19 19 <?php if ( !function_exists('dynamic_sidebar') 20 20 || !dynamic_sidebar('second-section') ) : ?> 21 21 22 22 <div class="widget-error"> 23 23 <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&show=&sidebar=second-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a> 24 24 </div> 25 25 26 26 <?php endif; ?> 27 27 </div> … … 33 33 <div class="widget-error"> 34 34 <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&show=&sidebar=third-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a> 35 </div> 36 35 </div> 36 37 37 <?php endif; ?> 38 38 </div> -
trunk/bp-themes/bp-sn-parent/index.php
r1905 r2077 6 6 7 7 <div class="page" id="blog-latest"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2> 10 10 11 11 <?php if ( have_posts() ) : ?> 12 12 13 13 <?php while (have_posts()) : the_post(); ?> 14 14 15 15 <?php do_action( 'bp_before_blog_post' ) ?> 16 16 17 17 <div class="post" id="post-<?php the_ID(); ?>"> 18 18 19 19 <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> 20 20 21 21 <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> 22 22 … … 34 34 35 35 <div class="navigation"> 36 36 37 37 <div class="alignleft"><?php next_posts_link( __( '« Previous Entries', 'buddypress' ) ) ?></div> 38 38 <div class="alignright"><?php previous_posts_link( __( 'Next Entries »', 'buddypress' ) ) ?></div> 39 39 40 40 </div> 41 41 -
trunk/bp-themes/bp-sn-parent/links.php
r1905 r2077 12 12 13 13 <div class="page" id="blog-latest"> 14 14 15 15 <h2 class="pagetitle"><?php _e( 'Links', 'buddypress' ) ?></h2> 16 16 … … 18 18 <?php get_links_list(); ?> 19 19 </ul> 20 20 21 21 </div> 22 22 -
trunk/bp-themes/bp-sn-parent/messages/compose.php
r1998 r2077 7 7 <div id="content"> 8 8 <h2><?php _e( 'Compose Message', 'buddypress' ); ?></h2> 9 9 10 10 <?php do_action( 'template_notices' ) ?> 11 11 12 12 <form action="<?php bp_messages_form_action('compose') ?>" method="post" id="send_message_form" class="standard-form"> 13 13 14 14 <?php do_action( 'bp_before_messages_compose_content' ) ?> 15 15 16 16 <label for="send-to-input"><?php _e("Send To", 'buddypress') ?> <span class="ajax-loader"></span></label> 17 17 <ul class="first acfb-holder"> … … 21 21 </li> 22 22 </ul> 23 23 24 24 <?php if ( is_site_admin() ) : ?> 25 25 <input type="checkbox" id="send-notice" name="send-notice" value="1" /> <?php _e( "This is a notice to all users.", "buddypress" ) ?> … … 33 33 34 34 <input type="hidden" name="send_to_usernames" id="send-to-usernames" value="<?php bp_message_get_recipient_usernames(); ?>" class="<?php bp_message_get_recipient_usernames() ?>" /> 35 35 36 36 <?php do_action( 'bp_after_messages_compose_content' ) ?> 37 37 … … 39 39 <input type="submit" value="<?php _e("Send", 'buddypress') ?> »" name="send" id="send" /> 40 40 </p> 41 41 42 42 <?php wp_nonce_field( 'messages_send_message' ) ?> 43 43 </form> 44 44 45 45 <script type="text/javascript"> 46 46 document.getElementById("send-to-input").focus(); -
trunk/bp-themes/bp-sn-parent/messages/index.php
r1905 r2077 4 4 5 5 <div class="content-header"> 6 <div class="messages-options"> 6 <div class="messages-options"> 7 7 <?php bp_messages_options() ?> 8 8 </div> … … 11 11 <div id="content"> 12 12 <h2><?php _e( "Inbox", "buddypress" ); ?></h2> 13 13 14 14 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 15 15 16 16 <?php do_action( 'bp_before_messages_inbox_content' ) ?> 17 17 18 18 <?php bp_message_get_notices(); // (admin created site wide notices) ?> 19 19 20 20 <?php if ( bp_has_message_threads() ) : ?> 21 21 22 22 <div class="pagination"> 23 23 … … 27 27 28 28 </div> 29 29 30 30 <?php do_action( 'bp_before_messages_inbox_list' ) ?> 31 31 32 32 <table id="message-threads"> 33 33 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 34 34 35 35 <tr id="m-<?php bp_message_thread_id() ?>"<?php if ( bp_message_thread_has_unread() ) : ?> class="unread"<?php else: ?> class="read"<?php endif; ?>> 36 36 <td width="1%"> … … 46 46 <p><?php bp_message_thread_excerpt() ?></p> 47 47 </td> 48 48 49 49 <?php do_action( 'bp_messages_inbox_list_item' ) ?> 50 50 51 51 <td width="10%"> 52 <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> 52 <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> 53 53 <input type="checkbox" name="message_ids[]" value="<?php bp_message_thread_id() ?>" /> 54 54 </td> 55 55 </tr> 56 56 57 57 <?php endwhile; ?> 58 58 </table> 59 59 60 60 <?php do_action( 'bp_after_messages_inbox_list' ) ?> 61 61 62 62 <?php else: ?> 63 63 64 64 <div id="message" class="info"> 65 65 <p><?php _e( 'You have no messages in your inbox.', 'buddypress' ); ?></p> 66 </div> 67 66 </div> 67 68 68 <?php endif;?> 69 69 -
trunk/bp-themes/bp-sn-parent/messages/notices.php
r1905 r2077 6 6 7 7 <div id="content"> 8 8 9 9 <div class="pagination"> 10 10 11 11 <div class="pagination-links"> 12 12 <?php bp_messages_pagination() ?> 13 13 </div> 14 14 15 15 </div> 16 16 17 17 <h2><?php _e( 'Sent Notices', 'buddypress' ); ?></h2> 18 18 19 19 <?php do_action( 'template_notices' ) ?> 20 20 … … 24 24 25 25 <?php do_action( 'bp_before_messages_notices_list' ) ?> 26 26 27 27 <table id="message-threads" class="notices"> 28 28 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> … … 39 39 <p class="date"><?php _e("Sent:", "buddypress"); ?> <?php bp_message_notice_post_date() ?></p> 40 40 </td> 41 41 42 42 <?php do_action( 'bp_messages_notices_list_item' ) ?> 43 43 44 44 <td width="4%"> 45 <a href="<?php bp_message_activate_deactivate_link() ?>" class="confirm"><?php bp_message_activate_deactivate_text() ?></a> 46 <a href="<?php bp_message_notice_delete_link() ?>" class="confirm" title="<?php _e("Delete Message", "buddypress"); ?>"><?php _e("Delete", "buddypress"); ?></a> 45 <a href="<?php bp_message_activate_deactivate_link() ?>" class="confirm"><?php bp_message_activate_deactivate_text() ?></a> 46 <a href="<?php bp_message_notice_delete_link() ?>" class="confirm" title="<?php _e("Delete Message", "buddypress"); ?>"><?php _e("Delete", "buddypress"); ?></a> 47 47 </td> 48 48 </tr> 49 49 50 50 <?php endwhile; ?> 51 51 </table> 52 52 53 53 <?php do_action( 'bp_after_messages_notices_list' ) ?> 54 54 55 55 <?php else: ?> 56 56 57 57 <div id="message" class="info"> 58 58 <p><?php _e("You have not sent any notices.", "buddypress"); ?></p> 59 </div> 59 </div> 60 60 61 61 <?php endif; ?> -
trunk/bp-themes/bp-sn-parent/messages/sentbox.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 <div class="messages-options"> 4 <div class="messages-options"> 5 5 <?php bp_messages_options() ?> 6 6 </div> 7 7 </div> 8 8 9 <div id="content"> 9 <div id="content"> 10 10 <h2><?php _e("Sent Messages", "buddypress"); ?></h2> 11 11 12 12 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 13 13 … … 15 15 16 16 <?php if ( bp_has_message_threads() ) : ?> 17 17 18 18 <div class="pagination"> 19 19 … … 21 21 <?php bp_messages_pagination() ?> 22 22 </div> 23 23 24 24 </div> 25 25 26 26 <?php do_action( 'bp_before_messages_sentbox_list' ) ?> 27 27 28 28 <table id="message-threads"> 29 29 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 30 30 31 31 <tr id="m-<?php bp_message_thread_id() ?>"> 32 32 <td width="1%"> … … 45 45 46 46 <td width="10%"> 47 <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> 47 <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> 48 48 <input type="checkbox" name="message_ids[]" value="<?php bp_message_thread_id() ?>" /> 49 49 </td> 50 50 </tr> 51 51 52 52 <?php endwhile; ?> 53 53 </table> 54 54 55 55 <?php do_action( 'bp_after_messages_sentbox_list' ) ?> 56 56 57 57 <?php else: ?> 58 58 59 59 <div id="message" class="info"> 60 60 <p><?php _e("You have no sent messages.", "buddypress"); ?></p> 61 </div> 61 </div> 62 62 63 63 <?php endif;?> 64 64 65 65 <?php do_action( 'bp_after_messages_sentbox_content' ) ?> 66 66 67 67 </div> 68 68 -
trunk/bp-themes/bp-sn-parent/messages/view.php
r1905 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 </div> 6 6 7 7 <div id="content"> 8 8 9 9 <?php do_action( 'template_notices' ) ?> 10 10 11 11 <?php do_action( 'bp_before_message_thread_content' ) ?> 12 12 13 13 <?php if ( bp_thread_has_messages() ) : ?> 14 14 15 15 <h2 id="message-subject"><?php bp_the_thread_subject() ?></h2> 16 16 17 17 <p id="message-recipients"> 18 18 <?php printf( __('Sent between %s and %s', 'buddypress'), bp_get_the_thread_recipients(), '<a href="' . bp_get_loggedin_user_link() . '" title="' . bp_get_loggedin_user_fullname() . '">' . bp_get_loggedin_user_fullname() . '</a>' ) ?> 19 19 </p> 20 20 21 21 <?php do_action( 'bp_before_message_thread_list' ) ?> 22 22 23 23 <?php while ( bp_thread_messages() ) : bp_thread_the_message(); ?> 24 24 25 25 <div class="message-box<?php bp_the_thread_message_alt_class() ?>"> 26 26 27 27 <div class="message-metadata"> 28 28 29 29 <?php do_action( 'bp_before_message_meta' ) ?> 30 30 31 31 <?php bp_the_thread_message_sender_avatar( 'type=thumb&width=30&height=30' ) ?> 32 32 <h3><a href="<?php bp_the_thread_message_sender_link() ?>" title="<?php bp_the_thread_message_sender_name() ?>"><?php bp_the_thread_message_sender_name() ?></a></h3> 33 33 34 34 <small> 35 35 <?php bp_the_thread_message_time_since() ?> 36 36 </small> 37 37 38 38 <?php do_action( 'bp_after_message_meta' ) ?> 39 39 40 40 </div> 41 41 42 42 <?php do_action( 'bp_before_message_content' ) ?> 43 43 44 44 <div class="message-content"> 45 45 46 46 <?php bp_the_thread_message_content() ?> 47 47 48 48 </div> 49 49 50 50 <?php do_action( 'bp_after_message_content' ) ?> 51 51 52 52 <div class="clear"></div> 53 53 54 54 </div> 55 55 56 56 <?php endwhile; ?> 57 57 58 58 <?php do_action( 'bp_after_message_thread_list' ) ?> 59 59 60 60 <?php do_action( 'bp_before_message_thread_reply' ) ?> 61 61 62 62 <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post" class="standard-form"> 63 63 64 64 <div class="message-box"> 65 65 66 66 <div class="message-metadata"> 67 68 <?php do_action( 'bp_before_message_meta' ) ?> 69 67 68 <?php do_action( 'bp_before_message_meta' ) ?> 69 70 70 <div class="avatar-box"> 71 71 <?php echo bp_core_fetch_avatar( array( 'item_id' => bp_loggedin_user_id(), 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ); ?> … … 75 75 76 76 <?php do_action( 'bp_after_message_meta' ) ?> 77 77 78 78 </div> 79 79 80 80 <div class="message-content"> 81 81 82 82 <?php do_action( 'bp_before_message_reply_box' ) ?> 83 83 84 84 <textarea name="content" id="message_content" rows="15" cols="40"></textarea> 85 85 86 86 <?php do_action( 'bp_after_message_reply_box' ) ?> 87 87 88 88 <p class="submit"> 89 89 <input type="submit" name="send" value="<?php _e( 'Send Reply', 'buddypress' ) ?> →" id="send_reply_button"/> … … 93 93 <input type="hidden" name="subject" id="subject" value="<?php _e( 'Re: ', 'buddypress' ); echo str_replace( 'Re: ', '', bp_get_the_thread_subject() ); ?>" /> 94 94 <?php wp_nonce_field( 'messages_send_message', 'send_message_nonce' ) ?> 95 95 96 96 </div> 97 97 98 98 </div> 99 99 100 100 </form> 101 101 102 102 <?php do_action( 'bp_after_message_thread_reply' ) ?> 103 103 104 104 <?php endif; ?> 105 105 -
trunk/bp-themes/bp-sn-parent/optionsbar.php
r1905 r2077 2 2 3 3 <div id="optionsbar"> 4 4 5 5 <h3><?php bp_get_options_title() ?></h3> 6 6 7 7 <?php do_action( 'bp_inside_before_options_bar' ) ?> 8 8 9 9 <?php if ( bp_has_options_avatar() ) : ?> 10 10 … … 14 14 15 15 <?php endif; ?> 16 16 17 17 <ul id="options-nav"> 18 18 <?php bp_get_options_nav() ?> 19 19 </ul> 20 20 21 21 <?php do_action( 'bp_inside_after_options_bar' ) ?> 22 22 -
trunk/bp-themes/bp-sn-parent/page.php
r1905 r2077 4 4 5 5 <?php do_action( 'bp_before_blog_page' ) ?> 6 6 7 7 <div class="page" id="blog-page"> 8 8 9 9 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 10 10 11 11 <h2 class="pagetitle"><?php the_title(); ?></h2> 12 12 13 13 <div class="post" id="post-<?php the_ID(); ?>"> 14 14 15 15 <div class="entry"> 16 16 17 17 <?php the_content( __( '<p class="serif">Read the rest of this page »</p>', 'buddypress' ) ); ?> 18 18 19 19 <?php wp_link_pages( array( 'before' => __( '<p><strong>Pages:</strong> ', 'buddypress' ), 'after' => '</p>', 'next_or_number' => 'number')); ?> 20 20 <?php edit_post_link( __( 'Edit this entry.', 'buddypress' ), '<p>', '</p>'); ?> 21 21 22 22 </div> 23 23 24 24 </div> 25 25 26 26 <?php endwhile; endif; ?> 27 27 28 28 </div> 29 29 30 30 <?php do_action( 'bp_after_blog_page' ) ?> 31 31 32 32 </div> 33 33 -
trunk/bp-themes/bp-sn-parent/plugin-template.php
r1905 r2077 7 7 <div id="content"> 8 8 <h2><?php do_action('bp_template_title') ?></h2> 9 9 10 10 <?php do_action('bp_template_content') ?> 11 11 </div> -
trunk/bp-themes/bp-sn-parent/profile/change-avatar.php
r1905 r2077 6 6 7 7 <div id="content"> 8 8 9 9 <h2><?php _e( 'Change Avatar', 'buddypress' ) ?></h2> 10 10 11 11 <?php do_action( 'template_notices' ) ?> 12 12 13 13 <?php do_action( 'bp_before_profile_avatar_upload_content' ) ?> 14 14 15 15 <p><?php _e( 'Your avatar will be used on your profile and throughout the site. If there is a <a href="http://gravatar.com">Gravatar</a> associated with your account email we will use that, or you can upload an image from your computer.', 'buddypress') ?></p> 16 17 <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data"> 18 16 17 <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data"> 18 19 19 <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?> 20 20 21 21 <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3> 22 22 23 23 <p id="current-avatar"> 24 24 <?php bp_displayed_user_avatar( 'type=full') ?> 25 25 <?php bp_displayed_user_avatar( 'type=thumb' ) ?> 26 26 </p> 27 27 28 28 <?php if ( bp_get_user_has_avatar() ) : ?> 29 29 <div class="generic-button" id="delete-avatar-button"> … … 31 31 </div> 32 32 <?php endif; ?> 33 33 34 34 <h3><?php _e( 'Upload a New Avatar', 'buddypress' ) ?></h3> 35 35 36 36 <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Image\' to proceed.', 'buddypress' ) ?></p> 37 37 38 38 <p id="avatar-upload"> 39 <input type="file" name="file" id="file" /> 39 <input type="file" name="file" id="file" /> 40 40 <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" /> 41 41 <input type="hidden" name="action" id="action" value="bp_avatar_upload" /> … … 43 43 44 44 <?php wp_nonce_field( 'bp_avatar_upload' ) ?> 45 45 46 46 <?php endif; ?> 47 47 48 48 <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?> 49 49 50 50 <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3> 51 51 52 52 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" /> 53 53 54 54 <div id="avatar-crop-pane"> 55 55 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" /> … … 57 57 58 58 <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" /> 59 59 60 60 <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" /> 61 61 <input type="hidden" id="x" name="x" /> … … 65 65 66 66 <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?> 67 67 68 68 <?php endif; ?> 69 69 70 70 </form> 71 71 72 72 <?php do_action( 'bp_after_profile_avatar_upload_content' ) ?> 73 73 74 74 </div> 75 75 -
trunk/bp-themes/bp-sn-parent/profile/edit.php
r1920 r2077 2 2 3 3 <div class="content-header"> 4 4 5 5 <ul class="content-header-nav"> 6 6 <?php bp_profile_group_tabs(); ?> 7 7 </ul> 8 8 9 9 </div> 10 10 … … 12 12 13 13 <?php do_action( 'template_notices' ) // (error/success feedback) ?> 14 14 15 15 <?php do_action( 'bp_before_profile_edit_content' ) ?> 16 16 17 17 <?php if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 18 18 … … 20 20 21 21 <?php do_action( 'bp_before_profile_field_content' ) ?> 22 22 23 23 <h2><?php printf( __( "Editing '%s'", "buddypress" ), bp_get_the_profile_group_name() ); ?></h2> 24 24 25 25 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 26 26 27 27 <div<?php bp_field_css_class( 'editfield' ) ?>> 28 28 29 29 <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?> 30 30 31 31 <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> 32 32 <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() ?>" /> 33 33 34 34 <?php endif; ?> 35 35 36 36 <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?> 37 37 38 38 <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> 39 39 <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> 40 40 41 41 <?php endif; ?> 42 42 43 43 <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?> 44 44 45 45 <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> 46 46 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"> 47 47 <?php bp_the_profile_field_options() ?> 48 48 </select> 49 49 50 50 <?php endif; ?> 51 51 52 52 <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?> 53 53 54 54 <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> 55 55 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple"> 56 56 <?php bp_the_profile_field_options() ?> 57 57 </select> 58 58 59 59 <?php endif; ?> 60 60 61 61 <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?> 62 62 63 63 <div class="radio"> 64 64 <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> 65 65 66 66 <?php bp_the_profile_field_options() ?> 67 67 68 68 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 69 69 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 70 70 <?php endif; ?> 71 71 </div> 72 73 <?php endif; ?> 74 72 73 <?php endif; ?> 74 75 75 <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?> 76 76 77 77 <div class="checkbox"> 78 78 <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> 79 79 80 80 <?php bp_the_profile_field_options() ?> 81 </div> 82 83 <?php endif; ?> 81 </div> 82 83 <?php endif; ?> 84 84 85 85 <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?> 86 86 87 87 <div class="datebox"> 88 88 <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> 89 89 90 90 <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day"> 91 91 <?php bp_the_profile_field_options( 'type=day' ) ?> 92 92 </select> 93 93 94 94 <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month"> 95 95 <?php bp_the_profile_field_options( 'type=month' ) ?> 96 96 </select> 97 97 98 98 <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year"> 99 99 <?php bp_the_profile_field_options( 'type=year' ) ?> 100 </select> 100 </select> 101 101 </div> 102 103 <?php endif; ?> 104 102 103 <?php endif; ?> 104 105 105 <?php do_action( 'bp_custom_profile_edit_fields' ) ?> 106 106 107 107 <p class="description"><?php bp_the_profile_field_description() ?></p> 108 108 </div> … … 111 111 112 112 <?php do_action( 'bp_after_profile_field_content' ) ?> 113 113 114 114 <input type="submit" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?> " /> 115 115 116 116 <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids() ?>" /> 117 117 <?php wp_nonce_field( 'bp_xprofile_edit' ) ?> 118 118 119 119 </form> 120 120 121 121 <?php endwhile; endif; ?> 122 122 123 123 <?php do_action( 'bp_after_profile_edit_content' ) ?> 124 124 -
trunk/bp-themes/bp-sn-parent/profile/index.php
r1905 r2077 10 10 11 11 <?php do_action( 'bp_before_profile_content' ) ?> 12 12 13 13 <div class="left-menu"> 14 14 <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) --> … … 18 18 <div class="main-column"> 19 19 <div class="inner-tube"> 20 20 21 21 <?php /* Profile Header (Name & Status) */ ?> 22 22 <?php locate_template( array( 'profile/profile-header.php' ), true ) ?> 23 23 24 24 <?php /* Profile Data Loop */ ?> 25 25 <?php locate_template( array( 'profile/profile-loop.php' ), true ) ?> 26 26 27 27 <?php do_action( 'bp_before_profile_activity_loop' ) ?> 28 28 29 29 <?php /* Latest Activity Loop */ ?> 30 30 <?php if ( function_exists( 'bp_activity_install')) : ?> 31 31 32 32 <?php do_action( 'bp_before_profile_activity_widget' ) ?> 33 33 … … 47 47 <?php bp_activity_avatar() ?> 48 48 </div> 49 49 50 50 <?php bp_activity_content() ?> 51 51 </li> … … 61 61 <?php endif;?> 62 62 </div> 63 63 64 64 <?php do_action( 'bp_after_profile_activity_widget' ) ?> 65 65 66 66 <?php endif; ?> 67 67 68 68 <?php do_action( 'bp_after_profile_activity_loop' ) ?> 69 69 <?php do_action( 'bp_before_profile_random_groups_loop' ) ?> 70 70 71 71 <?php /* Random Groups Loop */ ?> 72 72 <?php if ( function_exists( 'bp_has_groups' ) ) : ?> … … 75 75 76 76 <?php if ( bp_has_groups( 'type=random&max=5' ) ) : ?> 77 77 78 78 <div class="bp-widget"> 79 79 <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php bp_group_total_for_member() ?>) <span><a href="<?php echo bp_displayed_user_domain() . BP_GROUPS_SLUG ?>"><?php _e( 'See All', 'buddypress' ) ?> →</a></span></h4> 80 80 81 81 <ul class="horiz-gallery"> 82 82 <?php while ( bp_groups() ) : bp_the_group(); ?> … … 90 90 91 91 <?php do_action( 'bp_after_profile_groups_widget' ) ?> 92 92 93 93 <?php endif; ?> 94 94 95 95 <?php endif; ?> 96 96 97 97 <?php do_action( 'bp_after_profile_random_groups_loop' ) ?> 98 98 <?php do_action( 'bp_before_profile_random_friends_loop' ) ?> 99 99 100 100 <?php /* Random Friends Loop */ ?> 101 101 <?php if ( function_exists( 'bp_has_friendships' ) ) : ?> … … 104 104 105 105 <?php if ( bp_has_friendships( 'type=random&max=5' ) ) : ?> 106 106 107 107 <div class="bp-widget"> 108 108 <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php bp_friend_total_for_member() ?>) <span><a href="<?php echo bp_displayed_user_domain() . BP_FRIENDS_SLUG ?>"><?php _e( 'See All', 'buddypress' ) ?> →</a></span></h4> 109 109 110 110 <ul class="horiz-gallery"> 111 111 <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?> … … 115 115 </li> 116 116 <?php endwhile; ?> 117 </ul> 117 </ul> 118 118 </div> 119 119 120 120 <?php endif; ?> 121 121 122 122 <?php do_action( 'bp_after_profile_friends_widget' ) ?> 123 123 124 124 <?php endif; ?> 125 125 126 126 <?php do_action( 'bp_after_profile_random_friends_loop' ) ?> 127 127 <?php do_action( 'bp_before_profile_wire_loop' ); /* Deprecated -> */ do_action( 'bp_custom_profile_boxes' ) ?> … … 139 139 140 140 <?php do_action( 'bp_after_profile_wire_loop' ) ?> 141 141 142 142 </div> 143 143 -
trunk/bp-themes/bp-sn-parent/profile/profile-header.php
r1905 r2077 3 3 <div id="profile-name"> 4 4 <h1 class="fn"><a href="<?php bp_user_link() ?>"><?php bp_user_fullname() ?></a></h1> 5 5 6 6 <?php if ( function_exists( 'bp_the_status' ) ) : ?> 7 7 … … 11 11 12 12 <?php endif; ?> 13 13 14 14 <?php do_action( 'bp_profile_header_content' ) ?> 15 15 </div> -
trunk/bp-themes/bp-sn-parent/profile/profile-loop.php
r1905 r2077 1 1 <?php if ( function_exists('xprofile_get_profile') ) : ?> 2 3 <?php if ( bp_has_profile() ) : ?> 4 2 3 <?php if ( bp_has_profile() ) : ?> 4 5 5 <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 6 6 7 7 <?php if ( bp_profile_group_has_fields() ) : ?> 8 8 9 9 <?php do_action( 'bp_before_profile_field_content' ) ?> 10 10 11 11 <div class="bp-widget <?php bp_the_profile_group_slug() ?>"> 12 12 <h4><?php bp_the_profile_group_name() ?></h4> 13 13 14 14 <table class="profile-fields"> 15 15 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> … … 17 17 <?php if ( bp_field_has_data() ) : ?> 18 18 <tr<?php bp_field_css_class() ?>> 19 19 20 20 <td class="label"> 21 21 <?php bp_the_profile_field_name() ?> … … 24 24 <?php bp_the_profile_field_value() ?> 25 25 </td> 26 26 27 27 </tr> 28 28 <?php endif; ?> 29 29 30 30 <?php do_action( 'bp_profile_field_item' ) ?> 31 31 … … 35 35 36 36 <?php do_action( 'bp_after_profile_field_content' ) ?> 37 38 <?php endif; ?> 39 37 38 <?php endif; ?> 39 40 40 <?php endwhile; ?> 41 41 42 42 <div class="button-block"> 43 43 <?php if ( bp_is_home() || is_site_admin() ) : ?> 44 44 45 45 <?php bp_edit_profile_button() ?> 46 46 47 47 <?php endif; ?> 48 48 49 49 <?php do_action( 'bp_profile_field_buttons' ) ?> 50 50 </div> 51 51 52 52 <?php else: ?> 53 53 54 54 <div id="message" class="info"> 55 55 <p><?php _e( 'Sorry, this person does not have a public profile.', 'buddypress' ) ?></p> 56 56 </div> 57 57 58 58 <?php endif;?> 59 59 60 60 <?php else : ?> 61 61 62 62 <?php bp_core_get_wp_profile() ?> 63 63 -
trunk/bp-themes/bp-sn-parent/profile/profile-menu.php
r1982 r2077 4 4 5 5 <div class="button-block"> 6 6 7 7 <?php if ( function_exists('bp_add_friend_button') ) : ?> 8 8 9 9 <?php bp_add_friend_button() ?> 10 10 11 11 <?php endif; ?> 12 12 13 13 <?php if ( function_exists('bp_send_message_button') ) : ?> 14 14 15 15 <?php bp_send_message_button() ?> 16 16 17 17 <?php endif; ?> 18 18 19 19 <?php do_action( 'bp_before_profile_menu_buttons' ) ?> 20 20 -
trunk/bp-themes/bp-sn-parent/registration/activate.php
r1905 r2077 6 6 7 7 <div class="page" id="activate-page"> 8 8 9 9 <div class="register bp_core_widget_welcome"> 10 10 11 11 <?php do_action( 'template_notices' ) ?> 12 12 13 13 <?php if ( bp_account_was_activated() ) : ?> 14 14 15 15 <h2 class="widgettitle"><?php _e( 'Account Activated', 'buddypress' ) ?></h2> 16 16 17 17 <?php do_action( 'bp_before_activate_content' ) ?> 18 18 19 19 <p><?php _e( 'Your account was activated successfully! You can now log in with the username and password you provided when you signed up.', 'buddypress' ) ?></p> 20 21 20 21 22 22 <?php else : ?> 23 23 24 24 <h2 class="widgettitle"><?php _e( 'Activate your Account', 'buddypress' ) ?></h2> 25 25 26 26 <?php do_action( 'bp_before_activate_content' ) ?> 27 27 28 28 <p><?php _e( 'Please provide a valid activation key.', 'buddypress' ) ?></p> 29 29 30 30 <form action="" method="get" class="standard-form" id="activation-form"> 31 31 32 32 <label for="key"><?php _e( 'Activation Key:', 'buddypress' ) ?></label> 33 33 <input type="text" name="key" id="key" value="" /> 34 34 35 35 <p class="submit"> 36 36 <input type="submit" name="submit" value="<?php _e( 'Activate', 'buddypress' ) ?> →" /> 37 37 </p> 38 38 39 39 </form> 40 40 41 41 <?php endif; ?> 42 42 43 43 <?php do_action( 'bp_after_activate_content' ) ?> 44 44 45 45 </div> 46 46 47 47 </div> 48 48 … … 50 50 51 51 </div> 52 52 53 53 <?php get_sidebar() ?> 54 54 -
trunk/bp-themes/bp-sn-parent/registration/register.php
r1983 r2077 4 4 5 5 <?php do_action( 'bp_before_register_page' ) ?> 6 6 7 7 <div class="page" id="register-page"> 8 8 9 9 <form action="" name="signup_form" id="signup_form" class="standard-form" method="post" enctype="multipart/form-data"> 10 10 11 11 <?php if ( 'request-details' == bp_get_current_signup_step() ) : ?> 12 12 13 13 <h2 class="pagetitle"><?php _e( 'Sign Up', 'buddypress' ) ?></h2> 14 14 15 15 <?php do_action( 'template_notices' ) ?> 16 16 17 17 <p><?php _e( 'Registering for this site is easy, just fill in the fields below and we\'ll get a new account set up for you in no time.', 'buddypress' ) ?></p> 18 18 19 19 <?php do_action( 'bp_before_account_details_fields' ) ?> 20 20 21 21 <div class="register-section" id="basic-details-section"> 22 22 23 23 <?php /***** Basic Account Details ******/ ?> 24 24 25 25 <h3><?php _e( 'Account Details', 'buddypress' ) ?></h3> 26 26 27 27 <label for="signup_username"><?php _e( 'Username', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label> 28 28 <?php do_action( 'bp_signup_username_errors' ) ?> … … 40 40 <?php do_action( 'bp_signup_password_confirm_errors' ) ?> 41 41 <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" /> 42 42 43 43 </div> 44 44 45 45 <?php do_action( 'bp_after_account_details_fields' ) ?> 46 46 … … 51 51 52 52 <div class="register-section" id="profile-details-section"> 53 53 54 54 <h3><?php _e( 'Profile Details', 'buddypress' ) ?></h3> 55 55 56 56 <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?> 57 57 <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?> … … 62 62 63 63 <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?> 64 64 65 65 <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> 66 66 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 67 67 <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() ?>" /> 68 68 69 69 <?php endif; ?> 70 70 71 71 <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?> 72 72 73 73 <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> 74 74 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 75 75 <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> 76 76 77 77 <?php endif; ?> 78 78 … … 84 84 <?php bp_the_profile_field_options() ?> 85 85 </select> 86 86 87 87 <?php endif; ?> 88 88 … … 101 101 <div class="radio"> 102 102 <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> 103 103 104 104 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 105 105 <?php bp_the_profile_field_options() ?> 106 106 107 107 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 108 108 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> … … 110 110 </div> 111 111 112 <?php endif; ?> 112 <?php endif; ?> 113 113 114 114 <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?> … … 116 116 <div class="checkbox"> 117 117 <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> 118 118 119 119 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 120 120 <?php bp_the_profile_field_options() ?> 121 </div> 122 123 <?php endif; ?> 121 </div> 122 123 <?php endif; ?> 124 124 125 125 <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?> … … 128 128 <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> 129 129 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?> 130 130 131 131 <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day"> 132 132 <?php bp_the_profile_field_options( 'type=day' ) ?> 133 133 </select> 134 134 135 135 <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month"> 136 136 <?php bp_the_profile_field_options( 'type=month' ) ?> 137 137 </select> 138 138 139 139 <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year"> 140 140 <?php bp_the_profile_field_options( 'type=year' ) ?> 141 </select> 141 </select> 142 142 </div> 143 143 144 <?php endif; ?> 144 <?php endif; ?> 145 145 146 146 <?php do_action( 'bp_custom_profile_edit_fields' ) ?> 147 147 148 148 <p class="description"><?php bp_the_profile_field_description() ?></p> 149 149 150 150 </div> 151 151 … … 153 153 154 154 <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" /> 155 155 156 156 </div> 157 157 158 158 <?php endwhile; endif; endif; ?> 159 159 160 160 <?php do_action( 'bp_after_signup_profile_fields' ) ?> 161 161 162 162 <?php if ( 'all' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() ) : ?> 163 163 … … 167 167 168 168 <div class="register-section" id="blog-details-section"> 169 169 170 170 <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3> 171 171 172 172 <p><input type="checkbox" name="signup_with_blog" id="signup_with_blog" value="1"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes, I\'d like to create a new blog', 'buddypress' ) ?></p> 173 173 174 174 <div id="blog-details"> 175 175 176 176 <label for="signup_blog_url"><?php _e( 'Blog URL', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label> 177 177 <?php do_action( 'bp_signup_blog_url_errors' ) ?> 178 178 179 179 <?php if ( 'yes' == VHOST ) : ?> 180 180 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() ) ?> 181 181 <?php else : ?> 182 <?php echo site_url() ?>/ <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" /> 183 <?php endif; ?> 184 182 <?php echo site_url() ?>/ <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" /> 183 <?php endif; ?> 184 185 185 <label for="signup_blog_title"><?php _e( 'Blog Title', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label> 186 186 <?php do_action( 'bp_signup_blog_title_errors' ) ?> … … 189 189 <span class="label"><?php _e( 'I would like my blog to appear in search engines, and in public listings around this site', 'buddypress' ) ?>:</span> 190 190 <?php do_action( 'bp_signup_blog_privacy_errors' ) ?> 191 191 192 192 <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_public" value="public"<?php if ( 'public' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes' ) ?></label> 193 193 <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_private" value="private"<?php if ( 'private' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'No' ) ?></label> 194 195 </div> 196 194 195 </div> 196 197 197 </div> 198 198 199 199 <?php do_action( 'bp_after_blog_details_fields' ) ?> 200 200 201 201 <?php endif; ?> 202 202 203 203 <?php do_action( 'bp_before_registration_submit_buttons' ) ?> 204 204 205 205 <p class="submit"> 206 206 <input type="submit" name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> →" /> … … 212 212 213 213 <?php endif; // request-details signup step ?> 214 214 215 215 <?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?> 216 216 217 217 <h2 class="pagetitle"><?php _e( 'Sign Up Complete!', 'buddypress' ) ?></h2> 218 218 219 219 <?php do_action( 'template_notices' ) ?> 220 220 221 221 <p><?php _e( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' ) ?></p> 222 222 223 223 <?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?> 224 224 225 225 <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?> 226 226 227 227 <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3> 228 228 <p><?php _e( "We've fetched an avatar for your new account. If you'd like to change this, why not upload a new one while you wait for your activation email?", 'buddypress' ) ?></p> 229 229 230 230 <div id="signup-avatar"> 231 231 <?php bp_signup_avatar() ?> 232 232 </div> 233 233 234 234 <p> 235 <input type="file" name="file" id="file" /> 235 <input type="file" name="file" id="file" /> 236 236 <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" /> 237 237 <input type="hidden" name="action" id="action" value="bp_avatar_upload" /> … … 241 241 242 242 <?php wp_nonce_field( 'bp_avatar_upload' ) ?> 243 243 244 244 <?php endif; ?> 245 245 246 246 <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?> 247 247 248 248 <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3> 249 249 250 250 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" /> 251 251 252 252 <div id="avatar-crop-pane"> 253 253 <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" /> … … 255 255 256 256 <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" /> 257 257 258 258 <input type="hidden" name="signup_email" id="signup_email" value="<?php bp_signup_email_value() ?>" /> 259 259 <input type="hidden" name="signup_username" id="signup_username" value="<?php bp_signup_username_value() ?>" /> 260 260 <input type="hidden" name="signup_avatar_dir" id="signup_avatar_dir" value="<?php bp_signup_avatar_dir_value() ?>" /> 261 261 262 262 <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" /> 263 263 <input type="hidden" id="x" name="x" /> … … 267 267 268 268 <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?> 269 269 270 270 <?php endif; ?> 271 271 272 272 <?php else : ?> 273 273 274 274 <p><?php _e( "We've fetched an avatar for your new account. If you'd like to change this you can use the <a href=\"http://gravatar.com\">Gravatar</a> service to upload a new one.", 'buddypress' ) ?></p> 275 275 276 276 <?php endif; ?> 277 277 278 278 <?php endif; // completed-confirmation signup step ?> 279 279 280 280 <?php do_action( 'bp_custom_signup_steps' ) ?> 281 281 282 282 </form> 283 283 284 284 </div> 285 285 286 286 <?php do_action( 'bp_after_register_page' ) ?> 287 287 288 288 </div> 289 289 290 290 <?php get_sidebar(); ?> 291 291 -
trunk/bp-themes/bp-sn-parent/search.php
r1952 r2077 4 4 5 5 <?php do_action( 'bp_before_blog_search' ) ?> 6 6 7 7 <div class="page" id="blog-search"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2> 10 10 11 11 <?php if (have_posts()) : ?> 12 12 13 13 <h3 class="pagetitle"><?php _e( 'Search Results', 'buddypress' ) ?></h3> 14 14 … … 23 23 24 24 <div class="post"> 25 25 26 26 <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3> 27 27 <small><?php the_time('l, F jS, Y') ?></small> 28 28 29 29 <p class="postmetadata"><?php _e( 'Posted in', 'buddypress' ) ?> <?php the_category(', ') ?> | <?php edit_post_link( __( 'Edit', 'buddypress' ), '', ' | '); ?> <?php comments_popup_link( __( 'No Comments »', 'buddypress' ), __( '1 Comment »', 'buddypress' ), __( '% Comments »', 'buddypress' ) ); ?></p> 30 30 31 31 <?php do_action( 'bp_blog_post' ) ?> 32 32 … … 50 50 51 51 </div> 52 52 53 53 <?php do_action( 'bp_after_blog_search' ) ?> 54 54 55 55 </div> 56 56 -
trunk/bp-themes/bp-sn-parent/sidebar.php
r1905 r2077 3 3 <div id="sidebar"> 4 4 <?php do_action( 'bp_inside_before_blog_sidebar' ) ?> 5 5 6 6 <?php if ( !function_exists('dynamic_sidebar') 7 7 || !dynamic_sidebar('blog-sidebar') ) : ?> 8 8 9 9 <div class="widget-error"> 10 10 <?php _e( 'Please log in and add widgets to this column.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&show=&sidebar=blog-sidebar"><?php _e( 'Add Widgets', 'buddypress' ) ?></a> … … 12 12 13 13 <?php endif; ?> 14 14 15 15 <?php do_action( 'bp_inside_after_blog_sidebar' ) ?> 16 16 </div> -
trunk/bp-themes/bp-sn-parent/single.php
r1905 r2077 4 4 5 5 <?php do_action( 'bp_before_blog_single_post' ) ?> 6 6 7 7 <div class="page" id="blog-single"> 8 8 9 9 <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2> 10 10 11 11 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 12 12 13 13 <div class="item-options"> 14 14 15 15 <div class="alignleft"><?php next_posts_link( __( '« Previous Entries', 'buddypress' ) ) ?></div> 16 16 <div class="alignright"><?php previous_posts_link( __( 'Next Entries »', 'buddypress' ) ) ?></div> 17 17 18 18 </div> 19 19 … … 21 21 22 22 <?php do_action( 'bp_before_blog_post' ) ?> 23 23 24 24 <h3><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3> 25 25 26 26 <div class="entry"> 27 27 28 28 <?php the_content( __( '<p class="serif">Read the rest of this entry »</p>', 'buddypress' ) ); ?> 29 29 … … 43 43 44 44 <?php endif; ?> 45 45 46 46 </div> 47 47 -
trunk/bp-themes/bp-sn-parent/status/post-form.php
r1905 r2077 6 6 <label for="status-update-input"><?php _e( 'What are you up to?', 'buddypress' ) ?></label> 7 7 <textarea id="status-update-input" name="status-update-input" tabindex="99"></textarea> 8 8 9 9 <?php do_action( 'bp_after_status_update_input' ) ?> 10 10 11 11 <div id="status-update-buttons"> 12 12 <input type="submit" name="status-update-post" id="status-update-post" tabindex="100" value="<?php _e( 'Update', 'buddypress' ) ?>" /> 13 13 14 14 <?php do_action( 'bp_status_update_buttons' ) ?> 15 15 </div> 16 16 17 17 <?php wp_nonce_field( 'bp_status_add_status', '_wpnonce_add_status' ) ?> 18 18 </form> -
trunk/bp-themes/bp-sn-parent/style.css
r2042 r2077 1 /* 1 /* 2 2 Theme Name: BuddyPress Social Network Parent Theme 3 3 Theme URI: http://buddypress.org/extend/themes/ -
trunk/bp-themes/bp-sn-parent/userbar.php
r1996 r2077 5 5 6 6 <?php do_action( 'bp_inside_before_user_bar' ) ?> 7 7 8 8 <?php if ( is_user_logged_in() ) : ?> 9 9 10 10 <p class="avatar"> 11 11 <?php bp_loggedin_user_avatar( 'type=thumb' ) ?> 12 12 </p> 13 13 14 14 <ul id="bp-nav"> 15 15 <?php bp_get_loggedin_user_nav() ?> 16 16 </ul> 17 17 18 18 <?php else : ?> 19 19 20 20 <p class="avatar"> 21 21 <img src="<?php echo get_template_directory_uri() . '/_inc/images/mystery-man.jpg' ?>" alt="No User" width="50" height="50" /> 22 22 </p> 23 23 24 24 <p id="login-text"><?php _e( 'You must log in to access your account.', 'buddypress' ) ?></p> 25 25 26 26 <form name="userbar_loginform" id="userbar_loginform" action="<?php echo site_url( 'wp-login.php', 'login' ) ?>" method="post"> 27 27 <p> … … 40 40 </p> 41 41 </form> 42 42 43 43 <?php endif ?> 44 44 45 45 <?php do_action( 'bp_inside_after_user_bar' ) ?> 46 46 -
trunk/bp-wire/bp-wire-classes.php
r1905 r2077 3 3 class BP_Wire_Post { 4 4 var $table_name; 5 5 6 6 var $id; 7 7 var $item_id; … … 9 9 var $content; 10 10 var $date_posted; 11 11 12 12 function bp_wire_post( $table_name, $id = null, $populate = true ) { 13 13 $this->table_name = $table_name; 14 14 15 15 if ( $id ) { 16 16 $this->id = $id; 17 17 18 18 if ( $populate ) 19 19 $this->populate(); 20 20 } 21 21 } 22 22 23 23 function populate() { 24 24 global $wpdb, $bp; … … 35 35 } 36 36 } 37 37 38 38 function save() { 39 39 global $wpdb, $bp; 40 41 $this->item_id = apply_filters( 'bp_wire_post_item_id_before_save', $this->item_id, $this->id ); 42 $this->user_id = apply_filters( 'bp_wire_post_user_id_before_save', $this->user_id, $this->id ); 43 $this->content = apply_filters( 'bp_wire_post_content_before_save', $this->content, $this->id ); 40 41 $this->item_id = apply_filters( 'bp_wire_post_item_id_before_save', $this->item_id, $this->id ); 42 $this->user_id = apply_filters( 'bp_wire_post_user_id_before_save', $this->user_id, $this->id ); 43 $this->content = apply_filters( 'bp_wire_post_content_before_save', $this->content, $this->id ); 44 44 $this->date_posted = apply_filters( 'bp_wire_post_date_posted_before_save', $this->date_posted, $this->id ); 45 45 46 do_action( 'bp_wire_post_before_save', $this ); 47 46 do_action( 'bp_wire_post_before_save', $this ); 47 48 48 if ( $this->id ) { 49 $sql = $wpdb->prepare( 50 "UPDATE {$this->table_name} SET 51 item_id = %d, 52 user_id = %d, 53 content = %s, 49 $sql = $wpdb->prepare( 50 "UPDATE {$this->table_name} SET 51 item_id = %d, 52 user_id = %d, 53 content = %s, 54 54 date_posted = FROM_UNIXTIME(%d) 55 55 WHERE 56 56 id = %d 57 57 ", 58 $this->item_id, 59 $this->user_id, 60 $this->content, 61 $this->date_posted, 58 $this->item_id, 59 $this->user_id, 60 $this->content, 61 $this->date_posted, 62 62 $this->id 63 63 ); 64 64 } else { 65 $sql = $wpdb->prepare( 66 "INSERT INTO {$this->table_name} ( 65 $sql = $wpdb->prepare( 66 "INSERT INTO {$this->table_name} ( 67 67 item_id, 68 68 user_id, … … 72 72 %d, %d, %s, FROM_UNIXTIME(%d) 73 73 )", 74 $this->item_id, 75 $this->user_id, 76 $this->content, 77 $this->date_posted, 78 $this->id 74 $this->item_id, 75 $this->user_id, 76 $this->content, 77 $this->date_posted, 78 $this->id 79 79 ); 80 80 } 81 81 82 82 $result = $wpdb->query($sql); 83 83 84 84 if ( !$this->id ) 85 85 $this->id = $wpdb->insert_id; 86 86 87 do_action( 'bp_wire_post_after_save', $this ); 88 87 do_action( 'bp_wire_post_after_save', $this ); 88 89 89 return $result; 90 90 } 91 91 92 92 function delete() { 93 93 global $wpdb, $bp; 94 94 95 95 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$this->table_name} WHERE id = %d", $this->id ) ); 96 96 } 97 97 98 98 /* Static Functions */ 99 99 100 100 function get_all_for_item( $item_id, $table_name, $page = false, $limit = false ) { 101 101 global $wpdb, $bp; 102 102 103 103 if ( $limit && $page ) 104 104 $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ); 105 105 106 106 $wire_posts = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE item_id = %d ORDER BY date_posted DESC $pag_sql", $item_id ) ); 107 107 $count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$table_name} WHERE item_id = %d", $item_id ) ); 108 108 109 109 return array( 'wire_posts' => $wire_posts, 'count' => $count ); 110 110 } 111 111 112 112 function delete_all_for_item( $item_id, $table_name ) { 113 113 global $wpdb, $bp; 114 114 115 115 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE item_id = %d", $item_id ) ); 116 116 } -
trunk/bp-wire/bp-wire-filters.php
r1925 r2077 17 17 function bp_wire_filter_kses( $content ) { 18 18 global $allowedtags; 19 19 20 20 $wire_allowedtags = $allowedtags; 21 $wire_allowedtags['img'] = array(); 21 $wire_allowedtags['img'] = array(); 22 22 $wire_allowedtags['img']['src'] = array(); 23 23 $wire_allowedtags['img']['alt'] = array(); -
trunk/bp-wire/bp-wire-templatetags.php
r1910 r2077 6 6 var $wire_posts; 7 7 var $wire_post; 8 8 9 9 var $in_the_loop; 10 10 11 11 var $pag_page; 12 12 var $pag_num; 13 13 var $pag_links; 14 14 var $total_wire_post_count; 15 15 16 16 var $can_post; 17 17 18 18 var $table_name; 19 19 20 20 function bp_wire_posts_template( $item_id, $component_slug, $can_post, $per_page, $max ) { 21 21 global $bp; … … 25 25 } else 26 26 $this->table_name = $bp->{$bp->active_components[$component_slug]}->table_name_wire; 27 27 28 28 $this->pag_page = isset( $_REQUEST['wpage'] ) ? intval( $_REQUEST['wpage'] ) : 1; 29 29 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; … … 31 31 $this->wire_posts = BP_Wire_Post::get_all_for_item( $item_id, $this->table_name, $this->pag_page, $this->pag_num ); 32 32 $this->total_wire_post_count = (int)$this->wire_posts['count']; 33 33 34 34 $this->wire_posts = $this->wire_posts['wire_posts']; 35 35 $this->wire_post_count = count($this->wire_posts); 36 36 37 37 if ( is_site_admin() || ( (int)get_site_option('non-friend-wire-posting') && ( $bp->current_component == $bp->profile->slug || $bp->current_component == $bp->wire->slug ) ) ) 38 38 $this->can_post = 1; 39 39 else 40 40 $this->can_post = $can_post; 41 41 42 42 $this->pag_links = paginate_links( array( 43 43 'base' => add_query_arg( 'wpage', '%#%', $bp->displayed_user->domain ), … … 49 49 'mid_size' => 1 50 50 )); 51 52 } 53 51 52 } 53 54 54 function has_wire_posts() { 55 55 if ( $this->wire_post_count ) 56 56 return true; 57 57 58 58 return false; 59 59 } 60 60 61 61 function next_wire_post() { 62 62 $this->current_wire_post++; 63 63 $this->wire_post = $this->wire_posts[$this->current_wire_post]; 64 64 65 65 return $this->wire_post; 66 66 } 67 67 68 68 function rewind_wire_posts() { 69 69 $this->current_wire_post = -1; … … 72 72 } 73 73 } 74 75 function user_wire_posts() { 74 75 function user_wire_posts() { 76 76 if ( $this->current_wire_post + 1 < $this->wire_post_count ) { 77 77 return true; … … 85 85 return false; 86 86 } 87 87 88 88 function the_wire_post() { 89 89 global $wire_post; … … 99 99 function bp_has_wire_posts( $args = '' ) { 100 100 global $wire_posts_template, $bp; 101 101 102 102 $defaults = array( 103 103 'item_id' => false, … … 110 110 $r = wp_parse_args( $args, $defaults ); 111 111 extract( $r, EXTR_SKIP ); 112 112 113 113 if ( !$item_id ) 114 114 return false; 115 116 $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max ); 115 116 $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max ); 117 117 return apply_filters( 'bp_has_wire_posts', $wire_posts_template->has_wire_posts(), &$wire_posts_template ); 118 118 } … … 133 133 if ( !$item_id ) 134 134 return false; 135 135 136 136 if ( !$empty_message ) 137 137 $empty_message = __("There are currently no wire posts.", 'buddypress'); 138 138 139 139 if ( !$title ) 140 140 $title = __('Wire', 'buddypress'); … … 146 146 $bp_wire_can_post = $can_post; 147 147 $bp_wire_show_email_notify = $show_email_notify; 148 148 149 149 locate_template( array( '/wire/post-list.php' ), true ); 150 150 } … … 157 157 return apply_filters( 'bp_get_wire_title', $bp_wire_header ); 158 158 } 159 159 160 160 function bp_wire_item_id( $deprecated = false ) { 161 161 global $bp_item_id; 162 162 163 163 if ( $deprecated ) 164 164 echo bp_get_wire_item_id(); … … 179 179 return apply_filters( 'bp_get_wire_no_posts_message', $bp_wire_msg ); 180 180 } 181 181 182 182 function bp_wire_can_post() { 183 183 global $bp_wire_can_post; … … 192 192 function bp_wire_post_id( $deprecated = true ) { 193 193 global $wire_posts_template; 194 194 195 195 if ( !$deprecated ) 196 196 return bp_get_wire_post_id(); … … 218 218 if ( $wire_posts_template->total_wire_post_count > $wire_posts_template->pag_num ) 219 219 return true; 220 220 221 221 return false; 222 222 } … … 230 230 return apply_filters( 'bp_get_wire_pagination', $wire_posts_template->pag_links ); 231 231 } 232 232 233 233 function bp_wire_pagination_count() { 234 234 echo bp_get_wire_pagination_count(); … … 238 238 239 239 $from_num = intval( ( $wire_posts_template->pag_page - 1 ) * $wire_posts_template->pag_num ) + 1; 240 $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1); 241 242 return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 243 } 244 240 $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1); 241 242 return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 243 } 244 245 245 function bp_wire_ajax_loader_src() { 246 246 echo bp_get_wire_ajax_loader_src(); … … 262 262 function bp_get_wire_post_date() { 263 263 global $wire_posts_template; 264 264 265 265 return apply_filters( 'bp_get_wire_post_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format'), $wire_posts_template->wire_post->date_posted ) ); 266 266 } … … 268 268 function bp_wire_post_author_name( $deprecated = true ) { 269 269 global $wire_posts_template; 270 270 271 271 if ( !$deprecated ) 272 272 return bp_get_wire_post_author_name(); … … 291 291 function bp_wire_get_post_form() { 292 292 global $wire_posts_template; 293 293 294 294 if ( is_user_logged_in() && $wire_posts_template->can_post ) 295 locate_template( array( '/wire/post-form.php' ), true ); 295 locate_template( array( '/wire/post-form.php' ), true ); 296 296 } 297 297 … … 339 339 return bp_get_wire_poster_date(); 340 340 else 341 echo bp_get_wire_poster_date(); 341 echo bp_get_wire_poster_date(); 342 342 } 343 343 function bp_get_wire_poster_date() { 344 return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) ); 344 return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) ); 345 345 } 346 346 -
trunk/bp-wire/deprecated/bp-wire-deprecated.php
r1905 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 27 27 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 28 28 return $template; 29 29 30 30 /* Enqueue the structure CSS file to give basic positional formatting for components */ 31 wp_enqueue_style( 'bp-wire-structure', BP_PLUGIN_URL . '/bp-wire/deprecated/css/structure.css' ); 31 wp_enqueue_style( 'bp-wire-structure', BP_PLUGIN_URL . '/bp-wire/deprecated/css/structure.css' ); 32 32 } 33 33 add_action( 'bp_styles', 'bp_wire_add_structure_css' ); … … 46 46 <span class="ajax-loader"></span> 47 47 </div> 48 48 49 49 <div id="wire-pagination" class="pagination-links"> 50 50 <?php bp_wire_pagination() ?> 51 51 </div> 52 52 53 53 <ul id="wire-post-list"> 54 54 <?php $counter = 0; ?> … … 57 57 <div class="wire-post-metadata"> 58 58 <?php bp_wire_post_author_avatar() ?> 59 <?php _e( 'On', 'buddypress' ) ?> <?php bp_wire_post_date() ?> 59 <?php _e( 'On', 'buddypress' ) ?> <?php bp_wire_post_date() ?> 60 60 <?php bp_wire_post_author_name() ?> <?php _e( 'said:', 'buddypress' ) ?> 61 61 <?php bp_wire_delete_link() ?> 62 62 </div> 63 63 64 64 <div class="wire-post-content"> 65 65 <?php bp_wire_post_content() ?> … … 69 69 <?php endwhile; ?> 70 70 </ul> 71 71 72 72 <?php else: ?> 73 73 … … 77 77 78 78 <?php endif; ?> 79 79 80 80 <input type="hidden" name="bp_wire_item_id" id="bp_wire_item_id" value="<?php echo attribute_escape( $_POST['bp_wire_item_id'] ) ?>" /> 81 81 <?php -
trunk/bp-xprofile.php
r2059 r2077 15 15 /* Include deprecated functions if settings allow */ 16 16 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 17 require ( BP_PLUGIN_DIR . '/bp-xprofile/deprecated/bp-xprofile-deprecated.php' ); 17 require ( BP_PLUGIN_DIR . '/bp-xprofile/deprecated/bp-xprofile-deprecated.php' ); 18 18 19 19 /* Assign the base group and fullname field names to constants to use in SQL statements */ … … 25 25 * 26 26 * Set up the database tables needed for the xprofile component. 27 * 27 * 28 28 * @package BuddyPress XProfile 29 29 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 36 36 if ( !empty($wpdb->charset) ) 37 37 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 38 38 39 39 if ( '' == get_site_option( 'bp-xprofile-base-group-name' ) ) 40 40 update_site_option( 'bp-xprofile-base-group-name', 'Base' ); 41 41 42 42 if ( '' == get_site_option( 'bp-xprofile-fullname-field-name' ) ) 43 update_site_option( 'bp-xprofile-fullname-field-name', 'Name' ); 44 43 update_site_option( 'bp-xprofile-fullname-field-name', 'Name' ); 44 45 45 $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} ( 46 46 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 50 50 KEY can_delete (can_delete) 51 51 ) {$charset_collate};"; 52 52 53 53 $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} ( 54 54 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 70 70 KEY is_required (is_required) 71 71 ) {$charset_collate};"; 72 72 73 73 $sql[] = "CREATE TABLE {$bp->profile->table_name_data} ( 74 74 id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, … … 80 80 KEY user_id (user_id) 81 81 ) {$charset_collate};"; 82 82 83 83 if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) { 84 84 $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );"; 85 86 $sql[] = "INSERT INTO {$bp->profile->table_name_fields} ( 85 86 $sql[] = "INSERT INTO {$bp->profile->table_name_fields} ( 87 87 id, group_id, parent_id, type, name, is_required, can_delete 88 88 ) VALUES ( … … 90 90 );"; 91 91 } 92 92 93 93 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 94 94 dbDelta($sql); 95 95 96 96 if ( function_exists('bp_wire_install') ) 97 97 xprofile_wire_install(); 98 98 99 99 update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION ); 100 100 } … … 124 124 * 125 125 * Add the profile globals to the $bp global for use across the installation 126 * 126 * 127 127 * @package BuddyPress XProfile 128 128 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 132 132 function xprofile_setup_globals() { 133 133 global $bp, $wpdb; 134 134 135 135 /* For internal identification */ 136 136 $bp->profile->id = 'profile'; 137 137 138 138 $bp->profile->table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups'; 139 139 $bp->profile->table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields'; … … 145 145 /* Register this in the active components array */ 146 146 $bp->active_components[$bp->profile->slug] = $bp->profile->id; 147 147 148 148 /* Set the support field type ids */ 149 149 $bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) ); … … 151 151 if ( function_exists( 'bp_wire_install' ) ) 152 152 $bp->profile->table_name_wire = $wpdb->base_prefix . 'bp_xprofile_wire'; 153 153 154 154 do_action( 'xprofile_setup_globals' ); 155 155 } … … 162 162 * Creates the administration interface menus and checks to see if the DB 163 163 * tables are set up. 164 * 164 * 165 165 * @package BuddyPress XProfile 166 166 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 171 171 * @uses add_submenu_page() Adds a submenu tab to a top level tab in the admin area 172 172 * @uses xprofile_install() Runs the DB table installation function 173 * @return 173 * @return 174 174 */ 175 175 function xprofile_add_admin_menu() { 176 176 global $wpdb, $bp; 177 177 178 178 if ( !is_site_admin() ) 179 179 return false; 180 180 181 181 /* Add the administration tab under the "Site Admin" tab for site administrators */ 182 182 add_submenu_page( 'bp-general-settings', __("Profile Field Setup", 'buddypress'), __("Profile Field Setup", 'buddypress'), 'manage-options', 'bp-profile-setup', "xprofile_admin" ); … … 192 192 * 193 193 * Sets up the navigation items for the xprofile component 194 * 194 * 195 195 * @package BuddyPress XProfile 196 196 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 203 203 function xprofile_setup_nav() { 204 204 global $bp; 205 205 206 206 /* Add 'Profile' to the main navigation */ 207 207 bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress' ), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) ); 208 208 209 209 $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/'; 210 210 211 211 /* Add the subnav items to the profile */ 212 212 bp_core_new_subnav_item( array( 'name' => __( 'Public', 'buddypress' ), 'slug' => 'public', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_display_profile', 'position' => 10 ) ); … … 219 219 } else { 220 220 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 221 $bp->bp_options_title = $bp->displayed_user->fullname; 221 $bp->bp_options_title = $bp->displayed_user->fullname; 222 222 } 223 223 } 224 224 225 225 do_action( 'xprofile_setup_nav' ); 226 226 } … … 233 233 * 234 234 * Adds an admin bar menu to any profile page providing site admin options for that user. 235 * 235 * 236 236 * @package BuddyPress XProfile 237 237 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 239 239 function xprofile_setup_adminbar_menu() { 240 240 global $bp; 241 241 242 242 if ( !$bp->displayed_user->id ) 243 243 return false; 244 244 245 245 /* Don't show this menu to non site admins or if you're viewing your own profile */ 246 246 if ( !is_site_admin() || bp_is_home() ) … … 249 249 <li id="bp-adminbar-adminoptions-menu"> 250 250 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a> 251 251 252 252 <ul> 253 253 <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> 254 254 <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> 255 255 256 256 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?> 257 257 <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> … … 259 259 <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> 260 260 <?php endif; ?> 261 261 262 262 <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> 263 263 264 264 <?php do_action( 'xprofile_adminbar_menu_items' ) ?> 265 265 </ul> … … 281 281 * 282 282 * Handles the display of the profile page by loading the correct template file. 283 * 283 * 284 284 * @package BuddyPress Xprofile 285 285 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename) … … 292 292 if ( isset($_GET['new']) ) 293 293 bp_core_delete_notifications_for_user_by_item_id( $bp->loggedin_user->id, $bp->displayed_user->id, 'friends', 'friendship_accepted' ); 294 294 295 295 do_action( 'xprofile_screen_display_profile', $_GET['new'] ); 296 296 bp_core_load_template( apply_filters( 'xprofile_template_display_profile', 'profile/index' ) ); … … 302 302 * Handles the display of the profile edit page by loading the correct template file. 303 303 * Also checks to make sure this can only be accessed for the logged in users profile. 304 * 304 * 305 305 * @package BuddyPress Xprofile 306 306 * @uses bp_is_home() Checks to make sure the current user being viewed equals the logged in user … … 309 309 function xprofile_screen_edit_profile() { 310 310 global $bp; 311 311 312 312 if ( !bp_is_home() && !is_site_admin() ) 313 313 return false; 314 314 315 315 /* Check to see if any new information has been submitted */ 316 316 if ( isset($_POST['field_ids']) ) { 317 317 318 318 /* Check the nonce */ 319 319 check_admin_referer( 'bp_xprofile_edit' ); 320 320 321 321 /* Check we have field ID's */ 322 322 if ( empty( $_POST['field_ids'] ) ) 323 323 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' ); 324 324 325 325 /* Explode the posted field IDs into an array so we know which fields have been submitted */ 326 326 $posted_field_ids = explode( ',', $_POST['field_ids'] ); 327 327 328 328 /* Loop through the posted fields formatting any datebox values then validate the field */ 329 foreach ( $posted_field_ids as $field_id ) { 330 329 foreach ( $posted_field_ids as $field_id ) { 331 330 if ( !isset( $_POST['field_' . $field_id] ) ) { 332 331 333 332 if ( is_numeric( $_POST['field_' . $field_id . '_day'] ) ) { 334 333 /* Concatenate the values. */ 335 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . 334 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . 336 335 $_POST['field_' . $field_id . '_month'] . ' ' . 337 336 $_POST['field_' . $field_id . '_year']; … … 348 347 349 348 if ( $errors ) 350 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 351 else { 349 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 350 else { 352 351 /* Reset the errors var */ 353 352 $errors = false; 354 353 355 354 /* Now we've checked for required fields, lets save the values. */ 356 foreach ( $posted_field_ids as $field_id ) { 355 foreach ( $posted_field_ids as $field_id ) { 357 356 if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id] ) ) 358 357 $errors = true; … … 360 359 do_action( 'xprofile_profile_field_data_updated', $field_id, $_POST['field_' . $field_id] ); 361 360 } 362 361 363 362 do_action( 'xprofile_updated_profile', $posted_field_ids, $errors ); 364 363 365 364 /* Set the feedback messages */ 366 365 if ( $errors ) 367 366 bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' ); 368 else 367 else 369 368 bp_core_add_message( __( 'Changes saved.', 'buddypress' ) ); 370 369 … … 375 374 376 375 do_action( 'xprofile_screen_edit_profile' ); 377 bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) ); 376 bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) ); 378 377 } 379 378 … … 382 381 * 383 382 * Handles the uploading and cropping of a user avatar. Displays the change avatar page. 384 * 383 * 385 384 * @package BuddyPress Xprofile 386 385 * @uses bp_is_home() Checks to make sure the current user being viewed equals the logged in user … … 389 388 function xprofile_screen_change_avatar() { 390 389 global $bp; 391 390 392 391 if ( !bp_is_home() && !is_site_admin() ) 393 392 return false; 394 393 395 394 $bp->avatar_admin->step = 'upload-image'; 396 395 397 396 if ( !empty( $_FILES ) ) { 398 397 399 398 /* Check the nonce */ 400 399 check_admin_referer( 'bp_avatar_upload' ); 401 400 402 /* Pass the file to the avatar upload handler */ 403 if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) { 401 /* Pass the file to the avatar upload handler */ 402 if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) { 404 403 $bp->avatar_admin->step = 'crop-image'; 405 404 … … 408 407 } 409 408 } 410 409 411 410 /* If the image cropping is done, crop the image and save a full/thumb version */ 412 411 if ( isset( $_POST['avatar-crop-submit'] ) ) { 413 412 414 413 /* Check the nonce */ 415 414 check_admin_referer( 'bp_avatar_cropstore' ); … … 424 423 425 424 do_action( 'xprofile_screen_change_avatar' ); 426 425 427 426 bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'profile/change-avatar' ) ); 428 427 } … … 434 433 * Settings are hooked into the function: bp_core_screen_notification_settings_content() 435 434 * in bp-core/bp-core-settings.php 436 * 435 * 437 436 * @package BuddyPress Xprofile 438 437 * @global $current_user WordPress global variable containing current logged in user information 439 438 */ 440 function xprofile_screen_notification_settings() { 439 function xprofile_screen_notification_settings() { 441 440 global $current_user; ?> 442 441 <?php if ( function_exists('bp_wire_install') ) { ?> … … 455 454 <td class="no"><input type="radio" name="notifications[notification_profile_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_profile_wire_post' ) ) { ?>checked="checked" <?php } ?>/></td> 456 455 </tr> 457 456 458 457 <?php do_action( 'xprofile_screen_notification_settings' ) ?> 459 458 </table> 460 459 <?php } ?> 461 <?php 460 <?php 462 461 } 463 462 add_action( 'bp_notification_settings', 'xprofile_screen_notification_settings', 1 ); … … 479 478 * 480 479 * The function will delete the active avatar for a user. 481 * 480 * 482 481 * @package BuddyPress Xprofile 483 482 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 491 490 if ( $bp->profile->slug != $bp->current_component || 'change-avatar' != $bp->current_action || 'delete-avatar' != $bp->action_variables[0] ) 492 491 return false; 493 492 494 493 /* Check the nonce */ 495 494 check_admin_referer( 'bp_delete_avatar_link' ); 496 495 497 496 if ( !bp_is_home() && !is_site_admin() ) 498 497 return false; 499 498 500 499 if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->displayed_user->id ) ) ) 501 500 bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) ); … … 503 502 bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' ); 504 503 505 bp_core_redirect( wp_get_referer() ); 504 bp_core_redirect( wp_get_referer() ); 506 505 } 507 506 add_action( 'wp', 'xprofile_action_delete_avatar', 3 ); … … 510 509 * xprofile_action_new_wire_post() 511 510 * 512 * Posts a new wire post to the users profile wire. 513 * 511 * Posts a new wire post to the users profile wire. 512 * 514 513 * @package BuddyPress XProfile 515 514 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 523 522 if ( $bp->current_component != $bp->wire->slug ) 524 523 return false; 525 524 526 525 if ( 'post' != $bp->current_action ) 527 526 return false; 528 527 529 528 /* Check the nonce */ 530 if ( !check_admin_referer( 'bp_wire_post' ) ) 531 return false; 532 529 if ( !check_admin_referer( 'bp_wire_post' ) ) 530 return false; 531 533 532 if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->slug, false, $bp->profile->table_name_wire ) ) { 534 533 bp_core_add_message( __( 'Wire message could not be posted. Please try again.', 'buddypress' ), 'error' ); 535 534 } else { 536 535 bp_core_add_message( __( 'Wire message successfully posted.', 'buddypress' ) ); 537 536 538 537 /* Record the notification for the reciever if it's not on their own wire */ 539 538 if ( !bp_is_home() ) 540 bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' ); 541 539 bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' ); 540 542 541 /* Record this on the poster's activity screen */ 543 542 if ( ( $wire_post->item_id == $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id == $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) { 544 543 $from_user_link = bp_core_get_userlink($wire_post->user_id); 545 $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>'; 546 $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true ); 544 $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>'; 545 $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true ); 547 546 } else if ( ( $wire_post->item_id != $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id != $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) { 548 547 $from_user_link = bp_core_get_userlink($wire_post->user_id); 549 548 $to_user_link = bp_core_get_userlink( $wire_post->item_id, false, false, true, true ); 550 $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>'; 549 $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>'; 551 550 $primary_link = bp_core_get_userlink( $wire_post->item_id, false, true ); 552 } 553 551 } 552 554 553 $content .= '<blockquote>' . bp_create_excerpt($wire_post->content) . '</blockquote>'; 555 554 … … 563 562 ) ); 564 563 565 do_action( 'xprofile_new_wire_post', &$wire_post ); 564 do_action( 'xprofile_new_wire_post', &$wire_post ); 566 565 } 567 566 … … 577 576 * xprofile_action_delete_wire_post() 578 577 * 579 * Deletes a wire post from the users profile wire. 580 * 578 * Deletes a wire post from the users profile wire. 579 * 581 580 * @package BuddyPress XProfile 582 581 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 588 587 function xprofile_action_delete_wire_post() { 589 588 global $bp; 590 589 591 590 if ( $bp->current_component != $bp->wire->slug ) 592 591 return false; 593 592 594 593 if ( $bp->current_action != 'delete' ) 595 594 return false; 596 595 597 596 if ( !check_admin_referer( 'bp_wire_delete_link' ) ) 598 597 return false; 599 598 600 599 $wire_post_id = $bp->action_variables[0]; 601 600 … … 605 604 /* Delete the post from activity streams */ 606 605 xprofile_delete_activity( array( 'item_id' => $wire_post_id, 'component_action' => 'new_wire_post' ) ); 607 608 do_action( 'xprofile_delete_wire_post', $wire_post_id ); 606 607 do_action( 'xprofile_delete_wire_post', $wire_post_id ); 609 608 } else { 610 609 bp_core_add_message( __('Wire post could not be deleted, please try again.', 'buddypress'), 'error' ); 611 610 } 612 611 613 612 if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) { 614 613 bp_core_redirect( $bp->displayed_user->domain ); … … 629 628 function xprofile_register_activity_actions() { 630 629 global $bp; 631 630 632 631 if ( !function_exists( 'bp_activity_set_action' ) ) 633 632 return false; … … 647 646 * Records activity for the logged in user within the profile component so that 648 647 * it will show in the users activity stream (if installed) 649 * 648 * 650 649 * @package BuddyPress XProfile 651 650 * @param $args Array containing all variables used after extract() call … … 655 654 function xprofile_record_activity( $args = true ) { 656 655 global $bp; 657 656 658 657 if ( !function_exists( 'bp_activity_add' ) ) 659 658 return false; … … 672 671 673 672 $r = wp_parse_args( $args, $defaults ); 674 extract( $r, EXTR_SKIP ); 675 673 extract( $r, EXTR_SKIP ); 674 676 675 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 677 676 } … … 682 681 * Deletes activity for a user within the profile component so that 683 682 * it will be removed from the users activity stream and sitewide stream (if installed) 684 * 683 * 685 684 * @package BuddyPress XProfile 686 685 * @param $args Array containing all variables used after extract() call … … 690 689 function xprofile_delete_activity( $args = '' ) { 691 690 global $bp; 692 691 693 692 if ( function_exists('bp_activity_delete_by_item_id') ) { 694 693 extract($args); … … 699 698 function xprofile_register_activity_action( $key, $value ) { 700 699 global $bp; 701 700 702 701 if ( !function_exists( 'bp_activity_set_action' ) ) 703 702 return false; 704 703 705 704 return apply_filters( 'xprofile_register_activity_action', bp_activity_set_action( $bp->profile->id, $key, $value ), $key, $value ); 706 705 } … … 710 709 * 711 710 * Format notifications into something that can be read and displayed 712 * 711 * 713 712 * @package BuddyPress Xprofile 714 713 * @param $item_id The ID of the specific item for which the activity is recorded (could be a wire post id, user id etc) … … 724 723 if ( 'new_wire_post' == $action ) { 725 724 if ( (int)$total_items > 1 ) { 726 return apply_filters( 'bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( 'You have %d new posts on your wire', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 725 return apply_filters( 'bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( 'You have %d new posts on your wire', 'buddypress' ), (int)$total_items ) . '</a>', $total_items ); 727 726 } else { 728 727 $user_fullname = bp_core_get_user_displayname( $item_id ); … … 730 729 } 731 730 } 732 731 733 732 do_action( 'xprofile_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 734 733 735 734 return false; 736 735 } … … 758 757 759 758 $r = wp_parse_args( $args, $defaults ); 760 extract( $r, EXTR_SKIP ); 759 extract( $r, EXTR_SKIP ); 761 760 762 761 if ( !$name ) 763 762 return false; 764 763 765 764 $field_group = new BP_XProfile_Group( $field_group_id ); 766 765 $field_group->name = $name; 767 766 $field_group->description = $description; 768 767 $field_group->can_delete = $can_delete; 769 768 770 769 return $field_group->save(); 771 770 } … … 785 784 function xprofile_insert_field( $args = '' ) { 786 785 global $bp; 787 786 788 787 extract( $args ); 789 788 790 789 /** 791 790 * Possible parameters (pass as assoc array): … … 803 802 * 'option_order' 804 803 */ 805 804 806 805 /* Check we have the minimum details */ 807 806 if ( !$field_group_id ) 808 807 return false; 809 808 810 809 /* Check this is a valid field type */ 811 810 if ( !in_array( $type, (array) $bp->profile->field_types ) ) 812 811 return false; 813 812 814 813 /* Instantiate a new field object */ 815 814 if ( $field_id ) … … 819 818 820 819 $field->group_id = $field_group_id; 821 820 822 821 if ( !empty( $parent_id ) ) 823 822 $field->parent_id = $parent_id; 824 823 825 824 if ( !empty( $type ) ) 826 825 $field->type = $type; 827 826 828 827 if ( !empty( $name ) ) 829 828 $field->name = $name; … … 831 830 if ( !empty( $description ) ) 832 831 $field->description = $description; 833 832 834 833 if ( !empty( $is_required ) ) 835 834 $field->is_required = $is_required; 836 835 837 836 if ( !empty( $can_delete ) ) 838 837 $field->can_delete = $can_delete; 839 838 840 839 if ( !empty( $field_order ) ) 841 840 $field->field_order = $field_order; 842 841 843 842 if ( !empty( $order_by ) ) 844 843 $field->order_by = $order_by; 845 844 846 845 if ( !empty( $is_default_option ) ) 847 846 $field->is_default_option = $is_default_option; 848 847 849 848 if ( !empty( $option_order ) ) 850 849 $field->option_order = $option_order; 851 850 852 851 if ( !$field->save() ) 853 852 return false; … … 872 871 * 873 872 * Fetches profile data for a specific field for the user. 874 * 873 * 875 874 * @package BuddyPress Core 876 875 * @param $field The ID of the field, or the $name of the field. … … 882 881 function xprofile_get_field_data( $field, $user_id = null ) { 883 882 global $bp; 884 883 885 884 if ( !$user_id ) 886 885 $user_id = $bp->displayed_user->id; 887 886 888 887 if ( !$user_id ) 889 888 return false; … … 904 903 * 905 904 * A simple function to set profile data for a specific field for a specific user. 906 * 905 * 907 906 * @package BuddyPress Core 908 907 * @param $field The ID of the field, or the $name of the field. … … 918 917 else 919 918 $field_id = xprofile_get_field_id_from_name( $field ); 920 919 921 920 if ( !$field_id ) 922 921 return false; 923 922 924 923 $field = new BP_XProfile_ProfileData(); 925 924 $field->field_id = $field_id; 926 925 $field->user_id = $user_id; 927 926 $field->value = maybe_serialize( $value ); 928 927 929 928 return $field->save(); 930 929 } … … 935 934 else 936 935 $field_id = xprofile_get_field_id_from_name( $field ); 937 936 938 937 if ( !$field_id ) 939 938 return false; 940 939 941 940 $field = new BP_XProfile_ProfileData( $field_id ); 942 941 return $field->delete(); … … 945 944 function xprofile_check_is_required_field( $field_id ) { 946 945 $field = new BP_Xprofile_Field( $field_id ); 947 946 948 947 if ( (int)$field->is_required ) 949 948 return true; 950 949 951 950 return false; 952 951 } … … 956 955 * 957 956 * Returns the ID for the field based on the field name. 958 * 957 * 959 958 * @package BuddyPress Core 960 959 * @param $field_name The name of the field to get the ID for. … … 969 968 * 970 969 * Fetches a random piece of profile data for the user. 971 * 970 * 972 971 * @package BuddyPress Core 973 972 * @param $user_id User ID of the user to get random data for … … 982 981 $field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname ); 983 982 $field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value ); 984 983 985 984 if ( !$field_data[0]->value || empty( $field_data[0]->value ) ) 986 985 return false; 987 986 988 987 return apply_filters( 'xprofile_get_random_profile_data', $field_data ); 989 988 } … … 993 992 * 994 993 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ] 995 * 994 * 996 995 * @package BuddyPress Core 997 996 * @param $field_type The type of field: datebox, selectbox, textbox etc … … 1003 1002 if ( !isset($field_value) || empty( $field_value ) ) 1004 1003 return false; 1005 1004 1006 1005 $field_value = bp_unserialize_profile_field( $field_value ); 1007 1006 1008 1007 if ( 'datebox' == $field_type ) { 1009 1008 $field_value = bp_format_time( $field_value, true ); … … 1013 1012 $field_value = str_replace(']]>', ']]>', $content); 1014 1013 } 1015 1014 1016 1015 return stripslashes( stripslashes( $field_value ) ); 1017 1016 } … … 1025 1024 * 1026 1025 * Setup the avatar upload directory for a user. 1027 * 1026 * 1028 1027 * @package BuddyPress Core 1029 1028 * @param $directory The root directory name … … 1036 1035 if ( !$user_id ) 1037 1036 $user_id = $bp->displayed_user->id; 1038 1037 1039 1038 if ( !$directory ) 1040 1039 $directory = 'avatars'; … … 1045 1044 1046 1045 $newbdir = $newdir; 1047 1046 1048 1047 if ( !file_exists( $newdir ) ) 1049 1048 @wp_mkdir_p( $newdir ); … … 1060 1059 * 1061 1060 * Syncs Xprofile data to the standard built in WordPress profile data. 1062 * 1061 * 1063 1062 * @package BuddyPress Core 1064 1063 */ 1065 1064 function xprofile_sync_wp_profile() { 1066 1065 global $bp, $wpdb; 1067 1066 1068 1067 if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) 1069 1068 return true; 1070 1069 1071 1070 $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id ); 1072 1071 $space = strpos( $fullname, ' ' ); 1073 1072 1074 1073 if ( false === $space ) { 1075 1074 $firstname = $fullname; … … 1077 1076 } else { 1078 1077 $firstname = substr( $fullname, 0, $space ); 1079 $lastname = trim( substr( $fullname, $space, strlen($fullname) ) ); 1080 } 1081 1078 $lastname = trim( substr( $fullname, $space, strlen($fullname) ) ); 1079 } 1080 1082 1081 update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname ); 1083 1082 update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname ); … … 1095 1094 * Removes notifications from the notification menu when a user clicks on them and 1096 1095 * is taken to a specific screen. 1097 * 1096 * 1098 1097 * @package BuddyPress Core 1099 1098 */ 1100 1099 function xprofile_remove_screen_notifications() { 1101 1100 global $bp; 1102 1101 1103 1102 bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_wire_post' ); 1104 1103 } … … 1111 1110 * profile data from each table. Also we need to clean anything up in the usermeta table 1112 1111 * that this component uses. 1113 * 1112 * 1114 1113 * @package BuddyPress XProfile 1115 1114 * @param $user_id The ID of the deleted user … … 1120 1119 function xprofile_remove_data( $user_id ) { 1121 1120 BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 1122 1121 1123 1122 // delete any avatar files. 1124 1123 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v1_path' ) ); 1125 1124 @unlink( get_usermeta( $user_id, 'bp_core_avatar_v2_path' ) ); 1126 1125 1127 1126 // unset the usermeta for avatars from the usermeta table. 1128 1127 delete_usermeta( $user_id, 'bp_core_avatar_v1' ); … … 1144 1143 1145 1144 function xprofile_clear_profile_data_object_cache( $group_id ) { 1146 global $bp; 1145 global $bp; 1147 1146 wp_cache_delete( 'xprofile_fields_' . $group_id . '_' . $bp->loggedin_user->id, 'bp' ); 1148 1147 wp_cache_delete( 'bp_user_fullname_' . $bp->loggedin_user->id, 'bp' ); -
trunk/bp-xprofile/bp-xprofile-admin.php
r2066 r2077 4 4 /************************************************************************** 5 5 xprofile_admin() 6 6 7 7 Handles all actions for the admin area for creating, editing and deleting 8 8 profile groups and fields. … … 31 31 xprofile_admin_manage_group($_GET['group_id']); 32 32 } else { 33 ?> 33 ?> 34 34 <div class="wrap"> 35 35 36 36 <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2> 37 37 <br /> 38 <p><?php _e( 'Your users will distinguish themselves through their profile page. 39 You must give them profile fields that allow them to describe themselves 38 <p><?php _e( 'Your users will distinguish themselves through their profile page. 39 You must give them profile fields that allow them to describe themselves 40 40 in a way that is relevant to the theme of your social network.', 'buddypress') ?></p> 41 41 42 42 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p> 43 43 44 44 <form action="" id="profile-field-form" method="post"> 45 45 46 46 <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?> 47 47 48 48 <?php 49 49 if ( $message != '' ) { … … 54 54 </div> 55 55 <?php } 56 56 57 57 if ( $groups ) { ?> 58 <?php 58 <?php 59 59 for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach 60 60 ?> … … 65 65 <th scope="col"> </th> 66 66 <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo attribute_escape( $groups[$i]->name ); ?></th> 67 <?php if ( $groups[$i]->can_delete ) { ?> 67 <?php if ( $groups[$i]->can_delete ) { ?> 68 68 <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th> 69 69 <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th> … … 79 79 </thead> 80 80 <tbody id="the-list"> 81 81 82 82 <?php if ( $groups[$i]->fields ) { ?> 83 83 84 84 <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?> 85 86 <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> 85 86 <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?> 87 87 <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?> 88 88 <?php if ( !$field->can_delete ) { $class .= ' core'; } ?> 89 89 90 90 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>"> 91 91 <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td> … … 96 96 <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Delete', 'buddypress' ) ?></strike><?php } else { ?><a class="delete" href="admin.php?page=bp-profile-setup&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td> 97 97 </tr> 98 98 99 99 <?php } ?> 100 100 101 101 <?php } else { ?> 102 102 103 103 <tr class="nodrag"> 104 104 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td> 105 105 </tr> 106 106 107 107 <?php } ?> 108 108 109 109 </tbody> 110 110 111 111 <tfoot> 112 112 113 113 <tr class="nodrag"> 114 114 <td colspan="6"><a href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td> 115 115 </tr> 116 116 117 117 </tfoot> 118 118 119 119 </table> 120 120 </p> 121 121 122 122 <?php } /* End For */ ?> 123 123 124 124 <p> 125 125 <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a> 126 126 </p> 127 127 128 128 <?php } else { ?> 129 129 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 130 130 <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p> 131 131 <?php } ?> 132 132 133 133 </form> 134 134 135 135 </div> 136 136 <?php … … 141 141 /************************************************************************** 142 142 xprofile_admin_manage_group() 143 143 144 144 Handles the adding or editing of groups. 145 145 **************************************************************************/ … … 154 154 $group->name = wp_filter_kses( $_POST['group_name'] ); 155 155 $group->description = wp_filter_kses( $_POST['group_desc'] ); 156 156 157 157 if ( !$group->save() ) { 158 158 $message = __('There was an error saving the group. Please try again', 'buddypress'); … … 161 161 $message = __('The group was saved successfully.', 'buddypress'); 162 162 $type = 'success'; 163 163 164 164 do_action( 'xprofile_groups_saved_group', $group ); 165 165 } 166 166 167 167 unset($_GET['mode']); 168 168 xprofile_admin( $message, $type ); … … 172 172 } 173 173 } else { 174 $group->render_admin_form(); 174 $group->render_admin_form(); 175 175 } 176 176 } … … 178 178 /************************************************************************** 179 179 xprofile_admin_delete_group() 180 180 181 181 Handles the deletion of profile data groups. 182 182 **************************************************************************/ … … 184 184 function xprofile_admin_delete_group( $group_id ) { 185 185 global $message, $type; 186 186 187 187 $group = new BP_XProfile_Group($group_id); 188 188 189 189 if ( !$group->delete() ) { 190 190 $message = __('There was an error deleting the group. Please try again', 'buddypress'); … … 193 193 $message = __('The group was deleted successfully.', 'buddypress'); 194 194 $type = 'success'; 195 195 196 196 do_action( 'xprofile_groups_deleted_group', $group ); 197 197 } 198 198 199 199 unset($_GET['mode']); // TODO: wtf? 200 200 xprofile_admin( $message, $type ); … … 204 204 /************************************************************************** 205 205 xprofile_admin_manage_field() 206 206 207 207 Handles the adding or editing of profile field data for a user. 208 208 **************************************************************************/ … … 210 210 function xprofile_admin_manage_field( $group_id, $field_id = null ) { 211 211 global $bp, $wpdb, $message, $groups; 212 212 213 213 $field = new BP_XProfile_Field($field_id); 214 214 $field->group_id = $group_id; … … 228 228 $field->field_order++; 229 229 } 230 230 231 231 if ( !$field->save() ) { 232 232 $message = __('There was an error saving the field. Please try again', 'buddypress'); 233 233 $type = 'error'; 234 234 235 235 unset($_GET['mode']); 236 236 xprofile_admin($message, $type); … … 238 238 $message = __('The field was saved successfully.', 'buddypress'); 239 239 $type = 'success'; 240 240 241 241 unset($_GET['mode']); 242 242 243 243 do_action( 'xprofile_fields_saved_field', $field ); 244 244 245 245 $groups = BP_XProfile_Group::get_all(); 246 246 xprofile_admin( $message, $type ); … … 250 250 } 251 251 } else { 252 $field->render_admin_form(); 252 $field->render_admin_form(); 253 253 } 254 254 } … … 256 256 /************************************************************************** 257 257 xprofile_admin_delete_field() 258 258 259 259 Handles the deletion of a profile field [or option]. 260 260 **************************************************************************/ … … 262 262 function xprofile_admin_delete_field( $field_id, $type = 'field' ) { 263 263 global $message, $type; 264 264 265 265 if ( 'field' == $type ) { 266 266 $type = __('field', 'buddypress'); … … 268 268 $type = __('option', 'buddypress'); 269 269 } 270 270 271 271 $field = new BP_XProfile_Field($field_id); 272 272 … … 277 277 $message = sprintf( __('The %s was deleted successfully!', 'buddypress'), $type); 278 278 $type = 'success'; 279 279 280 280 do_action( 'xprofile_fields_deleted_field', $field ); 281 281 } 282 282 283 283 unset($_GET['mode']); 284 284 xprofile_admin($message, $type); … … 287 287 function xprofile_ajax_reorder_fields() { 288 288 global $bp; 289 289 290 290 /* Check the nonce */ 291 291 check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); 292 292 293 293 if ( empty( $_POST['field_order'] ) ) 294 294 return false; 295 295 296 296 parse_str($_POST['field_order'], $order ); 297 297 -
trunk/bp-xprofile/bp-xprofile-classes.php
r2066 r2077 7 7 var $can_delete; 8 8 var $fields; 9 9 10 10 function bp_xprofile_group( $id = null ) { 11 11 global $bp, $wpdb; … … 15 15 } 16 16 } 17 17 18 18 function populate( $id ) { 19 19 global $wpdb, $bp; 20 20 21 21 $sql = $wpdb->prepare("SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id); 22 22 … … 26 26 $this->description = $group->description; 27 27 $this->can_delete = $group->can_delete; 28 28 29 29 // get the fields for this group. 30 30 $this->fields = $this->get_fields(); … … 35 35 function save() { 36 36 global $wpdb, $bp; 37 37 38 38 $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id ); 39 39 $this->description = apply_filters( 'xprofile_group_description_before_save', $this->description, $this->id ); … … 44 44 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id ); 45 45 } else { 46 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description ); 47 } 48 46 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description ); 47 } 48 49 49 if ( !$wpdb->query($sql) ) 50 50 return false; 51 51 52 52 do_action( 'xprofile_group_after_save', $this ); 53 53 54 54 return true; 55 55 } 56 56 57 57 function delete() { 58 58 global $wpdb, $bp; 59 59 60 60 if ( !$this->can_delete ) 61 61 return false; 62 62 63 63 $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id ); 64 64 … … 69 69 if ( BP_XProfile_Field::delete_for_group($this->id) ) { 70 70 // Now delete all the profile data for the groups fields 71 for ( $i = 0; $i < count($this->fields); $i++ ) { 71 for ( $i = 0; $i < count($this->fields); $i++ ) { 72 72 BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id); 73 73 } 74 74 } 75 75 76 76 return true; 77 77 } 78 78 } 79 79 80 80 function get_fields() { 81 81 global $wpdb, $bp; 82 82 83 83 /* Find the max value for field_order, if it is zero, order by field_id instead -- provides backwards compat ordering */ 84 84 if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT MAX(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $this->id ) ) ) … … 90 90 if ( !$fields = $wpdb->get_results( $wpdb->prepare("SELECT id, type FROM {$bp->profile->table_name_fields} WHERE group_id = %d AND parent_id = 0 {$order_sql}", $this->id ) ) ) 91 91 return false; 92 92 93 93 return $fields; 94 94 } 95 95 96 96 /** Static Functions **/ 97 97 98 98 function get_all( $hide_empty = false ) { 99 99 global $wpdb, $bp; … … 107 107 if ( !$groups_temp = $wpdb->get_results($sql) ) 108 108 return false; 109 109 110 110 for ( $i = 0; $i < count($groups_temp); $i++ ) { 111 111 $group = new BP_XProfile_Group($groups_temp[$i]->id); … … 115 115 return $groups; 116 116 } 117