Piwik\

Access

Singleton that manages user access to Matomo (formerly Piwik) resources.

To check whether a user has access to a resource, use one of the Piwik::checkUser... methods.

In Matomo there are four different access levels:

  • no access: Users with this access level cannot view the resource.
  • view access: Users with this access level can view the resource, but cannot modify it.
  • admin access: Users with this access level can view and modify the resource.
  • Super User access: Only the Super User has this access level. It means the user can do whatever they want.

                     Super user access is required to set some configuration options.
                     All other options are specific to the user or to a website.
    

Access is granted per website. Uses with access for a website can view all data associated with that website.

Methods

The class defines the following methods:

  • doAsSuperUser() — Executes a callback with superuser privileges, making sure those privileges are rescinded before this method exits.

doAsSuperUser()

Executes a callback with superuser privileges, making sure those privileges are rescinded before this method exits.

Privileges will be rescinded even if an exception is thrown.

Signature

  • It accepts the following parameter(s):

    • $function (Piwik\callback) — The callback to execute. Should accept no arguments.
  • Returns: mixed — The result of $function.

  • It throws one of the following exceptions:
    • Exception — rethrows any exceptions thrown by $function.