mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-77312 files: exclude drafts when determining license usage.
This commit is contained in:
parent
4e632b7251
commit
c5c9185801
1 changed files with 3 additions and 2 deletions
|
@ -176,8 +176,9 @@ class license_manager {
|
||||||
|
|
||||||
if (!empty($licensetodelete)) {
|
if (!empty($licensetodelete)) {
|
||||||
if ($licensetodelete->custom == self::CUSTOM_LICENSE) {
|
if ($licensetodelete->custom == self::CUSTOM_LICENSE) {
|
||||||
// Check that the license is not in use by any files, if so it cannot be deleted.
|
// Check that the license is not in use by any non-draft files, if so it cannot be deleted.
|
||||||
$countfilesusinglicense = $DB->count_records('files', ['license' => $licenseshortname]);
|
$countfilesselect = 'license = :license AND NOT (component = \'user\' AND filearea = \'draft\')';
|
||||||
|
$countfilesusinglicense = $DB->count_records_select('files', $countfilesselect, ['license' => $licenseshortname]);
|
||||||
if ($countfilesusinglicense > 0) {
|
if ($countfilesusinglicense > 0) {
|
||||||
throw new moodle_exception('cannotdeletelicenseinuse', 'license');
|
throw new moodle_exception('cannotdeletelicenseinuse', 'license');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue