global $DB;
$contexts = array();
$contexts[] = $context->id;
- $children = get_child_contexts($context);
+ $children = $context->get_child_contexts();
foreach ($children as $c) {
$contexts[] = $c->id;
}
// 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
// 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
*
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();
+}
$componentstr = get_string('roles');
if (!empty($data->reset_roles_overrides)) {
- $children = get_child_contexts($context);
+ $children = $context->get_child_contexts();
foreach ($children as $child) {
$DB->delete_records('role_capabilities', array('contextid'=>$child->id));
}
}
if (!empty($data->reset_roles_local)) {
- $children = get_child_contexts($context);
+ $children = $context->get_child_contexts();
foreach ($children as $child) {
role_unassign_all(array('contextid'=>$child->id));
}
}
$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->resetDebugging();
unset($children);
// Make sure a debugging is thrown.
$this->assertDebuggingCalled('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.', DEBUG_DEVELOPER);
get_parent_contextid($context);
$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));
create_contexts();
* get_system_context() is deprecated, please use context_system::instance().
* get_parent_contexts() is deprecated, please use $context->get_parent_context_ids().
* get_parent_contextid() is deprecated, please use $context->get_parent_context().
+* get_child_contexts() is deprecated, please use $context->get_child_contexts().
=== 2.5.1 ===