| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace BookStack\Theming; | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * The ThemeEvents used within BookStack. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file details the events that BookStack may fire via the custom | 
					
						
							|  |  |  |  * theme system, including event names, parameters and expected return types. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This system is regarded as semi-stable. | 
					
						
							|  |  |  |  * We'll look to fix issues with it or migrate old event types but | 
					
						
							|  |  |  |  * events and their signatures may change in new versions of BookStack. | 
					
						
							|  |  |  |  * We'd advise testing any usage of these events upon upgrade. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class ThemeEvents | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-07-17 20:28:56 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Activity logged event. | 
					
						
							|  |  |  |      * Runs right after an activity is logged by bookstack. | 
					
						
							|  |  |  |      * These are the activities that can be seen in the audit log area of BookStack. | 
					
						
							|  |  |  |      * Activity types can be seen listed in the \BookStack\Actions\ActivityType class. | 
					
						
							|  |  |  |      * The provided $detail can be a string or a loggable type of model. You should check | 
					
						
							|  |  |  |      * the type before making use of this parameter. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param string $type | 
					
						
							| 
									
										
										
										
											2023-05-18 00:56:55 +08:00
										 |  |  |      * @param string|\BookStack\Activity\Models\Loggable $detail | 
					
						
							| 
									
										
										
										
											2022-07-17 20:28:56 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const ACTIVITY_LOGGED = 'activity_logged'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Application boot-up. | 
					
						
							|  |  |  |      * After main services are registered. | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-05-18 00:56:55 +08:00
										 |  |  |      * @param \BookStack\App\Application $app | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const APP_BOOT = 'app_boot'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-20 05:54:50 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Auth login event. | 
					
						
							|  |  |  |      * Runs right after a user is logged-in to the application by any authentication | 
					
						
							|  |  |  |      * system as a standard app user. This includes a user becoming logged in | 
					
						
							|  |  |  |      * after registration. This is not emitted upon API usage. | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param string $authSystem | 
					
						
							| 
									
										
										
										
											2023-05-18 00:56:55 +08:00
										 |  |  |      * @param \BookStack\Users\Models\User $user | 
					
						
							| 
									
										
										
										
											2021-03-20 05:54:50 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const AUTH_LOGIN = 'auth_login'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Auth pre-register event. | 
					
						
							|  |  |  |      * Runs right before a new user account is registered in the system by any authentication | 
					
						
							|  |  |  |      * system as a standard app user including auto-registration systems used by LDAP, | 
					
						
							|  |  |  |      * SAML, OIDC and social systems. It only includes self-registrations, | 
					
						
							|  |  |  |      * not accounts created by others in the UI or via the REST API. | 
					
						
							|  |  |  |      * It runs after any other normal validation steps. | 
					
						
							|  |  |  |      * Any account/email confirmation occurs post-registration. | 
					
						
							|  |  |  |      * The provided $userData contains the main details that would be used to create | 
					
						
							|  |  |  |      * the account, and may depend on authentication method. | 
					
						
							|  |  |  |      * If false is returned from the event, registration will be prevented and the user | 
					
						
							|  |  |  |      * will be returned to the login page. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $authSystem | 
					
						
							|  |  |  |      * @param array $userData | 
					
						
							|  |  |  |      * @returns bool|null | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     const AUTH_PRE_REGISTER = 'auth_pre_register'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-20 05:54:50 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Auth register event. | 
					
						
							|  |  |  |      * Runs right after a user is newly registered to the application by any authentication | 
					
						
							|  |  |  |      * system as a standard app user. This includes auto-registration systems used | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * by LDAP, SAML, OIDC and social systems. It only includes self-registrations. | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param string $authSystem | 
					
						
							| 
									
										
										
										
											2023-05-18 00:56:55 +08:00
										 |  |  |      * @param \BookStack\Users\Models\User $user | 
					
						
							| 
									
										
										
										
											2021-03-20 05:54:50 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const AUTH_REGISTER = 'auth_register'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Commonmark environment configure. | 
					
						
							| 
									
										
										
										
											2022-09-05 23:40:42 +08:00
										 |  |  |      * Provides the commonmark library environment for customization before it's used to render markdown content. | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  |      * If the listener returns a non-null value, that will be used as an environment instead. | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-02-07 04:00:44 +08:00
										 |  |  |      * @param \League\CommonMark\Environment\Environment $environment | 
					
						
							|  |  |  |      * @returns \League\CommonMark\Environment\Environment|null | 
					
						
							| 
									
										
										
										
											2021-03-17 01:14:03 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const COMMONMARK_ENVIRONMENT_CONFIGURE = 'commonmark_environment_configure'; | 
					
						
							| 
									
										
										
										
											2022-01-04 02:22:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-28 06:40:14 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * OIDC ID token pre-validate event. | 
					
						
							|  |  |  |      * Runs just before BookStack validates the user ID token data upon login. | 
					
						
							|  |  |  |      * Provides the existing found set of claims for the user as a key-value array, | 
					
						
							|  |  |  |      * along with an array of the proceeding access token data provided by the identity platform. | 
					
						
							|  |  |  |      * If the listener returns a non-null value, that will replace the existing ID token claim data. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param array $idTokenData | 
					
						
							|  |  |  |      * @param array $accessTokenData | 
					
						
							|  |  |  |      * @returns array|null | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     const OIDC_ID_TOKEN_PRE_VALIDATE = 'oidc_id_token_pre_validate'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-05 23:40:42 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Page include parse event. | 
					
						
							|  |  |  |      * Runs when a page include tag is being parsed, typically when page content is being processed for viewing. | 
					
						
							|  |  |  |      * Provides the "include tag" reference string, the default BookStack replacement content for the tag, | 
					
						
							|  |  |  |      * the current page being processed, and the page that's being referenced by the include tag. | 
					
						
							|  |  |  |      * The referenced page may be null where the page does not exist or where permissions prevent visibility. | 
					
						
							|  |  |  |      * If the listener returns a non-null value, that will be used as the replacement HTML content instead. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param string $tagReference | 
					
						
							|  |  |  |      * @param string $replacementHTML | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param \BookStack\Entities\Models\Page $currentPage | 
					
						
							|  |  |  |      * @param ?\BookStack\Entities\Models\Page $referencedPage | 
					
						
							| 
									
										
										
										
											2022-09-05 23:40:42 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const PAGE_INCLUDE_PARSE = 'page_include_parse'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-17 20:08:44 +08:00
										 |  |  |     /** | 
					
						
							| 
									
										
										
										
											2023-11-17 21:45:57 +08:00
										 |  |  |      * Routes register web event. | 
					
						
							|  |  |  |      * Called when standard web (browser/non-api) app routes are registered. | 
					
						
							|  |  |  |      * Provides an app router, so you can register your own web routes. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-12-10 22:58:05 +08:00
										 |  |  |      * @param \Illuminate\Routing\Router $router | 
					
						
							| 
									
										
										
										
											2023-11-17 21:45:57 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const ROUTES_REGISTER_WEB = 'routes_register_web'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Routes register web auth event. | 
					
						
							|  |  |  |      * Called when auth-required web (browser/non-api) app routes can be registered. | 
					
						
							|  |  |  |      * These are routes that typically require login to access (unless the instance is made public). | 
					
						
							|  |  |  |      * Provides an app router, so you can register your own web routes. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2023-12-10 22:58:05 +08:00
										 |  |  |      * @param \Illuminate\Routing\Router $router | 
					
						
							| 
									
										
										
										
											2023-11-17 21:45:57 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const ROUTES_REGISTER_WEB_AUTH = 'routes_register_web_auth'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2022-07-17 20:08:44 +08:00
										 |  |  |      * Web before middleware action. | 
					
						
							|  |  |  |      * Runs before the request is handled but after all other middleware apart from those | 
					
						
							|  |  |  |      * that depend on the current session user (Localization for example). | 
					
						
							|  |  |  |      * Provides the original request to use. | 
					
						
							|  |  |  |      * Return values, if provided, will be used as a new response to use. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param \Illuminate\Http\Request $request | 
					
						
							|  |  |  |      * @returns \Illuminate\Http\Response|null | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     const WEB_MIDDLEWARE_BEFORE = 'web_middleware_before'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Web after middleware action. | 
					
						
							|  |  |  |      * Runs after the request is handled but before the response is sent. | 
					
						
							|  |  |  |      * Provides both the original request and the currently resolved response. | 
					
						
							|  |  |  |      * Return values, if provided, will be used as a new response to use. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param \Illuminate\Http\Request $request | 
					
						
							| 
									
										
										
										
											2022-07-17 20:08:44 +08:00
										 |  |  |      * @param \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse $response | 
					
						
							|  |  |  |      * @returns \Illuminate\Http\Response|null | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     const WEB_MIDDLEWARE_AFTER = 'web_middleware_after'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-04 02:22:03 +08:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Webhook call before event. | 
					
						
							|  |  |  |      * Runs before a webhook endpoint is called. Allows for customization | 
					
						
							|  |  |  |      * of the data format & content within the webhook POST request. | 
					
						
							|  |  |  |      * Provides the original event name as a string (see \BookStack\Actions\ActivityType) | 
					
						
							|  |  |  |      * along with the webhook instance along with the event detail which may be a | 
					
						
							|  |  |  |      * "Loggable" model type or a string. | 
					
						
							|  |  |  |      * If the listener returns a non-null value, that will be used as the POST data instead | 
					
						
							|  |  |  |      * of the system default. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param string $event | 
					
						
							|  |  |  |      * @param \BookStack\Activity\Models\Webhook $webhook | 
					
						
							| 
									
										
										
										
											2023-05-18 00:56:55 +08:00
										 |  |  |      * @param string|\BookStack\Activity\Models\Loggable $detail | 
					
						
							| 
									
										
										
										
											2024-02-21 23:30:29 +08:00
										 |  |  |      * @param \BookStack\Users\Models\User $initiator | 
					
						
							|  |  |  |      * @param int $initiatedTime | 
					
						
							| 
									
										
										
										
											2023-07-12 23:16:12 +08:00
										 |  |  |      * @returns array|null | 
					
						
							| 
									
										
										
										
											2022-01-04 02:22:03 +08:00
										 |  |  |      */ | 
					
						
							|  |  |  |     const WEBHOOK_CALL_BEFORE = 'webhook_call_before'; | 
					
						
							| 
									
										
										
										
											2021-06-26 23:23:15 +08:00
										 |  |  | } |