MDL-69166 enrol_fee: Prevent adding instance if no currency is supported
authorShamim Rezaie <shamim@moodle.com>
Wed, 30 Sep 2020 01:48:58 +0000 (11:48 +1000)
committerShamim Rezaie <shamim@moodle.com>
Tue, 27 Oct 2020 04:44:59 +0000 (15:44 +1100)
enrol/fee/classes/plugin.php

index 1844de0..a089e98 100644 (file)
@@ -105,6 +105,10 @@ class enrol_fee_plugin extends enrol_plugin {
     public function can_add_instance($courseid) {
         $context = context_course::instance($courseid, MUST_EXIST);
 
+        if (empty(\core_payment\helper::get_supported_currencies())) {
+            return false;
+        }
+
         if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/fee:config', $context)) {
             return false;
         }