More manage stuff.

This commit is contained in:
flash 2018-08-15 22:29:18 +02:00
parent fa71040fbc
commit f3760f62ff
20 changed files with 139 additions and 304 deletions

View file

@ -1,134 +0,0 @@
.manage-header {
background-color: #111;
background-image: linear-gradient(0deg, #222, #333);
font-size: 1.5em;
color: #fff;
&__wrapper {
display: flex;
max-width: var(--site-max-width);
margin: 0 auto;
}
&__logo {
padding: 8px 10px;
color: #fff;
text-decoration: none;
display: block;
}
&__navigation {
display: flex;
}
&__navigation {
flex-grow: 1;
flex-shrink: 1;
}
&__logo {
flex-grow: 0;
flex-shrink: 0;
}
&__user {
flex-grow: 0;
flex-shrink: 1;
}
&__menu {
margin: 0 1px;
&__toggle {
padding: 8px 10px;
display: block;
cursor: pointer;
min-width: 50px;
transition: background-color .2s, min-width .2s;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
&--profile {
background-size: contain;
background-repeat: no-repeat;
background-position: right;
padding-right: 45px;
}
&:hover {
background-color: #333;
}
&--active,
&:active {
background-color: #222;
}
}
&__state {
display: none;
&:checked ~ .manage-header__menu__toggle {
background-color: #333;
min-width: 150px;
}
&:checked ~ .manage-header__menu__options {
max-height: 250px;
}
}
&__options {
overflow: hidden;
max-height: 0px;
width: 100%;
position: absolute;
background-color: #333;
z-index: 1000;
transition: max-height .2s;
box-shadow: 0 5px 5px 0 fade(#444, 80%);
&--user {
text-align: right;
}
}
&__link {
padding: 8px 10px;
display: block;
color: inherit;
text-decoration: none;
transition: background-color .2s;
&:hover {
background-color: #444;
}
&:active {
background-color: #2a2a2a;
}
}
&__section {
margin: 1px 2px;
&:first-child {
margin-top: 2px;
}
&:last-child {
margin-bottom: 2px;
}
&:not(:last-child) {
padding-bottom: 1px;
margin-bottom: 1px;
border-bottom: 1px solid #444;
}
}
}
}

View file

@ -1,5 +1,4 @@
@import "classes/form"; @import "classes/form";
@import "classes/header";
@import "classes/listing"; @import "classes/listing";
@import "classes/changelog-change"; @import "classes/changelog-change";

View file

@ -63,24 +63,19 @@
margin-left: 2px; margin-left: 2px;
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
flex: 0 0 auto;
&--active { &--active {
pointer-events: auto; pointer-events: auto;
} }
&--title {
flex: 1 1 auto;
}
&--country { &--country {
flex: 0 0 auto;
align-items: baseline; align-items: baseline;
vertical-align: middle; vertical-align: middle;
margin-right: 4px; margin-right: 4px;
} }
&--donator { &--donator {
flex: 0 0 auto;
background-image: url('https://static.flash.moe/images/tenshi.png'); background-image: url('https://static.flash.moe/images/tenshi.png');
width: 37px; width: 37px;
height: 11px; height: 11px;

View file

@ -85,7 +85,7 @@ if (!$changes) {
http_response_code(404); http_response_code(404);
} }
if (!empty($changelogDate)) { if (!empty($changelogDate) && count($changes) > 0) {
tpl_vars([ tpl_vars([
'comments_category' => $commentsCategory = comments_category_info("changelog-date-{$changelogDate}", true), 'comments_category' => $commentsCategory = comments_category_info("changelog-date-{$changelogDate}", true),
'comments' => comments_category_get($commentsCategory['category_id'], $app->getUserId()), 'comments' => comments_category_get($commentsCategory['category_id'], $app->getUserId()),

View file

@ -1,17 +0,0 @@
<?php
require_once __DIR__ . '/../../misuzu.php';
switch ($_GET['v'] ?? null) {
default:
case 'listing':
echo 'forum listing here';
break;
case 'permissions':
echo 'permissions here, not even sure what this would do';
break;
case 'settings':
echo 'overall forum settings here';
break;
}

View file

@ -15,14 +15,25 @@ switch ($_GET['v'] ?? null) {
break; break;
} }
var_dump(audit_log_list(0, 20)); tpl_var('log_dump', print_r(audit_log_list(0, 50), true));
echo tpl_render('manage.general.logs');
break; break;
case 'emoticons': case 'emoticons':
echo 'soon as well'; if (!perms_check($generalPerms, MSZ_GENERAL_PERM_MANAGE_EMOTICONS)) {
echo render_error(403);
break;
}
echo tpl_render('manage.general.emoticons');
break; break;
case 'settings': case 'settings':
echo 'somewhat soon i guess'; if (!perms_check($generalPerms, MSZ_GENERAL_PERM_MANAGE_SETTINGS)) {
echo render_error(403);
break;
}
echo tpl_render('manage.general.settings');
break; break;
} }

View file

@ -272,7 +272,7 @@ switch ($_GET['v'] ?? null) {
$getManageRoles = Database::prepare(' $getManageRoles = Database::prepare('
SELECT SELECT
`role_id`, `role_colour`, `role_name`, `role_id`, `role_colour`, `role_name`, `role_title`,
( (
SELECT COUNT(`user_id`) SELECT COUNT(`user_id`)
FROM `msz_user_roles` as ur FROM `msz_user_roles` as ur

View file

@ -12,110 +12,70 @@ function manage_get_menu(int $userId): array
} }
$menu = []; $menu = [];
$menu['General']['Overview'] = '/manage/index.php?v=overview';
$menu['General'] = [
'Overview' => '/manage/index.php?v=overview',
];
if (perms_check($perms['general'], MSZ_GENERAL_PERM_VIEW_LOGS)) { if (perms_check($perms['general'], MSZ_GENERAL_PERM_VIEW_LOGS)) {
$menu['General']['Logs'] = '/manage/index.php?v=logs'; $menu['General']['Logs'] = '/manage/index.php?v=logs';
} }
if (perms_check( if (perms_check($perms['general'], MSZ_GENERAL_PERM_MANAGE_EMOTICONS)) {
$perms['general'], $menu['General']['Emoticons'] = '/manage/index.php?v=emoticons';
MSZ_GENERAL_PERM_MANAGE_EMOTICONS | MSZ_GENERAL_PERM_MANAGE_SETTINGS
)) {
if (perms_check($perms['general'], MSZ_GENERAL_PERM_MANAGE_EMOTICONS)) {
$menu['General']['Emoticons'] = '/manage/index.php?v=emoticons';
}
if (perms_check($perms['general'], MSZ_GENERAL_PERM_MANAGE_SETTINGS)) {
$menu['General']['Settings'] = '/manage/index.php?v=settings';
}
} }
$canUserManage = MSZ_USER_PERM_MANAGE_USERS | MSZ_USER_PERM_MANAGE_ROLES if (perms_check($perms['general'], MSZ_GENERAL_PERM_MANAGE_SETTINGS)) {
| MSZ_USER_PERM_MANAGE_PERMS | MSZ_USER_PERM_MANAGE_REPORTS $menu['General']['Settings'] = '/manage/index.php?v=settings';
| MSZ_USER_PERM_MANAGE_RESTRICTIONS | MSZ_USER_PERM_MANAGE_BLACKLISTS;
if (perms_check($perms['user'], $canUserManage)) {
$menu['Users'] = [];
if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_USERS | MSZ_USER_PERM_MANAGE_PERMS)) {
$menu['Users']['Listing'] = '/manage/users.php?v=listing';
}
if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_ROLES | MSZ_USER_PERM_MANAGE_PERMS)) {
$menu['Users']['Roles'] = '/manage/users.php?v=roles';
}
if (perms_check(
$perms['user'],
MSZ_USER_PERM_MANAGE_REPORTS | MSZ_USER_PERM_MANAGE_RESTRICTIONS | MSZ_USER_PERM_MANAGE_BLACKLISTS
)) {
if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_REPORTS)) {
$menu['Users']['Reports'] = '/manage/users.php?v=reports';
}
if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_RESTRICTIONS)) {
$menu['Users']['Restrictions'] = '/manage/users.php?v=restrictions';
}
if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_BLACKLISTS)) {
$menu['Users']['Blacklisting'] = '/manage/users.php?v=blacklisting';
}
}
} }
$canNewsManage = MSZ_NEWS_PERM_MANAGE_POSTS | MSZ_NEWS_PERM_MANAGE_CATEGORIES; if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_USERS | MSZ_USER_PERM_MANAGE_PERMS)) {
$menu['Users']['Listing'] = '/manage/users.php?v=listing';
if (perms_check($perms['news'], $canNewsManage)) {
$menu['News'] = [];
if (perms_check($perms['news'], MSZ_NEWS_PERM_MANAGE_POSTS)) {
$menu['News']['Posts'] = '/manage/news.php?v=posts';
}
if (perms_check($perms['news'], MSZ_NEWS_PERM_MANAGE_CATEGORIES)) {
$menu['News']['Categories'] = '/manage/news.php?v=categories';
}
} }
$canForumManage = MSZ_FORUM_PERM_MANAGE_FORUMS; if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_ROLES | MSZ_USER_PERM_MANAGE_PERMS)) {
$menu['Users']['Roles'] = '/manage/users.php?v=roles';
if (perms_check($perms['forum'], $canForumManage)) {
$menu['Forums'] = [];
if (perms_check($perms['forum'], MSZ_FORUM_PERM_MANAGE_FORUMS)) {
$menu['Forums']['Listing'] = '/manage/forums.php?v=listing';
}
if (perms_check($perms['forum'], 0)) {
$menu['Forums']['Permissions'] = '/manage/forums.php?v=permissions';
}
if (perms_check($perms['forum'], 0)) {
$menu['Forums']['Settings'] = '/manage/forums.php?v=settings';
}
} }
$canChangelogManage = MSZ_CHANGELOG_PERM_MANAGE_CHANGES | MSZ_CHANGELOG_PERM_MANAGE_TAGS if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_REPORTS)) {
| MSZ_CHANGELOG_PERM_MANAGE_ACTIONS; $menu['Users']['Reports'] = '/manage/users.php?v=reports';
}
if (perms_check($perms['changelog'], $canChangelogManage)) { if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_RESTRICTIONS)) {
$menu['Changelog'] = []; $menu['Users']['Restrictions'] = '/manage/users.php?v=restrictions';
}
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_CHANGES)) { if (perms_check($perms['user'], MSZ_USER_PERM_MANAGE_BLACKLISTS)) {
$menu['Changelog']['Changes'] = '/manage/changelog.php?v=changes'; $menu['Users']['Blacklisting'] = '/manage/users.php?v=blacklisting';
} }
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_TAGS)) { if (perms_check($perms['news'], MSZ_NEWS_PERM_MANAGE_POSTS)) {
$menu['Changelog']['Tags'] = '/manage/changelog.php?v=tags'; $menu['News']['Posts'] = '/manage/news.php?v=posts';
} }
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_ACTIONS)) { if (perms_check($perms['news'], MSZ_NEWS_PERM_MANAGE_CATEGORIES)) {
$menu['Changelog']['Actions'] = '/manage/changelog.php?v=actions'; $menu['News']['Categories'] = '/manage/news.php?v=categories';
} }
if (perms_check($perms['forum'], MSZ_FORUM_PERM_MANAGE_FORUMS)) {
$menu['Forums']['Listing'] = '/manage/forums.php?v=listing';
}
if (perms_check($perms['forum'], 0)) {
$menu['Forums']['Permissions'] = '/manage/forums.php?v=permissions';
}
if (perms_check($perms['forum'], 0)) {
$menu['Forums']['Settings'] = '/manage/forums.php?v=settings';
}
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_CHANGES)) {
$menu['Changelog']['Changes'] = '/manage/changelog.php?v=changes';
}
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_TAGS)) {
$menu['Changelog']['Tags'] = '/manage/changelog.php?v=tags';
}
if (perms_check($perms['changelog'], MSZ_CHANGELOG_PERM_MANAGE_ACTIONS)) {
$menu['Changelog']['Actions'] = '/manage/changelog.php?v=actions';
} }
return $menu; return $menu;

View file

@ -3,7 +3,7 @@
<div class="header__icons"> <div class="header__icons">
<label class="header__icon header__icon--menu" for="toggle-mobile-header-menu"></label> <label class="header__icon header__icon--menu" for="toggle-mobile-header-menu"></label>
<a class="header__logo{% if is_manage|default(false) %} header__logo--manage{% endif %}" href="/"> <a class="header__logo{% if manage_menu is defined %} header__logo--manage{% endif %}" href="/">
{{ globals.site_name }} {{ globals.site_name }}
</a> </a>
@ -17,6 +17,7 @@
<li class="header__menu__item"> <li class="header__menu__item">
<a href="/" class="header__menu__link">Home</a> <a href="/" class="header__menu__link">Home</a>
<ul class="header__submenu"> <ul class="header__submenu">
<li class="header__submenu__item"><a href="/members.php" class="header__submenu__link">Members</a></li>
<li class="header__submenu__item"><a href="/changelog.php" class="header__submenu__link">Changelog</a></li> <li class="header__submenu__item"><a href="/changelog.php" class="header__submenu__link">Changelog</a></li>
{#<li class="header__submenu__item"><a href="/info.php?t=contact" class="header__submenu__link">Contact</a></li> {#<li class="header__submenu__item"><a href="/info.php?t=contact" class="header__submenu__link">Contact</a></li>
<li class="header__submenu__item"><a href="/info.php?t=rules" class="header__submenu__link">Rules</a></li>#} <li class="header__submenu__item"><a href="/info.php?t=rules" class="header__submenu__link">Rules</a></li>#}
@ -24,9 +25,15 @@
</ul> </ul>
</li> </li>
<li class="header__menu__item"><a href="/news.php" class="header__menu__link">News</a></li> <li class="header__menu__item"><a href="/news.php" class="header__menu__link">News</a></li>
<li class="header__menu__item"><a href="/forum/" class="header__menu__link">Forum</a></li> <li class="header__menu__item">
<a href="/forum/" class="header__menu__link">Forum</a>
{#<ul class="header__submenu">
<li class="header__submenu__item"><a href="#" class="header__submenu__link">Unanswered Posts</a></li>
<li class="header__submenu__item"><a href="#" class="header__submenu__link">New Posts</a></li>
<li class="header__submenu__item"><a href="#" class="header__submenu__link">Your Posts</a></li>
</ul>#}
</li>
<li class="header__menu__item"><a href="https://chat.flashii.net" class="header__menu__link">Chat</a></li> <li class="header__menu__item"><a href="https://chat.flashii.net" class="header__menu__link">Chat</a></li>
<li class="header__menu__item"><a href="/members.php" class="header__menu__link">Members</a></li>
</ul> </ul>
<input type="checkbox" class="header__user-toggle" id="toggle-mobile-header-user"> <input type="checkbox" class="header__user-toggle" id="toggle-mobile-header-user">

View file

@ -2,9 +2,7 @@
{% from 'macros.twig' import pagination %} {% from 'macros.twig' import pagination %}
{% block manage_content %} {% block manage_content %}
<div class="container"> <a href="?v=action" class="input__button">Create new action</a>
<a href="?v=action" class="input__button">Create new action</a>
</div>
<div class="container listing changelog-tags"> <div class="container listing changelog-tags">
{% for action in changelog_actions %} {% for action in changelog_actions %}
@ -19,7 +17,7 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="container container--center"> <div class="pagination__wrapper">
{{ pagination(changelog_actions_count, changelog_take, changelog_offset, '?v=actions') }} {{ pagination(changelog_actions_count, changelog_take, changelog_offset, '?v=actions') }}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -2,9 +2,7 @@
{% from 'macros.twig' import pagination %} {% from 'macros.twig' import pagination %}
{% block manage_content %} {% block manage_content %}
<div class="container"> <a href="?v=change" class="input__button">Create new change</a>
<a href="?v=change" class="input__button">Create new change</a>
</div>
<div class="container listing"> <div class="container listing">
{% for change in changelog_changes %} {% for change in changelog_changes %}
@ -48,7 +46,7 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="container container--center"> <div class="pagination__wrapper">
{{ pagination(changelog_changes_count, changelog_take, changelog_offset, '?v=changes') }} {{ pagination(changelog_changes_count, changelog_take, changelog_offset, '?v=changes') }}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -2,9 +2,7 @@
{% from 'macros.twig' import pagination %} {% from 'macros.twig' import pagination %}
{% block manage_content %} {% block manage_content %}
<div class="container"> <a href="?v=tag" class="input__button">Create new tag</a>
<a href="?v=tag" class="input__button">Create new tag</a>
</div>
<div class="container listing changelog-tags"> <div class="container listing changelog-tags">
{% for tag in changelog_tags %} {% for tag in changelog_tags %}
@ -22,7 +20,7 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="container container--center"> <div class="pagination__wrapper">
{{ pagination(changelog_tags_count, changelog_take, changelog_offset, '?v=tags') }} {{ pagination(changelog_tags_count, changelog_take, changelog_offset, '?v=tags') }}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -0,0 +1 @@
{% extends 'manage/general/master.twig' %}

View file

@ -0,0 +1,7 @@
{% extends 'manage/general/master.twig' %}
{% block manage_content %}
<pre>
{{ log_dump }}
</pre>
{% endblock %}

View file

@ -0,0 +1 @@
{% extends 'manage/general/master.twig' %}

View file

@ -1,7 +1,6 @@
{% extends 'master.twig' %} {% extends 'master.twig' %}
{% from 'manage/macros.twig' import manage_navigation %} {% from 'manage/macros.twig' import manage_navigation %}
{% set title = 'Broom Closet' %} {% set title = 'Broom Closet' %}
{% set is_manage = true %}
{% block content %} {% block content %}
<div class="management"> <div class="management">

View file

@ -3,23 +3,43 @@
{% block manage_content %} {% block manage_content %}
{% if can_manage_roles %} {% if can_manage_roles %}
<div class="container"> <a href="?v=role" class="input__button">Create new Role</a>
<a href="?v=role" class="input__button">Create new Role</a>
</div>
{% endif %} {% endif %}
<div class="container listing role-listing"> <div class="userlist">
{% for role in manage_roles %} {% for role in manage_roles %}
<a href="?v=role&amp;r={{ role.role_id }}" class="listing__entry role-listing__entry"{% if not role.role_colour|colour_get_inherit %} style="{{ role.role_colour|html_colour({'border-color':'%s'}) }}"{% endif %}> <div class="userlist__item">
<div class="listing__entry__content role-listing__entry__content"> <div class="usercard">
{{ role.role_name }} <a href="?v=role&amp;r={{ role.role_id }}"
{{ role.users }} users class="usercard__background"></a>
<div class="usercard__container">
<div class="avatar usercard__avatar"
style="{{ role.role_colour|html_colour({'background-color':'%s'}) }}">
</div>
<div class="usercard__content">
<div class="usercard__name">
{{ role.role_name }}
</div>
<div class="usercard__info">
<span class="usercard__item usercard__item--title">
{{ role.role_title }}
</span>
<span class="usercard__item usercard__item--title">
{{ role.users|number_format }} users
</span>
</div>
</div>
</div>
</div> </div>
</a> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="container container--center"> <div class="pagination__wrapper">
{{ pagination(manage_roles_count, manage_roles_range, manage_roles_offset, '?v=roles') }} {{ pagination(manage_roles_count, manage_roles_range, manage_roles_offset, '?v=roles') }}
</div> </div>
{% endblock %} {% endblock %}

View file

@ -93,8 +93,6 @@
</div> </div>
{% endif %} {% endif %}
<div class="container"> <button class="input__button" name="csrf" value="{{ csrf_token() }}">{{ edit_role is defined ? 'Update role' : 'Create role' }}</button>
<button class="input__button" name="csrf" value="{{ csrf_token() }}">{{ edit_role is defined ? 'Update role' : 'Create role' }}</button>
</div>
</form> </form>
{% endblock %} {% endblock %}

View file

@ -156,18 +156,15 @@
</div> </div>
{% endif %} {% endif %}
<div class="container"> <button class="input__button" name="csrf" value="{{ csrf_token() }}">Update</button>
<button class="input__button" name="csrf" value="{{ csrf_token() }}">Update</button>
</div>
</form> </form>
{% endif %} {% endif %}
{% if can_manage_users %} {% if can_manage_users %}
<div class="container"> {% if has_roles|length > 0 %}
{% if has_roles|length > 0 %} <form method="post" action="" class="container">
<form method="post" action="" style="display:inline-block"> <div class="container__title">Manage Roles</div>
<div class="container__title">Manage Roles</div> <div class="container__content">
<input type="hidden" name="csrf" value="{{ csrf_token() }}"> <input type="hidden" name="csrf" value="{{ csrf_token() }}">
<label class="form__label"> <label class="form__label">
@ -183,17 +180,16 @@
</div> </div>
</label> </label>
<div> <button class="input__button" name="manage_roles[mode]" value="display">Set Display</button>
<button class="input__button" name="manage_roles[mode]" value="display">Set Display</button> <button class="input__button" name="manage_roles[mode]" value="remove">Remove</button>
<button class="input__button" name="manage_roles[mode]" value="remove">Remove</button> </div>
</div> </form>
</form> {% endif %}
{% endif %}
{% if available_roles|length > 0 %}
<form method="post" action="" style="display:inline-block">
<div class="container__title">Add Role</div>
{% if available_roles|length > 0 %}
<form method="post" action="" class="container">
<div class="container__title">Add Role</div>
<div class="container__content">
<label class="form__label"> <label class="form__label">
<div class="form__label__text">Available Roles</div> <div class="form__label__text">Available Roles</div>
<div class="form__label__input"> <div class="form__label__input">
@ -207,11 +203,9 @@
</div> </div>
</label> </label>
<div> <button class="input__button" name="csrf" value="{{ csrf_token() }}">Add</button>
<button class="input__button" name="csrf" value="{{ csrf_token() }}">Add</button> </div>
</div> </form>
</form> {% endif %}
{% endif %}
</div>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -6,7 +6,7 @@
{% include '_layout/meta.twig' %} {% include '_layout/meta.twig' %}
<link href="{{ '/css/mio.css'|asset_url }}" rel="stylesheet"> <link href="{{ '/css/mio.css'|asset_url }}" rel="stylesheet">
<link href="{{ '/css/libraries.css'|asset_url }}" rel="stylesheet"> <link href="{{ '/css/libraries.css'|asset_url }}" rel="stylesheet">
{% if is_manage|default(false) %} {% if manage_menu is defined %}
<link href="{{ '/css/manage.css'|asset_url }}" rel="stylesheet"> <link href="{{ '/css/manage.css'|asset_url }}" rel="stylesheet">
<style> <style>
:root { :root {