Skip to content

Commit

Permalink
Merge pull request #58 from OCTRI/reddev-539-save-fix
Browse files Browse the repository at this point in the history
REDDEV-539 save fix
  • Loading branch information
wsams authored Jul 19, 2018
2 parents 637aabc + a93120c commit bd3c76e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/persist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
require_once dirname(realpath(__FILE__)) . '/../../../redcap_connect.php';
require_once dirname(realpath(__FILE__)) . '/permissions.php';

// Allows project settings to be saved when users don't have explicit module permission.
$module->disableUserBasedSettingPermissions();

/**
* Validates that input is shaped like a chart definition.
*
Expand Down Expand Up @@ -86,8 +89,12 @@ function sanitizeChartConfig($charts) {
if (inputIsValid($data)) {
try {
sanitizeChartConfig($data->charts);
$module->setProjectSetting('chart-definitions', $data->charts);
$response->item_count = 1;
if ($module->canEditVizrCharts()) {
$module->setProjectSetting('chart-definitions', $data->charts);
$response->item_count = 1;
} else {
$response->errors = array("You do not have permission to modify chart definitions.");
}
} catch (Exception $e) {
error_log("Vizr caught an exception persisting configuration for PID $project_id: " . $e->getMessage());
$response->errors = array("The settings could not be saved due to an error.");
Expand Down

0 comments on commit bd3c76e

Please sign in to comment.