diff --git a/lib/EbookPlaceholder.php b/lib/EbookPlaceholder.php index ec394170..d0618f81 100644 --- a/lib/EbookPlaceholder.php +++ b/lib/EbookPlaceholder.php @@ -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 diff --git a/scripts/update-project-statuses b/scripts/update-project-statuses index e5283c5e..f8f52b3e 100755 --- a/scripts/update-project-statuses +++ b/scripts/update-project-statuses @@ -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); }