-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend.php
executable file
·38 lines (31 loc) · 1.83 KB
/
extend.php
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
32
33
34
35
36
37
38
<?php
use Flarum\Extend;
use Flarum\User\Event\Saving;
use Flarum\Api\Serializer\UserSerializer;
use Flarum\Api\Serializer\ForumSerializer;
use Ziven\checkin\AddAttribute\AddUserCheckinAttributes;
use Ziven\checkin\Listeners\doCheckin;
use Ziven\checkin\Access\UserPolicy;
$extend = [
(new Extend\Frontend('admin'))->js(__DIR__.'/js/dist/admin.js'),
(new Extend\Frontend('forum'))->js(__DIR__ . '/js/dist/forum.js')->css(__DIR__.'/less/forum.less'),
(new Extend\Locales(__DIR__ . '/locale')),
(new Extend\Policy())->modelPolicy(User::class, UserPolicy::class),
(new Extend\Event())->listen(Saving::class, [doCheckin::class, 'checkinSaved']),
(new Extend\ApiSerializer(UserSerializer::class))->attributes(AddUserCheckinAttributes::class),
(new Extend\Settings())
->serializeToForum('forumCheckinRewarMoney', 'ziven-forum-checkin.checkinRewardMoney',function ($raw) {
return (float)$raw;
})
->serializeToForum('forumAutoCheckin', 'ziven-forum-checkin.autoCheckIn', 'intval', 0)
->serializeToForum('forumAutoCheckinDelay', 'ziven-forum-checkin.autoCheckInDelay', 'intval', 0)
->serializeToForum('forumCheckinTimeZone', 'ziven-forum-checkin.checkinTimeZone', 'intval', 0)
->serializeToForum('forumCheckinSuccessPromptType', 'ziven-forum-checkin.checkinSuccessPromptType', 'intval', 0)
->serializeToForum('forumCheckinSuccessPromptText', 'ziven-forum-checkin.checkinSuccessPromptText', 'strval')
->serializeToForum('forumCheckinSuccessPromptRewardText', 'ziven-forum-checkin.checkinSuccessPromptRewardText', 'strval'),
(new Extend\ApiSerializer(ForumSerializer::class))
->attribute('allowCheckIn', function (ForumSerializer $serializer) {
return $serializer->getActor()->hasPermission("checkin.allowCheckIn");
}),
];
return $extend;