Skip to content
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
7 changes: 3 additions & 4 deletions CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@
INSERT INTO `gibbonEmailTemplate` (`gibbonEmailTemplateID`, `type`, `templateType`, `moduleName`, `templateName`, `templateSubject`, `templateBody`, `variables`, `timestamp`) VALUES (NULL, 'Core', 'Staff Application Form Confirmation', 'Staff', 'Staff Application Form Confirmation', 'Staff Application Form Confirmation', '<p>Dear {{preferredName}},</p>\r\n<p>Thank you for applying for the position of {{jobTitle}} at {{organisationName}}.</p>\r\n<p>Your application was successfully submitted. Our Human Resources team will review your application and be in touch in due course.</p>\r\n<p>This is an automated message. In the meantime, should you have any questions please contact {{organisationName}} at {{organisationEmail}}. For reference, please quote the following application number(s): {{applicationID}}.</p>', '{\r\n\"email\": [\"safeEmail\"], \r\n\"date\": [\"date\"], \r\n\"applicationID\": [\"randomDigit\"], \r\n\"jobTitle\": [\"jobTitle\"], \r\n\"preferredName\": [\"firstName\"],\r\n\"surname\": [\"lastName\"],\r\n\"organisationEmail\": [\"safeEmail\"],\r\n\"organisationName\": [\"name\"]\r\n}', '2026-02-02 11:30:16');end
INSERT INTO `gibbonEmailTemplate` (`gibbonEmailTemplateID`, `type`, `templateType`, `moduleName`, `templateName`, `templateSubject`, `templateBody`, `variables`, `timestamp`) VALUES (NULL, 'Core', 'Staff Application Form Reference Request', 'Staff', 'Staff Application Form Reference Request', 'Request For Reference', '<p>To whom it may concern,</p>\r\n<p>This email is being sent in relation to the job application of an individual who has nominated you as a referee: {{preferredName}} {{surname}}.</p>\r\n<p>In assessing their application for the post of {{jobTitle}} at our school, we would like to enlist your help in completing the following reference form: {{applicationRefereeLink}}.</p>\r\n<p>Please feel free to contact me, should you have any questions in regard to this matter.</p>\r\n<p>Regards,</p>\r\n<p>{{organisationHRName}}</p>', '{\r\n\"email\": [\"safeEmail\"], \r\n\"date\": [\"date\"], \r\n\"applicationID\": [\"randomDigit\"], \r\n\"applicationRefereeLink\": \"https://gibbonedu.org\", \r\n\"preferredName\": [\"firstName\"],\r\n\"surname\": [\"lastName\"],\r\n\"jobTitle\": [\"jobTitle\"],\r\n\"organisationHRName\": [\"name\"]\r\n}', '2026-02-02 11:30:16');end
UPDATE `gibboni18n` SET `code`='ca_ES' WHERE `code`='ca_CA';end
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 ('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
";
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ v31.0.00
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
Library: added a new Library API Key in Library settings to call the Google Books API
Planner: improved the Deploy Unit page with a drag-drop interface and new tools
Planner: added the option to set a location for non-timetables lessons in Lesson Planner
Reports: added error detection while editing twig templates
Expand Down
10 changes: 8 additions & 2 deletions modules/Library/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ function stopRKey(evt) {
}

$.prototype.loadGoogleBookData = function (settings) {

$(document).on('click', '.gbooks', function () {
var isbn = $("#fieldISBN10").val() ? $("#fieldISBN10").val() : $("#fieldISBN13").val();

if (isbn) {
$.get(("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn), function (data) {
var apiUrl = "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn;

if (settings.apiKey && settings.apiKey !== '') {
apiUrl += "&key=" + settings.apiKey;
}

$.get((apiUrl), function (data) {
var obj = (data.constructor === String) ? jQuery.parseJSON(data) : data;

if (obj['totalItems'] == 0) {
Expand Down
15 changes: 13 additions & 2 deletions modules/Library/library_manage_catalog_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
*/

use Gibbon\Domain\Library\LibraryGateway;
use Gibbon\Http\Url;
use Gibbon\Forms\Form;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\DatabaseFormFactory;
use Gibbon\Forms\Form;
use Gibbon\Http\Url;

//Module includes
require_once __DIR__ . '/moduleFunctions.php';
Expand Down Expand Up @@ -217,15 +218,25 @@
$row->addSubmit();

echo $form->getOutput();

// Get Google Books API Key from settings
$settingGateway = $container->get(SettingGateway::class);
$libraryApi = $settingGateway->getSettingByScope('Library', 'libraryAPIKey', true);
$libraryApiKey = $libraryApi['value'];
}
?>


<script type='text/javascript'>
var libraryApiKey = '<?php echo $libraryApiKey; ?>';

$(document).ready(function(){
document.onkeypress = stopRKey;

$(".gbooks").loadGoogleBookData({
"notFound": "<?php echo __('The specified record cannot be found.'); ?>",
"dataRequired": "<?php echo __('Please enter an ISBN13 or ISBN10 value before trying to get data from Google Books.'); ?>",
"apiKey": libraryApiKey,
});

$('#gibbonLibraryTypeID').change(function(){
Expand Down
6 changes: 6 additions & 0 deletions modules/School Admin/librarySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
$row->addLabel($setting['name'], __($setting['nameDisplay']))->description(__($setting['description']));
$row->addTextField($setting['name'])->setValue($setting['value'])->maxLength(255);


$setting = $settingGateway->getSettingByScope('Library', 'libraryAPIKey', true);
$row = $form->addRow();
$row->addLabel($setting['name'], __($setting['nameDisplay']))->description(__($setting['description']));
$row->addTextField($setting['name'])->setValue($setting['value'])->maxLength(255);

$row = $form->addRow();
$row->addFooter();
$row->addSubmit();
Expand Down
77 changes: 27 additions & 50 deletions modules/School Admin/librarySettingsProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Gibbon\Data\Validator;
use Gibbon\Domain\System\SettingGateway;

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

Expand All @@ -30,56 +31,32 @@
$URL .= '&return=error0';
header("Location: {$URL}");
} else {
//Proceed!
$defaultLoanLength = $_POST['defaultLoanLength'] ?? '';
$browseBGColor = $_POST['browseBGColor'] ?? '';
$browseBGImage = $_POST['browseBGImage'] ?? '';

// Filter valid colour values
$browseBGColor = preg_replace('/[^a-fA-F0-9\#]/', '', mb_substr($browseBGColor, 0, 7));

//Validate Inputs
if ($defaultLoanLength == '') {
$URL .= '&return=error3';
header("Location: {$URL}");
} else {
//Write to database
$fail = false;

try {
$data = array('value' => $defaultLoanLength);
$sql = "UPDATE gibbonSetting SET value=:value WHERE scope='Library' AND name='defaultLoanLength'";
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$fail = true;
}

try {
$data = array('value' => $browseBGColor);
$sql = "UPDATE gibbonSetting SET value=:value WHERE scope='Library' AND name='browseBGColor'";
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$fail = true;
}

try {
$data = array('value' => $browseBGImage);
$sql = "UPDATE gibbonSetting SET value=:value WHERE scope='Library' AND name='browseBGImage'";
$result = $connection2->prepare($sql);
$result->execute($data);
} catch (PDOException $e) {
$fail = true;
}

if ($fail == true) {
$URL .= '&return=error2';
header("Location: {$URL}");
} else {
getSystemSettings($guid, $connection2);
$URL .= '&return=success0';
header("Location: {$URL}");
// Proceed!
$partialFail = false;

$settingGateway = $container->get(SettingGateway::class);
$settingsToUpdate = [
'Library' => [
'defaultLoanLength',
'browseBGColor',
'browseBGImage',
'libraryAPIKey',
]
];

foreach ($settingsToUpdate as $scope => $settings) {
foreach ($settings as $name) {
$value = $_POST[$name] ?? '';

if ($name === 'browseBGColor') {
$value = preg_replace('/[^a-fA-F0-9\#]/', '', mb_substr($value, 0, 7));
}

$updated = $settingGateway->updateSettingByScope($scope, $name, $value);
$partialFail &= !$updated;
}
}

$URL .= $partialFail ? '&return=error2' : '&return=success0';
header("Location: {$URL}");
}
Loading