mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
86 lines
2.6 KiB
PHP
86 lines
2.6 KiB
PHP
<?php
|
|
|
|
require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'smarty.php';
|
|
|
|
use App\Models\Category;
|
|
use App\Models\UserRole;
|
|
use App\Models\RoleExcludedCategory;
|
|
|
|
$page = new AdminPage();
|
|
|
|
// Get the user roles.
|
|
$userRoles = UserRole::getRoles();
|
|
$roles = [];
|
|
foreach ($userRoles as $userRole) {
|
|
$roles[$userRole['id']] = $userRole['name'];
|
|
}
|
|
|
|
switch ($_REQUEST['action'] ?? 'view') {
|
|
case 'add':
|
|
$page->title = 'User Roles Add';
|
|
$role = [
|
|
'id' => '',
|
|
'name' => '',
|
|
'apirequests' => '',
|
|
'downloadrequests' => '',
|
|
'defaultinvites' => '',
|
|
'canpreview' => 0,
|
|
'hideads' => 0,
|
|
'donation' => 0,
|
|
'addyears' => 0,
|
|
];
|
|
$page->smarty->assign('role', $role);
|
|
break;
|
|
|
|
case 'submit':
|
|
if ($_POST['id'] === '') {
|
|
$role = UserRole::addRole(
|
|
$_POST['name'],
|
|
$_POST['apirequests'],
|
|
$_POST['downloadrequests'],
|
|
$_POST['defaultinvites'],
|
|
$_POST['canpreview'],
|
|
$_POST['hideads'],
|
|
$_POST['donation'],
|
|
$_POST['addyears']
|
|
);
|
|
header('Location:'.WWW_TOP.'/role-list.php');
|
|
} else {
|
|
$role = UserRole::updateRole(
|
|
$_POST['id'],
|
|
$_POST['name'],
|
|
$_POST['apirequests'],
|
|
$_POST['downloadrequests'],
|
|
$_POST['defaultinvites'],
|
|
$_POST['isdefault'],
|
|
$_POST['canpreview'],
|
|
$_POST['hideads'],
|
|
$_POST['donation'],
|
|
$_POST['addyears']
|
|
);
|
|
header('Location:'.WWW_TOP.'/role-list.php');
|
|
|
|
$_POST['exccat'] = (! isset($_POST['exccat']) || ! is_array($_POST['exccat'])) ? [] : $_POST['exccat'];
|
|
RoleExcludedCategory::addRoleCategoryExclusions($_POST['id'], $_POST['exccat']);
|
|
}
|
|
$page->smarty->assign('role', $role);
|
|
break;
|
|
|
|
case 'view':
|
|
default:
|
|
if (isset($_GET['id'])) {
|
|
$page->title = 'User Roles Edit';
|
|
$role = UserRole::getRoleById($_GET['id']);
|
|
$page->smarty->assign('role', $role);
|
|
$page->smarty->assign('roleexccat', RoleExcludedCategory::getRoleCategoryExclusion($_GET['id']));
|
|
}
|
|
break;
|
|
}
|
|
|
|
$page->smarty->assign('yesno_ids', [1, 0]);
|
|
$page->smarty->assign('yesno_names', ['Yes', 'No']);
|
|
$page->smarty->assign('catlist', Category::getForSelect(false));
|
|
|
|
$page->content = $page->smarty->fetch('role-edit.tpl');
|
|
$page->render();
|