Merge pull request #60 from ThomasRubini/apprs_profile_pic

This commit is contained in:
Thomas Rubini 2023-01-23 22:37:43 +01:00 committed by GitHub
commit e6d5c63694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View File

@ -188,9 +188,17 @@ final class UserController
$O_userModel = new UserModel();
$A_user = $O_userModel->getUserByID($A_urlParams[0]);
header("Content-Type: image/png");
if (!isset($A_user)) {
die();
}
header("Content-Type: image/png");
if ($A_user["PROFILE_PIC"] === null) {
echo file_get_contents(Constants::rootDir()."/static/img/generic_user.jpg");
} else {
echo $A_user["PROFILE_PIC"];
}
return Utils::RETURN_RAW;
}

View File

@ -6,7 +6,9 @@ final class ApprModel {
{
$O_model = Model::get();
$stmt = $O_model->prepare("
SELECT APPRECIATION.*, USER.USERNAME as AUTHOR_NAME FROM APPRECIATION
SELECT APPRECIATION.*, USER.USERNAME as AUTHOR_NAME,
CONCAT('/user/profilePic/', APPRECIATION.AUTHOR_ID) AS AUTHOR_IMG_LINK
FROM APPRECIATION
JOIN USER ON USER.ID = APPRECIATION.AUTHOR_ID
WHERE RECIPE_ID = :recipe_id
");
@ -15,10 +17,6 @@ final class ApprModel {
$rows = $stmt->fetchAll();
foreach($rows as &$row) {
$row["AUTHOR_IMG_LINK"] = "/static/img/users/1.jpg";
}
return $rows;
}

View File

Before

Width:  |  Height:  |  Size: 452 KiB

After

Width:  |  Height:  |  Size: 452 KiB