77use BookStack \Activity \Tools \CommentTreeNode ;
88use BookStack \Entities \Queries \PageQueries ;
99use BookStack \Http \Controller ;
10+ use BookStack \Permissions \Permission ;
1011use Illuminate \Http \Request ;
1112use Illuminate \Validation \ValidationException ;
1213
@@ -42,7 +43,7 @@ public function savePageComment(Request $request, int $pageId)
4243 }
4344
4445 // Create a new comment.
45- $ this ->checkPermission (' comment-create-all ' );
46+ $ this ->checkPermission (Permission::CommentCreateAll );
4647 $ contentRef = $ input ['content_ref ' ] ?? '' ;
4748 $ comment = $ this ->commentRepo ->create ($ page , $ input ['html ' ], $ input ['parent_id ' ] ?? null , $ contentRef );
4849
@@ -64,8 +65,8 @@ public function update(Request $request, int $commentId)
6465 ]);
6566
6667 $ comment = $ this ->commentRepo ->getById ($ commentId );
67- $ this ->checkOwnablePermission (' page-view ' , $ comment ->entity );
68- $ this ->checkOwnablePermission (' comment-update ' , $ comment );
68+ $ this ->checkOwnablePermission (Permission::PageView , $ comment ->entity );
69+ $ this ->checkOwnablePermission (Permission::CommentUpdate , $ comment );
6970
7071 $ comment = $ this ->commentRepo ->update ($ comment , $ input ['html ' ]);
7172
@@ -81,8 +82,8 @@ public function update(Request $request, int $commentId)
8182 public function archive (int $ id )
8283 {
8384 $ comment = $ this ->commentRepo ->getById ($ id );
84- $ this ->checkOwnablePermission (' page-view ' , $ comment ->entity );
85- if (!userCan (' comment-update ' , $ comment ) && !userCan (' comment-delete ' , $ comment )) {
85+ $ this ->checkOwnablePermission (Permission::PageView , $ comment ->entity );
86+ if (!userCan (Permission::CommentUpdate , $ comment ) && !userCan (Permission::CommentDelete , $ comment )) {
8687 $ this ->showPermissionError ();
8788 }
8889
@@ -101,8 +102,8 @@ public function archive(int $id)
101102 public function unarchive (int $ id )
102103 {
103104 $ comment = $ this ->commentRepo ->getById ($ id );
104- $ this ->checkOwnablePermission (' page-view ' , $ comment ->entity );
105- if (!userCan (' comment-update ' , $ comment ) && !userCan (' comment-delete ' , $ comment )) {
105+ $ this ->checkOwnablePermission (Permission::PageView , $ comment ->entity );
106+ if (!userCan (Permission::CommentUpdate , $ comment ) && !userCan (Permission::CommentDelete , $ comment )) {
106107 $ this ->showPermissionError ();
107108 }
108109
@@ -121,7 +122,7 @@ public function unarchive(int $id)
121122 public function destroy (int $ id )
122123 {
123124 $ comment = $ this ->commentRepo ->getById ($ id );
124- $ this ->checkOwnablePermission (' comment-delete ' , $ comment );
125+ $ this ->checkOwnablePermission (Permission::CommentDelete , $ comment );
125126
126127 $ this ->commentRepo ->delete ($ comment );
127128
0 commit comments