moved appearance into account, closes #33
This commit is contained in:
parent
4c5ff241b6
commit
1230cc1f21
8 changed files with 90 additions and 125 deletions
|
@ -277,4 +277,75 @@ class AccountController extends Controller
|
||||||
|
|
||||||
return view('settings/account/ranks', compact('locked'));
|
return view('settings/account/ranks', compact('locked'));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Renders the userpage editing page.
|
||||||
|
*/
|
||||||
|
public function userpage()
|
||||||
|
{
|
||||||
|
// Check permission
|
||||||
|
if (!(
|
||||||
|
CurrentSession::$user->page
|
||||||
|
&& CurrentSession::$user->permission(Site::CHANGE_USERPAGE)
|
||||||
|
) && !CurrentSession::$user->permission(Site::CREATE_USERPAGE)) {
|
||||||
|
throw new HttpMethodNotAllowedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$userpage = $_POST['userpage'] ?? null;
|
||||||
|
$maxLength = config('user.page_max');
|
||||||
|
|
||||||
|
if (session_check() && $userpage) {
|
||||||
|
$redirect = route('settings.account.userpage');
|
||||||
|
|
||||||
|
if (strlen($userpage) > $maxLength) {
|
||||||
|
$message = 'Your userpage is too long, shorten it a little!';
|
||||||
|
} else {
|
||||||
|
DB::table('users')
|
||||||
|
->where('user_id', CurrentSession::$user->id)
|
||||||
|
->update([
|
||||||
|
'user_page' => $userpage,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$message = 'Updated your userpage!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('global/information', compact('message', 'redirect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('settings/account/userpage', compact('maxLength'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the signature changing page.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function signature()
|
||||||
|
{
|
||||||
|
// Check permission
|
||||||
|
if (!CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
|
||||||
|
throw new HttpMethodNotAllowedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$signature = $_POST['signature'] ?? null;
|
||||||
|
$maxLength = config('user.signature_max');
|
||||||
|
|
||||||
|
if (session_check() && $signature) {
|
||||||
|
$redirect = route('settings.account.signature');
|
||||||
|
|
||||||
|
if (strlen($signature) > $maxLength) {
|
||||||
|
$message = 'Your signature is too long, shorten it a little!';
|
||||||
|
} else {
|
||||||
|
DB::table('users')
|
||||||
|
->where('user_id', CurrentSession::$user->id)
|
||||||
|
->update([
|
||||||
|
'user_signature' => $signature,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$message = 'Updated your signature!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('global/information', compact('message', 'redirect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('settings/account/signature', compact('maxLength'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Holds the appearance section controller.
|
|
||||||
* @package Sakura
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Sakura\Controllers\Settings;
|
|
||||||
|
|
||||||
use Phroute\Phroute\Exception\HttpMethodNotAllowedException;
|
|
||||||
use Sakura\CurrentSession;
|
|
||||||
use Sakura\DB;
|
|
||||||
use Sakura\Perms\Site;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appearance settings.
|
|
||||||
* @package Sakura
|
|
||||||
* @author Julian van de Groep <me@flash.moe>
|
|
||||||
*/
|
|
||||||
class AppearanceController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Renders the userpage editing page.
|
|
||||||
*/
|
|
||||||
public function userpage()
|
|
||||||
{
|
|
||||||
// Check permission
|
|
||||||
if (!(
|
|
||||||
CurrentSession::$user->page
|
|
||||||
&& CurrentSession::$user->permission(Site::CHANGE_USERPAGE)
|
|
||||||
) && !CurrentSession::$user->permission(Site::CREATE_USERPAGE)) {
|
|
||||||
throw new HttpMethodNotAllowedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$userpage = $_POST['userpage'] ?? null;
|
|
||||||
$maxLength = config('user.page_max');
|
|
||||||
|
|
||||||
if (session_check() && $userpage) {
|
|
||||||
$redirect = route('settings.appearance.userpage');
|
|
||||||
|
|
||||||
if (strlen($userpage) > $maxLength) {
|
|
||||||
$message = 'Your userpage is too long, shorten it a little!';
|
|
||||||
} else {
|
|
||||||
DB::table('users')
|
|
||||||
->where('user_id', CurrentSession::$user->id)
|
|
||||||
->update([
|
|
||||||
'user_page' => $userpage,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = 'Updated your userpage!';
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('global/information', compact('message', 'redirect'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('settings/appearance/userpage', compact('maxLength'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the signature changing page.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function signature()
|
|
||||||
{
|
|
||||||
// Check permission
|
|
||||||
if (!CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
|
|
||||||
throw new HttpMethodNotAllowedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$signature = $_POST['signature'] ?? null;
|
|
||||||
$maxLength = config('user.signature_max');
|
|
||||||
|
|
||||||
if (session_check() && $signature) {
|
|
||||||
$redirect = route('settings.appearance.signature');
|
|
||||||
|
|
||||||
if (strlen($signature) > $maxLength) {
|
|
||||||
$message = 'Your signature is too long, shorten it a little!';
|
|
||||||
} else {
|
|
||||||
DB::table('users')
|
|
||||||
->where('user_id', CurrentSession::$user->id)
|
|
||||||
->update([
|
|
||||||
'user_signature' => $signature,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = 'Updated your signature!';
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('global/information', compact('message', 'redirect'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('settings/appearance/signature', compact('maxLength'));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -47,6 +47,15 @@ class Controller extends BaseController
|
||||||
if (CurrentSession::$user->permission(Site::ALTER_RANKS)) {
|
if (CurrentSession::$user->permission(Site::ALTER_RANKS)) {
|
||||||
$nav["Account"]["Ranks"] = route('settings.account.ranks');
|
$nav["Account"]["Ranks"] = route('settings.account.ranks');
|
||||||
}
|
}
|
||||||
|
if ((
|
||||||
|
CurrentSession::$user->page
|
||||||
|
&& CurrentSession::$user->permission(Site::CHANGE_USERPAGE)
|
||||||
|
) || CurrentSession::$user->permission(Site::CREATE_USERPAGE)) {
|
||||||
|
$nav["Account"]["Userpage"] = route('settings.account.userpage');
|
||||||
|
}
|
||||||
|
if (CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
|
||||||
|
$nav["Account"]["Signature"] = route('settings.account.signature');
|
||||||
|
}
|
||||||
|
|
||||||
// Friends
|
// Friends
|
||||||
if (CurrentSession::$user->permission(Site::MANAGE_FRIENDS)) {
|
if (CurrentSession::$user->permission(Site::MANAGE_FRIENDS)) {
|
||||||
|
@ -54,17 +63,6 @@ class Controller extends BaseController
|
||||||
$nav["Friends"]["Requests"] = route('settings.friends.requests');
|
$nav["Friends"]["Requests"] = route('settings.friends.requests');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appearance
|
|
||||||
if ((
|
|
||||||
CurrentSession::$user->page
|
|
||||||
&& CurrentSession::$user->permission(Site::CHANGE_USERPAGE)
|
|
||||||
) || CurrentSession::$user->permission(Site::CREATE_USERPAGE)) {
|
|
||||||
$nav["Appearance"]["Userpage"] = route('settings.appearance.userpage');
|
|
||||||
}
|
|
||||||
if (CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
|
|
||||||
$nav["Appearance"]["Signature"] = route('settings.appearance.signature');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
if (CurrentSession::$user->permission(Site::MANAGE_SESSIONS)) {
|
if (CurrentSession::$user->permission(Site::MANAGE_SESSIONS)) {
|
||||||
$nav["Advanced"]["Sessions"] = route('settings.advanced.sessions');
|
$nav["Advanced"]["Sessions"] = route('settings.advanced.sessions');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends 'settings/appearance/master.twig' %}
|
{% extends 'settings/account/master.twig' %}
|
||||||
|
|
||||||
{% set mode = 'Signature' %}
|
{% set mode = 'Signature' %}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
{% block settingsContent %}
|
{% block settingsContent %}
|
||||||
<div class="bbcode" id="settingsPreview" style="max-height: 500px; overflow-y: auto; background: #C2AEEE; box-shadow: inset 0 0 1em 1em #D3BFFF;">{{ user.signature()|raw|nl2br }}</div>
|
<div class="bbcode" id="settingsPreview" style="max-height: 500px; overflow-y: auto; background: #C2AEEE; box-shadow: inset 0 0 1em 1em #D3BFFF;">{{ user.signature()|raw|nl2br }}</div>
|
||||||
<hr class="default">
|
<hr class="default">
|
||||||
<form enctype="multipart/form-data" method="post" action="{{ route('settings.appearance.signature') }}">
|
<form enctype="multipart/form-data" method="post" action="{{ route('settings.account.signature') }}">
|
||||||
<div><textarea name="signature" id="settingsEditor" class="inputStyling" style="width: calc(100% - 12px); height: 400px;">{{ user.signature }}</textarea></div>
|
<div><textarea name="signature" id="settingsEditor" class="inputStyling" style="width: calc(100% - 12px); height: 400px;">{{ user.signature }}</textarea></div>
|
||||||
<div class="profile-save">
|
<div class="profile-save">
|
||||||
<button value="{{ session_id() }}" name="session" class="inputStyling">Save</button>
|
<button value="{{ session_id() }}" name="session" class="inputStyling">Save</button>
|
||||||
|
@ -17,5 +17,5 @@
|
||||||
<button type="button" class="inputStyling" onclick="settingsPreview();">Preview</button>
|
<button type="button" class="inputStyling" onclick="settingsPreview();">Preview</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% include 'settings/appearance/_preview.twig' %}
|
{% include 'settings/account/_preview.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends 'settings/appearance/master.twig' %}
|
{% extends 'settings/account/master.twig' %}
|
||||||
|
|
||||||
{% set mode = 'Userpage' %}
|
{% set mode = 'Userpage' %}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
{% block settingsContent %}
|
{% block settingsContent %}
|
||||||
<div class="bbcode" id="settingsPreview" style="max-height: 500px; overflow-y: auto; background: #C2AEEE; box-shadow: inset 0 0 1em 1em #D3BFFF;">{{ user.userPage()|raw|nl2br }}</div>
|
<div class="bbcode" id="settingsPreview" style="max-height: 500px; overflow-y: auto; background: #C2AEEE; box-shadow: inset 0 0 1em 1em #D3BFFF;">{{ user.userPage()|raw|nl2br }}</div>
|
||||||
<hr class="default">
|
<hr class="default">
|
||||||
<form enctype="multipart/form-data" method="post" action="{{ route('settings.appearance.userpage') }}">
|
<form enctype="multipart/form-data" method="post" action="{{ route('settings.account.userpage') }}">
|
||||||
<div><textarea name="userpage" id="settingsEditor" class="inputStyling" style="width: calc(100% - 12px); height: 400px;">{% if user.page %}{{ user.page }}{% else %}[header]Welcome to my userpage![/header]{% endif %}</textarea></div>
|
<div><textarea name="userpage" id="settingsEditor" class="inputStyling" style="width: calc(100% - 12px); height: 400px;">{% if user.page %}{{ user.page }}{% else %}[header]Welcome to my userpage![/header]{% endif %}</textarea></div>
|
||||||
<div class="profile-save">
|
<div class="profile-save">
|
||||||
<button value="{{ session_id() }}" name="session" class="inputStyling">Save</button>
|
<button value="{{ session_id() }}" name="session" class="inputStyling">Save</button>
|
||||||
|
@ -17,5 +17,5 @@
|
||||||
<button type="button" class="inputStyling" onclick="settingsPreview();">Preview</button>
|
<button type="button" class="inputStyling" onclick="settingsPreview();">Preview</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% include 'settings/appearance/_preview.twig' %}
|
{% include 'settings/account/_preview.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,3 +0,0 @@
|
||||||
{% extends 'settings/master.twig' %}
|
|
||||||
|
|
||||||
{% set category = 'Appearance' %}
|
|
17
routes.php
17
routes.php
|
@ -233,6 +233,10 @@ Routerv1::group(['before' => 'maintenance'], function () {
|
||||||
Routerv1::post('/details', 'Settings.AccountController@details', 'settings.account.details');
|
Routerv1::post('/details', 'Settings.AccountController@details', 'settings.account.details');
|
||||||
Routerv1::get('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
|
Routerv1::get('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
|
||||||
Routerv1::post('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
|
Routerv1::post('/ranks', 'Settings.AccountController@ranks', 'settings.account.ranks');
|
||||||
|
Routerv1::get('/userpage', 'Settings.AccountController@userpage', 'settings.account.userpage');
|
||||||
|
Routerv1::post('/userpage', 'Settings.AccountController@userpage', 'settings.account.userpage');
|
||||||
|
Routerv1::get('/signature', 'Settings.AccountController@signature', 'settings.account.signature');
|
||||||
|
Routerv1::post('/signature', 'Settings.AccountController@signature', 'settings.account.signature');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Friends section
|
// Friends section
|
||||||
|
@ -256,19 +260,6 @@ Routerv1::group(['before' => 'maintenance'], function () {
|
||||||
Routerv1::get('/history', 'Settings.NotificationsController@history', 'settings.notifications.history');
|
Routerv1::get('/history', 'Settings.NotificationsController@history', 'settings.notifications.history');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Appearance section
|
|
||||||
Routerv1::group(['prefix' => 'appearance'], function () {
|
|
||||||
Routerv1::get('/', function () {
|
|
||||||
$route = Routerv1::route('settings.appearance.avatar');
|
|
||||||
return header("Location: {$route}");
|
|
||||||
});
|
|
||||||
|
|
||||||
Routerv1::get('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
|
|
||||||
Routerv1::post('/userpage', 'Settings.AppearanceController@userpage', 'settings.appearance.userpage');
|
|
||||||
Routerv1::get('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
|
|
||||||
Routerv1::post('/signature', 'Settings.AppearanceController@signature', 'settings.appearance.signature');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Advanced section
|
// Advanced section
|
||||||
Routerv1::group(['prefix' => 'advanced'], function () {
|
Routerv1::group(['prefix' => 'advanced'], function () {
|
||||||
Routerv1::get('/', function () {
|
Routerv1::get('/', function () {
|
||||||
|
|
Reference in a new issue