PHP Class AvatarModel, huge

Inheritance: extends Model
Show file Open project: panique/huge Class Usage Examples

Public Methods

Method Description
createAvatar ( ) Create an avatar picture (and checks all necessary things too) TODO decouple TODO total rebuild
deleteAvatar ( integer $userId ) : boolean Delete a user's avatar
deleteAvatarImageFile ( integer $userId ) : boolean Removes the avatar image file from the filesystem
getGravatarLinkByEmail ( string $email ) : string Gets a gravatar image link from given email address
getPublicAvatarFilePathOfUser ( integer $user_has_avatar, integer $user_id ) : string Gets the user's avatar file path
getPublicUserAvatarFilePathByUserId ( $user_id ) : string Gets the user's avatar file path
isAvatarFolderWritable ( ) : boolean Checks if the avatar folder exists and is writable
resizeAvatarImage ( string $source_image, string $destination, integer $final_width = 44, integer $final_height = 44 ) : boolean Resize avatar image (while keeping aspect ratio and cropping it off in a clean way).
validateImageFile ( ) : boolean Validates the image Only accepts gif, jpg, png types
writeAvatarToDatabase ( $user_id ) Writes marker to database, saying user has an avatar now

Method Details

createAvatar() public static method

Create an avatar picture (and checks all necessary things too) TODO decouple TODO total rebuild
public static createAvatar ( )

deleteAvatar() public static method

Delete a user's avatar
public static deleteAvatar ( integer $userId ) : boolean
$userId integer
return boolean success

deleteAvatarImageFile() public static method

Removes the avatar image file from the filesystem
public static deleteAvatarImageFile ( integer $userId ) : boolean
$userId integer
return boolean

getGravatarLinkByEmail() public static method

Gravatar is the #1 (free) provider for email address based global avatar hosting. The URL (or image) returns always a .jpg file ! For deeper info on the different parameter possibilities:
See also: http://gravatar.com/site/implement/images/
public static getGravatarLinkByEmail ( string $email ) : string
$email string The email address
return string

getPublicAvatarFilePathOfUser() public static method

Gets the user's avatar file path
public static getPublicAvatarFilePathOfUser ( integer $user_has_avatar, integer $user_id ) : string
$user_has_avatar integer Marker from database
$user_id integer User's id
return string Avatar file path

getPublicUserAvatarFilePathByUserId() public static method

Gets the user's avatar file path
public static getPublicUserAvatarFilePathByUserId ( $user_id ) : string
$user_id integer The user's id
return string avatar picture path

isAvatarFolderWritable() public static method

Checks if the avatar folder exists and is writable
public static isAvatarFolderWritable ( ) : boolean
return boolean success status

resizeAvatarImage() public static method

Only works with gif, jpg and png file types. If you want to change this also have a look into method validateImageFile() inside this model. TROUBLESHOOTING: You don't see the new image ? Press F5 or CTRL-F5 to refresh browser cache.
public static resizeAvatarImage ( string $source_image, string $destination, integer $final_width = 44, integer $final_height = 44 ) : boolean
$source_image string The location to the original raw image
$destination string The location to save the new image
$final_width integer The desired width of the new image
$final_height integer The desired height of the new image
return boolean success state

validateImageFile() public static method

Validates the image Only accepts gif, jpg, png types
See also: http://php.net/manual/en/function.image-type-to-mime-type.php
public static validateImageFile ( ) : boolean
return boolean

writeAvatarToDatabase() public static method

Writes marker to database, saying user has an avatar now
public static writeAvatarToDatabase ( $user_id )
$user_id