Agent Banners, which lists them all. The handlers are * agent/post/agent_banner.php. */ /** Has the 3.7.2 update run? Until it has, there are no banners. */ function agentBannersReady() { return defined('CURRENT_DATABASE_VERSION') && version_compare(CURRENT_DATABASE_VERSION, '3.7.2', '>='); } /** May this agent add or change a banner for this client - one they can edit, or, for every client (0), an admin? */ function agentBannerCanEdit($client_id) { global $session_is_admin; $client_id = intval($client_id); if (!empty($session_is_admin)) { return true; } return $client_id > 0 && lookupUserPermission('module_client') >= 2 && hasClientAccess($client_id); } /** A banner, or null. */ function agentBannerRow($announcement_id) { global $mysqli; $announcement_id = intval($announcement_id); if (!agentBannersReady() || !$announcement_id) { return null; } return mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT announcement_id, announcement_title, announcement_body, announcement_tone, announcement_client_id, announcement_starts_at, announcement_ends_at, announcement_archived_at FROM portal_announcements WHERE announcement_id = $announcement_id AND announcement_audience = 'agents' LIMIT 1")) ?: null; } /** A client's banners not over yet - showing or still to come - for its ⋮ menu. */ function agentBannersForClient($client_id) { global $mysqli; $client_id = intval($client_id); $rows = []; if (!agentBannersReady() || !$client_id) { return $rows; } $sql = mysqli_query($mysqli, "SELECT announcement_id, announcement_title, announcement_tone, announcement_starts_at, announcement_ends_at, announcement_archived_at FROM portal_announcements WHERE announcement_audience = 'agents' AND announcement_client_id = $client_id AND announcement_archived_at IS NULL AND (announcement_ends_at IS NULL OR announcement_ends_at > NOW()) ORDER BY COALESCE(announcement_starts_at, announcement_created_at) DESC, announcement_id DESC LIMIT 10"); while ($row = mysqli_fetch_assoc($sql)) { $rows[] = $row; } return $rows; } /* * The banners for this page, as HTML - every client's, and this client's when the page is one of * its (0 when it isn't). Urgent first, then the client's, then the newest. Drawn with the alerts * (includes/inc_alert_feedback.php), unless the page sets $agent_banners_later because it learns * its client further down (a ticket opened on its own) and asks then. Each is drawn once a page, * so asking again on a client's page adds nothing. */ function agentBannersHtml($client_id = 0) { global $mysqli, $session_user_id; static $shown = []; static $script = false; $user_id = intval($session_user_id ?? 0); if (!$user_id || !agentBannersReady()) { return ''; } $client_id = intval($client_id); $not_shown = $shown ? ' AND announcement_id NOT IN (' . implode(',', array_keys($shown)) . ')' : ''; $sql = mysqli_query($mysqli, "SELECT announcement_id, announcement_title, announcement_body, announcement_tone, announcement_client_id, client_name FROM portal_announcements LEFT JOIN clients ON client_id = announcement_client_id LEFT JOIN announcement_dismissals ON announcement_dismissal_announcement_id = announcement_id AND announcement_dismissal_user_id = $user_id WHERE announcement_audience = 'agents' AND announcement_archived_at IS NULL AND announcement_client_id IN (0, $client_id)$not_shown AND (announcement_starts_at IS NULL OR announcement_starts_at <= NOW()) AND (announcement_ends_at IS NULL OR announcement_ends_at > NOW()) AND (announcement_tone = 'danger' OR announcement_dismissal_at IS NULL OR announcement_dismissal_at < COALESCE(announcement_updated_at, announcement_created_at)) ORDER BY announcement_tone = 'danger' DESC, announcement_client_id > 0 DESC, COALESCE(announcement_starts_at, announcement_created_at) DESC, announcement_id DESC LIMIT 10"); $html = ''; $hideable = false; while ($row = mysqli_fetch_assoc($sql)) { $announcement_id = intval($row['announcement_id']); $shown[$announcement_id] = true; $tone_key = isset(PORTAL_ANNOUNCEMENT_TONES[$row['announcement_tone']]) ? $row['announcement_tone'] : 'info'; $tone = PORTAL_ANNOUNCEMENT_TONES[$tone_key]; $urgent = $tone_key === 'danger'; $hideable = $hideable || !$urgent; $for = intval($row['announcement_client_id']) ? '' . escapeHtml($row['client_name'] ?? '') . '' : ''; $body = trim((string) $row['announcement_body']) !== '' ? '
' . portalAnnouncementBodyHtml($row['announcement_body']) . '
' : ''; $html .= '
' . '' . '
' . escapeHtml($row['announcement_title']) . $for . '
' . $body . '
' . ($urgent ? '' : '') . '
'; } // Hiding one - gone at once, and kept hidden for this agent from the next page on if ($hideable && !$script) { $script = true; $html .= ''; } return $html; }