mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-45678-006-master' of https://github.com/dbezborodovrp/moodle
This commit is contained in:
commit
207891d791
@ -46,6 +46,7 @@ $string['cachedef_coursemodinfo'] = 'Accumulated information about modules and s
|
||||
$string['cachedef_databasemeta'] = 'Database meta information';
|
||||
$string['cachedef_eventinvalidation'] = 'Event invalidation';
|
||||
$string['cachedef_externalbadges'] = 'External badges for particular user';
|
||||
$string['cachedef_get_suspended_userids'] = 'List of suspended user identifiers per course';
|
||||
$string['cachedef_gradecondition'] = 'User grades cached for evaluating conditional availability';
|
||||
$string['cachedef_groupdata'] = 'Course group information';
|
||||
$string['cachedef_htmlpurifier'] = 'HTML Purifier - cleaned content';
|
||||
|
@ -7460,11 +7460,21 @@ function extract_suspended_users($context, &$users, $ignoreusers=array()) {
|
||||
* or enrolment has expired or not started.
|
||||
*
|
||||
* @param context $context context in which user enrolment is checked.
|
||||
* @param bool $context Enable or disable (default) the request cache
|
||||
* @return array list of suspended user id's.
|
||||
*/
|
||||
function get_suspended_userids($context){
|
||||
function get_suspended_userids(context $context, $usecache = false) {
|
||||
global $DB;
|
||||
|
||||
// Check the cache first for performance reasons if enabled.
|
||||
if ($usecache) {
|
||||
$cache = cache::make('core', 'get_suspended_userids');
|
||||
$susers = $cache->get($context->id);
|
||||
if ($susers !== false) {
|
||||
return $susers;
|
||||
}
|
||||
}
|
||||
|
||||
// Get all enrolled users.
|
||||
list($sql, $params) = get_enrolled_sql($context);
|
||||
$users = $DB->get_records_sql($sql, $params);
|
||||
@ -7481,5 +7491,12 @@ function get_suspended_userids($context){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache results for the remainder of this request.
|
||||
if ($usecache) {
|
||||
$cache->set($context->id, $susers);
|
||||
}
|
||||
|
||||
// Return.
|
||||
return $susers;
|
||||
}
|
||||
|
@ -221,5 +221,12 @@ $definitions = array(
|
||||
'mode' => cache_store::MODE_SESSION,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true
|
||||
)
|
||||
),
|
||||
|
||||
// For the function get_suspended_userids() in core_access.
|
||||
'get_suspended_userids' => array(
|
||||
'mode' => cache_store::MODE_REQUEST,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
),
|
||||
);
|
||||
|
@ -1406,6 +1406,9 @@ abstract class enrol_plugin {
|
||||
$DB->update_record('user_enrolments', $ue);
|
||||
context_course::instance($instance->courseid)->mark_dirty(); // reset enrol caches
|
||||
|
||||
// Invalidate core_access cache for get_suspended_userids.
|
||||
cache_helper::invalidate_by_definition('core', 'get_suspended_userids', array(), array($instance->courseid));
|
||||
|
||||
// Trigger event.
|
||||
$event = \core\event\user_enrolment_updated::create(
|
||||
array(
|
||||
|
@ -132,9 +132,6 @@ class assign {
|
||||
/** @var bool whether to exclude users with inactive enrolment */
|
||||
private $showonlyactiveenrol = null;
|
||||
|
||||
/** @var array list of suspended user IDs in form of ([id1] => id1) */
|
||||
public $susers = null;
|
||||
|
||||
/** @var array cached list of participants for this assignment. The cache key will be group, showactive and the context id */
|
||||
private $participants = array();
|
||||
|
||||
@ -6965,10 +6962,7 @@ class assign {
|
||||
* @return bool true is user is active in course.
|
||||
*/
|
||||
public function is_active_user($userid) {
|
||||
if (is_null($this->susers) && !is_null($this->context)) {
|
||||
$this->susers = get_suspended_userids($this->context);
|
||||
}
|
||||
return !in_array($userid, $this->susers);
|
||||
return !in_array($userid, get_suspended_userids($this->context, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user