Merge branch 'MDL-40431_master' of https://github.com/markn86/moodle

This commit is contained in:
Damyon Wiese 2013-07-16 14:49:25 +08:00
commit ed9e492087
7 changed files with 27 additions and 20 deletions

View file

@ -67,7 +67,7 @@ if ($roleid && !isset($assignableroles[$roleid])) {
$a = new stdClass; $a = new stdClass;
$a->roleid = $roleid; $a->roleid = $roleid;
$a->context = $contextname; $a->context = $contextname;
print_error('cannotassignrolehere', '', get_context_url($context), $a); print_error('cannotassignrolehere', '', $context->get_url(), $a);
} }
// Work out an appropriate page title. // Work out an appropriate page title.

View file

@ -212,7 +212,7 @@ if (empty($availablefilters)) {
/// Appropriate back link. /// Appropriate back link.
if (!$isfrontpage) { if (!$isfrontpage) {
echo html_writer::start_tag('div', array('class'=>'backlink')); echo html_writer::start_tag('div', array('class'=>'backlink'));
echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>get_context_url($context))); echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $context->get_url()));
echo html_writer::end_tag('div'); echo html_writer::end_tag('div');
} }

View file

@ -7247,19 +7247,6 @@ function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
return array($select, $join); 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, * Is this context part of any course? if yes return course context,
* if not return null or throw exception. * if not return null or throw exception.

View file

@ -4137,3 +4137,19 @@ function delete_context($contextlevel, $instanceid, $deleterecord = true) {
return 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();
}

View file

@ -215,10 +215,10 @@ class required_capability_exception extends moodle_exception {
$capabilityname = get_capability_string($capability); $capabilityname = get_capability_string($capability);
if ($context->contextlevel == CONTEXT_MODULE and preg_match('/:view$/', $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 // 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(); $parentcontext = $context->get_parent_context();
$link = get_context_url($paranetcontext); $link = $parentcontext->get_url();
} else { } else {
$link = get_context_url($context); $link = $context->get_url();
} }
parent::__construct($errormessage, $stringfile, $link, $capabilityname); parent::__construct($errormessage, $stringfile, $link, $capabilityname);
} }

View file

@ -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->assertDebuggingCalled('print_context_name() is deprecated, please use $context->get_context_name() instead.', DEBUG_DEVELOPER);
$this->assertFalse(empty($name)); $this->assertFalse(empty($name));
$url = get_context_url($coursecontext); $url1 = get_context_url($coursecontext);
$this->assertFalse($url instanceof modole_url); $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]); $pagecm = get_coursemodule_from_instance('page', $testpages[7]);
$context = context_module::instance($pagecm->id); $context = context_module::instance($pagecm->id);

View file

@ -24,6 +24,7 @@ information provided here is intended especially for developers.
* print_context_name() is deprecated, please use $context->get_context_name(). * print_context_name() is deprecated, please use $context->get_context_name().
* mark_context_dirty($context->path) is deprecated, please use $context->mark_dirty(). * 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(). * 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 === === 2.5.1 ===