enable reporting saving errors back to web ui.

This commit is contained in:
Isaac Connor 2021-03-22 12:59:41 -04:00
parent 3fdd2bff7f
commit be0841832e
1 changed files with 13 additions and 7 deletions

View File

@ -18,9 +18,11 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// //
global $error_message;
// Event scope actions, view permissions only required // Event scope actions, view permissions only required
if ( !canView('Events') ) { 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; return;
} }
@ -65,12 +67,13 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
$changes = $filter->changes($_REQUEST['filter']); $changes = $filter->changes($_REQUEST['filter']);
ZM\Debug('Changes: ' . print_r($changes,true)); ZM\Debug('Changes: ' . print_r($changes,true));
if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { if ($filter->Id() and ($action == 'Save')) {
if ( $filter->Background() ) if ($filter->Background()) $filter->control('stop');
$filter->control('stop'); if (!$filter->save($changes)) {
$filter->save($changes); $error_message = $filter->get_last_error();
return;
}
} else { } else {
if ( $action == 'execute' ) { if ( $action == 'execute' ) {
if ( count($changes) ) { if ( count($changes) ) {
$filter->Name('_TempFilter'.time()); $filter->Name('_TempFilter'.time());
@ -79,7 +82,10 @@ if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) {
} else if ( $action == 'SaveAs' ) { } else if ( $action == 'SaveAs' ) {
$filter->Id(null); $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 // We update the request id so that the newly saved filter is auto-selected
$_REQUEST['Id'] = $filter->Id(); $_REQUEST['Id'] = $filter->Id();