mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
Merge branch 'MDL-40431_master' of https://github.com/markn86/moodle
This commit is contained in:
commit
ed9e492087
7 changed files with 27 additions and 20 deletions
|
@ -7247,19 +7247,6 @@ function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
|
|||
return array($select, $join);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a URL for a context, if there is a natural one. For example, for
|
||||
* CONTEXT_COURSE, this is the course page. For CONTEXT_USER it is the
|
||||
* user profile page.
|
||||
*
|
||||
* @deprecated since 2.2
|
||||
* @param context $context the context.
|
||||
* @return moodle_url
|
||||
*/
|
||||
function get_context_url(context $context) {
|
||||
return $context->get_url();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this context part of any course? if yes return course context,
|
||||
* if not return null or throw exception.
|
||||
|
|
|
@ -4137,3 +4137,19 @@ function delete_context($contextlevel, $instanceid, $deleterecord = true) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a URL for a context, if there is a natural one. For example, for
|
||||
* CONTEXT_COURSE, this is the course page. For CONTEXT_USER it is the
|
||||
* user profile page.
|
||||
*
|
||||
* @deprecated since 2.2
|
||||
* @see context::get_url()
|
||||
* @param context $context the context
|
||||
* @return moodle_url
|
||||
*/
|
||||
function get_context_url(context $context) {
|
||||
debugging('get_context_url() is deprecated, please use $context->get_url() instead.', DEBUG_DEVELOPER);
|
||||
return $context->get_url();
|
||||
}
|
||||
|
||||
|
|
|
@ -215,10 +215,10 @@ class required_capability_exception extends moodle_exception {
|
|||
$capabilityname = get_capability_string($capability);
|
||||
if ($context->contextlevel == CONTEXT_MODULE and preg_match('/:view$/', $capability)) {
|
||||
// we can not go to mod/xx/view.php because we most probably do not have cap to view it, let's go to course instead
|
||||
$paranetcontext = $context->get_parent_context();
|
||||
$link = get_context_url($paranetcontext);
|
||||
$parentcontext = $context->get_parent_context();
|
||||
$link = $parentcontext->get_url();
|
||||
} else {
|
||||
$link = get_context_url($context);
|
||||
$link = $context->get_url();
|
||||
}
|
||||
parent::__construct($errormessage, $stringfile, $link, $capabilityname);
|
||||
}
|
||||
|
|
|
@ -2476,8 +2476,11 @@ class accesslib_testcase extends advanced_testcase {
|
|||
$this->assertDebuggingCalled('print_context_name() is deprecated, please use $context->get_context_name() instead.', DEBUG_DEVELOPER);
|
||||
$this->assertFalse(empty($name));
|
||||
|
||||
$url = get_context_url($coursecontext);
|
||||
$this->assertFalse($url instanceof modole_url);
|
||||
$url1 = get_context_url($coursecontext);
|
||||
$this->assertDebuggingCalled('get_context_url() is deprecated, please use $context->get_url() instead.', DEBUG_DEVELOPER);
|
||||
$url2 = $coursecontext->get_url();
|
||||
$this->assertEquals($url1, $url2);
|
||||
$this->assertFalse($url2 instanceof modole_url);
|
||||
|
||||
$pagecm = get_coursemodule_from_instance('page', $testpages[7]);
|
||||
$context = context_module::instance($pagecm->id);
|
||||
|
|
|
@ -24,6 +24,7 @@ information provided here is intended especially for developers.
|
|||
* print_context_name() is deprecated, please use $context->get_context_name().
|
||||
* mark_context_dirty($context->path) is deprecated, please use $context->mark_dirty().
|
||||
* delete_context() is deprecated, please use $context->delete_content() or context_helper::delete_instance().
|
||||
* get_context_url() is deprecated, please use $context->get_url().
|
||||
|
||||
=== 2.5.1 ===
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue