Changeset 1636
- Timestamp:
- 08/08/2009 05:25:01 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 28 added
- 15 deleted
- 33 edited
- 1 copied
- 26 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r1632 r1636 10 10 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' ); 11 11 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-widgets.php' ); 12 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-cssjs.php' );13 12 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' ); 14 13 14 /* Include deprecated functions if settings allow */ 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' ); 17 15 18 function bp_activity_install() { 16 19 global $wpdb, $bp; … … 50 53 51 54 $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached'; 52 $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';53 55 $bp->activity->slug = BP_ACTIVITY_SLUG; 54 56 … … 81 83 $bp->bp_options_title = __( 'My Activity', 'buddypress' ); 82 84 } else { 83 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);85 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 84 86 $bp->bp_options_title = $bp->displayed_user->fullname; 85 87 } … … 307 309 } 308 310 309 /**** DEPRECATED FUNCTIONS (DO NOT USE IN YOUR CODE) **************/310 311 /* DEPRECATED - use bp_activity_add() */312 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 ) {313 global $bp, $wpdb;314 315 if ( !$user_id )316 $user_id = $bp->loggedin_user->id;317 318 if ( !$recorded_time )319 $recorded_time = time();320 321 $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' );322 bp_activity_add( $args );323 324 if ( $secondary_user_id ) {325 $hide_sitewide = true;326 $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time', 'hide_sitewide' );327 bp_activity_add( $args );328 }329 330 do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );331 332 return true;333 }334 335 /* DEPRECATED - use bp_activity_delete_by_item_id() */336 function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {337 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 ) ) )338 return false;339 340 do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );341 342 return true;343 }344 345 311 ?> -
trunk/bp-blogs.php
r1621 r1636 8 8 9 9 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-classes.php' ); 10 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-cssjs.php' );11 10 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-templatetags.php' ); 12 11 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-widgets.php' ); 13 require ( BP_PLUGIN_DIR . '/bp-blogs/bp-blogs-ajax.php' ); 14 12 13 /* Include deprecated functions if settings allow */ 14 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 15 require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 16 15 17 function bp_blogs_install() { 16 18 global $wpdb, $bp; … … 157 159 } else { 158 160 /* If we are not viewing the logged in user, set up the current users avatar and name */ 159 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);161 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 160 162 $bp->bp_options_title = $bp->displayed_user->fullname; 161 163 } … … 172 174 if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) { 173 175 $bp->is_directory = true; 174 175 wp_enqueue_script( 'bp-blogs-directory-blogs', BP_PLUGIN_URL . '/bp-blogs/js/directory-blogs.js', array( 'jquery', 'jquery-livequery-pack' ));176 177 do_action( 'bp_blogs_directory_blogs_setup' ); 176 178 bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) ); 177 179 } … … 742 744 } 743 745 744 function bp_blogs_force_buddypress_theme( $template ) {745 global $bp;746 747 if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {748 $member_theme = get_site_option( 'active-member-theme' );749 750 if ( empty( $member_theme ) )751 $member_theme = 'bpmember';752 753 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );754 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );755 756 return $member_theme;757 } else {758 return $template;759 }760 }761 add_filter( 'template', 'bp_blogs_force_buddypress_theme', 1, 1 );762 763 function bp_blogs_force_buddypress_stylesheet( $stylesheet ) {764 global $bp;765 766 if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {767 $member_theme = get_site_option( 'active-member-theme' );768 769 if ( empty( $member_theme ) )770 $member_theme = 'bpmember';771 772 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );773 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );774 775 return $member_theme;776 } else {777 return $stylesheet;778 }779 }780 add_filter( 'stylesheet', 'bp_blogs_force_buddypress_stylesheet', 1, 1 );781 782 746 function bp_blogs_remove_data( $user_id ) { 783 747 /* If this is regular blog, delete all data for that blog. */ -
trunk/bp-blogs/bp-blogs-widgets.php
r1608 r1636 38 38 <li> 39 39 <div class="item-avatar"> 40 <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_ get_avatar( $post->post_author, 1) ?></a>40 <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ?></a> 41 41 </div> 42 42 -
trunk/bp-core.php
r1621 r1636 1 1 <?php 2 2 3 /* Define the current version number for checking if DB tables are up to date. */ 3 define( 'BP_CORE_DB_VERSION', '1 300' );4 define( 'BP_CORE_DB_VERSION', '1400' ); 4 5 5 6 /* Define the path and url of the BuddyPress plugins directory */ … … 30 31 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-settings.php' ); 31 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-widgets.php' ); 32 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-ajax.php' );33 33 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-notifications.php' ); 34 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-signup.php' ); 34 35 35 36 /* If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar */ 36 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) )37 if ( !defined( 'BP_DISABLE_ADMIN_BAR' ) ) 37 38 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-adminbar.php' ); 39 40 /* If BP_IGNORE_DEPRECATED is defined, do not load any deprecated functions for backwards support */ 41 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 42 require ( BP_PLUGIN_DIR . '/bp-core/deprecated/bp-core-deprecated.php' ); 38 43 39 44 /* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */ … … 118 123 /* Sets up the array container for the component navigation rendered by bp_get_nav() */ 119 124 $bp->bp_nav = array(); 120 121 /* Sets up the array container for the user navigation rendered by bp_get_user_nav() */122 $bp->bp_users_nav = array();123 125 124 126 /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */ … … 146 148 /* Used to determine if the logged in user is a moderator for the current content. */ 147 149 $bp->is_item_mod = false; 148 149 $bp->core->image_base = BP_PLUGIN_URL . '/bp-core/images'; 150 150 151 $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications'; 151 152 … … 219 220 bp_core_add_illegal_names(); 220 221 221 // dbDelta won't change character sets, so we need to do this seperately.222 // This will only be in here pre v1.0223 $wpdb->query( $wpdb->prepare( "ALTER TABLE {$bp->core->table_name_notifications} DEFAULT CHARACTER SET %s", $wpdb->charset ) );224 225 222 update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION ); 226 223 } … … 253 250 add_action( 'admin_menu', 'bp_core_check_installed' ); 254 251 255 256 /**257 * bp_core_setup_cookies()258 *259 * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action260 * so that the message can be parsed into the template and displayed to the user.261 *262 * After the message is displayed, it removes the message vars from the cookie so that the message263 * is not shown to the user multiple times.264 *265 * @package BuddyPress Core266 * @global $bp_message The message text267 * @global $bp_message_type The type of message (error/success)268 * @uses setcookie() Sets a cookie value for the user.269 */270 function bp_core_setup_cookies() {271 global $bp_message, $bp_message_type;272 273 // Render any error/success feedback on the template274 if ( $_COOKIE['bp-message'] == '' || !isset( $_COOKIE['bp-message'] ) )275 return false;276 277 $bp_message = $_COOKIE['bp-message'];278 $bp_message_type = $_COOKIE['bp-message-type'];279 add_action( 'template_notices', 'bp_core_render_notice' );280 281 setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );282 setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );283 }284 add_action( 'init', 'bp_core_setup_cookies' );285 286 287 252 /** 288 253 * bp_core_add_admin_menu() … … 335 300 * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item 336 301 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user 337 * @uses bp_core_ get_avatar() Returns the either the thumb (1) or full (2)avatar URL for the user_id passed302 * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed 338 303 */ 339 304 function bp_core_setup_nav() { … … 354 319 $bp->bp_options_title = __('My Profile', 'buddypress'); 355 320 } else { 356 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);321 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 357 322 $bp->bp_options_title = $bp->displayed_user->fullname; 358 323 } … … 381 346 $bp->current_component = false; 382 347 383 wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ));348 do_action( 'bp_core_action_directory_members' ); 384 349 bp_core_load_template( apply_filters( 'bp_core_template_directory_members', 'directories/members/index' ) ); 385 350 } … … 498 463 } 499 464 } 500 /* DEPRECATED - use bp_core_new_nav_item() as it's more friendly and allows ordering */ 501 function bp_core_add_nav_item( $name, $slug, $css_id = false, $show_for_displayed_user = true ) { 502 bp_core_new_nav_item( array( 'name' => $name, 'slug' => $slug, 'item_css_id' => $css_id, 'show_for_displayed_user' => $show_for_displayed_user ) ); 503 } 465 504 466 505 467 /** … … 591 553 return false; 592 554 593 if ( !$user_has_access )594 return false;595 596 555 /* If this is for site admins only and the user is not one, don't create the subnav item */ 597 556 if ( $site_admin_only && !is_site_admin() ) … … 609 568 ); 610 569 611 if ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) {570 if ( $bp->current_action == $slug && $bp->current_component == $parent_slug && $user_has_access ) { 612 571 if ( !is_object($screen_function[0]) ) 613 572 add_action( 'wp', $screen_function, 3 ); … … 616 575 } 617 576 } 618 /* DEPRECATED - use bp_core_new_subnav_item() as it's more friendly and allows ordering. */619 function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) {620 bp_core_new_subnav_item( array( 'name' => $name, 'slug' => $slug, 'parent_slug' => $parent_id, 'parent_url' => $link, 'item_css_id' => $css_id, 'user_has_access' => $user_has_access, 'site_admin_only' => $admin_only, 'screen_function' => $function ) );621 }622 577 623 578 function bp_core_sort_subnav_items() { … … 799 754 return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 800 755 } 801 function bp_core_get_userid_from_user_login( $deprecated ) {802 return bp_core_get_userid( $deprecated );803 }804 756 805 757 /** … … 965 917 return apply_filters( 'bp_core_get_user_displayname', stripslashes( strip_tags( trim( $fullname ) ) ) ); 966 918 } 967 /* DEPRECATED Use: bp_core_get_user_displayname */968 function bp_core_global_user_fullname( $user_id ) { return bp_core_get_user_displayname( $user_id ); }969 970 919 971 920 /** … … 985 934 } 986 935 987 988 936 /** 989 937 * bp_core_get_userlink_by_username() … … 1034 982 */ 1035 983 function bp_core_add_message( $message, $type = false ) { 984 global $bp; 985 1036 986 if ( !$type ) 1037 987 $type = 'success'; 1038 988 989 /* Send the values to the cookie for page reload display */ 1039 990 setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH ); 1040 991 setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH ); 1041 } 1042 1043 1044 /** 1045 * bp_core_render_notice() 1046 * 1047 * Renders a feedback notice (either error or success message) to the theme template. 992 993 /*** 994 * Send the values to the $bp global so we can still output messages 995 * without a page reload 996 */ 997 $bp->template_message = $message; 998 $bp->template_message_type = $type; 999 } 1000 1001 /** 1002 * bp_core_setup_message() 1003 * 1004 * Checks if there is a feedback message in the WP cookie, if so, adds a "template_notices" action 1005 * so that the message can be parsed into the template and displayed to the user. 1006 * 1007 * After the message is displayed, it removes the message vars from the cookie so that the message 1008 * is not shown to the user multiple times. 1009 * 1010 * @package BuddyPress Core 1011 * @global $bp_message The message text 1012 * @global $bp_message_type The type of message (error/success) 1013 * @uses setcookie() Sets a cookie value for the user. 1014 */ 1015 function bp_core_setup_message() { 1016 global $bp; 1017 1018 if ( empty( $bp->template_message ) ) 1019 $bp->template_message = $_COOKIE['bp-message']; 1020 1021 if ( empty( $bp->template_message_type ) ) 1022 $bp->template_message_type = $_COOKIE['bp-message-type']; 1023 1024 add_action( 'template_notices', 'bp_core_render_message' ); 1025 1026 setcookie( 'bp-message', false, time() - 1000, COOKIEPATH ); 1027 setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 1028 } 1029 add_action( 'wp', 'bp_core_setup_message' ); 1030 1031 /** 1032 * bp_core_render_message() 1033 * 1034 * Renders a feedback message (either error or success message) to the theme template. 1048 1035 * The hook action 'template_notices' is used to call this function, it is not called directly. 1049 1036 * … … 1051 1038 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 1052 1039 */ 1053 function bp_core_render_notice() { 1054 if ( $_COOKIE['bp-message'] ) { 1055 $type = ( 'success' == $_COOKIE['bp-message-type'] ) ? 'updated' : 'error'; 1040 function bp_core_render_message() { 1041 global $bp; 1042 1043 if ( $bp->template_message ) { 1044 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error'; 1056 1045 ?> 1057 1046 <div id="message" class="<?php echo $type; ?>"> 1058 <p><?php echo stripslashes( $_COOKIE['bp-message']); ?></p>1047 <p><?php echo stripslashes( attribute_escape( $bp->template_message ) ); ?></p> 1059 1048 </div> 1060 1049 <?php 1061 do_action( 'bp_core_render_notice' ); 1062 } 1063 } 1064 1050 do_action( 'bp_core_render_message' ); 1051 } 1052 } 1065 1053 1066 1054 /** … … 1266 1254 1267 1255 /** 1268 * bp_core_get_buddypress_themes()1269 *1270 * Gets an array of all the BuddyPress themes in the /bp-themes/ directory.1271 *1272 * @package BuddyPress Core1273 * @uses get_themes()1274 * @return An array containing all of the themes.1275 */1276 function bp_core_get_buddypress_themes() {1277 global $wp_themes;1278 1279 /* Remove the cached WP themes first */1280 $wp_existing_themes = &$wp_themes;1281 $wp_themes = null;1282 1283 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );1284 $themes = get_themes();1285 1286 if ( $themes ) {1287 foreach ( $themes as $name => $values ) {1288 if ( $name == 'BuddyPress Default Home Theme' )1289 continue;1290 1291 $member_themes[] = array(1292 'name' => $name,1293 'template' => $values['Template'],1294 'version' => $values['Version']1295 );1296 }1297 }1298 1299 /* Restore the cached WP themes */1300 $wp_themes = $wp_existing_themes;1301 1302 return $member_themes;1303 }1304 function bp_core_get_member_themes() { return bp_core_get_buddypress_themes(); } // DEPRECATED1305 1306 1307 /**1308 * bp_get_buddypress_theme_uri()1309 *1310 * Get the url of the selected BuddyPress theme.1311 *1312 * @package BuddyPress Core1313 */1314 function bp_get_buddypress_theme_uri() {1315 return apply_filters( 'bp_get_buddypress_theme_uri', WP_CONTENT_URL . '/bp-themes/' . get_site_option( 'active-member-theme' ) );1316 }1317 1318 1319 /**1320 * bp_get_buddypress_theme_path()1321 *1322 * Get the path of the selected BuddyPress theme.1323 *1324 * @package BuddyPress Core1325 */1326 function bp_get_buddypress_theme_path() {1327 return apply_filters( 'bp_get_buddypress_theme_path', WP_CONTENT_DIR . '/bp-themes/' . get_site_option( 'active-member-theme' ) );1328 }1329 1330 1331 /**1332 * bp_core_filter_buddypress_theme_root()1333 *1334 * Adds a filter that changes the root path of the theme directory to the bp-themes directory.1335 *1336 * @package BuddyPress Core1337 */1338 function bp_core_filter_buddypress_theme_root() {1339 return apply_filters( 'bp_core_filter_buddypress_theme_root', WP_CONTENT_DIR . "/bp-themes" );1340 }1341 1342 1343 /**1344 * bp_core_filter_buddypress_theme_root_uri()1345 *1346 * Adds a filter that changes the root URI of the theme directory to the bp-themes directory.1347 *1348 * @package BuddyPress Core1349 */1350 function bp_core_filter_buddypress_theme_root_uri() {1351 return apply_filters( 'bp_core_filter_buddypress_theme_root_uri', WP_CONTENT_URL . '/bp-themes' );1352 }1353 1354 1355 /**1356 1256 * bp_core_add_illegal_names() 1357 1257 * … … 1383 1283 update_site_option( 'illegal_names', $new ); 1384 1284 } 1385 1386 1285 1387 1286 /** … … 1629 1528 add_action ( 'plugins_loaded', 'bp_core_load_buddypress_textdomain', 9 ); 1630 1529 1530 function bp_core_add_ajax_hook() { 1531 do_action( 'wp_ajax_' . $_REQUEST['action'] ); 1532 } 1533 add_action( 'init', 'bp_core_add_ajax_hook' ); 1631 1534 1632 1535 /** -
trunk/bp-core/bp-core-activation.php
r1366 r1636 1 1 <?php 2 3 function bp_core_activation_set_headers() { 4 global $wp_object_cache; 5 6 define( "WP_INSTALLING", true ); 7 8 require_once( ABSPATH . WPINC . '/registration.php'); 9 10 if( is_object( $wp_object_cache ) ) 11 $wp_object_cache->cache_enabled = false; 12 13 do_action("activate_header"); 14 } 15 16 function bp_core_activation_do_activation() { 17 global $current_site, $blog_id, $user_id; ?> 18 19 <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?> 20 21 <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3> 22 23 <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p> 24 25 <div class="field-box"> 26 <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php"> 27 <p> 28 <label for="key"><?php _e('Activation Key:', 'buddypress' ) ?></label> 29 <br /><input type="text" name="key" id="key" value="" size="50" /> 30 </p> 31 <p class="submit"> 32 <input id="submit" type="submit" name="Submit" class="submit" value="<?php _e('Activate »', 'buddypress' ) ?>"/> 33 </p> 34 </form> 35 </div> 36 37 <?php } else { 38 39 $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key']; 40 $result = wpmu_activate_signup($key); 41 42 if ( is_wp_error($result) ) { 43 if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) { 44 $signup = $result->get_error_data(); 45 ?> 46 47 <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3> 48 49 <?php 50 _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' ); 51 52 } else { 53 ?> 54 <h2><?php _e('An error occurred during the activation', 'buddypress' ); ?></h2> 55 <?php 56 echo '<p>'.$result->get_error_message().'</p>'; 57 } 58 } else { 59 extract($result); 60 61 $user = new WP_User( (int) $user_id); 62 63 ?> 64 65 <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3> 66 67 <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> 68 69 <div class="field-box" id="signup-welcome"> 70 <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p> 71 <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p> 72 </div> 73 74 <?php 75 do_action( 'bp_activation_extras', $user_id, $meta ); 76 } 77 } 78 } 79 80 // Notify user of signup success. 81 function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) { 82 global $current_site; 83 84 // Send email with activation link. 85 if ( 'no' == constant( "VHOST" ) ) { 86 $activate_url = bp_activation_page( false ) . "?key=$key"; 87 } else { 88 $activate_url = bp_activation_page( false ) ."?key=$key"; 89 } 90 91 $activate_url = clean_url($activate_url); 92 $admin_email = get_site_option( "admin_email" ); 93 94 if ( empty( $admin_email ) ) 95 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 96 97 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 98 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 99 $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}" ) ); 100 $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path)); 101 102 wp_mail($user_email, $subject, $message, $message_headers); 103 104 // Return false to stop the original WPMU function from continuing 105 return false; 106 } 107 add_filter( 'wpmu_signup_blog_notification', 'bp_core_activation_signup_blog_notification', 1, 7 ); 108 109 function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) { 110 global $current_site; 111 112 // Send email with activation link. 113 $admin_email = get_site_option( "admin_email" ); 114 115 if ( empty( $admin_email ) ) 116 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 117 118 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 119 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 120 $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" ) ) ); 121 $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __( 'Activate %s', 'buddypress' ), $user ) ); 122 123 wp_mail( $user_email, $subject, $message, $message_headers ); 124 125 // Return false to stop the original WPMU function from continuing 126 return false; 127 } 128 add_filter( 'wpmu_signup_user_notification', 'bp_core_activation_signup_user_notification', 1, 4 ); 2 // New activation code here next week. 3 ?> -
trunk/bp-core/bp-core-adminbar.php
r1599 r1636 27 27 global $bp; 28 28 29 echo '<a href="' . $bp->root_domain . '"><img id="admin-bar-logo" src="' . apply_filters( 'bp_admin_bar_logo_src', BP_PLUGIN_URL . '/bp-core/ images/admin_bar_logo.gif' ) . '" alt="' . apply_filters( 'bp_admin_bar_logo_alt_text', __( 'BuddyPress', 'buddypress' ) ) . '" /></a>';29 echo '<a href="' . $bp->root_domain . '"><img id="admin-bar-logo" src="' . apply_filters( 'bp_admin_bar_logo_src', BP_PLUGIN_URL . '/bp-core/deprecated/images/admin_bar_logo.gif' ) . '" alt="' . apply_filters( 'bp_admin_bar_logo_alt_text', __( 'BuddyPress', 'buddypress' ) ) . '" /></a>'; 30 30 } 31 31 … … 65 65 echo '<li' . $alt . '>'; 66 66 echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>'; 67 67 68 68 if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) { 69 69 echo '<ul>'; 70 70 $sub_counter = 0; 71 71 72 foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) { 72 73 $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : ''; -
trunk/bp-core/bp-core-avatars.php
r1599 r1636 1 1 <?php 2 2 /* 3 Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/4 Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/3 Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/ 4 Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/ 5 5 */ 6 6 7 /* Make sure we have the core WordPress files we need */ 8 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 9 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 10 11 /* Define settings for avatars. [TODO] This will eventually end up as admin configurable settings */ 12 define( 'CORE_AVATAR_V1_W', apply_filters( 'bp_core_avatar_v1_w', 50 ) ); 13 define( 'CORE_AVATAR_V1_H', apply_filters( 'bp_core_avatar_v1_h', 50 ) ); 14 define( 'CORE_AVATAR_V2_W', apply_filters( 'bp_core_avatar_v2_w', 150 ) ); 15 define( 'CORE_AVATAR_V2_H', apply_filters( 'bp_core_avatar_v2_h', 150 ) ); 16 define( 'CORE_CROPPING_CANVAS_MAX', apply_filters( 'bp_core_avatar_cropping_canvas_max', 450 ) ); 17 define( 'CORE_MAX_FILE_SIZE', get_site_option('fileupload_maxk') * 1024 ); 18 define( 'CORE_DEFAULT_AVATAR', apply_filters( 'bp_core_avatar_default_src', BP_PLUGIN_URL . '/bp-xprofile/images/none.gif' ) ); 19 define( 'CORE_DEFAULT_AVATAR_THUMB', apply_filters( 'bp_core_avatar_default_thumb_src', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ) ); 20 21 function bp_core_get_avatar( $user, $version = 1, $width = null, $height = null, $no_tag = false ) { 7 /*** 8 * Set up the constants we need for avatar support 9 */ 10 11 if ( !defined( 'BP_AVATAR_THUMB_WIDTH' ) ) 12 define( 'BP_AVATAR_THUMB_WIDTH', 50 ); 13 14 if ( !defined( 'BP_AVATAR_THUMB_HEIGHT' ) ) 15 define( 'BP_AVATAR_THUMB_HEIGHT', 50 ); 16 17 if ( !defined( 'BP_AVATAR_FULL_WIDTH' ) ) 18 define( 'BP_AVATAR_FULL_WIDTH', 150 ); 19 20 if ( !defined( 'BP_AVATAR_FULL_HEIGHT' ) ) 21 define( 'BP_AVATAR_FULL_HEIGHT', 150 ); 22 23 if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_WIDTH' ) ) 24 define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 ); 25 26 if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) 27 define( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', get_site_option( 'fileupload_maxk' ) * 1024 ); 28 29 if ( !defined( 'BP_AVATAR_DEFAULT' ) ) 30 define( 'BP_AVATAR_DEFAULT', BP_PLUGIN_URL . '/bp-xprofile/images/none.gif' ); 31 32 if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) ) 33 define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' ); 34 35 function bp_core_fetch_avatar( $args = '' ) { 22 36 global $bp, $current_blog; 23 24 if ( !is_int($version) ) 25 $version = (int) $version; 26 27 if ( CORE_AVATAR_V2_W == false && CORE_AVATAR_V2_H == false ) 28 $version = 1; 29 30 if ( !$width ) 31 $width = constant('CORE_AVATAR_V' . $version . '_W'); 32 33 if ( !$height ) 34 $height = constant('CORE_AVATAR_V' . $version . '_H'); 35 36 $avatar_file = wp_cache_get( 'bp_core_avatar_v' . $version . '_u' . $user, 'bp' ); 37 if ( false === $avatar_file ) { 38 $avatar_file = get_usermeta( $user, 'bp_core_avatar_v' . $version ); 39 wp_cache_set( 'bp_core_avatar_v' . $version . '_u' . $user, $avatar_file, 'bp' ); 40 } 41 42 $url = $bp->root_domain . '/' . $avatar_file; 43 44 if ( strlen($avatar_file) ) { 45 if ( $no_tag ) 46 return $url; 37 38 $defaults = array( 39 'item_id' => false, 40 'object' => 'user', // user OR group OR blog OR custom type (if you use filters) 41 'type' => 'thumb', 42 'avatar_dir' => 'avatars', 43 'width' => false, 44 'height' => false, 45 'class' => 'avatar', 46 'id' => false, 47 'alt' => __( 'Avatar Image', 'buddypress' ), 48 ); 49 50 $r = wp_parse_args( $args, $defaults ); 51 extract( $r, EXTR_SKIP ); 52 53 if ( !$item_id ) { 54 if ( 'user' == $object ) 55 $item_id = $bp->displayed_user->id; 56 else if ( 'group' == $object ) 57 $item_id = $bp->groups->current_group->id; 58 else if ( 'blog' == $object ) 59 $item_id = $current_blog->id; 60 61 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object ); 62 } 63 64 if ( !$id ) 65 $id = $object . '-' . $item_id . '-avatar'; 66 67 if ( $width ) 68 $html_width = " width='{$width}"; 69 70 if ( $height ) 71 $html_height = " height='{$height}'"; 72 73 $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 74 $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 ); 75 76 /* If no avatars have been uploaded for this item, display a gravatar */ 77 if ( !file_exists( $avatar_folder_dir ) ) { 78 79 if ( empty( $bp->grav_default->{$object} ) ) 80 $default_grav = 'wavatar'; 81 else if ( 'mystery' == $bp->grav_default->{$object} ) 82 $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg'; 47 83 else 48 return apply_filters( 'bp_core_get_avatar', '<img src="' . attribute_escape( $url ) . '" alt="" class="avatar photo" width="' . attribute_escape( $width ) . '" height="' . attribute_escape( $height ) . '" />', $user, $version, $width, $height, $no_tag ); 49 } else { 50 $ud = get_userdata($user); 51 52 if ( empty( $bp->grav_default ) ) { 53 $default_grav = 'wavatar'; 54 } else if ( 'mystery' == $bp->grav_default ) { 55 $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg'; 56 } else { 57 $default_grav = $bp->grav_default; 84 $default_grav = $bp->grav_default->{$object}; 85 86 if ( $width ) $grav_size = $width; 87 else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH; 88 else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH; 89 90 if ( 'user' == $object ) { 91 $ud = get_userdata( $item_id ); 92 $grav_email = $ud->user_email; 93 } else if ( 'group' == $object || 'blog' == $object ) { 94 $grav_email = "{$item_id}-{$object}@{$bp->root_domain}"; 58 95 } 59 60 $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ); 61 $gravatar = $gravatar_url . md5( $ud->user_email ) . '?d=' . $default_grav . '&s='; 62 63 if ( $no_tag ) 64 return apply_filters( 'bp_core_get_avatar', $gravatar . constant('CORE_AVATAR_V' . $version . '_W'), $user, $version, $width, $height, $no_tag ); 65 else 66 return apply_filters( 'bp_core_get_avatar', '<img src="' . attribute_escape( $gravatar ) . constant('CORE_AVATAR_V' . $version . '_W') . '" alt="" class="avatar" width="' . attribute_escape( $width ) . '" height="' . attribute_escape( $height ) . '" />', $user, $version, $width, $height, $no_tag ); 67 } 96 97 $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object ); 98 $gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&s=' . $grav_size; 99 100 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' id='{$class}' class='{$class}'{$html_width}{$html_height} />", $item_id, $object, $height, $width, $class, $alt ); 101 102 } 103 104 /* Set the file names to search for to select the full size or thumbnail image. */ 105 $avatar_name = ( 'full' == $type ) ? '-bpfull' : '-bpthumb'; 106 107 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 108 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 109 if ( preg_match( "/{$avatar_name}/", $avatar_file ) ) 110 $avatar_url = $avatar_folder_url . '/' . $avatar_file; 111 } 112 } 113 closedir($av_dir); 114 115 /* If no avatar is found, check for the legacy file names of '-avatar1' and '-avatar2' */ 116 if ( !$avatar_url && 'user' == $object ) { 117 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 118 $avatar_name = ( 'full' == $type ) ? '-avatar2' : '-avatar1'; 119 120 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 121 if ( preg_match( "/{$avatar_name}/", $avatar_file ) ) 122 $avatar_url = $avatar_folder_url . '/' . $avatar_file; 123 } 124 } 125 closedir($av_dir); 126 } 127 128 return apply_filters( 'bp_core_fetch_avatar', "<img src='{$avatar_url}' alt='{$alt}' class='{$class}'{$html_width}{$html_height} />", $item_id, $object, $height, $width, $class, $alt ); 129 } 130 131 function bp_core_delete_existing_avatar( $args = '' ) { 132 global $bp; 133 134 $defaults = array( 135 'item_id' => false, 136 'object' => 'user', // user OR group OR blog OR custom type (if you use filters) 137 'avatar_path' => false 138 ); 139 140 $r = wp_parse_args( $args, $defaults ); 141 extract( $r, EXTR_SKIP ); 142 143 if ( !$avatar_path ) 144 return false; 145 146 if ( 'user' == $object ) { 147 /* Delete any legacy meta entries if this is a user avatar */ 148 delete_usermeta( $item_id, 'bp_core_avatar_v1_path' ); 149 delete_usermeta( $item_id, 'bp_core_avatar_v1' ); 150 delete_usermeta( $item_id, 'bp_core_avatar_v2_path' ); 151 delete_usermeta( $item_id, 'bp_core_avatar_v2' ); 152 } 153 154 if ( $av_dir = opendir( $avatar_path ) ) { 155 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 156 if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) 157 @unlink( $avatar_path . '/' . $avatar_file ); 158 } 159 } 160 closedir($av_dir); 161 } 162 163 function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 164 global $bp; 165 166 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 167 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 168 169 $errors = false; 170 171 $uploadErrors = array( 172 0 => __("There is no error, the file uploaded with success", 'buddypress'), 173 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 174 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 175 3 => __("The uploaded file was only partially uploaded", 'buddypress'), 176 4 => __("No file was uploaded", 'buddypress'), 177 6 => __("Missing a temporary folder", 'buddypress') 178 ); 179 180 if ( !bp_core_check_avatar_upload( $file ) ) { 181 bp_core_add_message( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$file['file']['error']] ), 'error' ); 182 $errors = true; 183 } 184 185 if ( !bp_core_check_avatar_size( $file ) ) { 186 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' ); 187 $errors = true; 188 } 189 190 if ( !bp_core_check_avatar_type( $file ) ) { 191 bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' ); 192 $errors = true; 193 } 194 195 // Filter the upload location 196 add_filter( 'upload_dir', $upload_dir_filter ); 197 198 // Move the file to the correct upload location. 199 if ( !$bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) ) ) { 200 bp_core_add_message( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $bp->avatar_admin->original['error'] ), 'error' ); 201 $errors = true; 202 } 203 204 // Resize the image down to something manageable and then delete the original 205 if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) { 206 $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH ); 207 } 208 209 $bp->avatar_admin->image = new stdClass; 210 211 // We only want to handle one image after resize. 212 if ( empty( $bp->avatar_admin->resized ) ) 213 $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file']; 214 else { 215 $bp->avatar_admin->image->dir = $bp->avatar_admin->resized; 216 @unlink( $bp->avatar_admin->original['file'] ); 217 } 218 219 /* Set the url value for the image */ 220 $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir ); 221 222 return $errors; 223 } 224 225 function bp_core_avatar_handle_crop( $args = '' ) { 226 global $bp; 227 228 $defaults = array( 229 'object' => 'user', 230 'avatar_dir' => 'avatars', 231 'item_id' => false, 232 'original_file' => false, 233 'crop_w' => BP_AVATAR_FULL_WIDTH, 234 'crop_h' => BP_AVATAR_FULL_HEIGHT, 235 'crop_x' => 0, 236 'crop_y' => 0 237 ); 238 239 $r = wp_parse_args( $args, $defaults ); 240 extract( $r, EXTR_SKIP ); 241 242 if ( !$original_file ) 243 return false; 244 245 if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) ) 246 return false; 247 248 if ( !$item_id ) 249 $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir ); 250 else 251 $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 ); 252 253 if ( !file_exists( $avatar_folder_dir ) ) 254 return false; 255 256 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 257 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 258 259 /* Delete the existing avatar files for the object */ 260 bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) ); 261 262 /* Make sure we at least have a width and height for cropping */ 263 if ( !(int)$crop_w ) 264 $crop_w = BP_AVATAR_FULL_WIDTH; 265 266 if ( !(int)$crop_h ) 267 $crop_h = BP_AVATAR_FULL_HEIGHT; 268 269 /* Set the full and thumb filenames */ 270 $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg'; 271 $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg'; 272 273 /* Crop the image */ 274 $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 ); 275 $thumb_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_THUMB_WIDTH, BP_AVATAR_THUMB_HEIGHT, false, $avatar_folder_dir . '/' . $thumb_filename ); 276 277 /* Remove the original */ 278 @unlink( WP_CONTENT_DIR . $original_file ); 279 280 return true; 68 281 } 69 282 70 283 // Override internal "get_avatar()" function to use our own where possible 71 // WARNING: Does NOT apply size restrictions 72 function bp_core_get_avatar_filter( $avatar, $id_or_email, $size, $default ) { 73 $str = ''; 74 $ver = ( 1 == $size || 2 == $size ) ? $size : 1; 75 76 if ( !CORE_AVATAR_V2_W && !CORE_AVATAR_V2_H ) 77 $ver = 1; 78 79 if ( is_numeric($id_or_email) ) { 80 $str = bp_core_get_avatar( $id_or_email, $ver ); 81 } elseif ( is_object($id_or_email) ) { 82 if ( !empty($id_or_email->user_id) ) { 83 $str = bp_core_get_avatar( $id_or_email->user_id, $ver ); 84 } 85 } 86 87 return empty($str) ? $avatar : $str; 88 } 89 add_filter( 'get_avatar', 'bp_core_get_avatar_filter', 10, 4 ); 90 91 92 // Main UI Rendering 93 function bp_core_avatar_admin( $message = null, $action, $delete_action) { 94 global $wp_upload_error; 95 ?> 96 <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?> 97 <?php if ( $message ) { ?> 98 <br /> 99 <div id="message" class="updated fade"> 100 <p><?php echo $message; ?></p> 101 </div> 102 <?php } ?> 103 104 <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p> 105 <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> 106 107 <?php 108 109 bp_core_render_avatar_upload_form($action); 110 111 $str = bp_core_get_avatar( get_current_user_id(), 1 ); 112 if ( strlen($str) ) { 113 echo '<h3>' . __('This is your current avatar', 'buddypress') . '</h3>'; 114 echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 1) . '</span>'; 115 echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 2) . '</span>'; 116 echo '<a href="' . wp_nonce_url( $delete_action, 'bp_delete_avatar_link' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 117 } 118 119 } else if ( isset($_POST['slick_avatars_action']) && 'upload' == $_POST['slick_avatars_action'] ) { 120 121 // Confirm that the nonce is valid 122 if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') ) 123 bp_core_ap_die( 'Security error.' ); 124 125 // Set friendly error feedback. 126 $uploadErrors = array( 127 0 => __("There is no error, the file uploaded with success", 'buddypress'), 128 1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE), 129 2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(CORE_MAX_FILE_SIZE), 130 3 => __("The uploaded file was only partially uploaded", 'buddypress'), 131 4 => __("No file was uploaded", 'buddypress'), 132 6 => __("Missing a temporary folder", 'buddypress') 133 ); 134 135 if ( !bp_core_check_avatar_upload($_FILES) ) 136 bp_core_ap_die( sprintf( __( 'Your upload failed, please try again. Error was: %s', 'buddypress' ), $uploadErrors[$_FILES['file']['error']] ) ); 137 138 if ( !bp_core_check_avatar_size($_FILES) ) 139 bp_core_ap_die( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(CORE_MAX_FILE_SIZE) ) ); 140 141 if ( !bp_core_check_avatar_type($_FILES) ) 142 bp_core_ap_die( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ) ); 143 144 // "Handle" upload into temporary location 145 if ( !$original = bp_core_handle_avatar_upload($_FILES) ) 146 bp_core_ap_die( sprintf( __( 'Upload Failed! Error was: %s', 'buddypress' ), $wp_upload_error ) ); 147 148 // Resize down to something we can display on the page or use original if its small enough already. 149 if ( !$canvas = bp_core_resize_avatar($original) ) 150 $canvas = $original; 151 152 // Render the cropper UI 153 bp_core_render_avatar_cropper($original, $canvas, $action); 154 155 } else if ( isset($_POST['slick_avatars_action']) && 'crop' == $_POST['slick_avatars_action'] ) { 156 // Crop, save, store 157 158 // Confirm that the nonce is valid 159 if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') ) 160 bp_core_ap_die( __( 'Security error.', 'buddypress' ) ); 161 162 if ( !bp_core_check_crop( $_POST['orig'], $_POST['canvas'] ) ) 163 bp_core_ap_die( __( 'Error when cropping, please go back and try again', 'buddypress' ) ); 164 165 if ( !$result = bp_core_avatar_cropstore( stripslashes($_POST['orig']), $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] ) ) 166 bp_core_ap_die( __( 'Error when saving avatars, please go back and try again.', 'buddypress' ) ); 167 168 // Store details to the DB and we're done 169 echo '<p>' . __('Your new avatar was successfully created!', 'buddypress') . '</p>'; 170 171 bp_core_avatar_save($result); 172 173 echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 1 ) . '</span>'; 174 175 if ( CORE_AVATAR_V2_W && CORE_AVATAR_V2_H ) { 176 echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 2 ) . '</span>'; 177 } 178 179 } else if ( isset($_GET['slick_avatars_action']) && 'delete' == $_GET['slick_avatars_action'] ) { 180 // Delete an avatar 181 182 bp_core_delete_avatar(); 183 184 unset($_GET['slick_avatars_action']); 185 $message = __('Avatar successfully removed.', 'buddypress'); 186 bp_core_avatar_admin($message); 187 188 } 189 ?> 190 <?php 191 } 284 function bp_core_fetch_avatar_filter( $avatar, $id_or_email, $size, $default, $alt ) { 285 if ( is_object ( $id_or_email ) ) 286 $id_or_email = $id_or_email->user_id; 287 288 $bp_avatar = bp_core_fetch_avatar( array( 'item_id' => $id_or_email, 'width' => $size, 'height' => $size, 'alt' => $alt ) ); 289 290 return ( !$bp_avatar ) ? $avatar : $bp_avatar; 291 } 292 add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 ); 192 293 193 294 function bp_core_check_avatar_upload($file) { … … 199 300 200 301 function bp_core_check_avatar_size($file) { 201 if ( $file['file']['size'] > CORE_MAX_FILE_SIZE )302 if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE ) 202 303 return false; 203 304 … … 212 313 } 213 314 214 function bp_core_handle_avatar_upload($file) {215 global $wp_upload_error;216 217 // Change the upload file location to /avatars/user_id218 add_filter( 'upload_dir', 'bp_core_avatar_upload_dir' );219 220 $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') );221 222 if ( !in_array('error', array_keys($res) ) ) {223 return $res['file'];224 } else {225 $wp_upload_error = $res['error'];226 return false;227 }228 }229 230 function bp_core_avatar_upload_dir( $upload, $user_id = false ) {231 global $bp;232 233 if ( !$user_id )234 $user_id = $bp->loggedin_user->id;235 236 $path = get_blog_option( 1, 'upload_path' );237 $newdir = path_join( ABSPATH, $path );238 $newdir .= '/avatars/' . $user_id;239 240 $newbdir = $newdir;241 242 @wp_mkdir_p( $newdir );243 244 $newurl = trailingslashit( get_blog_option( 1, 'siteurl' ) ) . '/avatars/' . $user_id;245 $newburl = $newurl;246 $newsubdir = '/avatars/' . $user_id;247 248 return apply_filters( 'bp_core_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );249 }250 251 function bp_core_check_avatar_dimensions($file) {252 $size = getimagesize($file);253 254 if ( $size[0] < (int)CORE_AVATAR_V2_W || $size[1] < (int)CORE_CROPPING_CANVAS_MAX )255 return false;256 257 return true;258 }259 260 function bp_core_resize_avatar( $file, $size = false ) {261 262 if ( !$size )263 $size = CORE_CROPPING_CANVAS_MAX;264 265 $canvas = wp_create_thumbnail( $file, $size );266 267 if ( $canvas->errors )268 return false;269 270 return $canvas = str_replace( '//', '/', $canvas );271 }272 273 function bp_core_render_avatar_cropper( $original, $new, $action, $user_id = null, $no_form_tag = false, $url = false ) {274 global $bp;275 276 $size = getimagesize($new);277 278 if ( !$user_id )279 $user_id = $bp->loggedin_user->id;280 281 $src = str_replace( array(ABSPATH), array(site_url() . '/'), $new );282 283 // Load cropper details284 285 // V1 UI286 if ( !$no_form_tag )287 echo '<form action="' . $action . '" method="post" id="avatar-cropper">';288 289 echo '<input type="hidden" name="slick_avatars_action" value="crop" />';290 echo '<input type="hidden" name="action" value="slick_avatars" />';291 echo '<input type="hidden" name="nonce" value="' . wp_create_nonce('slick_avatars') . '" />';292 echo '<input type="hidden" name="orig" value="' . $original . '" />';293 echo '<input type="hidden" name="canvas" value="' . $new . '" />';294 295 echo '<div id="avatar_v1">';296 echo '<h3>' . __( 'Please Crop Your Avatar!', 'buddypress' ) . '</h3>';297 echo '<h4>' . __('Thumbnail Avatar', 'buddypress') . '</h4>';298 echo '<p>' . __('Please crop a small version of your avatar to use for thumbnails.', 'buddypress') . '</p>';299 300 // Canvas301 echo '<div id="crop-v1" class="crop-img"><img src="' . $src . '" ' . $size[3] . ' border="0" alt="' . __( 'Select the area to crop', 'buddypress' ) . '" id="crop-v1-img" /></div>';302 303 // Preview304 echo '<p class="crop-preview"><strong>' . __('Crop Preview', 'buddypress') . '</strong></p>';305 echo '<div id="crop-preview-v1" class="crop-preview"></div>';306 307 // Hidden form fields308 echo '<input type="hidden" id="v1_x1" name="v1_x1" value="" />';309 echo '<input type="hidden" id="v1_y1" name="v1_y1" value="" />';310 echo '<input type="hidden" id="v1_x2" name="v1_x2" value="" />';311 echo '<input type="hidden" id="v1_y2" name="v1_y2" value="" />';312 echo '<input type="hidden" id="v1_w" name="v1_w" value="" />';313 echo '<input type="hidden" id="v1_h" name="v1_h" value="" />';314 315 // V2 UI (optional)316 if (CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false) {317 // Continue button (v1 => v2)318 echo '<p class="submit"><input type="button" name="avatar_continue" id="avatar_continue" value="' . __('Crop Thumbnail & Continue', 'buddypress') . '" onclick="cropAndContinue();" /></p>';319 echo '</div>';320 321 echo '<div id="avatar_v2" style="display: none">';322 echo '<h4>' . __('Full Size Avatar', 'buddypress') . '</h4>';323 echo '<p>' . __('Please crop a full size version of your avatar.', 'buddypress') . '</p>';324 325 // Canvas326 echo '<div id="crop-v2" class="crop-img"><img src="' . $src . '" ' . $size[3] . ' border="0" alt="' . __('Select the area to crop', 'buddypress' ) . '" id="crop-v2-img" /></div>';327 328 // Preview329 echo '<p class="crop-preview"><strong>' . __('Crop Preview', 'buddypress') . '</strong></p>';330 echo '<div id="crop-preview-v2" class="crop-preview"></div>';331 332 // Hidden form fields333 echo '<input type="hidden" id="v2_x1" name="v2_x1" value="" />';334 echo '<input type="hidden" id="v2_y1" name="v2_y1" value="" />';335 echo '<input type="hidden" id="v2_x2"name="v2_x2" value="" />';336 echo '<input type="hidden" id="v2_y2"name="v2_y2" value="" />';337 echo '<input type="hidden" id="v2_w" name="v2_w" value="" />';338 echo '<input type="hidden" id="v2_h" name="v2_h" value="" />';339 340 // Final button to process everything341 echo '<p class="submit"><input type="submit" id="crop-complete" name="save" value="' . __('Crop Full Size & Save', 'buddypress') . '" /></p>';342 echo '</div>';343 } else {344 // Close out v1 DIV345 echo '</div>';346 347 // Final button to process everything348 echo '<p class="submit"><input type="submit" name="save" value="' . __('Crop Full Size & Save', 'buddypress') . '" /></p>';349 }350 351 do_action( 'bp_core_render_avatar_cropper', $original, $new, $action );352 353 if ( !$no_form_tag )354 echo '</form>';355 ?>356 <script type="text/javascript" charset="utf-8">357 jQuery(document).ready(function(){358 v1Cropper();359 });360 </script>361 <?php362 }363 364 function bp_core_check_crop( $original, $canvas ) {365 if ( is_file($original) && is_readable($original) && is_file($canvas) && is_readable($canvas) )366 return true;367 368 return false;369 }370 371 function bp_core_avatar_cropstore( $source, $canvas, $v1_x1, $v1_y1, $v1_w, $v1_h, $v2_x1, $v2_y1, $v2_w, $v2_h, $from_signup = false, $filename = 'avatar', $item_id = null ) {372 $size = getimagesize($source);373 $dims = getimagesize($canvas);374 375 // Figure out multiplier for scaling376 $multi = $size[0] / $dims[0];377 378 if ( $item_id )379 $filename_item_id = $item_id . '-';380 381 if ( $filename != 'avatar' ) {382 $v1_filename = '-' . md5( $filename_item_id . $filename . time() ) . '-thumb';383 $v2_filename = '-' . md5( $filename_item_id . $filename . time() ) . '-full';384 } else {385 $v1_filename = md5( $source . time() ) . '-avatar1';386 $v2_filename = md5( $source . time() ) . '-avatar2';387 }388 389 $v1_filename = apply_filters( 'bp_avatar_v1_filename', $v1_filename );390 $v2_filename = apply_filters( 'bp_avatar_v2_filename', $v2_filename );391 392 // Perform v1 crop393 $v1_dest = apply_filters( 'bp_avatar_v1_dest', dirname($source) . '/' . preg_replace('!(\.[^.]+)?$!', $v1_filename . '$1', basename($source), 1), $source );394 395 if ( $from_signup )396 $v1_out = wp_crop_image( $source, $v1_x1, $v1_y1, $v1_w, $v1_h, CORE_AVATAR_V1_W, CORE_AVATAR_V1_H, false, $v1_dest );397 else398 $v1_out = wp_crop_image( $source, ($v1_x1 * $multi), ($v1_y1 * $multi), ($v1_w * $multi), ($v1_h * $multi), CORE_AVATAR_V1_W, CORE_AVATAR_V1_H, false, $v1_dest );399 400 // Perform v2 crop401 if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {402 $v2_dest = apply_filters( 'bp_avatar_v2_dest', dirname($source) . '/' . preg_replace('!(\.[^.]+)?$!', $v2_filename . '$1', basename($source), 1), $source );403 404 if ( $from_signup )405 $v2_out = wp_crop_image( $source, $v2_x1, $v2_y1, $v2_w, $v2_h, CORE_AVATAR_V2_W, CORE_AVATAR_V2_H, false, $v2_dest );406 else407 $v2_out = wp_crop_image( $source, ($v2_x1 * $multi), ($v2_y1 * $multi), ($v2_w * $multi), ($v2_h * $multi), CORE_AVATAR_V2_W, CORE_AVATAR_V2_H, false, $v2_dest );408 }409 410 // Clean up canvas and original images used during cropping411 foreach ( array( str_replace( '..', '', $source ), str_replace( '..', '', $canvas) ) as $f ) {412 @unlink($f);413 }414 415 $dir = $source;416 417 do {418 $dir = dirname($dir);419 @rmdir($dir); // will fail on non-empty directories420 } while ( substr_count($dir, '/') >= 2 && stristr($dir, ABSPATH) );421 422 return apply_filters( 'bp_core_avatar_cropstore', array('v1_out' => $v1_out, 'v2_out' => $v2_out) );423 }424 425 function bp_core_avatar_save( $vars, $user_id = false ) {426 if ( !$user_id )427 $user_id = get_current_user_id();428 429 $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );430 $v1_href = apply_filters( 'bp_avatar_v1_href', str_replace( array(ABSPATH), array($src), $vars['v1_out'] ), $src, $vars['v1_out'] );431 update_usermeta( $user_id, 'bp_core_avatar_v1', $v1_href );432 update_usermeta( $user_id, 'bp_core_avatar_v1_path', $vars['v1_out'] );433 @unlink($old); // Removing old avatar434 435 if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {436 $old = get_usermeta( $user_id, 'bp_core_avatar_v2_path' );437 $v2_href = apply_filters( 'bp_avatar_v2_href', str_replace( array(ABSPATH), array($src), $vars['v2_out'] ), $src, $vars['v2_out'] );438 update_usermeta( $user_id, 'bp_core_avatar_v2', $v2_href );439 update_usermeta( $user_id, 'bp_core_avatar_v2_path', $vars['v2_out'] );440 @unlink($old); // Removing old avatar441 }442 443 do_action( 'bp_core_avatar_save', $user_id, $old, $v1_href, $vars['v1_out'] );444 }445 446 function bp_core_render_avatar_upload_form($action, $no_form_tag = false) {447 if ( !$no_form_tag ) { ?>448 <form method="post" action="<?php echo $action ?>" enctype="multipart/form-data" id="avatar-upload">449 <?php } ?>450 <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo CORE_MAX_FILE_SIZE; ?>" />451 <input type="hidden" name="slick_avatars_action" value="upload" />452 <input type="hidden" name="action" value="slick_avatars" />453 <input type="hidden" name="nonce" value="<?php echo wp_create_nonce('slick_avatars'); ?>" />454 <input type="file" name="file" id="file" />455 <p><input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Photo', 'buddypress' ) ?>"/></p>456 457 <?php do_action( 'bp_core_render_avatar_upload_form' ) ?>458 459 <?php if ( !$no_form_tag ) { ?>460 </form>461 <?php462 }463 }464 465 function bp_core_delete_avatar() {466 $user_id = get_current_user_id();467 468 $old_v1 = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );469 $old_v2 = get_usermeta( $user_id, 'bp_core_avatar_v2_path' );470 471 delete_usermeta( $user_id, 'bp_core_avatar_v1_path' );472 delete_usermeta( $user_id, 'bp_core_avatar_v2_path' );473 474 delete_usermeta( $user_id, 'bp_core_avatar_v1' );475 delete_usermeta( $user_id, 'bp_core_avatar_v2' );476 477 // Remove the actual images478 @unlink($old_v1);479 @unlink($old_v2);480 481 do_action( 'bp_core_delete_avatar', $user_id, $old_v1, $old_v2 );482 }483 484 function bp_core_ap_die( $msg ) {485 global $bp;486 echo '<p><strong>' . $msg . '</strong></p>';487 echo '<p><a href="' . $bp->loggedin_user->domain . $bp->profile->slug . '/change-avatar">' . __('Try Again', 'buddypress') . '</a></p>';488 echo '</div>';489 exit;490 }491 492 function bp_core_thumb_error( $str ) {493 if ( !is_string($str) ) {494 return false;495 } else {496 return preg_match( '/(filetype|invalid|not found)/is', $str );497 }498 }499 500 315 ?> -
trunk/bp-core/bp-core-catchuri.php
r1596 r1636 262 262 } 263 263 264 function bp_core_force_buddypress_theme( $template ) {265 global $is_member_page, $bp;266 267 $member_theme = get_site_option( 'active-member-theme' );268 269 if ( empty( $member_theme ) )270 $member_theme = 'bpmember';271 272 if ( $is_member_page ) {273 274 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );275 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );276 277 return $member_theme;278 } else {279 return $template;280 }281 }282 add_filter( 'template', 'bp_core_force_buddypress_theme', 1, 1 );283 284 function bp_core_force_buddypress_stylesheet( $stylesheet ) {285 global $is_member_page;286 287 $member_theme = get_site_option( 'active-member-theme' );288 289 if ( empty( $member_theme ) )290 $member_theme = 'bpmember';291 292 if ( $is_member_page ) {293 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );294 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );295 296 return $member_theme;297 } else {298 return $stylesheet;299 }300 }301 add_filter( 'stylesheet', 'bp_core_force_buddypress_stylesheet', 1, 1 );302 303 264 ?> -
trunk/bp-core/bp-core-classes.php
r1599 r1636 40 40 $this->populate_extras(); 41 41 } 42 } 42 } 43 43 44 44 /** … … 53 53 * @uses bp_core_get_user_email() Returns the email address for the user based on user ID 54 54 * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table 55 * @uses bp_core_ get_avatar() Returns HTML formatted avatar for a user55 * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user 56 56 * @uses bp_profile_last_updated_date() Returns the last updated date for a user. 57 57 */ … … 64 64 $this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ); 65 65 66 $this->avatar = bp_core_ get_avatar( $this->id, 2);67 $this->avatar_thumb = bp_core_ get_avatar( $this->id, 1);68 $this->avatar_mini = bp_core_ get_avatar( $this->id, 1, 25, 25, false);66 $this->avatar = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'full' ) ); 67 $this->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb' ) ); 68 $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 25, 'height' => 25 ) ); 69 69 } 70 70 -
trunk/bp-core/bp-core-cssjs.php
r1619 r1636 1 1 <?php 2 /**3 * bp_core_add_js()4 *5 * Add the JS required by the core, as well as shared JS used by other components.6 * [TODO] This needs to use wp_enqueue_script()7 *8 * @package BuddyPress Core9 * @uses get_option() Selects a site setting from the DB.10 */11 function bp_core_add_js() {12 wp_enqueue_script( 'jquery' );13 wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/js/jquery/jquery.livequery.pack.js', 'jquery' );14 wp_enqueue_script( 'bp-general-js', BP_PLUGIN_URL . '/bp-core/js/general.js' );15 }16 add_action( 'wp', 'bp_core_add_js' );17 add_action( 'admin_menu', 'bp_core_add_js' );18 19 /**20 * bp_core_add_ajax_js()21 *22 * Add the reference to ajaxurl used by all ajax functionality in BuddyPress.23 *24 * @package BuddyPress Core25 * @uses get_option() Selects a site setting from the DB.26 */27 function bp_core_add_ajax_js() {28 global $bp;29 30 echo31 '<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script>32 ';33 }34 add_action( 'wp_head', 'bp_core_add_ajax_js' );35 36 /**37 * bp_core_add_css()38 *39 * Add the CSS required by all BP components, regardless of the current theme.40 *41 * @package BuddyPress Core42 * @uses get_option() Selects a site setting from the DB.43 */44 function bp_core_add_css() {45 // Enable a sitewide CSS file that will apply styles to both the home blog theme46 // and the member theme.47 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) )48 wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' );49 50 wp_print_styles();51 }52 add_action( 'wp_head', 'bp_core_add_css', 2 );53 54 /**55 * bp_core_admin_bar_css()56 *57 * Add the CSS required for the global admin bar.58 *59 * @package BuddyPress Core60 */61 function bp_core_admin_bar_css() {62 if ( defined( 'BP_DISABLE_ADMIN_BAR') )63 return false;64 65 if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {66 wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/css/admin-bar.css' ) );67 68 if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/css/admin-bar-rtl.css' ) )69 wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/css/admin-bar-rtl.css' );70 }71 wp_print_styles();72 }73 add_action( 'wp_head', 'bp_core_admin_bar_css', 1 );74 75 /**76 * bp_core_add_structure_css()77 *78 * Add the CSS to add layout structure to BP pages in any WordPress theme.79 *80 * @package BuddyPress Core81 * @uses get_option() Selects a site setting from the DB.82 */83 function bp_core_add_structure_css() {84 /* Enqueue the structure CSS file to give basic positional formatting for components */85 wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/css/structure.css' );86 }87 add_action( 'bp_styles', 'bp_core_add_structure_css' );88 89 /**90 * bp_core_add_admin_js()91 *92 * Add the JS needed for all components in the admin area.93 *94 * @package BuddyPress Core95 * @uses get_option() Selects a site setting from the DB.96 */97 function bp_core_add_admin_js() {98 if ( false !== strpos( $_GET['page'], 'bp-core' ) ) {99 wp_enqueue_script( 'bp-account-admin-js', BP_PLUGIN_URL . '/bp-core/js/account-admin.js' );100 }101 102 if ( false !== strpos( $_GET['page'], 'bp-core/admin-mods' ) ) {103 wp_enqueue_script('password-strength-meter');104 }105 }106 add_action( 'admin_menu', 'bp_core_add_admin_js' );107 108 2 /** 109 3 * bp_core_add_admin_css() … … 142 36 143 37 /** 144 * bp_core_add_ cropper_js()38 * bp_core_add_jquery_cropper() 145 39 * 146 * Adds the JS needed for general avatar cropping.40 * Makes sure the jQuery jCrop library is loaded. 147 41 * 148 42 * @package BuddyPress Core 149 43 */ 150 function bp_core_add_cropper_js() { 44 function bp_core_add_jquery_cropper() { 45 wp_enqueue_script( 'jcrop' ); 46 add_action( 'wp_head', 'bp_core_add_cropper_inline_js' ); 47 add_action( 'wp_head', 'bp_core_add_cropper_inline_css' ); 48 } 49 50 /** 51 * bp_core_add_cropper_inline_js() 52 * 53 * Adds the inline JS needed for the cropper to work on a per-page basis. 54 * 55 * @package BuddyPress Core 56 */ 57 function bp_core_add_cropper_inline_js() { 58 global $bp; 59 60 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) ); 151 61 ?> 152 62 <script type="text/javascript"> 153 function cropAndContinue() { 154 jQuery('#avatar_v1').slideUp(); 155 jQuery('#avatar_v2').slideDown('normal', function(){ 156 v2Cropper(); 63 jQuery(window).load( function(){ 64 jQuery('#avatar-to-crop').Jcrop({ 65 onChange: showPreview, 66 onSelect: showPreview, 67 onSelect: updateCoords, 68 aspectRatio: 1, 69 setSelect: [ 50, 50, 200, 200 ] 157 70 }); 158 } 71 }); 159 72 160 function v1Cropper() { 161 v1Crop = new Cropper.ImgWithPreview( 162 'crop-v1-img', 163 { 164 ratioDim: { x: <?php echo round(CORE_AVATAR_V1_W / CORE_AVATAR_V1_H, 5); ?>, y: 1 }, 165 minWidth: <?php echo CORE_AVATAR_V1_W; ?>, 166 minHeight: <?php echo CORE_AVATAR_V1_H; ?>, 167 prevWidth: <?php echo CORE_AVATAR_V1_W; ?>, 168 prevHeight: <?php echo CORE_AVATAR_V1_H; ?>, 169 onEndCrop: onEndCropv1, 170 previewWrap: 'crop-preview-v1' 171 } 172 ); 173 } 73 function updateCoords(c) { 74 jQuery('#x').val(c.x); 75 jQuery('#y').val(c.y); 76 jQuery('#w').val(c.w); 77 jQuery('#h').val(c.h); 78 }; 174 79 175 function onEndCropv1(coords, dimensions) { 176 jQuery('#v1_x1').val(coords.x1); 177 jQuery('#v1_y1').val(coords.y1); 178 jQuery('#v1_x2').val(coords.x2); 179 jQuery('#v1_y2').val(coords.y2); 180 jQuery('#v1_w').val(dimensions.width); 181 jQuery('#v1_h').val(dimensions.height); 182 } 80 function showPreview(coords) { 81 if ( parseInt(coords.w) > 0 ) { 82 var rx = 100 / coords.w; 83 var ry = 100 / coords.h; 183 84 184 <?php if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) { ?> 185 function v2Cropper() { 186 v1Crop = new Cropper.ImgWithPreview( 187 'crop-v2-img', 188 { 189 ratioDim: { x: <?php echo round(CORE_AVATAR_V2_W / CORE_AVATAR_V2_H, 5); ?>, y: 1 }, 190 minWidth: <?php echo CORE_AVATAR_V2_W; ?>, 191 minHeight: <?php echo CORE_AVATAR_V2_H; ?>, 192 prevWidth: <?php echo CORE_AVATAR_V2_W; ?>, 193 prevHeight: <?php echo CORE_AVATAR_V2_H; ?>, 194 onEndCrop: onEndCropv2, 195 previewWrap: 'crop-preview-v2' 196 } 197 ); 198 } 199 <?php } ?> 200 201 function onEndCropv2(coords, dimensions) { 202 jQuery('#v2_x1').val(coords.x1); 203 jQuery('#v2_y1').val(coords.y1); 204 jQuery('#v2_x2').val(coords.x2); 205 jQuery('#v2_y2').val(coords.y2); 206 jQuery('#v2_w').val(dimensions.width); 207 jQuery('#v2_h').val(dimensions.height); 208 } 85 jQuery('#avatar-crop-preview').css({ 86 width: Math.round(rx * <?php echo $image[0] ?>) + 'px', 87 height: Math.round(ry * <?php echo $image[1] ?>) + 'px', 88 marginLeft: '-' + Math.round(rx * coords.x) + 'px', 89 marginTop: '-' + Math.round(ry * coords.y) + 'px' 90 }); 91 } 92 } 209 93 </script> 210 94 <?php 211 95 } 96 97 /** 98 * bp_core_add_cropper_inline_css() 99 * 100 * Adds the inline CSS needed for the cropper to work on a per-page basis. 101 * 102 * @package BuddyPress Core 103 */ 104 function bp_core_add_cropper_inline_css() { 105 global $bp; 106 ?> 107 <style type="text/css"> 108 .jcrop-holder { text-align: left; } 109 .jcrop-vline, .jcrop-hline { font-size: 0; position: absolute; background: white top left repeat url( <?php echo $bp->core->image_base ?>/Jcrop.gif ); } 110 .jcrop-vline { height: 100%; width: 1px !important; } 111 .jcrop-hline { width: 100%; height: 1px !important; } 112 .jcrop-handle { font-size: 1px; width: 7px !important; height: 7px !important; border: 1px #eee solid; background-color: #333; *width: 9px; *height: 9px; } 113 .jcrop-tracker { width: 100%; height: 100%; } 114 .custom .jcrop-vline, .custom .jcrop-hline { background: yellow; } 115 .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; } 116 117 </style> 118 <?php 119 } 120 121 /** 122 * bp_core_add_ajax_url_js() 123 * 124 * Adds AJAX target URL so themes can access the WordPress AJAX functionality. 125 * 126 * @package BuddyPress Core 127 */ 128 function bp_core_add_ajax_url_js() { 129 global $bp; 130 131 echo 132 '<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script> 133 '; 134 } 135 add_action( 'wp_head', 'bp_core_add_ajax_url_js' ); 136 137 ?> -
trunk/bp-core/bp-core-signup.php
r1366 r1636 1 1 <?php 2 2 3 function bp_core_signup_set_headers() { 4 add_action( 'wp_head', 'bp_core_signup_register_headers' ) ; 5 require_once( ABSPATH . WPINC . '/registration.php' ); 3 function bp_core_screen_signup() { 4 global $bp, $wpdb; 5 6 if ( $bp->current_component != BP_REGISTER_SLUG ) 7 return false; 8 9 /*** 10 * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function 11 * if the user is using the old two theme method. We can check if function 'wp_insert_user' 12 * exists because the old method would already have included that function's file at this point. 13 */ 14 if ( function_exists('wp_insert_user') ) 15 return false; 16 17 $bp->signup->step = 'request-details'; 18 19 /* If the signup page is submitted, validate and save */ 20 if ( isset( $_POST['signup_submit'] ) ) { 21 22 /* Check the nonce */ 23 check_admin_referer( 'bp_new_signup' ); 6 24 7 if( is_array( get_site_option( 'illegal_names' )) && $_GET[ 'new' ] != '' && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) { 8 wp_redirect( "http://{$current_site->domain}{$current_site->path}" ); 9 die(); 25 require_once( ABSPATH . WPINC . '/registration.php' ); 26 27 /* Check the base account details for problems */ 28 $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] ); 29 30 /* If there are errors with account details, set them for display */ 31 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 32 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; 33 34 if ( !empty( $account_details['errors']->errors['user_email'] ) ) 35 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 36 37 /* Check that both password fields are filled in */ 38 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) 39 $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' ); 40 41 /* Check that the passwords match */ 42 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) 43 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); 44 45 /* Now we've checked account details, we can check profile information */ 46 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 47 48 /* Loop through the posted fields formatting any datebox values then validate the field */ 49 foreach ( (array) $profile_field_ids as $field_id ) { 50 if ( !isset( $_POST['field_' . $field_id] ) ) { 51 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 52 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 53 } 54 55 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) ) 56 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); 57 } 58 59 /* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */ 60 if ( isset( $_POST['signup_with_blog'] ) ) { 61 $active_signup = get_site_option( 'registration' ); 62 63 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 64 $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 65 66 /* If there are errors with blog details, set them for display */ 67 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) 68 $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; 69 70 if ( !empty( $blog_details['errors']->errors['blog_title'] ) ) 71 $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0]; 72 } 73 } 74 75 do_action( 'bp_signup_validate' ); 76 77 /* Add any errors to the action for the field in the template for display. */ 78 if ( !empty( $bp->signup->errors ) ) { 79 foreach ( $bp->signup->errors as $fieldname => $error_message ) 80 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) ); 81 } else { 82 $bp->signup->step = 'save-details'; 83 84 /* No errors! Let's register those deets. */ 85 $active_signup = get_site_option( 'registration' ); 86 87 if ( 'none' != $active_signup ) { 88 89 /* Let's compact any profile field info into usermeta */ 90 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 91 92 /* Loop through the posted fields formatting any datebox values then add to usermeta */ 93 foreach ( (array) $profile_field_ids as $field_id ) { 94 if ( !isset( $_POST['field_' . $field_id] ) ) { 95 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 96 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 97 } 98 99 if ( !empty( $_POST['field_' . $field_id] ) ) 100 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; 101 } 102 103 /* Hash and store the password */ 104 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 105 106 /* If the user decided to create a blog, save those details to usermeta */ 107 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 108 $usermeta['public'] = $_POST['signup_blog_privacy']; 109 $usermeta['blogname'] = $_POST['signup_blog_url']; 110 $usermeta['blog_title'] = $_POST['signup_blog_title']; 111 } 112 113 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 114 115 /* Finally, sign up the user */ 116 wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 117 118 $bp->signup->step = 'completed-confirmation'; 119 } 120 121 do_action( 'bp_complete_signup' ); 122 } 123 10 124 } 125 126 $bp->avatar_admin->step = 'upload-image'; 127 128 /* If user has uploaded a new avatar */ 129 if ( !empty( $_FILES ) ) { 130 131 /* Check the nonce */ 132 check_admin_referer( 'bp_avatar_upload' ); 133 134 /* Get the activation key */ 135 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' ] ) ) ) { 136 bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) ); 137 } else { 138 /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */ 139 $bp->signup->avatar_dir = wp_hash( $bp->signup->key ); 140 141 /* Pass the file to the avatar upload handler */ 142 $errors = bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ); 143 144 if ( !$errors ) { 145 $bp->signup->step = 'completed-confirmation'; 146 $bp->avatar_admin->step = 'crop-image'; 147 148 /* Make sure we include the jQuery jCrop file for image cropping */ 149 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 150 } 151 } 152 } 153 154 /* If the image cropping is done, crop the image and save a full/thumb version */ 155 if ( isset( $_POST['avatar-crop-submit'] ) ) { 156 157 /* Check the nonce */ 158 check_admin_referer( 'bp_avatar_cropstore' ); 159 160 /* Reset the avatar step so we can show the upload form again if needed */ 161 $bp->signup->step = 'completed-confirmation'; 162 $bp->avatar_admin->step = 'upload-image'; 163 164 if ( !bp_core_avatar_handle_crop( array( 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) ) 165 bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ) ); 166 else 167 bp_core_add_message( __( 'Your new avatar was uploaded successfully', 'buddypress' ) ); 168 169 } 170 171 bp_core_load_template( 'register' ); 172 } 173 add_action( 'wp', 'bp_core_screen_signup', 3 ); 174 175 function bp_core_signup_avatar_upload_dir() { 176 global $bp; 177 178 if ( !$bp->signup->avatar_dir ) 179 return false; 180 181 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 182 $newdir = path_join( ABSPATH, $path ); 183 $newdir .= '/avatars/signups/' . $bp->signup->avatar_dir; 184 185 $newbdir = $newdir; 186 187 if ( !file_exists( $newdir ) ) 188 @wp_mkdir_p( $newdir ); 189 190 $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $bp->signup->avatar_dir; 191 $newburl = $newurl; 192 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 193 194 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 11 195 } 12 196 13 function bp_core_signup_do_headers() {14 do_action("signup_header");15 }16 add_action( 'wp_head', 'bp_core_signup_do_headers' );17 197 18 function bp_core_signup_register_headers() {19 echo "<meta name='robots' content='noindex,nofollow' />\n";20 }21 198 22 function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { 23 global $current_site; 24 25 ?> 26 <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3> 27 <p id="blog-details-help"> 28 <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?> 29 </p> 30 31 <div id="blog-details-fields"> 32 <?php 33 34 // Blog name 35 if ( 'no' == constant( "VHOST" ) ) 36 echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>'; 37 else 38 echo '<label for="blogname">' . __('Blog Domain:', 'buddypress') . '</label>'; 39 40 if ( $errmsg = $errors->get_error_message('blogname') ) { ?> 41 <p class="error"><?php echo $errmsg ?></p> 42 <?php } 43 44 if ( 'no' == constant( "VHOST" ) ) { 45 echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />'; 46 } else { 47 echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />'; 48 } 49 50 if ( !is_user_logged_in() ) { 51 echo '<p class="help-text">'; 52 print '(<strong>' . __( 'Your address will be ', 'buddypress' ); 53 if( 'no' == constant( "VHOST" ) ) { 54 print $current_site->domain . $current_site->path . __( 'blogname', 'buddypress' ); 55 } else { 56 print __( 'domain.', 'buddypress' ) . $current_site->domain . $current_site->path; 57 } 58 echo '</strong>. ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)', 'buddypress' ) . '</p>'; 59 echo '</p>'; 60 } 61 62 // Blog Title 63 ?> 64 <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label> 65 <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?> 66 <p class="error"><?php echo $errmsg ?></p> 67 <?php } 68 echo '<input name="blog_title" type="text" id="blog_title" value="'.wp_specialchars($blog_title, 1).'" /></p>'; 69 ?> 70 71 <p> 72 <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label> 73 <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?> 74 <label class="checkbox" for="blog_public_on"> 75 <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 } ?> /> 76 <?php _e( 'Yes', 'buddypress' ); ?> 77 </label> 78 <label class="checkbox" for="blog_public_off"> 79 <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if( isset( $_POST['blog_public'] ) && '0' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> /> 80 <?php _e( 'No', 'buddypress' ); ?> 81 </label> 82 </p> 83 </div> 84 <?php 85 do_action('signup_blogform', $errors); 86 } 87 88 function bp_core_signup_validate_blog_form() { 89 $user = ''; 90 if ( is_user_logged_in() ) 91 $user = wp_get_current_user(); 92 93 return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user); 94 } 95 96 function bp_core_signup_show_user_form($user_name = '', $user_email = '', $errors = '') { 97 // User name 98 echo '<div id="account-fields">'; 99 echo '<label for="user_name">' . __( 'Username:', 'buddypress' ) . '</label>'; 100 if ( $errmsg = $errors->get_error_message('user_name') ) { 101 echo '<p class="error">'.$errmsg.'</p>'; 102 } 103 echo '<input name="user_name" type="text" id="user_name" value="'.$user_name.'" maxlength="50" />'; 104 echo '<p class="help-text">'; 105 _e( '(Must be at least 4 characters, letters and numbers only.)', 'buddypress' ); 106 echo '</p>' 107 ?> 108 109 <label for="user_email"><?php _e( 'Email Address:', 'buddypress' ) ?></label> 110 <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?> 111 <p class="error"><?php echo $errmsg ?></p> 112 <?php } ?> 113 <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> 114 <?php 115 if ( $errmsg = $errors->get_error_message('generic') ) { 116 echo '<p class="error">'.$errmsg.'</p>'; 117 } 118 echo '</div>'; 119 120 echo '<div id="extra-fields">'; 121 do_action( 'signup_extra_fields', $errors ); 122 echo '</div>'; 123 } 124 125 function bp_core_signup_validate_user_form() { 126 return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); 127 } 128 129 function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') { 130 global $current_user, $current_site; 131 132 if ( ! is_wp_error($errors) ) { 133 $errors = new WP_Error(); 134 } 135 136 // allow definition of default variables 137 $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors )); 138 $blogname = $filtered_results['blogname']; 139 $blog_title = $filtered_results['blog_title']; 140 $errors = $filtered_results['errors']; 141 142 ?> 143 <h3><?php _e( "You're already registered!", 'buddypress' )?></h3> 144 <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?> 145 146 147 <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> 148 149 <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>"> 150 <input type="hidden" name="stage" value="gimmeanotherblog" /> 151 <?php do_action( "signup_hidden_fields" ); ?> 152 <?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?> 153 <p> 154 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Create Blog »') ?>"/> 155 </p> 156 </form> 157 <?php 158 } 159 160 function bp_core_signup_validate_another_blog_signup() { 161 global $wpdb, $current_user, $blogname, $blog_title, $errors, $domain, $path; 162 $current_user = wp_get_current_user(); 163 if( !is_user_logged_in() ) 164 die(); 165 166 $result = bp_core_signup_validate_blog_form(); 167 extract($result); 168 169 if ( $errors->get_error_code() ) { 170 bp_core_signup_signup_another_blog($blogname, $blog_title, $errors); 171 return false; 172 } 173 174 $public = (int) $_POST['blog_public']; 175 $meta = apply_filters('signup_create_blog_meta', array ('lang_id' => 1, 'public' => $public)); // depreciated 176 $meta = apply_filters( "add_signup_meta", $meta ); 177 178 wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid ); 179 bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta); 180 return true; 181 } 182 183 function bp_core_signup_confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email = '', $meta = '') { 184 ?> 185 <h2><?php printf( __( 'The blog %s is yours.', 'buddypress' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2> 186 <p> 187 <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new blog. <a href="%3$s">Login</a> as "%4$s" using your existing password.', 'buddypress' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "/wp-login.php", $user_name) ?> 188 </p> 189 <?php 190 do_action('signup_finished'); 191 } 192 193 function bp_core_signup_signup_user($user_name = '', $user_email = '', $errors = '') { 194 global $current_site, $active_signup; 195 196 $active_signup = get_site_option( 'registration' ); 197 198 if ( !is_wp_error($errors) ) 199 $errors = new WP_Error(); 200 if( isset( $_POST[ 'signup_for' ] ) ) { 201 $signup[ wp_specialchars( $_POST[ 'signup_for' ] ) ] = 'checked="checked"'; 202 } else { 203 $signup[ 'blog' ] = 'checked="checked"'; 204 } 205 206 // allow definition of default variables 207 $filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors )); 208 $user_name = $filtered_results['user_name']; 209 $user_email = $filtered_results['user_email']; 210 $errors = $filtered_results['errors']; 211 212 ?> 213 214 <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>"> 215 <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> 216 <input type="hidden" name="stage" value="validate-user-signup" /> 217 <?php do_action( "signup_hidden_fields" ); ?> 218 219 <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?> 220 221 <?php if( 'blog' == $active_signup ) { ?> 222 <input id="signupblog" type="hidden" name="signup_for" value="blog" /> 223 <?php } elseif( 'user' == $active_signup ) { ?> 224 <input id="signupblog" type="hidden" name="signup_for" value="user" /> 225 <?php } else { ?> 226 <div id="blog-or-username"> 227 <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3> 228 <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> 229 230 <div id="blog-or-username-fields"> 231 <p> 232 <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> /> 233 <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label> 234 </p> 235 236 <p> 237 <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> /> 238 <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label> 239 </p> 240 </div> 241 </div> 242 <?php } ?> 243 244 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Next »') ?>"/> 245 </form> 246 <?php 247 } 248 249 function bp_core_signup_validate_user_signup() { 250 $result = bp_core_signup_validate_user_form(); 251 extract($result); 252 253 if ( $errors->get_error_code() ) { 254 bp_core_signup_signup_user($user_name, $user_email, $errors); 255 return false; 256 } 257 258 if ( 'blog' == $_POST['signup_for'] ) { 259 bp_core_signup_signup_blog($user_name, $user_email); 260 return false; 261 } 262 263 wpmu_signup_user($user_name, $user_email, apply_filters( "add_signup_meta", array() ) ); 264 265 bp_core_signup_confirm_user_signup($user_name, $user_email); 266 return true; 267 } 268 269 function bp_core_signup_confirm_user_signup($user_name, $user_email) { 270 ?> 271 <h3><?php _e( 'Congratulations, you are now registered!', 'buddypress' ) ?></h3> 272 <p><?php printf(__('Your new username is: %s', 'buddypress' ), $user_name) ?></p> 273 <p> </p> 274 <p><?php printf(__('Before you can start using your new username, <strong>you must activate it</strong>. Check your inbox at <strong>%1$s</strong> and click the link given.', 'buddypress' ), $user_email) ?></p> 275 <p><?php _e('If you do not activate your username within two days, you will have to sign up again.', 'buddypress' ); ?></p> 276 <?php 277 do_action('signup_finished'); 278 } 279 280 function bp_core_signup_signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') { 281 if ( !is_wp_error($errors) ) 282 $errors = new WP_Error(); 283 284 // allow definition of default variables 285 $filtered_results = apply_filters('signup_blog_init', array('user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors )); 286 $user_name = $filtered_results['user_name']; 287 $user_email = $filtered_results['user_email']; 288 $blogname = $filtered_results['blogname']; 289 $blog_title = $filtered_results['blog_title']; 290 $errors = $filtered_results['errors']; 291 292 if ( empty($blogname) ) 293 $blogname = $user_name; 294 ?> 295 <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>"> 296 <input type="hidden" name="stage" value="validate-blog-signup" /> 297 <input type="hidden" name="user_name" value="<?php echo $user_name ?>" /> 298 <input type="hidden" name="user_email" value="<?php echo $user_email ?>" /> 299 <?php do_action( "signup_hidden_fields" ); ?> 300 <?php bp_core_signup_show_blog_form($blogname, $blog_title, $errors); ?> 301 <p> 302 <input id="submit" type="submit" name="submit" class="submit" value="<?php _e('Signup »') ?>"/></p> 303 </form> 304 <?php 305 } 306 307 function bp_core_signup_validate_blog_signup() { 308 // Re-validate user info. 309 $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']); 310 extract($result); 311 312 if ( $errors->get_error_code() ) { 313 bp_core_signup_signup_user($user_name, $user_email, $errors); 314 return false; 315 } 316 317 $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']); 318 extract($result); 319 320 if ( $errors->get_error_code() ) { 321 bp_core_signup_signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); 322 return false; 323 } 324 325 $public = (int) $_POST['blog_public']; 326 $meta = array ('lang_id' => 1, 'public' => $public); 327 $meta = apply_filters( "add_signup_meta", $meta ); 328 329 wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); 330 bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta); 331 return true; 332 } 333 334 function bp_core_signup_confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) { 335 ?> 336 <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3> 337 338 <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> 339 <p> </p> 340 341 <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3> 342 <p> 343 <?php _e( "If you haven't received your email yet, there are a number of things you can do:", 'buddypress' ) ?> 344 <ul> 345 <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'buddypress' ) ?></strong></p></li> 346 <li><p><?php _e( 'Check the junk email or spam folder of your email client. Sometime emails wind up there by mistake.', 'buddypress' ) ?></p></li> 347 <li><?php printf( __( "Have you entered your email correctly? We think it's %s but if you've entered it incorrectly, you won't receive it.", 'buddypress' ), $user_email) ?></li> 348 </ul> 349 </p> 350 <?php 351 do_action('signup_finished'); 352 } 353 354 function bp_core_signup_do_signup() { 355 // Main 356 $active_signup = get_site_option( 'registration' ); 357 if( !$active_signup ) 358 $active_signup = 'all'; 359 360 $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user" 361 362 if( is_site_admin() ) 363 echo '<div class="mu_alert">' . sprintf( __( "Greetings Site Administrator! You are currently allowing '%s' registrations. To change or disable registration go to your <a href='wp-admin/wpmu-options.php'>Options page</a>.", 'buddypress' ), $active_signup ) . '</div>'; 364 365 $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null; 366 367 $current_user = wp_get_current_user(); 368 if( $active_signup == "none" ) { 369 _e( "Registration has been disabled.", 'buddypress' ); 370 } elseif( $active_signup == 'blog' && !is_user_logged_in() ){ 371 if( is_ssl() ) { 372 $proto = 'https://'; 373 } else { 374 $proto = 'http://'; 375 } 376 $login_url = site_url( 'wp-login.php?redirect_to=' . site_url(BP_REGISTER_SLUG) ); 377 echo sprintf( __( "You must first <a href=\"%s\">login</a>, and then you can create a new blog.", 'buddypress' ), $login_url ); 378 } else { 379 switch ($_POST['stage']) { 380 case 'validate-user-signup' : 381 if( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) 382 bp_core_signup_validate_user_signup(); 383 else 384 _e( "User registration has been disabled.", 'buddypress' ); 385 break; 386 case 'validate-blog-signup': 387 if( $active_signup == 'all' || $active_signup == 'blog' ) 388 bp_core_signup_validate_blog_signup(); 389 else 390 _e( "Blog registration has been disabled.", 'buddypress' ); 391 break; 392 case 'gimmeanotherblog': 393 bp_core_signup_validate_another_blog_signup(); 394 break; 395 default : 396 $user_email = $_POST[ 'user_email' ]; 397 do_action( "preprocess_signup_form" ); // populate the form from invites, elsewhere? 398 if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) { 399 bp_core_signup_signup_another_blog($newblogname); 400 } elseif( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) ) { 401 bp_core_signup_signup_user( $newblogname, $user_email ); 402 } elseif( is_user_logged_in() == false && ( $active_signup == 'blog' ) ) { 403 _e( "I'm sorry. We're not accepting new registrations at this time.", 'buddypress' ); 404 } else { 405 _e( "You're logged in already. No need to register again!", 'buddypress' ); 406 } 407 if ($newblogname) { 408 if( constant( "VHOST" ) == 'no' ) 409 $newblog = 'http://' . $current_site->domain . $current_site->path . $newblogname . '/'; 410 else 411 $newblog = 'http://' . $newblogname . '.' . $current_site->domain . $current_site->path; 412 if ($active_signup == 'blog' || $active_signup == 'all') 413 printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist but you can create it now!</em></p>", 'buddypress' ), $newblog ); 414 else 415 printf( __( "<p><em>The blog you were looking for, <strong>%s</strong> doesn't exist.</em></p>", 'buddypress' ), $newblog ); 416 } 417 break; 418 } 419 } 420 } 199 ?> -
trunk/bp-core/bp-core-templatetags.php
r1608 r1636 140 140 } 141 141 142 function bp_get_options_title() { 143 global $bp; 144 145 if ( empty( $bp->bp_options_title ) ) 146 $bp->bp_options_title = __( 'Options', 'buddypress' ); 147 148 echo apply_filters( 'bp_get_options_avatar', attribute_escape( $bp->bp_options_title ) ); 149 } 150 151 152 /** AVATAR TEMPLATE TAGS *******************************************************/ 153 142 154 /** 143 155 * bp_has_options_avatar() … … 159 171 } 160 172 161 /**162 * bp_get_options_avatar()163 * TEMPLATE TAG164 *165 * Gets the avatar for the current sub nav (eg friends avatar or group avatar).166 * Does not check if there is one - so always use if ( bp_has_options_avatar() )167 *168 * @package BuddyPress Core169 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()170 */171 173 function bp_get_options_avatar() { 172 174 global $bp; 173 175 174 176 echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar ); 175 }176 177 function bp_get_options_title() {178 global $bp;179 180 if ( empty( $bp->bp_options_title ) )181 $bp->bp_options_title = __( 'Options', 'buddypress' );182 183 echo apply_filters( 'bp_get_options_avatar', attribute_escape( $bp->bp_options_title ) );184 177 } 185 178 … … 187 180 global $comment; 188 181 189 if ( function_exists('bp_core_ get_avatar') ) {190 echo apply_filters( 'bp_comment_author_avatar', bp_core_ get_avatar( $comment->user_id, 1) );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' ) ) ); 191 184 } else if ( function_exists('get_avatar') ) { 192 185 get_avatar(); … … 197 190 global $post; 198 191 199 if ( function_exists('bp_core_ get_avatar') ) {200 echo apply_filters( 'bp_post_author_avatar', bp_core_ get_avatar( $post->post_author, 1) );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' ) ) ); 201 194 } else if ( function_exists('get_avatar') ) { 202 195 get_avatar(); … … 204 197 } 205 198 206 function bp_loggedinuser_avatar( $width = false, $height = false ) { 207 global $bp; 208 209 if ( $width && $height ) 210 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2, $width, $height ) ); 211 else 212 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2 ) ); 213 } 214 215 function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) { 216 global $bp; 217 218 if ( $width && $height ) 219 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1, $width, $height ) ); 220 else 221 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1 ) ); 199 function bp_loggedin_user_avatar( $args = '' ) { 200 echo bp_get_loggedin_user_avatar( $args ); 201 } 202 function bp_get_loggedin_user_avatar( $args = '' ) { 203 global $bp; 204 205 $defaults = array( 206 'type' => 'thumb', 207 'width' => false, 208 'height' => false 209 ); 210 211 $r = wp_parse_args( $args, $defaults ); 212 extract( $r, EXTR_SKIP ); 213 214 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'user_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 215 } 216 217 function bp_displayed_user_avatar( $args = '' ) { 218 echo bp_get_displayed_user_avatar( $args ); 219 } 220 function bp_get_displayed_user_avatar( $args = '' ) { 221 global $bp; 222 223 $defaults = array( 224 'type' => 'thumb', 225 'width' => false, 226 'height' => false 227 ); 228 229 $r = wp_parse_args( $args, $defaults ); 230 extract( $r, EXTR_SKIP ); 231 232 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'user_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 233 } 234 235 function bp_avatar_admin_step() { 236 echo bp_get_avatar_admin_step(); 237 } 238 function bp_get_avatar_admin_step() { 239 global $bp; 240 241 return apply_filters( 'bp_get_avatar_admin_step', $bp->avatar_admin->step ); 242 } 243 244 function bp_avatar_to_crop() { 245 echo bp_get_avatar_to_crop(); 246 } 247 function bp_get_avatar_to_crop() { 248 global $bp; 249 250 return apply_filters( 'bp_get_avatar_to_crop', $bp->avatar_admin->image->url ); 251 } 252 253 function bp_avatar_to_crop_src() { 254 echo bp_get_avatar_to_crop_src(); 255 } 256 function bp_get_avatar_to_crop_src() { 257 global $bp; 258 259 return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) ); 260 } 261 262 function bp_avatar_cropper() { 263 global $bp; 264 265 echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />'; 222 266 } 223 267 … … 233 277 234 278 return false; 235 }236 237 /* DEPRECATED Use: bp_core_get_user_displayname() */238 function bp_fetch_user_fullname( $user_id, $echo = true ) {239 if ( $echo )240 echo apply_filters( 'bp_fetch_user_fullname', bp_core_get_user_displayname( $user_id ) );241 else242 return apply_filters( 'bp_fetch_user_fullname', bp_core_get_user_displayname( $user_id ) );243 279 } 244 280 … … 255 291 else 256 292 return apply_filters( 'bp_last_activity', $last_activity ); 257 }258 259 function bp_the_avatar() {260 global $bp;261 echo apply_filters( 'bp_the_avatar', bp_core_get_avatar( $bp->displayed_user->id, 2 ) );262 }263 264 function bp_the_avatar_thumbnail() {265 global $bp;266 echo apply_filters( 'bp_the_avatar_thumbnail', bp_core_get_avatar( $bp->displayed_user->id, 1 ) );267 293 } 268 294 … … 748 774 } 749 775 776 /*** Signup form template tags **********************/ 777 778 function bp_signup_username_value() { 779 echo bp_get_signup_username_value(); 780 } 781 function bp_get_signup_username_value() { 782 return apply_filters( 'bp_get_signup_username_value', $_POST['signup_username'] ); 783 } 784 785 function bp_signup_email_value() { 786 echo bp_get_signup_email_value(); 787 } 788 function bp_get_signup_email_value() { 789 return apply_filters( 'bp_get_signup_email_value', $_POST['signup_email'] ); 790 } 791 792 function bp_signup_with_blog_value() { 793 echo bp_get_signup_with_blog_value(); 794 } 795 function bp_get_signup_with_blog_value() { 796 return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] ); 797 } 798 799 function bp_signup_blog_url_value() { 800 echo bp_get_signup_blog_url_value(); 801 } 802 function bp_get_signup_blog_url_value() { 803 return apply_filters( 'bp_get_signup_blog_url_value', $_POST['signup_blog_url'] ); 804 } 805 806 function bp_signup_blog_title_value() { 807 echo bp_get_signup_blog_title_value(); 808 } 809 function bp_get_signup_blog_title_value() { 810 return apply_filters( 'bp_get_signup_blog_title_value', $_POST['signup_blog_title'] ); 811 } 812 813 function bp_signup_blog_privacy_value() { 814 echo bp_get_signup_blog_privacy_value(); 815 } 816 function bp_get_signup_blog_privacy_value() { 817 return apply_filters( 'bp_get_signup_blog_privacy_value', $_POST['signup_blog_privacy'] ); 818 } 819 820 function bp_signup_avatar_dir_value() { 821 echo bp_get_signup_avatar_dir_value(); 822 } 823 function bp_get_signup_avatar_dir_value() { 824 global $bp; 825 826 return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir ); 827 } 828 829 function bp_current_signup_step() { 830 echo bp_get_current_signup_step(); 831 } 832 function bp_get_current_signup_step() { 833 global $bp; 834 835 return $bp->signup->step; 836 } 837 838 function bp_signup_avatar( $args = '' ) { 839 echo bp_get_signup_avatar( $args = '' ); 840 } 841 function bp_get_signup_avatar( $args = '' ) { 842 global $bp; 843 844 $defaults = array( 845 'size' => BP_AVATAR_FULL_WIDTH, 846 'class' => 'avatar', 847 'alt' => __( 'Your Avatar', 'buddypress' ) 848 ); 849 850 $r = wp_parse_args( $args, $defaults ); 851 extract( $r, EXTR_SKIP ); 852 853 $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir; 854 855 if ( empty( $signup_avatar_dir) ) { 856 if ( empty( $bp->grav_default ) ) { 857 $default_grav = 'wavatar'; 858 } else if ( 'mystery' == $bp->grav_default ) { 859 $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg'; 860 } else { 861 $default_grav = $bp->grav_default; 862 } 863 864 $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ); 865 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 . '" />'; 866 } else { 867 return apply_filters( 'bp_get_signup_avatar', bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) ) ); 868 } 869 } 870 750 871 751 872 /*** CUSTOM LOOP TEMPLATE CLASSES *******************/ -
trunk/bp-forums.php
r1621 r1636 266 266 } 267 267 268 function bp_forums_make_user_active_member( $user_id ) {269 update_usermeta( $user_id, 'bb_capabilities', array( 'member' => true ) );270 }271 add_action( 'wpmu_new_user', 'bp_forums_make_user_active_member' );272 273 function bp_forums_get_keymaster() {274 global $wpdb;275 276 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'bb_capabilities' AND meta_value LIKE '%%keymaster%%'" ) );277 278 return get_userdata( $user_id );279 }280 281 268 // List actions to clear super cached pages on, if super cache is installed 282 269 add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' ); … … 284 271 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' ); 285 272 286 function b b_forums_filter_caps( $allcaps ) {273 function bp_forums_filter_caps( $allcaps ) { 287 274 global $bp, $wp_roles, $bb_table_prefix; 288 275 … … 298 285 return array_merge( (array) $allcaps, (array) $bb_cap ); 299 286 } 300 add_filter( 'user_has_cap', 'b b_forums_filter_caps' );287 add_filter( 'user_has_cap', 'bp_forums_filter_caps' ); 301 288 ?> -
trunk/bp-forums/bp-forums-bbpress.php
r1627 r1636 1 1 <?php 2 3 function bp_forums_on_activation() { 4 echo "here"; die; 5 } 6 add_action( 'activate_bp-loader.php', 'bp_forums_on_activate' ); 2 7 3 8 function bp_forums_load_bbpress() { … … 35 40 require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' ); 36 41 42 require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' ); 43 37 44 $bb = new stdClass(); 38 45 require_once( $bp->forums->bbconfig ); … … 64 71 define( 'BB_INSTALLING', false ); 65 72 66 /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */67 if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )68 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );69 70 require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );71 72 73 if ( is_object( $wp_roles ) ) { 73 74 $bb_roles =& $wp_roles; … … 92 93 93 94 /* Check if the tables are installed, if not, install them */ 94 if ( ! $tables_installed) {95 if ( !(boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) { 95 96 require_once( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' ); 96 97 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' ); 98 97 99 dbDelta( $bb_queries ); 98 100 -
trunk/bp-forums/bp-forums-templatetags.php
r1621 r1636 212 212 extract( $r, EXTR_SKIP ); 213 213 214 if ( 'thumb' == $type ) 215 $size = 1; 216 else 217 $size = 2; 218 219 if ( $width && $height ) 220 $av = bp_core_get_avatar( $forum_template->topic->topic_poster, $size, $width, $height ); 221 else 222 $av = bp_core_get_avatar( $forum_template->topic->topic_poster, $size ); 223 224 return apply_filters( 'bp_get_the_topic_poster_avatar', $av ); 214 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 ) ) ); 225 215 } 226 216 … … 258 248 extract( $r, EXTR_SKIP ); 259 249 260 if ( 'thumb' == $type ) 261 $size = 1; 262 else 263 $size = 2; 264 265 if ( $width && $height ) 266 $av = bp_core_get_avatar( $forum_template->topic->topic_last_poster, $size, $width, $height ); 267 else 268 $av = bp_core_get_avatar( $forum_template->topic->topic_last_poster, $size ); 269 270 return apply_filters( 'bp_get_the_topic_last_poster_avatar', $av ); 250 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 ) ) ); 271 251 } 272 252 … … 666 646 extract( $r, EXTR_SKIP ); 667 647 668 if ( 'thumb' == $type ) 669 $size = 1; 670 else 671 $size = 2; 672 673 if ( $width && $height ) 674 $av = bp_core_get_avatar( $topic_template->post->poster_id, $size, $width, $height ); 675 else 676 $av = bp_core_get_avatar( $topic_template->post->poster_id, $size ); 677 678 return apply_filters( 'bp_get_the_topic_post_poster_avatar', $av ); 648 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 ) ) ); 679 649 } 680 650 -
trunk/bp-friends.php
r1599 r1636 8 8 9 9 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' ); 10 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-ajax.php' );11 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-cssjs.php' );12 10 require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' ); 11 12 /* Include deprecated functions if settings allow */ 13 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 14 require ( BP_PLUGIN_DIR . '/bp-friends/deprecated/bp-friends-deprecated.php' ); 13 15 14 16 function friends_install() { … … 39 41 40 42 $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends'; 41 $bp->friends->image_base = BP_PLUGIN_URL . '/bp-friends/images';42 43 $bp->friends->format_activity_function = 'friends_format_activity'; 43 44 $bp->friends->format_notification_function = 'friends_format_notifications'; … … 78 79 $bp->bp_options_title = __( 'My Friends', 'buddypress' ); 79 80 } else { 80 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);81 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 81 82 $bp->bp_options_title = $bp->displayed_user->fullname; 82 83 } -
trunk/bp-friends/bp-friends-templatetags.php
r1599 r1636 414 414 <?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?> 415 415 <li> 416 <a href="<?php echo bp_core_get_userurl( $friend_ids[$i] ) ?>"><?php echo bp_core_ get_avatar( $friend_ids[$i], 1) ?></a>416 <a href="<?php echo bp_core_get_userurl( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a> 417 417 <h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5> 418 418 </li> … … 441 441 <?php for ( $i = 0; $i < count( $user_ids['users'] ); $i++ ) { ?> 442 442 <li> 443 <a href="<?php echo bp_core_get_userurl( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_ get_avatar( $user_ids['users'][$i]->user_id, 1) ?></a>443 <a href="<?php echo bp_core_get_userurl( $user_ids['users'][$i]->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->user_id, 'type' => 'thumb' ) ) ?></a> 444 444 <h5><?php echo bp_core_get_userlink($user_ids['users'][$i]->user_id) ?></h5> 445 445 <?php if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?> -
trunk/bp-groups.php
r1626 r1636 1 1 <?php 2 2 3 define ( 'BP_GROUPS_DB_VERSION', '13 50' );3 define ( 'BP_GROUPS_DB_VERSION', '1300' ); 4 4 5 5 /* Define the slug for the component */ … … 8 8 9 9 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' ); 10 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-ajax.php' );11 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-cssjs.php' );12 10 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' ); 13 11 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-widgets.php' ); 14 12 require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' ); 13 14 /* Include deprecated functions if settings allow */ 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' ); 15 17 16 18 function groups_install() { … … 27 29 description longtext NOT NULL, 28 30 news longtext NOT NULL, 29 status varchar(10) NOT NULL DEFAULT ' open',31 status varchar(10) NOT NULL DEFAULT 'public', 30 32 enable_wire tinyint(1) NOT NULL DEFAULT '1', 31 33 enable_forum tinyint(1) NOT NULL DEFAULT '1', … … 34 36 avatar_full varchar(250) NOT NULL, 35 37 KEY creator_id (creator_id), 36 KEY status (status) 38 KEY status (status), 37 39 ) {$charset_collate};"; 38 40 … … 96 98 } 97 99 98 function groups_setup_globals( $no_global = false ) { 99 global $wpdb; 100 101 if ( !$no_global ) 102 global $bp; 103 100 function groups_setup_globals() { 101 global $bp, $wpdb; 102 104 103 $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups'; 105 104 $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members'; 106 105 $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta'; 107 $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/images';108 106 $bp->groups->format_notification_function = 'groups_format_notifications'; 109 107 $bp->groups->slug = BP_GROUPS_SLUG; … … 126 124 } 127 125 add_action( 'plugins_loaded', 'groups_setup_globals', 5 ); 128 add_action( 'admin_menu', 'groups_setup_globals', 1);126 add_action( 'admin_menu', 'groups_setup_globals', 2 ); 129 127 130 128 function groups_setup_root_component() { … … 203 201 } else if ( !bp_is_home() && !$bp->is_single_item ) { 204 202 205 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);203 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 206 204 $bp->bp_options_title = $bp->displayed_user->fullname; 207 205 … … 217 215 218 216 $bp->bp_options_title = $bp->groups->current_group->name; 219 $bp->bp_options_avatar = '<img src="' . $bp->groups->current_group->avatar_thumb . '" alt="Group Avatar Thumbnail" />'; 217 218 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' ) ) ) ) 219 $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />'; 220 220 221 221 $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/'; … … 276 276 $bp->is_directory = true; 277 277 278 wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ));278 do_action( 'groups_directory_groups_setup' ); 279 279 bp_core_load_template( apply_filters( 'groups_template_directory_groups', 'directories/groups/index' ) ); 280 280 } … … 307 307 $group_id = $bp->action_variables[1]; 308 308 309 if ( isset($bp->action_variables) && in_array( 'accept', $bp->action_variables ) && is_numeric($group_id) ) {309 if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) { 310 310 /* Check the nonce */ 311 311 if ( !check_admin_referer( 'groups_accept_invite' ) ) … … 330 330 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); 331 331 332 } else if ( isset($bp->action_variables) && in_array( 'reject', $bp->action_variables ) && is_numeric($group_id) ) {332 } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) { 333 333 /* Check the nonce */ 334 334 if ( !check_admin_referer( 'groups_reject_invite' ) ) … … 358 358 global $bp; 359 359 360 $bp->groups->completed_create_steps = array(); 360 error_log( $bp->action_variables[0] ); 361 error_log( $bp->action_variables[1] ); 361 362 362 363 /* If no current step is set, reset everything so we can start a fresh group creation */ 363 364 if ( !$bp->groups->current_create_step = $bp->action_variables[1] ) { 365 364 366 unset( $bp->groups->current_create_step ); 365 367 unset( $bp->groups->completed_create_steps ); … … 369 371 370 372 $reset_steps = true; 371 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) );373 //bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) ); 372 374 } 373 375 … … 375 377 if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) { 376 378 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 377 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create' );379 //bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create' ); 378 380 } 379 381 … … 387 389 $bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id, false, false ); 388 390 } 389 390 /* If the save button is hit, lets calculate what we need to save */391 if ( isset( $_POST['save'] ) || isset( $_POST['skip'] )) {391 392 /* If the save, upload or skip button is hit, lets calculate what we need to save */ 393 if ( isset( $_POST['save'] ) ) { 392 394 393 395 /* Check the nonce */ … … 400 402 } 401 403 402 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']) ) ) ) ) {404 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() ) ) ) { 403 405 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 404 406 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step ); … … 447 449 } 448 450 } 449 450 if ( 'group-avatar' == $bp->groups->current_create_step ) {451 if ( !isset( $_POST['skip'] ) && $_POST['orig'] ) {452 // Image already cropped and uploaded, lets store a reference in the DB.453 if ( !wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !$result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $bp->groups->new_group_id ) )454 return false;455 456 // Success on group avatar cropping, now save the results.457 $avatar_hrefs = groups_get_avatar_hrefs($result);458 459 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'avatar_thumb' => stripslashes( $avatar_hrefs['thumb_href'] ), 'avatar_full' => stripslashes( $avatar_hrefs['full_href'] ) ) ) ) {460 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );461 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );462 }463 }464 }465 451 466 452 if ( 'group-invites' == $bp->groups->current_create_step ) { … … 476 462 * holding the information 477 463 */ 478 if ( !in_array( $bp->groups->current_create_step, $bp->groups->completed_create_steps ) )464 if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) ) 479 465 $bp->groups->completed_create_steps[] = $bp->groups->current_create_step; 480 481 /* Unset cookie info */482 setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );483 setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );484 466 485 467 /* Reset cookie info */ … … 492 474 unset( $bp->groups->completed_create_steps ); 493 475 494 bp_core_redirect( bp_get_group_permalink( $bp->groups-> new_group ) );476 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) ); 495 477 } else { 496 478 /** … … 510 492 } 511 493 512 /* Move onto the next step */513 494 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $next_step ); 514 495 } 515 496 } 516 497 498 /* Group avatar is handled seperately */ 499 if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) { 500 if ( !empty( $_FILES ) && isset( $_POST['upload'] ) ) { 501 /* Normally we would check a nonce here, but the group save nonce is used instead */ 502 503 /* Pass the file to the avatar upload handler */ 504 $errors = bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ); 505 506 if ( !$errors ) { 507 $bp->avatar_admin->step = 'crop-image'; 508 509 /* Make sure we include the jQuery jCrop file for image cropping */ 510 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 511 } 512 //var_dump($_COOKIE); 513 } 514 515 /* If the image cropping is done, crop the image and save a full/thumb version */ 516 if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) { 517 /* Normally we would check a nonce here, but the group save nonce is used instead */ 518 519 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'] ) ) ) 520 bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' ); 521 else 522 bp_core_add_message( __( 'The group avatar was uploaded successfully!', 'buddypress' ) ); 523 } 524 } 525 526 //var_dump($_COOKIE); 517 527 bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) ); 518 528 } … … 955 965 956 966 $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); 957 $status = ( in_array( $_POST['group-status'], $allowed_status ) ) ? $_POST['group-status'] : 'public';967 $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public'; 958 968 959 969 /* Check the nonce first. */ … … 990 1000 return false; 991 1001 992 if ( isset( $_POST['save'] ) ) { 993 994 // Image already cropped and uploaded, lets store a reference in the DB. 995 if ( !wp_verify_nonce($_POST['nonce'], 'slick_avatars') || !$result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'], false, 'groupavatar', $bp->groups->current_group->id ) ) 996 return false; 997 998 // Success on group avatar cropping, now save the results. 999 $avatar_hrefs = groups_get_avatar_hrefs($result); 1000 1001 // Delete the old group avatars first 1002 $avatar_thumb_path = groups_get_avatar_path( $bp->groups->current_group->avatar_thumb ); 1003 $avatar_full_path = groups_get_avatar_path( $bp->groups->current_group->avatar_full ); 1004 1005 @unlink($avatar_thumb_path); 1006 @unlink($avatar_full_path); 1007 1008 $bp->groups->current_group->avatar_thumb = stripslashes( $avatar_hrefs['thumb_href'] ); 1009 $bp->groups->current_group->avatar_full = stripslashes( $avatar_hrefs['full_href'] ); 1010 1011 if ( !$bp->groups->current_group->save() ) { 1012 bp_core_add_message( __( 'There was an error updating the group avatar, please try again.', 'buddypress' ), 'error' ); 1013 } else { 1014 bp_core_add_message( __( 'The group avatar was successfully updated.', 'buddypress' ) ); 1015 } 1016 1017 do_action( 'groups_group_avatar_updated', $bp->groups->current_group->id ); 1018 1019 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar' ); 1020 } 1021 1002 $bp->avatar_admin->step = 'upload-image'; 1003 1004 if ( !empty( $_FILES ) ) { 1005 1006 /* Check the nonce */ 1007 check_admin_referer( 'bp_avatar_upload' ); 1008 1009 /* Pass the file to the avatar upload handler */ 1010 $errors = bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ); 1011 1012 if ( !$errors ) { 1013 $bp->avatar_admin->step = 'crop-image'; 1014 1015 /* Make sure we include the jQuery jCrop file for image cropping */ 1016 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 1017 } 1018 1019 } 1020 1021 /* If the image cropping is done, crop the image and save a full/thumb version */ 1022 if ( isset( $_POST['avatar-crop-submit'] ) ) { 1023 1024 /* Check the nonce */ 1025 check_admin_referer( 'bp_avatar_cropstore' ); 1026 1027 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'] ) ) ) 1028 bp_core_add_message( __( 'There was a problem cropping the avatar, please try uploading it again', 'buddypress' ) ); 1029 else 1030 bp_core_add_message( __( 'The new group avatar was uploaded successfully!', 'buddypress' ) ); 1031 1032 } 1033 1022 1034 do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id ); 1023 1035 … … 1486 1498 1487 1499 /** 1488 * Possible parameters :1500 * Possible parameters (pass as assoc array): 1489 1501 * 'group_id' 1490 1502 * 'creator_id' … … 1656 1668 global $bp; 1657 1669 1658 return in_array( $status, $bp->groups->valid_status );1670 return in_array( $status, (array)$bp->groups->valid_status ); 1659 1671 } 1660 1672 … … 1665 1677 $slug = substr( $slug, 2, strlen( $slug ) - 2 ); 1666 1678 1667 if ( in_array( $slug, $bp->groups->forbidden_names ) ) {1679 if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) { 1668 1680 $slug = $slug . '-' . rand(); 1669 1681 } … … 1876 1888 /*** Group Avatars *************************************************************/ 1877 1889 1878 function groups_avatar_upload( $file ) { 1879 // validate the group avatar upload if there is one. 1880 $avatar_error = false; 1881 1882 // Set friendly error feedback. 1883 $uploadErrors = array( 1884 0 => __("There is no error, the file uploaded with success", 'buddypress'), 1885 1 => __("The uploaded file exceeds the upload_max_filesize directive in php.ini", 'buddypress'), 1886 2 => __("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 'buddypress'), 1887 3 => __("The uploaded file was only partially uploaded", 'buddypress'), 1888 4 => __("No file was uploaded", 'buddypress'), 1889 6 => __("Missing a temporary folder", 'buddypress') 1890 ); 1891 1892 if ( !bp_core_check_avatar_upload($file) ) { 1893 $avatar_error = true; 1894 $avatar_error_msg = __('Your group avatar upload failed, please try again. Error was: ' . $uploadErrors[$file['file']['error']] , 'buddypress'); 1895 } 1896 1897 else if ( !bp_core_check_avatar_size($file) ) { 1898 $avatar_error = true; 1899 $avatar_size = size_format(1024 * CORE_MAX_FILE_SIZE); 1900 $avatar_error_msg = __('The file you uploaded is too big. Please upload a file under', 'buddypress') . size_format(CORE_MAX_FILE_SIZE); 1901 } 1902 1903 else if ( !bp_core_check_avatar_type($file) ) { 1904 $avatar_error = true; 1905 $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.', 'buddypress'); 1906 } 1907 1908 // "Handle" upload into temporary location 1909 else if ( !$original = bp_core_handle_avatar_upload($file) ) { 1910 $avatar_error = true; 1911 $avatar_error_msg = __('Upload Failed! Please check the permissions on the group avatar upload directory.', 'buddypress'); 1912 } 1913 1914 if ( !$canvas = bp_core_resize_avatar($original) ) 1915 $canvas = $original; 1916 1917 if ( $avatar_error ) { ?> 1918 <div id="message" class="error"> 1919 <p><?php echo $avatar_error_msg ?></p> 1920 </div> 1921 <?php 1922 bp_core_render_avatar_upload_form( '', true ); 1923 } else { 1924 bp_core_render_avatar_cropper( $original, $canvas, null, null, false, $bp->loggedin_user->domain ); 1925 } 1926 } 1927 1928 function groups_get_avatar_hrefs( $avatars ) { 1929 global $bp; 1930 1931 $src = $bp->root_domain . '/'; 1932 1933 $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) ); 1934 $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) ); 1935 1936 return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href ); 1937 } 1938 1939 function groups_get_avatar_path( $avatar ) { 1940 global $bp; 1941 1942 $src = $bp->root_domain . '/'; 1943 1944 $path = str_replace( $src, ABSPATH, stripslashes( $avatar ) ); 1945 return $path; 1890 function groups_avatar_upload_dir() { 1891 global $bp; 1892 1893 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 1894 $newdir = path_join( ABSPATH, $path ); 1895 $newdir .= '/group-avatars/' . $bp->groups->current_group->id; 1896 1897 $newbdir = $newdir; 1898 1899 if ( !file_exists( $newdir ) ) 1900 @wp_mkdir_p( $newdir ); 1901 1902 $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/group-avatars/' . $user_id; 1903 $newburl = $newurl; 1904 $newsubdir = '/group-avatars/' . $bp->groups->current_group->id; 1905 1906 return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 1946 1907 } 1947 1908 … … 2549 2510 return true; 2550 2511 } 2551 2552 /*** Group Theme Handling ****************************************************/2553 2554 /**2555 * The following two functions will force the active member theme for2556 * groups pages, even though they are technically under the root "home" blog2557 * from a WordPress point of view.2558 */2559 2560 function groups_force_buddypress_theme( $template ) {2561 global $bp;2562 2563 if ( $bp->current_component != $bp->groups->slug )2564 return $template;2565 2566 $member_theme = get_site_option('active-member-theme');2567 2568 if ( empty($member_theme) )2569 $member_theme = 'bpmember';2570 2571 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );2572 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );2573 2574 return $member_theme;2575 }2576 add_filter( 'template', 'groups_force_buddypress_theme' );2577 2578 function groups_force_buddypress_stylesheet( $stylesheet ) {2579 global $bp;2580 2581 if ( $bp->current_component != $bp->groups->slug )2582 return $stylesheet;2583 2584 $member_theme = get_site_option('active-member-theme');2585 2586 if ( empty( $member_theme ) )2587 $member_theme = 'bpmember';2588 2589 add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );2590 add_filter( 'theme_root_uri', 'bp_core_filter_buddypress_theme_root_uri' );2591 2592 return $member_theme;2593 }2594 add_filter( 'stylesheet', 'groups_force_buddypress_stylesheet', 1, 1 );2595 2596 2512 2597 2513 /*** Group Cleanup Functions ****************************************************/ -
trunk/bp-groups/bp-groups-templatetags.php
r1621 r1636 65 65 66 66 function bp_group_avatar_edit_form() { 67 if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) { 68 groups_avatar_upload($_FILES); 69 } else { 70 bp_core_render_avatar_upload_form( '', true ); 71 } 67 groups_avatar_upload(); 72 68 } 73 69 … … 395 391 echo bp_get_group_avatar(); 396 392 } 397 function bp_get_group_avatar( $group = false ) { 398 global $groups_template; 399 400 if ( !$group ) 401 $group =& $groups_template->group; 402 403 return apply_filters( 'bp_get_group_avatar', '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />', $group->avatar_full, $group->avatar_name ); 393 function bp_get_group_avatar( $args = '' ) { 394 global $bp, $groups_template; 395 396 $defaults = array( 397 'type' => 'full', 398 'width' => false, 399 'height' => false, 400 'class' => 'avatar', 401 'id' => 'avatar-crop-preview', 402 'alt' => __( 'Group avatar', 'buddypress' ) 403 ); 404 405 $r = wp_parse_args( $args, $defaults ); 406 extract( $r, EXTR_SKIP ); 407 408 /* Fetch the avatar from the folder, if not provide backwards compat. */ 409 if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'id' => $id, 'class' => $class ) ) ) 410 $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />'; 411 412 return apply_filters( 'bp_get_group_avatar', $avatar ); 404 413 } 405 414 … … 408 417 } 409 418 function bp_get_group_avatar_thumb( $group = false ) { 410 global $groups_template; 411 412 if ( !$group ) 413 $group =& $groups_template->group; 414 415 return apply_filters( 'bp_get_group_avatar_thumb', '<img src="' . attribute_escape( $group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />', $group->avatar_thumb, $group->avatar_name ); 419 return bp_get_group_avatar( 'type=thumb' ); 416 420 } 417 421 … … 420 424 } 421 425 function bp_get_group_avatar_mini( $group = false ) { 422 global $groups_template; 423 424 if ( !$group ) 425 $group =& $groups_template->group; 426 427 return apply_filters( 'bp_get_group_avatar_mini', '<img src="' . attribute_escape( $group->avatar_thumb ) . '" class="avatar" width="30" height="30" alt="' . attribute_escape( $group->name ) . '" />', $group->avatar_thumb, $group->avatar_name ); 426 return bp_get_group_avatar( 'type=thumb&width=30&height=30' ); 428 427 } 429 428 … … 652 651 <?php for ( $i = 0; $i < count($group_mods); $i++ ) { ?> 653 652 <li> 654 <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_core_get_user_displayname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_ get_avatar( $group_mods[$i]->user_id, 1, 50, 50) ?></a>653 <a href="<?php echo bp_core_get_userlink( $group_mods[$i]->user_id, false, true ) ?>" title="<?php echo bp_core_get_user_displayname( $group_mods[$i]->user->user_id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $group_mods[$i]->user_id, 'type' => 'thumb' ) ) ?></a> 655 654 <h5><?php echo bp_core_get_userlink( $group_mods[$i]->user_id ) ?></h5> 656 655 <span class="activity"><?php _e( 'Group Mod', 'buddypress' ) ?></span> … … 897 896 <?php if ( $admin_list ) { ?> 898 897 <li> 899 <?php echo bp_core_ get_avatar( $admin->user_id, 1, 30, 30) ?>898 <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?> 900 899 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 901 900 </li> 902 901 <?php } else { ?> 903 902 <li> 904 <?php echo bp_core_ get_avatar( $admin->user_id, 1) ?>903 <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb' ) ) ?> 905 904 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5> 906 905 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> … … 935 934 <?php if ( $admin_list ) { ?> 936 935 <li> 937 <?php echo bp_core_ get_avatar( $mod->user_id, 1, 30, 30) ?>936 <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ) ?> 938 937 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?> <span class="small"> — <a href="<?php bp_group_member_ban_link() ?>"><?php _e( 'Kick & Ban', 'buddypress' ) ?></a> | <a href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5> 939 938 </li> 940 939 <?php } else { ?> 941 940 <li> 942 <?php echo bp_core_ get_avatar( $mod->user_id, 1) ?>941 <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb' ) ) ?> 943 942 <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5> 944 943 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span> … … 1398 1397 global $members_template; 1399 1398 1400 return apply_filters( 'bp_get_group_member_avatar', bp_core_ get_avatar( $members_template->member->user_id, 1) );1399 return apply_filters( 'bp_get_group_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'thumb' ) ) ); 1401 1400 } 1402 1401 … … 1407 1406 global $members_template; 1408 1407 1409 return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_ get_avatar( $members_template->member->user_id, 2) );1408 return apply_filters( 'bp_get_group_member_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'full' ) ) ); 1410 1409 } 1411 1410 … … 1416 1415 global $members_template; 1417 1416 1418 return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_ get_avatar( $members_template->member->user_id, 1, $width, $height) );1417 return apply_filters( 'bp_get_group_member_avatar_mini', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->user_id, 'type' => 'full', 'width' => $width, 'height' => $height ) ) ); 1419 1418 } 1420 1419 … … 1570 1569 global $bp; 1571 1570 1571 /* Make sure we are in the groups component */ 1572 1572 if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action ) 1573 1573 return false; 1574 1574 1575 /* If this the first step, we can just accept and return true */ 1575 1576 if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug ) 1576 1577 return true; … … 1582 1583 } 1583 1584 1585 /* Check the current step against the step parameter */ 1584 1586 if ( $bp->action_variables[1] == $step_slug ) 1585 1587 return true; … … 1687 1689 } 1688 1690 1689 function bp_new_group_avatar _thumb() {1690 echo bp_get_new_group_avatar _thumb();1691 } 1692 function bp_get_new_group_avatar _thumb() {1691 function bp_new_group_avatar( $args = '' ) { 1692 echo bp_get_new_group_avatar( $args ); 1693 } 1694 function bp_get_new_group_avatar( $args = '' ) { 1693 1695 global $bp; 1694 return apply_filters( 'bp_get_new_group_avatar_thumb', $bp->groups->current_group->avatar_thumb ); 1695 } 1696 1697 function bp_new_group_avatar_full() { 1698 echo bp_get_new_group_avatar_full(); 1699 } 1700 function bp_get_new_group_avatar_full() { 1701 global $bp; 1702 return apply_filters( 'bp_get_new_group_avatar_full', $bp->groups->current_group->avatar_full ); 1703 } 1704 1705 function bp_new_group_avatar_upload_form() { 1706 if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) { 1707 groups_avatar_upload($_FILES); 1708 } else { 1709 bp_core_render_avatar_upload_form( '', true ); 1710 } 1711 } 1696 1697 $defaults = array( 1698 'type' => 'full', 1699 'width' => false, 1700 'height' => false, 1701 'class' => 'avatar', 1702 'id' => 'avatar-crop-preview', 1703 'alt' => __( 'Group avatar', 'buddypress' ) 1704 ); 1705 1706 $r = wp_parse_args( $args, $defaults ); 1707 extract( $r, EXTR_SKIP ); 1708 1709 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 ) ) ); 1710 } 1712 1711 1713 1712 function bp_group_creation_previous_link() { … … 1992 1991 global $site_groups_template; 1993 1992 1994 return apply_filters( 'bp_the_site_group_avatar', bp_ get_group_avatar( $site_groups_template->group) );1993 return apply_filters( 'bp_the_site_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'full', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ); 1995 1994 } 1996 1995 … … 2001 2000 global $site_groups_template; 2002 2001 2003 return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_ get_group_avatar_thumb( $site_groups_template->group) );2002 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' ) ) ) ); 2004 2003 } 2005 2004 … … 2010 2009 global $site_groups_template; 2011 2010 2012 return apply_filters( 'bp_get_the_site_group_avatar_mini', bp_ get_group_avatar_mini( $site_groups_template->group) );2011 return apply_filters( 'bp_get_the_site_group_avatar_mini', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'width' => 30, 'height' => 30, 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) ); 2013 2012 } 2014 2013 … … 2070 2069 global $site_groups_template; 2071 2070 2072 return apply_filters( 'bp_get_the_site_group_date_created', date( get_option( 'date_format' ),$site_groups_template->group->date_created ) );2071 return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 2073 2072 } 2074 2073 … … 2245 2244 global $requests_template; 2246 2245 2247 echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_ get_avatar( $requests_template->request->user_id, 1) );2246 echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) ); 2248 2247 } 2249 2248 … … 2433 2432 } 2434 2433 2435 2436 /************************************2437 DEPRECATED FUNCTIONS2438 2439 Avoid using these, they are left here for backwards compatibility. Most of these have been deprecated2440 because they contain HTML and are very hard to customize. Each one has an alternative that will let you2441 customize them far easier.2442 ************************************/2443 2444 /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */2445 function bp_groups_random_selection( $total_groups = 5 ) {2446 global $bp;2447 2448 if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {2449 $group_ids = BP_Groups_Group::get_random( $total_groups, 1 );2450 wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );2451 }2452 ?>2453 <?php if ( $group_ids['groups'] ) { ?>2454 <ul class="item-list" id="random-groups-list">2455 <?php2456 for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {2457 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {2458 $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );2459 wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );2460 }2461 ?>2462 <li>2463 <div class="item-avatar">2464 <a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_avatar_thumb( $group ) ?></a>2465 </div>2466 2467 <div class="item">2468 <div class="item-title"><a href="<?php echo bp_get_group_permalink( $group ) ?>" title="<?php echo bp_get_group_name( $group ) ?>"><?php echo bp_get_group_name( $group ) ?></a></div>2469 <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) ) ?></span></div>2470 <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>2471 </div>2472 2473 <div class="action">2474 <?php bp_group_join_button( $group ) ?>2475 <div class="meta">2476 <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>2477 <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /2478 <?php if ( 1 == $member_count ) : ?>2479 <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>2480 <?php else : ?>2481 <?php printf( __( '%d members', 'buddypress' ), $member_count ) ?>2482 <?php endif; ?>2483 </div>2484 </div>2485 2486 <div class="clear"></div>2487 </li>2488 <?php } ?>2489 </ul>2490 <?php } else { ?>2491 <div id="message" class="info">2492 <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>2493 </div>2494 <?php } ?>2495 <?php2496 }2497 2498 /* DEPRECATED - use bp_has_groups( 'type=random' ) template loop */2499 function bp_groups_random_groups( $total_groups = 5 ) {2500 global $bp;2501 2502 if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {2503 $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );2504 wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );2505 }2506 2507 ?>2508 <div class="info-group">2509 <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> »</a></h4>2510 <?php if ( $group_ids ) { ?>2511 <ul class="horiz-gallery">2512 <?php2513 for ( $i = 0; $i < count( $group_ids ); $i++ ) {2514 if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {2515 $group = new BP_Groups_Group( $group_ids[$i], false, false );2516 wp_cache_set( 'groups_group_nouserdata_' . $group_ids[$i], $group, 'bp' );2517 }2518 ?> <li>2519 <a href="<?php echo bp_get_group_permalink( $group ) ?>"><img src="<?php echo attribute_escape( $group->avatar_thumb ); ?>" class="avatar" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" /></a>2520 <h5><a href="<?php echo bp_get_group_permalink( $group ) ?>"><?php echo attribute_escape( $group->name ) ?></a></h5>2521 </li>2522 <?php } ?>2523 </ul>2524 <?php } else { ?>2525 <div id="message" class="info">2526 <p><?php bp_word_or_name( __( "You haven't joined any groups yet.", 'buddypress' ), __( "%s hasn't joined any groups yet.", 'buddypress' ) ) ?></p>2527 </div>2528 <?php } ?>2529 <div class="clear"></div>2530 </div>2531 <?php2532 }2533 2534 /* DEPRECATED - use group invite template loop (see groups/create.php in skeleton BuddyPress theme) */2535 function bp_group_send_invite_form( $group = false ) {2536 global $bp, $groups_template, $invites;2537 2538 if ( !$group )2539 $group =& $groups_template->group;2540 2434 ?> 2541 <div class="left-menu">2542 <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp->groups->image_base ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>2543 <?php bp_group_list_invite_friends() ?>2544 <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?>2545 <input type="hidden" name="group_id" id="group_id" value="<?php echo attribute_escape( $group->id ) ?>" />2546 </div>2547 2548 <div class="main-column">2549 2550 <div id="message" class="info">2551 <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>2552 </div>2553 2554 <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?>2555 2556 <ul id="friend-list" class="item-list">2557 <?php for ( $i = 0; $i < count($invites); $i++ ) {2558 if ( !$user = wp_cache_get( 'bp_user_' . $invites[$i], 'bp' ) ) {2559 $user = new BP_Core_User( $invites[$i] );2560 wp_cache_set( 'bp_user_' . $invites[$i], $user, 'bp' );2561 }2562 ?>2563 <li id="uid-<?php echo $user->id ?>">2564 <?php echo $user->avatar_thumb ?>2565 <h4><?php echo $user->user_link ?></h4>2566 <span class="activity"><?php echo $user->last_active ?></span>2567 <div class="action">2568 <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>2569 </div>2570 </li>2571 <?php } // end for ?>2572 </ul>2573 2574 <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>2575 </div>2576 <?php2577 }2578 2579 /* DEPRECATED - use bp_group_has_invites() template loop */2580 function bp_group_list_invite_friends( $args = '' ) {2581 global $bp, $invites;2582 2583 if ( !function_exists('friends_install') )2584 return false;2585 2586 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $bp->groups->current_group->id );2587 2588 if ( $friends ) {2589 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $bp->groups->current_group->id );2590 2591 ?>2592 <div id="invite-list">2593 <ul>2594 <?php2595 for ( $i = 0; $i < count( $friends ); $i++ ) {2596 if ( $invites ) {2597 if ( in_array( $friends[$i]['id'], $invites ) ) {2598 $checked = ' checked="checked"';2599 } else {2600 $checked = '';2601 }2602 }2603 ?>2604 2605 <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>2606 <?php } ?>2607 </ul>2608 </div>2609 <?php2610 } else {2611 _e( 'No friends to invite.', 'buddypress' );2612 }2613 }2614 2615 /* DEPRECATED - use bp_group_has_members() template loop */2616 function bp_group_random_members( $group = false ) {2617 global $groups_template;2618 2619 if ( !$group )2620 $group =& $groups_template->group;2621 2622 $members = &$group->random_members;2623 ?>2624 <ul class="horiz-gallery">2625 <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>2626 <li>2627 <a href="<?php echo $members[$i]->user->user_url ?>"><?php echo $members[$i]->user->avatar_thumb ?></a>2628 <h5><?php echo $members[$i]->user->user_link ?></h5>2629 </li>2630 <?php } ?>2631 </ul>2632 <div class="clear"></div>2633 <?php2634 }2635 2636 /* DEPRECATED - see latest default BuddyPress theme /groups/create.php for replacement template tags */2637 function bp_group_create_form() {2638 global $bp, $invites;2639 ?>2640 <form action="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/create/step/<?php echo $bp->groups->current_create_step ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data">2641 <?php switch( $bp->groups->current_create_step ) {2642 case 'group-details': ?>2643 <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>2644 <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'] ); ?>" />2645 2646 <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>2647 <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea>2648 2649 <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>2650 <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea>2651 2652 <?php do_action( 'groups_custom_group_fields_editable' ) ?>2653 2654 <?php wp_nonce_field( 'groups_create_save_group-details' ) ?>2655 2656 <?php break; ?>2657 2658 <?php case 'group-settings': ?>2659 <?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?>2660 <?php if ( function_exists('bp_wire_install') ) : ?>2661 <div class="checkbox">2662 <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups->current_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>2663 </div>2664 <?php endif; ?>2665 2666 <?php if ( function_exists('bp_forums_setup') ) : ?>2667 <?php if ( bp_forums_is_installed_correctly() ) { ?>2668 <div class="checkbox">2669 <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $bp->groups->current_group->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label>2670 </div>2671 <?php } else {2672 if ( is_site_admin() ) {2673 ?>2674 <div class="checkbox">2675 <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), $bp->root_domain . '/wp-admin/admin.php?page=' . BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ) ?></label>2676 </div>2677 <?php2678 }2679 }?>2680 <?php endif; ?>2681 2682 <?php if ( function_exists('bp_albums_install') ) : ?>2683 <div class="checkbox with-suboptions">2684 <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups->current_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>2685 <div class="sub-options"<?php if ( !$bp->groups->current_group->enable_photos ) { ?> style="display: none;"<?php } ?>>2686 <label><input type="radio" name="group-photos-status" value="all"<?php if ( !$bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label>2687 <label><input type="radio" name="group-photos-status" value="admins"<?php if ( $bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label>2688 </div>2689 </div>2690 <?php endif; ?>2691 2692 <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>2693 2694 <div class="radio">2695 <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />2696 <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>2697 <ul>2698 <li><?php _e( 'Any site member can join this group.', 'buddypress' ) ?></li>2699 <li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>2700 <li><?php _e( 'Group content and activity will be visible to any site member.', 'buddypress' ) ?></li>2701 </ul>2702 </label>2703 2704 <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />2705 <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>2706 <ul>2707 <li><?php _e( 'Only users who request membership and are accepted can join the group.', 'buddypress' ) ?></li>2708 <li><?php _e( 'This group will be listed in the groups directory and in search results.', 'buddypress' ) ?></li>2709 <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>2710 </ul>2711 </label>2712 2713 <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />2714 <strong><?php _e('This is a hidden group', 'buddypress') ?></strong>2715 <ul>2716 <li><?php _e( 'Only users who are invited can join the group.', 'buddypress' ) ?></li>2717 <li><?php _e( 'This group will not be listed in the groups directory or search results.', 'buddypress' ) ?></li>2718 <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ) ?></li>2719 </ul>2720 </label>2721 </div>2722 2723 <?php wp_nonce_field( 'groups_create_save_group-settings' ) ?>2724 <?php } else { ?>2725 <div id="message" class="info">2726 <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>2727 </div>2728 <?php } ?>2729 <?php break; ?>2730 2731 <?php case 'group-avatar': ?>2732 <?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?>2733 <div class="left-menu">2734 <?php bp_group_current_avatar() ?>2735 </div>2736 2737 <div class="main-column">2738 <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>2739 2740 <?php2741 if ( !empty($_FILES) || ( isset($_POST['orig']) && isset($_POST['canvas']) ) ) {2742 groups_avatar_upload($_FILES);2743 } else {2744 bp_core_render_avatar_upload_form( '', true );2745 }2746 ?>2747 2748 </div>2749 2750 <?php wp_nonce_field( 'groups_step3_save' ) ?>2751 <?php } else { ?>2752 <div id="message" class="info">2753 <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>2754 </div>2755 <?php } ?>2756 2757 <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>2758 2759 <?php break; ?>2760 <?php case 'group-invites': ?>2761 <?php2762 if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) {2763 $group_link = bp_get_group_permalink( $bp->groups->new_group );2764 2765 if ( function_exists('friends_install') ) {2766 if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {2767 bp_group_send_invite_form( $bp->groups->new_group );2768 } else {2769 ?>2770 <div id="message" class="info">2771 <p><?php _e( 'Once you build up your friends list you will be able to invite friends to join your group.', 'buddypress' ) ?></p>2772 </div>2773 <?php2774 }2775 } ?>2776 2777 <?php wp_nonce_field( 'groups_step4_save' ) ?>2778 2779 <?php2780 } else { ?>2781 <div id="message" class="info">2782 <p><?php _e('Please complete all previous steps first.', 'buddypress'); ?></p>2783 </div>2784 <?php } ?>2785 2786 <?php wp_nonce_field( 'groups_create_save_group-invites' ) ?>2787 2788 <?php break; ?>2789 <?php } ?>2790 2791 <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>2792 2793 <div class="clear"></div>2794 2795 <div id="previous-next">2796 <!-- Previous Button -->2797 <?php if ( !bp_is_first_group_creation_step() ) : ?>2798 <input type="button" value="← <?php _e('Previous Step', 'buddypress') ?>" id="group-creation-previous" style="width: auto;" name="previous" onclick="location.href='<?php bp_group_creation_previous_link() ?>'" />2799 <?php endif; ?>2800 2801 <!-- Next Button -->2802 <?php if ( !bp_is_last_group_creation_step() && !bp_is_first_group_creation_step() ) : ?>2803 <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> →" id="group-creation-next" name="save" />2804 <?php endif;?>2805 2806 <!-- Create Button -->2807 <?php if ( bp_is_first_group_creation_step() ) : ?>2808 <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> →" id="group-creation-create" name="save" />2809 <?php endif; ?>2810 2811 <!-- Finish Button -->2812 <?php if ( bp_is_last_group_creation_step() ) : ?>2813 <input type="submit" value="<?php _e('Finish', 'buddypress') ?> →" id="group-creation-finish" name="save" />2814 <?php endif; ?>2815 </div>2816 2817 <!-- Don't leave out this hidden field -->2818 <input type="hidden" name="group_id" id="group_id" value="<?php bp_new_group_id() ?>" />2819 2820 </form>2821 <?php2822 }2823 2824 2825 ?> -
trunk/bp-groups/bp-groups-widgets.php
r1609 r1636 12 12 function bp_groups_widget() { 13 13 parent::WP_Widget( false, $name = 'Groups' ); 14 14 15 wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') ); 15 16 wp_enqueue_style( 'groups_widget_members-css', BP_PLUGIN_URL . '/bp-groups/css/widget-groups.css' ); -
trunk/bp-loader.php
r1608 r1636 5 5 Description: BuddyPress will add social networking features to a new or existing WordPress MU installation. 6 6 Author: The BuddyPress Community 7 <<<<<<< .working8 7 Version: 1.1-bleeding 9 =======10 Version: 1.0.211 >>>>>>> .merge-right.r160712 8 Author URI: http://buddypress.org/developers/ 13 9 Site Wide Only: true -
trunk/bp-messages.php
r1599 r1636 8 8 9 9 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' ); 10 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-ajax.php' );11 10 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' ); 12 11 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-templatetags.php' ); 13 12 require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' ); 14 13 14 /* Include deprecated functions if settings allow */ 15 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 16 require ( BP_PLUGIN_DIR . '/bp-messages/deprecated/bp-messages-deprecated.php' ); 17 15 18 function messages_install() { 16 19 global $wpdb, $bp; … … 128 131 $bp->bp_options_title = __( 'My Messages', 'buddypress' ); 129 132 } else { 130 $bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1);133 $bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 131 134 $bp->bp_options_title = $bp->displayed_user->fullname; 132 135 } … … 271 274 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component ); 272 275 } else { 273 $bp->bp_options_nav[$bp->messages->slug]['view'] = array( 274 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ), 275 'link' => $bp->loggedin_user->domain . $bp->messages->slug . '/' 276 ); 276 277 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() ) ); 277 278 278 279 bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) ); … … 455 456 } 456 457 } else { 457 $message = __('Message sent successfully!', 'buddypress') . ' <a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $pmessage->thread_id . '">' . __('View Message', 'buddypress') . '</a> »';458 $message = __('Message sent successfully!', 'buddypress'); 458 459 $type = 'success'; 459 460 … … 475 476 } else { 476 477 bp_core_add_message( $message ); 477 bp_core_redirect( $bp->loggedin_user->domain . $bp-> current_component . '/inbox');478 bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $pmessage->thread_id ); 478 479 } 479 480 } … … 506 507 507 508 function messages_send_notice( $subject, $message, $from_template ) { 508 509 510 509 if ( !is_site_admin() || empty( $subject ) || empty( $message ) ) { 511 510 return false; … … 566 565 } 567 566 567 function messages_ajax_autocomplete_results() { 568 global $bp; 569 570 $friends = false; 571 572 // Get the friend ids based on the search terms 573 if ( function_exists( 'friends_search_friends' ) ) 574 $friends = friends_search_friends( $_GET['q'], $bp->loggedin_user->id, $_GET['limit'], 1 ); 575 576 $friends = apply_filters( 'bp_friends_autocomplete_list', $friends, $_GET['q'], $_GET['limit'] ); 577 578 if ( $friends['friends'] ) { 579 foreach ( $friends['friends'] as $user_id ) { 580 $ud = get_userdata($user_id); 581 $username = $ud->user_login; 582 echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ') 583 '; 584 } 585 } 586 } 587 add_action( 'wp_ajax_messages_autocomplete_results', 'messages_ajax_autocomplete_results' ); 588 589 568 590 // List actions to clear super cached pages on, if super cache is installed 569 591 add_action( 'messages_delete_thread', 'bp_core_clear_cache' ); -
trunk/bp-messages/bp-messages-classes.php
r1534 r1636 293 293 if ( count($recipients) >= 5 ) 294 294 return count($recipients) . __(' Recipients', 'buddypress'); 295 296 for ( $i = 0; $i < count($recipients); $i++ ) {295 296 for ( $i = 0; $i < count($recipients); $i++ ) { 297 297 $recipient_links[] = bp_core_get_userlink( $recipients[$i] ); 298 298 } -
trunk/bp-messages/bp-messages-cssjs.php
r1498 r1636 1 1 <?php 2 2 3 function messages_add_ js() {3 function messages_add_autocomplete_js() { 4 4 global $bp; 5 6 if ( $bp->current_component == $bp->messages->slug ) 7 wp_enqueue_script( 'bp-messages-js', BP_PLUGIN_URL . '/bp-messages/js/general.js' ); 8 5 9 6 // Include the autocomplete JS for composing a message. 10 7 if ( $bp->current_component == $bp->messages->slug && $bp->current_action == 'compose') { … … 18 15 19 16 } 20 add_action( 'template_redirect', 'messages_add_ js', 1 );17 add_action( 'template_redirect', 'messages_add_autocomplete_js', 1 ); 21 18 22 function messages_add_ css() {19 function messages_add_autocomplete_css() { 23 20 global $bp; 24 21 25 22 if ( $bp->current_component == $bp->messages->slug && $bp->current_action == 'compose') { 26 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/deprecated/css/autocomplete/jquery.autocompletefb.css' ); 27 24 wp_print_styles(); 28 25 } 29 26 } 30 add_action( 'wp_head', 'messages_add_css' ); 31 32 function messages_add_structure_css() { 33 /* Enqueue the structure CSS file to give basic positional formatting for components */ 34 wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/css/structure.css' ); 35 } 36 add_action( 'bp_styles', 'messages_add_structure_css' ); 27 add_action( 'wp_head', 'messages_add_autocomplete_css' ); 37 28 38 29 function messages_autocomplete_init_jsblock() { -
trunk/bp-messages/bp-messages-filters.php
r1608 r1636 13 13 add_filter( 'messages_notice_message_before_save', 'wp_filter_kses', 1 ); 14 14 add_filter( 'messages_notice_subject_before_save', 'wp_filter_kses', 1 ); 15 16 add_filter( 'bp_get_the_thread_message_content', 'wp_filter_kses', 1 ); 17 add_filter( 'bp_get_the_thread_subject', 'wp_filter_kses', 1 ); 15 18 16 19 add_filter( 'messages_message_content_before_save', 'force_balance_tags' ); … … 51 54 add_filter( 'bp_get_message_content', 'stripslashes_deep' ); 52 55 56 add_filter( 'bp_get_the_thread_message_content', 'stripslashes_deep' ); 57 add_filter( 'bp_get_the_thread_subject', 'stripslashes_deep' ); 58 53 59 ?> -
trunk/bp-messages/bp-messages-templatetags.php
r1538 r1636 1 1 <?php 2 2 3 Class BP_Messages_Template { 3 /***************************************************************************** 4 * Message Box Template Class 5 **/ 6 7 Class BP_Messages_Box_Template { 4 8 var $current_thread = -1; 5 9 var $current_thread_count; … … 16 20 var $pag_links; 17 21 18 function bp_messages_ template( $user_id, $box, $per_page, $max, $type ) {22 function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) { 19 23 $this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1; 20 24 $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page; … … 134 138 $box = 'notices'; 135 139 136 $messages_template = new BP_Messages_ Template( $user_id, $box, $per_page, $max, $type );140 $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type ); 137 141 } 138 142 … … 240 244 function bp_get_message_thread_avatar() { 241 245 global $messages_template; 242 echo apply_filters( 'bp_get_message_thread_avatar', bp_core_ get_avatar($messages_template->thread->last_sender_id, 1) );246 echo apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => 'thumb' ) ) ); 243 247 } 244 248 … … 460 464 <li id="un-<?php echo $_GET['r'] ?>" class="friend-tab"> 461 465 <span> 462 <?php echo bp_core_ get_avatar( $user_id, 1, 15, 15) ?>466 <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?> 463 467 <?php echo bp_core_get_userlink( $user_id ) ?> 464 468 </span> … … 476 480 return apply_filters( 'bp_get_message_get_recipient_usernames', $_GET['r'] ); 477 481 } 478 482 483 484 /***************************************************************************** 485 * Message Thread Template Class 486 **/ 487 488 class BP_Messages_Thread_Template { 489 var $current_message = -1; 490 var $message_count; 491 var $message; 492 493 var $thread; 494 495 var $in_the_loop; 496 497 var $pag_page; 498 var $pag_num; 499 var $pag_links; 500 var $total_message_count; 501 502 function bp_messages_thread_template( $thread_id, $order ) { 503 global $bp; 504 505 $this->thread = new BP_Messages_Thread( $thread_id, true ); 506 $this->message_count = count( $this->thread->messages ); 507 } 508 509 function has_messages() { 510 if ( $this->message_count ) 511 return true; 512 513 return false; 514 } 515 516 function next_message() { 517 $this->current_message++; 518 $this->message = $this->thread->messages[$this->current_message]; 519 520 return $this->message; 521 } 522 523 function rewind_messages() { 524 $this->current_message = -1; 525 if ( $this->message_count > 0 ) { 526 $this->message = $this->thread->messages[0]; 527 } 528 } 529 530 function messages() { 531 if ( $this->current_message + 1 < $this->message_count ) { 532 return true; 533 } elseif ( $this->current_message + 1 == $this->message_count ) { 534 do_action('thread_loop_end'); 535 // Do some cleaning up after the loop 536 $this->rewind_messages(); 537 } 538 539 $this->in_the_loop = false; 540 return false; 541 } 542 543 function the_message() { 544 global $message; 545 546 $this->in_the_loop = true; 547 $this->message = $this->next_message(); 548 549 if ( 0 == $this->current_message ) // loop has just started 550 do_action('thread_loop_start'); 551 } 552 } 553 554 function bp_thread_has_messages( $args = '' ) { 555 global $bp, $thread_template, $group_id; 556 557 $defaults = array( 558 'thread_id' => false, 559 'order' => 'ASC' 560 ); 561 562 $r = wp_parse_args( $args, $defaults ); 563 extract( $r, EXTR_SKIP ); 564 565 if ( !$thread_id && $bp->current_component == BP_MESSAGES_SLUG && 'view' == $bp->current_action ) 566 $thread_id = (int)$bp->action_variables[0]; 567 568 $thread_template = new BP_Messages_Thread_Template( $thread_id, $order ); 569 return $thread_template->has_messages(); 570 } 571 572 function bp_thread_messages() { 573 global $thread_template; 574 575 return $thread_template->messages(); 576 } 577 578 function bp_thread_the_message() { 579 global $thread_template; 580 581 return $thread_template->the_message(); 582 } 583 584 function bp_the_thread_subject() { 585 echo bp_get_the_thread_subject(); 586 } 587 function bp_get_the_thread_subject() { 588 global $thread_template; 589 590 return apply_filters( 'bp_get_the_thread_subject', $thread_template->thread->subject ); 591 } 592 593 function bp_the_thread_recipients() { 594 echo bp_get_the_thread_recipients(); 595 } 596 function bp_get_the_thread_recipients() { 597 global $thread_template; 598 599 if ( count($thread_template->thread->recipients) >= 5 ) 600 return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) ); 601 602 foreach( $thread_template->thread->recipients as $recipient ) 603 $recipient_links[] = bp_core_get_userlink( $recipient ); 604 605 return apply_filters( 'bp_get_the_thread_recipients', implode( ', ', $recipient_links ) ); 606 } 607 608 function bp_the_thread_message_alt_class() { 609 echo bp_get_the_thread_message_alt_class(); 610 } 611 function bp_get_the_thread_message_alt_class() { 612 global $thread_template; 613 614 if ( $thread_template->current_message % 2 == 1 ) 615 $class = ' alt'; 616 else 617 $class = ''; 618 619 return apply_filters( 'bp_get_the_thread_message_alt_class', $class ); 620 } 621 622 function bp_the_thread_message_sender_avatar( $args = '' ) { 623 echo bp_get_the_thread_message_sender_avatar_thumb( $args ); 624 } 625 function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) { 626 global $thread_template; 627 628 $defaults = array( 629 'type' => 'thumb', 630 'width' => false, 631 'height' => false, 632 ); 633 634 $r = wp_parse_args( $args, $defaults ); 635 extract( $r, EXTR_SKIP ); 636 637 return apply_filters( 'bp_get_the_thread_message_sender_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $thread_template->message->sender_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 638 } 639 640 function bp_the_thread_message_sender_link() { 641 echo bp_get_the_thread_message_sender_link(); 642 } 643 function bp_get_the_thread_message_sender_link() { 644 global $thread_template; 645 646 return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) ); 647 } 648 649 function bp_the_thread_message_sender_name() { 650 echo bp_get_the_thread_message_sender_name(); 651 } 652 function bp_get_the_thread_message_sender_name() { 653 global $thread_template; 654 655 return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) ); 656 } 657 658 function bp_the_thread_message_time_since() { 659 echo bp_get_the_thread_message_time_since(); 660 } 661 function bp_get_the_thread_message_time_since() { 662 global $thread_template; 663 664 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 ) ) ) ); 665 } 666 667 function bp_the_thread_message_content() { 668 echo bp_get_the_thread_message_content(); 669 } 670 function bp_get_the_thread_message_content() { 671 global $thread_template; 672 673 return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message ); 674 } 675 676 677 /*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/ 678 679 /* DEPRECATED - please use the view message template loop. */ 479 680 function messages_view_thread( $thread_id ) { 480 681 global $bp; … … 515 716 <div class="message-box<?php echo $alt ?>"> 516 717 <div class="avatar-box"> 517 <?php echo apply_filters( 'bp_get_message_sender_avatar', bp_core_get_avatar( $message->sender_id, 1) ) ?>718 <?php echo apply_filters( 'bp_get_message_sender_avatar', bp_core_fetch_avatar( array( 'item_id' => $message->sender_id, 'type' => 'thumb' ) ) ) ?> 518 719 <h3><?php echo apply_filters( 'bp_get_message_sender_id', bp_core_get_userlink( $message->sender_id ) ) ?></h3> 519 720 <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small> … … 537 738 <div id="messagediv"> 538 739 <div class="avatar-box"> 539 <?php if ( function_exists('bp_core_get_avatar') ) 540 echo bp_core_get_avatar($bp->loggedin_user->id, 1); 541 ?> 740 <?php echo bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?> 542 741 543 742 <h3><?php _e("Reply: ", 'buddypress') ?></h3> -
trunk/bp-wire.php
r1621 r1636 6 6 7 7 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-classes.php' ); 8 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-ajax.php' );9 8 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-templatetags.php' ); 10 9 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-cssjs.php' ); 11 10 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-filters.php' ); 12 11 12 /* Include deprecated functions if settings allow */ 13 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 14 require ( BP_PLUGIN_DIR . '/bp-wire/deprecated/bp-wire-deprecated.php' ); 15 13 16 function bp_wire_install() { 14 17 // Tables are installed on a per component basis, where needed. … … 41 44 $bp->bp_options_title = __('My Wire', 'buddypress'); 42 45 } else { 43 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);46 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 44 47 $bp->bp_options_title = $bp->displayed_user->fullname; 45 48 } -
trunk/bp-wire/bp-wire-templatetags.php
r1480 r1636 292 292 global $wire_posts_template; 293 293 294 return apply_filters( 'bp_get_wire_post_author_avatar', bp_core_ get_avatar( $wire_posts_template->wire_post->user_id, 1) );294 return apply_filters( 'bp_get_wire_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $wire_posts_template->wire_post->user_id, 'type' => 'thumb' ) ) ); 295 295 } 296 296 … … 326 326 global $bp; 327 327 328 return apply_filters( 'bp_get_wire_poster_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1) );328 return apply_filters( 'bp_get_wire_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ) ); 329 329 } 330 330 -
trunk/bp-xprofile.php
r1599 r1636 13 13 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-notifications.php' ); 14 14 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php' ); 15 16 /* Include deprecated functions if settings allow */ 17 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 18 require ( BP_PLUGIN_DIR . '/bp-xprofile/deprecated/bp-xprofile-deprecated.php' ); 15 19 16 20 /* Assign the base group and fullname field names to constants to use in SQL statements */ … … 60 64 option_order bigint(20) NOT NULL DEFAULT '0', 61 65 order_by varchar(15) NOT NULL, 62 is_public int(2) NOT NULL DEFAULT '1',63 66 can_delete tinyint(1) NOT NULL DEFAULT '1', 64 67 KEY group_id (group_id), 65 68 KEY parent_id (parent_id), 66 KEY is_public (is_public),67 69 KEY can_delete (can_delete), 68 70 KEY is_required (is_required) … … 139 141 $bp->profile->image_base = BP_PLUGIN_URL . '/bp-xprofile/images'; 140 142 $bp->profile->slug = BP_XPROFILE_SLUG; 143 144 $bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) ); 141 145 142 146 $bp->version_numbers->profile = BP_XPROFILE_VERSION; … … 192 196 * @uses bp_core_add_subnav_item() Adds a sub navigation item to a nav item 193 197 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user 194 * @uses bp_core_ get_avatar() Returns the either the thumb (1) or full (2)avatar URL for the user_id passed198 * @uses bp_core_fetch_avatar() Returns the either the thumb or full avatar URL for the user_id passed 195 199 */ 196 200 function xprofile_setup_nav() { … … 211 215 $bp->bp_options_title = __('My Profile', 'buddypress'); 212 216 } else { 213 $bp->bp_options_avatar = bp_core_ get_avatar( $bp->displayed_user->id, 1);217 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 214 218 $bp->bp_options_title = $bp->displayed_user->fullname; 215 219 } … … 261 265 */ 262 266 function xprofile_screen_edit_profile() { 263 if ( bp_is_home() ) { 264 do_action( 'xprofile_screen_edit_profile' ); 265 bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) ); 266 } 267 global $bp; 268 269 if ( !bp_is_home() && !is_site_admin() ) 270 return false; 271 272 /* Check to see if any new information has been submitted */ 273 if ( isset($_POST['field_ids']) ) { 274 275 /* Check the nonce */ 276 check_admin_referer( 'bp_xprofile_edit' ); 277 278 /* Check we have field ID's */ 279 if ( empty( $_POST['field_ids'] ) ) 280 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' ); 281 282 /* Explode the posted field IDs into an array so we know which fields have been submitted */ 283 $posted_field_ids = explode( ',', $_POST['field_ids'] ); 284 285 /* Loop through the posted fields formatting any datebox values then validate the field */ 286 foreach ( $posted_field_ids as $field_id ) { 287 288 if ( !isset( $_POST['field_' . $field_id] ) ) { 289 290 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) { 291 /* Concatenate the values. */ 292 $date_value = $_POST['field_' . $field_id . '_day'] . 293 $_POST['field_' . $field_id . '_month'] . 294 $_POST['field_' . $field_id . '_year']; 295 296 /* Turn the concatenated value into a timestamp */ 297 $_POST['field_' . $field_id] = strtotime( $date_value ); 298 } 299 300 } 301 302 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) ) 303 $errors = true; 304 } 305 306 if ( $errors ) 307 bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' ); 308 else { 309 /* Reset the errors var */ 310 $errors = false; 311 312 /* Now we've checked for required fields, lets save the values. */ 313 foreach ( $posted_field_ids as $field_id ) { 314 if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id] ) ) 315 $errors = true; 316 else 317 do_action( 'xprofile_profile_field_data_updated', $field_id, $_POST['field_' . $field_id] ); 318 } 319 320 do_action( 'xprofile_updated_profile', $posted_field_ids, $errors ); 321 322 /* Set the feedback messages */ 323 if ( $errors ) 324 bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' ); 325 else 326 bp_core_add_message( __( 'Changes saved.', 'buddypress' ) ); 327 328 /* Redirect back to the edit screen to display the updates and message */ 329 bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' ); 330 } 331 } 332 333 do_action( 'xprofile_screen_edit_profile' ); 334 bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) ); 267 335 } 268 336 … … 270 338 * xprofile_screen_change_avatar() 271 339 * 272 * Handles the display of the change avatar page by loading the correct template file. 273 * Also checks to make sure this can only be accessed for the logged in users profile. 340 * Handles the uploading and cropping of a user avatar. Displays the change avatar page. 274 341 * 275 342 * @package BuddyPress Xprofile … … 278 345 */ 279 346 function xprofile_screen_change_avatar() { 280 if ( bp_is_home() ) { 281 add_action( 'wp_head', 'bp_core_add_cropper_js' ); 282 do_action( 'xprofile_screen_change_avatar' ); 283 bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'profile/change-avatar' ) ); 284 } 347 global $bp; 348 349 if ( !bp_is_home() && !is_site_admin() ) 350 return false; 351 352 $bp->avatar_admin->step = 'upload-image'; 353 354 if ( !empty( $_FILES ) ) { 355 356 /* Check the nonce */ 357 check_admin_referer( 'bp_avatar_upload' ); 358 359 /* Pass the file to the avatar upload handler */ 360 $errors = bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ); 361 362 if ( !$errors ) { 363 $bp->avatar_admin->step = 'crop-image'; 364 365 /* Make sure we include the jQuery jCrop file for image cropping */ 366 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 367 } 368 369 } 370 371 /* If the image cropping is done, crop the image and save a full/thumb version */ 372 if ( isset( $_POST['avatar-crop-submit'] ) ) { 373 374 /* Check the nonce */ 375 check_admin_referer( 'bp_avatar_cropstore' ); 376 377 if ( !bp_core_avatar_handle_crop( array( 'item_id' => $bp->displayed_user->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) ) 378 bp_core_add_message( __( 'There was a problem cropping your avatar, please try uploading it again', 'buddypress' ) ); 379 else 380 bp_core_add_message( __( 'Your new avatar was uploaded successfully!', 'buddypress' ) ); 381 382 } 383 384 do_action( 'xprofile_screen_change_avatar' ); 385 bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'profile/change-avatar' ) ); 285 386 } 286 387 … … 352 453 return false; 353 454 354 if ( bp_is_home() ) { 355 bp_core_delete_avatar(); 356 add_action( 'wp_head', 'bp_core_add_cropper_js' ); 357 bp_core_load_template( apply_filters( 'xprofile_template_delete_avatar', 'profile/change-avatar' ) ); 358 } 455 if ( !bp_is_home() ) 456 return false; 457 458 bp_core_delete_avatar(); 459 add_action( 'wp_head', 'bp_core_add_cropper_js' ); 460 bp_core_load_template( apply_filters( 'xprofile_template_delete_avatar', 'profile/change-avatar' ) ); 359 461 } 360 462 add_action( 'wp', 'xprofile_action_delete_avatar', 3 ); … … 614 716 */ 615 717 616 /** 617 * xprofile_edit() 618 * 619 * Renders the edit form for the profile fields within a group as well as 620 * handling the save action. 621 * 622 * [NOTE] This is old code that was written when editing was not done in the theme. 623 * It is big and clunky and will be broken up in future versions. 624 * 625 * @package BuddyPress XProfile 626 * @param $group_id The ID of the group of fields to edit 627 * @param $action The HTML form action 628 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 629 * @global $wpdb WordPress DB access object. 630 * @global $userdata WordPress global object containing current logged in user userdata 631 */ 632 function xprofile_edit( $group_id, $action ) { 633 global $wpdb, $userdata, $bp; 634 635 // Create a new group object based on the group ID. 636 $group = new BP_XProfile_Group($group_id); 637 ?> 638 <div class="wrap"> 639 640 <h2><?php echo attribute_escape( $group->name ) ?> <?php _e("Information", 'buddypress') ?></h2> 641 642 <?php 643 // If this group has fields then continue 644 if ( $group->fields ) { 645 $errors = null; 646 $list_html = '<ul class="forTab" id="' . strtolower($group_name) . '">'; 647 648 // Loop through each field in the group 649 for ( $j = 0; $j < count($group->fields); $j++ ) { 650 651 // Create a new field object for this field based on the field ID. 652 $field = new BP_XProfile_Field( $group->fields[$j]->id ); 653 654 // Add the ID for this field to the field_ids array 655 $field_ids[] = $group->fields[$j]->id; 656 657 // If the user has submitted the form - validate and save the new value for this field 658 if ( isset($_GET['mode']) && 'save' == $_GET['mode'] ) { 659 660 /* Check the nonce */ 661 if ( !check_admin_referer( 'bp_xprofile_edit' ) ) 662 return false; 663 664 // If the current field is a datebox, we need to append '_day' to the end of the field name 665 // otherwise the field name will not exist 666 $post_field_string = ( 'datebox' == $group->fields[$j]->type ) ? '_day' : null; 667 668 // Explode the posted field IDs into an array so we know which fields have been submitted 669 $posted_fields = explode( ',', $_POST['field_ids'] ); 670 671 // Fetch the current field from the _POST array based on field ID. 672 $current_field = $_POST['field_' . $posted_fields[$j] . $post_field_string]; 673 674 // If the field is required and has been left blank then we need to add a callback error. 675 if ( ( $field->is_required && !isset($current_field) ) || 676 ( $field->is_required && empty( $current_field ) ) ) { 677 678 // Add the error message to the errors array 679 $field->message = sprintf( __('%s cannot be left blank.', 'buddypress'), $field->name ); 680 $errors[] = $field->message . "<br />"; 681 682 // If the field is not required and the field has been left blank, delete any values for the 683 // field from the database. 684 } else if ( !$field->is_required && ( empty( $current_field ) || is_null($current_field) ) ) { 685 686 // Create a new profile data object for the logged in user based on field ID. 687 $profile_data = new BP_Xprofile_ProfileData( $group->fields[$j]->id, $bp->loggedin_user->id ); 688 689 if ( $profile_data ) { 690 // Delete any data 691 $profile_data->delete(); 692 693 // Also remove any selected profile field data from the $field object. 694 $field->data->value = null; 695 } 696 697 // If we get to this point then the field validates ok and we have new data. 698 } else { 699 700 // Create an empty profile data object and populate it with new data 701 $profile_data = new BP_Xprofile_ProfileData; 702 $profile_data->field_id = $group->fields[$j]->id; 703 $profile_data->user_id = $userdata->ID; 704 $profile_data->last_updated = time(); 705 706 // If the $post_field_string we set up earlier is not null, then this is a datebox 707 // we need to concatenate each of the three select boxes for day, month and year into 708 // one value. 709 if ( $post_field_string != null ) { 710 711 // Concatenate the values. 712 $date_value = $_POST['field_' . $group->fields[$j]->id . '_day'] . 713 $_POST['field_' . $group->fields[$j]->id . '_month'] . 714 $_POST['field_' . $group->fields[$j]->id . '_year']; 715 716 // Turn the concatenated value into a timestamp 717 $profile_data->value = strtotime($date_value); 718 719 } else { 720 721 // Checkbox and multi select box fields will submit an array as their value 722 // so we need to serialize them before saving to the DB. 723 if ( is_array($current_field) ) 724 $current_field = serialize($current_field); 725 726 $profile_data->value = $current_field; 727 } 728 729 // Finally save the value to the database. 730 if( !$profile_data->save() ) { 731 $field->message = __('There was a problem saving changes to this field, please try again.', 'buddypress'); 732 } else { 733 $field->data->value = $profile_data->value; 734 } 735 } 736 } 737 738 // Each field object comes with HTML that can be rendered to edit that field. 739 // We just need to render that to the page by adding it to the $list_html variable 740 // that will be rendered when the field loop has finished. 741 $list_html .= '<li>' . $field->get_edit_html() . '</li>'; 742 } 743 744 // Now that the loop has finished put the final touches on the HTML including the submit button. 745 $list_html .= '</ul>'; 746 747 $list_html .= '<p class="submit"> 748 <input type="submit" name="save" id="save" value="'.__('Save Changes »', 'buddypress').'" /> 749 </p>'; 750 751 $list_html .= wp_nonce_field( 'bp_xprofile_edit' ); 752 753 // If the user submitted the form to save new values, and there were errors, make sure we display them. 754 if ( $errors && isset($_POST['save']) ) { 755 $type = 'error'; 756 $message = __('There were problems saving your information. Please fix the following:<br />', 'buddypress'); 757 758 for ( $i = 0; $i < count($errors); $i++ ) { 759 $message .= $errors[$i]; 760 } 761 762 // If there were no errors then we can display a nice "Changes saved." message. 763 } else if ( !$errors && isset($_POST['save'] ) ) { 764 $type = 'success'; 765 $message = __('Changes saved.', 'buddypress'); 766 767 // Record in activity stream 768 xprofile_record_activity( array( 'item_id' => $group->id, 'component_name' => $bp->profile->slug, 'component_action' => 'updated_profile', 'is_private' => 0 ) ); 769 770 do_action( 'xprofile_updated_profile', $group->id ); 771 } 772 } 773 // If this is an invalid group, then display an error. 774 else { ?> 775 <div id="message" class="error fade"> 776 <p><?php _e('That group does not exist.', 'buddypress'); ?></p> 777 </div> 778 <?php 779 } 780 781 ?> 782 783 <?php // Finally, we can now render everything to the screen. ?> 784 785 <?php 786 if ( $message != '' ) { 787 $type = ( 'error' == $type ) ? 'error' : 'updated'; 788 ?> 789 <div id="message" class="<?php echo $type; ?> fade"> 790 <p><?php echo $message; ?></p> 791 </div> 792 <?php } ?> 793 794 <p><form action="<?php echo $action ?>" method="post" id="profile-edit-form" class="generic-form"> 795 <?php 796 if ( $field_ids ) 797 $field_ids = implode( ",", $field_ids ); 798 ?> 799 <input type="hidden" name="field_ids" id="field_ids" value="<?php echo attribute_escape( $field_ids ); ?>" /> 800 801 <?php echo $list_html; ?> 802 803 </form> 804 </p> 805 806 </div> 807 <?php 808 } 718 719 /*** Field Group Management **************************************************/ 720 721 function xprofile_insert_field_group( $args = '' ) { 722 $defaults = array( 723 'field_group_id' => false, 724 'name' => false, 725 'description' => '', 726 'can_delete' => true 727 ); 728 729 $r = wp_parse_args( $args, $defaults ); 730 extract( $r, EXTR_SKIP ); 731 732 if ( !$name ) 733 return false; 734 735 $field_group = new BP_XProfile_Group( $field_group_id ); 736 $field_group->name = $name; 737 $field_group->description = $description; 738 $field_group->can_delete = $can_delete; 739 740 return $field_group->save(); 741 } 742 743 function xprofile_get_field_group( $field_group_id ) { 744 return new BP_XProfile_Group( $field_group_id ); 745 } 746 747 function xprofile_delete_field_group( $field_group_id ) { 748 $field_group = new BP_XProfile_Group( $field_group_id ); 749 return $field_group->delete(); 750 } 751 752 753 /*** Field Management *********************************************************/ 754 755 function xprofile_insert_field( $args = '' ) { 756 extract( $args ); 757 758 /** 759 * Possible parameters (pass as assoc array): 760 * 'field_id' 761 * 'field_group_id' 762 * 'parent_id' 763 * 'type' 764 * 'name' 765 * 'description' 766 * 'is_required' 767 * 'can_delete' 768 * 'field_order' 769 * 'order_by' 770 * 'is_default_option' 771 * 'option_order' 772 */ 773 774 /* Check we have the minimum details */ 775 if ( !$field_group_id ) 776 return false; 777 778 /* Check this is a valid field type */ 779 if ( !in_array( $type, $bp->profile->field_types ) ) 780 return false; 781 782 /* Instantiate a new field object */ 783 if ( $field_id ) 784 $field = new BP_XProfile_Field( $field_id ); 785 else 786 $field = new BP_XProfile_Field; 787 788 $field->field_group_id = $field_group_id; 789 790 if ( !empty( $parent_id ) ) 791 $field->parent_id = $parent_id; 792 793 if ( !empty( $type ) ) 794 $field->type = $type; 795 796 if ( !empty( $name ) ) 797 $field->name = $name; 798 799 if ( !empty( $description ) ) 800 $field->description = $description; 801 802 if ( !empty( $is_required ) ) 803 $field->is_required = $is_required; 804 805 if ( !empty( $can_delete ) ) 806 $field->can_delete = $can_delete; 807 808 if ( !empty( $field_order ) ) 809 $field->field_order = $field_order; 810 811 if ( !empty( $order_by ) ) 812 $field->order_by = $order_by; 813 814 if ( !empty( $is_default_option ) ) 815 $field->is_default_option = $is_default_option; 816 817 if ( !empty( $option_order ) ) 818 $field->option_order = $option_order; 819 820 if ( !$field->save() ) 821 return false; 822 823 return true; 824 } 825 826 function xprofile_get_field( $field_id ) { 827 return new BP_XProfile_Field( $field_id ); 828 } 829 830 function xprofile_delete_field( $field_id ) { 831 $field = new BP_XProfile_Field( $field_id ); 832 return $field->delete(); 833 } 834 835 836 /*** Field Data Management *****************************************************/ 809 837 810 838 /** … … 814 842 * 815 843 * @package BuddyPress Core 816 * @param $field _name The name of the field to get data for.844 * @param $field The ID of the field, or the $name of the field. 817 845 * @param $user_id The ID of the user 818 846 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 820 848 * @return The profile field data. 821 849 */ 822 function xprofile_get_field_data( $field _name, $user_id = null ) {850 function xprofile_get_field_data( $field, $user_id = null ) { 823 851 global $bp; 824 852 825 853 if ( !$user_id ) 826 854 $user_id = $bp->displayed_user->id; 827 828 return apply_filters( 'xprofile_get_field_data', BP_XProfile_ProfileData::get_value_byfieldname( $field_name, $user_id ) ); 855 856 if ( is_numeric( $field ) ) 857 $field_id = $field; 858 else 859 $field_id = xprofile_get_field_id_from_name( $field ); 860 861 if ( !$field_id ) 862 return false; 863 864 return apply_filters( 'xprofile_get_field_data', BP_XProfile_ProfileData::get_value_byid( $field_id, $user_id ) ); 829 865 } 830 866 … … 835 871 * 836 872 * @package BuddyPress Core 837 * @param $field _name The name of the field to set data for.873 * @param $field The ID of the field, or the $name of the field. 838 874 * @param $user_id The ID of the user 839 875 * @param $value The value for the field you want to set for the user. … … 842 878 * @return true on success, false on failure. 843 879 */ 844 function xprofile_set_field_data( $field_name, $user_id, $value ) { 845 global $bp; 846 847 if ( !$field_id = xprofile_get_field_id_from_name( $field_name ) ) 880 function xprofile_set_field_data( $field, $user_id, $value ) { 881 if ( is_numeric( $field ) ) 882 $field_id = $field; 883 else 884 $field_id = xprofile_get_field_id_from_name( $field ); 885 886 if ( !$field_id ) 848 887 return false; 849 888 … … 851 890 $field->field_id = $field_id; 852 891 $field->user_id = $user_id; 853 $field->value = $value;892 $field->value = maybe_serialize( $value ); 854 893 855 894 return $field->save(); 895 } 896 897 function xprofile_delete_field_data( $field, $user_id ) { 898 if ( is_numeric( $field ) ) 899 $field_id = $field; 900 else 901 $field_id = xprofile_get_field_id_from_name( $field ); 902 903 if ( !$field_id ) 904 return false; 905 906 $field = new BP_XProfile_ProfileData( $field_id ); 907 return $field->delete(); 908 } 909 910 function xprofile_check_is_required_field( $field_id ) { 911 $field = new BP_Xprofile_Field( $field_id ); 912 913 if ( (int)$field->is_required ) 914 return true; 915 916 return false; 856 917 } 857 918 … … 920 981 return stripslashes( stripslashes( $field_value ) ); 921 982 } 983 984 function xprofile_avatar_upload_dir( $directory = false, $user_id = false ) { 985 global $bp; 986 987 if ( !$user_id ) 988 $user_id = $bp->displayed_user->id; 989 990 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 991 $newdir = path_join( ABSPATH, $path ); 992 $newdir .= '/avatars/' . $user_id; 993 994 $newbdir = $newdir; 995 996 if ( !file_exists( $newdir ) ) 997 @wp_mkdir_p( $newdir ); 998 999 $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $user_id; 1000 $newburl = $newurl; 1001 $newsubdir = '/avatars/' . $user_id; 1002 1003 return apply_filters( 'xprofile_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 1004 } 1005 922 1006 923 1007 /** -
trunk/bp-xprofile/bp-xprofile-classes.php
r1473 r1636 1 1 <?php 2 3 /**************************************************************************4 PLUGIN CLASSES5 --------------------------------------------------------------------------6 - BP_XProfile_Group -- Profile group management7 - BP_XProfile_Field -- Profile field management8 - BP_XProfile_ProfileData -- Profile data management9 - BP_XProfile_Picture -- Profile picture management10 --------------------------------------------------------------------------11 **************************************************************************/12 2 13 3 Class BP_XProfile_Group { … … 776 766 </form> 777 767 778 <div class="clear"> </div><br />779 780 <h2><?php _e( 'Add Prebuilt Field', 'buddypress' ) ?></h2>781 <?php $this->render_prebuilt_fields(); ?>782 768 783 769 </div> 784 770 785 771 <?php 786 }787 788 /** Static Functions **/789 function render_prebuilt_fields() {790 $action = "admin.php?page=" . BP_PLUGIN_DIR . "/bp-xprofile.php&group_id=" . $this->group_id . "&mode=add_field";791 792 // Files in wp-content/themes directory and one subdir down793 $prebuilt_fields_path = BP_PLUGIN_DIR . '/bp-xprofile/prebuilt-fields';794 if( !empty( $prebuilt_fields_path ) ){795 $prebuilt_fields_dir = @opendir($prebuilt_fields_path);796 if ( $prebuilt_fields_dir ){797 ?><table class="form-table"><?php798 $counter = 0;799 while ( ($field_file = readdir( $prebuilt_fields_dir )) !== false ) {800 801 if ( $field_file{0} == '.' || $field_file == '..' || $field_file == 'CVS' || $field_file == '.svn' )802 continue;803 804 $field_file_path = $prebuilt_fields_path . '/' . $field_file;805 806 if ( is_readable( $field_file_path ) ) {807 $field_data = $this->get_prebuilt_field_data( $field_file_path ); ?>808 <tr>809 <td style="vertical-align:top;">810 <h3>811 <?php echo $field_data['Name'] . $field_data['Version']; ?> by <a href="<?php echo $field_data['URI'];?>">812 <?php echo $field_data['Author'];?></a>813 </h3>814 </td>815 <td>816 <form action="<?php echo $action ?>" method="post">817 818 <label for="title">* <?php _e("Field Title", 'buddypress') ?></label>819 <div>820 <input type="text" name="title" id="title" value="<?php echo attribute_escape( $field_data['Name'] ); ?>" style="width:50%" />821 </div>822 <p></p>823 <label for="description"><?php _e("Field Description", 'buddypress') ?></label>824 <div>825 <textarea name="description" id="description" rows="5" cols="60"><?php echo htmlspecialchars( $field_data['Description'] ); ?></textarea>826 </div>827 <p></p>828 <label for="required">* <?php _e("Is This Field Required?", 'buddypress') ?></label>829 <div>830 <select name="required" id="required">831 <option value="0"<?php if ( $this->is_required == '0' ) { ?> selected="selected"<?php } ?>><?php _e( 'Not Required', 'buddypress' ) ?></option>832 <option value="1"<?php if ( $this->is_required == '1' ) { ?> selected="selected"<?php } ?>><?php _e( 'Required', 'buddypress' ) ?></option>833 </select>834 </div>835 <p></p>836 <label for="fieldtype">* <?php _e("Field Type", 'buddypress') ?></label>837 <div>838 <select name="fieldtype" id="fieldtype" onchange="show_options(this.value)">839 <?php if (in_array('textbox', $field_data['Types'])) { ?>840 <option value="textbox"<?php if ( $this->type == 'textbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Text Box', 'buddypress' ) ?></option>841 <?php } if (in_array('textarea', $field_data['Types'])) { ?>842 <option value="textarea"<?php if ( $this->type == 'textarea' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi-line Text Box', 'buddypress' ) ?></option>843 <?php } if (in_array('datebox', $field_data['Types'])) { ?>844 <option value="datebox"<?php if ( $this->type == 'datebox' ) {?> selected="selected"<?php } ?>><?php _e( 'Date Selector', 'buddypress' ) ?></option>845 <?php } if (in_array('radio', $field_data['Types'])) { ?>846 <option value="radio"<?php if ( $this->type == 'radio' ) {?> selected="selected"<?php } ?>><?php _e( 'Radio Buttons', 'buddypress' ) ?></option>847 <?php } if (in_array('selectbox', $field_data['Types'])) { ?>848 <option value="selectbox"<?php if ( $this->type == 'selectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Drop Down Select Box', 'buddypress' ) ?></option>849 <?php } if (in_array('multiselectbox', $field_data['Types'])) { ?>850 <option value="multiselectbox"<?php if ( $this->type == 'multiselectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi Select Box', 'buddypress' ) ?></option>851 <?php } ?>852 </select>853 </div>854 855 <p class="submit">856 <input type="submit" value="<?php _e("Add", 'buddypress') ?> »" name="saveField" id="saveField<?php echo $counter;?>" class="button" />857 <input type="hidden" name="field_file" value="<?php echo attribute_escape( $field_file_path ); ?>">858 </p>859 </form>860 </td>861 </tr>862 <?php863 }864 $counter++;865 }866 ?></table><?php867 } else {868 ?><p><?php _e('No prebuilt fields available at this time.', 'buddypress') ?></p><?php869 }870 @closedir( $prebuilt_fields_dir );871 }872 }873 874 function get_prebuilt_field_data( $field_file ) {875 $allowed_tags = array(876 'a' => array(877 'href' => array(),'title' => array()878 ),879 'abbr' => array(880 'title' => array()881 ),882 'acronym' => array(883 'title' => array()884 ),885 'code' => array(),886 'em' => array(),887 'strong' => array()888 );889 890 $field_data = implode( '', file( $field_file ) );891 $field_data = str_replace ( '\r', '\n', $field_data );892 preg_match( '|Field Name:(.*)$|mi', $field_data, $field_name );893 preg_match( '|URI:(.*)$|mi', $field_data, $uri );894 preg_match( '|Description:(.*)$|mi', $field_data, $description );895 preg_match( '|Types:(.*)$|mi', $field_data, $types );896 897 if ( preg_match( '|Version:(.*)|i', $field_data, $version ) )898 $version = wp_kses( trim( $version[1] ), $allowed_tags );899 else900 $version = '';901 902 $name = wp_kses( trim( $field_name[1] ), $allowed_tags );903 $description = wptexturize( wp_kses( trim( $description[1] ), $allowed_tags ) );904 $types = split( ",", wptexturize( wp_kses( trim( $types[1] ), $allowed_tags ) ) );905 906 if ( preg_match( '|Author:(.*)$|mi', $field_data, $author_name ) ) {907 if ( empty( $author_uri ) ) {908 $author = wp_kses( trim( $author_name[1] ), $allowed_tags );909 } else {910 $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' , 'buddypress'),911 wp_kses( trim( $author_name[1] ), $allowed_tags ) );912 }913 } else {914 $author = __('Anonymous', 'buddypress');915 }916 917 return array( 'Name' => $name, 'URI' => $uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Types' => $types);918 772 } 919 773 -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r1366 r1636 1 1 <?php 2 3 function xprofile_add_js() {4 if ( $_SERVER['SCRIPT_NAME'] == '/wp-signup.php' )5 wp_enqueue_script( 'jquery' );6 }7 add_action( 'wp', 'xprofile_add_js' );8 9 function xprofile_add_css() {10 if ( $_SERVER['SCRIPT_NAME'] == '/wp-signup.php' )11 wp_enqueue_style( 'bp-xprofile-signup', BP_PLUGIN_URL . '/bp-xprofile/css/signup.css' );12 13 wp_print_styles();14 }15 add_action( 'wp_head', 'xprofile_add_css' );16 17 function xprofile_add_structure_css() {18 /* Enqueue the structure CSS file to give basic positional formatting for xprofile pages */19 wp_enqueue_style( 'bp-xprofile-structure', BP_PLUGIN_URL . '/bp-xprofile/css/structure.css' );20 }21 add_action( 'bp_styles', 'xprofile_add_structure_css' );22 2 23 3 function xprofile_add_admin_css() { … … 34 14 add_action( 'admin_head', 'xprofile_add_admin_js' ); 35 15 36 function xprofile_add_cropper_js() {37 global $bp;38 39 if ( $_SERVER['SCRIPT_NAME'] == '/wp-activate.php' || $bp->current_component == BP_ACTIVATION_SLUG || $bp->current_action == 'change-avatar' ) {40 //wp_enqueue_script('jquery');41 //wp_enqueue_script('prototype');42 wp_enqueue_script('scriptaculous-root');43 wp_enqueue_script('cropper');44 add_action( 'wp_head', 'bp_core_add_cropper_js' );45 }46 47 if ( isset($_GET['page']) && $_GET['page'] == 'bp-xprofile.php' ) {48 add_action( 'admin_head', 'bp_core_add_cropper_js' );49 }50 }51 add_action( 'activate_header', 'xprofile_add_cropper_js' );52 add_action( 'template_redirect', 'xprofile_add_cropper_js', 1 );53 add_action( 'admin_menu', 'xprofile_add_cropper_js' );54 55 16 ?> -
trunk/bp-xprofile/bp-xprofile-filters.php
r1608 r1636 6 6 add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 ); 7 7 add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 ); 8 9 add_filter( 'bp_get_the_profile_field_edit_value', 'wp_filter_kses', 1 ); 10 add_filter( 'bp_get_the_profile_field_description', 'wp_filter_kses', 1 ); 8 11 9 12 add_filter( 'xprofile_field_name_before_save', 'force_balance_tags' ); -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r1608 r1636 1 1 <?php 2 2 3 Class BP_XProfile_Template { 3 /*************************************************************************** 4 * XProfile Data Display Template Tags 5 **/ 6 7 Class BP_XProfile_Data_Template { 4 8 var $current_group = -1; 5 9 var $group_count; … … 16 20 var $user_id; 17 21 18 function bp_xprofile_ template( $user_id, $profile_group_id ) {22 function bp_xprofile_data_template( $user_id, $profile_group_id ) { 19 23 20 24 if ( !$profile_group_id ) { … … 75 79 return true; 76 80 } elseif ( $this->current_group + 1 == $this->group_count ) { 77 do_action(' loop_end');81 do_action('xprofile_template_loop_end'); 78 82 // Do some cleaning up after the loop 79 83 $this->rewind_groups(); … … 91 95 92 96 if ( 0 == $this->current_group ) // loop has just started 93 do_action(' loop_start');97