Return count of shares by $type according to $user
@param number|unknown $type
@param number|unknown $user
320562
public function getSharesByUser($type, $user)
    {
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');

        switch ($type) {
            case 'shares':
                $filter = "e.action IN (13,14,15,16,17) AND e.label like '%espace client%'";
                break;
            case 'fbShares':
                $filter = "e.action IN (14,15) AND e.label like '%espace client%'";
                break;
            case 'twShares':
                $filter = "e.action=16 AND e.label like '%espace client%'";
                break;
            case 'glShares':
                $filter = "e.action=17 AND e.label like '%espace client%'";
                break;
            case 'mailShares':
                $filter = "e.action=13 AND e.label like '%espace client%'";
                break;
        }

        $query = $em->createQuery('
            SELECT COUNT(e.id) FROM PlaygroundReward\Entity\Event e
            WHERE e.user = :user
			AND ' . $filter . '
		');
        $query->setParameter('user', $user);
        $count = $query->getSingleScalarResult();
        return $count;
    }
1149451
public function countUnviewedNotifications(User $viewer = null)
    {
        if (empty($viewer)) {
            $viewer = $this->tokenStorage->getToken()->getUser();
        }
        $notificationParameters = $this->notificationParametersManager->getParametersByUser($viewer);

        return intval($this->getNotificationViewerRepository()->countUnviewedNotifications($viewer->getId(), $notificationParameters->getDisplayEnabledTypes())['total']);
    }
105240
public function shareAction(Request $request, User $user = null)
    {
        $share = new ShareAction();
        $share->setUser($user);
        $network = $request->get('network');
        $options = $this->getShareActionManager()->createShare($request, $share);
        $this->dispatchShareEvent($share);

        $response = array();
        if ($network !== null) {
            $socialShare = new SocialShare();
            $shareLink = $socialShare->getNetwork($network)->getShareLink($options['url'], array($options['title']));
            $response = new RedirectResponse($shareLink);
        }

        return $response;
    }
860442
function isTypingSince(\CharlotteDunois\Yasmin\Models\User $user) {
        if(!$this->isTyping($user)) {
            return -1;
        }
        
        return (\time() - $this->typings->get($user->id)['timestamp']);
    }
78214
public function countUserFinishedDayPapers(Exercise $exercise, User $user)
    {
        return $this->repository->countUserFinishedDayPapers($exercise, $user);
    }
1205127
public function getTotal($user)
    {
        $leaderboardType = $this->getLeaderboardTypeService()->getLeaderboardTypeDefault();
        $leaderboardUser = $this->getLeaderboardMapper()->findOneBy(
            array(
                'user' => $user,
                'leaderboardType' => $leaderboardType
            )
        );
        if (!$leaderboardUser) {
            return 0;
        }
        return $leaderboardUser->getTotalPoints();
    }
1012853
public function count($expression, $type = Query::TYPE_CSS)
    {
        $expression = Query::compile($expression, $type);
        $expression = sprintf('count(%s)', $expression);

        return (int) $this->createXpath()->evaluate($expression);
    }
202650
public function isBuyer(User $user)
    {
        return (bool) $this->purchases()->whereHas('buyer', function ($query) use ($user) {
            return $query->where('user_id', $user->userId);
        })->count();
    }
339763
public static function getAccountChecksum(int $node, int $user): string
    {
        return sprintf('%04X', self::crc16(sprintf('%04X%08X', $node, $user)));
    }
100183
public function getReadIds(User $user)
    {
        return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id')
            ->where('discussion_user.user_id', $user->id)
            ->whereColumn('last_read_post_number', '>=', 'last_post_number')
            ->pluck('id')
            ->all();
    }
144148
public function count($type = FALSE)
  {   
	$count = 0;
	
	$messages = $this->_session_get();
	
	if (is_array($messages)){
	
		if ($type === FALSE)
		{
			$count = count($messages);
		}
		else {
			
			foreach($messages as $message){
				
				if ($message->type == $type){
					
					$count++;
				}
			}
			
		}
	}
		
	return $count;
  }
244057
public static function getRowCount( $table, $type = 'row' ) {

		$stat = self::find()->where( '`table`=:table AND type=:type', [ ':table' => $table, ':type' => $type ] )->one();

		if( isset( $stat ) ) {

			return $stat->count;
		}

		return 0;
	}
693620
public function isApiEnabledForUser(User $user)
    {
        $roles = $user->roles->pluck('id')->toArray();
        return !count($roles) ? false : $this->newQuery()->whereIn('role_id', array_values($roles))->where('enabled', 1)->get()->count() > 0;
    }
41208
public function count($expression, $type = Query::TYPE_CSS)
    {
        return $this->toDocument()->count($expression, $type);
    }
1155046
protected function attemptToConnectUser(User $user, $type)
    {
        $model = $this->getClientOrCreate($user, $type);

        if (! is_null($currentUser = $this->auth->user())) {
            $model->setAttribute('user_id', $currentUser->getAuthIdentifier());
        }

        $model->setAttribute('token', new Token(['access' => $user->token]));
        $model->save();

        return $model;
    }
977570
public function getPosition(QueuedAction $action, User $user = null)
    {
        $action->setServiceLocator($this->getServiceManager());
        $positions = $this->getPositions($action);
        return count($positions);
    }
689104
private function loadAllUserGroupsIdsOfUser(User $user): array
    {
        $allUserGroups = [];
        $offset = 0;

        do {
            $userGroups = $this->userService->loadUserGroupsOfUser($user, $offset, self::USER_GROUPS_LIMIT);
            foreach ($userGroups as $userGroup) {
                $allUserGroups[] = $userGroup->contentInfo->id;
            }
            $offset += self::USER_GROUPS_LIMIT;
        } while (\count($userGroups) === self::USER_GROUPS_LIMIT);

        return $allUserGroups;
    }