mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-40405-master' of git://github.com/FMCorz/moodle
Conflicts: lib/upgrade.txt
This commit is contained in:
commit
0574cd9061
6 changed files with 32 additions and 25 deletions
|
@ -685,7 +685,7 @@ class comment {
|
||||||
global $DB;
|
global $DB;
|
||||||
$contexts = array();
|
$contexts = array();
|
||||||
$contexts[] = $context->id;
|
$contexts[] = $context->id;
|
||||||
$children = get_child_contexts($context);
|
$children = $context->get_child_contexts();
|
||||||
foreach ($children as $c) {
|
foreach ($children as $c) {
|
||||||
$contexts[] = $c->id;
|
$contexts[] = $c->id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7230,27 +7230,6 @@ class context_block extends context {
|
||||||
// before removing devs will be warned with a debugging message first,
|
// before removing devs will be warned with a debugging message first,
|
||||||
// then we will add error message and only after that we can remove the functions
|
// then we will add error message and only after that we can remove the functions
|
||||||
// completely.
|
// completely.
|
||||||
/**
|
|
||||||
* Recursive function which, given a context, find all its children context ids.
|
|
||||||
*
|
|
||||||
* For course category contexts it will return immediate children only categories and courses.
|
|
||||||
* It will NOT recurse into courses or child categories.
|
|
||||||
* If you want to do that, call it on the returned courses/categories.
|
|
||||||
*
|
|
||||||
* When called for a course context, it will return the modules and blocks
|
|
||||||
* displayed in the course page.
|
|
||||||
*
|
|
||||||
* If called on a user/course/module context it _will_ populate the cache with the appropriate
|
|
||||||
* contexts ;-)
|
|
||||||
*
|
|
||||||
* @deprecated since 2.2, use $context->get_child_contexts() instead
|
|
||||||
* @param context $context
|
|
||||||
* @return array Array of child records
|
|
||||||
*/
|
|
||||||
function get_child_contexts(context $context) {
|
|
||||||
return $context->get_child_contexts();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Precreates all contexts including all parents
|
* Precreates all contexts including all parents
|
||||||
*
|
*
|
||||||
|
|
|
@ -4963,3 +4963,26 @@ function get_parent_contextid(context $context) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursive function which, given a context, find all its children contexts.
|
||||||
|
*
|
||||||
|
* For course category contexts it will return immediate children only categories and courses.
|
||||||
|
* It will NOT recurse into courses or child categories.
|
||||||
|
* If you want to do that, call it on the returned courses/categories.
|
||||||
|
*
|
||||||
|
* When called for a course context, it will return the modules and blocks
|
||||||
|
* displayed in the course page.
|
||||||
|
*
|
||||||
|
* If called on a user/course/module context it _will_ populate the cache with the appropriate
|
||||||
|
* contexts ;-)
|
||||||
|
*
|
||||||
|
* @see context::get_child_contexts()
|
||||||
|
* @deprecated since 2.2
|
||||||
|
* @param context $context
|
||||||
|
* @return array Array of child records
|
||||||
|
*/
|
||||||
|
function get_child_contexts(context $context) {
|
||||||
|
debugging('get_child_contexts() is deprecated, please use $context->get_child_contexts() instead.', DEBUG_DEVELOPER);
|
||||||
|
return $context->get_child_contexts();
|
||||||
|
}
|
||||||
|
|
|
@ -5230,7 +5230,7 @@ function reset_course_userdata($data) {
|
||||||
$componentstr = get_string('roles');
|
$componentstr = get_string('roles');
|
||||||
|
|
||||||
if (!empty($data->reset_roles_overrides)) {
|
if (!empty($data->reset_roles_overrides)) {
|
||||||
$children = get_child_contexts($context);
|
$children = $context->get_child_contexts();
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
$DB->delete_records('role_capabilities', array('contextid'=>$child->id));
|
$DB->delete_records('role_capabilities', array('contextid'=>$child->id));
|
||||||
}
|
}
|
||||||
|
@ -5241,7 +5241,7 @@ function reset_course_userdata($data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data->reset_roles_local)) {
|
if (!empty($data->reset_roles_local)) {
|
||||||
$children = get_child_contexts($context);
|
$children = $context->get_child_contexts();
|
||||||
foreach ($children as $child) {
|
foreach ($children as $child) {
|
||||||
role_unassign_all(array('contextid'=>$child->id));
|
role_unassign_all(array('contextid'=>$child->id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2363,8 +2363,10 @@ class accesslib_testcase extends advanced_testcase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$children = get_child_contexts($systemcontext);
|
$children = get_child_contexts($systemcontext);
|
||||||
$this->resetDebugging();
|
// Using assertEquals here as assertSame fails for some reason...
|
||||||
|
$this->assertEquals($children, $systemcontext->get_child_contexts());
|
||||||
$this->assertEquals(count($children), $DB->count_records('context')-1);
|
$this->assertEquals(count($children), $DB->count_records('context')-1);
|
||||||
|
$this->resetDebugging();
|
||||||
unset($children);
|
unset($children);
|
||||||
|
|
||||||
// Make sure a debugging is thrown.
|
// Make sure a debugging is thrown.
|
||||||
|
@ -2378,6 +2380,8 @@ class accesslib_testcase extends advanced_testcase {
|
||||||
$this->assertDebuggingCalled('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.', DEBUG_DEVELOPER);
|
$this->assertDebuggingCalled('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.', DEBUG_DEVELOPER);
|
||||||
get_parent_contextid($context);
|
get_parent_contextid($context);
|
||||||
$this->assertDebuggingCalled('get_parent_contextid() is deprecated, please use $context->get_parent_context() instead.', DEBUG_DEVELOPER);
|
$this->assertDebuggingCalled('get_parent_contextid() is deprecated, please use $context->get_parent_context() instead.', DEBUG_DEVELOPER);
|
||||||
|
get_child_contexts($frontpagecontext);
|
||||||
|
$this->assertDebuggingCalled('get_child_contexts() is deprecated, please use $context->get_child_contexts() instead.', DEBUG_DEVELOPER);
|
||||||
|
|
||||||
$DB->delete_records('context', array('contextlevel'=>CONTEXT_BLOCK));
|
$DB->delete_records('context', array('contextlevel'=>CONTEXT_BLOCK));
|
||||||
create_contexts();
|
create_contexts();
|
||||||
|
|
|
@ -11,6 +11,7 @@ information provided here is intended especially for developers.
|
||||||
* get_system_context() is deprecated, please use context_system::instance().
|
* get_system_context() is deprecated, please use context_system::instance().
|
||||||
* get_parent_contexts() is deprecated, please use $context->get_parent_context_ids().
|
* get_parent_contexts() is deprecated, please use $context->get_parent_context_ids().
|
||||||
* get_parent_contextid() is deprecated, please use $context->get_parent_context().
|
* get_parent_contextid() is deprecated, please use $context->get_parent_context().
|
||||||
|
* get_child_contexts() is deprecated, please use $context->get_child_contexts().
|
||||||
* Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
|
* Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
|
||||||
|
|
||||||
=== 2.5.1 ===
|
=== 2.5.1 ===
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue