Changeset 1760
- Timestamp:
- 09/02/2009 07:54:19 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-avatars.php
r1714 r1760 140 140 'item_id' => false, 141 141 'object' => 'user', // user OR group OR blog OR custom type (if you use filters) 142 'avatar_ path' => false142 'avatar_dir' => false 143 143 ); 144 144 145 $r = wp_parse_args( $args, $defaults ); 146 extract( $r, EXTR_SKIP ); 147 148 if ( !$avatar_path ) 149 return false; 145 $args = wp_parse_args( $args, $defaults ); 146 extract( $args, EXTR_SKIP ); 147 148 if ( !$item_id ) { 149 if ( 'user' == $object ) 150 $item_id = $bp->displayed_user->id; 151 else if ( 'group' == $object ) 152 $item_id = $bp->groups->current_group->id; 153 else if ( 'blog' == $object ) 154 $item_id = $current_blog->id; 155 156 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object ); 157 158 if ( !$item_id ) return false; 159 } 160 161 if ( !$avatar_dir ) { 162 if ( 'user' == $object ) 163 $avatar_dir = 'avatars'; 164 else if ( 'group' == $object ) 165 $avatar_dir = 'group-avatars'; 166 else if ( 'blog' == $object ) 167 $avatar_dir = 'blog-avatars'; 168 169 $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object ); 170 171 if ( !$avatar_dir ) return false; 172 } 150 173 151 174 if ( 'user' == $object ) { … … 157 180 } 158 181 159 if ( $av_dir = opendir( $avatar_path ) ) { 182 $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 ); 183 184 if ( !file_exists( $avatar_folder_dir ) ) 185 return false; 186 187 if ( $av_dir = opendir( $avatar_folder_dir ) ) { 160 188 while ( false !== ( $avatar_file = readdir($av_dir) ) ) { 161 189 if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file ) 162 @unlink( $avatar_ path . '/' . $avatar_file );190 @unlink( $avatar_folder_dir . '/' . $avatar_file ); 163 191 } 164 192 } 165 193 closedir($av_dir); 194 195 @rmdir( $avatar_folder_dir ); 196 197 do_action( 'bp_core_delete_existing_avatar', $args ); 198 199 return true; 166 200 } 167 201 -
trunk/bp-groups.php
r1750 r1760 1018 1018 if ( !$bp->is_item_admin ) 1019 1019 return false; 1020 1021 /* If the group admin has deleted the admin avatar */ 1022 if ( 'delete' == $bp->action_variables[1] ) { 1023 1024 /* Check the nonce */ 1025 check_admin_referer( 'bp_group_avatar_delete' ); 1026 1027 if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) ) 1028 bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) ); 1029 else 1030 bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' ); 1031 1032 } 1020 1033 1021 1034 $bp->avatar_admin->step = 'upload-image'; 1022 1035 1023 1036 if ( !empty( $_FILES ) ) { 1024 1037 1025 1038 /* Check the nonce */ 1026 1039 check_admin_referer( 'bp_avatar_upload' ); … … 1033 1046 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 1034 1047 } 1035 1048 1036 1049 } 1037 1050 1038 1051 /* If the image cropping is done, crop the image and save a full/thumb version */ 1039 1052 if ( isset( $_POST['avatar-crop-submit'] ) ) { 1040 1053 1041 1054 /* Check the nonce */ 1042 1055 check_admin_referer( 'bp_avatar_cropstore' ); -
trunk/bp-groups/bp-groups-templatetags.php
r1730 r1760 63 63 <?php } 64 64 } 65 66 67 function bp_get_group_has_avatar() { 68 global $bp; 69 70 if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) ) 71 return false; 72 73 return true; 74 } 75 76 function bp_group_avatar_delete_link() { 77 echo bp_get_group_avatar_delete_link(); 78 } 79 function bp_get_group_avatar_delete_link() { 80 global $bp; 81 82 return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) ); 83 } 65 84 66 85 function bp_group_avatar_edit_form() { … … 399 418 'height' => false, 400 419 'class' => 'avatar', 401 'id' => 'avatar-crop-preview',420 'id' => false, 402 421 'alt' => __( 'Group avatar', 'buddypress' ) 403 422 ); -
trunk/bp-xprofile.php
r1750 r1760 445 445 global $bp; 446 446 447 if ( 'delete-avatar' != $bp->current_action ) 448 return false; 449 450 if ( !check_admin_referer( 'bp_delete_avatar_link' ) ) 451 return false; 452 453 if ( !bp_is_home() ) 454 return false; 455 456 bp_core_delete_avatar(); 457 add_action( 'wp_head', 'bp_core_add_cropper_js' ); 458 bp_core_load_template( apply_filters( 'xprofile_template_delete_avatar', 'profile/change-avatar' ) ); 447 if ( $bp->profile->slug != $bp->current_component || 'change-avatar' != $bp->current_action || 'delete-avatar' != $bp->action_variables[0] ) 448 return false; 449 450 /* Check the nonce */ 451 check_admin_referer( 'bp_delete_avatar_link' ); 452 453 if ( !bp_is_home() && !is_site_admin() ) 454 return false; 455 456 if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->displayed_user->id ) ) ) 457 bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) ); 458 else 459 bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' ); 460 461 bp_core_redirect( $_SERVER['HTTP_REFERER'] ); 459 462 } 460 463 add_action( 'wp', 'xprofile_action_delete_avatar', 3 ); -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r1747 r1760 640 640 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); // admin/profile/edit/[group-id] 641 641 } 642 642 643 function bp_avatar_delete_link() { 644 echo bp_get_avatar_delete_link(); 645 } 646 function bp_get_avatar_delete_link() { 647 global $bp; 648 649 return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->profile->slug . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) ); 650 } 651 652 function bp_get_user_has_avatar() { 653 if ( !bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'no_grav' => true ) ) ) 654 return false; 655 656 return true; 657 } 643 658 644 659 function bp_edit_profile_button() {
Note: See TracChangeset
for help on using the changeset viewer.