public function enablePlugin($pluginName, $filter = 'all')
{
if (!Gdn::request()->isAuthenticatedPostBack(true)) {
throw new Exception('Requires POST', 405);
}
$this->permission('Garden.Settings.Manage');
$action = 'none';
if ($filter == 'disabled') {
$action = 'SlideUp';
}
$addon = Gdn::addonManager()->lookupAddon($pluginName);
try {
$validation = new Gdn_Validation();
if (!Gdn::pluginManager()->enablePlugin($pluginName, $validation)) {
$this->Form->setValidationResults($validation->results());
} else {
Gdn_LibraryMap::ClearCache();
$this->informMessage(sprintf(t('%s Enabled.'), val('name', $addon->getInfo(), t('Plugin'))));
}
$this->EventArguments['PluginName'] = $pluginName;
$this->EventArguments['Validation'] = $validation;
$this->fireEvent('AfterEnablePlugin');
} catch (Exception $e) {
$this->Form->addError($e);
}
$this->handleAddonToggle($pluginName, $addon->getInfo(), 'plugins', true, $filter, $action);
}