<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Config; if (!defined('ABSPATH')) exit; use MailPoet\Automation\Engine\Engine; use MailPoet\WP\Functions as WPFunctions; class AccessControl { const PERMISSION_ACCESS_PLUGIN_ADMIN = 'mailpoet_access_plugin_admin'; const PERMISSION_MANAGE_SETTINGS = 'mailpoet_manage_settings'; const PERMISSION_MANAGE_FEATURES = 'mailpoet_manage_features'; const PERMISSION_MANAGE_EMAILS = 'mailpoet_manage_emails'; const PERMISSION_MANAGE_SUBSCRIBERS = 'mailpoet_manage_subscribers'; const PERMISSION_MANAGE_FORMS = 'mailpoet_manage_forms'; const PERMISSION_MANAGE_SEGMENTS = 'mailpoet_manage_segments'; const PERMISSION_MANAGE_AUTOMATIONS = Engine::CAPABILITY_MANAGE_AUTOMATIONS; const PERMISSION_MANAGE_HELP = 'mailpoet_manage_help'; const NO_ACCESS_RESTRICTION = 'mailpoet_no_access_restriction'; const ALL_ROLES_ACCESS = 'mailpoet_all_roles_access'; public function getDefaultPermissions() { return [ self::PERMISSION_ACCESS_PLUGIN_ADMIN => WPFunctions::get()->applyFilters( 'mailpoet_permission_access_plugin_admin', [ 'administrator', 'editor', ] ), self::PERMISSION_MANAGE_SETTINGS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_settings', [ 'administrator', ] ), self::PERMISSION_MANAGE_FEATURES => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_features', [ 'administrator', ] ), self::PERMISSION_MANAGE_EMAILS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_emails', [ 'administrator', 'editor', ] ), self::PERMISSION_MANAGE_SUBSCRIBERS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_subscribers', [ 'administrator', ] ), self::PERMISSION_MANAGE_FORMS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_forms', [ 'administrator', ] ), self::PERMISSION_MANAGE_SEGMENTS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_segments', [ 'administrator', ] ), self::PERMISSION_MANAGE_AUTOMATIONS => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_automations', [ 'administrator', 'editor', ] ), self::PERMISSION_MANAGE_HELP => WPFunctions::get()->applyFilters( 'mailpoet_permission_manage_help', [ 'administrator', 'editor', ] ), ]; } public function getPermissionLabels() { return [ self::PERMISSION_ACCESS_PLUGIN_ADMIN => __('Admin menu item', 'mailpoet'), self::PERMISSION_MANAGE_SETTINGS => __('Manage settings', 'mailpoet'), self::PERMISSION_MANAGE_FEATURES => __('Manage features', 'mailpoet'), self::PERMISSION_MANAGE_EMAILS => __('Manage emails', 'mailpoet'), self::PERMISSION_MANAGE_SUBSCRIBERS => __('Manage subscribers', 'mailpoet'), self::PERMISSION_MANAGE_FORMS => __('Manage forms', 'mailpoet'), self::PERMISSION_MANAGE_SEGMENTS => __('Manage segments', 'mailpoet'), self::PERMISSION_MANAGE_AUTOMATIONS => __('Manage automations', 'mailpoet'), self::PERMISSION_MANAGE_HELP => __('Manage help', 'mailpoet'), ]; } public function validatePermission($permission) { if ($permission === self::NO_ACCESS_RESTRICTION) return true; if ($permission === self::ALL_ROLES_ACCESS) { $capabilities = array_keys($this->getDefaultPermissions()); foreach ($capabilities as $capability) { if (WPFunctions::get()->currentUserCan($capability)) { return true; } } return false; } return WPFunctions::get()->currentUserCan($permission); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
PopulatorData | Folder | 0755 |
|
|
AccessControl.php | File | 3.89 KB | 0644 |
|
Activator.php | File | 4.94 KB | 0644 |
|
AssetsLoader.php | File | 1.68 KB | 0644 |
|
Capabilities.php | File | 2.87 KB | 0644 |
|
Changelog.php | File | 5.04 KB | 0644 |
|
DeactivationPoll.php | File | 1.43 KB | 0644 |
|
DeferredAdminNotices.php | File | 1.16 KB | 0644 |
|
Env.php | File | 4.16 KB | 0644 |
|
Hooks.php | File | 20.01 KB | 0644 |
|
HooksReCaptcha.php | File | 2.92 KB | 0644 |
|
HooksWooCommerce.php | File | 6.76 KB | 0644 |
|
Initializer.php | File | 16.88 KB | 0644 |
|
Installer.php | File | 3.12 KB | 0644 |
|
Localizer.php | File | 2.49 KB | 0644 |
|
Menu.php | File | 23.54 KB | 0644 |
|
PersonalDataErasers.php | File | 769 B | 0644 |
|
PersonalDataExporters.php | File | 3.22 KB | 0644 |
|
PluginActivatedHook.php | File | 776 B | 0644 |
|
Populator.php | File | 23.37 KB | 0644 |
|
PrivacyPolicy.php | File | 4.53 KB | 0644 |
|
Renderer.php | File | 4.34 KB | 0644 |
|
RendererFactory.php | File | 670 B | 0644 |
|
RequirementsChecker.php | File | 3.73 KB | 0644 |
|
Router.php | File | 1006 B | 0644 |
|
ServicesChecker.php | File | 7.04 KB | 0644 |
|
Shortcodes.php | File | 8.63 KB | 0644 |
|
SilentUpgraderSkin.php | File | 570 B | 0644 |
|
SubscriberChangesNotifier.php | File | 5 KB | 0644 |
|
TranslationUpdater.php | File | 7.92 KB | 0644 |
|
TwigEnvironment.php | File | 694 B | 0644 |
|
TwigFileSystemCache.php | File | 853 B | 0644 |
|
Updater.php | File | 1.97 KB | 0644 |
|
index.php | File | 6 B | 0644 |
|