diff options
author | jnew-gh <github@hazelden.ca> | 2021-04-21 19:39:09 +0300 |
---|---|---|
committer | jnew-gh <github@hazelden.ca> | 2021-04-21 19:39:09 +0300 |
commit | dfbcf35b9d2d396036c5353cd510191d7ddf6fc1 (patch) | |
tree | d6dfd34e44c5126405ec977dd0bb65c62d2e08d5 | |
parent | ea7d240faa03a1a5a620a8a5aa7e7e3ab3dd3031 (diff) |
Check if any options have been removed or added to $options[]
-rw-r--r-- | dmarcts-report-viewer-common.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dmarcts-report-viewer-common.php b/dmarcts-report-viewer-common.php index c218e2d..47146c3 100644 --- a/dmarcts-report-viewer-common.php +++ b/dmarcts-report-viewer-common.php @@ -376,6 +376,21 @@ function configure() { exit; } else { // Not POST $cookie_options = json_decode($_COOKIE[$cookie_name], true); + + // Check if any options have been removed or added to $options[] + // Update $cookie_options with any new options from $options (excluding headings) + foreach ($option as $option_name) { + if ( $options[$option_name]['option_type'] != "heading" && is_null($cookie_options[$option_name]) ) { + $cookie_options[$option_name] = $options[$option_name]['option_value']; + } + } + // Remove any options from $cookie_options which are not in $options + foreach ($cookie_options as $key => $value) { + if ( $options[$key] == null ) { + unset($cookie_options[$key]); + } + } + setcookie($cookie_name, json_encode($cookie_options), time() + $cookie_timeout, "/"); } } } |