Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request from GHSA-mc98-xjm3-c4fm
Remove unwanted update in dashboard controller
  • Loading branch information
matks committed Jun 29, 2020
2 parents f2f4102 + 5b100ce commit 0f0d623
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
24 changes: 24 additions & 0 deletions classes/module/Module.php
Expand Up @@ -3427,6 +3427,30 @@ public function get($serviceName)

return false;
}

/**
* Save dashboard configuration
*
* @param array $config
*
* @return array Array of errors
*/
public function validateDashConfig(array $config): array
{
return [];
}

/**
* Save dashboard configuration
*
* @param array $config
*
* @return bool Determines if the save returns an error
*/
public function saveDashConfig(array $config): bool
{
return false;
}
}

function ps_module_version_sort($a, $b)
Expand Down
18 changes: 4 additions & 14 deletions controllers/admin/AdminDashboardController.php
Expand Up @@ -519,21 +519,11 @@ public function ajaxProcessSaveDashConfig()
);

if (Validate::isModuleName($module) && $module_obj = Module::getInstanceByName($module)) {
if (Validate::isLoadedObject($module_obj) && method_exists($module_obj, 'validateDashConfig')) {
$return['errors'] = $module_obj->validateDashConfig($configs);
}
if (!count($return['errors'])) {
if (Validate::isLoadedObject($module_obj) && method_exists($module_obj, 'saveDashConfig')) {
$return['has_errors'] = $module_obj->saveDashConfig($configs);
} elseif (is_array($configs) && count($configs)) {
foreach ($configs as $name => $value) {
if (Validate::isConfigName($name)) {
Configuration::updateValue($name, $value);
}
}
}
} else {
$return['errors'] = $module_obj->validateDashConfig($configs);
if (count($return['errors'])) {
$return['has_errors'] = true;
} else {
$return['has_errors'] = $module_obj->saveDashConfig($configs);
}
}

Expand Down

0 comments on commit 0f0d623

Please sign in to comment.