mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Add /edit endpoint to update placeholders
This commit is contained in:
parent
b125758138
commit
f449c024ea
7 changed files with 297 additions and 73 deletions
35
www/ebooks/edit.php
Normal file
35
www/ebooks/edit.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?
|
||||
|
||||
$ebook = null;
|
||||
|
||||
try{
|
||||
if(Session::$User === null){
|
||||
throw new Exceptions\LoginRequiredException();
|
||||
}
|
||||
|
||||
if(!Session::$User->Benefits->CanEditEbookPlaceholders){
|
||||
throw new Exceptions\InvalidPermissionsException();
|
||||
}
|
||||
|
||||
$identifier = EBOOKS_IDENTIFIER_PREFIX . trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/');
|
||||
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
|
||||
if($ebook->IsPlaceholder()){
|
||||
require('/standardebooks.org/web/www/ebook-placeholders/edit.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Editing published `Ebooks` is not supported.
|
||||
Template::Emit404();
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
Template::Emit404();
|
||||
}
|
||||
catch(Exceptions\LoginRequiredException){
|
||||
Template::RedirectToLogin();
|
||||
}
|
||||
catch(Exceptions\InvalidPermissionsException){
|
||||
Template::Emit403();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue