Export all user preferences for the subsystem.

@param int $userid The ID of the user whose data is to be exported.
335104
public static function export_user_preferences(int $userid) {

        $preference = get_user_preferences('filemanager_recentviewmode');

        if ($preference !== null) {
            switch ($preference) {
                case 1:
                    $value = get_string('displayasicons', 'core_repository');
                    break;
                case 2:
                    $value = get_string('displayastree', 'core_repository');
                    break;
                case 3:
                    $value = get_string('displaydetails', 'core_repository');
                    break;
                default:
                    $value = $preference;
            }

            $desc = get_string('privacy:preference:filemanager_recentviewmode', 'core_form', $value);
            writer::export_user_preference('core_form', 'filemanager_recentviewmode', $preference, $desc);
        }
    }
675428
public function addUser($id, $userId)
    {
        $xml = new \SimpleXMLElement('<?xml version="1.0"?><user_id>'.$userId.'</user_id>');

        return $this->post('/groups/'.$id.'/users.xml', $xml->asXML());
    }
618525
public function removeUserById($userId)
    {
        $updtableProperties = Updatable::getInstance()
            ->table($this->getUserPropertiesDefinition()->table())
            ->where(
                "{$this->getUserPropertiesDefinition()->getUserid()} = :id",
                [
                    "id" => $userId
                ]
            );
        $this->propertiesRepository->deleteByQuery($updtableProperties);

        $this->userRepository->delete($userId);

        return true;
    }
894183
public static function export_user_preferences(int $userid) {
        $preferences = get_user_preferences(null, null, $userid);
        foreach ($preferences as $name => $value) {
            if (
                (substr($name, 0, 16) == 'message_provider') ||
                ($name == 'message_blocknoncontacts') ||
                ($name == 'message_entertosend')
            ) {
                writer::export_user_preference(
                    'core_message',
                    $name,
                    $value,
                    get_string('privacy:request:preference:set', 'core_message', (object) [
                        'name' => $name,
                        'value' => $value,
                    ])
                );
            }
        }
    }
788874
public static function export_user_preferences(int $userid) {

        $yesno = function($v) {
            return transform::yesno($v);
        };
        $datetime = function($v) {
            return $v ? transform::datetime($v) : null;
        };

        $prefs = [
            ['auth_forcepasswordchange', 'forcepasswordchange', $yesno],
            ['create_password', 'createpassword', $yesno],
            ['login_failed_count', 'loginfailedcount', null],
            ['login_failed_count_since_success', 'loginfailedcountsincesuccess', null],
            ['login_failed_last', 'loginfailedlast', $datetime],
            ['login_lockout', 'loginlockout', $datetime],
            ['login_lockout_ignored', 'loginlockoutignored', $yesno],
            ['login_lockout_secret', 'loginlockoutsecret', null],
        ];

        foreach ($prefs as $prefdata) {
            list($prefname, $langkey, $transformer) = $prefdata;
            $value = get_user_preferences($prefname, null, $userid);
            if ($value === null) {
                continue;
            }
            writer::export_user_preference('core_auth', $prefname, $transformer ? $transformer($value) : $value,
                get_string("privacy:metadata:userpref:{$langkey}", 'core_auth'));
        }
    }
1014980
public function deleteUserLoginTokenFields($userID) {
        $user = $this->getFind($userID);

        $user->login_token            = '';
        $user->login_token_created_at = '';

        return $user->save();
    }
29521
protected static function export_user_devices(int $userid, \context $context) {
        global $DB;
        $records = $DB->get_records('user_devices', ['userid' => $userid]);
        if (!empty($records)) {
            $userdevices = (object) array_map(function($record) {
                return [
                    'appid' => $record->appid,
                    'name' => $record->name,
                    'model' => $record->model,
                    'platform' => $record->platform,
                    'version' => $record->version,
                    'timecreated' => transform::datetime($record->timecreated),
                    'timemodified' => transform::datetime($record->timemodified)
                ];
            }, $records);
            writer::with_context($context)->export_data([get_string('privacy:devicespath', 'user')], $userdevices);
        }
    }
1226836
public static function export_user_preferences(int $userid) {
        $preferences = get_user_preferences();
        foreach ($preferences as $name => $value) {
            $prefname = null;
            $prefdescription = null;
            $transformedvalue = null;
            switch ($name) {
                case 'grade_report_showcalculations':
                case 'grade_report_showeyecons':
                case 'grade_report_showaverages':
                case 'grade_report_showlocks':
                case 'grade_report_showuserimage':
                case 'grade_report_showactivityicons':
                case 'grade_report_showranges':
                case 'grade_report_showanalysisicon':
                case 'grade_report_shownumberofgrades':
                case 'grade_report_quickgrading':
                case 'grade_report_showonlyactiveenrol':
                case 'grade_report_showquickfeedback':
                case 'grade_report_enableajax':
                    $prefname = $name;
                    $transformedvalue = transform::yesno($value);
                    break;
                case 'grade_report_meanselection':
                    $prefname = $name;
                    switch ($value) {
                        case GRADE_REPORT_MEAN_ALL:
                            $transformedvalue = get_string('meanall', 'grades');
                            break;
                        case GRADE_REPORT_MEAN_GRADED:
                            $transformedvalue = get_string('meangraded', 'grades');
                            break;
                    }
                    break;
                case 'grade_report_rangesdecimalpoints':
                case 'grade_report_averagesdecimalpoints':
                case 'grade_report_studentsperpage':
                    $prefname = $name;
                    $transformedvalue = $value;
                    break;
                case 'grade_report_rangesdisplaytype':
                case 'grade_report_averagesdisplaytype':
                    $prefname = $name;
                    switch ($value) {
                        case GRADE_REPORT_PREFERENCE_INHERIT:
                            $transformedvalue = get_string('inherit', 'grades');
                            break;
                        case GRADE_DISPLAY_TYPE_REAL:
                            $transformedvalue = get_string('real', 'grades');
                            break;
                        case GRADE_DISPLAY_TYPE_PERCENTAGE:
                            $transformedvalue = get_string('percentage', 'grades');
                            break;
                        case GRADE_DISPLAY_TYPE_LETTER:
                            $transformedvalue = get_string('letter', 'grades');
                            break;
                    }
                    break;
                case 'grade_report_aggregationposition':
                    $prefname = $name;
                    switch ($value) {
                        case GRADE_REPORT_AGGREGATION_POSITION_FIRST:
                            $transformedvalue = get_string('positionfirst', 'grades');
                            break;
                        case GRADE_REPORT_AGGREGATION_POSITION_LAST:
                            $transformedvalue = get_string('positionlast', 'grades');
                            break;
                    }
                    break;
                default:
                    if (strpos($name, 'grade_report_grader_collapsed_categories') === 0) {
                        $prefname = 'grade_report_grader_collapsed_categories';
                        $courseid = substr($name, strlen('grade_report_grader_collapsed_categories'));
                        $transformedvalue = $value;
                        $course = get_course($courseid);
                        $prefdescription = get_string(
                            'privacy:request:preference:'.$prefname,
                            'gradereport_grader',
                            (object) [
                                'name' => $course->fullname,
                            ]
                        );
                    }
            }

            if ($prefname !== null) {
                if ($prefdescription == null) {
                    $prefdescription = get_string('privacy:metadata:preference:'.$prefname, 'gradereport_grader');
                }
                writer::export_user_preference(
                    'gradereport_grader',
                    $prefname,
                    $transformedvalue,
                    $prefdescription
                );
            }
        }
    }
1075477
public static function export_user_preferences(int $userid) {
        $calendarsavedflt = get_user_preferences('calendar_savedflt', null, $userid);

        if (null !== $calendarsavedflt) {
            writer::export_user_preference(
                'core_calendar',
                'calendarsavedflt',
                $calendarsavedflt,
                get_string('privacy:metadata:calendar:preferences:calendar_savedflt', 'core_calendar')
            );
        }
    }
945869
public function getUserPreferenceByUserIdAndName(int $userId, string $name): UserPreference
    {
        $userPreference = $this->mapper->extractUserPreferencesFromRows(
            $this->gateway->getUserPreferenceByUserIdAndName($userId, $name)
        );

        if (count($userPreference) < 1) {
            throw new NotFoundException('User Preference', $userId . ',' . $name);
        }

        return reset($userPreference);
    }
992621
public final function set_user_config($config, $userid=0) {
        global $DB;

        if (empty($userid)) {
            $userid = $this->user->id;
        }

        foreach ($config as $key => $value) {
            if ($key != 'visible' && !in_array($key, $this->get_allowed_user_config())) {
                $a = (object)array('property' => $key, 'class' => get_class($this));
                throw new portfolio_export_exception($this->get('exporter'), 'invaliduserproperty', 'portfolio', null, $a);
            }
            if (!$existing = $DB->get_record('portfolio_instance_user', array('instance'=> $this->id, 'userid' => $userid, 'name' => $key))) {
                $DB->insert_record('portfolio_instance_user', (object)array(
                    'instance' => $this->id,
                    'name' => $key,
                    'value' => $value,
                    'userid' => $userid,
                ));
            } else if ($existing->value != $value) {
                $DB->set_field('portfolio_instance_user', 'value', $value, array('name' => $key, 'instance' => $this->id, 'userid' => $userid));
            }
            $this->userconfig[$userid]->{$key} = $value;
        }

    }
407845
public static function export_user_preferences(int $userid) {
        $preference = get_user_preferences('quiz_overview_slotmarks', null);
        if (null !== $preference) {
            if (empty($preference)) {
                $description = get_string('privacy:preference:slotmarks:no', 'quiz_overview');
            } else {
                $description = get_string('privacy:preference:slotmarks:yes', 'quiz_overview');
            }

            writer::export_user_preference(
                'quiz_overview',
                'slotmarks',
                transform::yesno($preference),
                $description
            );
        }
    }
171021
public function loadRoleAssignmentsForUser($userId)
    {
        $user = $this->userService->loadUser($userId);

        $roleAssignments = $this->roleService->getRoleAssignmentsForUser($user);

        return new Values\RoleAssignmentList($roleAssignments, $user->id);
    }
1301337
protected static function delete_data(int $userid) {
        global $DB;

        foreach (static::get_records($userid) as $record) {
            $DB->delete_records('message_airnotifier_devices', ['id' => $record->id]);
        }
    }
1237856
public function setUserId( $userId )
    {
        $this->_user    = null;
        $this->userId   = ( (int) $userId ) ?: null;
        return $this;
    }
1062065
protected static function export_user_data_in_system_context($userid) {
        static::export_user_data_frameworks_in_context($userid, context_system::instance());
        static::export_user_data_templates_in_context($userid, context_system::instance());
    }
212113
public function delete($userid)
	{
		$event = new Event('onPlatformUserDelete');
		$event->addArgument('userid', $userid);
		$event->addArgument('activePlugin', $this->activePlugin);

		Factory::getDispatcher()->triggerEvent($event);

		$debug = $event->getArgument('debug', null);
		if ($debug) {
			$this->debug[] = $debug;
		}

		$error = $event->getArgument('error', null);
		if ($error) {
			$this->error[] = $error;
		}
	}