public static function handleEmailPreviewRequest(AbstractAlert $Alert) { $GLOBALS['Session']->requireAccountLevel('Staff'); $email = \Emergence\Mailer\AbstractMailer::renderTemplate('alerts/notifications/' . $Alert::$notificationTemplate, ['Alert' => $Alert]); \Debug::dumpVar($Alert->getData(), false, 'Alert'); print '<h2>Email</h2>'; print '<pre>'; print 'From: ' . htmlspecialchars($email['from'] ?: \Emergence\Mailer\AbstractMailer::getDefaultFrom()) . PHP_EOL; print 'Subject: ' . htmlspecialchars($email['subject']) . PHP_EOL . PHP_EOL; print htmlspecialchars($email['body']); print '</pre>'; print '<h2>Preview</h2>'; print '<div style="border: 1px dashed #ccc; width: 600px; font-family: arial,sans-serif; font-size: 80%; padding: 15px">' . $email['body'] . '</div>'; }
public static function getDownEndpoints() { if (isset(static::$_downEndpointIds)) { return static::$_downEndpointIds; } $cacheKey = 'endpoints-down'; if (false === ($endpointIds = Cache::fetch($cacheKey))) { $endpointIds = []; foreach (AbstractAlert::getAllByField('Status', 'open') as $Alert) { if ($Alert::$isFatal) { $endpointIds[] = $Alert->EndpointID; } } $endpointIds = array_unique($endpointIds); Cache::store($cacheKey, $endpointIds, static::$metricTTL); } return static::$_downEndpointIds = $endpointIds; }