Reloads/refreshes the list of {@link User users} associated to the context.
@param contextId the ID of the context
423333
public void reloadUsers(int contextId) {
		List<User> users = usersExtension.getContextUserAuthManager(contextId).getUsers();
		User[] usersArray = users.toArray(new User[users.size()]);
		ListModel<User> usersModel = new DefaultComboBoxModel<User>(usersArray);
		this.setModel(usersModel);
	}
723774
private void releaseContext(String contextId) {
        if (mode == ContextLockingMode.DEACTIVATED) {
            return;
        }
        synchronized (activeWritingContexts) {
            activeWritingContexts.remove(contextId);
        }
    }
1125649
public void setUsers(java.util.Collection<UserData> users) {
        if (users == null) {
            this.users = null;
            return;
        }

        this.users = new java.util.ArrayList<UserData>(users);
    }
1121947
public static function preload_contexts_by_id(array $contextids) {
        global $DB;

        // Determine which contexts are not already cached.
        $tofetch = [];
        foreach ($contextids as $contextid) {
            if (!self::cache_get_by_id($contextid)) {
                $tofetch[] = $contextid;
            }
        }

        if (count($tofetch) > 1) {
            // There are at least two to fetch.
            // There is no point only fetching a single context as this would be no more efficient than calling the existing code.
            list($insql, $inparams) = $DB->get_in_or_equal($tofetch, SQL_PARAMS_NAMED);
            $ctxs = $DB->get_records_select('context', "id {$insql}", $inparams, '',
                    \context_helper::get_preload_record_columns_sql('{context}'));
            foreach ($ctxs as $ctx) {
                self::preload_from_record($ctx);
            }
        }
    }
537990
public function get_contexts_for_userid(int $userid) : contextlist_collection {
        $progress = static::get_log_tracer();

        $components = $this->get_component_list();
        $a = (object) [
            'total' => count($components),
            'progress' => 0,
            'component' => '',
            'datetime' => userdate(time()),
        ];
        $clcollection = new contextlist_collection($userid);

        $progress->output(get_string('trace:fetchcomponents', 'core_privacy', $a), 1);
        foreach ($components as $component) {
            $a->component = $component;
            $a->progress++;
            $a->datetime = userdate(time());
            $progress->output(get_string('trace:processingcomponent', 'core_privacy', $a), 2);
            $contextlist = $this->handled_component_class_callback($component, core_user_data_provider::class,
                'get_contexts_for_userid', [$userid]);
            if ($contextlist === null) {
                $contextlist = new local\request\contextlist();
            }

            // Each contextlist is tied to its respective component.
            $contextlist->set_component($component);

            // Add contexts that the component may not know about.
            // Example of these include activity completion which modules do not know about themselves.
            $contextlist = local\request\helper::add_shared_contexts_to_contextlist_for($userid, $contextlist);

            if (count($contextlist)) {
                $clcollection->add_contextlist($contextlist);
            }
        }
        $progress->output(get_string('trace:done', 'core_privacy'), 1);

        return $clcollection;
    }
1027953
public static function add_contexts_for_userid(contextlist $contextlist, $userid) {
        $sql = "
            SELECT ctx.id
              FROM {context} ctx
              JOIN {log} l
                ON (l.cmid = 0 AND l.course = ctx.instanceid AND ctx.contextlevel = :courselevel)
                OR (l.cmid > 0 AND l.cmid = ctx.instanceid AND ctx.contextlevel = :modulelevel)
                OR (l.course <= 0 AND ctx.id = :syscontextid)
             WHERE l.userid = :userid";
        $params = [
            'courselevel' => CONTEXT_COURSE,
            'modulelevel' => CONTEXT_MODULE,
            'syscontextid' => SYSCONTEXTID,
            'userid' => $userid,
        ];
        $contextlist->add_from_sql($sql, $params);
    }
251538
public void addReportingUser(String userId)
	{
		addActiveParticipant(
				userId, 
				null, 
				null, 
				true, 
				null, 
				null);
	}
593565
public void startScanAllInContext(Context context, User user) {
		Target target = new Target(context);
		target.setRecurse(true);
		this.startScan(target, user, null);
	}
1370999
public void setUserIdList(java.util.Collection<String> userIdList) {
        if (userIdList == null) {
            this.userIdList = null;
            return;
        }

        this.userIdList = new java.util.ArrayList<String>(userIdList);
    }
462522
public void setUsers(final List<User> users)
    {
        synchronized(this.getUsers())
        {
            if(users != this.getUsers())
            {
                this.getUsers().clear();
                
                if(users != null)
                {
                    this.getUsers().addAll(users);
                }
            }
        }
    }
768891
public function add_user_context(int $userid) : contextlist {
        $sql = "SELECT DISTINCT ctx.id
                  FROM {context} ctx
                 WHERE ctx.contextlevel = :contextlevel
                   AND ctx.instanceid = :instanceid";
        return $this->add_from_sql($sql, ['contextlevel' => CONTEXT_USER, 'instanceid' => $userid]);
    }
626143
protected void refresh(ApplicationContext applicationContext) {
		Assert.isInstanceOf(AbstractApplicationContext.class, applicationContext);
		((AbstractApplicationContext) applicationContext).refresh();
	}
421385
def _get_context_and_user_ids(self, context_name, user_name):
        """"""
        if context_name is None:
            return None, None

        context_id = self.get_context_info(context_name)['id']
        user_id = None
        if user_name:
            user_id = self._get_user_id_from_name(context_id, user_name)

        return context_id, user_id
919922
public static function get_contexts_for_userid(int $userid) : contextlist {
        $contextlist = new contextlist();

        // Glossary entries.
        $sql = "SELECT c.id
                  FROM {context} c
                  JOIN {course_modules} cm ON cm.id = c.instanceid AND c.contextlevel = :contextlevel
                  JOIN {modules} m ON m.id = cm.module AND m.name = :modname
                  JOIN {glossary} g ON g.id = cm.instance
                  JOIN {glossary_entries} ge ON ge.glossaryid = g.id
                 WHERE ge.userid = :glossaryentryuserid";
        $params = [
            'contextlevel' => CONTEXT_MODULE,
            'modname' => 'glossary',
            'commentarea' => 'glossary_entry',
            'glossaryentryuserid' => $userid,
        ];
        $contextlist->add_from_sql($sql, $params);

        // Where the user has rated something.
        $ratingquery = \core_rating\privacy\provider::get_sql_join('r', 'mod_glossary', 'entry', 'ge.id', $userid, true);
        $sql = "SELECT c.id
                  FROM {context} c
                  JOIN {course_modules} cm ON cm.id = c.instanceid AND c.contextlevel = :contextlevel
                  JOIN {modules} m ON m.id = cm.module AND m.name = :modname
                  JOIN {glossary} g ON g.id = cm.instance
                  JOIN {glossary_entries} ge ON ge.glossaryid = g.id
            {$ratingquery->join}
                 WHERE {$ratingquery->userwhere}";
        $params = [
            'contextlevel' => CONTEXT_MODULE,
            'modname' => 'glossary',
        ] + $ratingquery->params;
        $contextlist->add_from_sql($sql, $params);

        // Comments.
        $sql = "SELECT c.id
                  FROM {context} c
                  JOIN {course_modules} cm ON cm.id = c.instanceid AND c.contextlevel = :contextlevel
                  JOIN {modules} m ON m.id = cm.module AND m.name = :modname
                  JOIN {glossary} g ON g.id = cm.instance
                  JOIN {glossary_entries} ge ON ge.glossaryid = g.id
                  JOIN {comments} com ON com.commentarea =:commentarea AND com.itemid = ge.id
                 WHERE com.userid = :commentuserid";
        $params = [
            'contextlevel' => CONTEXT_MODULE,
            'modname' => 'glossary',
            'commentarea' => 'glossary_entry',
            'commentuserid' => $userid,
        ];
        $contextlist->add_from_sql($sql, $params);

        return $contextlist;
    }
213680
public function updateUserContext(UserContext $context): void
    {
        if ($this->session->isStarted()) {
            $context->addParameter('sessionId', $this->session->getId());
        }
    }
1031374
public void setUserList(java.util.Collection<User> userList) {
        if (userList == null) {
            this.userList = null;
            return;
        }

        this.userList = new java.util.ArrayList<User>(userList);
    }
406801
public synchronized USER remove(final ID sessionId)
	{
		final USER user = getUser(sessionId);
		if (user != null)
		{
			usersOnline.remove(user);
		}
		sessionIdToUser.remove(sessionId);
		return user;
	}