Returns Collection of User Ratings and Reviews.

@param string $userId

@return ArrayCollection
170968
public function getReviewAndRatingList($userId)
    {
        $reviewAndRatingList = $this->getMergedReviewAndRatingList($userId);
        $reviewAndRatingList = $this->sortReviewAndRatingList($reviewAndRatingList);

        return $reviewAndRatingList;
    }
959389
private function getMergedReviewAndRatingList($userId)
    {
        $reviews = $this->userReviewService->getReviews($userId);
        $ratings = $this->userRatingService->getRatings($userId);

        return $this
            ->reviewAndRatingMergingService
            ->mergeReviewAndRating($reviews, $ratings);
    }
888021
public static function get_course_grades($userid = 0) {
        global $USER;

        $warnings = array();

        // Validate the parameter.
        $params = self::validate_parameters(self::get_course_grades_parameters(),
            array(
                'userid' => $userid
            )
        );

        $userid = $params['userid'];
        if (empty($userid)) {
            $userid = $USER->id;
        }

        $systemcontext = context_system::instance();
        self::validate_context($systemcontext);

        if ($USER->id != $userid) {
            // We must check if the current user can view other users grades.
            $user = core_user::get_user($userid, '*', MUST_EXIST);
            core_user::require_active_user($user);
            require_capability('moodle/grade:viewall', $systemcontext);
        }

        // We need the site course, and course context.
        $course = get_course(SITEID);
        $context = context_course::instance($course->id);

        // Force a regrade if required.
        grade_regrade_final_grades_if_required($course);
        // Get the course final grades now.
        $gpr = new grade_plugin_return(array('type' => 'report', 'plugin' => 'overview', 'courseid' => $course->id,
                                        'userid' => $userid));
        $report = new grade_report_overview($userid, $gpr, $context);
        $coursesgrades = $report->setup_courses_data(true);

        $grades = array();
        foreach ($coursesgrades as $coursegrade) {
            $gradeinfo = array(
                'courseid' => $coursegrade['course']->id,
                'grade' => grade_format_gradevalue($coursegrade['finalgrade'], $coursegrade['courseitem'], true),
                'rawgrade' => $coursegrade['finalgrade'],
            );
            if (isset($coursegrade['rank'])) {
                $gradeinfo['rank'] = $coursegrade['rank'];
            }
            $grades[] = $gradeinfo;
        }

        $result = array();
        $result['grades'] = $grades;
        $result['warnings'] = $warnings;
        return $result;
    }
41339
public function getReviewList()
    {
        $currentPage = $this->getActPage();
        $itemsPerPage = $this->getItemsPerPage();
        $offset = $currentPage * $itemsPerPage;

        $userId = $this->getUser()->getId();

        $reviewModel = oxNew(Review::class);
        $reviewAndRatingList = $reviewModel->getReviewAndRatingListByUserId($userId);

        return $this->getPaginatedReviewAndRatingList(
            $reviewAndRatingList,
            $itemsPerPage,
            $offset
        );
    }
290607
public function index($userId)
    {
        $user = User::with('addresses')
            ->findOrFail($userId);
        $this->authorize('view', $user);
        return fractal($user->addresses, new AddressTransformer())
            ->withResourceName('userAddress')
            ->respond();
    }
54309
public function index($userId)
    {
        $user = User::with('phones')
            ->findOrFail($userId);
        $this->authorize('view', $user);
        return fractal($user->phones, new PhoneTransformer())
            ->withResourceName('userPhone')
            ->respond();
    }
787264
protected static function filterRecursive($items, $userId)
    {
        $result = [];
        foreach ($items as $i => $item) {
            $allow = false;
            if (is_array($item) && isset($item['url']) && isset($item['url'][0])) {
                $allow = static::checkRoute($userId, $item['url'][0]);
            } else {
                $allow = true;
            }
            if (isset($item['items']) && is_array($item['items'])) {
                $subItems = self::filterRecursive($item['items'], $userId);
                if (count($subItems)) {
                    $allow = true;
                }
                $item['items'] = $subItems;
            }
            if ($allow) {
                $result[$i] = $item;
            }
        }
        return $result;
    }
554998
public function reviews()
    {
        if (is_null($this->reviewRequests)) {
            $this->reviewRequests = new ReviewRequests($this->client);
        }

        return $this->reviewRequests;
    }
826852
public static function get_unread_conversation_counts(int $userid) : array {
        global $DB;

        // Get all conversations the user is in, and check unread.
        $unreadcountssql = 'SELECT conv.id, conv.type, indcounts.unreadcount
                              FROM {message_conversations} conv
                        INNER JOIN (
                                      SELECT m.conversationid, count(m.id) as unreadcount
                                        FROM {messages} m
                                  INNER JOIN {message_conversations} mc
                                          ON mc.id = m.conversationid
                                  INNER JOIN {message_conversation_members} mcm
                                          ON m.conversationid = mcm.conversationid
                                   LEFT JOIN {message_user_actions} mua
                                          ON (mua.messageid = m.id AND mua.userid = ? AND
                                             (mua.action = ? OR mua.action = ?))
                                       WHERE mcm.userid = ?
                                         AND m.useridfrom != ?
                                         AND mua.id is NULL
                                    GROUP BY m.conversationid
                                   ) indcounts
                                ON indcounts.conversationid = conv.id
                             WHERE conv.enabled = 1';

        $unreadcounts = $DB->get_records_sql($unreadcountssql, [$userid, self::MESSAGE_ACTION_READ, self::MESSAGE_ACTION_DELETED,
            $userid, $userid]);

        // Get favourites, so we can track these separately.
        $service = \core_favourites\service_factory::get_service_for_user_context(\context_user::instance($userid));
        $favouriteconversations = $service->find_favourites_by_type('core_message', 'message_conversations');
        $favouriteconvids = array_flip(array_column($favouriteconversations, 'itemid'));

        // Assemble the return array.
        $counts = ['favourites' => 0, 'types' => [
            self::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL => 0,
            self::MESSAGE_CONVERSATION_TYPE_GROUP => 0,
            self::MESSAGE_CONVERSATION_TYPE_SELF => 0
        ]];
        foreach ($unreadcounts as $convid => $info) {
            if (isset($favouriteconvids[$convid])) {
                $counts['favourites']++;
                continue;
            }
            $counts['types'][$info->type]++;
        }

        return $counts;
    }
28351
public function listRepositories($userId = null)
    {
        $parameters = [];
        if ($userId) {
            $parameters['user_id'] = $userId;
        }

        return $this->get('/installation/repositories', $parameters);
    }
437438
static function fetchListForUser( $userID )
    {
        return eZPersistentObject::fetchObjectList( eZContentBrowseRecent::definition(),
                                                    null, array( 'user_id' => $userID ),
                                                    array( 'created' => 'desc' ), null, true );
    }
692543
private function getRatingWithoutReviewData(ArrayCollection $reviews, ArrayCollection $ratings)
    {
        $ratingList = [];

        foreach ($ratings as $rating) {
            if ($this->isRatingWithoutReview($rating, $reviews)) {
                $ratingList[] = [
                    'ratingId'      => $rating->getId(),
                    'reviewId'      => false,
                    'rating'        => $rating->getRating(),
                    'text'          => '',
                    'objectId'      => $rating->getObjectId(),
                    'objectType'    => $rating->getType(),
                    'createdAt'     => $rating->getCreatedAt(),
                ];
            }
        }

        return $ratingList;
    }
1104263
public function listMonetaryAccounts($userId)
    {
        $monetaryAccounts = $this->client->get($this->getResourceEndpoint($userId));

        return $monetaryAccounts;
    }
1063137
public function setHasRespondents($userId)
    {
        if (! $this->_get('gor_has_respondents')) {
            $values['gor_has_respondents'] = 1;
            $values['gor_changed']         = new \MUtil_Db_Expr_CurrentTimestamp();
            $values['gor_changed_by']      = $userId;

            $where = $this->db->quoteInto('gor_id_organization = ?', $this->_id);

            $this->db->update('gems__organizations', $values, $where);

            // Invalidate cache / change value
            $this->_set('gor_has_respondents', 1);
        }

        return $this;
    }
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
                );
            }
        }
    }
1018539
public static function get_contexts_for_userid(int $userid) : contextlist {
        $contextlist = new contextlist();

        $contextlist->add_from_sql('SELECT ctx.id
            FROM {modules} m
            JOIN {course_modules} cm ON cm.module = m.id AND m.name = :modname
            JOIN {context} ctx ON ctx.instanceid = cm.id AND ctx.contextlevel = :contextlevel
            JOIN {wiki_subwikis} s ON cm.instance = s.wikiid
            LEFT JOIN {wiki_pages} p ON p.subwikiid = s.id
            LEFT JOIN {wiki_versions} v ON v.pageid = p.id AND v.userid = :userid3
            LEFT JOIN {wiki_locks} l ON l.pageid = p.id AND l.userid = :userid4
            LEFT JOIN {comments} com ON com.itemid = p.id AND com.commentarea = :commentarea
                AND com.contextid = ctx.id AND com.userid = :userid5
            WHERE s.userid = :userid1 OR p.userid = :userid2 OR v.id IS NOT NULL OR l.id IS NOT NULL OR com.id IS NOT NULL',
            ['modname' => 'wiki', 'contextlevel' => CONTEXT_MODULE, 'userid1' => $userid, 'userid2' => $userid,
                'userid3' => $userid, 'userid4' => $userid, 'commentarea' => 'wiki_page', 'userid5' => $userid]);

        return $contextlist;
    }
501014
public static function fetchUserCapabilities(string $userId): array
    {
        $entities = [];

        if (array_key_exists($userId, static::$userCapabilities)) {
            return static::$userCapabilities[$userId];
        }

        $table = TableRegistry::get('RolesCapabilities.Capabilities');
        Assert::isInstanceOf($table, CapabilitiesTable::class);

        $userGroups = $table->getUserGroups($userId);
        if (empty($userGroups)) {
            return $entities;
        }

        $userRoles = $table->getGroupsRoles($userGroups);
        if (empty($userRoles)) {
            return $entities;
        }

        static::$userCapabilities[$userId] = $table->getUserRolesEntities($userRoles);

        return static::$userCapabilities[$userId];
    }