Diff #4 - trunk/src/Models/EmailQueue.php
2,314 bytes
|
|
January 20, 2025 at 08:20
|
Diff
Index: EmailQueue.php
--- EmailQueue.php (nonexistent) +++ EmailQueue.php (revision 4) @@ -0,0 +1,83 @@ +<?php +declare(strict_types=1); + +namespace App\Webapp\Models; + +use Apex\App\Base\Model\MagicModel; +use App\Webapp\AdminProfiles; +use DateTime; + +/** + * EmailQueue Model + */ +class EmailQueue extends MagicModel +{ + + #[Inject(AdminProfiles::class)] + private AdminProfiles $admin_profiles; + + /** + * Database table + * + * @var string + */ + protected static string $dbtable = 'internal_email_notifications_queue'; + + /** + * Constructor + */ + public function __construct( + protected int $id, + protected bool $is_pending = true, + protected int $total_sent = 0, + protected int $opens = 0, + protected int $clicks = 0, + protected string $mhash = '', + protected string $sent_by = '', + protected string $sender = '', + protected string $reply_to = '', + protected ?DateTIme $send_date = null, + protected string $adapter = '', + protected string $subject = '', + protected string $attach_filename = '', + protected string $attach_contents = '', + protected string $text_message = '', + protected string $html_message = '', + protected string $condition_vars = '', + protected ?DateTime $started_at = null, + protected ?DateTime $completed_at = null + ) { + + } + + /** + * toDisplayArray + */ + public function toDisplayArray():array + { + + // Get array + $vars = $this->toArray(); + + // Get sender + if (!$sender = $this->admin_profiles->loadUuid($this->sender)) { + throw new \Exception("No sender admin exists with the uuid, " . $this->sender); + } + + // Set variables + $vars['sender'] = $sender->getFullName() . " <" . $sender->getEmail() . ">"; + $vars['started_at'] = $this->convert->date($this->started_at, true); + $vars['completed_at'] = $this->completed_at === null ? 'Not Sent' : $this->convert->date($this->completed_at, true); + + // Get attachment + $vars['attachment'] = ''; + if ($this->attach_filename != '') { + $vars['attachment'] = "mhash . "\" target=\"_blank\">" . $this->attach_filename . ""; + } + + // Return + return $vars; + } + +} +
Full Code
<?php declare(strict_types=1);
namespace App\Webapp\Models;
use Apex\App\Base\Model\MagicModel; use App\Webapp\AdminProfiles; use DateTime;
/** * EmailQueue Model */ class EmailQueue extends MagicModel {
#[Inject(AdminProfiles::class)]
private AdminProfiles $admin_profiles;
/**
* Database table
*
* @var string
*/
protected static string $dbtable = 'internal_email_notifications_queue';
/**
* Constructor
*/
public function __construct(
protected int $id,
protected bool $is_pending = true,
protected int $total_sent = 0,
protected int $opens = 0,
protected int $clicks = 0,
protected string $mhash = '',
protected string $sent_by = '',
protected string $sender = '',
protected string $reply_to = '',
protected ?DateTIme $send_date = null,
protected string $adapter = '',
protected string $subject = '',
protected string $attach_filename = '',
protected string $attach_contents = '',
protected string $text_message = '',
protected string $html_message = '',
protected string $condition_vars = '',
protected ?DateTime $started_at = null,
protected ?DateTime $completed_at = null
) {
}
/**
* toDisplayArray
*/
public function toDisplayArray():array
{
// Get array
$vars = $this->toArray();
// Get sender
if (!$sender = $this->admin_profiles->loadUuid($this->sender)) {
throw new \Exception("No sender admin exists with the uuid, " . $this->sender);
}
// Set variables
$vars['sender'] = $sender->getFullName() . " <" . $sender->getEmail() . ">";
$vars['started_at'] = $this->convert->date($this->started_at, true);
$vars['completed_at'] = $this->completed_at === null ? 'Not Sent' : $this->convert->date($this->completed_at, true);
// Get attachment
$vars['attachment'] = '';
if ($this->attach_filename != '') {
$vars['attachment'] = "<a href=\"/admin/communicate/email_history_attach_download?mhash=" . $this->mhash . "\" target=\"_blank\">" . $this->attach_filename . "</a>";
}
// Return
return $vars;
}
}