use wcf\system\WCF;
$tables = [
+ DatabaseTable::create('wcf1_email_log_entry')
+ ->columns([
+ ObjectIdDatabaseTableColumn::create('entryID'),
+ NotNullInt10DatabaseTableColumn::create('time'),
+ NotNullVarchar255DatabaseTableColumn::create('messageID'),
+ NotNullVarchar255DatabaseTableColumn::create('recipient'),
+ IntDatabaseTableColumn::create('recipientID')
+ ->length(10)
+ ->notNull(false),
+ NotNullVarchar255DatabaseTableColumn::create('status'),
+ TextDatabaseTableColumn::create('message'),
+ ])
+ ->indices([
+ DatabaseTablePrimaryIndex::create()
+ ->columns(['entryID']),
+ DatabaseTableIndex::create('time')
+ ->columns(['time']),
+ ])
+ ->foreignKeys([
+ DatabaseTableForeignKey::create()
+ ->columns(['recipientID'])
+ ->referencedTable('wcf1_user')
+ ->referencedColumns(['userID'])
+ ->onDelete('SET NULL'),
+ ]),
+
// This update script was added with 5.3.3. We need to ensure that the change is applied
// when someone attempts to upgrade from an older 5.3.x for whatever reason.
// If the database already has the proper state this will be a simple noop.
--- /dev/null
+<?php
+
+namespace wcf\data\email\log\entry;
+
+use wcf\data\DatabaseObject;
+
+/**
+ * Represents an email log entry.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\Email\Log\Entry
+ *
+ * @property-read int $entryID unique id of the log entry
+ * @property-read int $time timestamp when the delivery job was created
+ * @property-read string $messageID the email's 'Message-ID'
+ * @property-read string $recipient the recipient ("RCPT TO")
+ * @property-read ?int $recipientID the recipient's userID (if the email is being sent to a registered user)
+ * @property-read string $status one of the `STATUS_*` constants
+ * @property-read string $message a human readable explanation for the status
+ *
+ */
+class EmailLogEntry extends DatabaseObject
+{
+ public const STATUS_NEW = 'new';
+
+ public const STATUS_SUCCESS = 'success';
+
+ public const STATUS_TRANSIENT_FAILURE = 'transient_failure';
+
+ public const STATUS_PERMANENT_FAILURE = 'permanent_failure';
+}
--- /dev/null
+<?php
+
+namespace wcf\data\email\log\entry;
+
+use wcf\data\AbstractDatabaseObjectAction;
+
+/**
+ * Executes email log entry-related actions.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\Email\Log\Entry
+ *
+ * @method EmailLogEntry create()
+ * @method EmailLogEntryEditor[] getObjects()
+ * @method EmailLogEntryEditor getSingleObject()
+ */
+class EmailLogEntryAction extends AbstractDatabaseObjectAction
+{
+ /**
+ * @inheritDoc
+ */
+ protected $className = EmailLogEntryEditor::class;
+}
--- /dev/null
+<?php
+
+namespace wcf\data\email\log\entry;
+
+use wcf\data\DatabaseObjectEditor;
+
+/**
+ * Extends the email log entry object with functions to create, update and delete history entries.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\Email\Log\Entry
+ *
+ * @method static EmailLogEntry create(array $parameters = [])
+ * @method EmailLogEntry getDecoratedObject()
+ * @mixin EmailLogEntry
+ */
+class EmailLogEntryEditor extends DatabaseObjectEditor
+{
+ /**
+ * @inheritDoc
+ */
+ protected static $baseClass = EmailLogEntry::class;
+}
--- /dev/null
+<?php
+
+namespace wcf\data\email\log\entry;
+
+use wcf\data\DatabaseObjectList;
+
+/**
+ * Represents a list of email log entries.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\Emaiil\Log\Entry
+ *
+ * @method EmailLogEntry current()
+ * @method EmailLogEntry[] getObjects()
+ * @method EmailLogEntry|null search($objectID)
+ * @property EmailLogEntry[] $objects
+ */
+class EmailLogEntryList extends DatabaseObjectList
+{
+ /**
+ * @inheritDoc
+ */
+ public $className = EmailLogEntry::class;
+}
KEY (obsoletedAt, obsoletedByUserID)
);
+DROP TABLE IF EXISTS wcf1_email_log_entry;
+CREATE TABLE wcf1_email_log_entry (
+ entryID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ time INT(10) NOT NULL,
+ messageID VARCHAR(255) NOT NULL,
+ recipient VARCHAR(255) NOT NULL,
+ recipientID INT(10) DEFAULT NULL,
+ status VARCHAR(255) NOT NULL,
+ message TEXT,
+
+ KEY time (time)
+);
+
DROP TABLE IF EXISTS wcf1_event_listener;
CREATE TABLE wcf1_event_listener (
listenerID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
ALTER TABLE wcf1_edit_history_entry ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_edit_history_entry ADD FOREIGN KEY (obsoletedByUserID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
+ALTER TABLE wcf1_email_log_entry ADD FOREIGN KEY (recipientID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
+
ALTER TABLE wcf1_event_listener ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
ALTER TABLE wcf1_language_item ADD FOREIGN KEY (languageID) REFERENCES wcf1_language (languageID) ON DELETE CASCADE;