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
37 changes: 37 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Functions for the QR code block.
*
* @package block_qrcode
* @copyright 2026 L. Herfeldt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Clears cached QR code images when relevant global settings are changed.
*
* This is used after changing the custom wwwroot, because existing cached
* QR image files may still contain the old URL.
*/
function block_qrcode_clear_cache(): void {
$cachedir = make_localcache_directory('block_qrcode', false);

if ($cachedir !== false && is_dir($cachedir)) {
remove_dir($cachedir, true);
}
}
11 changes: 8 additions & 3 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@
*/

defined('MOODLE_INTERNAL') || die;
require_once($CFG->dirroot . '/blocks/qrcode/lib.php');

if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext(
$setting = new admin_setting_configtext(
'block_qrcode/custom_wwwroot',
new lang_string('customwwwroot', 'block_qrcode'),
new lang_string('customwwwroot_desc', 'block_qrcode', $CFG->wwwroot),
'',
PARAM_URL,
));
PARAM_URL
);

$setting->set_updatedcallback('block_qrcode_clear_cache');

$settings->add($setting);

$settings->add(new admin_setting_configcheckbox(
'block_qrcode/use_logo',
Expand Down
Loading