blob: 1d8f3abe24d6406d96e77583b6122885b38d0244 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
namespace JsonApi\Routes\MassMail;
use JsonApi\Errors\AuthorizationFailedException;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use JsonApi\JsonApiController;
class MassMailPermissionsIndex extends JsonApiController
{
protected $allowedPagingParameters = ['offset', 'limit'];
protected $allowedIncludePaths = ['institute', 'allowed-degrees', 'allowed-subjects', 'allowed-institutes'];
public function __invoke(Request $request, Response $response, $args)
{
if (!Authority::canIndexMassMailPermissions($this->getUser($request))) {
throw new AuthorizationFailedException();
}
[$offset, $limit] = $this->getOffsetAndLimit();
$total = \MassMail\MassMailPermission::countBySQL('1');
$permissions = \MassMail\MassMailPermission::findBySQL(
"JOIN `Institute` ON (`Institute`.`Institut_id` = `massmail_permissions`.`institute_id`)
ORDER BY `Institute`.`Name` LIMIT ?, ?",
[$offset, $limit]);
return $this->getPaginatedContentResponse($permissions, $total);
}
}
|