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
18 changes: 18 additions & 0 deletions backup/moodle2/restore_hvp_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,24 @@ protected function process_hvp_library($data) {

$libraryid = self::get_library_id($data);
if (!$libraryid) {
// If this library is not installed, ensure that the user has
// permission to install it before proceeding.
$params = ['machine_name' => $data->machine_name];
if (!$DB->record_exists('hvp_libraries', $params)) {
$systemctx = \core\context\system::instance();
$caninstall = has_capability('mod/hvp:updatelibraries', $systemctx);

$librarycache = $DB->get_record('hvp_libraries_hub_cache', $params, 'id, is_recommended');
if ($librarycache && $librarycache->is_recommended) {
$coursectx = \core\context\course::instance($this->get_courseid());
$caninstall = $caninstall || has_capability('mod/hvp:installrecommendedh5plibraries', $coursectx);
}

if (!$caninstall) {
throw new \core\exception\moodle_exception('restoreinstalldenied', 'hvp', '', $data->title);
}
}

// There is no updating of libraries. If an older patch version exists
// on the site that one will be used instead of the new one in the backup.
// This is due to the default behavior when files are restored in Moodle.
Expand Down
3 changes: 3 additions & 0 deletions lang/en/hvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,6 @@
// Export libraries.
$string['exportlibraries'] = 'Export libraries';
$string['exportlibrarieserror'] = 'An error occured while export the libraries.';

// Restore H5P library.
$string['restoreinstalldenied'] = 'You do not have permission to install missing content type \'{$a}\'. Please contact your site administrator.';
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024120900;
$plugin->version = 2024120901;
$plugin->requires = 2022112800; // 4.1.0
$plugin->cron = 0;
$plugin->component = 'mod_hvp';
Expand Down
Loading