mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-53451 competency: Improve performance by bypassing api::is_enabled()
This commit is contained in:
parent
86dd906aa7
commit
5592edb646
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if (\core_competency\api::is_enabled()) {
|
||||
if (get_config('core_competency', 'enabled')) {
|
||||
|
||||
$parentname = 'competencies';
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user