-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhooks.php
138 lines (130 loc) · 5.44 KB
/
hooks.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
return [
/**
* Page-Hooks
*/
'page.create:after' => function ($page) {
site()->git()->changeHandler("Created Page: {$page->id()}");
},
'page.update:after' => function ($newPage,$oldPage) {
site()->git()->changeHandler("Edited Page: {$newPage->id()}");
},
'page.delete:after' => function ($status, $page) {
site()->git()->changeHandler("Deleted Page: {$page->id()}");
},
'page.changeNum:after' => function ($newPage,$oldPage) {
$oldNum = $oldPage->num() ?? "None";
site()->git()->changeHandler("Sorted Page: {$newPage->id()} ({$oldNum} → {$newPage->num()})");
},
'page.changeSlug:after' => function ($newPage,$oldPage) {
$oldSlug = $oldPage->slug() ?? "None";
site()->git()->changeHandler("Changed Slug: {$newPage->id()} ({$oldSlug} → {$newPage->slug()})");
},
'page.changeStatus:after' => function ($newPage,$oldPage) {
$oldStatus = $oldPage->status() ?? "None";
site()->git()->changeHandler("Changed Status: {$newPage->id()} ({$oldStatus} → {$newPage->status()})");
},
'page.changeTemplate:after' => function ($newPage,$oldPage) {
$oldTemplate = $oldPage->template() ?? "None";
site()->git()->changeHandler("Changed Template: {$newPage->id()} ({$oldTemplate} → {$newPage->template()})");
},
'page.changeTitle:after' => function ($newPage,$oldPage) {
$oldTitle = $oldPage->title() ?? "None";
site()->git()->changeHandler("Changed Title: {$newPage->id()} ({$oldTitle} → {$newPage->title()})");
},
/**
* File-Hooks
*/
'file.create:after' => function ($file) {
site()->git()->changeHandler("Uploaded File: {$file->id()}");
},
'file.delete:after' => function ($status, $file) {
site()->git()->changeHandler("Deleted File: {$file->id()}");
},
'file.changeName:after' => function ($newFile,$oldFile) {
$oldFilename = $oldFile->filename() ?? "None";
site()->git()->changeHandler("Changed Filename: {$newFile->id()} ({$oldFilename} → {$newFile->filename()})");
},
'file.changeSort:after' => function ($newFile,$oldFile) {
$oldSort = $oldFile->sort() ?? "None";
site()->git()->changeHandler("Sorted File: {$newFile->id()} ({$oldSort} → {$newFile->sort()})");
},
'file.update:after' => function ($newFile,$oldFile) {
site()->git()->changeHandler("Edited File-Metadata: {$newFile->id()}");
},
'file.replace:after' => function ($newFile,$oldFile) {
site()->git()->changeHandler("Replaced File: {$newFile->id()}");
},
/**
* Site-Hooks
*/
'site.update:after' => function ($newSite,$oldSite) {
site()->git()->changeHandler("Edited Site");
},
/**
* Avatar-Hooks
*/
'avatar.create:after' => function ($avatar) {
if (!site()->git()->userHooksEnabled()) return;
$name = $avatar->user()->name() ?? $avatar->user()->email();
site()->git()->changeHandler("Uploaded Avatar: {$name}");
},
'avatar.replace:after' => function ($newAvatar, $oldAvatar) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newAvatar->user()->name() ?? $newAvatar->user()->email();
site()->git()->changeHandler("Replaced Avatar: {$name}");
},
'avatar.delete:after' => function ($status, $avatar) {
if (!site()->git()->userHooksEnabled()) return;
$name = $avatar->user()->name() ?? $avatar->user()->email();
site()->git()->changeHandler("Deleted Avatar: {$name}");
},
/**
* User-Hooks
*/
'user.changeEmail:after' => function ($newUser, $oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
$oldEmail = $oldUser->email() ?? "None";
site()->git()->changeHandler("Changed E-Mail: {$name} ({$oldEmail} → {$newUser->email()})");
},
'user.changeName:after' => function ($newUser, $oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
$oldName = $oldUser->name() ?? "None";
$newName = $newUser->name() ?? "None";
site()->git()->changeHandler("Changed Name: {$name} ({$oldName} → {$newName})");
},
'user.changeLanguage:after' => function ($newUser, $oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
$oldLang = $oldUser->language() ?? "None";
site()->git()->changeHandler("Changed Language: {$name} ({$oldLang} → {$newUser->language()})");
},
'user.changePassword:after' => function ($newUser, $oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
site()->git()->changeHandler("Changed Password: {$name}");
},
'user.changeRole:after' => function ($newUser, $oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
$oldRole = $oldUser->role() ?? "None";
site()->git()->changeHandler("Changed Role: {$name} ({$oldRole} → {$newUser->role()})");
},
'user.create:after' => function ($user) {
if (!site()->git()->userHooksEnabled()) return;
$name = $user->name() ?? $user->email();
site()->git()->changeHandler("Created User: {$name}");
},
'user.update:after' => function ($newUser,$oldUser) {
if (!site()->git()->userHooksEnabled()) return;
$name = $newUser->name() ?? $newUser->email();
site()->git()->changeHandler("Edited User: {$name}");
},
'user.delete:after' => function ($status, $user ) {
if (!site()->git()->userHooksEnabled()) return;
$name = $user->name() ?? $user->email();
site()->git()->changeHandler("Deleted User: {$name}");
},
];