Makes sure feedback messages are included only once

main
Yasen Pramatarov 2025-11-11 17:40:08 +02:00
parent 26c9f49138
commit 2ed49eb12d
22 changed files with 29 additions and 38 deletions

View File

@ -29,7 +29,7 @@ class DatabaseConnector
// Show error and exit // Show error and exit
Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage())); Feedback::flash('ERROR', 'DEFAULT', getError('Error connecting to the database.', $e->getMessage()));
include __DIR__ . '/../templates/page-header.php'; include __DIR__ . '/../templates/page-header.php';
include __DIR__ . '/../helpers/feedback.php'; include_once __DIR__ . '/../helpers/feedback.php';
include __DIR__ . '/../templates/page-footer.php'; include __DIR__ . '/../templates/page-footer.php';
exit(); exit();
} }

View File

@ -6,17 +6,8 @@
* Combines functionality to handle retrieving and displaying feedback messages. * Combines functionality to handle retrieving and displaying feedback messages.
*/ */
// Prevent multiple display of flash messages on the same page // Get any flash messages from previous request
if (!isset($_SESSION['flash_messages_displayed'])) { $flash_messages = Feedback::getFlash();
$_SESSION['flash_messages_displayed'] = false;
}
// Get any flash messages from previous request (only once per page load)
$flash_messages = [];
if (!$_SESSION['flash_messages_displayed']) {
$flash_messages = Feedback::getFlash();
$_SESSION['flash_messages_displayed'] = true;
}
if (!empty($flash_messages)) { if (!empty($flash_messages)) {
$system_messages = array_merge($system_messages ?? [], array_map(function($flash) { $system_messages = array_merge($system_messages ?? [], array_map(function($flash) {

View File

@ -29,7 +29,7 @@ if (!$canAdmin) {
} }
// Get any old feedback messages // Get any old feedback messages
include __DIR__ . '/../helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Handle actions // Handle actions
$action = $_POST['action'] ?? ''; $action = $_POST['action'] ?? '';

View File

@ -167,7 +167,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/agents.php'; include '../app/templates/agents.php';

View File

@ -101,7 +101,7 @@ if ($response['db'] === null) {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// display the widget // display the widget
include '../app/templates/components.php'; include '../app/templates/components.php';

View File

@ -160,7 +160,7 @@ if ($response['db'] === null) {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// display the widget // display the widget
include '../app/templates/conferences.php'; include '../app/templates/conferences.php';

View File

@ -7,7 +7,7 @@
*/ */
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
require '../app/classes/config.php'; require '../app/classes/config.php';
require '../app/classes/api_response.php'; require '../app/classes/api_response.php';

View File

@ -143,7 +143,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
} }
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the 2FA setup template // Load the 2FA setup template
include '../app/templates/credentials-2fa-setup.php'; include '../app/templates/credentials-2fa-setup.php';
@ -151,7 +151,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
case 'verify': case 'verify':
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the 2FA verification template // Load the 2FA verification template
include '../app/templates/credentials-2fa-verify.php'; include '../app/templates/credentials-2fa-verify.php';
@ -159,7 +159,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
default: default:
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the combined management template // Load the combined management template
include '../app/templates/credentials-manage.php'; include '../app/templates/credentials-manage.php';

View File

@ -10,7 +10,7 @@
*/ */
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
require '../app/classes/conference.php'; require '../app/classes/conference.php';
require '../app/classes/participant.php'; require '../app/classes/participant.php';

View File

@ -85,7 +85,7 @@ $widget['name'] = 'Graphs';
$widget['title'] = 'Jitsi graphs'; $widget['title'] = 'Jitsi graphs';
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/graphs.php'; include '../app/templates/graphs.php';

View File

@ -1,6 +1,6 @@
<?php <?php
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
include '../app/templates/help.php'; include '../app/templates/help.php';

View File

@ -100,7 +100,7 @@ foreach ($hosts as $host) {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/latest.php'; include '../app/templates/latest.php';

View File

@ -10,7 +10,7 @@ $settingsObject = new Settings();
$livejsData = $settingsObject->getPlatformJsFile($platformDetails[0]['jitsi_url'], $item, $raw); $livejsData = $settingsObject->getPlatformJsFile($platformDetails[0]['jitsi_url'], $item, $raw);
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/livejs.php'; include '../app/templates/livejs.php';

View File

@ -60,7 +60,7 @@ try {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Make userId available to template // Make userId available to template
$userId = $pending2FA['user_id']; $userId = $pending2FA['user_id'];
@ -115,7 +115,7 @@ try {
$security->generateCsrfToken(); $security->generateCsrfToken();
// Load the forgot password form // Load the forgot password form
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
include '../app/templates/form-password-forgot.php'; include '../app/templates/form-password-forgot.php';
exit(); exit();
@ -175,7 +175,7 @@ try {
} }
// Show reset password form // Show reset password form
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
include '../app/templates/form-password-reset.php'; include '../app/templates/form-password-reset.php';
exit(); exit();
@ -272,7 +272,7 @@ if (!empty($config['login_message'])) {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/form-login.php'; include '../app/templates/form-login.php';

View File

@ -170,7 +170,7 @@ if ($response['db'] === null) {
} }
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// display the widget // display the widget
include '../app/templates/participants.php'; include '../app/templates/participants.php';

View File

@ -160,7 +160,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$isTimezoneSet = !empty($userDetails[0]['timezone']); $isTimezoneSet = !empty($userDetails[0]['timezone']);
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/profile-edit.php'; include '../app/templates/profile-edit.php';
@ -168,7 +168,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
default: default:
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/profile.php'; include '../app/templates/profile.php';

View File

@ -168,7 +168,7 @@ $whitelisted = $rateLimiter->getWhitelistedIps();
$blacklisted = $rateLimiter->getBlacklistedIps(); $blacklisted = $rateLimiter->getBlacklistedIps();
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Load the template // Load the template
include '../app/templates/security.php'; include '../app/templates/security.php';

View File

@ -12,7 +12,7 @@ $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
$action = $_REQUEST['action'] ?? ''; $action = $_REQUEST['action'] ?? '';
$agent = $_REQUEST['agent'] ?? ''; $agent = $_REQUEST['agent'] ?? '';

View File

@ -9,7 +9,7 @@
*/ */
// Get any new feedback messages // Get any new feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
require '../app/classes/agent.php'; require '../app/classes/agent.php';
require '../app/classes/host.php'; require '../app/classes/host.php';

View File

@ -20,7 +20,7 @@ if (!Session::isValidSession()) {
} }
// Get any old feedback messages // Get any old feedback messages
include '../app/helpers/feedback.php'; include_once '../app/helpers/feedback.php';
// Handle theme switching // Handle theme switching
if (isset($_GET['switch_to'])) { if (isset($_GET['switch_to'])) {

View File

@ -113,7 +113,7 @@ if (!empty($search)) {
$username = $userObject->getUserDetails($userId)[0]['username']; $username = $userObject->getUserDetails($userId)[0]['username'];
// Get any new feedback messages // Get any new feedback messages
include dirname(__FILE__, 4) . '/app/helpers/feedback.php'; include_once dirname(__FILE__, 4) . '/app/helpers/feedback.php';
// Load plugin helpers // Load plugin helpers
include PLUGIN_LOGS_PATH . 'helpers/logs_view_helper.php'; include PLUGIN_LOGS_PATH . 'helpers/logs_view_helper.php';

View File

@ -99,7 +99,7 @@ if ($config['registration_enabled'] == true) {
} }
// Get any new feedback messages // Get any new feedback messages
include dirname(__FILE__, 4) . '/app/helpers/feedback.php'; include_once dirname(__FILE__, 4) . '/app/helpers/feedback.php';
// Load the template // Load the template
include PLUGIN_REGISTER_PATH . 'views/form-register.php'; include PLUGIN_REGISTER_PATH . 'views/form-register.php';