Changeset 2025
- Timestamp:
- 10/02/2009 10:07:58 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-activation.php
r1970 r2025 5 5 6 6 if ( BP_ACTIVATION_SLUG != $bp->current_component ) 7 return false; 8 9 /* If we are using a BuddyPress 1.0 theme ignore this. */ 10 if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 7 11 return false; 8 12 … … 68 72 } 69 73 70 bp_core_load_template( 'registration/activate' ); 74 if ( '' != locate_template( array( 'registration/activate' ), false ) ) 75 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) ); 76 else 77 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) ); 71 78 } 72 79 add_action( 'wp', 'bp_core_screen_activation', 3 ); -
trunk/bp-core/bp-core-avatars.php
r2002 r2025 283 283 $r = wp_parse_args( $args, $defaults ); 284 284 extract( $r, EXTR_SKIP ); 285 285 286 286 if ( !$original_file ) 287 287 return false; … … 318 318 $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 ); 319 319 $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 ); 320 320 321 321 /* Remove the original */ 322 322 @unlink( WP_CONTENT_DIR . $original_file ); -
trunk/bp-core/bp-core-cssjs.php
r2017 r2025 123 123 124 124 jQuery('#avatar-crop-preview').css({ 125 <?php if ( $image ) : ?> 125 126 width: Math.round(rx * <?php echo $image[0] ?>) + 'px', 126 127 height: Math.round(ry * <?php echo $image[1] ?>) + 'px', 128 <?php endif; ?> 127 129 marginLeft: '-' + Math.round(rx * coords.x) + 'px', 128 130 marginTop: '-' + Math.round(ry * coords.y) + 'px' -
trunk/bp-core/deprecated/bp-core-deprecated.php
r1984 r2025 712 712 } 713 713 714 function bp_core_handle_avatar_upload($file) { 715 global $wp_upload_error; 716 717 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 718 719 // Change the upload file location to /avatars/user_id 720 add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' ); 721 722 $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') ); 723 724 if ( !in_array('error', array_keys($res) ) ) { 725 return $res['file']; 726 } else { 727 $wp_upload_error = $res['error']; 728 return false; 729 } 730 } 731 732 function bp_core_resize_avatar( $file, $size = false ) { 733 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 734 735 if ( !$size ) 736 $size = CORE_CROPPING_CANVAS_MAX; 737 738 $canvas = wp_create_thumbnail( $file, $size ); 739 740 if ( $canvas->errors ) 741 return false; 742 743 return $canvas = str_replace( '//', '/', $canvas ); 744 } 714 745 715 746 /*** END OLD AVATAR CROPPING SUPPORT **************************/ -
trunk/bp-groups.php
r2004 r2025 569 569 } 570 570 } 571 572 //var_dump($_COOKIE); 571 573 572 bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) ); 574 573 } -
trunk/bp-xprofile/bp-xprofile-classes.php
r1977 r2025 622 622 } 623 623 } 624 625 /* Deprecated - Signup fields are now in the template */626 function get_signup_fields() {627 global $wpdb, $bp;628 629 $sql = $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f, {$bp->profile->table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0 AND g.id = f.group_id ORDER BY f.id", get_site_option('bp-xprofile-base-group-name') );630 631 if ( !$temp_fields = $wpdb->get_results($sql) )632 return false;633 634 for ( $i = 0; $i < count($temp_fields); $i++ ) {635 $fields[] = new BP_XProfile_Field( $temp_fields[$i]->id, null, false );636 }637 638 return $fields;639 }640 641 624 } 642 625 -
trunk/bp-xprofile/deprecated/bp-xprofile-deprecated.php
r1905 r2025 406 406 return $html; 407 407 } 408 409 /* Deprecated - Signup fields are now in the template */ 410 function get_signup_fields() { 411 global $wpdb, $bp; 412 413 $sql = $wpdb->prepare( "SELECT f.id FROM {$bp->profile->table_name_fields} AS f, {$bp->profile->table_name_groups} AS g WHERE g.name = %s AND f.parent_id = 0 AND g.id = f.group_id ORDER BY f.id", get_site_option('bp-xprofile-base-group-name') ); 414 415 if ( !$temp_fields = $wpdb->get_results($sql) ) 416 return false; 417 418 for ( $i = 0; $i < count($temp_fields); $i++ ) { 419 $fields[] = new BP_XProfile_Field_Deprecated( $temp_fields[$i]->id, null, false ); 420 } 421 422 return $fields; 423 } 424 408 425 409 426 } … … 425 442 426 443 /* Fetch the fields needed for the signup form */ 427 $fields = BP_XProfile_Field ::get_signup_fields();444 $fields = BP_XProfile_Field_Deprecated::get_signup_fields(); 428 445 429 446 if ( $fields ) { … … 537 554 538 555 // Validate all sign up fields 539 $fields = BP_XProfile_Field ::get_signup_fields();556 $fields = BP_XProfile_Field_Deprecated::get_signup_fields(); 540 557 541 558 if ( $fields ) { … … 619 636 if ( $checked_upload && $checked_size && $checked_type && !$original = bp_core_handle_avatar_upload($_FILES) ) { 620 637 $bp_signup_avatar_has_errors = true; 621 $avatar_error_msg = sprintf( __('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error ); 638 $avatar_error_msg = sprintf( __('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error ); 639 die; 622 640 } 623 641 … … 639 657 $bp_user_signup_meta['avatar_image_original'] = $original; 640 658 641 setcookie( 'bp_xprofile_meta', serialize($bp_user_signup_meta), time()+60*60*24, COOKIEPATH);659 $bp_user_signup_meta = serialize( $bp_user_signup_meta ); 642 660 } 643 661 } 644 662 add_action( 'init', 'xprofile_load_signup_meta' ); 663 664 function xprofile_render_user_signup_meta() { 665 global $bp_user_signup_meta; 666 667 echo '<input type="hidden" name="bp_xprofile_meta" id="bp_xprofile_meta" value="' . attribute_escape( $bp_user_signup_meta ) . '" />'; 668 } 669 add_action( 'signup_blogform', 'xprofile_render_user_signup_meta' ); 645 670 646 671 function xprofile_load_blog_signup_meta() { … … 656 681 ); 657 682 658 $bp_meta = unserialize( stripslashes( $_ COOKIE['bp_xprofile_meta'] ) );659 $bp_blog_signup_meta = array_merge( $bp_meta,$blog_meta );683 $bp_meta = unserialize( stripslashes( $_POST['bp_xprofile_meta'] ) ); 684 $bp_blog_signup_meta = array_merge( (array)$bp_meta, (array)$blog_meta ); 660 685 } 661 686 add_action( 'init', 'xprofile_load_blog_signup_meta' ); … … 671 696 add_action( 'wpmu_activate_blog', 'xprofile_on_activate_blog', 1, 5 ); 672 697 673 674 698 function xprofile_on_activate_user( $user_id, $password, $meta ) { 675 699 xprofile_extract_signup_meta( $user_id, $meta ); … … 680 704 xprofile_handle_signup_avatar( $user_id, $meta ); 681 705 } 682 add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 3);706 add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 5 ); 683 707 684 708 function xprofile_extract_signup_meta( $user_id, $meta ) { … … 706 730 707 731 function xprofile_handle_signup_avatar( $user_id, $meta ) { 732 global $bp; 733 734 $meta = maybe_unserialize( $meta ); 735 708 736 $resized = $meta['avatar_image_resized']; 709 737 $original = $meta['avatar_image_original']; 710 738 711 739 if ( !empty($resized) && !empty($original) ) { 712 740 // Create and set up the upload dir first. 713 $upload_dir = bp_core_avatar_upload_dir( false, $user_id );741 $upload_dir = xprofile_avatar_upload_dir( false, $user_id ); 714 742 715 743 $resized_strip_path = explode( '/', $resized ); … … 730 758 $resized = $resized_new; 731 759 $original = $original_new; 732 733 // Render the cropper UI 734 $action = bp_activation_page( false ) . '?key=' . $_GET['key'] . '&cropped=true'; 735 bp_core_render_avatar_cropper($original, $resized, $action, $user_id); 736 } 737 } 760 761 $bp->avatar_admin->image = new stdClass; 762 $bp->avatar_admin->image->dir = $resized; 763 764 /* Set the url value for the image */ 765 $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir ); 766 767 ?> 768 <form action="<?php echo $bp->root_domain . '/' . BP_ACTIVATION_SLUG ?>" method="post"> 769 <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3> 770 771 <img src="<?php echo attribute_escape( $bp->avatar_admin->image->url ) ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" /> 772 773 <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" /> 774 775 <input type="hidden" name="image_src" id="image_src" value="<?php echo attribute_escape( $bp->avatar_admin->image->dir ) ?>" /> 776 <input type="hidden" id="x" name="x" /> 777 <input type="hidden" id="y" name="y" /> 778 <input type="hidden" id="w" name="w" /> 779 <input type="hidden" id="h" name="h" /> 780 <input type="hidden" id="cropped" name="cropped" /> 781 <input type="hidden" id="key" name="key" value="<?php echo attribute_escape( $_GET['key'] ) ?>"/> 782 783 <?php wp_nonce_field( 'bp_avatar_cropstore' ); ?> 784 </form><?php 785 } 786 } 787 788 function xprofile_deprecated_add_cropper_js() { 789 global $bp; 790 791 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 792 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 793 return false; 794 795 if ( $bp->current_component == BP_ACTIVATION_SLUG ) 796 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 797 } 798 add_action( 'init', 'xprofile_deprecated_add_cropper_js' ); 738 799 739 800 function xprofile_catch_activate_crop() { 740 if ( isset( $_GET['cropped'] ) ) { 801 if ( isset( $_POST['cropped'] ) ) { 802 741 803 // The user has cropped their avatar after activating account 742 804 743 805 // Confirm that the nonce is valid 744 if ( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'slick_avatars' ) ) 745 bp_core_redirect( get_option('home') ); 746 747 $user_id = xprofile_get_user_by_key($_GET['key']); 748 749 if ( $user_id && isset( $_POST['orig'] ) && isset( $_POST['canvas'] ) ) { 750 bp_core_check_crop( $_POST['orig'], $_POST['canvas'] ); 751 $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'] ); 752 bp_core_avatar_save( $result, $user_id ); 753 } 754 806 check_admin_referer( 'bp_avatar_cropstore' ); 807 808 $user_id = xprofile_get_user_by_key( $_POST['key'] ); 809 810 bp_core_avatar_handle_crop( array( 'item_id' => $user_id, 'original_file' => str_replace( WP_CONTENT_DIR, '', $_POST['image_src'] ), 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ); 811 755 812 $ud = get_userdata($user_id); 756 813 $url = site_url( BP_MEMBERS_SLUG . '/' . $ud->user_login ); 757 814 758 815 bp_core_redirect( $url ); 759 816 } 760 817 } 761 818 add_action( 'activate_header', 'xprofile_catch_activate_crop' ); 762 763 819 764 820 function xprofile_get_user_by_key($key) {
Note: See TracChangeset
for help on using the changeset viewer.