fix pages and add distribution system
Tests / PHPUnit (push) Failing after 1m13s

This commit is contained in:
root
2026-07-15 23:03:51 -04:00
parent 7f3b24e47f
commit ba87598d3a
38 changed files with 1362 additions and 658 deletions
@@ -90,6 +90,10 @@ class NotificationsController extends BaseController
{
helper('url');
if ($redirect = $this->redirectWithoutLegacyTermFilters('notifications/active')) {
return $redirect;
}
$targetGroup = $this->request->getGet('target_group');
return view('notifications/list_active', [
@@ -102,6 +106,10 @@ class NotificationsController extends BaseController
{
helper(['url', 'form']);
if ($redirect = $this->redirectWithoutLegacyTermFilters('notifications/deleted')) {
return $redirect;
}
return view('notifications/list_deleted', [
'deletedNotificationsEndpoint' => site_url('api/notifications/deleted'),
'restoreEndpoint' => site_url('notifications/restore'),
@@ -149,7 +157,7 @@ class NotificationsController extends BaseController
$targetGroup = null;
}
$schoolYear = (string) ((new \App\Models\ConfigurationModel())->getConfig('school_year') ?? '');
$schoolYear = $this->currentSchoolYearName();
if ($schoolYear !== '' && db_connect()->fieldExists('school_year', 'notifications')) {
$this->notificationModel->where('school_year', $schoolYear);
}
@@ -215,4 +223,25 @@ class NotificationsController extends BaseController
'notifications' => $notifications,
];
}
private function redirectWithoutLegacyTermFilters(string $route): ?\CodeIgniter\HTTP\RedirectResponse
{
$legacyTermKeys = ['school_year', 'schoolYear', 'year', 'semester'];
$query = $this->request->getGet();
$hasLegacyTermFilter = false;
foreach ($legacyTermKeys as $key) {
if (array_key_exists($key, $query)) {
unset($query[$key]);
$hasLegacyTermFilter = true;
}
}
if (!$hasLegacyTermFilter) {
return null;
}
$target = site_url($route) . (!empty($query) ? '?' . http_build_query($query) : '');
return redirect()->to($target);
}
}