Created = new DateTime(); 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(); } } public function Reactivate(bool $sendEmail = true): void{ 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(); } } private function SendWelcomeEmail(): void{ $this->__get('User'); if($this->User !== null){ $em = new Email(); $em->To = $this->User->Email; $em->From = EDITOR_IN_CHIEF_EMAIL_ADDRESS; $em->Subject = 'Thank you for supporting Standard Ebooks!'; $em->Body = Template::EmailPatronsCircleWelcome(['isAnonymous' => $this->IsAnonymous]); $em->TextBody = Template::EmailPatronsCircleWelcomeText(['isAnonymous' => $this->IsAnonymous]); $em->Send(); } } }