I've added four explicit consent checkboxes to the cookie banner:
https://github.com/octfx/mediawiki-extensions-CookieWarning
Commit Message:
Four checkboxes for required, preference, statistic and marketing cookies are added to the cookie banner
{F34181174}
Those preferences are saved to a 'cookiewarning_preferences' cookie, and to the user options if the user is logged in
Cookie settings are viewable and changeable in the user preferences
{F34181169}
Five new config values are added:
- $wgCookieWarningUnsetCookies
- Unsets all cookies that are not strictly required
- $wgCookieWarningRequiredCookies
- A list of cookie names that can't be unset
- $wgCookieWarningPreferenceCookies
- A list of cookie names that belong to the preference group
- $wgCookieWarningStatisticCookies
- A list of cookie names that belong to the statistic group
- $wgCookieWarningMarketingCookies
- A list of cookie names that belong to the marketing group
All cookie groups are based on https://gdpr.eu/cookies/
These groups will only have an effect if $wgCookieWarningUnsetCookies is true.
If $wgCookieWarningUnsetCookies is set to true, each cookie name is checked against all four lists, if nothing was found, the cookie is unset.
NOTE: At this point no message is shown to the user that the banner needs to be accepted in order for login functionality to work properly when $wgCookieWarningUnsetCookies is true
The login will succeed, but upon any action the user is logged out again
Also NOTE: Cookies that are set through javascript can still be set, but will be unset each page load
Preferences from the preference cookie are saved in the database after a successful login
The maintenance script `RemoveDismissedState` can be used to force the display of the cookiebanner
Additionally five hooks are introduced:
- `CookiePreferencesChangedHook::onPreferencesChanged( array $preferences )`
- This hook is run after the user changed the cookie preferences through the settings menu
- `CookieListRetrieveHook::onCookieListRetrieve( array &$required, array &$preference, array &$statistics, array &$marketing )`
- Allows to add cookie names to the list of allowed cookies, or to remove present ones
- `CookieAllowedCheckHook::onCookieAllowedCheck( bool &$allowed, string $cookieName, array $preferences )`
- Run right before deciding if a cookie is allowed
- `mw.hook( 'cookiewarning.dismissed' ).fire( true );`
- Fired when the accept button was clicked in the banner
- `mw.hook( 'cookiewarning.preferences_set' ).fire( preferenceData );`
- Fired after the preference cookie was set
The state of each preference is saved in the user properties:
- `cookiewarning_cookies_required` (always true)
- `cookiewarning_cookies_preference`
- `cookiewarning_cookies_statistic`
- `cookiewarning_cookies_marketing`