Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System: refactoring error messages in activities and attendance. #1768

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions index_tt_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@

if (isActionAccessible($guid, $connection2, '/modules/Timetable/tt.php') == false) {
//Acess denied
$output .= "<div class='error'>";
$output .= __('Your request failed because you do not have access to this action.');
$output .= '</div>';
$page->addError(__('Your request failed because you do not have access to this action.'));
} else {
include './modules/Timetable/moduleFunctions.php';
$ttDate = '';
Expand Down
4 changes: 1 addition & 3 deletions modules/Activities/activities_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);
if ($result) {
if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The selected record does not exist, or you do not have access to it.');
echo '</div>';
$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();
Expand Down
4 changes: 1 addition & 3 deletions modules/Activities/activities_manage_enrolment_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
$result->execute($data);

if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$page->addError(__('The specified record does not exist.'));
} else {
$values = $result->fetch();

Expand Down
8 changes: 2 additions & 6 deletions modules/Activities/activities_my_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@

if (isActionAccessible($guid, $connection2, '/modules/Activities/activities_my_full.php') == false) {
//Acess denied
echo "<div class='error'>";
echo __('Your request failed because you do not have access to this action.');
echo '</div>';
$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 "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
//Proceed!
//Get class variable
Expand Down
4 changes: 1 addition & 3 deletions modules/Activities/activities_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
// Get action with highest precedence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
$page->breadcrumbs->add(__('View Activities'));

Expand Down
8 changes: 2 additions & 6 deletions modules/Activities/activities_view_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@

if (isActionAccessible($guid, $connection2, '/modules/Activities/activities_view_full.php') == false) {
//Acess denied
echo "<div class='error'>";
echo __('Your request failed because you do not have access to this action.');
echo '</div>';
$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 "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
//Check access controls
$settingGateway = $container->get(SettingGateway::class);
Expand Down
24 changes: 6 additions & 18 deletions modules/Activities/activities_view_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
$page->breadcrumbs
->add(__('View Activities'), 'activities_view.php')
Expand Down Expand Up @@ -69,9 +67,7 @@
//Check if gibbonActivityID specified
$gibbonActivityID = $_GET['gibbonActivityID'];
if ($gibbonActivityID == 'Y') {
echo "<div class='error'>";
echo __('You have not specified one or more required parameters.');
echo '</div>';
$page->addError(__('You have not specified one or more required parameters.'));
} else {
$mode = $_GET['mode'];

Expand Down Expand Up @@ -136,9 +132,7 @@

if ($mode == 'register') {
if ($continue == false) {
echo "<div class='error'>";
echo __('Your request failed due to a database error.');
echo '</div>';
$page->addError(__('Your request failed due to a database error.'));
} else {
$today = date('Y-m-d');

Expand All @@ -163,9 +157,7 @@
}

if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The selected record does not exist, or you do not have access to it.');
echo '</div>';
$page->addError(__('The selected record does not exist, or you do not have access to it.'));
} else {
$values = $result->fetch();

Expand Down Expand Up @@ -306,9 +298,7 @@
}
} elseif ($mode = 'unregister') {
if ($continue == false) {
echo "<div class='error'>";
echo __('Your request failed due to a database error.');
echo '</div>';
$page->addError(__('Your request failed due to a database error.'));
} else {
$today = date('Y-m-d');

Expand All @@ -330,9 +320,7 @@
}

if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The selected record does not exist, or you do not have access to it.');
echo '</div>';
$page->addError(__('The selected record does not exist, or you do not have access to it.'));
} else {
$values = $result->fetch();

Expand Down
8 changes: 2 additions & 6 deletions modules/Activities/report_attendance_byDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,10 @@
if (empty($date)) return;

if ($date > $today) {
echo "<div class='error'>" ;
echo __('The specified date is in the future: it must be today or earlier.');
echo "</div>" ;
$page->addError(__('The specified date is in the future: it must be today or earlier.'));
return;
} else if (isSchoolOpen($guid, $date, $connection2)==FALSE) {
echo "<div class='error'>" ;
echo __('School is closed on the specified date, and so attendance information cannot be recorded.') ;
echo "</div>" ;
$page->addError(__('School is closed on the specified date, and so attendance information cannot be recorded.'));
return;
}

Expand Down
4 changes: 1 addition & 3 deletions modules/Attendance/attendance_take_byCourseClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@

if (isActionAccessible($guid, $connection2, "/modules/Attendance/attendance_take_byCourseClass.php") == false) {
//Acess denied
echo "<div class='error'>";
echo __("You do not have access to this action.");
echo "</div>";
$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.')]);
Expand Down
4 changes: 1 addition & 3 deletions modules/Attendance/attendance_take_byFormGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
} else {
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$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.')]);
Expand Down
4 changes: 1 addition & 3 deletions modules/Attendance/attendance_take_byFormGroupProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
} else {
$highestAction = getHighestGroupedAction($guid, '/modules/Attendance/attendance_take_byFormGroup.php', $connection2);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
//Proceed!
//Check if gibbonFormGroupID and currentDate specified
Expand Down
4 changes: 1 addition & 3 deletions modules/Attendance/attendance_take_byPerson_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
$resultPerson->execute($dataPerson);

if ($resultPerson->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$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.'&currentDate='.$currentDate);
echo $form->getOutput();
Expand Down
4 changes: 1 addition & 3 deletions modules/Attendance/attendance_take_byPerson_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
$resultPerson->execute($dataPerson);

if ($resultPerson->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$page->addError(__('The specified record does not exist.'));
} else {
$values = $resultPerson->fetch();
$currentDate = Format::date($values['date']);
Expand Down
20 changes: 5 additions & 15 deletions modules/Attendance/report_studentHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
//Get action with highest precendence
$highestAction = getHighestGroupedAction($guid, $_GET['q'], $connection2);
if ($highestAction == false) {
echo "<div class='error'>";
echo __('The highest grouped action cannot be determined.');
echo '</div>';
$page->addError(__('The highest grouped action cannot be determined.'));
} else {
$viewMode = $_REQUEST['viewMode'] ?? '';
$canTakeAttendanceByPerson = isActionAccessible($guid, $connection2, '/modules/Attendance/attendance_take_byPerson.php');
Expand Down Expand Up @@ -79,9 +77,7 @@
$result = $connection2->prepare($sql);
$result->execute($data);
if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$page->addError(__('The specified record does not exist.'));
} else {
$row = $result->fetch();

Expand Down Expand Up @@ -189,9 +185,7 @@
@$resultChild->execute($dataChild);

if ($resultChild->rowCount() < 1) {
echo "<div class='error'>";
echo __('The selected record does not exist, or you do not have access to it.');
echo '</div>';
$page->addError(__('The selected record does not exist, or you do not have access to it.'));
} else {
$rowChild = $resultChild->fetch();

Expand All @@ -203,9 +197,7 @@
$result = $connection2->prepare($sql);
$result->execute($data);
if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$page->addError(__('The specified record does not exist.'));
} else {
$row = $result->fetch();

Expand Down Expand Up @@ -234,9 +226,7 @@
$result = $connection2->prepare($sql);
$result->execute($data);
if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('The specified record does not exist.');
echo '</div>';
$page->addError(__('The specified record does not exist.'));
} else {
$row = $result->fetch();

Expand Down
4 changes: 1 addition & 3 deletions passwordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@
$result->execute($data);

if ($result->rowCount() != 1) {
echo "<div class='error'>";
echo __('Your reset request is invalid: you may not proceed.');
echo '</div>';
$page->addError(__('Your reset request is invalid: you may not proceed.'));
} else {
echo "<div class='success'>";
echo __('Your reset request is valid: you may proceed.');
Expand Down