diff --git a/config/sql/se/EbookPlaceholders.sql b/config/sql/se/EbookPlaceholders.sql index 409591ec..6622d2a9 100644 --- a/config/sql/se/EbookPlaceholders.sql +++ b/config/sql/se/EbookPlaceholders.sql @@ -1,10 +1,10 @@ CREATE TABLE IF NOT EXISTS `EbookPlaceholders` ( `EbookId` int(10) unsigned NOT NULL, `YearPublished` smallint unsigned NULL, - `Status` enum('wanted', 'in_progress') NULL, `Difficulty` enum('beginner', 'intermediate', 'advanced') NULL, `TranscriptionUrl` varchar(511) NULL, `IsWanted` boolean NOT NULL DEFAULT FALSE, + `IsInProgress` boolean NOT NULL DEFAULT FALSE, `IsPatron` boolean NOT NULL DEFAULT FALSE, `Notes` TEXT NULL DEFAULT NULL, PRIMARY KEY (`EbookId`) diff --git a/config/sql/se/Projects.sql b/config/sql/se/Projects.sql new file mode 100644 index 00000000..947b4664 --- /dev/null +++ b/config/sql/se/Projects.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS `Projects` ( + `ProjectId` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Status` enum('in_progress','stalled','completed','abandoned') NOT NULL DEFAULT 'in_progress', + `EbookId` int(11) NOT NULL, + `ProducerName` varchar(151) DEFAULT NULL, + `ProducerEmail` varchar(80) DEFAULT NULL, + `DiscussionUrl` varchar(255) DEFAULT NULL, + `VcsUrl` varchar(255) NOT NULL, + `Created` timestamp NOT NULL DEFAULT current_timestamp(), + `Updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `Started` datetime NOT NULL, + `Ended` datetime DEFAULT NULL, + `ManagerUserId` int(11) NOT NULL, + `ReviewerUserId` int(11) NOT NULL, + PRIMARY KEY (`ProjectId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; diff --git a/lib/Ebook.php b/lib/Ebook.php index b51a539c..9198a410 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -612,11 +612,16 @@ class Ebook{ protected function GetEbookPlaceholder(): ?EbookPlaceholder{ if(!isset($this->_EbookPlaceholder)){ - $this->_EbookPlaceholder = Db::Query(' - SELECT * - from EbookPlaceholders - where EbookId = ? - ', [$this->EbookId], EbookPlaceholder::class)[0] ?? null; + if(!isset($this->EbookId)){ + $this->_EbookPlaceholder = null; + } + else{ + $this->_EbookPlaceholder = Db::Query(' + SELECT * + from EbookPlaceholders + where EbookId = ? + ', [$this->EbookId], EbookPlaceholder::class)[0] ?? null; + } } return $this->_EbookPlaceholder; diff --git a/lib/EbookPlaceholder.php b/lib/EbookPlaceholder.php index 3b88a670..db01350f 100644 --- a/lib/EbookPlaceholder.php +++ b/lib/EbookPlaceholder.php @@ -11,7 +11,7 @@ class EbookPlaceholder{ public int $EbookId; public ?int $YearPublished = null; public bool $IsWanted = false; - public ?Enums\EbookPlaceholderStatus $Status = null; + public bool $IsInProgress = false; public ?Enums\EbookPlaceholderDifficulty $Difficulty = null; public ?string $TranscriptionUrl = null; public bool $IsPatron = false; @@ -61,10 +61,10 @@ class EbookPlaceholder{ public function FillFromHttpPost(): void{ $this->PropertyFromHttp('YearPublished'); $this->PropertyFromHttp('IsWanted'); + $this->PropertyFromHttp('IsInProgress'); // These properties apply only to books on the SE wanted list. if($this->IsWanted){ - $this->PropertyFromHttp('Status'); $this->PropertyFromHttp('Difficulty'); $this->PropertyFromHttp('TranscriptionUrl'); $this->PropertyFromHttp('IsPatron'); @@ -104,8 +104,8 @@ class EbookPlaceholder{ public function Create(): void{ $this->Validate(); Db::Query(' - INSERT into EbookPlaceholders (EbookId, YearPublished, Status, Difficulty, TranscriptionUrl, - IsWanted, IsPatron, Notes) + INSERT into EbookPlaceholders (EbookId, YearPublished, Difficulty, TranscriptionUrl, + IsWanted, IsInProgress, IsPatron, Notes) values (?, ?, ?, @@ -114,7 +114,7 @@ class EbookPlaceholder{ ?, ?, ?) - ', [$this->EbookId, $this->YearPublished, $this->Status, $this->Difficulty, $this->TranscriptionUrl, - $this->IsWanted, $this->IsPatron, $this->Notes]); + ', [$this->EbookId, $this->YearPublished, $this->Difficulty, $this->TranscriptionUrl, + $this->IsWanted, $this->IsInProgress, $this->IsPatron, $this->Notes]); } } diff --git a/lib/Enums/EbookPlaceholderStatus.php b/lib/Enums/EbookPlaceholderStatus.php deleted file mode 100644 index 1be91269..00000000 --- a/lib/Enums/EbookPlaceholderStatus.php +++ /dev/null @@ -1,7 +0,0 @@ - -namespace Enums; - -enum EbookPlaceholderStatus: string{ - case Wanted = 'wanted'; - case InProgress = 'in_progress'; -} diff --git a/templates/EbookGrid.php b/templates/EbookGrid.php index 97d4c0ec..c8df24e5 100644 --- a/templates/EbookGrid.php +++ b/templates/EbookGrid.php @@ -12,7 +12,7 @@ $collection = $collection ?? null; } ?> foreach($ebooks as $ebook){ ?> -
We don’t have this ebook in our catalog yet, but someone is working on it now! We hope to have it available for you to read very soon.
}else{ ?>We don’t have this ebook in our catalog yet, but it’s if($ebook->EbookPlaceholder->IsWanted){ ?>on our Wanted Ebooks list }else{ ?>in the U.S. public domain } ?>!