Retrieves the notifications list.

@param int  $userId
@param int  $page
@param int  $maxResult
@param bool $isRss

@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException

@return mixed
12067
public function getUserNotificationsList(User $user, $page = 1, $maxResult = -1, $isRss = false, $notificationParameters = null, $category = null)
    {
        $query = $this->getUserNotifications($user, $page, $maxResult, $isRss, $notificationParameters, false, $category);
        $adapter = new DoctrineORMAdapter($query, false);
        $pager = new Pagerfanta($adapter);
        $pager->setMaxPerPage($maxResult);

        try {
            $pager->setCurrentPage($page);
        } catch (NotValidCurrentPageException $e) {
            throw new NotFoundHttpException();
        }
        $notifications = $this->renderNotifications($pager->getCurrentPageResults());

        return [
            'pager' => $pager,
            'notificationViews' => $notifications['views'],
            'colors' => $notifications['colors'],
        ];
    }
535253
public function getLogsByUserId($id, $page = 0, $pagesize = 100, $sort = 'id', $direction = 'asc')
    {
        if(is_null($id)) {
            throw new \Exception('User ID is required.');
        }

        $result = (Object)array(
            "logs" =>  array(),
            "total" => 0
        );

        $repo = $this->getRepository('\erdiko\users\entities\user\event\Log');

        $offset = 0;
        if ($page > 0) {
            $offset = ($page - 1) * $pagesize;
        }

        $result->logs = $repo->findBy(
            array("user_id" => $id),
            array(
                $sort => $direction
            ),
            $pagesize,
            $offset
        );

        // get total log count
        $result->total = (int)$repo->createQueryBuilder('u')
            ->select('count(u.id)')
            ->where('u.user_id = :user_id')
            ->setParameter("user_id", $id)
            ->getQuery()
            ->getSingleScalarResult();

        return $result;
    }
800981
public static function list_user_plans($userid) {
        global $PAGE;
        $params = self::validate_parameters(self::list_user_plans_parameters(), array(
            'userid' => $userid
        ));

        $context = context_user::instance($params['userid']);
        self::validate_context($context);
        $output = $PAGE->get_renderer('core');

        $response = array();
        $plans = api::list_user_plans($params['userid']);
        foreach ($plans as $plan) {
            $exporter = new plan_exporter($plan, array('template' => $plan->get_template()));
            $response[] = $exporter->export($output);
        }

        return $response;
    }
807155
public function getPagedResults($limit = 50, $page = 0)
    {
        $dql = sprintf(self::DQL_GET_USERS, User::class);

        return $this->getPaginator($dql, $limit, $page);
    }
353052
function getUserList($page=0,$pagesize=10,$groupid=0){
		$send_snoopy = new Snoopy;
		$t = time().strval(mt_rand(100,999));
		$send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index&pagesize=".$pagesize."&pageidx=".$page."&type=0&groupid=0&lang=zh_CN&token=".$this->_token;
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$submit = "https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index&pagesize=".$pagesize."&pageidx=".$page."&type=0&groupid=$groupid&lang=zh_CN&f=json&token=".$this->_token;
		$send_snoopy->fetch($submit);
		$result = $send_snoopy->results;
		$this->log('userlist:'.$result);
		$json = json_decode($result,true);
		if (isset($json['contact_list'])) {
			$json = json_decode($json['contact_list'],true);
			if (isset($json['contacts']))
				return $json['contacts'];
		}
		return false;
	}
760171
public function events($username, $repository, $page = 1)
    {
        return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/events', ['page' => $page]);
    }
62013
public static function data_for_messagearea_get_most_recent_message($currentuserid, $otheruserid) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'currentuserid' => $currentuserid,
            'otheruserid' => $otheruserid
        );
        $params = self::validate_parameters(self::data_for_messagearea_get_most_recent_message_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['currentuserid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        $message = \core_message\api::get_most_recent_message($params['currentuserid'], $params['otheruserid']);
        $message = new \core_message\output\messagearea\message($message);

        $renderer = $PAGE->get_renderer('core_message');
        return $message->export_for_template($renderer);
    }
112254
public function noteListAction($resourceId, $page, User $user)
    {
        $notesQB = $this->getNoteActionManager()->getNotesForPagination($resourceId, $user);
        $pager = $this->paginateQuery($notesQB, $page);

        return array('pager' => $pager, 'resourceId' => $resourceId);
    }
350559
public static function data_for_user_evidence_list_page($userid) {
        global $PAGE;
        $params = self::validate_parameters(self::data_for_user_evidence_list_page_parameters(),
            array('userid' => $userid));

        $context = context_user::instance($params['userid']);
        self::validate_context($context);
        $output = $PAGE->get_renderer('tool_lp');

        $renderable = new \tool_lp\output\user_evidence_list_page($params['userid']);
        return $renderable->export_for_template($output);
    }
717763
public function readByUser(int $userId, int $expirationInSeconds, int $limit = null): array
    {
        try {
            /** @var TokenInterface[] $tokens */
            $tokens = parent::readByUser($userId, $expirationInSeconds, $limit);

            // select scope identifiers for tokens
            if (empty($tokens) === false) {
                $schema        = $this->getDatabaseSchema();
                $tokenIdColumn = $schema->getTokensScopesTokenIdentityColumn();
                $scopeIdColumn = $schema->getTokensScopesScopeIdentityColumn();

                $connection = $this->getConnection();
                $query      = $connection->createQueryBuilder();

                $tokenIds = array_keys($tokens);
                $query
                    ->select([$tokenIdColumn, $scopeIdColumn])
                    ->from($schema->getTokensScopesTable())
                    ->where($query->expr()->in($tokenIdColumn, $tokenIds))
                    ->orderBy($tokenIdColumn);

                $statement = $query->execute();
                $statement->setFetchMode(PDO::FETCH_ASSOC);
                $tokenScopePairs = $statement->fetchAll();

                $curTokenId = null;
                $curScopes  = null;
                // set selected scopes to tokens
                foreach ($tokenScopePairs as $pair) {
                    $tokenId = $pair[$tokenIdColumn];
                    $scopeId = $pair[$scopeIdColumn];

                    if ($curTokenId !== $tokenId) {
                        $assignScopes = $curTokenId !== null && empty($curScopes) === false;
                        $assignScopes ? $tokens[$curTokenId]->setScopeIdentifiers($curScopes) : null;
                        $curTokenId = $tokenId;
                        $curScopes  = [$scopeId];

                        continue;
                    }

                    $curScopes[] = $scopeId;
                }
                $curTokenId === null || empty($curScopes) === true ?:
                    $tokens[$curTokenId]->setScopeIdentifiers($curScopes);
            }

            return $tokens;
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (RepositoryException | DBALEx $exception) {
            $message = 'Token reading failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
38866
public static function fetch_notifications($contextid) {
        global $PAGE;

        self::validate_parameters(self::fetch_notifications_parameters(), [
                'contextid' => $contextid,
            ]);

        $context = \context::instance_by_id($contextid);
        self::validate_context($context);

        return \core\notification::fetch_as_array($PAGE->get_renderer('core'));
    }
990993
public function subjectsAction(Category $category, $page, $max)
    {
        $forum = $category->getForum();
        $this->checkAccess($forum);
        $pager = $this->manager->getSubjectsPager($category, $page, $max);

        $subjectsIds = array();
        $lastMessages = array();

        foreach ($pager as $subject) {
            $subjectsIds[] = $subject['id'];
        }
        $messages = $this->manager->getLastMessagesBySubjectsIds($subjectsIds);

        foreach ($messages as $message) {
            $lastMessages[$message->getSubject()->getId()] = $message;
        }
        $collection = new ResourceCollection(array($forum->getResourceNode()));
        $isAnon = $this->isAnon();
        $canCreateSubject = $this->authorization->isGranted('post', $collection);
        $isModerator = $this->authorization->isGranted('moderate', $collection) &&
            !$isAnon;

        $logs = array();

        if (!$isAnon) {
            $securityToken = $this->tokenStorage->getToken();

            if (!is_null($securityToken)) {
                $user = $securityToken->getUser();
                $logs = $this->manager->getSubjectsReadingLogs($user, $forum->getResourceNode());
            }
        }
        $lastAccessDates = array();

        foreach ($logs as $log) {
            $details = $log->getDetails();
            $subjectId = $details['subject']['id'];

            if (!isset($lastAccessDates[$subjectId])) {
                $lastAccessDates[$subjectId] = $log->getDateLog();
            }
        }

        return array(
            'pager' => $pager,
            '_resource' => $forum,
            'canCreateSubject' => $canCreateSubject,
            'isModerator' => $isModerator,
            'category' => $category,
            'max' => $max,
            'lastMessages' => $lastMessages,
            'workspace' => $forum->getResourceNode()->getWorkspace(),
            'lastAccessDates' => $lastAccessDates,
            'isAnon' => $isAnon
        );
    }
54969
public function getNotificationFeed($user_id)
    {
        $user_feed = $this->config->get("stream-laravel::notification_feed");
        return $this->client->feed($user_feed, $user_id);
    }
910866
public function GetNotifications($NotifyUserID, $Offset = '0', $Limit = '30') {
      $this->ActivityQuery(FALSE);
      $this->FireEvent('BeforeGetNotifications');
      $Result = $this->SQL
         ->Where('NotifyUserID', $NotifyUserID)
         ->Limit($Limit, $Offset)
         ->OrderBy('a.ActivityID', 'desc')
         ->Get();
      $Result->DatasetType(DATASET_TYPE_ARRAY);
      
      self::GetUsers($Result->ResultArray());
      Gdn::UserModel()->JoinUsers($Result->ResultArray(), array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Photo', 'Email', 'Gender')));
      $this->CalculateData($Result->ResultArray());
      
      return $Result;
   }
1035010
public function transform($events, $eventsCount, $page, $maxPerPage)
    {
        $pageCount = count($events);
        $eventsCollection = new EventCollectionObjectRepresentation(
            (int) $page,
            (int) $maxPerPage,
            (int) $numberOfPages = ceil($eventsCount/$maxPerPage),
            (int) $eventsCount,
            $this->calculateLinks($page, $numberOfPages)
        );
        foreach ($events as $event) {
            $eventsCollection->addEvent(new EventObjectRepresentation($event));
        }

        $response = new Response(
            $this->serializer->serialize(
                [
                    $eventsCollection
                ], 'xml'),
            $this->getHttpStatusCode($pageCount)
        );

        $response->headers->set('Content-type', 'text/xml');
        $response->setCharset('utf-8');

        // set infinite cache if page is complete
        if ($maxPerPage === $pageCount) {
            $response
                ->setMaxAge(60 * 60 * 24 * 365)
                ->setSharedMaxAge(60 * 60 * 24 * 365);
        }

        return $response;
    }
1070235
public function getUsersByRoles(array $roles, $page = 1, $max = 20)
    {
        $res = $this->userRepo->findByRoles($roles, true);

        return $this->pagerFactory->createPager($res, $page, $max);
    }
847294
public function getAllUsersExcept($page, $max = 20, $orderedBy = 'id', $order = null, array $users )
    {
        $query = $this->userRepo->findAllExcept($users);
        return $this->pagerFactory->createPagerFromArray($query, $page, $max);
    }