PHP Class AvatarModel, huge

Inheritance: extends Model
Afficher le fichier Open project: panique/huge Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

deleteAvatar() public static méthode

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

deleteAvatarImageFile() public static méthode

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

getGravatarLinkByEmail() public static méthode

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
Résultat string

getPublicAvatarFilePathOfUser() public static méthode

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
Résultat string Avatar file path

getPublicUserAvatarFilePathByUserId() public static méthode

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

isAvatarFolderWritable() public static méthode

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

resizeAvatarImage() public static méthode

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
Résultat boolean success state

validateImageFile() public static méthode

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
Résultat boolean

writeAvatarToDatabase() public static méthode

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