diff --git a/admin/tool/lp/lib.php b/admin/tool/lp/lib.php index 04a5dfe9211..1539e32617c 100644 --- a/admin/tool/lp/lib.php +++ b/admin/tool/lp/lib.php @@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die(); * @param context $coursecontext The context of the course */ function tool_lp_extend_navigation_course($navigation, $course, $coursecontext) { - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return; } @@ -61,7 +61,7 @@ function tool_lp_extend_navigation_course($navigation, $course, $coursecontext) * @param context_course $coursecontext The context of the course */ function tool_lp_extend_navigation_user($navigation, $user, $usercontext, $course, $coursecontext) { - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return; } @@ -88,7 +88,7 @@ function tool_lp_extend_navigation_user($navigation, $user, $usercontext, $cours * @return bool */ function tool_lp_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return false; } else if (!\core_competency\plan::can_read_user($user->id)) { return false; @@ -109,7 +109,7 @@ function tool_lp_myprofile_navigation(core_user\output\myprofile\tree $tree, $us * @param context $coursecategorycontext The context of the course category */ function tool_lp_extend_navigation_category_settings($navigation, $coursecategorycontext) { - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return false; } @@ -160,7 +160,7 @@ function tool_lp_extend_navigation_category_settings($navigation, $coursecategor function tool_lp_coursemodule_standard_elements($formwrapper, $mform) { global $CFG, $COURSE; - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return; } else if (!has_capability('moodle/competency:coursecompetencymanage', $formwrapper->get_context())) { return; @@ -195,7 +195,7 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) { * @param stdClass $course The course. */ function tool_lp_coursemodule_edit_post_actions($data, $course) { - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return $data; } diff --git a/admin/tool/lp/settings.php b/admin/tool/lp/settings.php index 80758aedc94..2481791b9d7 100644 --- a/admin/tool/lp/settings.php +++ b/admin/tool/lp/settings.php @@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die(); $parentname = 'competencies'; // If the plugin is enabled we add the pages. -if (\core_competency\api::is_enabled()) { +if (get_config('core_competency', 'enabled')) { // Manage competency frameworks page. $temp = new admin_externalpage( diff --git a/admin/tool/lpmigrate/settings.php b/admin/tool/lpmigrate/settings.php index 26b362295d6..b1ecf3b9af6 100644 --- a/admin/tool/lpmigrate/settings.php +++ b/admin/tool/lpmigrate/settings.php @@ -23,7 +23,7 @@ */ defined('MOODLE_INTERNAL') || die(); -if (\core_competency\api::is_enabled()) { +if (get_config('core_competency', 'enabled')) { $parentname = 'competencies'; diff --git a/blocks/lp/block_lp.php b/blocks/lp/block_lp.php index 84b02a0d655..60a9aea47fc 100644 --- a/blocks/lp/block_lp.php +++ b/blocks/lp/block_lp.php @@ -62,7 +62,7 @@ class block_lp extends block_base { } $this->content = new stdClass(); - if (!\core_competency\api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return $this->content; } diff --git a/competency/classes/api.php b/competency/classes/api.php index 07e76f7b40f..2a76ecd06b7 100644 --- a/competency/classes/api.php +++ b/competency/classes/api.php @@ -49,6 +49,10 @@ class api { /** * Returns whether competencies are enabled. * + * This method should never do more than checking the config setting, the reason + * being that some other code could be checking the config value directly + * to avoid having to load this entire file into memory. + * * @return boolean True when enabled. */ public static function is_enabled() { diff --git a/competency/lib.php b/competency/lib.php index c3b4b05dc04..e9007747fab 100644 --- a/competency/lib.php +++ b/competency/lib.php @@ -40,7 +40,7 @@ use core_competency\user_evidence; function core_competency_comment_add($comment, $params) { global $USER; - if (!api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return; } @@ -215,7 +215,7 @@ function core_competency_comment_add($comment, $params) { * @return array */ function core_competency_comment_permissions($params) { - if (!api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return array('post' => false, 'view' => false); } @@ -241,7 +241,7 @@ function core_competency_comment_permissions($params) { * @return bool */ function core_competency_comment_validate($params) { - if (!api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return false; } @@ -274,7 +274,7 @@ function core_competency_comment_validate($params) { function core_competency_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { global $CFG; - if (!api::is_enabled()) { + if (!get_config('core_competency', 'enabled')) { return false; } diff --git a/report/competency/lib.php b/report/competency/lib.php index 35bd488f875..5476c55e290 100644 --- a/report/competency/lib.php +++ b/report/competency/lib.php @@ -34,6 +34,10 @@ defined('MOODLE_INTERNAL') || die; * @param stdClass $context The context of the course */ function report_competency_extend_navigation_course($navigation, $course, $context) { + if (!get_config('core_competency', 'enabled')) { + return; + } + if (has_capability('moodle/competency:coursecompetencyview', $context)) { $url = new moodle_url('/report/competency/index.php', array('id' => $course->id)); $name = get_string('pluginname', 'report_competency');