Skip to content

Commit

Permalink
System: refactoring Error Messages in various modules (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixOlesen authored Dec 15, 2023
1 parent c351187 commit dd1c19c
Show file tree
Hide file tree
Showing 79 changed files with 174 additions and 518 deletions.
4 changes: 1 addition & 3 deletions modules/Behaviour/behaviour_manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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(__('Manage Behaviour Records'));

Expand Down
4 changes: 1 addition & 3 deletions modules/Behaviour/behaviour_manage_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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(__('Manage Behaviour Records'), 'behaviour_manage.php')
Expand Down
8 changes: 2 additions & 6 deletions modules/Behaviour/behaviour_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,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 {
//Proceed!
//Check if gibbonBehaviourID specified
Expand All @@ -50,9 +48,7 @@
$result->execute($data);

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')."/behaviour_manage_deleteProcess.php?gibbonBehaviourID=$gibbonBehaviourID&gibbonPersonID=".$_GET['gibbonPersonID'].'&gibbonFormGroupID='.$_GET['gibbonFormGroupID'].'&gibbonYearGroupID='.$_GET['gibbonYearGroupID'].'&type='.$_GET['type']);
echo $form->getOutput();
Expand Down
8 changes: 2 additions & 6 deletions modules/Behaviour/behaviour_manage_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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 {
//Proceed!
$page->breadcrumbs
Expand Down Expand Up @@ -76,9 +74,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 {
//Let's go!
$values = $result->fetch();
Expand Down
4 changes: 1 addition & 3 deletions modules/Behaviour/behaviour_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,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 Behaviour Records'));

Expand Down
8 changes: 2 additions & 6 deletions modules/Behaviour/behaviour_view_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,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 {
$gibbonPersonID = $_GET['gibbonPersonID'] ?? '';

Expand All @@ -69,9 +67,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 {
$row = $result->fetch();

Expand Down
12 changes: 3 additions & 9 deletions modules/Data Updater/data_family.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,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 {
//Proceed!
$page->breadcrumbs->add(__('Update Family Data'));
Expand Down Expand Up @@ -116,9 +114,7 @@
}

if ($resultCheck->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 {
//Check if there is already a pending form for this user
$existing = false;
Expand All @@ -130,9 +126,7 @@
$result->execute($data);

if ($result->rowCount() > 1) {
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.'));
} elseif ($result->rowCount() == 1) {
$existing = true;
echo "<div class='warning'>";
Expand Down
4 changes: 1 addition & 3 deletions modules/Data Updater/data_family_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);

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 {
//Let's go!

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

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 {
$data = array('gibbonFamilyUpdateID' => $gibbonFamilyUpdateID);
$sql = 'SELECT gibbonFamilyUpdate.* FROM gibbonFamilyUpdate JOIN gibbonFamily ON (gibbonFamilyUpdate.gibbonFamilyID=gibbonFamily.gibbonFamilyID) WHERE gibbonFamilyUpdateID=:gibbonFamilyUpdateID';
Expand Down
12 changes: 3 additions & 9 deletions modules/Data Updater/data_finance.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,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 {
//Proceed!
$page->breadcrumbs->add(__('Update Finance Data'));
Expand Down Expand Up @@ -149,9 +147,7 @@
}

if ($checkCount < 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 {
//Check if there is already a pending form for this user
$existing = false;
Expand All @@ -163,9 +159,7 @@
$result->execute($data);

if ($result->rowCount() > 1) {
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.'));
} elseif ($result->rowCount() == 1) {
$existing = true;
echo "<div class='warning'>";
Expand Down
4 changes: 1 addition & 3 deletions modules/Data Updater/data_finance_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);

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 {
//Let's go!

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

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 {
$data = array('gibbonFinanceInvoiceeUpdateID' => $gibbonFinanceInvoiceeUpdateID);
$sql = "SELECT gibbonFinanceInvoiceeUpdate.* FROM gibbonFinanceInvoiceeUpdate JOIN gibbonFinanceInvoicee ON (gibbonFinanceInvoiceeUpdate.gibbonFinanceInvoiceeID=gibbonFinanceInvoicee.gibbonFinanceInvoiceeID) WHERE gibbonFinanceInvoiceeUpdateID=:gibbonFinanceInvoiceeUpdateID";
Expand Down
12 changes: 3 additions & 9 deletions modules/Data Updater/data_medical.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,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 {
//Proceed!
$page->breadcrumbs->add(__('Update Medical Data'));
Expand Down Expand Up @@ -152,9 +150,7 @@
}
}
if ($checkCount < 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 {
//Get user's data

Expand All @@ -175,9 +171,7 @@
$resultForm = $connection2->prepare($sqlForm);
$resultForm->execute($dataForm);
if ($resultForm->rowCount() > 1) {
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.'));
} elseif ($resultForm->rowCount() == 1) {
$existing = true;
echo "<div class='warning'>";
Expand Down
4 changes: 1 addition & 3 deletions modules/Data Updater/data_medical_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);

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')."/data_medical_manage_deleteProcess.php?gibbonPersonMedicalUpdateID=$gibbonPersonMedicalUpdateID");
echo $form->getOutput();
Expand Down
4 changes: 1 addition & 3 deletions modules/Data Updater/data_medical_manage_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,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 {
$data = array('gibbonPersonMedicalUpdateID' => $gibbonPersonMedicalUpdateID);
$sql = "SELECT gibbonPersonMedicalUpdate.* FROM gibbonPersonMedicalUpdate
Expand Down
12 changes: 3 additions & 9 deletions modules/Data Updater/data_personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,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 {
//Proceed!
$page->breadcrumbs->add(__('Update Personal Data'));
Expand Down Expand Up @@ -176,9 +174,7 @@
}

if ($checkCount < 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 {
//Get categories

Expand Down Expand Up @@ -252,9 +248,7 @@
$result->execute($data);

if ($result->rowCount() > 1) {
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.'));
} elseif ($result->rowCount() == 1) {
$existing = true;
echo "<div class='warning'>";
Expand Down
4 changes: 1 addition & 3 deletions modules/Data Updater/data_personal_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);

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 {
//Let's go!

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

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 {
$data = array('gibbonPersonUpdateID' => $gibbonPersonUpdateID);
$sql = "SELECT gibbonPersonUpdate.* FROM gibbonPersonUpdate JOIN gibbonPerson ON (gibbonPersonUpdate.gibbonPersonID=gibbonPerson.gibbonPersonID) WHERE gibbonPersonUpdateID=:gibbonPersonUpdateID";
Expand Down
4 changes: 1 addition & 3 deletions modules/Departments/department.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,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 {
$row = $result->fetch();

Expand Down
4 changes: 1 addition & 3 deletions modules/Departments/department_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,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 {
$row = $result->fetch();

Expand Down
8 changes: 2 additions & 6 deletions modules/Departments/department_course_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
$result->execute($data);

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 All @@ -64,9 +62,7 @@
->add(__('Edit Course'));

if ($role != 'Coordinator' and $role != 'Assistant Coordinator' and $role != 'Teacher (Curriculum)') {
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 = Form::create('courseEdit', $session->get('absoluteURL').'/modules/'.$session->get('module').'/department_course_editProcess.php?gibbonDepartmentID='.$gibbonDepartmentID.'&gibbonCourseID='.$gibbonCourseID);
Expand Down
8 changes: 2 additions & 6 deletions modules/Departments/department_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
$result->execute($data);

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 All @@ -58,9 +56,7 @@
$role = getRole($session->get('gibbonPersonID'), $gibbonDepartmentID, $connection2);

if ($role != 'Coordinator' and $role != 'Assistant Coordinator' and $role != 'Teacher (Curriculum)' and $role != 'Director' and $role != 'Manager') {
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 = Form::create('action', $session->get('absoluteURL').'/modules/'.$session->get('module').'/department_editProcess.php?gibbonDepartmentID='.$gibbonDepartmentID);
Expand Down
4 changes: 1 addition & 3 deletions modules/Finance/budgets_manage_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
$result->execute($data);

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')."/budgets_manage_deleteProcess.php?gibbonFinanceBudgetID=$gibbonFinanceBudgetID");
echo $form->getOutput();
Expand Down
Loading

0 comments on commit dd1c19c

Please sign in to comment.