This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user