mirror of
https://github.com/moodle/moodle.git
synced 2025-03-10 10:58:38 +01:00
Merge branch 'w51_MDL-35685_m25_capinit_b' of git://github.com/skodak/moodle
This commit is contained in:
commit
1a12cbd9df
@ -269,10 +269,9 @@ function get_role_access($roleid) {
|
||||
|
||||
$accessdata['ra']['/'.SYSCONTEXTID] = array((int)$roleid => (int)$roleid);
|
||||
|
||||
//
|
||||
// Overrides for the role IN ANY CONTEXTS
|
||||
// down to COURSE - not below -
|
||||
//
|
||||
// Overrides for the role IN ANY CONTEXTS down to COURSE - not below -.
|
||||
|
||||
/*
|
||||
$sql = "SELECT ctx.path,
|
||||
rc.capability, rc.permission
|
||||
FROM {context} ctx
|
||||
@ -281,6 +280,19 @@ function get_role_access($roleid) {
|
||||
ON (cctx.contextlevel = ".CONTEXT_COURSE." AND ctx.path LIKE ".$DB->sql_concat('cctx.path',"'/%'").")
|
||||
WHERE rc.roleid = ? AND cctx.id IS NULL";
|
||||
$params = array($roleid);
|
||||
*/
|
||||
|
||||
// Note: the commented out query is 100% accurate but slow, so let's cheat instead by hardcoding the blocks mess directly.
|
||||
|
||||
$sql = "SELECT COALESCE(ctx.path, bctx.path) AS path, rc.capability, rc.permission
|
||||
FROM {role_capabilities} rc
|
||||
LEFT JOIN {context} ctx ON (ctx.id = rc.contextid AND ctx.contextlevel <= ".CONTEXT_COURSE.")
|
||||
LEFT JOIN ({context} bctx
|
||||
JOIN {block_instances} bi ON (bi.id = bctx.instanceid)
|
||||
JOIN {context} pctx ON (pctx.id = bi.parentcontextid AND pctx.contextlevel < ".CONTEXT_COURSE.")
|
||||
) ON (bctx.id = rc.contextid AND bctx.contextlevel = ".CONTEXT_BLOCK.")
|
||||
WHERE rc.roleid = :roleid AND (ctx.id IS NOT NULL OR bctx.id IS NOT NULL)";
|
||||
$params = array('roleid'=>$roleid);
|
||||
|
||||
// we need extra caching in CLI scripts and cron
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user