X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffilter%2Fsrc%2FFilterFormatAccessControlHandler.php;fp=web%2Fcore%2Fmodules%2Ffilter%2Fsrc%2FFilterFormatAccessControlHandler.php;h=2dcb6dc7d1ef73a939a0ddae7d2641496509be23;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/filter/src/FilterFormatAccessControlHandler.php b/web/core/modules/filter/src/FilterFormatAccessControlHandler.php new file mode 100644 index 000000000..2dcb6dc7d --- /dev/null +++ b/web/core/modules/filter/src/FilterFormatAccessControlHandler.php @@ -0,0 +1,52 @@ +isFallbackFormat()) { + return AccessResult::allowed(); + } + else { + return AccessResult::allowedIfHasPermission($account, $filter_format->getPermissionName()); + } + } + + // The fallback format may not be disabled. + if ($operation == 'disable' && $filter_format->isFallbackFormat()) { + return AccessResult::forbidden(); + } + + // We do not allow filter formats to be deleted through the UI, because that + // would render any content that uses them unusable. + if ($operation == 'delete') { + return AccessResult::forbidden(); + } + + if (in_array($operation, ['disable', 'update', 'view'])) { + return parent::checkAccess($filter_format, $operation, $account); + } + + // No opinion. + return AccessResult::neutral(); + } + +}