$item = $tree->getCategory(); if ($item) { $result = $this->getResult('item_id', $this->registry->core . 'menu_items', null, array('where' => 'url_id=' . $item['url_id'])); if ($result) { $num_rows = count($result); } else { $pass = false; } // if just one url depends on this item then delete it. if ($num_rows == 1) { $result = $this->remove($this->registry->core . 'menu_urls', 'url_id=' . $item['url_id']); $pass = $result ? true : false; } } if ($num_rows) { $result = $tree->remove($this->registry->params['item']); $pass = $result ? true : false; } if ($pass) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu item was successfully deleted.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu item could not be deleted due to an error.</h2>'; } $menuBar = array('back' => '/menu/view/id-' . $this->registry->params['id']); } else { $menuBar = array('cancel' => '/menu/view/id-' . $this->registry->params['id'], 'delete' => '/menu/view/id-' . $this->registry->params['id'] . '/action-delete/itemAction-delete/item-' . $this->registry->params['item']); $params['TYPE'] = 'warning'; $params['MESSAGE'] = 'Are you sure you want to delete this menu item'; }
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $menuBar = array(); if ($this->registry->params['comfirm'] == 'delete') { $tree = new NestedTreeAdmin($ushop->db_name . 'product_categories', $this->registry->params['id'], 'category'); $res = $tree->remove($this->registry->params['id']); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Category was successfully deleted.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Category could not be deleted due to an error.</h2>'; } // done! $menuBar = array('back' => $_SESSION['referer_link']); } else { $menuBar = array('cancel' => $_SESSION['referer_link'], 'delete' => '/ushop/products/action-delete_category/id-' . $this->registry->params['id'] . '/comfirm-delete'); $params['TYPE'] = 'warning'; $params['MESSAGE'] = 'Are you sure you want to delete this category'; } if (isset($params)) { $params['CONTENT'] = $this->makeMessageBar($menuBar, 24); $this->content .= $this->message($params); } } else { header("Location:" . $this->get('config.server.web_url')); exit; }