From be0841832ec9498ba41f38bd05f17d0f5001e81c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 22 Mar 2021 12:59:41 -0400 Subject: [PATCH] enable reporting saving errors back to web ui. --- web/includes/actions/filter.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/web/includes/actions/filter.php b/web/includes/actions/filter.php index 9216ef723..08eb8c020 100644 --- a/web/includes/actions/filter.php +++ b/web/includes/actions/filter.php @@ -18,9 +18,11 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // +global $error_message; // Event scope actions, view permissions only required if ( !canView('Events') ) { - ZM\Warning('You do not have permission to view Events.'); + $error_message = 'You do not have permission to view Events.'; + ZM\Warning($error_message); return; } @@ -65,12 +67,13 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { $changes = $filter->changes($_REQUEST['filter']); ZM\Debug('Changes: ' . print_r($changes,true)); - if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { - if ( $filter->Background() ) - $filter->control('stop'); - $filter->save($changes); + if ($filter->Id() and ($action == 'Save')) { + if ($filter->Background()) $filter->control('stop'); + if (!$filter->save($changes)) { + $error_message = $filter->get_last_error(); + return; + } } else { - if ( $action == 'execute' ) { if ( count($changes) ) { $filter->Name('_TempFilter'.time()); @@ -79,7 +82,10 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { } else if ( $action == 'SaveAs' ) { $filter->Id(null); } - $filter->save($changes); + if (!$filter->save($changes)) { + $error_message = $filter->get_last_error(); + return; + } // We update the request id so that the newly saved filter is auto-selected $_REQUEST['Id'] = $filter->Id();