Replace all SendGrid references with CyberMail in admin UI

This commit is contained in:
2026-05-29 15:06:43 +00:00
parent 25e96a3d5f
commit 53f9f3e4da
2 changed files with 139 additions and 169 deletions
+34 -34
View File
@@ -10,24 +10,24 @@ require_once __DIR__ . '/includes/header.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$section = $_POST['section'] ?? '';
if ($section === 'sendgrid') {
setSetting('email_sendgrid', [
'api_key' => trim($_POST['sendgrid_api_key'] ?? ''),
if ($section === 'cybermail') {
setSetting('email_cybermail', [
'api_key' => trim($_POST['cybermail_api_key'] ?? ''),
'from_email' => trim($_POST['from_email'] ?? ''),
'from_name' => trim($_POST['from_name'] ?? '')
'from_name' => trim($_POST['from_name'] ?? '')
]);
setFlash('success', 'SendGrid settings updated');
setFlash('success', 'CyberMail settings updated');
}
if ($section === 'notifications') {
setSetting('email_notifications', [
'order_confirmation' => isset($_POST['notif_order_confirmation']),
'order_shipped' => isset($_POST['notif_order_shipped']),
'order_delivered' => isset($_POST['notif_order_delivered']),
'abandoned_cart' => isset($_POST['notif_abandoned_cart']),
'low_stock' => isset($_POST['notif_low_stock']),
'admin_new_order' => isset($_POST['notif_admin_new_order']),
'admin_email' => trim($_POST['admin_email'] ?? '')
'order_shipped' => isset($_POST['notif_order_shipped']),
'order_delivered' => isset($_POST['notif_order_delivered']),
'abandoned_cart' => isset($_POST['notif_abandoned_cart']),
'low_stock' => isset($_POST['notif_low_stock']),
'admin_new_order' => isset($_POST['notif_admin_new_order']),
'admin_email' => trim($_POST['admin_email'] ?? '')
]);
setFlash('success', 'Notification settings updated');
}
@@ -36,12 +36,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$testEmail = trim($_POST['test_email'] ?? '');
if ($testEmail && filter_var($testEmail, FILTER_VALIDATE_EMAIL)) {
$sent = sendEmail($testEmail, 'Test Email from Tom\'s Java Jive',
'<div style="font-family: Arial; padding: 20px;"><h2>Test Email</h2><p>If you received this, your email settings are working correctly!</p></div>'
'<div style="font-family: Arial; padding: 20px;"><h2>Test Email</h2><p>If you received this, your CyberMail settings are working correctly!</p></div>'
);
if ($sent) {
setFlash('success', 'Test email sent to ' . $testEmail);
} else {
setFlash('error', 'Failed to send test email. Check your SendGrid settings.');
setFlash('error', 'Failed to send test email. Check CYBERMAIL_API_KEY in config.');
}
}
}
@@ -50,20 +50,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit;
}
$sendgrid = getSetting('email_sendgrid', [
'api_key' => '',
$cybermail = getSetting('email_cybermail', [
'api_key' => '',
'from_email' => '',
'from_name' => "Tom's Java Jive"
'from_name' => "Tom's Java Jive"
]);
$notifications = getSetting('email_notifications', [
'order_confirmation' => true,
'order_shipped' => true,
'order_delivered' => true,
'abandoned_cart' => false,
'low_stock' => true,
'admin_new_order' => true,
'admin_email' => ''
'order_shipped' => true,
'order_delivered' => true,
'abandoned_cart' => false,
'low_stock' => true,
'admin_new_order' => true,
'admin_email' => ''
]);
?>
@@ -91,38 +91,38 @@ $notifications = getSetting('email_notifications', [
</div>
<div>
<!-- SendGrid Settings -->
<!-- CyberMail Settings -->
<form method="POST">
<input type="hidden" name="section" value="sendgrid">
<input type="hidden" name="section" value="cybermail">
<div class="admin-card">
<div class="admin-card-header">
<h3 class="admin-card-title"><i class="fas fa-paper-plane"></i> SendGrid Configuration</h3>
<h3 class="admin-card-title"><i class="fas fa-paper-plane"></i> CyberMail Configuration</h3>
</div>
<div class="admin-card-body">
<div class="form-group">
<label class="form-label">SendGrid API Key</label>
<input type="password" name="sendgrid_api_key" class="form-input"
value="<?= htmlspecialchars($sendgrid['api_key']) ?>"
placeholder="SG.xxxx...">
<small class="text-muted">Get this from <a href="https://app.sendgrid.com/settings/api_keys" target="_blank">SendGrid Dashboard</a></small>
<label class="form-label">CyberMail API Key</label>
<input type="password" name="cybermail_api_key" class="form-input"
value="<?= htmlspecialchars($cybermail['api_key']) ?>"
placeholder="sk_live_...">
<small class="text-muted">Manage at <a href="https://platform.cyberpersons.com/email/api-keys/" target="_blank">CyberMail Dashboard</a></small>
</div>
<div class="form-row">
<div class="form-group">
<label class="form-label">From Email</label>
<input type="email" name="from_email" class="form-input"
value="<?= htmlspecialchars($sendgrid['from_email']) ?>"
placeholder="noreply@yourdomain.com">
value="<?= htmlspecialchars($cybermail['from_email']) ?>"
placeholder="noreply@orbishosting.com">
</div>
<div class="form-group">
<label class="form-label">From Name</label>
<input type="text" name="from_name" class="form-input"
value="<?= htmlspecialchars($sendgrid['from_name']) ?>"
value="<?= htmlspecialchars($cybermail['from_name']) ?>"
placeholder="Tom's Java Jive">
</div>
</div>
<button type="submit" class="btn btn-primary">Save SendGrid Settings</button>
<button type="submit" class="btn btn-primary">Save CyberMail Settings</button>
</div>
</div>
</form>
+43 -73
View File
@@ -13,17 +13,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$section = $_POST['section'] ?? '';
$settingsMap = [
'sendgrid' => ['sendgrid_api_key', 'sendgrid_from_email', 'sendgrid_from_name', 'email_notifications_enabled'],
'twilio' => ['twilio_account_sid', 'twilio_auth_token', 'twilio_phone_number', 'sms_notifications_enabled'],
'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'],
'loyalty' => ['loyalty_enabled']
'cybermail' => ['cybermail_api_key', 'cybermail_from_email', 'cybermail_from_name', 'email_notifications_enabled'],
'twilio' => ['twilio_account_sid', 'twilio_auth_token', 'twilio_phone_number', 'sms_notifications_enabled'],
'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'],
'loyalty' => ['loyalty_enabled']
];
if (isset($settingsMap[$section])) {
foreach ($settingsMap[$section] as $key) {
$value = $_POST[$key] ?? '';
// Check if setting exists
$existing = db()->fetch("SELECT id FROM settings WHERE setting_key = :key", ['key' => $key]);
if ($existing) {
@@ -33,7 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
);
} else {
db()->insert('settings', [
'setting_key' => $key,
'setting_key' => $key,
'setting_value' => $value
]);
}
@@ -84,10 +83,10 @@ foreach ($allSettings as $s) {
font-size: 1.5rem;
}
.integration-icon.sendgrid { background: #1A82E2; color: white; }
.integration-icon.twilio { background: #F22F46; color: white; }
.integration-icon.push { background: #8B5CF6; color: white; }
.integration-icon.loyalty { background: #F59E0B; color: white; }
.integration-icon.cybermail { background: #0ea5e9; color: white; }
.integration-icon.twilio { background: #F22F46; color: white; }
.integration-icon.push { background: #8B5CF6; color: white; }
.integration-icon.loyalty { background: #F59E0B; color: white; }
.integration-body {
padding: 1.5rem;
@@ -100,44 +99,15 @@ foreach ($allSettings as $s) {
font-weight: 600;
}
.status-badge.configured {
background: rgba(16, 185, 129, 0.1);
color: var(--admin-success);
}
.status-badge.configured { background: rgba(16, 185, 129, 0.1); color: var(--admin-success); }
.status-badge.not-configured { background: rgba(245, 158, 11, 0.1); color: var(--admin-warning); }
.status-badge.enabled { background: rgba(16, 185, 129, 0.1); color: var(--admin-success); }
.status-badge.disabled { background: rgba(239, 68, 68, 0.1); color: var(--admin-error); }
.status-badge.not-configured {
background: rgba(245, 158, 11, 0.1);
color: var(--admin-warning);
}
.status-badge.enabled {
background: rgba(16, 185, 129, 0.1);
color: var(--admin-success);
}
.status-badge.disabled {
background: rgba(239, 68, 68, 0.1);
color: var(--admin-error);
}
.key-input {
font-family: monospace;
font-size: 0.875rem;
}
.test-btn {
margin-top: 0.5rem;
}
.help-text {
font-size: 0.75rem;
color: var(--admin-text-muted);
margin-top: 0.25rem;
}
.help-link {
color: var(--admin-primary);
}
.key-input { font-family: monospace; font-size: 0.875rem; }
.test-btn { margin-top: 0.5rem; }
.help-text { font-size: 0.75rem; color: var(--admin-text-muted); margin-top: 0.25rem; }
.help-link { color: var(--admin-primary); }
</style>
<div class="page-header">
@@ -151,41 +121,41 @@ foreach ($allSettings as $s) {
</div>
<?php endif; ?>
<!-- SendGrid Email -->
<!-- CyberMail Email -->
<div class="integration-card">
<div class="integration-header">
<div class="integration-title">
<div class="integration-icon sendgrid">
<div class="integration-icon cybermail">
<i class="fas fa-envelope"></i>
</div>
<div>
<h3 style="margin: 0;">SendGrid Email</h3>
<h3 style="margin: 0;">CyberMail</h3>
<p style="margin: 0.25rem 0 0; color: var(--admin-text-muted); font-size: 0.875rem;">
Send transactional emails (order confirmations, shipping updates, etc.)
</p>
</div>
</div>
<?php
$sgConfigured = !empty($settings['sendgrid_api_key']) && $settings['sendgrid_api_key'] !== 'YOUR_SENDGRID_API_KEY_HERE';
$sgEnabled = ($settings['email_notifications_enabled'] ?? '0') === '1';
$cmConfigured = !empty($settings['cybermail_api_key']);
$cmEnabled = ($settings['email_notifications_enabled'] ?? '0') === '1';
?>
<span class="status-badge <?= $sgConfigured && $sgEnabled ? 'enabled' : ($sgConfigured ? 'configured' : 'not-configured') ?>">
<?= $sgConfigured && $sgEnabled ? 'Enabled' : ($sgConfigured ? 'Configured' : 'Not Configured') ?>
<span class="status-badge <?= $cmConfigured && $cmEnabled ? 'enabled' : ($cmConfigured ? 'configured' : 'not-configured') ?>">
<?= $cmConfigured && $cmEnabled ? 'Enabled' : ($cmConfigured ? 'Configured' : 'Not Configured') ?>
</span>
</div>
<div class="integration-body">
<form method="POST">
<input type="hidden" name="section" value="sendgrid">
<input type="hidden" name="section" value="cybermail">
<div class="form-row">
<div class="form-group" style="flex: 2;">
<label class="form-label">SendGrid API Key</label>
<input type="password" name="sendgrid_api_key" class="form-input key-input"
value="<?= htmlspecialchars($settings['sendgrid_api_key'] ?? '') ?>"
placeholder="SG.xxxxxxxxxxxxxxxxxxxxxxxx">
<label class="form-label">CyberMail API Key</label>
<input type="password" name="cybermail_api_key" class="form-input key-input"
value="<?= htmlspecialchars($settings['cybermail_api_key'] ?? '') ?>"
placeholder="sk_live_...">
<p class="help-text">
Get your API key from
<a href="https://app.sendgrid.com/settings/api_keys" target="_blank" class="help-link">SendGrid Dashboard</a>
Manage at
<a href="https://platform.cyberpersons.com/email/api-keys/" target="_blank" class="help-link">CyberMail Dashboard</a>
</p>
</div>
</div>
@@ -193,13 +163,13 @@ foreach ($allSettings as $s) {
<div class="form-row">
<div class="form-group">
<label class="form-label">From Email</label>
<input type="email" name="sendgrid_from_email" class="form-input"
value="<?= htmlspecialchars($settings['sendgrid_from_email'] ?? 'noreply@tomsjavajive.com') ?>">
<input type="email" name="cybermail_from_email" class="form-input"
value="<?= htmlspecialchars($settings['cybermail_from_email'] ?? 'noreply@tomsjavajive.com') ?>">
</div>
<div class="form-group">
<label class="form-label">From Name</label>
<input type="text" name="sendgrid_from_name" class="form-input"
value="<?= htmlspecialchars($settings['sendgrid_from_name'] ?? "Tom's Java Jive") ?>">
<input type="text" name="cybermail_from_name" class="form-input"
value="<?= htmlspecialchars($settings['cybermail_from_name'] ?? "Tom's Java Jive") ?>">
</div>
</div>
@@ -215,7 +185,7 @@ foreach ($allSettings as $s) {
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Settings
</button>
<button type="button" class="btn btn-secondary" onclick="testSendGrid()">
<button type="button" class="btn btn-secondary" onclick="testCyberMail()">
<i class="fas fa-paper-plane"></i> Send Test Email
</button>
</div>
@@ -239,7 +209,7 @@ foreach ($allSettings as $s) {
</div>
<?php
$twConfigured = !empty($settings['twilio_account_sid']) && !empty($settings['twilio_auth_token']);
$twEnabled = ($settings['sms_notifications_enabled'] ?? '0') === '1';
$twEnabled = ($settings['sms_notifications_enabled'] ?? '0') === '1';
?>
<span class="status-badge <?= $twConfigured && $twEnabled ? 'enabled' : ($twConfigured ? 'configured' : 'not-configured') ?>">
<?= $twConfigured && $twEnabled ? 'Enabled' : ($twConfigured ? 'Configured' : 'Not Configured') ?>
@@ -311,7 +281,7 @@ foreach ($allSettings as $s) {
</div>
<?php
$pushConfigured = !empty($settings['vapid_public_key']) && !empty($settings['vapid_private_key']);
$pushEnabled = ($settings['push_notifications_enabled'] ?? '0') === '1';
$pushEnabled = ($settings['push_notifications_enabled'] ?? '0') === '1';
?>
<span class="status-badge <?= $pushConfigured && $pushEnabled ? 'enabled' : ($pushConfigured ? 'configured' : 'not-configured') ?>">
<?= $pushConfigured && $pushEnabled ? 'Enabled' : ($pushConfigured ? 'Configured' : 'Not Configured') ?>
@@ -424,7 +394,7 @@ foreach ($allSettings as $s) {
</tbody>
</table>
<p class="text-muted" style="margin: 1rem 0 0; font-size: 0.875rem;">
100 points = $1 credit Points earned on every purchase
100 points = $1 credit &bull; Points earned on every purchase
</p>
</div>
@@ -463,7 +433,7 @@ foreach ($allSettings as $s) {
<script>
let testType = '';
function testSendGrid() {
function testCyberMail() {
testType = 'email';
document.getElementById('testModalTitle').textContent = 'Send Test Email';
document.getElementById('testInputLabel').textContent = 'Recipient Email';
@@ -486,9 +456,9 @@ function testTwilio() {
document.getElementById('testForm').addEventListener('submit', async function(e) {
e.preventDefault();
const recipient = document.getElementById('testRecipient').value;
const resultDiv = document.getElementById('testResult');
const submitBtn = document.getElementById('testSubmitBtn');
const recipient = document.getElementById('testRecipient').value;
const resultDiv = document.getElementById('testResult');
const submitBtn = document.getElementById('testSubmitBtn');
submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Sending...';