Skip to content
Extraits de code Groupes Projets
Valider b969dc79 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #4126 fix settings were not saved

parent 313ccf74
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -159,7 +159,8 @@ class Settings ...@@ -159,7 +159,8 @@ class Settings
$setting = $this->getSetting($name); $setting = $this->getSetting($name);
if (empty($setting)) { if (empty($setting)) {
throw new \Exception('This setting does not exist'); // TODO escape $name? or is it automatically escaped?
throw new \Exception(sprintf('The setting %s does not exist', $name));
} }
if (!$setting['displayedForCurrentUser']) { if (!$setting['displayedForCurrentUser']) {
......
...@@ -30,10 +30,10 @@ class Manager ...@@ -30,10 +30,10 @@ class Manager
{ {
if (empty(static::$settings)) { if (empty(static::$settings)) {
$pluginSettings = array('Login' => 'Piwik\\Plugins\\Login\\Settings'); $pluginSettings = array();
// TODO: document hook and think about better name // TODO: document hook and think about better name
Piwik::postEvent('Plugin.addSettings', $pluginSettings); Piwik::postEvent('Plugin.addSettings', array(&$pluginSettings));
$settings = array(); $settings = array();
foreach ($pluginSettings as $pluginName => $pluginSetting) { foreach ($pluginSettings as $pluginName => $pluginSetting) {
......
...@@ -110,13 +110,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin ...@@ -110,13 +110,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
Piwik::checkUserIsNotAnonymous(); Piwik::checkUserIsNotAnonymous();
Json::sendHeaderJSON(); Json::sendHeaderJSON();
$updateSettings = Common::getRequestVar('settings', null, 'json'); $changedPluginSettings = Common::getRequestVar('settings', null, 'array');
$pluginSettings = SettingsManager::getAllPluginSettings(); $pluginSettings = SettingsManager::getAllPluginSettings();
try { try {
foreach ($updateSettings as $pluginName => $serializedSetting) { foreach ($changedPluginSettings as $pluginName => $changedPluginSetting) {
$unserializedSettings = UrlHelper::getArrayFromQueryString($serializedSetting);
if (!array_key_exists($pluginName, $pluginSettings)) { if (!array_key_exists($pluginName, $pluginSettings)) {
// this plugin is not using settings, skip it // this plugin is not using settings, skip it
...@@ -125,8 +124,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin ...@@ -125,8 +124,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
$pluginSetting = $pluginSettings[$pluginName]; $pluginSetting = $pluginSettings[$pluginName];
foreach ($unserializedSettings as $key => $value) { foreach ($changedPluginSetting as $changedSetting) {
$pluginSetting->setSettingValue($key, $value); $pluginSetting->setSettingValue($changedSetting['name'], $changedSetting['value']);
} }
} }
......
...@@ -22,7 +22,7 @@ $(document).ready(function () { ...@@ -22,7 +22,7 @@ $(document).ready(function () {
module: 'CoreAdminHome', module: 'CoreAdminHome',
action: 'setPluginSettings' action: 'setPluginSettings'
}, 'GET'); }, 'GET');
ajaxHandler.addParams({settings: JSON.stringify(getSettings())}, 'POST'); ajaxHandler.addParams({settings: getSettings()}, 'POST');
ajaxHandler.redirectOnSuccess(); ajaxHandler.redirectOnSuccess();
ajaxHandler.setLoadingElement(getLoadingElement()); ajaxHandler.setLoadingElement(getLoadingElement());
ajaxHandler.setErrorElement(getErrorElement()); ajaxHandler.setErrorElement(getErrorElement());
...@@ -39,7 +39,7 @@ $(document).ready(function () { ...@@ -39,7 +39,7 @@ $(document).ready(function () {
$pluginSection = $(pluginSection); $pluginSection = $(pluginSection);
var pluginName = $pluginSection.attr('data-pluginname'); var pluginName = $pluginSection.attr('data-pluginname');
var serialized = $('input, textarea, select', $pluginSection ).serialize(); var serialized = $('input, textarea, select', $pluginSection ).serializeArray();
values[pluginName] = serialized; values[pluginName] = serialized;
}); });
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter