Skip to content

Commit

Permalink
MDL-40431 libraries: deprecated get_context_url()
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Jul 11, 2013
1 parent c592eea commit 6c89d4e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
$a = new stdClass;
$a->roleid = $roleid;
$a->context = $contextname;
print_error('cannotassignrolehere', '', get_context_url($context), $a);
print_error('cannotassignrolehere', '', $context->get_url(), $a);
}

// Work out an appropriate page title.
Expand Down
2 changes: 1 addition & 1 deletion filter/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
/// Appropriate back link.
if (!$isfrontpage) {
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');
}

Expand Down
13 changes: 0 additions & 13 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7246,19 +7246,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.
Expand Down
16 changes: 16 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

6 changes: 3 additions & 3 deletions lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ function __construct($context, $capability, $errormessage, $stringfile) {
$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);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/accesslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,9 @@ public function test_permission_evaluation() {
$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);
get_context_url($coursecontext);
$this->assertDebuggingCalled('get_context_url() is deprecated, please use $context->get_url() instead.', DEBUG_DEVELOPER);
$url = $coursecontext->get_url();
$this->assertFalse($url instanceof modole_url);

$pagecm = get_coursemodule_from_instance('page', $testpages[7]);
Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===

Expand Down

0 comments on commit 6c89d4e

Please sign in to comment.