Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,6 @@
INSERT INTO `gibbonSetting` (`scope`, `name`, `nameDisplay`, `description`, `value`) VALUES ('System', 'timeFormatPHP', 'Time Format', 'How should the time of day be displayed?', 'H:i');end
INSERT INTO `gibbonSetting` (`scope`, `name`, `nameDisplay`, `description`, `value`) VALUES ('Attendance', 'showIncompleteAttendance', 'Show Incomplete Attendance', 'Show class periods where attendance has not been taken (Not Available).', 'N');end
INSERT INTO `gibbonSetting` (`scope`, `name`, `nameDisplay`, `description`, `value`) VALUES ('Library', 'libraryAPIKey', 'Library API Key', 'Google Books API Key from Google Cloud Console.', '');end
ALTER TABLE `gibbonAttendanceLogPerson` ADD `foreignTable` VARCHAR(60) NULL AFTER `gibbonTTDayRowClassID`;end
ALTER TABLE `gibbonAttendanceLogPerson` ADD `foreignTableID` INT(14) UNSIGNED ZEROFILL NULL AFTER `foreignTable`;end
";
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ v31.0.00
Admissions: added a warning to Accept Application when milestones have not been completed
Attendance: student attendance history now ordered by timetable period
Attendance: fixed the Consecutive Absences check to only count the final status for each day
Attendance: added a foreign table field to attendance logs for recording target of future absences
Calendar: switched default sorting of Manage Events to newest first
Calendar: remove future absence when deleting participant or editing the date
Formal Assessment: added the feature for teachers to view unpublished internal assessments
Library: updated automatic shelf lists so that lists are queried dynamically in Browse Library
Library: added the option to edit the category and sub-category for an automatic shelf
Expand All @@ -58,6 +60,7 @@ v31.0.00
Staff: added the feature to send an automated email for staff application confirmation
Students: added an indicator at the top of view student profile to indicate attendance status and current location of the student
System Admin: added a validation to check for error in email twig templates
System Admin: added new Marks By Term importer for Markbook Column
Timetable: added class and location details to non-timetabled lessons in the Timetable
Tracking: fixed the post variable validation
User Admin: linked user names to Student and Staff profiles in Manage Users
Expand Down
4 changes: 4 additions & 0 deletions modules/Attendance/attendance_future_byPerson.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
$dateEnd = $_GET['dateEnd'] ?? '';
$timeStart = $_GET['timeStart'] ?? '';
$timeEnd = $_GET['timeEnd'] ?? '';
$foreignTable = $_GET['foreignTable'] ?? '';
$foreignTableID = $_GET['foreignTableID'] ?? '';

$urlParams = compact('target', 'gibbonActivityID', 'gibbonGroupID', 'absenceType', 'date', 'timeStart', 'timeEnd');

Expand Down Expand Up @@ -381,6 +383,8 @@
$form->addHiddenValue('timeStart', $timeStart);
$form->addHiddenValue('timeEnd', $timeEnd);
$form->addHiddenValue('gibbonPersonIDList', implode(",", $gibbonPersonIDList));
$form->addHiddenValue('foreignTable', $foreignTable);
$form->addHiddenValue('foreignTableID', $foreignTableID);

$form->addRow()->addHeading('Set Future Attendance', __('Set Future Attendance'));

Expand Down
15 changes: 13 additions & 2 deletions modules/Attendance/attendance_future_byPersonProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@
$comment = $_POST['comment'] ?? '';
$courseList = $_POST['courses'] ?? '';

if (in_array($urlParams['target'], ['Activity', 'Messenger'])) {
$foreignTable = $urlParams['target'];
$foreignTableID = $urlParams['target'] === 'Activity' ? $urlParams['gibbonActivityID'] : $urlParams['gibbonGroupID'];
} else {
$foreignTable = $_POST['foreignTable'] ?? '';
$foreignTableID = $_POST['foreignTableID'] ?? '';
}

$attendanceCode = $attendance->getAttendanceCodeByType($type);
$direction = $attendanceCode['direction'];

Expand Down Expand Up @@ -138,6 +146,8 @@
'comment' => $comment,
'gibbonPersonIDTaker' => $session->get('gibbonPersonID'),
'date' => $date,
'foreignTable' => $foreignTable,
'foreignTableID' => $foreignTableID,
'timestampTaken' => date('Y-m-d H:i:s'),
];

Expand Down Expand Up @@ -166,8 +176,10 @@
'timestampTaken' => date('Y-m-d H:i:s'),
'gibbonCourseClassID' => $gibbonCourseClassID,
'gibbonTTDayRowClassID' => $gibbonTTDayRowClassID,
'foreignTable' => $foreignTable,
'foreignTableID' => $foreignTableID
];

$gibbonAttendanceLogPersonID = $attendanceLogGateway->insert($data);
if (empty($gibbonAttendanceLogPersonID)) $partialFail = true;
}
Expand All @@ -189,5 +201,4 @@
header("Location: {$URL}");
}
}

}
9 changes: 5 additions & 4 deletions modules/Calendar/calendar_event_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Services\Format;
use Gibbon\Forms\Prefab\DeleteForm;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Forms\Prefab\DeleteForm;

if (isActionAccessible($guid, $connection2, '/modules/Calendar/calendar_event_delete.php') == false) {
// Access denied
Expand All @@ -32,10 +31,12 @@
$page->addError(__('You have not specified one or more required parameters.'));
return;
}

$calendarEventGateway = $container->get(CalendarEventGateway::class);

$values = $container->get(CalendarEventGateway::class)->getByID($gibbonCalendarEventID);
$event = $calendarEventGateway->getByID($gibbonCalendarEventID);

if (empty($values)) {
if (empty($event)) {
$page->addError(__('The specified record cannot be found.'));
return;
}
Expand Down
14 changes: 10 additions & 4 deletions modules/Calendar/calendar_event_deleteProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/

use Gibbon\Data\Validator;
use Gibbon\Support\Facades\Access;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Domain\Calendar\CalendarEventPersonGateway;
use Gibbon\Support\Facades\Access;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;

require_once '../../gibbon.php';

Expand All @@ -42,6 +43,7 @@
// Proceed!
$calendarEventGateway = $container->get(CalendarEventGateway::class);
$calendarEventPersonGateway = $container->get(CalendarEventPersonGateway::class);
$attendanceLogPersonGateway = $container->get(AttendanceLogPersonGateway::class);

// Validate the database relationships exist
$event = $calendarEventGateway->getEventDetailsByID($gibbonCalendarEventID, $session->get('gibbonPersonID'));
Expand All @@ -54,13 +56,17 @@
if ($event['editor'] != 'Y' && !Access::allows('Calendar', 'calendar_event_edit', 'Manage Events_all')) {
header("Location: {$URL}&return=error0");
exit;
}
}

$deleted = $calendarEventGateway->delete($gibbonCalendarEventID);
$eventDeleted = $calendarEventGateway->delete($gibbonCalendarEventID);

// Remove all participants linked to this event
$calendarEventPersonGateway->deleteWhere(['gibbonCalendarEventID' => $gibbonCalendarEventID]);

$URL .= !$deleted
// Remove future absences for participants linked to this event
$attendanceLogPersonGateway->deleteWhere(['foreignTable' => 'gibbonCalendarEvent', 'foreignTableID' => $gibbonCalendarEventID]);

$URL .= !$eventDeleted
? '&return=error2'
: '&return=success0';

Expand Down
4 changes: 4 additions & 0 deletions modules/Calendar/calendar_event_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
if (empty($gibbonCalendarEventID) && isset($_GET['editID'])) {
$page->return->setEditLink($session->get('absoluteURL').'/index.php?q=/modules/Calendar/calendar_event_edit.php&gibbonCalendarEventID='.$_GET['editID']);
}

$page->return->addReturns([
'warning9' => __('Your request was completed successfully. Previous future absences tied to this event were removed due to the date/time change. Please set future absences again.'),
]);

$calendarEventGateway = $container->get(CalendarEventGateway::class);
$calendarEventPersonGateway = $container->get(CalendarEventPersonGateway::class);
Expand Down
42 changes: 29 additions & 13 deletions modules/Calendar/calendar_event_editProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

use Gibbon\Data\Validator;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Domain\Calendar\CalendarEventPersonGateway;
use Gibbon\Support\Facades\Access;
Expand All @@ -40,6 +41,7 @@

$calendarEventGateway = $container->get(CalendarEventGateway::class);
$calendarEventPersonGateway = $container->get(CalendarEventPersonGateway::class);
$attendanceLogPersonGateway = $container->get(AttendanceLogPersonGateway::class);

// Get event details
$event = $calendarEventGateway->getEventDetailsByID($gibbonCalendarEventID, $session->get('gibbonPersonID'));
Expand Down Expand Up @@ -92,23 +94,26 @@
header("Location: {$URL}");
}

// Check if the date or time has changed compared to the existing event
$dateTimeChanged = $data['dateStart'] !== $event['dateStart'] || $data['dateEnd'] !== $event['dateEnd'] || $data['timeStart'] !== $event['timeStart'] || $data['timeEnd'] !== $event['timeEnd'];

// Update the record
if (!$calendarEventGateway->update($gibbonCalendarEventID, $data)) {
$URL .= '&return=error2';
header("Location: {$URL}");
}

$organiser = $calendarEventPersonGateway->selectBy(['gibbonCalendarEventID' => $gibbonCalendarEventID, 'role' => 'Organiser', 'gibbonPersonID' => $gibbonPersonIDOrganiser])->fetch();
$organiser = $calendarEventPersonGateway->selectBy(['gibbonCalendarEventID' => $gibbonCalendarEventID, 'role' => 'Organiser', 'gibbonPersonID' => $gibbonPersonIDOrganiser])->fetch();

if (empty($organiser)) {
$organiserData = [
'gibbonCalendarEventID' => $gibbonCalendarEventID,
'gibbonPersonID' => $gibbonPersonIDOrganiser,
'role' => 'Organiser',
'gibbonPersonIDModified' => $session->get('gibbonPersonID') ?? '',
'timestampModified' => date('Y-m-d H:i:s'),
'timestampCreated' => date('Y-m-d H:i:s'),
'gibbonPersonIDCreated' => $session->get('gibbonPersonID') ?? '',
'gibbonCalendarEventID' => $gibbonCalendarEventID,
'gibbonPersonID' => $gibbonPersonIDOrganiser,
'role' => 'Organiser',
'gibbonPersonIDModified' => $session->get('gibbonPersonID') ?? '',
'timestampModified' => date('Y-m-d H:i:s'),
'timestampCreated' => date('Y-m-d H:i:s'),
'gibbonPersonIDCreated' => $session->get('gibbonPersonID') ?? '',
];

$inserted = $calendarEventPersonGateway->insertAndUpdate($organiserData, $organiserData);
Expand All @@ -135,9 +140,20 @@
$inserted = $calendarEventPersonGateway->insertAndUpdate($personData, $personData);
$partialFail &= !$inserted;
}

$URL .= $partialFail
? "&return=warning1"
: "&return=success0&editID=$gibbonCalendarEventID";
header("Location: {$URL}");

// If event date or time changed, remove future absences for all student participants using the OLD dates
$futureAbsencesRemoved = false;
if ($dateTimeChanged) {
$futureAbsencesRemoved = $attendanceLogPersonGateway->deleteWhere(['foreignTable' => 'gibbonCalendarEvent', 'foreignTableID' => $gibbonCalendarEventID]);
}

if ($futureAbsencesRemoved) {
$URL .= "&return=warning9&editID=$gibbonCalendarEventID";
} elseif ($partialFail) {
$URL .= "&return=warning1";
} else {
$URL .= "&return=success0&editID=$gibbonCalendarEventID";
}

header("Location: {$URL}");
}
2 changes: 2 additions & 0 deletions modules/Calendar/calendar_event_participants.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
'timeStart' => $event['timeStart'],
'timeEnd' => $event['timeEnd'],
'gibbonPersonIDList' => implode(',', $futureAbsenceStudents),
'foreignTable' => 'gibbonCalendarEvent',
'foreignTableID' => $gibbonCalendarEventID
])
->setIcon('user-plus')
->setAttribute('target', '_blank')
Expand Down
24 changes: 14 additions & 10 deletions modules/Calendar/calendar_event_participantsProcessBulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Services\Format;
use Gibbon\Support\Facades\Access;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Domain\Calendar\CalendarEventPersonGateway;
use Gibbon\Support\Facades\Access;

include '../../gibbon.php';

$action = $_POST['action'] ?? '';
$gibbonCalendarEventID = $_POST['gibbonCalendarEventID'] ?? '';
$action = $_POST['action'] ?? '';
$attendees = $_POST['gibbonCalendarEventPersonID'] ?? [];

$URL = $session->get('absoluteURL')."/index.php?q=/modules/Calendar/calendar_event_participants.php&gibbonCalendarEventID=$gibbonCalendarEventID";

Expand All @@ -36,11 +37,9 @@
header("Location: {$URL}");
} else {
// Proceed!

$calendarEventGateway = $container->get(CalendarEventGateway::class);
$calendarEventPersonGateway = $container->get(CalendarEventPersonGateway::class);

$attendees = $_POST['gibbonCalendarEventPersonID'] ?? [];
$attendanceLogPersonGateway = $container->get(AttendanceLogPersonGateway::class);

if (empty($action) || ($action != 'Delete')) {
$URL .= '&return=error1';
Expand All @@ -53,7 +52,7 @@
$URL .= '&return=error3';
header("Location: {$URL}");
exit;
}
}

// Get event details
$event = $calendarEventGateway->getEventDetailsByID($gibbonCalendarEventID, $session->get('gibbonPersonID'));
Expand All @@ -69,7 +68,7 @@
}

$partialFail = false;

foreach ($attendees AS $gibbonCalendarEventPersonID) {
$eventAttendee = $calendarEventPersonGateway->getByID($gibbonCalendarEventPersonID);

Expand All @@ -79,12 +78,17 @@
}

if ($action == 'Delete') {
$calendarEventPersonGateway->delete($gibbonCalendarEventPersonID);
$deleted = $calendarEventPersonGateway->delete($gibbonCalendarEventPersonID);

if ($deleted && !empty($eventAttendee['gibbonPersonID'])) {
// Remove future absences for all deleted participants
$attendanceLogPersonGateway->deleteWhere(['foreignTable' => 'gibbonCalendarEvent', 'foreignTableID' => $gibbonCalendarEventID, 'gibbonPersonID' => $eventAttendee['gibbonPersonID']]);
}
}
}

$URL .= $partialFail
? '&return=warning1'
: '&return=success0';
header("Location: {$URL}");
}
}
20 changes: 14 additions & 6 deletions modules/Calendar/calendar_event_participants_deleteProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
*/

use Gibbon\Data\Validator;
use Gibbon\Domain\Calendar\CalendarEventPersonGateway;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Support\Facades\Access;
use Gibbon\Domain\Calendar\CalendarEventGateway;
use Gibbon\Domain\Calendar\CalendarEventPersonGateway;
use Gibbon\Domain\Attendance\AttendanceLogPersonGateway;

require_once '../../gibbon.php';

$_POST = $container->get(Validator::class)->sanitize($_POST);

$gibbonCalendarEventPersonID = $_POST['gibbonCalendarEventPersonID'] ?? '';
$gibbonCalendarEventID = $_POST['gibbonCalendarEventID'] ?? '';
$gibbonPersonID = $_POST['gibbonPersonID'] ?? '';

$URL = $session->get('absoluteURL').'/index.php?q=/modules/Calendar/calendar_event_participants.php&gibbonCalendarEventID='.$gibbonCalendarEventID;

Expand All @@ -43,7 +45,8 @@
// Proceed!
$calendarEventGateway = $container->get(CalendarEventGateway::class);
$calendarEventPersonGateway = $container->get(CalendarEventPersonGateway::class);

$attendanceLogPersonGateway = $container->get(AttendanceLogPersonGateway::class);

// Get event details
$event = $calendarEventGateway->getEventDetailsByID($gibbonCalendarEventID, $session->get('gibbonPersonID'));
if (empty($event)) {
Expand All @@ -57,16 +60,21 @@
exit;
}

// Validate the database relationships exist
// Validate the participant record exists
if (!$calendarEventPersonGateway->exists($gibbonCalendarEventPersonID)) {
$URL .= '&return=error2';
header("Location: {$URL}");
exit;
}

$deleted = $calendarEventPersonGateway->delete($gibbonCalendarEventPersonID);
$deletedParticipant = $calendarEventPersonGateway->delete($gibbonCalendarEventPersonID);

// Remove future absences for this participant linked to the event
if ($deletedParticipant && !empty($gibbonPersonID)) {
$attendanceLogPersonGateway->deleteWhere(['foreignTable' => 'gibbonCalendarEvent', 'foreignTableID' => $gibbonCalendarEventID, 'gibbonPersonID' => $gibbonPersonID]);
}

$URL .= !$deleted
$URL .= !$deletedParticipant
? '&return=error2'
: '&return=success0';

Expand Down
Loading
Loading