Merge pull request #142 from ThomasRubini/anon_user_2

This commit is contained in:
Thomas Rubini 2023-01-26 19:58:14 +01:00 committed by GitHub
commit 68bf0a4c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -119,6 +119,15 @@ final class RecipeModel
return round($avg*2)/2;
}
public function getAuthorOrAnon(){
$O_author = self::getAuthor();
if ($O_author === null) {
return UserModel::getAnonUser();
} else {
return $O_author;
}
}
public function getAuthor(){
if($this->O_AUTHOR === null){

View File

@ -35,14 +35,7 @@ $O_recipe = $A_view["RECIPE"];
</ol>
</section>
<?php
$O_author = $O_recipe->getAuthor();
if($O_author === null) {
echo '<p>By an anonymous user</p>';
} else {
echo '<p>By '.$O_author->S_USERNAME.' </p>';
}
?>
<p>By <?= $O_recipe->getAuthorOrAnon()->S_USERNAME ?> </p>
<section class="buttonsEditRecipe">
<a href="/recipe/edit/<?= $O_recipe->I_ID ?>">Modifier la recette</a>