diff --git a/admin/handlevirus.php b/admin/handlevirus.php index b29392df3b9..36cc0e37172 100644 --- a/admin/handlevirus.php +++ b/admin/handlevirus.php @@ -39,9 +39,10 @@ while(!feof($fd)) { $action = clam_handle_infected_file($file,$log->userid,true); clam_replace_infected_file($file); - list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT c.id, c.fullname $ctxselect FROM {course} c $ctxjoin WHERE c.id = :courseid"; - $course = $DB->get_record_sql($sql, array('courseid' => $log->course)); + $course = $DB->get_record_sql($sql, array('courseid' => $log->course, 'contextlevel' => CONTEXT_COURSE)); context_helper::preload_from_record($course); $user = $DB->get_record("user", array("id"=>$log->userid)); diff --git a/backup/util/ui/restore_ui_components.php b/backup/util/ui/restore_ui_components.php index 832717f62af..6f655330796 100644 --- a/backup/util/ui/restore_ui_components.php +++ b/backup/util/ui/restore_ui_components.php @@ -277,8 +277,10 @@ class restore_course_search extends restore_search_base { protected function get_searchsql() { global $DB; - list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $params = array( + 'contextlevel' => CONTEXT_COURSE, 'fullnamesearch' => '%'.$this->get_search().'%', 'shortnamesearch' => '%'.$this->get_search().'%', 'siteid' => SITEID @@ -326,8 +328,10 @@ class restore_category_search extends restore_search_base { protected function get_searchsql() { global $DB; - list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSECAT, 'ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $params = array( + 'contextlevel' => CONTEXT_COURSECAT, 'namesearch' => '%'.$this->get_search().'%', ); diff --git a/calendar/lib.php b/calendar/lib.php index bbcd41a83c5..50ef3a6877e 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1568,13 +1568,14 @@ function calendar_get_default_courses() { $courses = array(); if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', context_system::instance())) { - list ($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $select = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT c.* $select FROM {course} c $join WHERE EXISTS (SELECT 1 FROM {event} e WHERE e.courseid = c.id) "; - $courses = $DB->get_records_sql($sql, null, 0, 20); + $courses = $DB->get_records_sql($sql, array('contextlevel' => CONTEXT_COURSE), 0, 20); foreach ($courses as $course) { context_helper::preload_from_record($course); } diff --git a/enrol/externallib.php b/enrol/externallib.php index f7f08046533..53e1c139826 100644 --- a/enrol/externallib.php +++ b/enrol/externallib.php @@ -458,8 +458,9 @@ class core_enrol_external extends external_api { } list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive); - list($ctxselect, $ctxjoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx'); - $sqlparams['courseid'] = $courseid; + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)"; + $enrolledparams['contextlevel'] = CONTEXT_USER; $sql = "SELECT u.* $ctxselect FROM {user} u $ctxjoin WHERE u.id IN ($enrolledsql) diff --git a/enrol/meta/addinstance_form.php b/enrol/meta/addinstance_form.php index 469e23ff8d4..c4630826863 100644 --- a/enrol/meta/addinstance_form.php +++ b/enrol/meta/addinstance_form.php @@ -40,9 +40,10 @@ class enrol_meta_addinstance_form extends moodleform { // TODO: this has to be done via ajax or else it will fail very badly on large sites! $courses = array('' => get_string('choosedots')); - list ($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $select = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT c.id, c.fullname, c.shortname, c.visible $select FROM {course} c $join ORDER BY c.sortorder ASC"; - $rs = $DB->get_recordset_sql($sql); + $rs = $DB->get_recordset_sql($sql, array('contextlevel' => CONTEXT_COURSE)); foreach ($rs as $c) { if ($c->id == SITEID or $c->id == $course->id or isset($existing[$c->id])) { continue; diff --git a/lib/accesslib.php b/lib/accesslib.php index 4fe6f21baec..ed501689f5d 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -7231,21 +7231,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. -/** - * Preloads context information together with instances. - * Use context_helper::preload_from_record() to strip the context info from the record and cache the context instance. - * - * @deprecated since 2.2 - * @param string $joinon for example 'u.id' - * @param string $contextlevel context level of instance in $joinon - * @param string $tablealias context table alias - * @return array with two values - select and join part - */ -function context_instance_preload_sql($joinon, $contextlevel, $tablealias) { - $select = ", ".context_helper::get_preload_record_columns_sql($tablealias); - $join = "LEFT JOIN {context} $tablealias ON ($tablealias.instanceid = $joinon AND $tablealias.contextlevel = $contextlevel)"; - return array($select, $join); -} /** * Runs get_records select on context table and returns the result diff --git a/lib/blocklib.php b/lib/blocklib.php index 0a0fc080ad2..1a7b909104a 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -580,9 +580,11 @@ class block_manager { list($pagetypepatterntest, $pagetypepatternparams) = $DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest'); - list($ccselect, $ccjoin) = context_instance_preload_sql('bi.id', CONTEXT_BLOCK, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = bi.id AND ctx.contextlevel = :contextlevel)"; $params = array( + 'contextlevel' => CONTEXT_BLOCK, 'subpage1' => $this->page->subpage, 'subpage2' => $this->page->subpage, 'contextid1' => $context->id, diff --git a/lib/datalib.php b/lib/datalib.php index 36ad2972a47..e7683ea539d 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -619,7 +619,9 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*") $visiblecourses = array(); - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; $sql = "SELECT $fields $ccselect FROM {course} c @@ -681,7 +683,9 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c $categoryselect = ""; } - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; $totalcount = 0; if (!$limitfrom) { @@ -799,7 +803,10 @@ function get_courses_search($searchterms, $sort, $page, $recordsperpage, &$total $limitfrom = $page * $recordsperpage; $limitto = $limitfrom + $recordsperpage; - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; + $fields = array_diff(array_keys($DB->get_columns('course')), array('modinfo', 'sectioncache')); $sql = "SELECT c.".join(',c.',$fields)." $ccselect FROM {course} c diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 25e09baa2f3..b0a84867b11 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -4306,4 +4306,33 @@ function get_courseid_from_context(context $context) { } else { return false; } + +/** + * Preloads context information together with instances. + * Use context_instance_preload() to strip the context info from the record and cache the context instance. + * + * If you are using this methid, you should have something like this: + * + * list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + * + * To prevent the use of this deprecated function, replace the line above with something similar to this: + * + * $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + * ^ + * $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + * ^ ^ ^ ^ + * $params = array('contextlevel' => CONTEXT_COURSE); + * ^ + * @see context_helper:;get_preload_record_columns_sql() + * @deprecated since 2.2 + * @param string $joinon for example 'u.id' + * @param string $contextlevel context level of instance in $joinon + * @param string $tablealias context table alias + * @return array with two values - select and join part + */ +function context_instance_preload_sql($joinon, $contextlevel, $tablealias) { + debugging('context_instance_preload_sql() is deprecated, please use context_helper::get_preload_record_columns_sql() instead.', DEBUG_DEVELOPER); + $select = ", " . context_helper::get_preload_record_columns_sql($tablealias); + $join = "LEFT JOIN {context} $tablealias ON ($tablealias.instanceid = $joinon AND $tablealias.contextlevel = $contextlevel)"; + return array($select, $join); } diff --git a/lib/enrollib.php b/lib/enrollib.php index b000654b41c..d3a878e091d 100644 --- a/lib/enrollib.php +++ b/lib/enrollib.php @@ -276,7 +276,9 @@ function enrol_get_shared_courses($user1, $user2, $preloadcontexts = false, $che $ctxselect = ''; $ctxjoin = ''; if ($preloadcontexts) { - list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; } $sql = "SELECT c.* $ctxselect @@ -572,7 +574,9 @@ function enrol_get_my_courses($fields = NULL, $sort = 'visible DESC,sortorder AS } $coursefields = 'c.' .join(',c.', $fields); - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; $wheres = implode(" AND ", $wheres); //note: we can not use DISTINCT + text fields due to Oracle and MS limitations, that is why we have the subselect there @@ -830,7 +834,9 @@ function enrol_get_all_users_courses($userid, $onlyactive = false, $fields = NUL } $coursefields = 'c.' .join(',c.', $fields); - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; //note: we can not use DISTINCT + text fields due to Oracle and MS limitations, that is why we have the subselect there $sql = "SELECT $coursefields $ccselect diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 776e293a1e7..55c59622acb 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -1423,8 +1423,10 @@ class global_navigation extends navigation_node { if (count($fullfetch)) { // First up fetch all of the courses in categories where we know that we are going to // need the majority of courses. - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); list($categoryids, $categoryparams) = $DB->get_in_or_equal($fullfetch, SQL_PARAMS_NAMED, 'lcategory'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $categoryparams['contextlevel'] = CONTEXT_COURSE; $sql = "SELECT c.id, c.sortorder, c.visible, c.fullname, c.shortname, c.category $ccselect FROM {course} c $ccjoin @@ -1458,13 +1460,14 @@ class global_navigation extends navigation_node { // Next we will work our way through the categories where we will likely only need a small // proportion of the courses. foreach ($partfetch as $categoryid) { - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT c.id, c.sortorder, c.visible, c.fullname, c.shortname, c.category $ccselect FROM {course} c $ccjoin WHERE c.category = :categoryid ORDER BY c.sortorder ASC"; - $courseparams = array('categoryid' => $categoryid); + $courseparams = array('categoryid' => $categoryid, 'contextlevel' => CONTEXT_COURSE); $coursesrs = $DB->get_recordset_sql($sql, $courseparams, 0, $limit * 5); foreach ($coursesrs as $course) { if ($course->id == $SITE->id) { @@ -1492,8 +1495,10 @@ class global_navigation extends navigation_node { } } else { // Prepare the SQL to load the courses and their contexts - list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); list($courseids, $courseparams) = $DB->get_in_or_equal(array_keys($this->addedcourses), SQL_PARAMS_NAMED, 'lc', false); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $courseparams['contextlevel'] = CONTEXT_COURSE; $sql = "SELECT c.id, c.sortorder, c.visible, c.fullname, c.shortname, c.category $ccselect FROM {course} c $ccjoin diff --git a/lib/tests/accesslib_test.php b/lib/tests/accesslib_test.php index bc5e180ed29..863cfc3e8cc 100644 --- a/lib/tests/accesslib_test.php +++ b/lib/tests/accesslib_test.php @@ -2428,6 +2428,9 @@ class accesslib_testcase extends advanced_testcase { context_helper::reset_caches(); list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSECAT, 'ctx'); + $this->assertDebuggingCalled('context_instance_preload_sql() is deprecated, please use context_helper::get_preload_record_columns_sql() instead.', DEBUG_DEVELOPER); + $this->assertEquals(', ' . context_helper::get_preload_record_columns_sql('ctx'), $select); + $this->assertEquals('LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = ' . CONTEXT_COURSECAT . ')', $join); $sql = "SELECT c.id $select FROM {course_categories} c $join"; $records = $DB->get_records_sql($sql); foreach ($records as $record) { diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 4fcfca8a054..4c865c0c853 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -22,6 +22,7 @@ Accesslib: * context_moved() -> context::update_moved() * preload_course_contexts() -> context_helper::preload_course() * context_instance_preload() -> context_helper::preload_from_record() + * context_instance_preload_sql()-> context_helper::get_preload_record_columns_sql() * get_contextlevel_name() -> context_helper::get_level_name() * create_contexts() -> context_helper::create_instances() * cleanup_contexts() -> context_helper::cleanup_instances() diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3281b98680e..213b8d49dfd 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -8186,7 +8186,9 @@ function forum_get_courses_user_posted_in($user, $discussionsonly = false, $incl // Join to the context table so that we can preload contexts if required. if ($includecontexts) { - list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; } else { $ctxselect = ''; $ctxjoin = ''; diff --git a/rating/lib.php b/rating/lib.php index e2d786d6b2a..69c90c4141d 100644 --- a/rating/lib.php +++ b/rating/lib.php @@ -791,15 +791,17 @@ class rating_manager { $modulename = $options->modulename; $moduleid = intval($options->moduleid); - //going direct to the db for the context id seems wrong - list($ctxselect, $ctxjoin) = context_instance_preload_sql('cm.id', CONTEXT_MODULE, 'ctx'); + // Going direct to the db for the context id seems wrong. + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = cm.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT cm.* $ctxselect FROM {course_modules} cm LEFT JOIN {modules} mo ON mo.id = cm.module LEFT JOIN {{$modulename}} m ON m.id = cm.instance $ctxjoin WHERE mo.name=:modulename AND m.id=:moduleid"; - $contextrecord = $DB->get_record_sql($sql, array('modulename'=>$modulename, 'moduleid'=>$moduleid), '*', MUST_EXIST); + $params = array('modulename' => $modulename, 'moduleid' => $moduleid, 'contextlevel' => CONTEXT_MODULE); + $contextrecord = $DB->get_record_sql($sql, $params, '*', MUST_EXIST); $contextid = $contextrecord->ctxid; } diff --git a/report/backups/index.php b/report/backups/index.php index c041d3494e8..4b408a93bc5 100644 --- a/report/backups/index.php +++ b/report/backups/index.php @@ -49,12 +49,13 @@ $strunfinished = get_string("unfinished"); $strskipped = get_string("skipped"); $strwarning = get_string("warning"); -list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); +$select = ', ' . context_helper::get_preload_record_columns_sql('ctx'); +$join = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; $sql = "SELECT bc.*, c.fullname $select FROM {backup_courses} bc JOIN {course} c ON c.id = bc.courseid $join"; -$rs = $DB->get_recordset_sql($sql); +$rs = $DB->get_recordset_sql($sql, array('contextlevel' => CONTEXT_COURSE)); foreach ($rs as $backuprow) { // Cache the course context diff --git a/user/externallib.php b/user/externallib.php index 7947f2ecfb2..356b55666bc 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -678,8 +678,10 @@ class core_user_external extends external_api { $params = self::validate_parameters(self::get_users_by_id_parameters(), array('userids'=>$userids)); - list($uselect, $ujoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx'); list($sqluserids, $params) = $DB->get_in_or_equal($userids); + $uselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ujoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_USER; $usersql = "SELECT u.* $uselect FROM {user} u $ujoin WHERE u.id $sqluserids"; @@ -778,8 +780,10 @@ class core_user_external extends external_api { // cache all courses $courses = array(); - list($cselect, $cjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx'); list($sqlcourseids, $params) = $DB->get_in_or_equal(array_unique($courseids)); + $cselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $cjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_COURSE; $coursesql = "SELECT c.* $cselect FROM {course} c $cjoin WHERE c.id $sqlcourseids"; @@ -792,8 +796,10 @@ class core_user_external extends external_api { } $rs->close(); - list($uselect, $ujoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx'); list($sqluserids, $params) = $DB->get_in_or_equal($userids); + $uselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ujoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_USER; $usersql = "SELECT u.* $uselect FROM {user} u $ujoin WHERE u.id $sqluserids"; diff --git a/user/index.php b/user/index.php index 394674e9dab..c5200a74e85 100644 --- a/user/index.php +++ b/user/index.php @@ -401,7 +401,9 @@ } // performance hacks - we preload user contexts together with accounts - list($ccselect, $ccjoin) = context_instance_preload_sql('u.id', CONTEXT_USER, 'ctx'); + $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); + $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)"; + $params['contextlevel'] = CONTEXT_USER; $select .= $ccselect; $joins[] = $ccjoin;