public function installAllPaidPlugins()
{
Piwik::checkUserHasSuperUserAccess();
$this->dieIfPluginsAdminIsDisabled();
Plugin\ControllerAdmin::displayWarningIfConfigFileNotWritable();
Nonce::checkNonce(static::INSTALL_NONCE);
$paidPlugins = $this->plugins->getAllPaidPlugins();
$hasErrors = false;
foreach ($paidPlugins as $paidPlugin) {
if (!$this->canPluginBeInstalled($paidPlugin)) {
continue;
}
$pluginName = $paidPlugin['name'];
try {
$this->pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName);
} catch (\Exception $e) {
$notification = new Notification($e->getMessage());
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('Marketplace_Install' . $pluginName, $notification);
$hasErrors = true;
}
}
if ($hasErrors) {
Url::redirectToReferrer();
return;
}
$dependency = new Plugin\Dependency();
for ($i = 0; $i <= 10; $i++) {
foreach ($paidPlugins as $index => $paidPlugin) {
$pluginName = $paidPlugin['name'];
if ($this->pluginManager->isPluginActivated($pluginName)) {
unset($paidPlugins[$index]);
continue;
}
if (empty($paidPlugin['require']) || !$dependency->hasDependencyToDisabledPlugin($paidPlugin['require'])) {
unset($paidPlugins[$index]);
try {
$this->pluginManager->activatePlugin($pluginName);
} catch (Exception $e) {
$hasErrors = true;
$notification = new Notification($e->getMessage());
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('Marketplace_Install' . $pluginName, $notification);
}
}
}
}
if ($hasErrors) {
$notification = new Notification(Piwik::translate('Marketplace_OnlySomePaidPluginsInstalledAndActivated'));
$notification->context = Notification::CONTEXT_INFO;
} else {
$notification = new Notification(Piwik::translate('Marketplace_AllPaidPluginsInstalledAndActivated'));
$notification->context = Notification::CONTEXT_SUCCESS;
}
Notification\Manager::notify('Marketplace_InstallAll', $notification);
Url::redirectToReferrer();
}