ProfilePhoto
extends Entity
in package
Profile photo class
This class maps the profile_photos table.
It also provides helper methods to handle avatars or get all the photos from a specified perso.
Table of Contents
Properties
- $avatar : mixed
- $description : mixed
- $id : mixed
- $lastError : string
- $name : mixed
- $perso_id : mixed
- $db : DatabaseEngine
Methods
- __construct() : mixed
- Initializes a new instance of the ProfilePhoto class
- delete() : mixed
- Deletes the photo
- generate_thumbnail() : bool
- Generates a thumbnail using ImageMagick binary
- get_avatar() : mixed
- Gets perso avatar
- get_photos() : array<string|int, ProfilePhoto>
- Gets photos from the specified perso
- getDatabase() : DatabaseEngine
- load_from_database() : bool
- Loads the object photo (ie fill the properties) from the database
- load_from_form() : mixed
- Loads the object photo (ie fill the properties) from the $_POST array
- promote_to_avatar() : mixed
- Promotes the photo to avatar
- save_to_database() : void
- Saves the object to the database
- setDatabase() : void
Properties
$avatar
public
mixed
$avatar
$description
public
mixed
$description
$id
public
mixed
$id
$lastError
public
string
$lastError
= ""
$name
public
mixed
$name
$perso_id
public
mixed
$perso_id
$db
private
DatabaseEngine
$db
Methods
__construct()
Initializes a new instance of the ProfilePhoto class
public
__construct(DatabaseEngine $db[, mixed $id = '' ]) : mixed
Parameters
- $db : DatabaseEngine
- $id : mixed = ''
delete()
Deletes the photo
public
delete() : mixed
generate_thumbnail()
Generates a thumbnail using ImageMagick binary
public
generate_thumbnail() : bool
Return values
bool —true if the thumbnail command returns 0 as program exit code ; otherwise, false
get_avatar()
Gets perso avatar
public
static get_avatar(DatabaseEngine $db, int $perso_id[, string $username = '' ]) : mixed
Parameters
- $db : DatabaseEngine
- $perso_id : int
-
the perso to get the avatar ID
- $username : string = ''
-
the username to put in title tag
get_photos()
Gets photos from the specified perso
public
static get_photos(DatabaseEngine $db, int $perso_id[, bool $allowUnsafe = true ]) : array<string|int, ProfilePhoto>
Parameters
- $db : DatabaseEngine
- $perso_id : int
-
the perso ID
- $allowUnsafe : bool = true
-
if false, don't include not safe for work photos
Return values
array<string|int, ProfilePhoto>getDatabase()
public
getDatabase() : DatabaseEngine
Return values
DatabaseEngineload_from_database()
Loads the object photo (ie fill the properties) from the database
public
load_from_database() : bool
Return values
boolload_from_form()
Loads the object photo (ie fill the properties) from the $_POST array
public
load_from_form([bool $readBoolean = true ]) : mixed
Parameters
- $readBoolean : bool = true
-
if false, don't read the bool avatar field to avoid to set by error false if the field weren't in the form.
promote_to_avatar()
Promotes the photo to avatar
public
promote_to_avatar() : mixed
save_to_database()
Saves the object to the database
public
save_to_database() : void
setDatabase()
public
setDatabase(DatabaseEngine $db) : void
Parameters
- $db : DatabaseEngine