Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/05/2011 08:26:32 PM (14 years ago)
Author:
djpaul
Message:

Add some tasty phpdoc. Props Backie, see #2345

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r4400 r4462  
    279279}
    280280
     281/**
     282 * Delete an existing avatar
     283 *
     284 * Accepted values for $args are:
     285 *  item_id - item id which relates to the object type.
     286 *  object - the objetc type user, group, blog, etc.
     287 *  avatar_dir - The directory where the avatars to be uploaded.
     288 *
     289 * @global object $bp BuddyPress global settings
     290 * @param mixed $args
     291 * @return bool Success/failure
     292 */
    281293function bp_core_delete_existing_avatar( $args = '' ) {
    282294    global $bp;
     
    337349}
    338350
     351/**
     352 * Handles avatar uploading.
     353 *
     354 * The functions starts off by checking that the file has been uploaded properly using bp_core_check_avatar_upload().
     355 * It then checks that the file size is within limits, and that it has an accepted file extension (jpg, gif, png).
     356 * If everything checks out, crop the image and move it to its real location.
     357 *
     358 * @global object $bp BuddyPress global settings
     359 * @param array $file The appropriate entry the from $_FILES superglobal.
     360 * @param string $upload_dir_filter A filter to be applied to upload_dir
     361 * @return bool Success/failure
     362 * @see bp_core_check_avatar_upload()
     363 * @see bp_core_check_avatar_type()
     364 */
    339365function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
    340366    global $bp;
     
    422448}
    423449
     450/**
     451 * Crop an uploaded avatar
     452 *
     453 * $args has the following parameters:
     454 *  object - What component the avatar is for, e.g. "user"
     455 *  avatar_dir  The absolute path to the avatar
     456 *  item_id - Item ID
     457 *  original_file - The absolute path to the original avatar file
     458 *  crop_w - Crop width
     459 *  crop_h - Crop height
     460 *  crop_x - The horizontal starting point of the crop
     461 *  crop_y - The vertical starting point of the crop
     462 *
     463 * @global object $bp BuddyPress global settings
     464 * @param mixed $args
     465 * @return bool Success/failure
     466 */
    424467function bp_core_avatar_handle_crop( $args = '' ) {
    425468    global $bp;
     
    538581add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 );
    539582
    540 function bp_core_check_avatar_upload($file) {
     583/**
     584 * Has the current avatar upload generated an error?
     585 *
     586 * @param array $file
     587 * @return bool
     588 */
     589function bp_core_check_avatar_upload( $file ) {
    541590    if ( isset( $file['error'] ) && $file['error'] )
    542591        return false;
     
    545594}
    546595
    547 function bp_core_check_avatar_size($file) {
     596/**
     597 * Is the file size of the current avatar upload permitted?
     598 *
     599 * @param array $file
     600 * @return bool
     601 */
     602function bp_core_check_avatar_size( $file ) {
    548603    if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE )
    549604        return false;
     
    552607}
    553608
     609/**
     610 * Does the current avatar upload have an allowed file type?
     611 *
     612 * Permitted file types are JPG, GIF and PNG.
     613 *
     614 * @param string $file
     615 * @return bool
     616 */
    554617function bp_core_check_avatar_type($file) {
    555618    if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
Note: See TracChangeset for help on using the changeset viewer.