Skip to content

Commit

Permalink
Merge pull request #5 from AgID/develop
Browse files Browse the repository at this point in the history
Consolidation in master
  • Loading branch information
pdavide authored Apr 17, 2021
2 parents 2a4f6d2 + 9cc2088 commit fd45c97
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.0.0

Rename plugin
Extend the restrictions to some other modules/actions

## 0.1.0

First release
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Matomo UsersManagerOnlySuperUser Plugin
# Matomo SuperUserOnlyRestrictions Plugin

## Description

This plugin restricts the ability to edit users via userSettings to super users only.
This plugin restricts some modules/actions to super users only.

## Installation

Expand All @@ -13,9 +13,9 @@ Refer to [this Matomo FAQ](https://matomo.org/faq/plugins/faq_21/).
Add the following section to your `config.ini.php`:

```ini
[UsersManagerOnlySuperUser]
users_manager_only_super_user_enabled = true
[SuperUserOnlyRestrictions]
super_user_only_restrictions_enabled = true

```

**Make sure you have direct access to the `config.ini.php` file before using this plugin**
**Make sure you have direct access to the `config.ini.php` file before using this plugin**
18 changes: 11 additions & 7 deletions UsersManagerOnlySuperUser.php → SuperUserOnlyRestrictions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

namespace Piwik\Plugins\UsersManagerOnlySuperUser;
namespace Piwik\Plugins\SuperUserOnlyRestrictions;

use Piwik\Config;
use Piwik\Piwik;
use Piwik\Plugins\UsersManager\UsersManager;

class UsersManagerOnlySuperUser extends \Piwik\Plugin
class SuperUserOnlyRestrictions extends \Piwik\Plugin
{
/**
* The configuration array.
Expand All @@ -23,7 +23,7 @@ class UsersManagerOnlySuperUser extends \Piwik\Plugin
protected $pluginConfig;

/**
* Construct a new LoginFilterIp instance.
* Construct a new SuperUserOnlyRestrictions instance.
*/
public function __construct() {
parent::__construct();
Expand All @@ -39,16 +39,20 @@ public function __construct() {
public function registerEvents()
{
return [
'Controller.UsersManager.userSettings' => 'checkUserHasSuperUserAccess',
'Controller.UsersManager.userSettings' => 'restrictAccess',
'Controller.Widgetize.index' => 'restrictAccess',
'Controller.API.listAllAPI' => 'restrictAccess',
'Controller.CoreAdminHome.trackingCodeGenerator' => 'restrictAccess',
];
}

/**
* Check if user has super user access.
* Restrict access to super users only, if the plugin is enabled.
*/
public function checkUserHasSuperUserAccess()
public function restrictAccess()
{
if(isset($this->pluginConfig['users_manager_only_super_user_enabled']) && $this->pluginConfig['users_manager_only_super_user_enabled']){
if(isset($this->pluginConfig['super_user_only_restrictions_enabled'])
&& $this->pluginConfig['super_user_only_restrictions_enabled']) {
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSuperUserAccess();
}
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## FAQ
# FAQ

See readme.
See readme.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Documentation
# Documentation

See readme.
See readme.
6 changes: 3 additions & 3 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "UsersManagerOnlySuperUser",
"description": "This plugin restricts the ability to edit users via userSettings to super users only",
"version": "0.2.0",
"name": "SuperUserOnlyRestrictions",
"description": "This plugin restricts some modules/actions to super users only",
"version": "1.0.0",
"theme": false,
"require": {
"piwik": ">=3.13.0-stable,<4.0.0-b1"
Expand Down

0 comments on commit fd45c97

Please sign in to comment.