// Build the array of contexts we are going to look
$systemctx = context_system::instance();
$coursectx = context_course::instance($courseid);
- $parentctxs= get_parent_contexts($coursectx);
+ $parentctxs = $coursectx->get_parent_context_ids();
foreach ($parentctxs as $parentctx) {
// Exclude system context
if ($parentctx == $systemctx->id) {
foreach ($rs as $instance) {
$coursecontext = context_course::instance($instance->courseid);
- $contextids = get_parent_contexts($coursecontext);
+ $contextids = $coursecontext->get_parent_context_ids();
array_pop($contextids); // Remove system context, we are interested in categories only.
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
// First find out if any parent category context contains interesting role assignments.
$coursecontext = context_course::instance($course->id);
- $contextids = get_parent_contexts($coursecontext);
+ $contextids = $coursecontext->get_parent_context_ids();
array_pop($contextids); // Remove system context, we are interested in categories only.
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
if (!has_capability('moodle/course:enrolconfig', $coursecontext) or !has_capability('enrol/cohort:config', $coursecontext)) {
return false;
}
- list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($coursecontext));
+ list($sqlparents, $params) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids());
$sql = "SELECT id, contextid
FROM {cohort}
WHERE contextid $sqlparents
$enrolled[] = $instance->customint1;
}
}
- list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($context));
+ list($sqlparents, $params) = $DB->get_in_or_equal($context->get_parent_context_ids());
$sql = "SELECT id, name, idnumber, contextid
FROM {cohort}
WHERE contextid $sqlparents
public function get_total_other_users() {
global $DB;
if ($this->totalotherusers === null) {
- list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
+ list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
$params['courseid'] = $this->course->id;
$sql = "SELECT COUNT(DISTINCT u.id)
FROM {role_assignments} ra
}
$key = md5("$sort-$direction-$page-$perpage");
if (!array_key_exists($key, $this->otherusers)) {
- list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
+ list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
$params['courseid'] = $this->course->id;
$params['cid'] = $this->course->id;
$sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, u.*, ue.lastseen
// 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 parent context ids,
- * and return the array in reverse order, i.e. parent first, then grand
- * parent, etc.
- *
- * @deprecated since 2.2, use $context->get_parent_context_ids() instead
- * @param context $context
- * @param bool $includeself optional, defaults to false
- * @return array
- */
-function get_parent_contexts(context $context, $includeself = false) {
- return $context->get_parent_context_ids($includeself);
-}
-
/**
* Return the id of the parent of this context, or false if there is no parent (only happens if this
* is the site context.)
$context = $this->page->context;
$contexttest = 'bi.parentcontextid = :contextid2';
$parentcontextparams = array();
- $parentcontextids = get_parent_contexts($context);
+ $parentcontextids = $context->get_parent_context_ids();
if ($parentcontextids) {
list($parentcontexttest, $parentcontextparams) =
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext');
debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
return context_system::instance(0, IGNORE_MISSING, $cache);
}
+
+/**
+ * Recursive function which, given a context, find all parent context ids,
+ * and return the array in reverse order, i.e. parent first, then grand
+ * parent, etc.
+ *
+ * @see context::get_parent_context_ids()
+ * @deprecated since 2.2, use $context->get_parent_context_ids() instead
+ * @param context $context
+ * @param bool $includeself optional, defaults to false
+ * @return array
+ */
+function get_parent_contexts(context $context, $includeself = false) {
+ debugging('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.', DEBUG_DEVELOPER);
+ return $context->get_parent_context_ids($includeself);
+}
} else if ($rcontext->contextlevel > $context->contextlevel) {
throw new restricted_context_exception();
} else {
- $parents = get_parent_contexts($context);
+ $parents = $context->get_parent_context_ids();
if (!in_array($rcontext->id, $parents)) {
throw new restricted_context_exception();
}
$letters = array();
- $contexts = get_parent_contexts($context);
+ $contexts = $context->get_parent_context_ids();
array_unshift($contexts, $context->id);
foreach ($contexts as $ctxid) {
$this->assertDebuggingCalled('get_context_instance_by_id() is deprecated, please use context::instance_by_id($id) instead.', DEBUG_DEVELOPER);
get_system_context();
$this->assertDebuggingCalled('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
+ get_parent_contexts($context);
+ $this->assertDebuggingCalled('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.', DEBUG_DEVELOPER);
$DB->delete_records('context', array('contextlevel'=>CONTEXT_BLOCK));
create_contexts();
information provided here is intended especially for developers.
=== 2.6 ===
+
* Use new core_component::* plugin listing and component normalisation methods.
* Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*.
* get_context_instance() is deprecated, please use use context_xxxx::instance().
* get_context_instance_by_id() is deprecated, please use context::instance_by_id($id).
* load_temp_role() and remove_temp_roles() can not be used any more.
* get_system_context() is deprecated, please use context_system::instance().
+* get_parent_contexts() is deprecated, please use $context->get_parent_context_ids().
=== 2.5.1 ===