Skip to content

Commit 0d7287f

Browse files
committed
Merge branch 'development' into release
2 parents e77c96f + 219da9d commit 0d7287f

File tree

18 files changed

+98
-23
lines changed

18 files changed

+98
-23
lines changed

.github/translators.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,4 @@ Filip Antala (AntalaFilip) :: Slovak
267267
mcgong (GongMingCai) :: Chinese Simplified; Chinese Traditional
268268
Nanang Setia Budi (sefidananang) :: Indonesian
269269
Андрей Павлов (andrei.pavlov) :: Russian
270+
Alex Navarro (alex.n.navarro) :: Portuguese, Brazilian

app/Actions/ActivityType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class ActivityType
2929
const COMMENTED_ON = 'commented_on';
3030
const PERMISSIONS_UPDATE = 'permissions_update';
3131

32+
const REVISION_RESTORE = 'revision_restore';
33+
const REVISION_DELETE = 'revision_delete';
34+
3235
const SETTINGS_UPDATE = 'settings_update';
3336
const MAINTENANCE_ACTION_RUN = 'maintenance_action_run';
3437

app/Entities/Models/PageRevision.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BookStack\Entities\Models;
44

55
use BookStack\Auth\User;
6+
use BookStack\Interfaces\Loggable;
67
use BookStack\Model;
78
use Carbon\Carbon;
89
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -27,7 +28,7 @@
2728
* @property Page $page
2829
* @property-read ?User $createdBy
2930
*/
30-
class PageRevision extends Model
31+
class PageRevision extends Model implements Loggable
3132
{
3233
protected $fillable = ['name', 'text', 'summary'];
3334
protected $hidden = ['html', 'markdown', 'restricted', 'text'];
@@ -83,4 +84,9 @@ public static function isA(string $type): bool
8384
{
8485
return $type === 'revision';
8586
}
87+
88+
public function logDescriptor(): string
89+
{
90+
return "Revision #{$this->revision_number} (ID: {$this->id}) for page ID {$this->page_id}";
91+
}
8692
}

app/Entities/Repos/PageRepo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ public function restoreRevision(Page $page, int $revisionId): Page
337337
$this->savePageRevision($page, $summary);
338338

339339
Activity::add(ActivityType::PAGE_RESTORE, $page);
340+
Activity::add(ActivityType::REVISION_RESTORE, $revision);
340341

341342
return $page;
342343
}

app/Facades/Activity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Support\Facades\Facade;
66

77
/**
8-
* @see \BookStack\Actions\ActivityLogger
8+
* @mixin \BookStack\Actions\ActivityLogger
99
*/
1010
class Activity extends Facade
1111
{

app/Http/Controllers/Api/UserApiController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ protected function rules(int $userId = null): array
3636
{
3737
return [
3838
'create' => [
39-
'name' => ['required', 'min:2'],
39+
'name' => ['required', 'min:2', 'max:100'],
4040
'email' => [
4141
'required', 'min:2', 'email', new Unique('users', 'email'),
4242
],
4343
'external_auth_id' => ['string'],
44-
'language' => ['string'],
44+
'language' => ['string', 'max:15', 'alpha_dash'],
4545
'password' => [Password::default()],
4646
'roles' => ['array'],
4747
'roles.*' => ['integer'],
4848
'send_invite' => ['boolean'],
4949
],
5050
'update' => [
51-
'name' => ['min:2'],
51+
'name' => ['min:2', 'max:100'],
5252
'email' => [
5353
'min:2',
5454
'email',
5555
(new Unique('users', 'email'))->ignore($userId ?? null),
5656
],
5757
'external_auth_id' => ['string'],
58-
'language' => ['string'],
58+
'language' => ['string', 'max:15', 'alpha_dash'],
5959
'password' => [Password::default()],
6060
'roles' => ['array'],
6161
'roles.*' => ['integer'],

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class RegisterController extends Controller
3030

3131
use RegistersUsers;
3232

33-
protected $socialAuthService;
34-
protected $registrationService;
35-
protected $loginService;
33+
protected SocialAuthService $socialAuthService;
34+
protected RegistrationService $registrationService;
35+
protected LoginService $loginService;
3636

3737
/**
3838
* Where to redirect users after login / registration.
@@ -69,7 +69,7 @@ public function __construct(
6969
protected function validator(array $data)
7070
{
7171
return Validator::make($data, [
72-
'name' => ['required', 'min:2', 'max:255'],
72+
'name' => ['required', 'min:2', 'max:100'],
7373
'email' => ['required', 'email', 'max:255', 'unique:users'],
7474
'password' => ['required', Password::default()],
7575
]);

app/Http/Controllers/PageRevisionController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace BookStack\Http\Controllers;
44

5+
use BookStack\Actions\ActivityType;
56
use BookStack\Entities\Repos\PageRepo;
67
use BookStack\Entities\Tools\PageContent;
78
use BookStack\Exceptions\NotFoundException;
9+
use BookStack\Facades\Activity;
810
use Ssddanbrown\HtmlDiff\Diff;
911

1012
class PageRevisionController extends Controller
@@ -132,6 +134,7 @@ public function destroy(string $bookSlug, string $pageSlug, int $revId)
132134
}
133135

134136
$revision->delete();
137+
Activity::add(ActivityType::REVISION_DELETE, $revision);
135138
$this->showSuccessNotification(trans('entities.revision_delete_success'));
136139

137140
return redirect($page->getUrl('/revisions'));

app/Http/Controllers/UserController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
class UserController extends Controller
2020
{
21-
protected $userRepo;
22-
protected $imageRepo;
21+
protected UserRepo $userRepo;
22+
protected ImageRepo $imageRepo;
2323

2424
/**
2525
* UserController constructor.
@@ -81,9 +81,9 @@ public function store(Request $request)
8181
$passwordRequired = ($authMethod === 'standard' && !$sendInvite);
8282

8383
$validationRules = [
84-
'name' => ['required'],
84+
'name' => ['required', 'max:100'],
8585
'email' => ['required', 'email', 'unique:users,email'],
86-
'language' => ['string'],
86+
'language' => ['string', 'max:15', 'alpha_dash'],
8787
'roles' => ['array'],
8888
'roles.*' => ['integer'],
8989
'password' => $passwordRequired ? ['required', Password::default()] : null,
@@ -139,11 +139,11 @@ public function update(Request $request, int $id)
139139
$this->checkPermissionOrCurrentUser('users-manage', $id);
140140

141141
$validated = $this->validate($request, [
142-
'name' => ['min:2'],
142+
'name' => ['min:2', 'max:100'],
143143
'email' => ['min:2', 'email', 'unique:users,email,' . $id],
144144
'password' => ['required_with:password_confirm', Password::default()],
145145
'password-confirm' => ['same:password', 'required_with:password'],
146-
'language' => ['string'],
146+
'language' => ['string', 'max:15', 'alpha_dash'],
147147
'roles' => ['array'],
148148
'roles.*' => ['integer'],
149149
'external_auth_id' => ['string'],

resources/lang/nl/entities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
'chapters_permissions_active' => 'Hoofdstuk Machtigingen Actief',
172172
'chapters_permissions_success' => 'Hoofdstuk Machtigingen Bijgewerkt',
173173
'chapters_search_this' => 'Doorzoek dit hoofdstuk',
174-
'chapter_sort_book' => 'Sort Book',
174+
'chapter_sort_book' => 'Sorteer Boek',
175175

176176
// Pages
177177
'page' => 'Pagina',

0 commit comments

Comments
 (0)