1
0
mirror of https://github.com/flarum/core.git synced 2025-10-18 10:16:09 +02:00

Add user activity system

This commit is contained in:
Toby Zerner
2015-03-17 17:06:12 +10:30
parent 5055377eb1
commit 3880ce70f0
27 changed files with 508 additions and 72 deletions

View File

@@ -0,0 +1,30 @@
<?php namespace Flarum\Api\Actions\Posts;
use Flarum\Core\Models\User;
use Flarum\Api\Actions\ApiParams;
trait GetsPosts
{
protected function getPosts(ApiParams $params, $where)
{
$sort = $params->sort(['time']);
$count = $params->count(20, 50);
$user = $this->actor->getUser();
if (isset($where['discussion_id']) && ($near = $params->get('near')) > 1) {
$start = $this->posts->getIndexForNumber($where['discussion_id'], $near, $user);
$start = max(0, $start - $count / 2);
} else {
$start = 0;
}
return $this->posts->findWhere(
$where,
$user,
$sort['field'],
$sort['order'] ?: 'asc',
$count,
$start
);
}
}