- update_sql( $id, {
- sql => $sql,
- name => $reportname,
- group => $group,
- subgroup => $subgroup,
- notes => $notes,
- cache_expiry => $cache_expiry,
- public => $public,
- } );
- $template->param(
- 'save_successful' => 1,
- 'reportname' => $reportname,
- 'id' => $id,
- );
+
+ # Check defined SQL parameters for authorised value validity
+ my $problematic_authvals = ValidateSQLParameters($sql);
+
+ if ( scalar @$problematic_authvals > 0 && not $save_anyway ) {
+ # There's at least one problematic parameter, report to the
+ # GUI and provide all user input for further actions
+ $template->param(
+ 'id' => $id,
+ 'sql' => $sql,
+ 'reportname' => $reportname,
+ 'group' => $group,
+ 'subgroup' => $subgroup,
+ 'notes' => $notes,
+ 'cache_expiry' => $cache_expiry,
+ 'cache_expiry_units' => $cache_expiry_units,
+ 'public' => $public,
+ 'problematic_authvals' => $problematic_authvals,
+ 'warn_authval_problem' => 1,
+ 'phase_update' => 1
+ );
+
+ } else {
+ # No params problem found or asked to save anyway
+ update_sql( $id, {
+ sql => $sql,
+ name => $reportname,
+ group => $group,
+ subgroup => $subgroup,
+ notes => $notes,
+ cache_expiry => $cache_expiry,
+ public => $public,
+ } );
+ $template->param(
+ 'save_successful' => 1,
+ 'reportname' => $reportname,
+ 'id' => $id,
+ );
+ }