MDL-66911 files: Update $CFG->licenses when adding/deleting licenses
authorJun Pataleta <jun@moodle.com>
Thu, 28 May 2020 08:15:15 +0000 (16:15 +0800)
committerJun Pataleta <jun@moodle.com>
Thu, 28 May 2020 08:15:15 +0000 (16:15 +0800)
* When creating custom licenses, the list of active licenses
  ($CFG->licenses) also needs to be updated. Same when a custom license
  is being deleted.

lib/licenselib.php

index abf4cb6..3010ef9 100644 (file)
@@ -127,6 +127,8 @@ class license_manager {
 
         $DB->insert_record('license', $license);
         self::reset_license_cache();
+        // Update the config setting of active licenses.
+        self::set_active_licenses();
     }
 
     /**
@@ -203,6 +205,9 @@ class license_manager {
                     }
                 }
 
+                // Update the config setting of active licenses as well.
+                self::set_active_licenses();
+
             } else {
                 throw new moodle_exception('cannotdeletecore', 'license');
             }