use Anon user in Recipe

This commit is contained in:
Thomas Rubini 2023-01-26 19:57:55 +01:00
parent a36fb5dde2
commit 04d3fdb206
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 10 additions and 8 deletions

View File

@ -120,6 +120,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){
$this->O_AUTHOR = UserModel::getByID($this->I_AUTHOR_ID);

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>