diff --git a/config/sql/se/Benefits.sql b/config/sql/se/Benefits.sql index 7606efb2..b8f63236 100644 --- a/config/sql/se/Benefits.sql +++ b/config/sql/se/Benefits.sql @@ -8,6 +8,7 @@ CREATE TABLE IF NOT EXISTS `Benefits` ( `CanReviewOwnArtwork` tinyint(1) unsigned NOT NULL DEFAULT 0, `CanEditUsers` tinyint(1) unsigned NOT NULL DEFAULT 0, `CanEditCollections` tinyint(1) unsigned NOT NULL DEFAULT 0, + `CanEditEbooks` tinyint(1) unsigned NOT NULL DEFAULT 0, `CanCreateEbookPlaceholders` tinyint(1) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`UserId`), KEY `idxBenefits` (`CanAccessFeeds`,`CanVote`,`CanBulkDownload`) diff --git a/lib/AtomFeed.php b/lib/AtomFeed.php index 1b2a8e02..32f6ba76 100644 --- a/lib/AtomFeed.php +++ b/lib/AtomFeed.php @@ -55,14 +55,21 @@ class AtomFeed extends Feed{ foreach($this->Entries as $entry){ $obj = new StdClass(); if($entry instanceof Ebook){ - $obj->Updated = $entry->EbookUpdated->format(Enums\DateTimeFormat::Iso->value); - $obj->Id = SITE_URL . $entry->Url; + if($entry->EbookUpdated !== null){ + $obj->Updated = $entry->EbookUpdated->format(Enums\DateTimeFormat::Iso->value); + $obj->Id = SITE_URL . $entry->Url; + } } else{ - $obj->Updated = $entry->Updated->format(Enums\DateTimeFormat::Iso->value); - $obj->Id = $entry->Id; + if($entry->Updated !== null){ + $obj->Updated = $entry->Updated->format(Enums\DateTimeFormat::Iso->value); + $obj->Id = $entry->Id; + } + } + + if(isset($obj->Id)){ + $currentEntries[] = $obj; } - $currentEntries[] = $obj; } $oldEntries = []; diff --git a/lib/Benefits.php b/lib/Benefits.php index 20d25c14..b43a60fa 100644 --- a/lib/Benefits.php +++ b/lib/Benefits.php @@ -16,6 +16,7 @@ class Benefits{ public bool $CanReviewOwnArtwork = false; public bool $CanEditUsers = false; public bool $CanEditCollections = false; + public bool $CanEditEbooks = false; public bool $CanCreateEbookPlaceholders = false; protected bool $_HasBenefits; @@ -30,6 +31,10 @@ class Benefits{ || $this->CanEditUsers || + $this->CanEditCollections + || + $this->CanEditEbooks + || $this->CanCreateEbookPlaceholders ){ return true; diff --git a/lib/Ebook.php b/lib/Ebook.php index 6f3649cb..b51a539c 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -444,7 +444,7 @@ class Ebook{ protected function GetReadingTime(): string{ if(!isset($this->_ReadingTime)){ - $readingTime = ceil($this->WordCount / AVERAGE_READING_WORDS_PER_MINUTE); + $readingTime = ceil(($this->WordCount ?? 0) / AVERAGE_READING_WORDS_PER_MINUTE); $this->_ReadingTime = (string)$readingTime; if($readingTime < 60){ diff --git a/scripts/generate-bulk-downloads b/scripts/generate-bulk-downloads index 76525774..813cf663 100755 --- a/scripts/generate-bulk-downloads +++ b/scripts/generate-bulk-downloads @@ -110,6 +110,10 @@ foreach(Ebook::GetAll() as $ebook){ continue; } + if($ebook->EbookCreated === null || $ebook->EbookUpdated === null){ + continue; + } + $timestamp = $ebook->EbookCreated->format('Y-m'); $updatedTimestamp = $ebook->EbookUpdated->getTimestamp(); diff --git a/templates/EbookGrid.php b/templates/EbookGrid.php index fb2b679a..97d4c0ec 100644 --- a/templates/EbookGrid.php +++ b/templates/EbookGrid.php @@ -47,7 +47,9 @@ $collection = $collection ?? null; IsPlaceholder()){ ?> -

WordCount) ?> words • ReadingEase ?> reading ease

+ WordCount !== null){ ?> +

WordCount) ?> words • ReadingEase ?> reading ease

+