1d875ccfb7
Cleaned up PermissionApplicator to remove old cache system which was hardly ever actuall caching anything since it was reset after each public method run. Changed the scope of 'userCanOnAny' to just check entity permissions, and added protections of action scope creep, in case a role permission action was passed by mistake.
33 lines
818 B
PHP
33 lines
818 B
PHP
<?php
|
|
|
|
namespace BookStack\Entities\Queries;
|
|
|
|
use BookStack\Actions\View;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class RecentlyViewed extends EntityQuery
|
|
{
|
|
public function run(int $count, int $page): Collection
|
|
{
|
|
$user = user();
|
|
if ($user === null || $user->isDefault()) {
|
|
return collect();
|
|
}
|
|
|
|
$query = $this->permissionService()->filterRestrictedEntityRelations(
|
|
View::query(),
|
|
'views',
|
|
'viewable_id',
|
|
'viewable_type'
|
|
)
|
|
->orderBy('views.updated_at', 'desc')
|
|
->where('user_id', '=', user()->id);
|
|
|
|
return $query->with('viewable')
|
|
->skip(($page - 1) * $count)
|
|
->take($count)
|
|
->get()
|
|
->pluck('viewable')
|
|
->filter();
|
|
}
|
|
}
|