handle case where user is null in interactions

This commit is contained in:
Thomas Rubini 2023-01-26 21:26:22 +01:00
parent 5e80f58f40
commit 9014ca45f3
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 12 additions and 2 deletions

View File

@ -8,7 +8,12 @@
<h3> <?= $O_appr->getAuthorOrAnon()->S_USERNAME ?> </h3>
<p>Le <?= $O_appr->S_DATE ?> </p>
<p> <?= $O_appr->I_NOTE ?>/5 </p>
<?php if ($A_view["ADMIN"] || $A_view["USER_ID"] === $O_appr->I_AUTHOR_ID) { ?>
<?php
$B_can_delete = (
$A_view["ADMIN"] ||
($A_view["USER_ID"] === $O_appr->I_AUTHOR_ID && $O_appr->I_AUTHOR_ID !== null)
);
if ($B_can_delete) { ?>
<a href="/appr/delete/<?= $O_appr->I_ID ?>">Supprimer l'appréciation</a>
<?php } ?>
</header>

View File

@ -37,7 +37,12 @@ $O_recipe = $A_view["RECIPE"];
<p>By <?= $O_recipe->getAuthorOrAnon()->S_USERNAME ?> </p>
<?php if ($A_view["ADMIN"] || $A_view["USER_ID"] === $O_recipe->I_AUTHOR_ID) { ?>
<?php
$B_can_interact = (
$A_view["ADMIN"] ||
($A_view["USER_ID"] === $O_appr->I_AUTHOR_ID && $O_appr->I_AUTHOR_ID !== null)
);
if ($B_can_interact) { ?>
<section class="buttonsEditRecipe">
<a href="/recipe/edit/<?= $O_recipe->I_ID ?>">Modifier la recette</a>
<a href="/recipe/delete/<?= $O_recipe->I_ID ?>">Supprimer la recette</a>