Allow editing of projects

This commit is contained in:
Alex Cabal 2024-12-18 14:20:28 -06:00
parent e21f411191
commit b2191d1219
16 changed files with 191 additions and 75 deletions

View file

@ -3,21 +3,11 @@ use function Safe\session_unset;
session_start();
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
/** @var string $identifier Passed from script this is included from. */
$ebook = HttpInput::SessionObject('ebook', Ebook::class);
$exception = HttpInput::SessionObject('exception', Exceptions\AppException::class);
try{
if(Session::$User === null){
throw new Exceptions\LoginRequiredException();
}
if(!Session::$User->Benefits->CanEditEbookPlaceholders){
throw new Exceptions\InvalidPermissionsException();
}
if($ebook === null){
$ebook = Ebook::GetByIdentifier($identifier);
}
@ -26,6 +16,14 @@ try{
throw new Exceptions\EbookNotFoundException();
}
if(Session::$User === null){
throw new Exceptions\LoginRequiredException();
}
if(!Session::$User->Benefits->CanEditEbookPlaceholders){
throw new Exceptions\InvalidPermissionsException();
}
if($exception){
http_response_code(Enums\HttpCode::UnprocessableContent->value);
session_unset();
@ -57,7 +55,7 @@ catch(Exceptions\InvalidPermissionsException){
<form class="create-update-ebook-placeholder" method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $ebook->Url ?>" autocomplete="off">
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Put->value ?>" />
<?= Template::EbookPlaceholderForm(['ebook' => $ebook]) ?>
<?= Template::EbookPlaceholderForm(['ebook' => $ebook, 'isEditForm' => true]) ?>
</form>
</section>
</main>