mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
Merge branch 'MDL-40463-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
1d1f7ac81f
filter
lib
@ -36,9 +36,11 @@ class filter_activitynames extends moodle_text_filter {
|
||||
static $cachedcourseid;
|
||||
|
||||
function filter($text, array $options = array()) {
|
||||
if (!$courseid = get_courseid_from_context($this->context)) {
|
||||
$coursectx = $this->context->get_course_context(false);
|
||||
if (!$coursectx) {
|
||||
return $text;
|
||||
}
|
||||
$courseid = $coursectx->instanceid;
|
||||
|
||||
// Initialise/invalidate our trivial cache if dealing with a different course
|
||||
if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int)$courseid) {
|
||||
|
@ -40,9 +40,12 @@ class filter_data extends moodle_text_filter {
|
||||
|
||||
static $nothingtodo;
|
||||
|
||||
// Try to get current course
|
||||
if (!$courseid = get_courseid_from_context($this->context)) {
|
||||
// Try to get current course.
|
||||
$coursectx = $this->context->get_course_context(false);
|
||||
if (!$coursectx) {
|
||||
$courseid = 0;
|
||||
} else {
|
||||
$courseid = $coursectx->instanceid;
|
||||
}
|
||||
|
||||
// Initialise/invalidate our trivial cache if dealing with a different context
|
||||
|
@ -56,9 +56,12 @@ class filter_glossary extends moodle_text_filter {
|
||||
|
||||
static $nothingtodo; // To avoid processing if no glossaries / concepts are found
|
||||
|
||||
// Try to get current course
|
||||
if (!$courseid = get_courseid_from_context($this->context)) {
|
||||
// Try to get current course.
|
||||
$coursectx = $this->context->get_course_context(false);
|
||||
if (!$coursectx) {
|
||||
$courseid = 0;
|
||||
} else {
|
||||
$courseid = $coursectx->instanceid;
|
||||
}
|
||||
|
||||
// Initialise/invalidate our trivial cache if dealing with a different context
|
||||
|
@ -7247,22 +7247,6 @@ function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
|
||||
return array($select, $join);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current course id or null if outside of course based on context parameter.
|
||||
*
|
||||
* @deprecated since 2.2, use $context->get_course_context instead
|
||||
* @param context $context
|
||||
* @return int|bool related course id or false
|
||||
*/
|
||||
function get_courseid_from_context(context $context) {
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
return $coursecontext->instanceid;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs get_records select on context table and returns the result
|
||||
* Does get_records_select on the context table, and returns the results ordered
|
||||
|
@ -4262,3 +4262,20 @@ function get_role_context_caps($roleid, context $context) {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current course id or false if outside of course based on context parameter.
|
||||
*
|
||||
* @see context::get_course_context()
|
||||
* @deprecated since 2.2
|
||||
* @param context $context
|
||||
* @return int|bool related course id or false
|
||||
*/
|
||||
function get_courseid_from_context(context $context) {
|
||||
debugging('get_courseid_from_context() is deprecated, please use $context->get_course_context(false) instead.', DEBUG_DEVELOPER);
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
return $coursecontext->instanceid;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2490,6 +2490,7 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($coursecontext1, $coursecontext2);
|
||||
$this->assertEquals($coursecontext2->contextlevel, CONTEXT_COURSE);
|
||||
$this->assertEquals(get_courseid_from_context($context), $pagecm->course);
|
||||
$this->assertDebuggingCalled('get_courseid_from_context() is deprecated, please use $context->get_course_context(false) instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$caps = fetch_context_capabilities($systemcontext);
|
||||
$this->assertDebuggingCalled('fetch_context_capabilities() is deprecated, please use $context->get_capabilities() instead.', DEBUG_DEVELOPER);
|
||||
|
@ -29,6 +29,7 @@ information provided here is intended especially for developers.
|
||||
* get_course_context() is deprecated, please use $context->get_course_context().
|
||||
* get_user_courses_bycap() is deprecated, please use enrol_get_users_courses().
|
||||
* get_role_context_caps() is deprecated, it is really slow. Don't use it.
|
||||
* get_courseid_from_context() is deprecated, please use $context->get_course_context(false).
|
||||
|
||||
=== 2.5.1 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user