Uses Intializer to check permissions before running Activator
This commit is contained in:
@ -5,15 +5,6 @@ namespace MailPoet\Config;
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Activator {
|
||||
private $access_control;
|
||||
|
||||
function __construct(AccessControl $access_control) {
|
||||
$this->access_control = $access_control;
|
||||
if(!$this->access_control->validatePermission(AccessControl::PERMISSION_UPDATE_PLUGIN)) {
|
||||
throw new \Exception(__('You do not have permission to activate/deactivate MailPoet plugin.', 'mailpoet'));
|
||||
}
|
||||
}
|
||||
|
||||
function activate() {
|
||||
$migrator = new Migrator();
|
||||
$migrator->up();
|
||||
|
@ -136,6 +136,9 @@ class Initializer {
|
||||
|
||||
// if current db version and plugin version differ
|
||||
if(version_compare($current_db_version, Env::$version) !== 0) {
|
||||
if(!$this->access_control->validatePermission(AccessControl::PERMISSION_UPDATE_PLUGIN)) {
|
||||
throw new \Exception(__('You do not have permission to activate/deactivate MailPoet plugin.', 'mailpoet'));
|
||||
}
|
||||
$activator = new Activator($this->access_control);
|
||||
$activator->activate();
|
||||
}
|
||||
|
Reference in New Issue
Block a user