TrackingSettings
4 years ago
views
3 years ago
AccessSettings.php
4 years ago
Admin.php
4 years ago
AdminSettings.php
4 years ago
AdminSettingsInterface.php
6 years ago
AdvancedSettings.php
4 years ago
Chart.php
4 years ago
CookieConsent.php
4 years ago
Dashboard.php
4 years ago
ExclusionSettings.php
4 years ago
GeolocationSettings.php
4 years ago
GetStarted.php
4 years ago
ImportWpStatistics.php
4 years ago
Info.php
4 years ago
InvalidIpException.php
4 years ago
Marketplace.php
4 years ago
Menu.php
3 years ago
PrivacySettings.php
4 years ago
SafeModeMenu.php
4 years ago
Summary.php
4 years ago
SystemReport.php
3 years ago
TrackingSettings.php
4 years ago
AccessSettings.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Matomo - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * @package matomo |
| 8 | */ |
| 9 | |
| 10 | namespace WpMatomo\Admin; |
| 11 | |
| 12 | use WpMatomo\Access; |
| 13 | use WpMatomo\Capabilities; |
| 14 | use WpMatomo\Roles; |
| 15 | use WpMatomo\Settings; |
| 16 | |
| 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | exit; // if accessed directly |
| 19 | } |
| 20 | |
| 21 | class AccessSettings implements AdminSettingsInterface { |
| 22 | const NONCE_NAME = 'matomo_tracking'; |
| 23 | const FORM_NAME = 'matomo_role'; |
| 24 | |
| 25 | /** |
| 26 | * @var Access |
| 27 | */ |
| 28 | private $access; |
| 29 | |
| 30 | /** |
| 31 | * @var Settings |
| 32 | */ |
| 33 | private $settings; |
| 34 | |
| 35 | public function __construct( Access $access, Settings $settings ) { |
| 36 | $this->access = $access; |
| 37 | $this->settings = $settings; |
| 38 | } |
| 39 | |
| 40 | public function get_title() { |
| 41 | return esc_html__( 'Access', 'matomo' ); |
| 42 | } |
| 43 | |
| 44 | public function show_settings() { |
| 45 | $this->update_if_submitted(); |
| 46 | |
| 47 | $access = $this->access; |
| 48 | $roles = new Roles( $this->settings ); |
| 49 | $capabilites = new Capabilities( $this->settings ); |
| 50 | include dirname( __FILE__ ) . '/views/access.php'; |
| 51 | } |
| 52 | |
| 53 | private function update_if_submitted() { |
| 54 | if ( isset( $_POST ) |
| 55 | && ! empty( $_POST[ self::FORM_NAME ] ) |
| 56 | && is_admin() |
| 57 | && check_admin_referer( self::NONCE_NAME ) |
| 58 | && current_user_can( Capabilities::KEY_SUPERUSER ) ) { |
| 59 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 60 | $this->access->save( wp_unslash( $_POST[ self::FORM_NAME ] ) ); |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | return false; |
| 66 | } |
| 67 | } |
| 68 |