Files
newznab-tmux/public/admin/menu-edit.php
T
2018-01-10 12:57:15 +01:00

55 lines
1.3 KiB
PHP

<?php
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
use App\Models\Menu;
use App\Models\UserRole;
$page = new AdminPage();
$id = 0;
// Get the user roles.
$userroles = UserRole::getRoles();
$roles = [];
foreach ($userroles as $r) {
$roles[$r['id']] = $r['name'];
}
// set the current action
$action = $_REQUEST['action'] ?? 'view';
switch ($action) {
case 'submit':
if ($_POST['id'] === '') {
\App\Models\Menu::addMenu($_POST);
} else {
$ret = Menu::updateMenu($_POST);
}
header('Location:'.WWW_TOP.'/menu-list.php');
break;
case 'view':
default:
$menuRow = [
'id' => '', 'title' => '', 'href' => '', 'tooltip' => '',
'menueval' => '', 'role' => 0, 'ordinal' => 0, 'newwindow' => 0,
];
if (isset($_GET['id'])) {
$id = $_GET['id'];
$menuRow = Menu::getById($id);
}
$page->title = 'Menu Edit';
$page->smarty->assign('menu', $menuRow);
break;
}
$page->smarty->assign('yesno_ids', [1, 0]);
$page->smarty->assign('yesno_names', ['Yes', 'No']);
$page->smarty->assign('role_ids', array_keys($roles));
$page->smarty->assign('role_names', $roles);
$page->content = $page->smarty->fetch('menu-edit.tpl');
$page->render();