From dbefba6b94958daf3d812a775cbf92b3e4d2be8a Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 29 Jun 2022 17:19:28 -0500 Subject: [PATCH] Change 'timestamp' properties on objects to more descriptive names --- config/sql/se/NewsletterSubscribers.sql | 2 +- config/sql/se/Patrons.sql | 6 +++--- config/sql/se/Payments.sql | 4 ++-- config/sql/se/PendingPayments.sql | 2 +- config/sql/se/Users.sql | 2 +- lib/AtomFeed.php | 4 ++-- lib/Ebook.php | 10 +++++----- lib/GitCommit.php | 4 ++-- lib/Library.php | 4 ++-- lib/NewsletterSubscriber.php | 6 +++--- lib/OpdsAcquisitionFeed.php | 2 +- lib/OpdsFeed.php | 10 +++++----- lib/OpdsNavigationFeed.php | 2 +- lib/Patron.php | 14 +++++++------- lib/Payment.php | 4 ++-- lib/RssFeed.php | 2 +- lib/User.php | 6 +++--- scripts/delete-unconfirmed-newsletter-subscribers | 2 +- scripts/generate-feeds | 6 +++--- scripts/process-pending-payments | 10 +++++----- scripts/update-patrons-circle | 6 +++--- templates/AtomFeed.php | 2 +- templates/AtomFeedEntry.php | 4 ++-- templates/DonationProgress.php | 2 +- templates/OpdsAcquisitionEntry.php | 6 +++--- templates/OpdsAcquisitionFeed.php | 2 +- templates/OpdsNavigationFeed.php | 2 +- templates/RssEntry.php | 2 +- templates/RssFeed.php | 2 +- www/about/index.php | 8 ++++---- www/ebooks/ebook.php | 6 +++--- www/webhooks/zoho.php | 4 ++-- 32 files changed, 74 insertions(+), 74 deletions(-) diff --git a/config/sql/se/NewsletterSubscribers.sql b/config/sql/se/NewsletterSubscribers.sql index bd79caae..57446862 100644 --- a/config/sql/se/NewsletterSubscribers.sql +++ b/config/sql/se/NewsletterSubscribers.sql @@ -7,7 +7,7 @@ CREATE TABLE `NewsletterSubscribers` ( `IsConfirmed` tinyint(1) unsigned NOT NULL DEFAULT 0, `IsSubscribedToNewsletter` tinyint(1) unsigned NOT NULL DEFAULT 1, `IsSubscribedToSummary` tinyint(1) unsigned NOT NULL DEFAULT 1, - `Timestamp` datetime NOT NULL, + `Created` datetime NOT NULL, PRIMARY KEY (`NewsletterSubscriberId`), UNIQUE KEY `Uuid_UNIQUE` (`Uuid`), UNIQUE KEY `Email_UNIQUE` (`Email`) diff --git a/config/sql/se/Patrons.sql b/config/sql/se/Patrons.sql index 0a81082a..b13e6e8a 100644 --- a/config/sql/se/Patrons.sql +++ b/config/sql/se/Patrons.sql @@ -3,8 +3,8 @@ CREATE TABLE `Patrons` ( `IsAnonymous` tinyint(1) unsigned NOT NULL DEFAULT 0, `AlternateName` varchar(80) DEFAULT NULL, `IsSubscribedToEmails` tinyint(1) NOT NULL DEFAULT 1, - `Timestamp` datetime NOT NULL, - `DeactivatedTimestamp` datetime DEFAULT NULL, + `Created` datetime NOT NULL, + `Ended` datetime DEFAULT NULL, PRIMARY KEY (`UserId`), - KEY `index2` (`IsAnonymous`,`DeactivatedTimestamp`) + KEY `index2` (`IsAnonymous`,`Ended`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/config/sql/se/Payments.sql b/config/sql/se/Payments.sql index d389b7db..2ae4169b 100644 --- a/config/sql/se/Payments.sql +++ b/config/sql/se/Payments.sql @@ -1,12 +1,12 @@ CREATE TABLE `Payments` ( `PaymentId` int(10) unsigned NOT NULL AUTO_INCREMENT, `UserId` int(10) unsigned DEFAULT NULL, - `Timestamp` datetime NOT NULL, + `Created` datetime NOT NULL, `ChannelId` tinyint(4) unsigned NOT NULL, `TransactionId` varchar(80) NOT NULL, `Amount` decimal(7,2) unsigned NOT NULL, `Fee` decimal(7,2) unsigned NOT NULL DEFAULT 0.00, `IsRecurring` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`PaymentId`), - KEY `index2` (`UserId`,`Amount`,`Timestamp`,`IsRecurring`) + KEY `index2` (`UserId`,`Amount`,`Created`,`IsRecurring`) ) ENGINE=InnoDB AUTO_INCREMENT=828 DEFAULT CHARSET=utf8mb4; diff --git a/config/sql/se/PendingPayments.sql b/config/sql/se/PendingPayments.sql index 54602247..b979487a 100644 --- a/config/sql/se/PendingPayments.sql +++ b/config/sql/se/PendingPayments.sql @@ -1,5 +1,5 @@ CREATE TABLE `PendingPayments` ( - `Timestamp` datetime NOT NULL, + `Created` datetime NOT NULL, `ChannelId` tinyint(4) unsigned NOT NULL, `TransactionId` varchar(80) NOT NULL, `ProcessedOn` datetime DEFAULT NULL diff --git a/config/sql/se/Users.sql b/config/sql/se/Users.sql index 330ea9e5..87310a17 100644 --- a/config/sql/se/Users.sql +++ b/config/sql/se/Users.sql @@ -2,7 +2,7 @@ CREATE TABLE `Users` ( `UserId` int(10) unsigned NOT NULL AUTO_INCREMENT, `Email` varchar(80) DEFAULT NULL, `Name` varchar(255) DEFAULT NULL, - `Timestamp` datetime NOT NULL, + `Created` datetime NOT NULL, `Uuid` char(36) NOT NULL, PRIMARY KEY (`UserId`), UNIQUE KEY `idxEmail` (`Email`) diff --git a/lib/AtomFeed.php b/lib/AtomFeed.php index fc26c0d0..b83910d5 100644 --- a/lib/AtomFeed.php +++ b/lib/AtomFeed.php @@ -21,7 +21,7 @@ class AtomFeed extends Feed{ protected function GetXmlString(): string{ if($this->XmlString === null){ - $feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updatedTimestamp' => $this->Updated, 'entries' => $this->Entries]); + $feed = Template::AtomFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'subtitle' => $this->Subtitle, 'updated' => $this->Updated, 'entries' => $this->Entries]); $this->XmlString = $this->CleanXmlString($feed); } @@ -47,7 +47,7 @@ class AtomFeed extends Feed{ foreach($this->Entries as $entry){ $obj = new StdClass(); if(is_a($entry, 'Ebook')){ - $obj->Updated = $entry->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z'); + $obj->Updated = $entry->Modified->format('Y-m-d\TH:i:s\Z'); $obj->Id = SITE_URL . $entry->Url; } else{ diff --git a/lib/Ebook.php b/lib/Ebook.php index 28f19d71..ca083a0d 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -53,8 +53,8 @@ class Ebook{ public $Contributors = []; // Array of Contributors public $ContributorsHtml; public $TitleWithCreditsHtml = ''; - public $Timestamp; - public $ModifiedTimestamp; + public $Created; + public $Modified; public $TextUrl; public $TextSinglePageUrl; public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise @@ -151,7 +151,7 @@ class Ebook{ if(stripos($this->RepoFilesystemPath, '.git') === false){ $gitFolderPath = $gitFolderPath . '/.git'; } - $hash = substr(sha1($this->GitCommits[0]->Timestamp->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8); + $hash = substr(sha1($this->GitCommits[0]->Created->format('U') . ' ' . $this->GitCommits[0]->Message), 0, 8); $this->CoverImageUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.jpg'; if(file_exists(WEB_ROOT . '/images/covers/' . $this->UrlSafeIdentifier . '-cover.avif')){ $this->CoverImageAvifUrl = '/images/covers/' . $this->UrlSafeIdentifier . '-' . $hash . '-cover.avif'; @@ -186,12 +186,12 @@ class Ebook{ $date = $xml->xpath('/package/metadata/dc:date'); if($date !== false && sizeof($date) > 0){ - $this->Timestamp = new DateTime((string)$date[0]); + $this->Created = new DateTime((string)$date[0]); } $modifiedDate = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]'); if($modifiedDate !== false && sizeof($modifiedDate) > 0){ - $this->ModifiedTimestamp = new DateTime((string)$modifiedDate[0]); + $this->Modified = new DateTime((string)$modifiedDate[0]); } // Get SE tags diff --git a/lib/GitCommit.php b/lib/GitCommit.php index 466d9b23..7cfa3750 100644 --- a/lib/GitCommit.php +++ b/lib/GitCommit.php @@ -2,12 +2,12 @@ use Safe\DateTimeImmutable; class GitCommit{ - public $Timestamp; + public $Created; public $Message; public $Hash; public function __construct(string $unixTimestamp, string $hash, string $message){ - $this->Timestamp = new DateTimeImmutable('@' . $unixTimestamp); + $this->Created = new DateTimeImmutable('@' . $unixTimestamp); $this->Message = $message; $this->Hash = $hash; } diff --git a/lib/Library.php b/lib/Library.php index a59147ab..c18a9736 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -50,10 +50,10 @@ class Library{ case SORT_NEWEST: usort($matches, function($a, $b){ - if($a->Timestamp < $b->Timestamp){ + if($a->Created < $b->Created){ return -1; } - elseif($a->Timestamp == $b->Timestamp){ + elseif($a->Created == $b->Created){ return 0; } else{ diff --git a/lib/NewsletterSubscriber.php b/lib/NewsletterSubscriber.php index e2bd9795..a2a2f9b5 100644 --- a/lib/NewsletterSubscriber.php +++ b/lib/NewsletterSubscriber.php @@ -11,7 +11,7 @@ class NewsletterSubscriber extends PropertiesBase{ public $IsConfirmed = false; public $IsSubscribedToSummary = true; public $IsSubscribedToNewsletter = true; - public $Timestamp; + public $Created; protected $Url = null; protected function GetUrl(): string{ @@ -27,10 +27,10 @@ class NewsletterSubscriber extends PropertiesBase{ $uuid = Uuid::uuid4(); $this->Uuid = $uuid->toString(); - $this->Timestamp = new DateTime(); + $this->Created = new DateTime(); try{ - Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Timestamp) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Timestamp]); + Db::Query('INSERT into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Created) values (?, ?, ?, ?, ?, ?, ?, ?);', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Created]); } catch(PDOException $ex){ if($ex->errorInfo[1] == 1062){ diff --git a/lib/OpdsAcquisitionFeed.php b/lib/OpdsAcquisitionFeed.php index f06bb785..0c5b8a00 100644 --- a/lib/OpdsAcquisitionFeed.php +++ b/lib/OpdsAcquisitionFeed.php @@ -11,7 +11,7 @@ class OpdsAcquisitionFeed extends OpdsFeed{ protected function GetXmlString(): string{ if($this->XmlString === null){ - $this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries])); + $this->XmlString = $this->CleanXmlString(Template::OpdsAcquisitionFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'isCrawlable' => $this->IsCrawlable, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries])); } return $this->XmlString; diff --git a/lib/OpdsFeed.php b/lib/OpdsFeed.php index 40f0db75..fa7f7505 100644 --- a/lib/OpdsFeed.php +++ b/lib/OpdsFeed.php @@ -11,24 +11,24 @@ class OpdsFeed extends AtomFeed{ $this->Stylesheet = '/feeds/opds/style'; } - protected function SaveUpdatedTimestamp(string $entryId, DateTime $updatedTimestamp): void{ + protected function SaveUpdated(string $entryId, DateTime $updated): void{ // Only save the updated timestamp for the given entry ID in this file foreach($this->Entries as $entry){ if(is_a($entry, 'OpdsNavigationEntry')){ if($entry->Id == SITE_URL . $entryId){ - $entry->Updated = $updatedTimestamp; + $entry->Updated = $updated; } } } - $this->Updated = $updatedTimestamp; + $this->Updated = $updated; $this->XmlString = null; file_put_contents($this->Path, $this->GetXmlString()); // Do we have any parents of our own to update? if($this->Parent !== null){ - $this->Parent->SaveUpdatedTimestamp($this->Id, $updatedTimestamp); + $this->Parent->SaveUpdated($this->Id, $updated); } } @@ -40,7 +40,7 @@ class OpdsFeed extends AtomFeed{ $this->Updated = new DateTime(); if($this->Parent !== null){ - $this->Parent->SaveUpdatedTimestamp($this->Id, $this->Updated); + $this->Parent->SaveUpdated($this->Id, $this->Updated); } // Save our own file diff --git a/lib/OpdsNavigationFeed.php b/lib/OpdsNavigationFeed.php index 80bd6a99..4e077398 100644 --- a/lib/OpdsNavigationFeed.php +++ b/lib/OpdsNavigationFeed.php @@ -31,7 +31,7 @@ class OpdsNavigationFeed extends OpdsFeed{ protected function GetXmlString(): string{ if($this->XmlString === null){ - $this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updatedTimestamp' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries])); + $this->XmlString = $this->CleanXmlString(Template::OpdsNavigationFeed(['id' => $this->Id, 'url' => $this->Url, 'title' => $this->Title, 'parentUrl' => $this->Parent ? $this->Parent->Url : null, 'updated' => $this->Updated, 'subtitle' => $this->Subtitle, 'entries' => $this->Entries])); } return $this->XmlString; diff --git a/lib/Patron.php b/lib/Patron.php index a06df341..a7f96142 100644 --- a/lib/Patron.php +++ b/lib/Patron.php @@ -7,8 +7,8 @@ class Patron extends PropertiesBase{ public $IsAnonymous; public $AlternateName; public $IsSubscribedToEmail; - public $Timestamp = null; - public $DeactivatedTimestamp = null; + public $Created = null; + public $Ended = null; public static function Get(?int $userId): Patron{ $result = Db::Query('SELECT * from Patrons where UserId = ?', [$userId], 'Patron'); @@ -31,9 +31,9 @@ class Patron extends PropertiesBase{ } public function Create(bool $sendEmail = true): void{ - $this->Timestamp = new DateTime(); + $this->Created = new DateTime(); - Db::Query('INSERT into Patrons (Timestamp, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Timestamp, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]); + Db::Query('INSERT into Patrons (Created, UserId, IsAnonymous, AlternateName, IsSubscribedToEmail) values(?, ?, ?, ?, ?);', [$this->Created, $this->UserId, $this->IsAnonymous, $this->AlternateName, $this->IsSubscribedToEmail]); if($sendEmail){ $this->SendWelcomeEmail(); @@ -41,9 +41,9 @@ class Patron extends PropertiesBase{ } public function Reactivate(bool $sendEmail = true): void{ - Db::Query('UPDATE Patrons set Timestamp = utc_timestamp(), DeactivatedTimestamp = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]); - $this->Timestamp = new DateTime(); - $this->DeactivatedTimestamp = null; + Db::Query('UPDATE Patrons set Created = utc_timestamp(), Ended = null, IsAnonymous = ?, IsSubscribedToEmail = ?, AlternateName = ? where UserId = ?;', [$this->IsAnonymous, $this->IsSubscribedToEmail, $this->AlternateName, $this->UserId]); + $this->Created = new DateTime(); + $this->Ended = null; if($sendEmail){ $this->SendWelcomeEmail(); diff --git a/lib/Payment.php b/lib/Payment.php index 94341bc0..f8c3dc1a 100644 --- a/lib/Payment.php +++ b/lib/Payment.php @@ -4,7 +4,7 @@ class Payment extends PropertiesBase{ public $PaymentId; protected $User = null; public $UserId = null; - public $Timestamp; + public $Created; public $ChannelId; public $TransactionId; public $Amount; @@ -33,7 +33,7 @@ class Payment extends PropertiesBase{ } try{ - Db::Query('INSERT into Payments (UserId, Timestamp, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Timestamp, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]); + Db::Query('INSERT into Payments (UserId, Created, ChannelId, TransactionId, Amount, Fee, IsRecurring) values(?, ?, ?, ?, ?, ?, ?);', [$this->UserId, $this->Created, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]); } catch(PDOException $ex){ if($ex->errorInfo[1] == 1062){ diff --git a/lib/RssFeed.php b/lib/RssFeed.php index db2df941..836baf80 100644 --- a/lib/RssFeed.php +++ b/lib/RssFeed.php @@ -15,7 +15,7 @@ class RssFeed extends Feed{ protected function GetXmlString(): string{ if($this->XmlString === null){ - $feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updatedTimestamp' => (new DateTime())->format('r')]); + $feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updated' => (new DateTime())->format('r')]); $this->XmlString = $this->CleanXmlString($feed); } diff --git a/lib/User.php b/lib/User.php index 5543c3eb..c6729437 100644 --- a/lib/User.php +++ b/lib/User.php @@ -12,7 +12,7 @@ class User extends PropertiesBase{ protected $DisplayName = null; public $Email; protected $DisplayEmail; - public $Timestamp; + public $Created; public $Uuid; public static function Get(?int $userId): User{ @@ -46,10 +46,10 @@ class User extends PropertiesBase{ public function Create(): void{ $uuid = Uuid::uuid4(); $this->Uuid = $uuid->toString(); - $this->Timestamp = new DateTime(); + $this->Created = new DateTime(); try{ - Db::Query('INSERT into Users (Email, Name, Uuid, Timestamp) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Timestamp]); + Db::Query('INSERT into Users (Email, Name, Uuid, Created) values (?, ?, ?, ?);', [$this->Email, $this->Name, $this->Uuid, $this->Created]); } catch(PDOException $ex){ if($ex->errorInfo[1] == 1062){ diff --git a/scripts/delete-unconfirmed-newsletter-subscribers b/scripts/delete-unconfirmed-newsletter-subscribers index 35a8a530..b9a4e30e 100644 --- a/scripts/delete-unconfirmed-newsletter-subscribers +++ b/scripts/delete-unconfirmed-newsletter-subscribers @@ -3,5 +3,5 @@ require_once('/standardebooks.org/web/lib/Core.php'); // Delete unconfirmed newsletter subscribers who are more than a week old -Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Timestamp) >= 7'); +Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Created) >= 7'); ?> diff --git a/scripts/generate-feeds b/scripts/generate-feeds index 100315b9..fa04bf38 100755 --- a/scripts/generate-feeds +++ b/scripts/generate-feeds @@ -57,8 +57,8 @@ foreach($contentFiles as $path){ $ebook = new Ebook($ebookWwwFilesystemPath); - $allEbooks[$ebook->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; - $newestEbooks[$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; + $allEbooks[$ebook->Modified->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; + $newestEbooks[$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; foreach($ebook->Tags as $tag){ // Add the book's subjects to the main subjects list @@ -67,7 +67,7 @@ foreach($contentFiles as $path){ } // Sort this ebook by subject - $ebooksBySubject[$tag->Name][$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; + $ebooksBySubject[$tag->Name][$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook; } } catch(\Exception $ex){ diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index abbb496d..ed1bdb84 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -133,7 +133,7 @@ try{ $payment->User = null; } - $payment->Timestamp = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText())); + $payment->Created = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText())); $payment->TransactionId = trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "ID"]]'))->getText()); $payment->IsRecurring = sizeof($headerRow->findElements(WebDriverBy::xpath('//td[contains(., "Recurring")]'))) > 0; $payment->Amount = floatval(str_replace('$', '', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Total Amount"]]'))->getText()))); @@ -157,7 +157,7 @@ try{ // If this payment isn't anonymous, does it put us in the Patrons Circle? if($payment->User !== null){ - if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Timestamp >= $lastMonth) || ($payment->Amount >= 100 && $payment->Timestamp >= $lastYear)){ + if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Created >= $lastMonth) || ($payment->Amount >= 100 && $payment->Created >= $lastYear)){ // This payment is eligible for the Patrons Circle. // Are we already a patron? try{ @@ -170,7 +170,7 @@ try{ $patron->User = $payment->User; } - if($patron->Timestamp === null || $patron->DeactivatedTimestamp !== null){ + if($patron->Created === null || $patron->Ended !== null){ // If we're a new patron, or an old patron that was deactivated, // re-enable them as a patron in the system $patron->IsAnonymous = (trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution"]]'))->getText()) == 'Private'); @@ -182,11 +182,11 @@ try{ catch(Exception $ex){ } - if($patron->Timestamp === null){ + if($patron->Created === null){ $log->Write('Adding donor as patron ...'); $patron->Create(); } - elseif($patron->DeactivatedTimestamp !== null){ + elseif($patron->Ended !== null){ $log->Write('Reactivating donor as patron ...'); $patron->Reactivate(); } diff --git a/scripts/update-patrons-circle b/scripts/update-patrons-circle index e008d4b4..676750d6 100755 --- a/scripts/update-patrons-circle +++ b/scripts/update-patrons-circle @@ -8,16 +8,16 @@ require_once('/standardebooks.org/web/lib/Core.php'); Db::Query(' update Patrons - set DeactivatedTimestamp = utc_timestamp() + set Ended = utc_timestamp() where UserId not in ( select distinct UserId from Payments where UserId is not null and ( - (IsRecurring = 1 and Amount >= 10 and Timestamp > utc_timestamp() - interval 45 day) + (IsRecurring = 1 and Amount >= 10 and Created > utc_timestamp() - interval 45 day) or - (IsRecurring = 0 and Amount >= 100 and Timestamp > utc_timestamp() - interval 1 year) + (IsRecurring = 0 and Amount >= 100 and Created > utc_timestamp() - interval 1 year) ) ) '); diff --git a/templates/AtomFeed.php b/templates/AtomFeed.php index 3160873c..ad5aed53 100644 --- a/templates/AtomFeed.php +++ b/templates/AtomFeed.php @@ -12,7 +12,7 @@ print("\n"); <?= Formatter::ToPlainXmlText($title) ?> /images/logo.png - format('Y-m-d\TH:i:s\Z') ?> + format('Y-m-d\TH:i:s\Z') ?> Standard Ebooks diff --git a/templates/AtomFeedEntry.php b/templates/AtomFeedEntry.php index fcfacb0f..397571a9 100644 --- a/templates/AtomFeedEntry.php +++ b/templates/AtomFeedEntry.php @@ -7,8 +7,8 @@ AuthorsUrl) ?> - Timestamp->format('Y-m-d\TH:i:s\Z') ?> - ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') ?> + Created->format('Y-m-d\TH:i:s\Z') ?> + Modified->format('Y-m-d\TH:i:s\Z') ?> Public domain in the United States. Users located outside of the United States must check their local laws before using this ebook. Original content released to the public domain via the Creative Commons CC0 1.0 Universal Public Domain Dedication. Description) ?> LongDescription) ?> diff --git a/templates/DonationProgress.php b/templates/DonationProgress.php index ec42a20f..58d7ee45 100644 --- a/templates/DonationProgress.php +++ b/templates/DonationProgress.php @@ -9,7 +9,7 @@ $startDate = new DateTime('2022-07-01'); $endDate = new DateTime('2022-07-31'); $autoHide = $autoHide ?? true; $showDonateButton = $showDonateButton ?? true; -$current = (Db::Query('SELECT count(*) as PatronCount from Patrons where Timestamp >= ?', [$startDate]))[0]->PatronCount; +$current = (Db::Query('SELECT count(*) as PatronCount from Patrons where Created >= ?', [$startDate]))[0]->PatronCount; $target = 70; $stretchCurrent = 0; $stretchTarget = 20; diff --git a/templates/OpdsAcquisitionEntry.php b/templates/OpdsAcquisitionEntry.php index b4b7430f..0d005071 100644 --- a/templates/OpdsAcquisitionEntry.php +++ b/templates/OpdsAcquisitionEntry.php @@ -11,9 +11,9 @@ NacoafUrl !== null){ ?>NacoafUrl) ?> - Timestamp->format('Y-m-d\TH:i:s\Z') ?> - Timestamp->format('Y-m-d\TH:i:s\Z') ?> - ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') ?> + Created->format('Y-m-d\TH:i:s\Z') ?> + Created->format('Y-m-d\TH:i:s\Z') ?> + Modified->format('Y-m-d\TH:i:s\Z') ?> Language) ?> Standard Ebooks Public domain in the United States. Users located outside of the United States must check their local laws before using this ebook. Original content released to the public domain via the Creative Commons CC0 1.0 Universal Public Domain Dedication. diff --git a/templates/OpdsAcquisitionFeed.php b/templates/OpdsAcquisitionFeed.php index bec27955..abc66a0b 100644 --- a/templates/OpdsAcquisitionFeed.php +++ b/templates/OpdsAcquisitionFeed.php @@ -26,7 +26,7 @@ print("\n"); <?= Formatter::ToPlainXmlText($title) ?> /images/logo.png - format('Y-m-d\TH:i:s\Z') ?> + format('Y-m-d\TH:i:s\Z') ?> Standard Ebooks diff --git a/templates/OpdsNavigationFeed.php b/templates/OpdsNavigationFeed.php index a5d58e97..b28e6787 100644 --- a/templates/OpdsNavigationFeed.php +++ b/templates/OpdsNavigationFeed.php @@ -17,7 +17,7 @@ print("\n"); <?= Formatter::ToPlainXmlText($title) ?> /images/logo.png - format('Y-m-d\TH:i:s\Z') ?> + format('Y-m-d\TH:i:s\Z') ?> Standard Ebooks diff --git a/templates/RssEntry.php b/templates/RssEntry.php index 5c5c4f22..d47f9a6f 100644 --- a/templates/RssEntry.php +++ b/templates/RssEntry.php @@ -2,7 +2,7 @@ <?= Formatter::ToPlainXmlText($entry->Title) ?>, by <?= Formatter::ToPlainXmlText(strip_tags($entry->AuthorsHtml)) ?> Url) ?> Description) ?> - Timestamp->format('r') ?> + Created->format('r') ?> Identifier)) ?> Tags as $tag){ ?> Name) ?> diff --git a/templates/RssFeed.php b/templates/RssFeed.php index bba4075b..b17d3e13 100644 --- a/templates/RssFeed.php +++ b/templates/RssFeed.php @@ -12,7 +12,7 @@ print("\n"); en-US https://creativecommons.org/publicdomain/zero/1.0/ - + http://blogs.law.harvard.edu/tech/rss