mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
MDL-40403 libraries: Deprecate get_parent_contexts()
This commit is contained in:
parent
01546175d2
commit
8e8891b76b
@ -741,7 +741,7 @@ abstract class restore_dbops {
|
||||
// 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) {
|
||||
|
@ -129,7 +129,7 @@ class enrol_category_handler {
|
||||
|
||||
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');
|
||||
@ -178,7 +178,7 @@ function enrol_category_sync_course($course) {
|
||||
|
||||
// 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');
|
||||
|
@ -86,7 +86,7 @@ class enrol_cohort_plugin extends enrol_plugin {
|
||||
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
|
||||
|
@ -394,7 +394,7 @@ function enrol_cohort_get_cohorts(course_enrolment_manager $manager) {
|
||||
$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
|
||||
|
@ -176,7 +176,7 @@ class course_enrolment_manager {
|
||||
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
|
||||
@ -293,7 +293,7 @@ class course_enrolment_manager {
|
||||
}
|
||||
$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
|
||||
|
@ -7225,20 +7225,6 @@ class context_block extends context {
|
||||
// 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.)
|
||||
|
@ -566,7 +566,7 @@ class block_manager {
|
||||
$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');
|
||||
|
@ -4928,3 +4928,19 @@ function get_system_context($cache = true) {
|
||||
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);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ class external_api {
|
||||
} 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();
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ function grade_get_letters($context=null) {
|
||||
|
||||
$letters = array();
|
||||
|
||||
$contexts = get_parent_contexts($context);
|
||||
$contexts = $context->get_parent_context_ids();
|
||||
array_unshift($contexts, $context->id);
|
||||
|
||||
foreach ($contexts as $ctxid) {
|
||||
|
@ -2374,6 +2374,8 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$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();
|
||||
|
@ -2,12 +2,14 @@ This files describes API changes in core libraries and APIs,
|
||||
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 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user