From 6f30071fda6906013010e90838b8f25ebd17a23f Mon Sep 17 00:00:00 2001 From: felixOlesen <74660787+felixOlesen@users.noreply.github.com> Date: Wed, 13 Dec 2023 16:05:00 +0800 Subject: [PATCH] System: refactoring error messages in activities and attendance. (#1768) --- index_tt_ajax.php | 4 +--- .../Activities/activities_manage_delete.php | 4 +--- .../activities_manage_enrolment_add.php | 4 +--- modules/Activities/activities_my_full.php | 8 ++----- modules/Activities/activities_view.php | 4 +--- modules/Activities/activities_view_full.php | 8 ++----- .../Activities/activities_view_register.php | 24 +++++-------------- .../Activities/report_attendance_byDate.php | 8 ++----- .../attendance_take_byCourseClass.php | 4 +--- .../attendance_take_byFormGroup.php | 4 +--- .../attendance_take_byFormGroupProcess.php | 4 +--- .../attendance_take_byPerson_delete.php | 4 +--- .../attendance_take_byPerson_edit.php | 4 +--- modules/Attendance/report_studentHistory.php | 20 ++++------------ passwordReset.php | 4 +--- 15 files changed, 27 insertions(+), 81 deletions(-) diff --git a/index_tt_ajax.php b/index_tt_ajax.php index 3a29702c40..b3083b03db 100644 --- a/index_tt_ajax.php +++ b/index_tt_ajax.php @@ -41,9 +41,7 @@ if (isActionAccessible($guid, $connection2, '/modules/Timetable/tt.php') == false) { //Acess denied - $output .= "
"; - $output .= __('Your request failed because you do not have access to this action.'); - $output .= '
'; + $page->addError(__('Your request failed because you do not have access to this action.')); } else { include './modules/Timetable/moduleFunctions.php'; $ttDate = ''; diff --git a/modules/Activities/activities_manage_delete.php b/modules/Activities/activities_manage_delete.php index 1a9cd3d9be..703039c808 100644 --- a/modules/Activities/activities_manage_delete.php +++ b/modules/Activities/activities_manage_delete.php @@ -41,9 +41,7 @@ $result->execute($data); if ($result) { if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError( __('The selected record does not exist, or you do not have access to it.')); } else { $form = DeleteForm::createForm($session->get('absoluteURL').'/modules/'.$session->get('module')."/activities_manage_deleteProcess.php?gibbonActivityID=$gibbonActivityID&search=".$_GET['search']."&gibbonSchoolYearTermID=".$_GET['gibbonSchoolYearTermID']); echo $form->getOutput(); diff --git a/modules/Activities/activities_manage_enrolment_add.php b/modules/Activities/activities_manage_enrolment_add.php index 9910ed3ce8..c5e61b492f 100644 --- a/modules/Activities/activities_manage_enrolment_add.php +++ b/modules/Activities/activities_manage_enrolment_add.php @@ -66,9 +66,7 @@ $result->execute($data); if ($result->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $values = $result->fetch(); diff --git a/modules/Activities/activities_my_full.php b/modules/Activities/activities_my_full.php index f9f200692a..30b13b0ec4 100644 --- a/modules/Activities/activities_my_full.php +++ b/modules/Activities/activities_my_full.php @@ -28,16 +28,12 @@ if (isActionAccessible($guid, $connection2, '/modules/Activities/activities_my_full.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('Your request failed because you do not have access to this action.')); } else { //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Proceed! //Get class variable diff --git a/modules/Activities/activities_view.php b/modules/Activities/activities_view.php index 2437770209..75ff0cb519 100644 --- a/modules/Activities/activities_view.php +++ b/modules/Activities/activities_view.php @@ -36,9 +36,7 @@ // Get action with highest precedence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { $page->breadcrumbs->add(__('View Activities')); diff --git a/modules/Activities/activities_view_full.php b/modules/Activities/activities_view_full.php index eae851f856..68606f3580 100644 --- a/modules/Activities/activities_view_full.php +++ b/modules/Activities/activities_view_full.php @@ -28,16 +28,12 @@ if (isActionAccessible($guid, $connection2, '/modules/Activities/activities_view_full.php') == false) { //Acess denied - echo "
"; - echo __('Your request failed because you do not have access to this action.'); - echo '
'; + $page->addError(__('Your request failed because you do not have access to this action.')); } else { //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Check access controls $settingGateway = $container->get(SettingGateway::class); diff --git a/modules/Activities/activities_view_register.php b/modules/Activities/activities_view_register.php index ad0bff8178..a4f45b3b9a 100644 --- a/modules/Activities/activities_view_register.php +++ b/modules/Activities/activities_view_register.php @@ -36,9 +36,7 @@ //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { $page->breadcrumbs ->add(__('View Activities'), 'activities_view.php') @@ -69,9 +67,7 @@ //Check if gibbonActivityID specified $gibbonActivityID = $_GET['gibbonActivityID']; if ($gibbonActivityID == 'Y') { - echo "
"; - echo __('You have not specified one or more required parameters.'); - echo '
'; + $page->addError(__('You have not specified one or more required parameters.')); } else { $mode = $_GET['mode']; @@ -136,9 +132,7 @@ if ($mode == 'register') { if ($continue == false) { - echo "
"; - echo __('Your request failed due to a database error.'); - echo '
'; + $page->addError(__('Your request failed due to a database error.')); } else { $today = date('Y-m-d'); @@ -162,9 +156,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { $values = $result->fetch(); @@ -305,9 +297,7 @@ } } elseif ($mode = 'unregister') { if ($continue == false) { - echo "
"; - echo __('Your request failed due to a database error.'); - echo '
'; + $page->addError(__('Your request failed due to a database error.')); } else { $today = date('Y-m-d'); @@ -328,9 +318,7 @@ } if ($result->rowCount() != 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { $values = $result->fetch(); diff --git a/modules/Activities/report_attendance_byDate.php b/modules/Activities/report_attendance_byDate.php index a068b50319..41785ba9ba 100644 --- a/modules/Activities/report_attendance_byDate.php +++ b/modules/Activities/report_attendance_byDate.php @@ -70,14 +70,10 @@ if (empty($date)) return; if ($date > $today) { - echo "
" ; - echo __('The specified date is in the future: it must be today or earlier.'); - echo "
" ; + $page->addError(__('The specified date is in the future: it must be today or earlier.')); return; } else if (isSchoolOpen($guid, $date, $connection2)==FALSE) { - echo "
" ; - echo __('School is closed on the specified date, and so attendance information cannot be recorded.') ; - echo "
" ; + $page->addError(__('School is closed on the specified date, and so attendance information cannot be recorded.')); return; } diff --git a/modules/Attendance/attendance_take_byCourseClass.php b/modules/Attendance/attendance_take_byCourseClass.php index d2f79205e5..480bbcaf3f 100644 --- a/modules/Attendance/attendance_take_byCourseClass.php +++ b/modules/Attendance/attendance_take_byCourseClass.php @@ -35,9 +35,7 @@ if (isActionAccessible($guid, $connection2, "/modules/Attendance/attendance_take_byCourseClass.php") == false) { //Acess denied - echo "
"; - echo __("You do not have access to this action."); - echo "
"; + $page->addError(__("You do not have access to this action.")); } else { //Proceed! $page->return->addReturns(['error3' => __('Your request failed because the specified date is in the future, or is not a school day.')]); diff --git a/modules/Attendance/attendance_take_byFormGroup.php b/modules/Attendance/attendance_take_byFormGroup.php index 4bf4675c0b..d25d10eb16 100644 --- a/modules/Attendance/attendance_take_byFormGroup.php +++ b/modules/Attendance/attendance_take_byFormGroup.php @@ -38,9 +38,7 @@ } else { $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Proceed! $page->return->addReturns(['error3' => __('Your request failed because the specified date is in the future, or is not a school day.')]); diff --git a/modules/Attendance/attendance_take_byFormGroupProcess.php b/modules/Attendance/attendance_take_byFormGroupProcess.php index e9f693970b..59ec293cdd 100644 --- a/modules/Attendance/attendance_take_byFormGroupProcess.php +++ b/modules/Attendance/attendance_take_byFormGroupProcess.php @@ -41,9 +41,7 @@ } else { $highestAction = getHighestGroupedAction($guid, '/modules/Attendance/attendance_take_byFormGroup.php', $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { //Proceed! //Check if gibbonFormGroupID and currentDate specified diff --git a/modules/Attendance/attendance_take_byPerson_delete.php b/modules/Attendance/attendance_take_byPerson_delete.php index 047f9ca346..5853991110 100644 --- a/modules/Attendance/attendance_take_byPerson_delete.php +++ b/modules/Attendance/attendance_take_byPerson_delete.php @@ -44,9 +44,7 @@ $resultPerson->execute($dataPerson); if ($resultPerson->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $form = DeleteForm::createForm($session->get('absoluteURL').'/modules/'.$session->get('module'). '/attendance_take_byPerson_deleteProcess.php?gibbonAttendanceLogPersonID='.$gibbonAttendanceLogPersonID.'&gibbonPersonID='.$gibbonPersonID.'¤tDate='.$currentDate); echo $form->getOutput(); diff --git a/modules/Attendance/attendance_take_byPerson_edit.php b/modules/Attendance/attendance_take_byPerson_edit.php index 223bb44c6a..9658aed22d 100644 --- a/modules/Attendance/attendance_take_byPerson_edit.php +++ b/modules/Attendance/attendance_take_byPerson_edit.php @@ -57,9 +57,7 @@ $resultPerson->execute($dataPerson); if ($resultPerson->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $values = $resultPerson->fetch(); $currentDate = Format::date($values['date']); diff --git a/modules/Attendance/report_studentHistory.php b/modules/Attendance/report_studentHistory.php index 4f88768e01..ffff2d3e4d 100644 --- a/modules/Attendance/report_studentHistory.php +++ b/modules/Attendance/report_studentHistory.php @@ -41,9 +41,7 @@ //Get action with highest precendence $highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2); if ($highestAction == false) { - echo "
"; - echo __('The highest grouped action cannot be determined.'); - echo '
'; + $page->addError(__('The highest grouped action cannot be determined.')); } else { $viewMode = $_REQUEST['viewMode'] ?? ''; $canTakeAttendanceByPerson = isActionAccessible($guid, $connection2, '/modules/Attendance/attendance_take_byPerson.php'); @@ -79,9 +77,7 @@ $result = $connection2->prepare($sql); $result->execute($data); if ($result->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $row = $result->fetch(); @@ -189,9 +185,7 @@ @$resultChild->execute($dataChild); if ($resultChild->rowCount() < 1) { - echo "
"; - echo __('The selected record does not exist, or you do not have access to it.'); - echo '
'; + $page->addError(__('The selected record does not exist, or you do not have access to it.')); } else { $rowChild = $resultChild->fetch(); @@ -203,9 +197,7 @@ $result = $connection2->prepare($sql); $result->execute($data); if ($result->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $row = $result->fetch(); @@ -234,9 +226,7 @@ $result = $connection2->prepare($sql); $result->execute($data); if ($result->rowCount() != 1) { - echo "
"; - echo __('The specified record does not exist.'); - echo '
'; + $page->addError(__('The specified record does not exist.')); } else { $row = $result->fetch(); diff --git a/passwordReset.php b/passwordReset.php index 0e0de20384..2d667d1caa 100644 --- a/passwordReset.php +++ b/passwordReset.php @@ -83,9 +83,7 @@ $result->execute($data); if ($result->rowCount() != 1) { - echo "
"; - echo __('Your reset request is invalid: you may not proceed.'); - echo '
'; + $page->addError(__('Your reset request is invalid: you may not proceed.')); } else { echo "
"; echo __('Your reset request is valid: you may proceed.');