Files
itflow/admin/modals/portal_announcement/announcement_form.php
johnnyq e29369926f Client portal stage 4: accounts - Your account rebuilt with details and an ask-us link, phone numbers, ticket email choices, password change needing the current password and 8 characters with an email notice, two-step sign-in with an authenticator app set up from a QR code, remembered browsers with Forget them, phone PIN and recent sign-ins with the device; activity rebuilt with signing-in and changes tabs and paging; sign-in asks portal users with two-step sign-in for a code, remembers the browser on request and locks an account after five wrong codes in ten minutes, matching portal users by contact_user_id; Admin > Client Portal can require two-step sign-in, sending anyone without it to set it up first, and agents can turn it off for a contact from the contact page; password links stored as SHA-256 and running out after an hour for Forgot password and a week for invites, the nightly run clearing only run-out links, Forgot password limited to one email per account every five minutes and ten requests per address in ten minutes, the reset page rebuilt with the password typed twice and a confirmation email, fixing the empty-token check that let anyone trigger the reset email; contacts choose every ticket email or replies and fixes only, and primary and technical contacts can hear about new tickets at their company or every update, honoured by agent, portal, email parser and recurring ticket emails; announcements for every client or one with tone and start and end dates on the portal home page, managed in Admin > Client Portal; View as contact opens the portal read only as a contact from the agent contact page, audited, with billing shown only when the agent's role reads sales and financial, nothing written or paid while viewing; agent contact page shows two-step status, last sign-in and ticket email choices; database 3.1.0 adds portal_announcements, contact ticket email columns and config_client_portal_require_mfa and hashes outstanding links; new functions/portal.php; changelog updated
2026-10-17 12:05:55 -04:00

78 lines
3.6 KiB
PHP

<?php
/*
* An announcement's fields - for portal_announcement_add.php and _edit.php,
* which set $announcement (null when new). Posts to admin/post.php
* (admin/post/portal_announcement.php).
*/
isset($mysqli) || die("Direct file access is not allowed");
$a = $announcement ?? [];
$a_tone = isset(PORTAL_ANNOUNCEMENT_TONES[$a['announcement_tone'] ?? '']) ? $a['announcement_tone'] : 'info';
$a_client = intval($a['announcement_client_id'] ?? 0);
$a_local = function ($value) {
return $value ? date('Y-m-d\TH:i', strtotime($value)) : '';
};
?>
<div class="mb-3">
<label class="form-label">Title <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-bullhorn"></i></span>
<input type="text" class="form-control" name="title" maxlength="200" placeholder="Planned maintenance Saturday night" value="<?= escapeHtml($a['announcement_title'] ?? '') ?>" required autofocus>
</div>
</div>
<div class="mb-3">
<label class="form-label">Message</label>
<textarea class="form-control" name="body" rows="5" maxlength="5000" placeholder="What is happening, when, and what they need to do - web addresses become links"><?= escapeHtml($a['announcement_body'] ?? '') ?></textarea>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">Shown as</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-flag"></i></span>
<select class="form-select" name="tone">
<?php foreach (PORTAL_ANNOUNCEMENT_TONES as $key => $tone) { ?>
<option value="<?= $key ?>"<?= $a_tone === $key ? ' selected' : '' ?>><?= escapeHtml($tone['label']) ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">For</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-users"></i></span>
<select class="form-select select2" name="client_id">
<option value="0">Every client</option>
<?php
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL OR client_id = $a_client ORDER BY client_name ASC");
while ($row = mysqli_fetch_assoc($sql_clients)) { ?>
<option value="<?= intval($row['client_id']) ?>"<?= intval($row['client_id']) === $a_client ? ' selected' : '' ?>><?= escapeHtml($row['client_name']) ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">Show from</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-plus"></i></span>
<input type="datetime-local" class="form-control" name="starts_at" value="<?= escapeHtml($a_local($a['announcement_starts_at'] ?? '')) ?>">
</div>
<small class="text-secondary">Empty is straight away</small>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Until</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-times"></i></span>
<input type="datetime-local" class="form-control" name="ends_at" value="<?= escapeHtml($a_local($a['announcement_ends_at'] ?? '')) ?>">
</div>
<small class="text-secondary">Empty is until you archive it</small>
</div>
</div>