From cb4481353bbd324f0e93cf11f166e81067f1990d Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Tue, 21 May 2024 12:07:35 +0300 Subject: [PATCH] Added "action" for the "delete" button (montage.php) --- web/includes/actions/montage.php | 34 +++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/web/includes/actions/montage.php b/web/includes/actions/montage.php index c4b55b2af..18ebb2b68 100644 --- a/web/includes/actions/montage.php +++ b/web/includes/actions/montage.php @@ -21,9 +21,9 @@ require_once('includes/MontageLayout.php'); if ( isset($_REQUEST['object']) ) { if ( $_REQUEST['object'] == 'MontageLayout' ) { - if ($action == 'Save') { - $Layout = null; + $Layout = null; + if ($action == 'Save') { # Name is only populated when creating a new layout if ( $_REQUEST['Name'] != '' ) { $Layout = new ZM\MontageLayout(); @@ -44,7 +44,35 @@ if ( isset($_REQUEST['object']) ) { ZM\Warning('Need System permissions to edit layouts'); return; } - } // end if save + } else if ($action == 'Delete') { // end if save + if ( isset($_REQUEST['zmMontageLayout']) ) { + $Layout = new ZM\MontageLayout($_REQUEST['zmMontageLayout']); + } else { + ZM\Warning('Name of layout to be deleted is not specified'); + return; + } + + if (canEdit('System')) { + if ($Layout->Id()) { + $Layout->delete(); + zm_session_start(); + unset($_SESSION["zmMontageLayout"]); + $_SESSION['zmMontageLayout'] = ''; + session_write_close(); + unset($_COOKIE['zmMontageLayout']); + zm_setcookie('zmMontageLayout', '', array('expires'=>time()-3600*24)); //!!! After this JS still sees cookies, strange !!! + $redirect = '?view=montage'; + } else { + ZM\Warning('Layout Id=' . $_REQUEST['zmMontageLayout'] . ' not found for delete'); + $redirect = '?view=montage'; + } + } else { + ZM\Warning('Need System permissions to delete layouts'); + $redirect = '?view=montage'; + } + } else {// end if delete + ZM\Warning("Unsupported action $action in montage"); + } // end if else } # end if isset($_REQUEST['object'] ) } # end if isset($_REQUEST['object'] ) ?>