<?php namespace MailPoet\Config; if (!defined('ABSPATH')) exit; 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 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', ] ), ]; } public function getPermissionLabels() { return [ self::PERMISSION_ACCESS_PLUGIN_ADMIN => WPFunctions::get()->__('Admin menu item', 'mailpoet'), self::PERMISSION_MANAGE_SETTINGS => WPFunctions::get()->__('Manage settings', 'mailpoet'), self::PERMISSION_MANAGE_FEATURES => WPFunctions::get()->__('Manage features', 'mailpoet'), self::PERMISSION_MANAGE_EMAILS => WPFunctions::get()->__('Manage emails', 'mailpoet'), self::PERMISSION_MANAGE_SUBSCRIBERS => WPFunctions::get()->__('Manage subscribers', 'mailpoet'), self::PERMISSION_MANAGE_FORMS => WPFunctions::get()->__('Manage forms', 'mailpoet'), self::PERMISSION_MANAGE_SEGMENTS => WPFunctions::get()->__('Manage segments', '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 | 0700 |
|
|
AccessControl.php | File | 3.23 KB | 0644 |
|
Activator.php | File | 2.22 KB | 0644 |
|
AssetsLoader.php | File | 801 B | 0644 |
|
Capabilities.php | File | 2.8 KB | 0644 |
|
Changelog.php | File | 3.9 KB | 0644 |
|
Database.php | File | 2.78 KB | 0644 |
|
DatabaseInitializer.php | File | 601 B | 0644 |
|
DeferredAdminNotices.php | File | 1.07 KB | 0644 |
|
Env.php | File | 3.93 KB | 0644 |
|
Hooks.php | File | 10.32 KB | 0644 |
|
HooksWooCommerce.php | File | 3.97 KB | 0644 |
|
Initializer.php | File | 9.92 KB | 0644 |
|
Installer.php | File | 2.69 KB | 0644 |
|
Localizer.php | File | 1.15 KB | 0644 |
|
MP2Migrator.php | File | 35.34 KB | 0644 |
|
Menu.php | File | 14.04 KB | 0644 |
|
Migrator.php | File | 25.73 KB | 0644 |
|
PersonalDataErasers.php | File | 622 B | 0644 |
|
PersonalDataExporters.php | File | 2.64 KB | 0644 |
|
PluginActivatedHook.php | File | 682 B | 0644 |
|
Populator.php | File | 29.67 KB | 0644 |
|
PrivacyPolicy.php | File | 3.37 KB | 0644 |
|
Renderer.php | File | 3.95 KB | 0644 |
|
RendererFactory.php | File | 474 B | 0644 |
|
RequirementsChecker.php | File | 4.3 KB | 0644 |
|
Router.php | File | 846 B | 0644 |
|
ServicesChecker.php | File | 4.93 KB | 0644 |
|
Shortcodes.php | File | 6.22 KB | 0644 |
|
Updater.php | File | 1.71 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|