3 namespace BookStack\Permissions;
6 * Enum to represent the permissions which may be used in checks.
7 * These generally align with RolePermission names, although some are abstract or truncated as some checks
8 * are performed across a range of different items which may be subject to inheritance and other complications.
10 * We use and still allow the string values in usage to allow for compatibility with scenarios where
11 * users have customised their instance with additional permissions via the theme system.
12 * This enum primarily exists for alignment within the codebase.
14 * Permissions with all/own suffixes may also be represented as a higher-level alias without the own/all
15 * suffix, which are used and assessed in the permission system logic.
17 enum Permission: string
20 // Used for more abstract entity permission checks
22 case Create = 'create';
23 case Update = 'update';
24 case Delete = 'delete';
27 case AccessApi = 'access-api';
28 case ContentExport = 'content-export';
29 case ContentImport = 'content-import';
30 case EditorChange = 'editor-change';
31 case ReceiveNotifications = 'receive-notifications';
32 case RestrictionsManage = 'restrictions-manage';
33 case RestrictionsManageAll = 'restrictions-manage-all';
34 case RestrictionsManageOwn = 'restrictions-manage-own';
35 case SettingsManage = 'settings-manage';
36 case TemplatesManage = 'templates-manage';
37 case UserRolesManage = 'user-roles-manage';
38 case UsersManage = 'users-manage';
40 // Non-entity content permissions
41 case AttachmentCreate = 'attachment-create';
42 case AttachmentCreateAll = 'attachment-create-all';
43 case AttachmentCreateOwn = 'attachment-create-own';
44 case AttachmentDelete = 'attachment-delete';
45 case AttachmentDeleteAll = 'attachment-delete-all';
46 case AttachmentDeleteOwn = 'attachment-delete-own';
47 case AttachmentUpdate = 'attachment-update';
48 case AttachmentUpdateAll = 'attachment-update-all';
49 case AttachmentUpdateOwn = 'attachment-update-own';
51 case CommentCreate = 'comment-create';
52 case CommentCreateAll = 'comment-create-all';
53 case CommentCreateOwn = 'comment-create-own';
54 case CommentDelete = 'comment-delete';
55 case CommentDeleteAll = 'comment-delete-all';
56 case CommentDeleteOwn = 'comment-delete-own';
57 case CommentUpdate = 'comment-update';
58 case CommentUpdateAll = 'comment-update-all';
59 case CommentUpdateOwn = 'comment-update-own';
61 case ImageCreateAll = 'image-create-all';
62 case ImageCreateOwn = 'image-create-own';
63 case ImageDelete = 'image-delete';
64 case ImageDeleteAll = 'image-delete-all';
65 case ImageDeleteOwn = 'image-delete-own';
66 case ImageUpdate = 'image-update';
67 case ImageUpdateAll = 'image-update-all';
68 case ImageUpdateOwn = 'image-update-own';
70 // Entity content permissions
71 case BookCreate = 'book-create';
72 case BookCreateAll = 'book-create-all';
73 case BookCreateOwn = 'book-create-own';
74 case BookDelete = 'book-delete';
75 case BookDeleteAll = 'book-delete-all';
76 case BookDeleteOwn = 'book-delete-own';
77 case BookUpdate = 'book-update';
78 case BookUpdateAll = 'book-update-all';
79 case BookUpdateOwn = 'book-update-own';
80 case BookView = 'book-view';
81 case BookViewAll = 'book-view-all';
82 case BookViewOwn = 'book-view-own';
84 case BookshelfCreate = 'bookshelf-create';
85 case BookshelfCreateAll = 'bookshelf-create-all';
86 case BookshelfCreateOwn = 'bookshelf-create-own';
87 case BookshelfDelete = 'bookshelf-delete';
88 case BookshelfDeleteAll = 'bookshelf-delete-all';
89 case BookshelfDeleteOwn = 'bookshelf-delete-own';
90 case BookshelfUpdate = 'bookshelf-update';
91 case BookshelfUpdateAll = 'bookshelf-update-all';
92 case BookshelfUpdateOwn = 'bookshelf-update-own';
93 case BookshelfView = 'bookshelf-view';
94 case BookshelfViewAll = 'bookshelf-view-all';
95 case BookshelfViewOwn = 'bookshelf-view-own';
97 case ChapterCreate = 'chapter-create';
98 case ChapterCreateAll = 'chapter-create-all';
99 case ChapterCreateOwn = 'chapter-create-own';
100 case ChapterDelete = 'chapter-delete';
101 case ChapterDeleteAll = 'chapter-delete-all';
102 case ChapterDeleteOwn = 'chapter-delete-own';
103 case ChapterUpdate = 'chapter-update';
104 case ChapterUpdateAll = 'chapter-update-all';
105 case ChapterUpdateOwn = 'chapter-update-own';
106 case ChapterView = 'chapter-view';
107 case ChapterViewAll = 'chapter-view-all';
108 case ChapterViewOwn = 'chapter-view-own';
110 case PageCreate = 'page-create';
111 case PageCreateAll = 'page-create-all';
112 case PageCreateOwn = 'page-create-own';
113 case PageDelete = 'page-delete';
114 case PageDeleteAll = 'page-delete-all';
115 case PageDeleteOwn = 'page-delete-own';
116 case PageUpdate = 'page-update';
117 case PageUpdateAll = 'page-update-all';
118 case PageUpdateOwn = 'page-update-own';
119 case PageView = 'page-view';
120 case PageViewAll = 'page-view-all';
121 case PageViewOwn = 'page-view-own';
124 * Get the generic permissions which may be queried for entities.
126 public static function genericForEntity(): array