mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
Merge branch 'MDL-63785-master' of git://github.com/rezaies/moodle
This commit is contained in:
commit
f706dabd50
@ -161,18 +161,10 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {mnet_log} ml
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = ml.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {mnet_log}
|
||||
WHERE userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -99,18 +99,10 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {auth_oauth2_linked_login} ao
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = ao.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {auth_oauth2_linked_login}
|
||||
WHERE userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -105,18 +105,10 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT bc.userid as userid
|
||||
FROM {block_community} bc
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = bc.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {block_community}
|
||||
WHERE userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -98,22 +98,25 @@ class provider implements
|
||||
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
|
||||
*/
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
// This block doesn't know who information is stored against unless it
|
||||
// is at the user context.
|
||||
$context = $userlist->get_context();
|
||||
|
||||
if (!is_a($context, \context_block::class)) {
|
||||
if (!$context instanceof \context_block) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT bpc.instanceid AS userid
|
||||
FROM {context} c
|
||||
JOIN {block_instances} bi ON bi.id = c.instanceid AND bi.blockname = 'html'
|
||||
JOIN {context} bpc ON bpc.id = bi.parentcontextid AND bpc.contextlevel = :contextuser
|
||||
WHERE c.id = :contextid";
|
||||
FROM {block_instances} bi
|
||||
JOIN {context} bpc ON bpc.id = bi.parentcontextid
|
||||
WHERE bi.blockname = 'html'
|
||||
AND bpc.contextlevel = :contextuser
|
||||
AND bi.id = :blockinstanceid";
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'blockinstanceid' => $context->instanceid
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
@ -98,18 +98,10 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT brc.userid as userid
|
||||
FROM {block_rss_client} brc
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = brc.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {block_rss_client}
|
||||
WHERE userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -105,20 +105,11 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextcourse' => CONTEXT_COURSE,
|
||||
];
|
||||
|
||||
$sql = "SELECT ue.userid as userid
|
||||
FROM {user_enrolments} ue
|
||||
JOIN {enrol} e
|
||||
ON e.id = ue.enrolid
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = e.courseid
|
||||
AND ctx.contextlevel = :contextcourse
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
JOIN {enrol} e ON e.id = ue.enrolid
|
||||
WHERE e.courseid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -105,20 +105,11 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT ud.userid as userid
|
||||
$sql = "SELECT ud.userid
|
||||
FROM {message_airnotifier_devices} mad
|
||||
JOIN {user_devices} ud
|
||||
ON ud.id = mad.userdeviceid
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = ud.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
JOIN {user_devices} ud ON ud.id = mad.userdeviceid
|
||||
WHERE ud.userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -113,27 +113,16 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {portfolio_instance_user} piu
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = piu.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
$params = [$context->instanceid];
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {portfolio_instance_user}
|
||||
WHERE userid = ?";
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {portfolio_log} pl
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = pl.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$sql = "SELECT userid
|
||||
FROM {portfolio_log}
|
||||
WHERE userid = ?";
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -109,15 +109,10 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT c.instanceid as userid
|
||||
FROM {repository_instances} ri
|
||||
JOIN {context} c ON c.instanceid = ri.userid AND c.contextlevel = :contextuser
|
||||
WHERE c.id = :contextid";
|
||||
$sql = "SELECT userid
|
||||
FROM {repository_instances}
|
||||
WHERE userid = ?";
|
||||
$params = [$context->instanceid];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
@ -111,21 +111,15 @@ class provider implements
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
$context = $userlist->get_context();
|
||||
|
||||
if (!is_a($context, \context_user::class)) {
|
||||
if (!$context instanceof \context_user) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The data is associated at the user context level, so retrieve the user's context id.
|
||||
$sql = "SELECT roa.usermodified AS userid
|
||||
FROM {repository_onedrive_access} roa
|
||||
JOIN {context} c ON c.instanceid = roa.usermodified AND c.contextlevel = :contextuser
|
||||
WHERE c.id = :contextid";
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
];
|
||||
|
||||
$sql = "SELECT usermodified AS userid
|
||||
FROM {repository_onedrive_access}
|
||||
WHERE usermodified = ?";
|
||||
$params = [$context->instanceid];
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -213,16 +213,7 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
|
||||
$sql = "SELECT instanceid as userid
|
||||
FROM {context}
|
||||
WHERE id = :contextid and contextlevel = :contextuser";
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
$userlist->add_user($context->instanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,22 +95,18 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
'datatype' => 'checkbox'
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
$sql = "SELECT uda.userid
|
||||
FROM {user_info_data} uda
|
||||
JOIN {user_info_field} uif
|
||||
ON uda.fieldid = uif.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = uda.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid
|
||||
WHERE uda.userid = :userid
|
||||
AND uif.datatype = :datatype";
|
||||
|
||||
$params = [
|
||||
'userid' => $context->instanceid,
|
||||
'datatype' => 'checkbox'
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -96,22 +96,18 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
'datatype' => 'datetime'
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
$sql = "SELECT uda.userid
|
||||
FROM {user_info_data} uda
|
||||
JOIN {user_info_field} uif
|
||||
ON uda.fieldid = uif.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = uda.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid
|
||||
WHERE uda.userid = :userid
|
||||
AND uif.datatype = :datatype";
|
||||
|
||||
$params = [
|
||||
'userid' => $context->instanceid,
|
||||
'datatype' => 'datetime'
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -95,22 +95,18 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
'datatype' => 'menu'
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
$sql = "SELECT uda.userid
|
||||
FROM {user_info_data} uda
|
||||
JOIN {user_info_field} uif
|
||||
ON uda.fieldid = uif.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = uda.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid
|
||||
WHERE uda.userid = :userid
|
||||
AND uif.datatype = :datatype";
|
||||
|
||||
$params = [
|
||||
'userid' => $context->instanceid,
|
||||
'datatype' => 'menu'
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -95,22 +95,18 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
'datatype' => 'text'
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
$sql = "SELECT uda.userid
|
||||
FROM {user_info_data} uda
|
||||
JOIN {user_info_field} uif
|
||||
ON uda.fieldid = uif.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = uda.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid
|
||||
WHERE uda.userid = :userid
|
||||
AND uif.datatype = :datatype";
|
||||
|
||||
$params = [
|
||||
'userid' => $context->instanceid,
|
||||
'datatype' => 'text'
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -95,22 +95,18 @@ class provider implements
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'contextuser' => CONTEXT_USER,
|
||||
'contextid' => $context->id,
|
||||
'datatype' => 'textarea'
|
||||
];
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
$sql = "SELECT uda.userid
|
||||
FROM {user_info_data} uda
|
||||
JOIN {user_info_field} uif
|
||||
ON uda.fieldid = uif.id
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = uda.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid
|
||||
WHERE uda.userid = :userid
|
||||
AND uif.datatype = :datatype";
|
||||
|
||||
$params = [
|
||||
'userid' => $context->instanceid,
|
||||
'datatype' => 'textarea'
|
||||
];
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
|
@ -115,39 +115,23 @@ class provider implements
|
||||
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
|
||||
*/
|
||||
public static function get_users_in_context(userlist $userlist) {
|
||||
global $DB;
|
||||
|
||||
$context = $userlist->get_context();
|
||||
|
||||
$params = [
|
||||
'contextid' => $context->id,
|
||||
'contextuser' => CONTEXT_USER,
|
||||
];
|
||||
if (!$context instanceof \context_user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {external_tokens} t
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = t.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
$userid = $context->instanceid;
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
$hasdata = false;
|
||||
$hasdata = $hasdata || $DB->record_exists_select('external_tokens', 'userid = ? OR creatorid = ?', [$userid, $userid]);
|
||||
$hasdata = $hasdata || $DB->record_exists('external_services_users', ['userid' => $userid]);
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {external_tokens} t
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = t.creatorid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
|
||||
$sql = "SELECT ctx.instanceid as userid
|
||||
FROM {external_services_users} su
|
||||
JOIN {context} ctx
|
||||
ON ctx.instanceid = su.userid
|
||||
AND ctx.contextlevel = :contextuser
|
||||
WHERE ctx.id = :contextid";
|
||||
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
if ($hasdata) {
|
||||
$userlist->add_user($userid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user