mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 18:42:00 -04:00
Set ebook placeholders to not be in progress when a project is marked as abandoned
This commit is contained in:
parent
97021ce26d
commit
28b7384769
2 changed files with 32 additions and 0 deletions
|
@ -118,6 +118,27 @@ class EbookPlaceholder{
|
|||
$this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exceptions\InvalidEbookPlaceholderException
|
||||
*/
|
||||
public function Save(): void{
|
||||
$this->Validate();
|
||||
Db::Query('
|
||||
UPDATE
|
||||
EbookPlaceholders
|
||||
set
|
||||
YearPublished = ?,
|
||||
Difficulty = ?,
|
||||
TranscriptionUrl = ?,
|
||||
IsWanted = ?,
|
||||
IsInProgress = ?,
|
||||
IsPatron = ?,
|
||||
Notes = ?
|
||||
where EbookId = ?
|
||||
', [$this->YearPublished, $this->Difficulty, $this->TranscriptionUrl,
|
||||
$this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes, $this->EbookId]);
|
||||
}
|
||||
|
||||
public function Delete(): void{
|
||||
Db::Query('
|
||||
DELETE
|
||||
|
|
|
@ -65,6 +65,17 @@ foreach($projects as $project){
|
|||
// A stalled `Project` is now abandoned.
|
||||
$project->Status = Enums\ProjectStatusType::Abandoned;
|
||||
|
||||
// Set the corresponding `EbookPlaceholder` to not be "in progress" any more.
|
||||
if($project->Ebook->EbookPlaceholder !== null){
|
||||
try{
|
||||
$project->Ebook->EbookPlaceholder->IsInProgress = false;
|
||||
$project->Ebook->EbookPlaceholder->Save();
|
||||
}
|
||||
catch(Exceptions\InvalidEbookPlaceholderException){
|
||||
// Pass.
|
||||
}
|
||||
}
|
||||
|
||||
// Send a notification to the producer.
|
||||
$project->SendReminder(Enums\ProjectReminderType::Abandoned);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue